What is the best way to remove quests from a building?

Galgus

Emperor
Joined
Aug 22, 2012
Messages
1,705
In an affinity buildings mod, some buildings have been repurposed as national wonders of a sort, and I plan to either add quests to all of them or to remove quests from those buildings.

What is the best way to do that?

I know how to add and alter them, but I don't know how to remove them.
 
Building quests are actually defined within the file BuildingChoiceTemplateQuest.lua, so to delete one you'd need to include a modified version of that file in your mod, with the relevant lines deleted from it. (Which would cause compatability problems with other mods that replace that file)

lilgamefreek's made a handy version of that file which loads new/replacement building quests from XML, but it still includes the vanilla quests within the lua so you'd still need to include a modified (and therefore incompatible) version of it to actually delete one.

So I guess there is no good way to remove a building quest. Better to delete the building instead, then create a new, different building with the same description and stats. :)
 
Thanks, I'll either do that or just add quests for all the national wonders.

I forget exactly how quests trigger - isn't it something like a 5% chance every turn?

Does it scale with number of buildings?
 
5% for each "copy" of a building. However, only one quest per turn can trigger, so the actual chance for buildings that aren't tested first is lower than that number.
 
So for a national wonder it would be a 5% chance, or one in 20 of triggering, assuming no other quests blocked it.

That may work for the Marathon speed I'm accustomed to, but I'm worried it would be too random in others.

Anyway, thanks for the clarification.
 
Well, you can change the trigger chance per building in the same file that HandyVac mentioned. The easiest way (though not quite the "proper" way, but it will work) is to edit the QuestScript.OnBuildingProcessed-function - this part, to be exact:

Code:
if buildTableData ~= nil then
			-- data already exists, increment or decrement depending on whether the building is being added or removed
			if buildingAdded then
				buildTableData.TriggerChance = buildTableData.TriggerChance + TRIGGER_CHANCE;
			else
				buildTableData.TriggerChance = buildTableData.TriggerChance - TRIGGER_CHANCE;
			end
else
			-- first building of its class, set base table data
			local newTableData = {};
			newTableData.TriggerChance = TRIGGER_CHANCE;
			newTableData.QuestStarted = false;
			newTableData.BuildingID= buildingID;
			table.insert(QuestScript.PersistentData.PlayerTriggerTables[playerID], newTableData);
end

Change it to something like:

Code:
if buildTableData ~= nil then
			-- data already exists, increment or decrement depending on whether the building is being added or removed
			if buildingAdded then
				buildTableData.TriggerChance = buildTableData.TriggerChance + TRIGGER_CHANCE;
			else
				buildTableData.TriggerChance = buildTableData.TriggerChance - TRIGGER_CHANCE;
			end
else
			-- first building of its class, set base table data
			local newTableData = {};
[B]			if buildingID == GameInfo.Buildings["BUILDING_RELIC"].ID then
				print("First Relic found. Setting base trigger Chance to 20%.")
				newTableData.TriggerChance = 20;
			else
				newTableData.TriggerChance = TRIGGER_CHANCE;
			end[/B]
			newTableData.QuestStarted = false;
			newTableData.BuildingID= buildingID;
			table.insert(QuestScript.PersistentData.PlayerTriggerTables[playerID], newTableData);
end
...and the first copy of the building defined (in this case the relic) will set the base trigger chance of the quest to 20%. You can just add more buildings by using elseif:

Code:
if buildTableData ~= nil then
			-- data already exists, increment or decrement depending on whether the building is being added or removed
			if buildingAdded then
				buildTableData.TriggerChance = buildTableData.TriggerChance + TRIGGER_CHANCE;
			else
				buildTableData.TriggerChance = buildTableData.TriggerChance - TRIGGER_CHANCE;
			end
else
			-- first building of its class, set base table data
			local newTableData = {};
[B]			if buildingID == GameInfo.Buildings["BUILDING_CLINIC"].ID then
				print("First Clinic found. Setting base trigger Chance to 50%.")
				newTableData.TriggerChance = 50;
			elseif buildingID == GameInfo.Buildings["BUILDING_RELIC"].ID then
				print("First Relic found. Setting base trigger Chance to 20%.")
				newTableData.TriggerChance = 20;
			else
				newTableData.TriggerChance = TRIGGER_CHANCE;
			end[/B]
			newTableData.QuestStarted = false;
			newTableData.BuildingID= buildingID;
			table.insert(QuestScript.PersistentData.PlayerTriggerTables[playerID], newTableData);
end
 
Back
Top Bottom