Sid Meier's Civilization VI

Sid Meier's Civilization VI

Better visual Notifications
CasinoX 22 Apr, 2019 @ 3:14am
OnCityPopulationChanged in lua.log
Hi!

So here is my "research" regarding the population changed notification after building units. I can only hope this is going to be helpful, since i have no idea what i'm doing! ;)

I ran a test-game with zero City States and only one AI-player on "Online" speed and kept watching the lua.log for the "OnCityPopulationChanged" function.

Turn 1: I found my city and got the green icon sliding down on the screen, telling me my city grew to population 1. In the log i found this entry:
NotificationSlide: OnCityPopulationChanged: 0 65536 1 NotificationSlide: ------------------ Adding A Slide Notification -------------------- NotificationSlide: NotifyType: NEWPOP NotificationSlide: PlayerID: 0 NotificationSlide: Target: nil NotificationSlide: eNum: 65536 NotificationSlide: ToolTip: nil

Turn 2: Found the following entry in the log (i'm guessing the AI found his city?)
NotificationSlide: OnCityPopulationChanged: 1 65536 1 NotificationSlide: ------------------ Adding A Slide Notification -------------------- NotificationSlide: NotifyType: NEWPOP NotificationSlide: PlayerID: 1 NotificationSlide: Target: nil NotificationSlide: eNum: 65536 NotificationSlide: ToolTip: nil NotificationSlide: Wrong player or start of the game: PlayerID: 1 localPlayerID: 0 m_DoNotifications: true

Turn 4: Finished producing a Scout, got no icon and the log did not show any "OnCityPopulationChanged" entry - my city did not grow, so still pop 1 at this point

Turn 6: I guess the AI's city grew to population 2? This entry in the log:
otificationSlide: OnCityPopulationChanged: 1 65536 2 NotificationSlide: ------------------ Adding A Slide Notification -------------------- NotificationSlide: NotifyType: NEWPOP NotificationSlide: PlayerID: 1 NotificationSlide: Target: nil NotificationSlide: eNum: 65536 NotificationSlide: ToolTip: nil NotificationSlide: Wrong player or start of the game: PlayerID: 1 localPlayerID: 0 m_DoNotifications: true

Turn 7: Finished a Builder (to see if maybe a civilian unit triggers it? i know a settler does, and it makes sense in the settler case, since it takes away 1 pop) but same as turn 4: no icon no log entry

Turn 8: My City grows to Population 2, i get the green icon sliding down telling me so and in the log i get this entry:
Cannot cast from Unknown_Type to ControlBase. Using NULL instead. NotificationSlide: OnCityPopulationChanged: 0 65536 2 NotificationSlide: ------------------ Adding A Slide Notification -------------------- NotificationSlide: NotifyType: NEWPOP NotificationSlide: PlayerID: 0 NotificationSlide: Target: nil NotificationSlide: eNum: 65536 NotificationSlide: ToolTip: nil
I don't know if the first line got anything to do with it? But this whole block was everything that was added to the log during this turn so i copy-pasted it here.

Turn 10: AI's City grew to pop 2?
Cannot cast from Unknown_Type to ControlBase. Using NULL instead. NotificationSlide: OnCityPopulationChanged: 1 65536 2 NotificationSlide: ------------------ Adding A Slide Notification -------------------- NotificationSlide: NotifyType: NEWPOP NotificationSlide: PlayerID: 1 NotificationSlide: Target: nil NotificationSlide: eNum: 65536 NotificationSlide: ToolTip: nil NotificationSlide: Wrong player or start of the game: PlayerID: 1 localPlayerID: 0 m_DoNotifications: true

(still turn 10) And i finished building a Slinger in my City and got the green icon telling me my city grew to population 2 and found the function in the log:
NotificationSlide: OnCityPopulationChanged: 0 65536 2 NotificationSlide: ------------------ Adding A Slide Notification -------------------- NotificationSlide: NotifyType: NEWPOP NotificationSlide: PlayerID: 0 NotificationSlide: Target: nil NotificationSlide: eNum: 65536 NotificationSlide: ToolTip: nil

Turn 11: I finished a Scout the next turn and again got the green icon sliding down and found this block in the log (maybe the AI finished a production too and it triggered?):
NotificationSlide: OnCityPopulationChanged: 1 65536 2 NotificationSlide: ------------------ Adding A Slide Notification -------------------- NotificationSlide: NotifyType: NEWPOP NotificationSlide: PlayerID: 1 NotificationSlide: Target: nil NotificationSlide: eNum: 65536 NotificationSlide: ToolTip: nil NotificationSlide: Wrong player or start of the game: PlayerID: 1 localPlayerID: 0 m_DoNotifications: true NotificationSlide: OnCityPopulationChanged: 0 65536 2 NotificationSlide: ------------------ Adding A Slide Notification -------------------- NotificationSlide: NotifyType: NEWPOP NotificationSlide: PlayerID: 0 NotificationSlide: Target: nil NotificationSlide: eNum: 65536 NotificationSlide: ToolTip: nil

That's as far as i tested and now my head hurts! ;)

Can you work with that or should i better have posted the entire log? :steamfacepalm: If so, are there any private data in the log i should be careful with before posting?

Cheers!
< >
Showing 1-3 of 3 comments
Serp  [developer] 22 Apr, 2019 @ 3:47am 
thank you. I think this is enough for first hints (but lua.log does not contain anything dangerous)
So obviously the game developers trigger this official OnCityPopulationChanged event now also when a unit is created... but why.. and how to know if it was triggered because of a unit, instead of new pop...

My first idea would be to test if maybe the developers added an additional information to this event, which I currently do not check.

So you could try to edit the NotificationSlide.lua and search for this function:

function OnnCityPopulationChanged( playerID, cityID, NewAmount)
if PrintSetting.Value then
print("OnCityPopulationChanged: "..tostring(playerID).." "..tostring(cityID).." "..tostring(NewAmount));
end
OnAddNotification("NEWPOP", playerID, cityID, nil, NewAmount);
end

and change it to:

function OnnCityPopulationChanged( playerID, cityID, NewAmount, a, b)
if PrintSetting.Value then
print("OnCityPopulationChanged: "..tostring(playerID).." "..tostring(cityID).." "..tostring(NewAmount).." "..tostring(a).." "..tostring(b));
end
OnAddNotification("NEWPOP", playerID, cityID, nil, NewAmount);
end

I added a and b within the brackets and within the print statement to test if there are more values.
Test it again with this change and show me the log when creating a unit shows the notification.
I guess it will look like this:
NotificationSlide: OnCityPopulationChanged: 0 65536 2 nil nil

but maybe one of them is not nil. If so, show me this line from a real newpop vs a "fake" newpop
CasinoX 22 Apr, 2019 @ 4:30am 
Seems like your guess was right: Heres the part of the log when i finished building a unit and got the icon sliding down (again, only after the city already grew to pop 2 the turn before, any unit finished before did not trigger it):

NotificationSlide: OnCityPopulationChanged: 0 65536 2 nil nil NotificationSlide: ------------------ Adding A Slide Notification -------------------- NotificationSlide: NotifyType: NEWPOP NotificationSlide: PlayerID: 0 NotificationSlide: Target: nil NotificationSlide: eNum: 65536 NotificationSlide: ToolTip: nil

:steamsad:

anything else i can try?
Serp  [developer] 22 Apr, 2019 @ 4:54am 
ok, thank you for testing.
I made a new thread at civfanatics, maybe there someone knows more =/
https://forums.civfanatics.com/threads/oncitypopulationchanged-event-fires-for-training-units-in-gs.645191/
< >
Showing 1-3 of 3 comments
Per page: 1530 50