OK, I have gotten it to fire from all slots in all banks if they are linked,
this is the targeting beam procesing function, replace the exsisting one with this
void ship_process_targeting_lasers()
{
beam_fire_info fire_info;
ship_obj *so;
ship *shipp;
polymodel *m;
// interate over all ships
for ( so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so) ) {
shipp = &Ships[Objects[so->objnum].instance];
polymodel *po = model_get( Ship_info[shipp->ship_info_index].modelnum );
//if (shipp->targeting_laser_bank != 2)
int num_slots = po->gun_banks[shipp->targeting_laser_bank].num_slots;
// sanity checks
if(so->objnum < 0){
continue;
}
if(Objects[so->objnum].type != OBJ_SHIP){
continue;
}
if(Objects[so->objnum].instance < 0){
continue;
}
// if our trigger is no longer down, switch it off
if(!(shipp->flags & SF_TRIGGER_DOWN)){
ship_stop_targeting_laser(shipp);
continue;
}
// if we have a bank to fire - fire it
//for nonlinked
if((shipp->targeting_laser_bank >= 0) && (shipp->targeting_laser_bank < 2)){
// try and get the model
m = model_get(shipp->modelnum);
if(m == NULL){
continue;
}
// fire a targeting laser
for ( int j = 0; j < num_slots; j++ ){
fire_info.accuracy = 0.0f;
fire_info.beam_info_index = shipp->weapons.primary_bank_weapons[shipp->targeting_laser_bank];
fire_info.beam_info_override = NULL;
fire_info.shooter = &Objects[shipp->objnum];
fire_info.target = NULL;
fire_info.target_subsys = NULL;
fire_info.turret = NULL;
fire_info.targeting_laser_offset = m->gun_banks[shipp->targeting_laser_bank].pnt[j];
shipp->targeting_laser_objnum = beam_fire_targeting(&fire_info);
// hmm, why didn't it fire?
if(shipp->targeting_laser_objnum < 0){
Int3();
ship_stop_targeting_laser(shipp);
}
}
//for linked
//if primarys are linked and we have already fired the first bank
//and the second bank is also a fighter beam, fire fighter beams
//from all fireing points in the second bank
if((shipp->flags & SF_PRIMARY_LINKED) && (shipp->targeting_laser_bank == 0) && (shipp->weapons.primary_bank_weapons[1] >= 0) && (Weapon_info[shipp->weapons.primary_bank_weapons[1]].wi_flags & WIF_BEAM) && (Weapon_info[shipp->weapons.primary_bank_weapons[1]].b_info.beam_type == BEAM_TYPE_C)){
int num_slots = po->gun_banks[1].num_slots;
for ( int j = 0; j < (num_slots); j++ ){
fire_info.accuracy = 0.0f;
fire_info.beam_info_index = shipp->weapons.primary_bank_weapons[1];
fire_info.beam_info_override = NULL;
fire_info.shooter = &Objects[shipp->objnum];
fire_info.target = NULL;
fire_info.target_subsys = NULL;
fire_info.turret = NULL;
fire_info.targeting_laser_offset = m->gun_banks[1].pnt[j];
shipp->targeting_laser_objnum = beam_fire_targeting(&fire_info);
// hmm, why didn't it fire?
if(shipp->targeting_laser_objnum < 0){
Int3();
ship_stop_targeting_laser(shipp);
}
}
}
}
}
}
also, I have changed part of the fire primary functin wich is what calls the start_targetting_laser function, and in an (failed) effort to get AI ships to fire it I moved it to line 5121, or thereabouts, you can probly put this in were it is suposed to be, most stuff that may not make sence in this is all trying to get AI to fire,
// if this is a targeting laser, start it up
//fighterbeams
if((shipp->flags & SF_TRIGGER_DOWN)){
if((winfo_p->wi_flags & WIF_BEAM) && (winfo_p->b_info.beam_type == BEAM_TYPE_C) ){
shipp->weapons.flags |= SW_FLAG_BEAM_FREE;
if(shipp->weapon_energy > 0.0f)
swp->next_primary_fire_stamp[shipp->targeting_laser_bank] = timestamp(0);
if(shipp->weapon_energy < 0.0f)
swp->next_primary_fire_stamp[shipp->targeting_laser_bank] = timestamp(1000);
if( (shipp->weapon_energy > 0.0f) && (swp->next_primary_fire_stamp[shipp->targeting_laser_bank] == timestamp(0))){
ship_start_targeting_laser(shipp);
if ( sound_played != winfo_p->launch_snd ) {
sound_played = winfo_p->launch_snd;
if ( obj == Player_obj ) {
if ( winfo_p->launch_snd != -1 ) {
weapon_info *wip;
ship_weapon *swp;
// HACK
if(winfo_p->launch_snd == SND_AUTOCANNON_SHOT){
snd_play( &Snds[winfo_p->launch_snd], 0.0f, 1.0f, SND_PRIORITY_TRIPLE_INSTANCE );
} else {
snd_play( &Snds[winfo_p->launch_snd], 0.0f, 1.0f, SND_PRIORITY_MUST_PLAY );
}
// snd_play( &Snds[winfo_p->launch_snd] );
swp = &Player_ship->weapons;
if (swp->current_primary_bank >= 0) {
wip = &Weapon_info[swp->primary_bank_weapons[swp->current_primary_bank]];
joy_ff_play_primary_shoot((int) ((wip->armor_factor + wip->shield_factor * 0.2f) * (wip->damage * wip->damage - 7.5f) * 0.45f + 0.6f) * 10 + 2000);
}
}
}
else {
if ( winfo_p->launch_snd != -1 ) {
snd_play_3d( &Snds[winfo_p->launch_snd], &obj->pos, &View_position );
}
}
}
}
/*
if ( !timestamp_elapsed(swp->next_primary_fire_stamp[shipp->targeting_laser_bank]) ) {
if (timestamp_until(swp->next_primary_fire_stamp[shipp->targeting_laser_bank]) > 5000){
swp->next_primary_fire_stamp[shipp->targeting_laser_bank] = timestamp(1000);
}
}
*/
polymodel *po = model_get( Ship_info[shipp->ship_info_index].modelnum );
//if (shipp->targeting_laser_bank != 2)
int num_slots = po->gun_banks[shipp->targeting_laser_bank].num_slots;
//if (shipp->targeting_laser_bank == 2)
//int num_slots = po->gun_banks[0].num_slots +po->gun_banks[1].num_slots;
/* if ( ship_weapon_maybe_fail(shipp) && !force) {
if ( obj == Player_obj ) {
if ( ship_maybe_play_primary_fail_sound() ) {
}
}
continue;
}*/
shipp->weapon_energy -= num_slots*winfo_p->energy_consumed;
if(shipp->weapon_energy < 0.0f){
swp->next_primary_fire_stamp[shipp->targeting_laser_bank] = timestamp(1000);
if ( obj == Player_obj )
ship_maybe_play_primary_fail_sound();
shipp->weapon_energy = 0.0f;
ship_stop_targeting_laser(shipp);
}
continue;
}
}
I still want to get a bit of a delay after the primary weapons energy runns out, but I can't figure out how to use the timestamp stuff, havn't realy given it as much atention as the AI problem, wich is starting to piss me off, I hear the other ships weapon sounds, so I know it's getting at least as far as ship_start_targeting_laser(shipp); meaning the AI is trying to fire it but I can't figure out were exactly it screws up, it should work, it works for the player ship, might be fun to se if this works in multi-player, I think I need some more experienced programer to at least find were the AI ships are messing