Author Topic: Not bad for two hours work  (Read 2873 times)

0 Members and 1 Guest are viewing this topic.

Offline phreak

  • Gun Phreak
  • 211
  • -1
Not bad for two hours work
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.



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.
« Last Edit: November 14, 2006, 12:36:46 pm by phreak »
Offically approved by Ebola Virus Man :wtf:
phreakscp - gtalk
phreak317#7583 - discord

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: Not bad for two hours work
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.
-C

 

Offline phreak

  • Gun Phreak
  • 211
  • -1
Re: Not bad for two hours work
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;

}
Offically approved by Ebola Virus Man :wtf:
phreakscp - gtalk
phreak317#7583 - discord

 

Offline Trivial Psychic

  • 212
  • Snoop Junkie
Re: Not bad for two hours work
How well does the AI know how to use it?
The Trivial Psychic Strikes Again!

 

Offline phreak

  • Gun Phreak
  • 211
  • -1
Re: Not bad for two hours work
Good question.  I'll put that in the "bugs" section.
Offically approved by Ebola Virus Man :wtf:
phreakscp - gtalk
phreak317#7583 - discord