(Problem)Nothing happens when the weapon with the script's tags strikes a unit.
(Example Mod Download)TestMod (Guaranteed Damage) V0-2.zip(Details)I'm trying to make a small script that will cause a weapon to deal
X guaranteed damage to the struck targets HP on top of any damage caused by the weapon's normal power.
But it isn't currently yielding results.
The
battle_game.flashMessage is not appearing and the health is not changing on the struck unit.
extended:
tags:
RuleItem:
GUARANTEED_DAMAGE_AMOUNT_ITEM: int
GUARANTEED_DAMAGE_ALLOWED_ITEM: int
RuleArmor:
GUARANTEED_DAMAGE_ALLOWED_ARMOR: int
scripts:
damageUnit:
- offset: 1
code: |
var int DMG 0;
var int ArmorAllowed 0;
var int ItemAllowed 0;
var int invert 0;
var int WeaponCurrentPower 0;
var ptr RuleArmor armor_rule;
var ptr RuleItem item_rule;
unit.getRuleArmor armor_rule;
damaging_item.getRuleItem item_rule;
# Load TAG values from involved item & armor
item_rule.getTag ItemAllowed Tag.GUARANTEED_DAMAGE_ALLOWED_ARMOR;
armor_rule.getTag ArmorAllowed Tag.GUARANTEED_DAMAGE_ALLOWED_ARMOR;
item_rule.getTag DMG Tag.GUARANTEED_DAMAGE_AMOUNT;
# If Armor & Weapon allow it deal the extra damage
if eq ItemAllowed ArmorAllowed;
# Apply Extra Damage Directly To Health
sub invert DMG;
unit.addHealth invert;
end;
# Get the current power of the attacking weapon's random roll
set WeaponCurrentPower currPower;
# Display a "Message" followed by "Extra Damage" then the "current power" of the attacking weapon
battle_game.flashMessage "STR_TEST_MSG_DAMAGE_STRENGTH" DMG WeaponCurrentPower;
return;
I've been over the code several times and can't spot why there isn't any interaction when the weapon strikes.
The variable '
currPower' was mentioned in the verbose version of the
openxcom.log's '
damageUnit' section and I'm making the possibly incorrect assumption that '
currPower' stores the weapon's current power after it goes through the chosen
RandomType: randomization roll.
For convenience I've attached a mod to this post with a test weapon already configured to use the script and also set the "
NONE" X-Com armor to be able to be effected by the weapon's script tags.
What am I missing?