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

Offline kevL

  • Colonel
  • ****
  • Posts: 482
  • pitchforks and torches
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #30 on: September 22, 2013, 05:58:13 am »
tryReactionSnap() breaks the loop (through potential shooters) when it returns false. It returns true

Code: [Select]
if (action.weapon
&& action.weapon->getAmmoItem()
&& action.weapon->getAmmoItem()->getAmmoQuantity()
&& unit->getTimeUnits() >= action.TU)

hence, if any of those are false, the loop exits prematurely, possibly leaving some reactors that are eligible to fire unable to fire.


I've sparsed down my commit ( and at present still stand by it ) It looks like this:

Code: [Select]
for (std::vector<BattleUnit*>::iterator i = spotters.begin(); i != spotters.end(); ++i)
{
if (tryReactionSnap(reactor, unit))
{
result = true;
}

reactor = getReactor(spotters, unit);
if (reactor == unit)
{
break;
}
}

Note that getReactor() returns whoever has initiative.



& here's how the base mission went:

Offline Mysyk

  • Squaddie
  • *
  • Posts: 4
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #31 on: September 23, 2013, 08:07:58 pm »
Does it still don't work?

Offline kevL

  • Colonel
  • ****
  • Posts: 482
  • pitchforks and torches
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #32 on: September 23, 2013, 10:18:30 pm »
the way i understand it now, when deciding who gets initiative, a so-called vector is made up of all units that spot the victim. There will be an order or sequence of those units: check #1 to see if he can react, check #2 etc etc.

If and when a unit in that vector fails to meet the reaction requirements (a loaded gun + able to make a snapshot) then the loop or sequence-checking stops short.

On redv's save above, the current code and my change give the same results (because all the soldiers are topped up on ammo + tu)


I think Sup is waiting for someone with more knowledge of the craziness that is xCom combat to have a looksee...

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: X-Com reaction fire mechanics
« Reply #33 on: September 24, 2013, 12:32:42 am »
so you are saying that if you have ten soldiers lined up and the first one (in the "vector") doesn't have a gun, nobody will reaction-fire?

Offline kevL

  • Colonel
  • ****
  • Posts: 482
  • pitchforks and torches
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #34 on: September 24, 2013, 01:19:37 am »
i think so -- it's what to watch for

I'll try some more tests w/ output to Log later, see what shows up


( my real debugger is hanging on an unhandled exception..:\ )

Offline kevL

  • Colonel
  • ****
  • Posts: 482
  • pitchforks and torches
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #35 on: September 24, 2013, 03:12:44 am »
current code works.

units won't get added to the vector unless they are capable of making a snaphot!

- will withdraw my PR


(now, if you want to talk messy, convoluted and redundant ( welcome to c++ ) that's a different cake)




ps. sry khar my bad..
« Last Edit: September 24, 2013, 03:40:17 am by kevL »

Offline Align

  • Colonel
  • ****
  • Posts: 196
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #36 on: September 24, 2013, 03:08:41 pm »
Only snapshots? Does that mean no more reaction-fired blasterbombs? Because those were funny but annoying.

Offline djemon_lda

  • Captain
  • ***
  • Posts: 52
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #37 on: September 24, 2013, 04:42:38 pm »
Quote
(now, if you want to talk messy, convoluted and redundant ( welcome to c++ ) that's a different cake)

this isn't a thing of c++, it is a thing of bad coders. I have seen better written and more readable assembly code, than java. it is not a problem of any language - it is always a problem of how the programmer is able to express their thoughts and the process of coding. there is no (and will never be any ) language on earth for example that will make a thought process put into file look good when it is by the algorithm : "ok, so I will change/add this fully or semi random thing, and will check if it works..."


Offline Mysyk

  • Squaddie
  • *
  • Posts: 4
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #38 on: September 24, 2013, 08:22:06 pm »
How can I fix it?

Offline Shadow

  • Captain
  • ***
  • Posts: 75
  • Veteran Lieutenant
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #39 on: October 08, 2013, 04:54:58 pm »
What's the status on this? I'm using the latest nightly to date, and reactions don't seem to work very well for my guys.

I can get reaction-fired upon by a Sectoid for so much as kneeling (on Veteran), but it's really hard for my men to surprise an alien with any kind of reliability.

Reaction fire was crucial in the original game, and not only for door camping. A good portion of my kills in it was due to it given how I advanced across the field carefully, using scouts and HWPs as spotters and keeping many shooters with TUs so to deal with enemies that would come into range. Active, manual, spotter-aided firing was only half of that strategy.
« Last Edit: October 08, 2013, 05:03:09 pm by Shadow »

Offline Sharp

  • Colonel
  • ****
  • Posts: 181
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #40 on: October 08, 2013, 08:31:16 pm »
On Veteran difficulty aliens have higher stats, sectoids will have around 60 TU's and 70 reaction which will be more then any rookie. Just keeping a unit on reserve to fire a snap-shot doesn't mean they will fire a snap-shot  if they don't have a lot of TU's as their initiative will be lower

Initiative = Reaction * (CurrentTU/MaxTU)

You want the people who take/avoid reaction shots to have high TU's and high reactions so any movement will lower their Iniative less, and generally try to keep them moving a little.

Leap-frogging can work in XCOM but you need to take the leaps over two turns instead of doing it in one turn for reaction fire to take place, but even then it can be hard to make it work well. I normally use reserve fire for units to move around to make sure they can shoot an alien if they spot one but I will move them into good positions before the turn ends instead of hoping to get a reaction shot.

Offline Shadow

  • Captain
  • ***
  • Posts: 75
  • Veteran Lieutenant
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #41 on: October 08, 2013, 08:49:33 pm »
I've had more success against Floaters just now. Maybe they're slower on the trigger, but I managed to get a satisfying number of reaction-fired laser shots off in my last terror mission.

A bunch of those were good hits, to boot. There's nothing quite like a good reaction-fire kill. 8)

Offline Mysyk

  • Squaddie
  • *
  • Posts: 4
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #42 on: October 09, 2013, 03:34:49 pm »
Sharp. Don't forget about Stamina. Good tactic is to exhaust aliens during their turn. Good idea to use smoke grenades, especially near UFO gates. Aliens will spend all their TU and possibly stamina when they show themselves from smoke. They won't be able to shoot and our troops will reaction fire on them.
Isn't it working in OpenXCom?

Offline Nevill

  • Squaddie
  • *
  • Posts: 7
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #43 on: November 04, 2013, 08:59:30 am »
This wasn't really my playthrough, so I can't verify this (and thus can't place this in the bug tracker), but was the issue of the game not checking your stats correctly when you were fired at during your turn fixed in any of the nightly builds?

To better understand what I am talking about, see this:
https://www.dailymotion.com/video/x16qvdp_o-alienbase-01_music?start=75

At around 01:21, the soldier gets reaction fired at with a Stun Launcher. He does not lose consciousness until another soldier takes a shot during the same turn at 02:24.

Offline Danny

  • Colonel
  • ****
  • Posts: 204
    • View Profile
Re: X-Com reaction fire mechanics
« Reply #44 on: November 04, 2013, 12:19:07 pm »
Does the mutual surprise rule still counts in OpenXcom?