aliens

Author Topic: [Documentation] Close Quarters Combat (CQC)  (Read 7768 times)

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
[Documentation] Close Quarters Combat (CQC)
« 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.

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.
« Last Edit: July 17, 2018, 03:15:42 pm by Meridian »

Offline Starving Poet

  • Colonel
  • ****
  • Posts: 265
    • View Profile
Re: [EXE] Close Quarters Combat
« Reply #1 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


Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [EXE] Close Quarters Combat
« Reply #2 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!

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8597
    • View Profile
Re: [EXE] Close Quarters Combat
« Reply #3 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 )?
« Last Edit: April 24, 2017, 03:15:57 pm by Meridian »

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [EXE] Close Quarters Combat
« Reply #4 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:
  • The inclusion of melee dodge in the calculation is how it takes into account both the firing unit and the defending unit; I take melee dodge to be 'close quarters defense score,' while the shooter has a 'close quarters offense score.'  The goal is to have something like the melee accuracy roll of offense minus defense.
  • I originally did not intend to make it work with stairs, mostly because I thought that would make the search for defending units needlessly complicated, but also because I didn't think it made sense for two units to be in a 'grappling' situation when one was on stairs.
  • I wasn't thinking about 2x2 units without turrets (I specifically excluded units with turrets) when I wrote it... oops.  I agree that 2x2 units should probably be excluded from being both attacker and defender for this code.
  • I don't have a strong opinion on whether melee dodge/defending in close quarters should have a TU cost.  I think it would be too punishing for the defender to lose TUs just from attempted melee/CQB attacks.  On the other hand, having it cost TUs to successfully dodge such an attack but not when it hits/would miss without dodge doesn't make sense to me for the sake of what we're trying to simulate.  Perhaps we should add an optional cost to successful melee dodges?  Since both pieces of code use TileEngine::MeleeAttack to make the check, it probably could be put there. Just set the default cost to 0, let modders decide?

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.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8597
    • View Profile
Re: [EXE] Close Quarters Combat
« Reply #5 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 :)

Offline BTAxis

  • Colonel
  • ****
  • Posts: 149
    • View Profile
Re: [EXE] Close Quarters Combat
« Reply #6 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?

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11408
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [EXE] Close Quarters Combat
« Reply #7 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.

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [EXE] Close Quarters Combat
« Reply #8 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.

Offline mumble

  • Colonel
  • ****
  • Posts: 338
    • View Profile
Re: [EXE] Close Quarters Combat
« Reply #9 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.