Help - Adding a quest to a new building

BinderAJ

Chieftain
Joined
Feb 3, 2014
Messages
18
Location
Santiago, Chile
I created a few weeks ago the "Adaptive Greenhouse" building, play-tested it and works fine, it's quite balanced at the moment, but i'm looking to add a quest to it, so the player can choose between +2 culture or +2 science to the building (same behavior as vivariums).

After some research i found out the quest system is a two part component:

a) 3 XML files with text info the TextInfo_Quest XML, the TextInfo_Traits XML and the PlayerPerks XML, first two contain the descriptions and "lore" about the choices...last one has the yields and effects.

b) a LUA file that contains the code that triggers the quest once you have built the building in your city. Specifically something like "BuildingChoiceTemplateQuest.lua"

Now, i've never dabbled into LUA code...but after checking it looks i can replicate it for a single building.

Is this section of the original LUA file required on my own code?

local QuestScript = hmake CvQuestScript{};

----------------------------------------------------
-- Definitions
----------------------------------------------------
hstructure BuildingChoiceStruct
ID : number
Text : string
Epilogue : string
Flavor : number
RewardPerkType : string
end

hstructure BuildingQuestStruct
TitleTextKey : string
BodyTextKey : string
SummaryTextKey : string
ChoiceA : BuildingChoiceStruct
ChoiceB : BuildingChoiceStruct
end

----------------------------------------------------
-- Locals (constants)
----------------------------------------------------
local TRIGGER_CHANCE = 5;
local VARIANT_SUFFIX : string = "_VARIANT_B";

local BUILDING_CHOICES_TABLE = {};

And second, this is the choices for vivariums, which is very similar to what i want to do, all names in "" are references to the XML labels, so changing them should work.

BUILDING_CHOICES_TABLE[GameInfo.Buildings["BUILDING_VIVARIUM"].ID] = hmake BuildingQuestStruct {
TitleTextKey = "TXT_KEY_QUEST_BUILDING_VIVARIUM",
BodyTextKey = "TXT_KEY_QUEST_BUILDING_VIVARIUM_BODY",
SummaryTextKey = "TXT_KEY_QUEST_BUILDING_VIVARIUM_SUMMARY",
ChoiceA = hmake BuildingChoiceStruct {
ID = 1,
Text = "TXT_KEY_QUEST_BUILDING_VIVARIUM_CHOICE_A",
Epilogue = "TXT_KEY_QUEST_BUILDING_VIVARIUM_CHOICE_EPILOGUE_A";
Flavor = GameInfo.Flavors["FLAVOR_SCIENCE"].ID,
RewardPerkType = "PLAYERPERK_VIVARIUMS_SCIENCE_FLAT";
},
ChoiceB = hmake BuildingChoiceStruct {
ID = 2,
Text = "TXT_KEY_QUEST_BUILDING_VIVARIUM_CHOICE_B",
Epilogue = "TXT_KEY_QUEST_BUILDING_VIVARIUM_CHOICE_EPILOGUE_B";
Flavor = GameInfo.Flavors["FLAVOR_GROWTH"].ID,
RewardPerkType = "PLAYERPERK_VIVARIUMS_FOOD_FLAT";
}
}

But here comes the tricky question, i know the mod properties window handle the way and sequence all files are loaded onto the game engine, is there any specific order or action i should look for in this case?

regards
AJ
 
No need to do all that, there's a modder resource on the workshop called modular building quests which let's you add a quest in an easy XML format. Not pretty hard to use and there's instructions
 
Cool info SN, will have to look into that as wanting to add quests for some buildings I've added. - thanks.
 
No need to do all that, there's a modder resource on the workshop called modular building quests which let's you add a quest in an easy XML format. Not pretty hard to use and there's instructions

does that mean that everyone must have that resource installed for me being able to add a simple quest to the building? or can i do a stand-alone mod using that resource somehow?
 
does that mean that everyone must have that resource installed for me being able to add a simple quest to the building? or can i do a stand-alone mod using that resource somehow?
You can simply implement it into the mod, then everybody automatically has it. It's designed so multiple mods can have it without conflicting with each other (as long as all have the most recent version). The Modder's Resource comes with a description on how to properly implement it into other mods.
_____________________________

Just some further information because I feel like it:
Directly editing the BuildingChoiceTemplateQuest.lua will heavily conflict with other mods that try to implement Building Quests and should be avoided in Standalone-Buildings and similar mods.

Copying the system in a separate file will not run into compatibility issues, however, it will create some other "inconsistencies" with the rest of the quests, for example having 2 building quests trigger at the same turn, and having the new building quest not "compete" with other building quests because it's on its own list.

So aside from the easier implementation those are some additional reasons to just use the Modder's Resource.
 
Top Bottom