OpenXcom Forum

Modding => OpenXcom Extended => OXCE Suggestions DONE => Topic started by: ohartenstein23 on April 20, 2017, 10:59:40 pm

Title: [Documentation] Close Quarters Combat (CQC)
Post by: ohartenstein23 on April 20, 2017, 10:59:40 pm
Hey everyone, I finished coding a feature requested by Dioxine for Piratez, but it could also be useful for those looking for a bit more challenge from the game!  This code adds an extra check when firing a ranged weapon when an enemy is within one of the 8 tiles surrounding the unit firing; if the check fails, the firing unit will be turned up to 90 degrees from the direction they're facing before shooting, to simulate the enemy doing more than just standing there and taking an autoshot with the gun's muzzle buried into their skin.  Don't worry, this check is enabled for aliens attacking your units too, so it's more feasible to block a door with your soldiers!

Under the hood, the weapon firing has a close quarters accuracy, which is multiplied by certain stats of your units.  The melee dodge of the enemy is subtracted from this score, and a 0-100 dice roll is made.  If the roll is greater than your score, the unit has a equal chance of firing straight up, straight down, 45 degrees to the left or right of the unit's current facing, or 90 degrees to the left or right of the unit's current facing.  The parameters open to ruleset are as follows:

Code: [Select]
enableCloseQuartersCombat: 1 # default is 0 to disable this new code, 1 enables it
closeQuartersAccuracyGlobal: 100 # default 100, this sets the default weapon close quarters combat accuracy - bump it up to make your soldiers less crappy at 1 tile!

items:
  - type: STR_RIFLE
    accuracyCloseQuarters: 125 # this overrides the global default, so you can make weapons better and worse at close range
    closeQuartersMultiplier: # determines which stats get used for the close quarters combat score, defaults to (melee+reactions) / 2 if not defined on an item
      melee: 0.5
      reactions: 0.5

extraStrings:
  - type: en-US
    strings:
      STR_FAILED_CQB_CHECK: "Failed Close Quarters Combat Check!"

See the source code commit in my repository here (https://github.com/ohartenstein23/OpenXcom/commit/3bab53fcd9177fbd0c6937b36c4a2947bd5d3a87).

Thanks to the new upload size, I've also attached a Windows .exe for those brave enough to try it out!  The zip file contains the new executable and the above ruleset file to put in a mod for testing.

Edit 171110: This is an official part of OXCE+, so the links for my repository above are deprecated.  This post will remain for documentation.
Title: Re: [EXE] Close Quarters Combat
Post by: Starving Poet on April 24, 2017, 06:06:25 am
two questions I forgot to ask earlier : Does this mean that i would be more likely to hit a unit from 2 tiles away (which I guess is pretty standard for attacking melee units)?  Also,  does it take into account ctrl-clicking past the unit?

Sent from my KFGIWI using Tapatalk

Title: Re: [EXE] Close Quarters Combat
Post by: ohartenstein23 on April 24, 2017, 02:51:10 pm
Whether or not it's better to fire from 2 tiles away depends on both the target and the unit firing - if you have high melee/reactions and poor accuracy, it'd probably be better to fire from 1 tile.  And yes, it takes into account firing not directly at a unit within 1 tile, an enemy can even mess up your aim if you're trying to shoot at their buddy!
Title: Re: [EXE] Close Quarters Combat
Post by: Meridian on April 24, 2017, 03:10:18 pm
Does this mean that i would be more likely to hit a unit from 2 tiles away (which I guess is pretty standard for attacking melee units)?

Yes, definitely.
I just tried it with a random gal and osiron security standing next to each other in quick battle... nobody hit each other for 2 whole turns :)

New best cover: right in front of your enemy :P

Also,  does it take into account ctrl-clicking past the unit?

Yes, any enemy unit in your vicinity can disrupt your shot... not only the target unit (there doesn't even have to be a target unit).
Even if they have no TUs left lol.



Other things I noticed:
- melee dodge is used too... why? isn't the new "close combat dodge" enough?
- doesn't work with stairs (i.e. when the disrupting unit's Z-level is +1 compared to your unit)
- turning 45 degrees is not enough... if you turn 45 degrees when facing a 2x2 unit, you can/will still hit it
- 2x2 units in general should probably be completely excluded from this... I can't imagine a universe in which a puny G.O. dodges/disrupts my mutated reaper's acid spit
- disrupting a shot in close combat doesn't cost any TUs... it should at least cost TUs... just like reaction fire for example... the unit didn't have time to run away or to shoot at you, but can magically still disrupt your shots? That's BS. (And yes, I know melee dodge doesn't cost anything either... in my opinion it should too).

In general, I have to say I'm not impressed by the idea.

Forgetting the idea itself, the implementation is fine, I'll merge it later today.
One question tho: why is finding a nearby unit around you done in such a complicated way? (start in front, check twice, go clockwise and counter-clockwise in parallel checking once; and then check your back, twice again). Is this order necessary/by design, or can we just check let's say clockwise, each tile once in a single loop ( facing + 0..7 % 8 )?
Title: Re: [EXE] Close Quarters Combat
Post by: ohartenstein23 on April 24, 2017, 05:26:20 pm
Yes, definitely.
I just tried it with a random gal and osiron security standing next to each other in quick battle... nobody hit each other for 2 whole turns :)

Yes, I admit that the default numbers are quite harsh.  I fully intend it to be toned down as it's balanced.

For your other points:

About the check - in the case of multiple units within 1 tile of the attacker, I wanted the code to prioritize units closer to the front of the attacker, working around on both sides to the back, rather than just a clockwise search.  The double-checking front and back was just me not wanting to write special cases for those.
Title: Re: [EXE] Close Quarters Combat
Post by: Meridian on April 24, 2017, 05:40:56 pm
About the check - in the case of multiple units within 1 tile of the attacker, I wanted the code to prioritize units closer to the front of the attacker, working around on both sides to the back, rather than just a clockwise search.  The double-checking front and back was just me not wanting to write special cases for those.

OK, searching twice doesn't matter that much at the moment, since only one unit will ever be checked at the end.

... which makes me ask... is that correct/by design? If there are 8 units around you, shouldn't they all be checked? Common-sense-wise, 8 people would have a higher chance to disrupt your actions than just 1 guy... unless you're Neo, or Chuck Norris or Jason Statham or Uma Thurman :)
Title: Re: [EXE] Close Quarters Combat
Post by: BTAxis on April 24, 2017, 07:18:23 pm
Also shouldn't facing matter? I mean, can you effectively disrupt someone's fire if they're standing behind you? Or is this overthinking it?
Title: Re: [EXE] Close Quarters Combat
Post by: Solarius Scorch on April 24, 2017, 07:19:55 pm
Also shouldn't facing matter? I mean, can you effectively disrupt someone's fire if they're standing behind you? Or is this overthinking it?

Right, does melee-from-the-back penalty apply? It's not clear to me from the description.
Title: Re: [EXE] Close Quarters Combat
Post by: ohartenstein23 on April 24, 2017, 08:04:09 pm
Yes, melee dodge is taken according to the facing of the defending unit, so if they're facing away, they will have a lower defense score.
Title: Re: [EXE] Close Quarters Combat
Post by: mumble on May 17, 2017, 01:46:07 am
I tried this recently in "xcom files" and its a great concept, but the idea that it costs no TU's I think is a little strange.

For how it could work, I imagine you could have maybe, a 1% TU chance to check, and actually grabbing would take say, 5%.

Alternatively, could it be coded so it was a couple dice rolls, like one with reactions to see if its ATTEMPTED, and then one with melee and all that to see if its successful, with an attempted success and attempted fail both consuming the same TUs? Its a little silly reactions play no part in this, as I figure it would be more important than melee, in a sense,. and I figure a high melee person with terrible reactions would not be able to avoid point blank shots as easy as an insane reactions person with mediocre melee.

Also, sorry for borderline necro, but wanted to put in my 2 cents... There was also a crash involving this mechanic I posted about in the xcom files bug report section : only happened once, but I suspect it might of been an issue with this.