Author Topic: X-Com reaction fire mechanics  (Read 36638 times)

Offline wsmithjr

  • Colonel
  • ****
  • Posts: 149
    • View Profile
X-Com reaction fire mechanics
« on: August 08, 2013, 03:58:21 am »
So, a recent mission using .9 stable version of OpenXcom has got me wondering about how exactly it is determined if X-Com units can reaction fire at the aliens.

The situation is that a group of rookies assaulted a Muton Supply Ship.  The Skyranger landed right next to the Supply Ship and only found 1 Muton immediately outside.  So, I figured I'd head on into the ship and let the Mutons come to me.  I stationed 2 rookies at one door, and 3 at the other.  They sat inside the ship watching the doors and did nothing else.  Eventually, the Mutons started entering the ship from outside.  One would enter in, shoot one of my rookies and then leave.  I lost 6 rookies in this manner and at no point did any of the Rookies react and fire back.  I don't have a save game and can't say what kind of reaction stats the rookies had, so the stats may not have been particularly notable, but the fact that they sat there turn after turn and had full TUs but never fired makes me wonder how it all works.

Ufopaedia talks about a concept of "mutual surprise" https://www.ufopaedia.org/index.php?title=Reaction_fire_triggers that indicates for the original that Xcom would be unable to fire after the alien first stumbles into their LOS.  This makes sense, but why would the remained rookies not fire once the Muton guns down one of their buddies as now we have a case of an action that can trigger reaction fire?

I remember in the "good old days" having my guys circling a UFO and having tons of reaction fire each time an alien would attempt to walk out the door.  So, I'm wondering if things work differently in OXC and how to best handle situations such as this.  Is there a better way to guard doorways which would enable your soldiers to fire if this behavior is intentional?  Or has this all changed with the Nightly builds.  I'll try to replicate this scenario using a more recent version and see what happens.

Thanks for any comments.
« Last Edit: August 08, 2013, 04:12:28 am by wsmithjr »

Offline Morbo

  • Squaddie
  • *
  • Posts: 8
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #1 on: August 08, 2013, 07:42:35 am »
Agreed. There is something seriously wrong with reaction fire in 0.9.

I've mind controlled the last alien and stuffed it in the corner and lined up my troops in a V formation trapping the alien. on the next turn, the alien walks around and expends all his TUs and not a single one of my soldiers reaction fires. It seems like only soldiers with 70+ reaction stat perform actual reaction fire, and sometimes even they don't fire.

Offline Hythlodaeus

  • Colonel
  • ****
  • Posts: 276
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #2 on: August 08, 2013, 11:39:02 am »
So, a recent mission using .9 stable version of OpenXcom

There's your problem. Use the nightly.

Offline kharille

  • Colonel
  • ****
  • Posts: 370
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #3 on: August 08, 2013, 12:23:38 pm »
Yeah, yesterday I had 11 guys with assault rifles pinning down 4 mutons, with pistols.  Only 1 or 2 guys reaction fired at reactions 70 and 52.  One of the mutons fired about 5 rounds and then started to wander in the enclosed box.

I can't train my guys properly!

Offline Align

  • Colonel
  • ****
  • Posts: 196
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #4 on: August 08, 2013, 12:28:53 pm »
Reaction-chance is proportional to your TUs as well as your Reactions. If you don't move a guy on a turn he's way more likely to get a reaction shot in, unless his Reactions is exceptionally low.

Offline kharille

  • Colonel
  • ****
  • Posts: 370
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #5 on: August 08, 2013, 01:02:10 pm »
Nah.  I remember the old days, queuing up my guys outside a ufo.  It was a fun action scene with laser blasts flying everywhere.  Now nothing happens.

Maybe I'll try laser pistols next time....

Offline wsmithjr

  • Colonel
  • ****
  • Posts: 149
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #6 on: August 08, 2013, 02:48:03 pm »
I haven't been able to set up the original scenario, but I did start a new game with the latest build and in the first terror mission, I did get reaction shots on Reapers trying to approach me and the like armed with Laser Pistols.  So, it's not like I don't see any reaction fire; I'm just wondering if it's something peculiar to the type of situation indicated above.  I'm wondering if it's pointless to guard doorways like that and need to come up with some different tactics.  Or, maybe things have significantly changed since 0.9 and now it is more effective.

Thanks.

Offline Align

  • Colonel
  • ****
  • Posts: 196
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #7 on: August 08, 2013, 06:37:10 pm »
I think reaction fire got rewritten since 0.9, but don't know if the triggering in itself was affected.

It's definitely possible to set up a bunch of guys to guard a door and have them shoot whatever comes out before it can move, just did it myself twice in a row on the same turn with a pair of Reactions 40-50 rookies.

However, keep in mind that if the alien that pops out has high Reactions and/or most of its TUs left, it'll STILL get the jump on your guys, so reaction fire becomes more unlikely as the aliens become better.

Offline wsmithjr

  • Colonel
  • ****
  • Posts: 149
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #8 on: August 09, 2013, 01:39:49 am »
I think reaction fire got rewritten since 0.9, but don't know if the triggering in itself was affected.

It's definitely possible to set up a bunch of guys to guard a door and have them shoot whatever comes out before it can move, just did it myself twice in a row on the same turn with a pair of Reactions 40-50 rookies.

However, keep in mind that if the alien that pops out has high Reactions and/or most of its TUs left, it'll STILL get the jump on your guys, so reaction fire becomes more unlikely as the aliens become better.

Good to hear.  It makes sense that the stronger aliens would get the drop on us.  I can understand the Muton going in and gunning down a soldier, but if you have several soldiers guarding the door, my question is why the surviving soldiers didn't return fire.  Maybe that could be explained if the other rookies had too low of a Reaction stat even though they had full TUs available.

Thanks.

Offline Morbo

  • Squaddie
  • *
  • Posts: 8
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #9 on: August 09, 2013, 08:26:30 am »
There's your problem. Use the nightly.

Break save game. There's your problem.

Offline Morbo

  • Squaddie
  • *
  • Posts: 8
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #10 on: August 09, 2013, 08:28:46 am »
Reaction-chance is proportional to your TUs as well as your Reactions. If you don't move a guy on a turn he's way more likely to get a reaction shot in, unless his Reactions is exceptionally low.

You didn't read my post. All my guys were at full TU because the previous turn i had MC the alien to trap it in a corner (not literally a corner, but a section of the ship where all he can do is walk around back and forth in front of my troops). None of my guys had moved for 2 straight turns.

I just would like to request it to behave similar to vanilla. One of the most fun parts of vanilla was watching the hail of laser + plasma fire when an unsuspecting alien would walk out of the door. Those fun "moments" don't happen anymore.

Offline kharille

  • Colonel
  • ****
  • Posts: 370
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #11 on: August 09, 2013, 08:46:37 am »
Yeah...  Loved it.  10 guys with laser rifles.  Alien walks out and its like Butch Cassidy and the Sundance kid....

Beautiful....

Offline kkmic

  • Commander
  • *****
  • Posts: 582
  • Undefined
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #12 on: August 09, 2013, 10:09:14 am »
Morbo, the reaction fire code is wrong in the 0.9 game version.

As Hythlodaeus said, use a nightly version. Check the log to see what breaks your saved games and update your savegame to make it work. Better yet, ask Warboy on IRC for help on this.

Keep in mind that this is still a "work-in-progress" software. Some things are broken. Some thinks don't work at all. Some may work as intended.

Help the developers finish the game by using the nightlies and reporting any bug you find. The "stable" versions are beta, and are tested only to insure that you can run the game. They are not a "complete product" and also they are not bug free. Neither are the nightlies, mind you, but by using the them you won't have to deal with bugs that got fixed sometime after the last "stable" release.

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #13 on: September 08, 2013, 07:29:19 am »
sorry to reiterate, but yes, the reaction fire code has been completely re-written to be completely in-line with the original game.

it's fairly easy to update a saved game from 0.9 to the nightly, and it's a LOT easier to do if it's a geoscape save.

Offline djemon_lda

  • Captain
  • ***
  • Posts: 52
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #14 on: September 17, 2013, 01:37:32 am »
@Warboy, or any other openXcom dev:

I've seen the code for the reaction fire (code dwonloaded not longer than 3 days ago), and I think, that this isn't exactly what it was like in the original, and perhaps what is written here isn't what the author had in mind.

Code: [Select]
while (true)
{
if (!tryReactionSnap(reactor, unit))
break;
reactor = getReactor(spotters, unit);
result = true;
if (reactor == unit)
break;
}

The reaciton fire routines finish in two cases:
1) the best "reactor" was unable to fire.
2) all reactors have worse reflexes than the spotted unit.

Only The second case is corresponding to the original implementation. The whole round of checking reaction fire is finished if and only if the spotted unit has the greatest reaction score.
In your algorithm it's either this, or a situation where the shooter fails to shoot the reaction snap, which is fully dependant on what this condition gets evaluated to ( true or false )

if (action.weapon && action.weapon->getAmmoItem() && action.weapon->getAmmoItem()->getAmmoQuantity() && unit->getTimeUnits() >= action.TU)

(the first check btw isn't necessarry and just creates noise - you are using the action.weapon pointer 4 statemnes earlier)

Not knowing your internal architecture with details I cannot say when would the getAmmoItem() return a null pointer, but the rest of the condition tells us, that this returns false when a unit has not enough time units for its action OR the currently considered reactionist is out of ammo.

This in turn means, that if I have sick reactions ( like for example Point Man from FEAR series ), and have exactly one time unit less than I need to fire a time consuming fire action, then none of my buddies will fire.

This makes many situations where good reacionists are stomped by that break invoked because a better reaction guy was unable to perform a shot for whatever reason ( other than problems with line of fire, because this is not checked in the tryReactionSnap as far as I've seen ).

I hope this will help you improve the code and functionality of the product.

Regards,
djemon_lda