So, I'm making some Lua coding for some future mods and the functions work all fine and the new bug-fix on dummy policies by whoward69 should be hopefully okay to do, but anyway. The function below is designed to detect an event choice. If an event is chosen, grant a dummy policy and revoke the original dummy policy. Now, this is great but the event does however loop, so the policy that needs to be revoked might not be there anymore.
Question is how do I get it to revoke any dummy policies?
Let's per se, all civilizations had the original 1st government civic. India picks the 2nd government civic and the function then revokes the original 1st government civic and grants India the 2nd civic. A few turns pass and now India has decided to choose the 4th government civic. How would I code the function to make it revoke the 2nd civic and any other interchangeably rather than being stuck to one variable to which it only revokes the 1st government civic?
Question is how do I get it to revoke any dummy policies?
Let's per se, all civilizations had the original 1st government civic. India picks the 2nd government civic and the function then revokes the original 1st government civic and grants India the 2nd civic. A few turns pass and now India has decided to choose the 4th government civic. How would I code the function to make it revoke the 2nd civic and any other interchangeably rather than being stuck to one variable to which it only revokes the 1st government civic?
Code:
function EventChosen(iPlayer, iChoice)
local pPlayer = Players[iPlayer]
if iChoice == GameInfoTypes.PLAYER_EVENT_GOVERNMENTCIVIC_CHOICE_1 then
pPlayer:RevokePolicy(iPolicy)
pPlayer:GrantPolicy(GameInfoTypes.POLICY_CIVIC_DEPOTISM, true)
elseif iChoice == GameInfoTypes.PLAYER_EVENT_GOVERNMENTCIVIC_CHOICE_2 then
pPlayer:RevokePolicy(iPolicy)
pPlayer:GrantPolicy(GameInfoTypes.POLICY_CIVIC_HEREDITARY_RULE, true)
elseif iChoice == GameInfoTypes.PLAYER_EVENT_GOVERNMENTCIVIC_CHOICE_3 then
pPlayer:RevokePolicy(iPolicy)
pPlayer:GrantPolicy(GameInfoTypes.POLICY_CIVIC_PATRONAGE, true)
elseif iChoice == GameInfoTypes.PLAYER_EVENT_GOVERNMENTCIVIC_CHOICE_4 then
pPlayer:RevokePolicy(iPolicy)
pPlayer:GrantPolicy(GameInfoTypes.POLICY_CIVIC_REPRESENTATION, true)
elseif iChoice == GameInfoTypes.PLAYER_EVENT_GOVERNMENTCIVIC_CHOICE_5 then
pPlayer:RevokePolicy(iPolicy)
pPlayer:GrantPolicy(GameInfoTypes.POLICY_CIVIC_POLICE_STATE, true)
elseif iChoice == GameInfoTypes.PLAYER_EVENT_GOVERNMENTCIVIC_CHOICE_6 then
pPlayer:RevokePolicy(iPolicy)
pPlayer:GrantPolicy(GameInfoTypes.POLICY_CIVIC_UNIVERSAL_SUFFRAGE, true)
end
end
GameEvents.EventChoiceActivated.Add(EventChosen)