Author Topic: Wounds proportional to damage [OXCE]  (Read 9219 times)

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Wounds proportional to damage [OXCE]
« on: August 22, 2019, 10:42:46 am »
The original formula for calculation of the amount of received wounds is rather illogical. In one hit you receive from one to three wounds, with the exact amount being absolutely independent from the amount of damage. You can receive 3 wounds if the threshold of 10 hit points is exceeded by just 1 HP, and at the same time you can't get more than 3 wounds (in one hit), even if the hit has dealt 50 damage (suppose your soldier had 60 HP, so he survived that hit). Furthermore, that 50-damage hit can leave you with 1 wound with the same probability as with 3 wounds! (And an 11-damage hit can leave you with 3 wounds with, again, the same probability).

It bugged me a lot, so I decided to make this tweak that distributes the wounds proportionately to the lost HP. If I were more meticulous, I would even made it so that the amount of wounds received grew with the lost HP exponentially (like the difference between 0 and 10 lost HP would result in 1 wound, but the difference between 30 and 40 lost HP would mean about 5 wounds), but being lazy as I am, I just went with even distribution: for every 5 HP lost you receive 1 wound, as simple as that. This, of course, is also true for all units that can be wounded (if you enabled "Alien bleeding" in advanced options of the game).

There is one difference between the aliens and the humans though: humans will die the moment they have 10 fatal wounds, even if they still have some HP left. I decided against extending this mechanic to aliens, since most of them are either mentioned in UFOpaedia for their survival abilities, like Snakemen, or are enhanced in some way, or, in case of Ethereals, are not even supposed to be able to survive without their psychic powers (which would also enable them to withstand fatal wounds, I suppose). The only species for which dying upon receiving a certain amount of fatal wounds would make sense is Sectoids, but they already have rather few HP, so I didn't want to make them even more wimpy.

The mechanic with 1 wound per 5 lost HP should work on all weapons, even those added by other mods. The mechanic with 10 fatal wounds works only as long as you use vanilla armors, so if you have some additional armors from other mods, you would have to make the adjustments yourself. (Or you can leave a comment here with the id of the armor, and I would add it to the list). I also covered the civilian armors (including the civilians from the "Armed Civilians" mod), in case you increased the amount of HP civilians have.

In case you want some weapon to be more/less likely to inflict wounds, you can give this weapon a tag SPECIAL_WOUND if it does not use any clips like laser weapons or melee weapons. If it has a clip, give this tag to the clip.
For example:

Code: [Select]
items:
  - type: STR_SOME_WEAPON_OR_CLIP
    tags:
      SPECIAL_WOUND: 1

  - type: STR_SOME_OTHER_WEAPON_OR_CLIP
    tags:
      SPECIAL_WOUND: 2
      WOUND_FACTOR: 3

The weapon/clip with "SPECIAL_WOUND: 1" would either use the vanilla formula for wound amount, or you can adjust it with "damageAlter" in this item's ruleset as explained here:
https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Power_and_Damage_types
and here:
https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Item_Damage_Types

The weapon/clip with "SPECIAL_WOUND: 2" needs to be given one more tag: WOUND_FACTOR. The value you assign to this tag means how many hitpoints will be lost by the unit damaged with that item before a wound is inflicted. For example, "WOUND_FACTOR: 3" means that the item will give one wound per three HP.

I wouldn't be able to create this mod without the great help from Yankes.

Upd. Attached version 1.1
« Last Edit: August 28, 2019, 03:32:27 pm by Kzer-Za »

Offline efrenespartano

  • Commander
  • *****
  • Posts: 760
  • I know a lot about the law and other lawyerings.
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #1 on: August 23, 2019, 03:20:00 pm »
Very interesting, indeed. Looking forward for more scripts of you, mate. :)

Question: how does it work with damageAlter (specifically with ToWound and RandomWound)

Question 2: Can I use this on my mods? ;D
My shotguns are lacking some stopping and wounding power. ;)

Enviado desde mi LG-M400 mediante Tapatalk
« Last Edit: August 23, 2019, 03:28:16 pm by efrenespartano »

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #2 on: August 23, 2019, 10:46:11 pm »
1. It overrides ToWound and RandomWound. But if you want for some specific weapon to have a different wound calculation, you can give this weapon a tag SPECIAL_WOUND equal to 1 (see readme) and specify damageAlter with ToWound and RandomWound.

2. Of course, you are welcome :)

Offline efrenespartano

  • Commander
  • *****
  • Posts: 760
  • I know a lot about the law and other lawyerings.
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #3 on: August 23, 2019, 11:24:20 pm »
1. It overrides ToWound and RandomWound. But if you want for some specific weapon to have a different wound calculation, you can give this weapon a tag SPECIAL_WOUND equal to 1 (see readme) and specify damageAlter with ToWound and RandomWound.

2. Of course, you are welcome :)
Nice!

Question 3: does it work on ammo? (battleType: 2). I have a weapon system where one ammo type has better armor piercing capabilities and the other ammo type has better wounding chance.

Enviado desde mi LG-M400 mediante Tapatalk


Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #4 on: August 24, 2019, 11:47:47 am »
Currently, no. It simply takes the amount of damage inflicted to health, divides it by 5, and sets the amount of woulds equal to the received figure. Perhaps, what you want is doable, but as I have already mentioned, I'm lazy :)

If you want to add this feature yourself, then you need to edit the script damageUnit and probably get the ammo used for the shot with "damaging_item.getAmmoItem" (I'm not sure), and add a condition depending on whether this ammo has a tag, which you will also need to add to the description of this ammo. I think, this could work.

Offline efrenespartano

  • Commander
  • *****
  • Posts: 760
  • I know a lot about the law and other lawyerings.
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #5 on: August 26, 2019, 02:28:29 am »
Hahaha I don't know how to write code, so I'll wait to you. xD

Question 4: What if I define a number higher than 1 with the tag SPECIAL_WOUND?

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #6 on: August 26, 2019, 07:18:39 am »
The script will just treat the weapon with this tag as "not special", as if it had no such tag. I inserted only a check for SPECIAL_WOUND=1, because any weapon that does not have this tag is gonna have this value equal to 0. So the check for 1 is simply to make sure that someone wanted this weapon to not use the amount of wounds calculated by this script.

You have some suggestions of using it for anything else?

Offline efrenespartano

  • Commander
  • *****
  • Posts: 760
  • I know a lot about the law and other lawyerings.
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #7 on: August 26, 2019, 08:46:40 am »


The script will just treat the weapon with this tag as "not special", as if it had no such tag. I inserted only a check for SPECIAL_WOUND=1, because any weapon that does not have this tag is gonna have this value equal to 0. So the check for 1 is simply to make sure that someone wanted this weapon to not use the amount of wounds calculated by this script.

Oh, I get it! :0

Quote
You have some suggestions of using it for anything else?

Yeah, ammo. :v

Hahahahaha just kidding... kinda.

How does it behave it a melee weapon?

I give your cool script to the shotguns, LMGs and melee weapon types on UNEXCOM, but I'm afraid that the shotguns just obliterate the target before being wounded. xD

Would you recommend to give your tag to a weapon with low damage?

I'm curious, what's STR_CIVILIAN/SOLDIER/SECTOID/etc_UNARMED item?




Enviado desde mi LG-M400 mediante Tapatalk


Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #8 on: August 26, 2019, 10:38:51 am »
Well, about ammo, I'm gonna give it a thought, but I have other things on my mind now.

In melee weapons it behaves exactly the same. If you want them to be more/less wounding you need to give them the tag. This is exactly why these ..._UNARMED items are there. Because in my personal changes to the game mechanics I have these "items" that allow soldiers and aliens to fight unarmed :) These unarmed attacks actully deal very minor damage, that is why I don't see the reason to release them as a mod. They are just for flavor, you can't actually beat anyone up except a civilian or a sectoid. And I also gave them that tag and specified that unarmed attacks don't cause wounds at all (they inflict minor damage, but even when you manage to deal more than 5 damage per hit, there still will be no wounds).

Quote
Would you recommend to give your tag to a weapon with low damage?

You mean, so that less damaging weapons would still inflict significant amount of wounds? Personally I see no reason, because I see it as this: if the weapon deals little damage, than it's less likely to inflict more wounds. As I said above, I even prevented (already low-damaging) unarmed attacks from inflicting wounds even when the amount of damage would allow it. But in your mod it's your choice.

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #9 on: August 28, 2019, 03:41:54 pm »

Yeah, ammo. :v


I attached the new version and updated the description.

Offline efrenespartano

  • Commander
  • *****
  • Posts: 760
  • I know a lot about the law and other lawyerings.
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #10 on: August 28, 2019, 03:55:00 pm »
I attached the new version and updated the description.
Thanks a lot, Kzer-Za! :')


I'm adding it to UNEXCOM and TGWotW. Expect to see it on OXC Factions too.

Enviado desde mi LG-M400 mediante Tapatalk


Offline new_civilian

  • Commander
  • *****
  • Posts: 725
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #11 on: November 05, 2019, 11:53:33 am »
Thanks, Kzer-Za!

Offline cevaralien

  • Captain
  • ***
  • Posts: 96
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #12 on: July 28, 2020, 02:11:05 am »
Hi

This script is fantastic for my mod. I'm changing the damagetype rule of 0-200% to a 100% damage but random health, but these numbers goes from 0 to 100%, so, i could have a soldier with full HP with fatal wounds. This script really change that.

I have a question. I want the alien bleeding too, so, if i understand that if i add the alien armors to the code, the wound effect will affect them too, correct?

Offline CyberAxe

  • Squaddie
  • *
  • Posts: 3
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #13 on: October 31, 2020, 12:21:37 am »
I get the following errors in OXCE - OpenXcom Version: Extended 6.7.2 (v2020-10-24)

Error processing 'HUMAN_ARMOR' in armors: Missing battle corpse item(s).
Error processing 'HUMAN_SOLDIER_ARMOR' in armors: Missing battle corpse item(s).
Error processing 'PARAMEDIC_ARMOR' in armors: Missing battle corpse item(s).
Error processing 'POLICE_FEMALE_ARMOR' in armors: Missing battle corpse item(s).
Error processing 'POLICE_MALE_ARMOR' in armors: Missing battle corpse item(s).
Error processing 'STR_NONE_UC' in armors: Missing battle corpse item(s).

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8974
    • View Profile
Re: Wounds proportional to damage [OXCE]
« Reply #14 on: October 31, 2020, 04:53:48 pm »
1/ You can delete HUMAN_ARMOR, HUMAN_SOLDIER_ARMOR, PARAMEDIC_ARMOR, POLICE_FEMALE_ARMOR and POLICE_MALE_ARMOR.
They are not present in unmodded xcom.

Or alternatively, you can enable the "Armed Civilians" mod, which the author mentions in the first post and where these armors are presumably defined.

2/ STR_NONE_UC does have a battle corpse in unmodded xcom... so you'll need to find a mod, which removed the battle corpse (or the entire armor) and either disable it, fix it or make it otherwise compatible with this mod.