DGun Behavior change

DGun Behavior change

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

DGun Behavior change

Post by aegis »

Related to this, this and this.

A content dev was trying to implement a dgun-like weapon in a unit, and was told to just use the canDGun=1 tag on the unit with commandfire=1 on the weapon.

This presented a problem, however, when he went to fire the unit's dgun... for you see, dgunning fired *all* of the weapons on the unit.
He came to me, and we tried several things.

We first looked at the *A commanders' unit scripts, and it seems they use a static var to block the laser from aiming while the dgun is aiming (so only one can fire at the same time). We tried this and it didn't work for some reason, so I looked to the forums and the engine source code for answers.

After following code around until I found where the engine decides whether to fire a weapon... I found some lovely code, which basically said:
if we are dgunning, or the unit can't dgun, or the weapon isn't commandfire, fire the weapon.
This means all weapons will fire on dgun.
I think that kinda defeats the purpose of the dgun tag if you have to hack support into the unit script ;)

I thought the logic should actually be:
if we are firing normally, and the unit and weapon can dgun, don't fire this weapon.
if we are dgunning, and the unit and weapon can dgun, fire this weapon.
I made a patch to change the firing logic, and it works with every dgun unit I could find except the gimp/corapmh (which could dgun before my patch, although the dgun just fired the normal laser. now dgun does nothing but the laser and torpedo still seem to function normally).

I'm not perfect at testing, so I'm releasing a windows build of the current release spring (0.81.2.1) with my patch applied, to reduce raging in case I messed something up.

Enjoy: http://aegis.eat-peet.net/spring-dgun.7z
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: DGun Behavior change

Post by Pressure Line »

I always thought that the 'dgun' weapon HAD to be weapon3 (as well as being a dgun and commandfire) mebbe someone changed something?
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: DGun Behavior change

Post by aegis »

went back to 2005 in github.

the exact same logic has been used for checking which weapons to fire for the past five years.
dgun weapons haven't worked properly for a long time (dgunning fired ALL weapons)
the *A commander used a script hack to fix this.
Post Reply

Return to “Engine”