[BNW] Camera skip to newly found cities

linksbrawler

Chieftain
Joined
Oct 22, 2016
Messages
4
Hello,
I am trying to create a mod where the camera jumps to locations whenever a new city has been founded.

I have spent many hours trying to do this but with no success. My idea was to add the UI.LookAt method after any Player:InitCity method calls. Unfortunately, the InitCity calls at UI/InGame/WorldView/WorldView.lua doesn't get called when a city has been founded.

I'm not sure what else I could do, and I was hoping for ideas or help from here.
Thanks in advance
 
Perhaps this hook could be of help:
Code:
function CityFounded(iPlayer,iX,iY)
    --do stuff here
end

GameEvents.PlayerCityFounded.Add(CityFounded);

Now I don't know anything about Camera functions, but what I do know is that the Notification for 'Wonder Completed' (you know, the one that appears when an enemy has constructed a wonder) can move the Camera to a specific plot when left-clicked.
Code:
Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes["NOTIFICATION_WONDER_BEATEN"], description, descriptionShort, iX, iY,iBuilding,iPlayerOverlay)
where description is the 'hover'-description, descriptionShort is the 'Lhasa is in awe of you' kind of header description, NOTIFICIATION_WONDER_BEATEN is the Notificationtype, iX and iY the plot-coordinates to zoom to when left-clicked,, iBuilding the icon (requires an 80*80px building icon!) of the notification, and iPlayerOverlay the ID of the player who 'constructed your wonder' (or in your case, settled a city).
I believe that if you have not yet met the player of iPlayerOverlay that the 'Unknown civ'-icon will be displayed rather than the actual civilization icon.

I know that this wasn't what you were looking for specifically, but I thought it might be of a little help/could be a last resort if no other solutions are found
 
Thank you for your help! I have used the following code to have the camera move to newly founded city locations.
Code:
function CityFounded(iPlayer,iX,iY)
   local plot = Map.GetPlot(iX, iY);
   UI.LookAt(plot, 0);
end
GameEvents.PlayerCityFounded.Add(CityFounded);
 
Back
Top Bottom