project-navigation
Personal tools

Author Topic: Reaction Fire Fix  (Read 3005 times)

Offline TDarklighter

  • Rookie
  • ***
  • Posts: 12
    • View Profile
Reaction Fire Fix
« on: June 30, 2010, 06:52:10 am »
I'm not sure if we're allowed to modify the code, but I believe I've found a fix for the "No Reaction Fire" issue that a lot of people are having and want to submit it.  This may not work for everyone, but it did make a change for me.  This fix requires modifying a source code file, so be careful not to fool around with anything else unless you REALLY REALLY know what you're doing.  This was all done with code I found in 2.2.1's g_combat.c - all I did was compare notes and copy and paste what seemed to be missing.

The process:
Open up the reaction.c module with a C editor (Pelles C is what I use), and then scroll down until you find the entry of:

/* see how quickly ent can fire (if it can fire at all) */
tus = G_ReactionFireGetTUsForItem(ent, target, RIGHT(ent));
if (tus < 0)
  continue;

Replace the first line under the "see how quickly" comment with this:

tus = G_ReactionFireGetTUsForItem(ent, target, NULL, RIGHT(ent));

Also, at the end of:
/* An enemy entering the line of fire of a soldier on reaction
* fire should have the opportunity to spend time equal to the
* sum of these values. */
ent->reactionTUs = max(0, target->TU - (tus / 4.0));
ent->reactionNoDraw = qfalse;

Add the line:
queued = qtrue;

Put it between the last line and the } mark right below it.

The result:
My soldiers now occasionally make reaction fire.  I ran through three battles like this and there was at least one instance where my guys shot in response to being shot at.  It was worth it just to see them defend themselves finally. :)  I'm not sure how to make them fire with a left-handed weapon, but the three reactions I clearly remember were one flamethrower (cooked a bloodspider), and two laser pistol shots: One from my Lance-Corporal and one from one of my rifleman-ranked guys.  Both missed, but it was pretty to see, lol.

Hope this helps!  Awesome game, guys, and great work.  Keep it coming! :)

Offline Hertzila

  • Sergeant
  • *****
  • Posts: 469
    • View Profile
Re: Reaction Fire Fix
« Reply #1 on: June 30, 2010, 02:37:00 pm »
This is an open-source game, so modifying the code is not only allowed but actually recommended. It might not make it into the official version, that's all.

Ildamos

  • Guest
Re: Reaction Fire Fix
« Reply #2 on: July 01, 2010, 02:31:02 pm »
Quote
My soldiers now occasionally make reaction fire.  I ran through three battles like this and there was at least one instance where my guys shot in response to being shot at.

Still shatters the game's atmosphere. Keep it going though; who knows maybe you can whip up a fix that will go into the next version?

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Reaction Fire Fix
« Reply #3 on: July 01, 2010, 07:32:14 pm »
i'm sorry - that won't compile - G_ReactionFireGetTUsForItem only accepts 3 parameters, not 4 - also why not just post a diff? checked out the svn version? use tortoise svn to generate a diff.

Offline TDarklighter

  • Rookie
  • ***
  • Posts: 12
    • View Profile
Re: Reaction Fire Fix
« Reply #4 on: July 14, 2010, 03:15:13 am »
I've fooled with it some more and still can't quite make it work just right.  It's the compile issue - I'm not sure it was the NULL at all now, but rather the qtrue line I mentioned.

Something interesting to note is that when I leave enough TUs for one or two more reaction snap shots, my guys will take a reaction shot up TO the amount saved for TUs, and then stop.  I'm taking a guess here, but I think the issue lies in a combination of range, accuracy, and spare time units.  If the reaction will take time units that will drop the TU total below the amount being saved for reaction fire, the soldier will not shoot.  (A paradox, I realize, but it seems to be a common occurance)  When I save more than enough, the soldier will shoot, even at range and down to roughly 40% accuracy, but very very rarely anything below that.  I think the amount of cover the target has plays a good part in whether the soldier will fire at it, which I understand is by design.  I'd rather my guy not waste bullets on a wall. ;)

I admit I'm still growing familiar with the code, so I don't yet fully understand everything I'm working with; in specific how the reservation system works for saving TUs to reaction fire.  I'll keep experimenting when time allows and see if I can come up with something more solid.  In the meantime, I'll submit any future postings of changes in a diff or at least in the form of a file.