Hi,
I have problems accessing global events occured and hope someone can help. Basically I only need to know if a specific global event happened somewhere at any point in history, but I can't get it to work.
As I understand things, a player's functions getEventTriggered(itrigger) and getEventOccured(ievent) are the way to find triggered and occured events. The first one tells me if the itrigger trigger has been activated by the player, which however does not necessarily mean the associated event has taken place, so it's useless for me. But the second tells me if ievent has occured to player, and that's what I'm looking for. Right?
The problem is I get a curious behavior when using it. I made the following experiment: I put the code below in EventManager.py, within the OnBeginPlayerTurn function, to monitor what was going on, event-wise. As you can see from the code, every turn I'm going through all possible triggers in the game, see for each if it is Global, and if it is, I check all active players to see if its (first) associated event has occured. If so, I print on screen some data.
The curious thing is this: I start playing, for a while getting no prints on screen as expected, and then a global event appears to occur to some player I haven't met yet since I get a first print. Something like: "Sitting Bull - EVENTTRIGGER_HYMNS_AND_SCULPTURES (EVENT_HYMNS_AND_SCULPTURES_1)"
So far so good. For the following two or three turns I get, as expected, the same print each turn, confirming what I already know. Good. But then the prints stop. As if the program forgets the event took place. Other global events happen later, I get their prints, but it's the same thing: it keeps printing for only a few turns and then stops.
So basically I find myself unable to determine if a global event ever happened. Ideas?
Thanks in advance.
I have problems accessing global events occured and hope someone can help. Basically I only need to know if a specific global event happened somewhere at any point in history, but I can't get it to work.
As I understand things, a player's functions getEventTriggered(itrigger) and getEventOccured(ievent) are the way to find triggered and occured events. The first one tells me if the itrigger trigger has been activated by the player, which however does not necessarily mean the associated event has taken place, so it's useless for me. But the second tells me if ievent has occured to player, and that's what I'm looking for. Right?
The problem is I get a curious behavior when using it. I made the following experiment: I put the code below in EventManager.py, within the OnBeginPlayerTurn function, to monitor what was going on, event-wise. As you can see from the code, every turn I'm going through all possible triggers in the game, see for each if it is Global, and if it is, I check all active players to see if its (first) associated event has occured. If so, I print on screen some data.
Code:
if pPlayer.isHuman():
for i in range(gc.getNumEventTriggerInfos()):
trigger=gc.getEventTriggerInfo(i)
if trigger.isGlobal():
for ii in range(gc.getMAX_CIV_PLAYERS()):
if gc.getPlayer(ii).isAlive():
ev=gc.getPlayer(ii).getEventOccured(trigger.getEvent(0))
if (ev != None):
CyInterface().addImmediateMessage("%s - %s (%s)" %(gc.getPlayer(ii).getName(),trigger.getType(),gc.getEventInfo(trigger.getEvent(0)).getType()),"")
The curious thing is this: I start playing, for a while getting no prints on screen as expected, and then a global event appears to occur to some player I haven't met yet since I get a first print. Something like: "Sitting Bull - EVENTTRIGGER_HYMNS_AND_SCULPTURES (EVENT_HYMNS_AND_SCULPTURES_1)"
So far so good. For the following two or three turns I get, as expected, the same print each turn, confirming what I already know. Good. But then the prints stop. As if the program forgets the event took place. Other global events happen later, I get their prints, but it's the same thing: it keeps printing for only a few turns and then stops.
So basically I find myself unable to determine if a global event ever happened. Ideas?
Thanks in advance.