This is my code, but it doesn't work!
function CanDoWarriorDeath(playerID, unitID, bTestVisible)
if (Players[playerID]:GetUnitByID(unitID):GetUnitType() == GameInfoTypes.UNIT_WARRIOR) then
return true
end
return false
end
GameEvents.CanDoWarriorDeath.Add(CanDoWarriorDeath)
function DoWarriorDeath(playerID, unitID)
Players[playerID]:GetUnitByID(unitID):Kill()
end
GameEvents.DoWarriorDeath.Add(DoWarriorDeath)
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 2/13/2018 7:20:42 PM -->
<GameData>
<Missions>
<Row>
<Type>MISSION_WARRIOR_DEATH</Type>
<Description>TXT_KEY_MISSION_WARRIOR_DEATH</Description>
<Help>TXT_KEY_MISSION_WARRIOR_DEATH_HELP</Help>
<DisabledHelp>TXT_KEY_MISSION_WARRIOR_DEATH_DISABLED_HELP</DisabledHelp>
<EntityEventType>ENTITY_EVENT_GREAT_EVENT</EntityEventType>
<OrderPriority>199</OrderPriority>
<Visible>1</Visible>
<IconIndex>0</IconIndex>
<IconAtlas>UNIT_ACTION_ATLAS_RELIGION</IconAtlas>
<LuaCanHandleEvent>CanDoWarriorDeath</LuaCanHandleEvent>
<LuaHandleEvent>DoWarriorDeath</LuaHandleEvent>
</Row>
</Missions>
<Language_en_US>
<Row Tag="TXT_KEY_MISSION_WARRIOR_DEATH">
<Text>Herd</Text>
</Row>
<Row Tag="TXT_KEY_MISSION_WARRIOR_DEATH_HELP">
<Text>Herd the Deer resource to the capital.</Text>
</Row>
<Row Tag="TXT_KEY_MISSION_WARRIOR_DEATH_DISABLED_HELP">
<Text>Herd the Deer resource to the capital.</Text>
</Row>
</Language_en_US>
</GameData>
And yes, it's from this tutorial: https://forums.civfanatics.com/threads/dll-custom-missions-via-xml-and-lua.494531/
Spoiler Lua :
function CanDoWarriorDeath(playerID, unitID, bTestVisible)
if (Players[playerID]:GetUnitByID(unitID):GetUnitType() == GameInfoTypes.UNIT_WARRIOR) then
return true
end
return false
end
GameEvents.CanDoWarriorDeath.Add(CanDoWarriorDeath)
function DoWarriorDeath(playerID, unitID)
Players[playerID]:GetUnitByID(unitID):Kill()
end
GameEvents.DoWarriorDeath.Add(DoWarriorDeath)
Spoiler XML :
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 2/13/2018 7:20:42 PM -->
<GameData>
<Missions>
<Row>
<Type>MISSION_WARRIOR_DEATH</Type>
<Description>TXT_KEY_MISSION_WARRIOR_DEATH</Description>
<Help>TXT_KEY_MISSION_WARRIOR_DEATH_HELP</Help>
<DisabledHelp>TXT_KEY_MISSION_WARRIOR_DEATH_DISABLED_HELP</DisabledHelp>
<EntityEventType>ENTITY_EVENT_GREAT_EVENT</EntityEventType>
<OrderPriority>199</OrderPriority>
<Visible>1</Visible>
<IconIndex>0</IconIndex>
<IconAtlas>UNIT_ACTION_ATLAS_RELIGION</IconAtlas>
<LuaCanHandleEvent>CanDoWarriorDeath</LuaCanHandleEvent>
<LuaHandleEvent>DoWarriorDeath</LuaHandleEvent>
</Row>
</Missions>
<Language_en_US>
<Row Tag="TXT_KEY_MISSION_WARRIOR_DEATH">
<Text>Herd</Text>
</Row>
<Row Tag="TXT_KEY_MISSION_WARRIOR_DEATH_HELP">
<Text>Herd the Deer resource to the capital.</Text>
</Row>
<Row Tag="TXT_KEY_MISSION_WARRIOR_DEATH_DISABLED_HELP">
<Text>Herd the Deer resource to the capital.</Text>
</Row>
</Language_en_US>
</GameData>
And yes, it's from this tutorial: https://forums.civfanatics.com/threads/dll-custom-missions-via-xml-and-lua.494531/