| General | Hosted Sites | Civ5 | CivRev | Civ4Col | Civ4 | Civ3 | Civ2 | Civ1 | Misc | Marketplace |
![]() |
|
|
Welcome to Civilization Fanatics' Center. You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support. |
|
|||||||
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Deity
Join Date: Jun 2008
Posts: 2,054
|
End of human player turn
As noted by others here, Events.ActivePlayerTurnEnd actually fires after the next player's turn starts. Is there an event that really fires before the player's turn is over, say when the human presses the End Turn button?
One strange thing is that when ActivePlayerTurnEnd fires (which is really the next player's turn), unit:MovesLeft() now returns 120 for units that I know used up all their movement (though if I try to move them, they don't move). It's causing me all sorts of problems and I really just need to catch the human player turn before it is really over. |
|
|
|
|
|
#2 |
|
Proud father and civ-nut!
Join Date: Aug 2003
Location: Eastern Front
Posts: 1,005
|
Raised a similar thread a while back and concluded that there was no event of this nature.
Last night I ran a few tests on SerialEventEndTurnDirty which seems to fire 3 times on starting the turn and then around 20 on clicking the end turn button. I tracked the function down to the ActionInfoPanel (don't have name in front of me) and it seems to check the various states to display for the next turn button. If you can figure this function out then your probably a step closer to something useful. I wrote some code to store each unit's movement points for refueling, but was forced to attach it to the UnitSetXY function. If I had a preference it would have been at the end of the turn to speed things up.
__________________
“The Pope? How many divisions has he got?” Josef Stalin Current Project: The Great Patriotic War - WWII on the Eastern Front |
|
|
|
|
|
#3 |
|
Deity
Join Date: Jun 2008
Posts: 2,054
|
Well, I can do it for the human player by intercepting in ActionInfoPanel.lua right before Game.DoControl(iEndTurnControl). This is a case where I only need it for the human player, so that should work for me.
|
|
|
|
|
|
#4 |
|
Proud father and civ-nut!
Join Date: Aug 2003
Location: Eastern Front
Posts: 1,005
|
Please post any useful findings or examples as I am sure many here would appreciate the knowledge
__________________
“The Pope? How many divisions has he got?” Josef Stalin Current Project: The Great Patriotic War - WWII on the Eastern Front |
|
|
|
|
|
#5 |
|
Deity
Join Date: May 2011
Location: Near Portsmouth, UK
Posts: 2,484
|
That's not the end of the player's turn, only the end of their manual moves. Any unit with a mission will move after that.
__________________
All my mods (.civ5mod files) can be downloaded from http://www.picknmixmods.com/. If you want to incorporate (parts of) my mods into your own mod(s), please read this first Snap-shots (which are slowly going out-of-date) can still be download in zipped groups from the CfC Downloads Database - search for PickNMix - a list of what is in each zipped group can be found here |
|
|
|
|
|
#6 | |
|
Deity
Join Date: Jun 2008
Posts: 2,054
|
Quote:
What I'm not 100% sure about is whether we always get to the Game.DoControl(iEndTurnControl) line in ActionInfoPanel.lua exactly once in a turn. I think so, but I'm not sure. |
|
|
|
|
|
|
#7 |
|
Deity
Join Date: May 2011
Location: Near Portsmouth, UK
Posts: 2,484
|
If it's an issue, just store the turn you last ran in a file scope variable and test that you're not executing twice in the same turn (and add a warning if you detect a skipped turn)
Code:
local g_LastExecTurn = 0
function ExecOncePerTurn()
local iThisTurn = Game.GetGameTurn()
if (iThisTurn = g_LastExecTurn) then
-- Don't do stuff twice
elseif (iThisTurn ~= (g_LastExecTurn+1)) then
-- Oops, we skipped a turn or more
else
g_LastExecTurn = iThisTurn
-- Do some useful stuff
end
end
__________________
All my mods (.civ5mod files) can be downloaded from http://www.picknmixmods.com/. If you want to incorporate (parts of) my mods into your own mod(s), please read this first Snap-shots (which are slowly going out-of-date) can still be download in zipped groups from the CfC Downloads Database - search for PickNMix - a list of what is in each zipped group can be found here |
|
|
|
|
|
#8 |
|
Deity
Join Date: Jun 2008
Posts: 2,054
|
Well, just to follow up, Game.DoControl(iEndTurnControl) line in ActionInfoPanel.lua fires whenever you actually end turn by pressing the "Next Turn" button (or really, as whoward69 said, fires as your units with queued moves are moving). However, it does not fire when you end turn by pressing Enter. There is nowhere else in UI that Game.DoControl() is used to end turn (I don't know where the Enter key gets processed in this situation). So that's a failure.
What I really need is a way to catch the game when the human player's queued missions normally fire (which is before end of turn when the player presses Next Turn or achieves the same effect with Enter). But it has to work even if you don't have any queued missions. Is there an event like this or any way to jury rig one? |
|
|
|
![]() |
| Bookmarks |
|
| Thread Tools | |
|
|