SerialEventCityCaptured: Difference between revisions

From Civilization Modding Wiki
Jump to navigationJump to search
(Created page with "Up: Lua Game Events ==Description== Fired when city is captured '''or traded to an another civ'''. ==Example== ([http://forums.2kgames.com/showthread.php?113029-Reward-for...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:


==Description==
==Description==
Fired when city is captured '''or traded to an another civ'''.  
Fired when [[Lua Game Objects/City|city]] is captured '''or traded to an another civ'''.  


==Example==
==Example==
Line 22: Line 22:
   end
   end
   Events.SerialEventCityCaptured.Add(OnCityCaptured)
   Events.SerialEventCityCaptured.Add(OnCityCaptured)
*hexPos argument passes encoded coordinates. Use it to get a corresponding plot:
  local pPlot = Map.GetPlot(ToGridFromHex(hexPos)

Latest revision as of 10:41, 14 February 2012

Up: Lua Game Events

Description

Fired when city is captured or traded to an another civ.

Example

(by whoward69)

 function OnCityCaptured(hexPos, playerID, cityID, newPlayerID)
   -- Empire destroyed?
   if (Players[playerID]:GetNumCities() == 0) then
     if (Game.GetActivePlayer() == newPlayerID) then
       -- Captured by player
       if (Players[playerID]:IsMinorCiv()) then
         -- It was a minor
       else
         -- It was a major
       end
     else
       -- Captured by AI
     end
   end
 end
 Events.SerialEventCityCaptured.Add(OnCityCaptured)
  • hexPos argument passes encoded coordinates. Use it to get a corresponding plot:
 local pPlot = Map.GetPlot(ToGridFromHex(hexPos)