Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: phreak on November 13, 2006, 11:59:48 pm

Title: Not bad for two hours work
Post by: phreak on November 13, 2006, 11:59:48 pm
See for yourself.  Yes all 6 of the trebs are homing, I don't have fraps so it doesn't really look like it from a still photo.

(http://fs2source.warpcore.org/exes/phreak/salvo_fire.jpg)

I'll have a test build out in a week or so, i'm busy IRL and hacked something up in a couple hours

features


bugs

Title: Re: Not bad for two hours work
Post by: WMCoolmon on November 14, 2006, 12:30:03 am
Sweet!!!

This is exactly what's been bothering me about the way that I've got weapons set up in scripting. Are you setting it up to work by toggling each individual bank in the ship_weapons struct? This is IMHO the best way for it to work, since it would allow me to add a variable in scripting that would let you toggle each weapon bank on/off individually.
Title: Re: Not bad for two hours work
Post by: phreak on November 14, 2006, 12:42:05 am
no i did it the straight forward way of giving each ship an additional flag (SF2_SECONDARY_LINKED) and then in ship_fire_secondary() just changed

Code: [Select]
bank = swp->current_secondary_weapon;

to this

Code: [Select]
for (bank = 0; bank < swp->num_secondary_banks; bank++)
{
if (bank != swp->current_secondary_bank && !ship_is_secondary_linked_with(shipp, bank, 1))
continue;
//...

where ship_is_secondary_linked_with() is some helper function that comares shipp's current secondary weapon with the secondary residing in index of shipp->weapons.secondary_bank_weapons[bank].  The third argument tells the function to ignore ammo counts when processing the link (only used for the hud stuff (drawing the extra triangles).  The function would return non-zero if the two weapons are linkable

Code: [Select]
int ship_is_secondary_linked_with(ship* shipp, int other_secondary_bank, int ignore_ammo)
{
ship_weapon* swp = &shipp->weapons;

//this could be bad if we don't check for this
if (other_secondary_bank < 0)
return 0;

//this could also be bad
if (other_secondary_bank >= swp->num_secondary_banks)
return 0;

//if the ship doesn't have the linked secondary flag set, bail
if (!(shipp->flags2 & SF2_SECONDARY_LINKED))
return 0;

//if the weapon types are different, return the two weapons can't be linked
if (swp->secondary_bank_weapons[swp->current_secondary_bank] != swp->secondary_bank_weapons[other_secondary_bank])
return 0;

//if either of the banks has no ammo, the two weapons can't be linked
if (swp->secondary_bank_ammo[swp->current_secondary_bank] == 0 && !ignore_ammo)
return 0;

if (swp->secondary_bank_ammo[other_secondary_bank] == 0 && !ignore_ammo)
return 0;

//TODO:
//if the currently selected secondary weapon has the "no link" flag, bail.

//looks goods
return 1;

}
Title: Re: Not bad for two hours work
Post by: Trivial Psychic on November 14, 2006, 04:58:49 am
How well does the AI know how to use it?
Title: Re: Not bad for two hours work
Post by: phreak on November 14, 2006, 12:35:43 pm
Good question.  I'll put that in the "bugs" section.