Which event runs at turn end (when next turn button appears or is pushed)?

ww2commander

Emperor
Joined
Aug 23, 2003
Messages
1,243
Location
Australia
Can anyone confirm which event I should use to run functions when each player (human and AI) has completed their turn. I guess this would be when the active player has hit the end turn button (or when the end turn button writing appears!).

I need to check unit.HasMoved object for all units and figured it would be easier to do this at the end of the turn when no further movement is possible.

The closest candidate event I have come across is SerialEventEndTurnDirty but don't know how it works.
 
when you hit the end turn button, only your turn is done, all the AI have not move yet.

I didn't tried SerialEventEndTurnDirty , but you can add that code in your mod (from 2K wiki) to check when it's called and what are the value it can return to a function using firetuner :

Code:
function Listen(...)

	print("Listen to SerialEventEndTurnDirty")
	print(unpack({...}))

end

Events.SerialEventEndTurnDirty.Add(Listen)
 
So what would you use to call at end of each players turn similar to PlayerDoTurn being used at beginning.

Reason for all this is that I am 'expanding' your re-enforcement code to consider fuel, but I want it to apply fuel usage after units have moved. Logic here is that if a unit has not moved then it should not consume fuel. Of course this also needs to apply to AI units.

I want to make sure the fuel is subtracted before turn end from relevant counter as the beginning of turn will then add more fuel based on refineries and number of oil resources available.

I hope I am making sense!
 
ActivePlayerTurnEnd is a serial event that triggers at the end of each turn of the active player (i.e., you). I use it heavily in my mod. Note that there are still a few things that the game will do for your empire after this event triggers; for instance, the game recalculates your Happiness at the end of your turn to see how much needs to be added to the Golden Age meter, and any happiness changes you make within this event will be overridden by that final recalculation. But for most other things, it works fine as an end-of-turn event for the main player.

So what would you use to call at end of each players turn similar to PlayerDoTurn being used at beginning.

There isn't one for that. PlayerDoTurn is a GameEvent, and there are only about a dozen or so of those in existence. There's not one for end-of-turn, start-of-combat, end-of-combat, or any number of other triggers we've asked for.
 
I would try SerialEventUnitMove to see if it can be made on the fly for each movement, as I 'm not sure we can catch the end of each player turn.

But try SerialEventEndTurnDirty first, it may be what you're looking.
 
I would try SerialEventUnitMove to see if it can be made on the fly for each movement, as I 'm not sure we can catch the end of each player turn.

If you're trying to trap unit movement, a better choice is the GameEvent "UnitSetXY", which, contrary to its name, is a listener for whenever a unit is given a valid move command. There are three different Serial events that trigger on unit movement, but each of these has major limitations in terms of what arguments it passes or whether you need the moving unit to be visible to the active player; the GameEvent is far superior to any of these.

Of course, an event that triggers every time a unit moves will be a major resource hog if it tries to do a lot, because that's a LOT of times it'd be called during a late-game turn. But depending on what you intend to use it for, this might not be so bad.
 
That is part of my concern Spatz. I don't want to add additional processing on each key stroke or click of a unit.

I did further searching (don't have game in front of me right now) and it turns out that the function is used by the game at the point where the button for next turn appears as per the ActionInfoPanel.lua file.

In the above example, it checks if all loose ends are wrapped up before allowing a player to click on the next turn button. Also, it does not seem to require extra arguments.
 
Back
Top Bottom