ok I've gotten after burner trails to work, they still need some tweakage, and some of the values I am going to recode so they can be specifyed through the ships table, but the main bulk of the code I have done now shouldn't change too much
allright in ShipContrails.cpp I added a bunch of new functions wich do basicly the same thing as the ones in there now but rather than doing the nebula trails it does the ABtrails
new forward declairations (these go at the top of the file right under the ones there now)
// determine if the ship has AB trails
int ct_has_ABtrails(ship *shipp);
// update active ABtrails - moving existing ones, adding new ones where necessary
void ct_update_ABtrails(ship *shipp);
// create new ABtrails
void ct_create_ABtrails(ship *shipp);
made changes to ct_ship_create so it will initalise both neb trails and ABtrails
// call when a ship is created to initialize its contrail stuff
void ct_ship_create(ship *shipp)
{
int idx;
Assert(shipp != NULL);
// null out the ct indices for this guy
for(idx=0; idx shipp->trail_num[idx] = (short)-1;
}
for(idx=0; idx shipp->ABtrail_num[idx] = (short)-1;
}
}
a similar thing here
// call when a ship is deleted to free up its contrail stuff
void ct_ship_delete(ship *shipp)
{
int idx;
Assert(shipp != NULL);
// free up any contrails this guy may have had
for(idx=0; idx if(shipp->trail_num[idx] >= 0){
trail_object_died(shipp->trail_num[idx]);
shipp->trail_num[idx] = (short)-1;
}
if(shipp->ABtrail_num[idx] >= 0){
trail_object_died(shipp->ABtrail_num[idx]);
shipp->ABtrail_num[idx] = (short)-1;
}
}
}
add this to the first line in ct_ship_process
ct_ship_process_ABtrails(shipp);//seems like as good a place as any -Bobboau
here's the real meat of the code, the ABtrail proces, creation, and updateing code, this is all below everything else
// call each frame for processing a ship's ABtrails
void ct_ship_process_ABtrails(ship *shipp)
{
int idx;
object *objp;
Assert(shipp != NULL);
Assert(shipp->objnum >= 0);
objp = &Objects[shipp->objnum];
// if this is not a ship, we don't care
if((objp->type != OBJ_SHIP) || (Ship_info[Ships[objp->instance].ship_info_index].ct_count <= 0)){
return;
}
Assert(objp->instance >= 0);
shipp = &Ships[objp->instance];
if(!(objp->phys_info.flags & PF_AFTERBURNER_ON)){ //if the after burners aren't on -Bobboau
for(idx=0; idx trail_object_died(shipp->ABtrail_num[idx]);
shipp->ABtrail_num[idx] = (short)-1;
}
}
// if the object already has ABtrails
if(ct_has_ABtrails(shipp)){
ct_update_ABtrails(shipp);
}
// otherwise add new ones
else {
ct_create_ABtrails(shipp);
}
/* if(shipp->ab_info->stamp > timestamp( (int)(shipp->ab_info->max_life * 1000) ) ){
for(idx=0; idx if(shipp->ABtrail_num[idx] >= 0){
trail_object_died(shipp->ABtrail_num[idx]);
shipp->ABtrail_num[idx] = (short)-1;
}
}
}
*/
}
// create new ABtrails
void ct_create_ABtrails(ship *shipp)
{
vector v1;
int idx;
matrix m;
ship_info *sip;
object *objp;
// get object and ship info
Assert(shipp != NULL);
Assert(shipp->objnum >= 0);
Assert(shipp->ship_info_index >= 0);
objp = &Objects[shipp->objnum];
sip = &Ship_info[shipp->ship_info_index];
// get the inverse rotation matrix
vm_copy_transpose_matrix(&m, &objp->orient);
if(objp->phys_info.flags & PF_AFTERBURNER_ON){//AB trails-Bobboau
for(idx=0; idxab_count; idx++){
shipp->ABtrail_num[idx] = (short)trail_create(shipp->ab_info[idx]);
// get the point for the contrail
vm_vec_rotate(&v1, &shipp->ab_info[idx].pt, &m);
vm_vec_add2(&v1, &objp->pos);
// if the spew stamp has elapsed
if(trail_stamp_elapsed(shipp->ABtrail_num[idx])){
trail_add_segment(shipp->ABtrail_num[idx], &v1);
trail_set_stamp(shipp->ABtrail_num[idx]);
} else {
trail_set_segment(shipp->ABtrail_num[idx], &v1);
}
}
/* if( objp == Player_obj){
HUD_printf("trailnum %d", shipp->ABtrail_num[0]);
}
*/
}
}
// update active ABtrails - moving existing ones, adding new ones where necessary
void ct_update_ABtrails(ship *shipp)
{
vector v1;
matrix m;
int idx;
ship_info *sip;
object *objp;
// get object and ship info
Assert(shipp != NULL);
Assert(shipp->objnum >= 0);
Assert(shipp->ship_info_index >= 0);
objp = &Objects[shipp->objnum];
sip = &Ship_info[shipp->ship_info_index];
// get the inverse rotation matrix
vm_copy_transpose_matrix(&m, &objp->orient);
for(idx=0; idx if(objp->phys_info.flags & PF_AFTERBURNER_ON){//ABtrails
if(shipp->ABtrail_num[idx] >= 0){
// get the point for the contrail
vm_vec_rotate(&v1, &shipp->ab_info[idx].pt, &m);
vm_vec_add2(&v1, &objp->pos);
// if the spew stamp has elapsed
if(trail_stamp_elapsed(shipp->ABtrail_num[idx])){
trail_add_segment(shipp->ABtrail_num[idx], &v1);
trail_set_stamp(shipp->ABtrail_num[idx]);
} else {
trail_set_segment(shipp->ABtrail_num[idx], &v1);
}
}
}
}
}
// if a ship has active ABtrails
int ct_has_ABtrails(ship *shipp)
{
int idx;
for(idx=0; idx if(shipp->ABtrail_num[idx] >= 0){
return 1;
}
}
// no contrails
return 0;
}
add this to the end of ShipContrails.h
// call each frame for processing a ship's contrails
void ct_ship_process_ABtrails(ship *shipp);
// determine if the ship has AB trails
int ct_has_ABtrails(ship *shipp);
// update active ABtrails - moving existing ones, adding new ones where necessary
void ct_update_ABtrails(ship *shipp);
// create new ABtrails
void ct_create_ABtrails(ship *shipp);
there now you have all the code for handeling the trails, but we still need to make chages to the ship structure in ship.h
these need to be added
short ABtrail_num[MAX_SHIP_CONTRAILS]; //after burner trails -Bobboau
trail_info ab_info[MAX_SHIP_CONTRAILS];
int ab_count;
now this following code is subject to change, it assigns the inital values for the ABtrails, things like position are going to remain hard coded, things like the bitmap and posably max life are defonantly going into the table, things like width alpha, I might make a factoring value
this goes into ship_create down near the bottom just before the ct_ship_create(shipp);
trail_info *ci;
//first try at ABtrails -Bobboau
shipp->ab_count = 0;
//if(sip->flags & SIF_AFTERBURNER){
for(int h = 0; h < pm->n_thrusters; h++){
for(int j = 0; j < pm->thrusters->num_slots; j++){
// this means you've reached the max # of AB trails for a ship
Assert(sip->ct_count <= MAX_SHIP_CONTRAILS);
ci = &shipp->ab_info[shipp->ab_count++];
// ci = &sip->ct_info[sip->ct_count++];
ci->pt = pm->thrusters[h].pnt[j];//offset
ci->w_start = pm->thrusters[h].radius[j];//width
ci->w_end = 0.05f;//end width
ci->a_start = 1.0f;//start alpha
ci->a_end = 0.0f;//end alpha
ci->max_life = 5.0f;//max life
ci->stamp = 60; //spew time???
ci->bitmap = bm_load("ABtrail");
//loading this bitmap as default for now,
//I might add this to the afterburner section of the ships.tbl later
}
}
//}//end AB trails -Bobboau
remember my executable is right
here, also in there are the other things I have done to date, the code is currently being beta tested, make sure you have no mods instaled and make a new pilot,
you stand about a %50 chance of this not crashing good luck