OpenXcom Forum
Modding => Released Mods => XPiratez => Topic started by: peirceg on May 04, 2020, 09:15:07 am
-
Is there any way for to enable reaction shots/strikes with melee weapons against melee weapon strikes? A nice simple edit somewhere?
-
Yes, here: https://github.com/OpenXcom/OpenXcom/blob/master/src/Battlescape/MeleeAttackBState.cpp#L171
-
Thank you very much! How can I incorporate this into my game? What files do I have to edit? Sorry for being a newb.
-
How can I incorporate this into my game?
Edit, compile, run.
What files do I have to edit?
file MeleeAttackBState.cpp at lines 172-175
-
Yes, here: https://github.com/OpenXcom/OpenXcom/blob/master/src/Battlescape/MeleeAttackBState.cpp#L171
Is this already enabled in OXCE?
-
Is this already enabled in OXCE?
no
-
I couldnt find the MeleeAttackBState.cpp file in my xpiratez download folder. I am going to assume that I need to download a seperate OXCE from somewhere?
-
I couldnt find the MeleeAttackBState.cpp file in my xpiratez download folder. I am going to assume that I need to download a seperate OXCE from somewhere?
Nope, this is c++ code, you have to fork OXC/OXCE on GitHub, and make that edit on it, then compile it according to the instructions on the OXCE subforum except substituting your fork for meridian's link.
-
I couldnt find the MeleeAttackBState.cpp file in my xpiratez download folder. I am going to assume that I need to download a seperate OXCE from somewhere?
PirateZ has a compiled version of OXCE, not the source code.
Also for OXCE, it's in a difference file: https://github.com/MeridianOXC/OpenXcom/blob/oxce-plus/src/Battlescape/TileEngine.cpp#L2012
-
Just want to confirm, because I am very new to this,
1.Create a fork on github for this https://github.com/OpenXcom/OpenXcom/blob/master/src/Battlescape/MeleeAttackBState.cpp#L171
2. Delete lines 171-175 then commit those changes
3 Follow instructions here about compiling https://openxcom.org/forum/index.php/topic,7048.0.html
Replace stage 2 here with the link to my newly forked version ;
"1. Download, install and update Visual Studio 2019 Community Edition: https://visualstudio.microsoft.com/downloads/
2. Clone OXCE repo: https://github.com/MeridianOXC/OpenXcom.git
3. Download and extract the pre-compiled dependencies (into repo's root): openxcom-deps-win-vc2017-newest.zip
4. Open solution "src/OpenXcom.2010.sln"
5. Click "Build" from menu or toolbar"
4. Compile then overwrite with the newly compiled OXCE into my xpiratez folder.
-
2. Delete lines 171-175 then commit those changes
All steps are correct except the quoted ones, don't delete the lines, just remove the comments from the code, other than the obvious comment at the start.
Comments are the // symbols.
-
All steps are correct except the quoted ones, don't delete the lines, just remove the comments from the code, other than the obvious comment at the start.
Comments are the // symbols.
https://imgur.com/a/KOpEddH
I am going to assume that this is now correct? I am going to assume with these edits units will not be able to reaction fire with their equipped weapons when engaged by enemies in melee?
-
https://imgur.com/a/KOpEddH
I am going to assume that this is now correct? I am going to assume with these edits units will not be able to reaction fire with their equipped weapons when engaged by enemies in melee?
Units WILL be able to react with those edits
-
sorry had a bit of brainfar, its pretty late here. Thanks a lot for your help guys. I didnt like my melee units standing defenceless as they got whapped on by aliens in their turn.
-
Just want to confirm, because I am very new to this,
1.Create a fork on github for this https://github.com/OpenXcom/OpenXcom/blob/master/src/Battlescape/MeleeAttackBState.cpp#L171
2. Delete lines 171-175 then commit those changes
3 Follow instructions here about compiling https://openxcom.org/forum/index.php/topic,7048.0.html
This is if you want OXC.
If you want OXCE, you need to download a different repo and change different file and different line... as written above.
The rest is OK.
PS: no need to fork unless you want to publish your changes, downloading existing repo is enough
-
But you do not need change any thing in OXCE, is not enabled by default but code still allow to enable it by scripts.
-
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.
-
As the link says, line 2012.
-
I am seeing this at line 2012
int reactionChance = BA_HIT != originalAction.type ? 100 : 0;
What should I edit now?
-
change the reaction chance from 0 to 100 maybe?
-
Thank you! I will see if it works.
-
After building, I got this file OpenXcom.2010.vcxproj successfully built, where is the .exe? What should I do with this newly built file?
-
Have you ever built anything?
If not, nothing I say will help you.
If yes, you should not need our help.
-
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:
extended:
scripts:
reactionUnitAction:
- offset: -10
code: |
if eq battle_action battle_action_hit;
set reaction_chance 100;
end;
return reaction_chance;
-
By the way which hand does the game prioritise when making a reaction shot? Or is it random?
-
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)
-
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.
-
Btw. I've added some experimental support for reactions to melee attacks.
Configurable via global switch
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
-
Will units also react to movement in tiles other than the one directly in front of them?
-
No, and that wouldn't make sense anyway.
-
Aliens react to movement already. Trying to stab someone in the back or running past them should provoke a reaction but I digress.
-
Aliens react to movement already. Trying to stab someone in the back or running past them should provoke a reaction but I digress.
Of course stabbing someone in the back would provoke a reaction, but if they don't see you, moving around behind them wouldn't. Unless we're bringing sound into this game which has been suggested(and rejected) before.
-
Will units also react to movement in tiles other than the one directly in front of them?
The units react only to units they see (90 degrees cone) or units that have hit/shot them (even if they are not in the cone).
With the new option = 2, they will also react to units that have attempted melee attack on them (both hit and miss count!).
So theoretical situation like this is possible:
1. you melee attack a Lobsterman from behind... hit or miss, doesn't matter
2. Lobsterman has low TU and poor reactions, so it won't attack you immediately.... but it WILL remember you
3. now you run away from Lobsterman (outside of his vision range)... slowly decreasing your TUs
4. as soon as you have low enough TU, the Lobsterman will turn around and shoot at you
Enjoy the pain.
-
Scenario above illustrated with reactions 100 and full TU.
Just rename `lobster.mp4.txt` to `lobster.mp4`
-
So in the situation detailed above, which sounds wonderful btw, will they also react to you moving and coming into melee range if you move into melee range in their 90 degree arc (if they have high reactions), the three tiles directly in front of them with a melee attack-potentially before you do a melee attack?
-
So in the situation detailed above, which sounds wonderful btw, will they also react to you moving and coming into melee range if you move into melee range in their 90 degree arc, the three tiles directly in front of them with a melee attack?
They've always done that...
-
So they will react to movement with a melee attack of their own if a unit just steps into melee range in their 90 degree front arc?
-
They've always done that...
they reacted with melee only from 1 tile, directly in front of them... for the other 2 tiles they reacted with a snapshot
now they can react with melee on all 3 tiles (assuming the new setting = 2)... or to be precise on all 8 tiles around them
-
Fantastic option, makes certain weapons that reduce TUs really useful now.
-
Ive also noted that in CQC situations pistols are preferred to a melee weapon, is this intentional?
-
Ive also noted that in CQC situations pistols are preferred to a melee weapon, is this intentional?
Depends on the modder.
-
Was stumped for a bit when "Ranged" melee weapons were not activating on reactions (Barbarian Sword etc), realized that the gauntlets on certain armors were taking priority. I edited the gauntlets to act as ranged weapons with a melee component (both are effectively the same when selected except one has a crosshair icon). Is there anyway to get rid of one of the selections?.
Anyways after testing it seems to work, units use their ranged melee weapons if available, then their gauntlet weapons.
-
Was stumped for a bit when "Ranged" melee weapons were not activating on reactions (Barbarian Sword etc), realized that the gauntlets on certain armors were taking priority. I edited the gauntlets to act as ranged weapons with a melee component (both are effectively the same when selected except one has a crosshair icon). Is there anyway to get rid of one of the selections?.
Anyways after testing it seems to work, units use their ranged melee weapons if available, then their gauntlet weapons.
Both aren't effectively the same as one Is affected by cqc.
-
How can i match the cqc multiplier to be effectively the same?
-
Melees don't use CQB, they use melee dodge, which is just an accuracy reduction based on target stats.
You could make the formula for enemy CQB similar to the formula for melee dodge, and give the weapon a CQB multiplier and high accuracy to make it similarly likely to hit. But it's impossible to make them very similar.
-
Guess Ill just save myself the hassle and not use the ranged version. Reactions are based on the melee segment anyways. Is there any way to get the ranged version to not display?
*Just worked it out just needed to delete all references to Snapshots autoshots etc, it acts like a gun without the gun part now.