LeeS
Imperator
I've done some searching on this sub-forum and have only found information to confirm my conclusion that it is not possible through any lua method to directly detect which (if any) Ideology a player has adopted.
GameEvents.PlayerAdoptPolicyBranch runs for everything except the Ideology Branches so far as I have been able to tell through setting up 'listener' functions and printing the results to the lua.log.
I wrote a detector function that runs off GameEvents.PlayerAdoptPolicy (and GameEvents.PlayerDoTurn for extra re-confirmation) that functions correctly when I use the pPlayer:HasPolicy() method.
Did I miss something simple-Simon here that can directly tell which Ideology the player has?
GameEvents.PlayerAdoptPolicyBranch runs for everything except the Ideology Branches so far as I have been able to tell through setting up 'listener' functions and printing the results to the lua.log.
I wrote a detector function that runs off GameEvents.PlayerAdoptPolicy (and GameEvents.PlayerDoTurn for extra re-confirmation) that functions correctly when I use the pPlayer:HasPolicy() method.
Did I miss something simple-Simon here that can directly tell which Ideology the player has?
Spoiler :
The code doesn't actually do anything yet other than detect for Ideology and print to the log. In a 'real' mod I'd want to tweak and tighten up a bit, but here's the basic method I'm using:
Code:
FreedomIdeologyPolicies = { GameInfoTypes.POLICY_OPEN_SOCIETY, GameInfoTypes.POLICY_CREATIVE_EXPRESSION , GameInfoTypes.POLICY_CIVIL_SOCIETY , GameInfoTypes.POLICY_COVERT_ACTION , GameInfoTypes.POLICY_CAPITALISM , GameInfoTypes.POLICY_ECONOMIC_UNION }
OrderIdeologyPolicies = { GameInfoTypes.POLICY_HERO_OF_THE_PEOPLE, GameInfoTypes.POLICY_SOCIALIST_REALISM, GameInfoTypes.POLICY_SKYSCRAPERS, GameInfoTypes.POLICY_PATRIOTIC_WAR, GameInfoTypes.POLICY_DOUBLE_AGENTS, GameInfoTypes.POLICY_YOUNG_PIONEERS }
AutocracyIdeologyPolicies = { GameInfoTypes.POLICY_ELITE_FORCES, GameInfoTypes.POLICY_MOBILIZATION, GameInfoTypes.POLICY_UNITED_FRONT, GameInfoTypes.POLICY_FUTURISM, GameInfoTypes.POLICY_INDUSTRIAL_ESPIONAGE, GameInfoTypes.POLICY_FORTIFIED_BORDERS }
function AdoptPolicyListener(iPlayer, iPolicyID)
local pPlayer = Players[iPlayer]
local bFreedom, bOrder, bAutocracy = false, false, false
for k,v in pairs(FreedomIdeologyPolicies) do
if pPlayer:HasPolicy(v) then
bFreedom = true
break
end
if iPolicyID ~= nil and iPolicyID == v then
bFreedom = true
break
end
end
for k,v in pairs(OrderIdeologyPolicies) do
if pPlayer:HasPolicy(v) then
bOrder = true
break
end
if iPolicyID ~= nil and iPolicyID == v then
bOrder = true
break
end
end
for k,v in pairs(AutocracyIdeologyPolicies) do
if pPlayer:HasPolicy(v) then
bAutocracy = true
break
end
if iPolicyID ~= nil and iPolicyID == v then
bAutocracy = true
break
end
end
print("Player " .. iPlayer .. " has Freedom Ideology is " .. tostring(bFreedom))
print("Player " .. iPlayer .. " has Order Ideology is " .. tostring(bOrder))
print("Player " .. iPlayer .. " has Autocracy Ideology is " .. tostring(bAutocracy))
end
GameEvents.PlayerAdoptPolicy.Add(AdoptPolicyListener)