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
-
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
- Like weapon types are linked upon pressing the dual-fire secondary key again. (eg single-dual-savlo-single-etc..)
- There will be a weapon flag to be able to disallow this on weapons of your choice. maybe could be the other way around, where you need the flag to enable it. As it stands its kind of overpo--- i mean awesome.
- If no salvoable missile banks are available, behavior reverts to the standard single-dual-single action.
- Awesome hud arrows to show which banks are linked
bugs
- If the main bank runs out of ammo before the linked ones, the linked ones won't fire until you switch over to them
- The AI is oblivious to these changes. Which is understandable, since the AI is dumb.
-
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.
-
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
bank = swp->current_secondary_weapon;
to this
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
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;
}
-
How well does the AI know how to use it?
-
Good question. I'll put that in the "bugs" section.