You do not combine them as each is called in different moment, `createUnit` is called when game create any unit, and my `damageSpecialUnit` is called when any unit get hit.
If you mean to simply have both in one file, then you need follow standard yaml rules, effect would look like:
extended:
scripts:
createUnit:
- offset: 1
code: |
var ptr RuleArmor armorRuleSet;
var int faction;
var text armor_type;
var int fulltu;
unit.getRuleArmor armorRuleSet;
armorRuleSet.getType armor_type;
unit.getFaction faction;
if eq faction 0;
if eq armor_type "ZOMBIE_ARMOR";
debug_log "Turn " turn ", setting Friendly spawnunit for new faction " faction " unit, Armor type " armor_type;
unit.setSpawnUnitFaction 0;
debug_log "Turn " turn ", Giving new friendly Zombie full TUs";
unit.getTimeUnitsMax fulltu;
unit.setTimeUnits fulltu;
end;
if eq armor_type "STR_CHRYSSALID_ARMOR_B_UC";
debug_log "Turn " turn ", Giving new friendly Chryssalid full TUs";
unit.getTimeUnitsMax fulltu;
unit.setTimeUnits fulltu;
end;
end;
return;
damageSpecialUnit:
- offset: 13
code: |
if gt health_damage 0;
var ptr RuleUnit zombie;
var int faction;
attacker.getFaction faction;
rules.getRuleUnit zombie "STR_ZOMBIE";
unit.setSpawnUnit zombie;
unit.setSpawnUnitInstantRespawn 1;
unit.setSpawnUnitFaction faction;
# disable defualt transforamtion
set transform_chance 0;
end;
return;
Another thing is that both scripts like this is called for every unit, some times you want only one to have special behavior.
This can be archived by local scripts like:
armor:
- type: STR_FOOO
scripts:
damageSpecialUnit: |
if gt health_damage 0;
var ptr RuleUnit zombie;
var int faction;
attacker.getFaction faction;
rules.getRuleUnit zombie "STR_ZOMBIE";
unit.setSpawnUnit zombie;
unit.setSpawnUnitInstantRespawn 1;
unit.setSpawnUnitFaction faction;
# disable defualt transforamtion
set transform_chance 0;
end;
return;
This will make only unit with armor `STR_FOOO` change any thing into zombie.