Author Topic: Reaction vs Melee Enable  (Read 14890 times)

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Reaction vs Melee Enable
« Reply #15 on: May 06, 2020, 10:37:26 pm »
But you do not need change any thing in OXCE, is not enabled by default but code still allow to enable it by scripts.

Offline peirceg

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Reaction vs Melee Enable
« Reply #16 on: May 07, 2020, 07:12:18 am »
What lines do I need to edit for https://github.com/MeridianOXC/OpenXcom/blob/oxce-plus/src/Battlescape/TileEngine.cpp#L2012   ?

It was unfortunately never mentioned and I cant write c++ so I dont know where to look.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9098
    • View Profile
Re: Reaction vs Melee Enable
« Reply #17 on: May 07, 2020, 10:21:39 am »
As the link says, line 2012.

Offline peirceg

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Reaction vs Melee Enable
« Reply #18 on: May 07, 2020, 11:50:15 am »
I am seeing this at line 2012

int reactionChance = BA_HIT != originalAction.type ? 100 : 0;

What should I edit now?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9098
    • View Profile
Re: Reaction vs Melee Enable
« Reply #19 on: May 07, 2020, 11:57:44 am »
change the reaction chance from 0 to 100 maybe?

Offline peirceg

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Reaction vs Melee Enable
« Reply #20 on: May 07, 2020, 11:59:00 am »
Thank you! I will see if it works.

Offline peirceg

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Reaction vs Melee Enable
« Reply #21 on: May 07, 2020, 01:51:59 pm »
After building, I got this file OpenXcom.2010.vcxproj successfully built, where is the .exe? What should I do with this newly built file?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9098
    • View Profile
Re: Reaction vs Melee Enable
« Reply #22 on: May 07, 2020, 01:54:26 pm »
Have you ever built anything?

If not, nothing I say will help you.
If yes, you should not need our help.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Reaction vs Melee Enable
« Reply #23 on: May 07, 2020, 09:36:28 pm »
I am seeing this at line 2012

int reactionChance = BA_HIT != originalAction.type ? 100 : 0;

What should I edit now?

This line set default behavior that script will read and change, you do not need change this source code, only add mod that will have script like:
Code: [Select]
extended:
  scripts:
    reactionUnitAction:
      - offset: -10
        code: |
          if eq battle_action battle_action_hit;
            set reaction_chance 100;
          end;
          return reaction_chance;

Offline peirceg

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Reaction vs Melee Enable
« Reply #24 on: May 08, 2020, 03:29:31 am »
By the way which hand does the game prioritise when making a reaction shot? Or is it random?

Offline vadracas

  • Colonel
  • ****
  • Posts: 285
  • Just another player/modder combo.
    • View Profile
Re: Reaction vs Melee Enable
« Reply #25 on: May 08, 2020, 03:37:33 am »
Good question, will check tomorrow, see if Meridian answers this as fast as he normally does. I swear that he must have somehow memorized the codebase. 8)

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9098
    • View Profile
Re: Reaction vs Melee Enable
« Reply #26 on: May 08, 2020, 10:22:58 am »
Game prefers:
1. melee weapons
2. if not found, melee attack of ranged weapons (gunbutt)
3. if not found, ranged weapons with snapshot

For AI, weapon with quickest  snapshot; for xcom main (=last used) weapon.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9098
    • View Profile
Re: Reaction vs Melee Enable
« Reply #27 on: May 08, 2020, 10:30:23 am »
Btw. I've added some experimental support for reactions to melee attacks.

Configurable via global switch

Code: [Select]
constants:
  extendedMeleeReactions: 2     # default 0

0 = vanilla, cannot react to melee attacks
1 = can react to melee attacks, if attacked from the front... same effect as Yankes' script above
2 = can react to melee attacks, if attacked from any side

PS: The scripts can change the % chance to perform a melee reaction in all 3 cases. But only with option "2" the reaction from any side can be triggered, that's not scriptable (yet).

PPS: turn on only if you're 120% sure you want it
« Last Edit: May 14, 2020, 05:29:04 pm by Meridian »

Offline peirceg

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Reaction vs Melee Enable
« Reply #28 on: May 08, 2020, 04:10:50 pm »
Will units also react to movement in tiles other than the one directly in front of them?

Offline vadracas

  • Colonel
  • ****
  • Posts: 285
  • Just another player/modder combo.
    • View Profile
Re: Reaction vs Melee Enable
« Reply #29 on: May 08, 2020, 04:21:49 pm »
No, and that wouldn't make sense anyway.