Author Topic: Unarmed combat  (Read 6153 times)

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Unarmed combat
« on: August 04, 2019, 11:28:57 am »
I was thinking of adding a possibility for soldiers to hit enemies with bare hands. Just for fun mostly, and as a complementary thing to Gun Melee mod. Seeing as a pistol deals 25 melee damage in that mod, I think it's reasonable to make unarmed damage equal to strength/4. I made the following ruleset, but I seem to be missing something, because it doesn't work:

Code: [Select]
soldiers:
  - type: XCOM
    meleeWeapon: XCOM_WEAPON
items:
  - type: XCOM_WEAPON
    weight: 0
    clipSize: -1
    damageType: 7
    accuracyMelee: 100
    tuMelee: 30
    battleType: 3
    fixedWeapon: true
    recover: false
    damageBonus:
      strength: 0.25

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: Unarmed combat
« Reply #1 on: August 04, 2019, 11:31:30 am »
Soldiers don't have a meleeWeapon attribute.

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Unarmed combat
« Reply #2 on: August 04, 2019, 11:45:51 am »
Is there any way around this then?

And by the way, aliens do have this attribute, so if I give them the unarmed attack with this method (for after they drop their weapons), it is gonna work, I suppose?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: Unarmed combat
« Reply #3 on: August 04, 2019, 12:43:39 pm »
1/ Yes, both XcomFiles and Piratez have unarmed combat, check there... I assume it was done via built-in-weapons per armor. Not sure.

2/ Probably, best to test.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11727
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Unarmed combat
« Reply #4 on: August 04, 2019, 01:19:27 pm »
Yes, that's how it works in X-Com Files. The unarmed attack is determined by the armour, as there are several different melee "weapons" for different types of armour: standard unarmed, armoured gloves, power suit, etc.

For example on basic suit (which is the starting outfit in XCF), the item entry looks like this:

Code: [Select]
items:
  - type: STR_UNARMED_SUIT
    weight: 0
    bigSprite: 822
    meleeHitSound: 109
    meleeAnimation: 0
    power: 0
    damageType: 6
    damageBonus:
      strength: 0.2
      melee: 0.2
      reactions: 0.1
    damageAlter:
      RandomType: 1
      FixRadius: 0
      IgnoreDirection: false
      ArmorEffectiveness: 1.5
      ToHealth: 0.15
    accuracyMelee: 100
    meleeMultiplier:
      melee: 0.5
      reactions: 0.5
    confMelee:
      name: STR_PUNCH
    costMelee:
      time: 8
      energy: 2
    flatRate: true
    battleType: 3
    clipSize: -1
    experienceTrainingMode: 13
    invWidth: 2
    invHeight: 2
    fixedWeapon: true
    recover: false
    specialUseEmptyHand: true

The key property is "specialUseEmptyHand: true", which means that this weapon is activated if you click on an empty hand slot.

The item entry must also be declared on the armour:

Code: [Select]
armors:
  - type: STR_SUIT_UC
    specialWeapon: STR_UNARMED_SUIT

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Unarmed combat
« Reply #5 on: August 04, 2019, 01:56:37 pm »
Thanks! It's a very helpful example. I also found this: https://openxcom.org/forum/index.php?topic=6289.0

For my personal use I will probably make the damage dependent on strength only, without melee and reactions: I prefer to keep things simple. But the idea about stun damage with only 15% of the damage going to the target health (if I understood the code correctly) is very nice :)

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Unarmed combat
« Reply #6 on: August 04, 2019, 07:15:19 pm »
Hm, with soldiers it works, but with aliens not. Neither with meleeWeapon (I thought it would work since this seems to be the method for Lobstermen), nor with adding specialWeapon through armor. Has anyone added unarmed attacks to aliens?

On second thought, do I even need to try to add them that ability? Is it supported by AI? I mean, some terrorist species attack you in melee, but sentient species do not seem to attack in melee even when they do have this ability, via Gun Melee mod. I tried unloading their weapons and throwing away the clips under mind control, and while they are mind controlled, I can make them attack in melee with unloaded guns, but when the control is returned to the AI, they are just hanging around without trying to hit the soldiers, even if they are on adjacent tiles.
« Last Edit: August 04, 2019, 07:38:14 pm by Kzer-Za »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11727
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Unarmed combat
« Reply #7 on: August 04, 2019, 10:03:59 pm »
Yes, the AI uses such weapons fairly well. Please post your code for the weapon and the armour.

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Unarmed combat
« Reply #8 on: August 05, 2019, 11:44:29 am »
I have tried to ways. Number one:

Code: [Select]
units:
  - type: STR_SNAKEMAN_SOLDIER
    stats:
      reactions: 120
      melee: 120
      psiStrength: 1 # for testing purposes, to make them easier to MC
    meleeWeapon: SNAKEMAN_SOLDIER_WEAPON

items:
  - type: SNAKEMAN_SOLDIER_WEAPON
    weight: 0
    power: 5
    clipSize: -1
    damageType: 7
    accuracyMelee: 110
    tuMelee: 30
    battleType: 3
    fixedWeapon: true
    recover: false
    damageBonus:
      strength: 0.25

Number two:

Code: [Select]
units:
  - type: STR_SNAKEMAN_SOLDIER
    stats:
      reactions: 120
      melee: 120
      psiStrength: 1 # for testing purposes, to make them easier to MC

items:
  - type: SNAKEMAN_SOLDIER_WEAPON
    weight: 0
    power: 5
    clipSize: -1
    damageType: 7
    accuracyMelee: 110
    tuMelee: 30
    battleType: 3
    fixedWeapon: true
    recover: false
    damageBonus:
      strength: 0.25
    specialUseEmptyHand: true

armors:
  - type: SNAKEMAN_ARMOR0
    specialWeapon: SNAKEMAN_SOLDIER_WEAPON

Neither one is working. What's more, they don't even use guns for melee, as I have already said, and I didn't mess with items apart from installing Alien Armoury expanded and adding melee attacks to the new weapons that didn't have them — but I didn't touch the weapons that already had melee attacks due to Gun Melee mod, i.e. all original weapons like plasma rifle and heavy plasma, but aliens do not use (for melee, I mean) even them.

Besides, they do not pick up their weapons either, though I enabled mod Aliens Pick Up Weapons.

openxcom.log has no errors or warnings.

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Unarmed combat
« Reply #9 on: August 06, 2019, 12:04:29 am »
I'm very sorry about the confusion I must have caused, it was my lack of attention. Changes for soldiers and enemy units are in separate files, and I forgot to change the extension of the second file from txt to rul. Now that I changed it, the unarmed attacks work. Though I still don't understand why they do not pick up weapons, even lying under their feet, even with "pickUpWeaponsMoreActively: 1".

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11727
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Unarmed combat
« Reply #10 on: August 06, 2019, 12:42:48 am »
Are you sure you have the right syntax?

Code: [Select]
ai:
  pickUpWeaponsMoreActively: true

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Unarmed combat
« Reply #11 on: August 06, 2019, 07:08:07 pm »
If it is in the ai section, wouldn't it also affect terror units? I don't wot chryssalids running around picking up weapons :) So I used it on a per unit basis, i.e. like this:

Code: [Select]
units:
  - type: STR_SNAKEMAN_SOLDIER
    stats:
      pickUpWeaponsMoreActively: 1

According to this (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Items), it can be used this way.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11727
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Unarmed combat
« Reply #12 on: August 06, 2019, 08:52:53 pm »
Chryssalids etc. have no inventory. :P

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: Unarmed combat
« Reply #13 on: August 06, 2019, 08:58:35 pm »
If it is in the ai section, wouldn't it also affect terror units? I don't wot chryssalids running around picking up weapons :) So I used it on a per unit basis, i.e. like this:

Code: [Select]
units:
  - type: STR_SNAKEMAN_SOLDIER
    stats:
      pickUpWeaponsMoreActively: 1

According to this (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Items), it can be used this way.

where is it written it belongs under "stats"?

if you're not sure about the syntax, better use the ruleset validator: https://openxcom.org/forum/index.php/topic,6552.0.html

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Unarmed combat
« Reply #14 on: August 06, 2019, 09:48:13 pm »
Chryssalids etc. have no inventory. :P

Oh, I didn't know that :)