[vanilla] How to add a mission?

fb2017

Chieftain
Joined
Oct 8, 2017
Messages
53
This is my code, but it doesn't work!
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/
 
It will only work if you have downloaded and enabled the DLL mod mentioned (and I believe linked to) in the tutorial. It wasn't clear from a quick skim of the tutorial whether you will also need another mod linked from the tutorial also downloaded and enabled.

And then your mod cannot work with any other DLL mod, or the game's original DLL systems (since when the custom DLL mod loads it will replace the DLL files the game usually uses for that game-session). I do not know if William Howard rolled this into his VMC DLL system before he retired from modding, and I do not know if @Gazebo has the DLL code rolled into the CP/Vox Populi system.
 
I do not know if William Howard rolled this into his VMC DLL system before he retired from modding, and I do not know if @Gazebo has the DLL code rolled into the CP/Vox Populi system.

It's indeed integrated into VMC as of v46 (which is quite a long time ago!). Not sure which version of the CP it was introduced, but it should be there considering it was integrated into VMC that long ago.
Here are the related tutorials for those:
Instantaneous missions: https://forums.civfanatics.com/threads/dll-various-mod-components.479600/page-56#post-13643698
Durational missions: https://forums.civfanatics.com/threads/dll-lua-durational-custom-missions.552351/

To enable the system use this line in an SQL file (also mentioned in the tutorial but it's something that you tend to forget :crazyeye:)
Code:
UPDATE CustomModOptions SET Value=1 WHERE Name='EVENTS_CUSTOM_MISSIONS';
 
Back
Top Bottom