Popup for one player only

xooll

Chieftain
Joined
Jun 3, 2011
Messages
77
I made a mod that features a popup when a unit spends enough time in certain terrain types. When testing it, however, I found that I get the popup even if it's not my unit. How do I make a PyPopup (or a CyPopup, I'm not picky) appear for only one player?
I have my popup appearing inside a loop that goes through all players, so I can refer to the relevant player easily enough. I'm just not sure where to put that reference.
 
That should work fine for single player games, but I suspect that in a multiplayer environment it would be pretty annoying to get each other's popups.
 
On each computer in a multiplayer game the "active player" is the human sitting at that computer (actually, this is true in single player games too). So if you check to see if the owner of the unit matches the active player and only show the popup if it does, then each player should get only his own popups.

Just make sure not to actually do anything in the pop-up processing to change the state of the game unless you add a mod net message to let everybody know (i.e. do not give the player any choices that do anything, just an "OK, I saw the pop-up" button that doesn't actually do anything other than close the pop-up window). Otherwise you'll go out-of-synch with no hope of recovery since the other computers have no way of knowing what the player picked (that is what the mod net message is for: to let all the computers have the same information about what happened).
 
So, in a multiplayer game, each individual computer considers the others to be not human (otherguy.isHuman() == 0)?
 
It's not a check for if a civ is played by a human human, which is different, it is a check for the "active civ": CyGame().getActivePlayer() or gc.getActivePlayer() - the former returns the player ID, the later returns the player object.
 
Back
Top Bottom