Is there an event for new playerperks ?

Gokudo01

Emperor
Joined
Apr 12, 2014
Messages
1,044
Location
Toulouse(France)
Because playerperk wasn't in civ 5 . I want to catch an event where the player unlocks/is granted a new playerperk. ( the ones from the Table "PlayerPerks" that you get when you reach some affinity levels or with wonders. ).

And if I can't catch new perks with an event, how can I loop though the active player perks.
 
There is no event for this. Player perks are pretty flexible and can be earned through a wide variety of ways. I don't know what you intend for this event, but it may be more specific or concise to monitor wonder completion, affinity level, or building quests instead (not a simple task, but a little more straightforward than looping through the player's perks).
 
As lilgamefreek says, there is no event for this.

You can check if the player has a specific perk using:
Code:
if pPlayer:HasPerk(iPerkID) then
  -- do something
end

So you could loop through every entry in the PlayerPerks table, and check whether or not the player has that perk:
Code:
for row in GameInfo.PlayerPerks() do
   if pPlayer:HasPerk(row.ID) then
      -- do something
   end
end
 
It may be possible to detect when a perk is gained by having perks give free buildings and detecting (then deleting) those buildings. The structure would be similar to the old civ5 building created event I made (before there was a supported building created event).

I haven't investigated exactly how free buildings on perks interact through so I can't promise this method will work.
 
Ok I'm trying to link virtue table with the playerperk one.

An example ? :

+ 5 global health at lvl 5 Supremacy
or
-25% unhappiness from citycount at lvl 5 Harmony :

you can't do it with the perk table but the virtue table has got it.
So I want to be able to create an invisible virtue. And give to to the player once he's got the perk.
 
Top Bottom