Looking for help with the XML for a spy-related custom civ trait.

DoktorApplejuce

Champion of Kirkwall
Joined
Apr 9, 2015
Messages
582
Location
Canada
I'm looking to create a custom civ, with offensive spies that produce faith, and defensive spies/diplomats that produce culture, yet I'm not sure what I would need to put in my Civ_Traits XML file in order to make it work.

Also, I'd like to make a unique unit for the same civ that produces faith when garrisoned, and I'm not sure how to do that.
 
The real trick will be determining what spies are doing what. You would have to do it through lua. Looking through the available methods in lua it is possible to get the total number of spies a player has through
Code:
Player:GetNumSpies()
And also the number of unassigned spies through
Code:
Player:GetNumUnassignedSpies()
From there is a method
Code:
Player:GetEspionageSpies()
But there is no real documentation available as to whether that gives a number for those assigned to spy on foriegn civs(+CS ?), or those assigned as diplomats and spies in foreign civs(+CS ?), or the total that have been assigned as counter-espionage agents and as spies in foriegn civs(+CS ?), or what exactly.

----------------------------------------------------------------------------

There is also this for individual spy/diplomats
Code:
Player:IsSpyDiplomat()
But I'm not sure how you get at the individual spies to then determine if they are a diplomat.

--------------------------------------------------------------------------------

So far these are the only lua methods I found related to spies/diplomats for "Player":
Code:
Player.CanSpyStageCoup
Player.GetNumSpies
Player.GetNumUnassignedSpies
Player.GetEspionageCityStatus
Player.GetEspionageSpies
Player.HasSpyEstablishedSurveillance
Player.IsSpyDiplomat
Player.IsSpySchmoozing
 
My Tanuki civilization uses GetEspionageSpies to determine what cities spies are in, and generates gold accordingly. It's been a while since I worked on the civ, so there may be some better methods to do some of what I did in it, but here's the relevant code:

Code:
function TanukiCon(iPlayer)
	local pPlayer = Players[iPlayer];
	local pCity = pPlayer:GetCapitalCity();
	totSuckers = 0;
	for i,v in pairs(Players[iPlayer]:GetEspionageSpies()) do
		if v.EstablishedSurveillance then
			local iCity = Map.GetPlot(v.CityX, v.CityY):GetPlotCity();
			local vPlayer = iCity:GetOwner();
			local iCityPop = iCity:GetPopulation();
			local iConJob = math.ceil(iCityPop / 2)
			local iCityName = iCity:GetName()
			if vPlayer ~= iPlayer then
				print(iCityName .. " has a population of " .. iCityPop);
				print("Tricked them out of " .. iConJob .. " gold")
				totSuckers = totSuckers + iConJob;
			else
				print("Checking " .. iCityName .. " for Moneylender");
				if iCity:IsHasBuilding(GameInfoTypes.BUILDING_TANUKI_BOOKSTORE) then
					print("Has Moneylender")
					print("Spawning tanuki patrol")
					iCity:SetNumRealBuilding(GameInfoTypes.BUILDING_TH_TANUKI_PATROL, 1);
				else
					print("No Moneylender")
					iCity:SetNumRealBuilding(GameInfoTypes.BUILDING_TH_TANUKI_PATROL, 0);
				end
			end
		end
	end
	print("Total gold obtained: " .. totSuckers);
	pCity:SetNumRealBuilding(bGOLD, totSuckers);
end

This uses a dummy building to generate the gold, and spawns it in the capital. The function itself gets called as part of another PlayerDoTurn function I use elsewhere.

So far I haven't found a way to determine if a particular spy is a diplomat, however. It is possible to at least determine if they're in a friendly city or not by comparing the city owner against the active player, though.
 
The real trick will be determining what spies are doing what. You would have to do it through lua. Looking through the available methods in lua it is possible to get the total number of spies a player has through
Code:
Player:GetNumSpies()
And also the number of unassigned spies through
Code:
Player:GetNumUnassignedSpies()
From there is a method
Code:
Player:GetEspionageSpies()
But there is no real documentation available as to whether that gives a number for those assigned to spy on foriegn civs(+CS ?), or those assigned as diplomats and spies in foreign civs(+CS ?), or the total that have been assigned as counter-espionage agents and as spies in foriegn civs(+CS ?), or what exactly.

----------------------------------------------------------------------------

There is also this for individual spy/diplomats
Code:
Player:IsSpyDiplomat()
But I'm not sure how you get at the individual spies to then determine if they are a diplomat.

--------------------------------------------------------------------------------

So far these are the only lua methods I found related to spies/diplomats for "Player":
Code:
Player.CanSpyStageCoup
Player.GetNumSpies
Player.GetNumUnassignedSpies
Player.GetEspionageCityStatus
Player.GetEspionageSpies
Player.HasSpyEstablishedSurveillance
Player.IsSpyDiplomat
Player.IsSpySchmoozing

Lua? Ok, wow. I don't even understand SQL yet. I don't think I'm quite ready to step up to something that advanced so quickly. I suppose I'll have to change it around to something easier to script; maybe culture per turn for every declaration of friendship and City State ally.
 
Top Bottom