Well... i was testing it and it is working. I want to share it.
First, thanks to Yankees and Meridian for the help, and credits to Kzer-Za for the base script.
The objective of this mod is to enhance the random damage received by the units. By default, we can do "damageAlter" to define a random multiplier from 0 to X percent. I don't like the zero damage.
Another think that i don't like is the range of weapon power (default 0 -200). Why change the raw power of a weapon every shot? To enhance this, i used a fixed power and i changed the random damage after armor. This is equivalent to critical hits.
Now, if the unit receive a headshot, the damage could be a random percentage from 100% of the power after armor to 200%, but if the hit is at torso, the damage could be from 50% to 200%.
The limbs. No one dies imediately if loses a leg or an arm, right? well, in xcom is a reality. With this script, all damage to limbs is reduced, but the wounds are more critical than torso wounds or even head. When the unit receive damage equal or more than 20% of the max health, it will stun and bleed to death, if no one is near with a medikit to save the day, but the health damage would be not so heavy at all.
Feel free to use or enhance it if you like it.
Notice that i have a health cap for humans at 45. You can increase the value of wounds if you are using the base ruleset for soldiers. The use of tags it's better explained at
https://openxcom.org/forum/index.php?topic=7310.0 extended:
tags:
RuleItem:
SPECIAL_WOUND: int
WOUND_FACTOR: int
scripts:
damageUnit:
- offset: -41
code: |
var int wounds;
var int special;
var int woundFactor;
var int ranhealth;
var int health;
var int lowv;
var int higv;
var ptr RuleItem itemRuleset;
damaging_item.getRuleItem itemRuleset;
itemRuleset.getTag special Tag.SPECIAL_WOUND;
if ge to_health 5;
if eq special 1;
return;
else eq special 2;
itemRuleset.getTag woundFactor Tag.WOUND_FACTOR;
set wounds to_health;
div wounds woundFactor;
set to_wound wounds;
else and neq special 1 neq special 2;
set wounds to_health;
div wounds 5;
set to_wound wounds;
end;
end;
if or eq part BODYPART_LEFTARM eq part BODYPART_RIGHTARM;
set lowv 1;
set higv 2;
else or eq part BODYPART_LEFTLEG eq part BODYPART_RIGHTLEG;
set lowv 1;
set higv 2;
else eq part BODYPART_TORSO;
set lowv 5;
set higv 20;
else eq part BODYPART_HEAD;
set lowv 10;
set higv 20;
end;
battle_game.randomRange ranhealth lowv higv;
set health to_health;
mul health ranhealth;
div health 10;
set to_health health;
armors:
- &HUMAN_ARMOR
type: HUMAN_ARMOR
scripts:
damageUnit: |
var int wounds;
var int health;
unit.getFatalwoundsTotal wounds;
unit.getHealthMax health;
add wounds to_wound;
if gt wounds 9;
unit.setStun health;
end;
return;
# Civilians
- type: CIVM_ARMOR
refNode: *HUMAN_ARMOR
- type: CIVF_ARMOR
refNode: *HUMAN_ARMOR
# Soldiers
- type: STR_NONE_UC
refNode: *HUMAN_ARMOR
- type: STR_PERSONAL_ARMOR_UC
refNode: *HUMAN_ARMOR
- type: STR_POWER_SUIT_UC
refNode: *HUMAN_ARMOR
- type: STR_FLYING_SUIT_UC
refNode: *HUMAN_ARMOR