I am trying to make a civ with a % chance to "capture" a unit on killing it. Ideally this would be done by adding an OnKill event to units of this Civ that spawns a builder at about a 10% rate when one of your units kills an enemy unit, so in psuedocode it would be
function captureChance(attacker){
the problems I have are how to actually hook this function to run on an attacker killing a unit, and then to make sure I have the right syntax, I don't actually do any coding in lua, mostly just Java, with a bit of python and C++, so my syntax is probably off.local player = Players[attacker.ID.player];
local playerConfig = PlayerConfigurations[attacker.ID.player];
if(player.GetCivilizationName() == "MY_CIV_NAME"){
}local playerConfig = PlayerConfigurations[attacker.ID.player];
if(player.GetCivilizationName() == "MY_CIV_NAME"){
if(Math.random()*100 < 15){
}player.GetUnits().Create(
Integer.parse((GameInfo.Units["UNIT_BUILDER"].getIndex)),attacker.getX(), attacker.getY());
}Integer.parse((GameInfo.Units["UNIT_BUILDER"].getIndex)),attacker.getX(), attacker.getY());