GameEvents.CityCaptureComplete (Civ5 API)

From Civilization Modding Wiki
Jump to navigationJump to search

This page is a part of the Lua and UI Reference (Civ5).


Function.png This function is a member of GameEvents.

This is a static method, invoke it with a dot.


This event is triggered when a city is captured. We may infer from the name that it is triggered when the capture has been completed, the city now shows as owned by the conqueror, and buildings have been destroyed (this has not been confirmed). We might hope that there is a matching event when the capture has been determined, but ownership not yet changed and buildings not yet destroyed, but have no information on this as yet.


Usage

void GameEvents.CityCaptureComplete(PlayerID player, int capital, ResourceType x, ResourceType y, PlayerID newPlayer, int conquest, int conquest)


Event Type

Unknown

Parameters

player: Presumably the player who lost the city
capital: Presumably true if the city captured is a capital
x: Location of the city
y: No description available.
newPlayer: Presumably the player who captured the city
conquest: No description available.
conquest: No description available.


Source code samples

Too many occurences. Only 50 out of 3 are listed.

TurnsRemaining.lua - DLC_02 DLC

DLC/DLC_02/Scenarios/NewWorldScenario/TurnsRemaining.lua
0500
GameEvents.CityCaptureComplete.Add(OnCityCaptured);


TurnsRemaining.lua (G&K)

DLC/Expansion/Scenarios/MedievalScenario/TurnsRemaining.lua
0185
GameEvents.CityCaptureComplete.Add(function(iOldOwner, bIsCapital, iX, iY, iNewOwner, iPop, bConquest)
0187
local plot = Map.GetPlot(iX, iY);
0188
local cCity = plot:GetPlotCity();
0189
local iNewOwner = cCity:GetOwner();
0190
local civType = Players[iNewOwner]:GetCivilizationType();
0192
local pOrthodoxHolyCity = Game.GetHolyCityForReligion(GameInfoTypes["RELIGION_ORTHODOXY"], -1);
0193
local pIslamHolyCity = Game.GetHolyCityForReligion(GameInfoTypes["RELIGION_ISLAM"], -1);
0194
local pChristianityHolyCity = Game.GetHolyCityForReligion(GameInfoTypes["RELIGION_CHRISTIANITY"], -1);
0195
local pProtestantHolyCity = Game.GetHolyCityForReligion(GameInfoTypes["RELIGION_PROTESTANTISM"], -1);
0197
local popupInfo = {
0198
Data1 = 500,
0199
Type = ButtonPopupTypes.BUTTONPOPUP_TEXT,
0200
}
0202
if (cCity == pOrthodoxHolyCity) then
0203
if (civType == GameInfo.Civilizations["CIVILIZATION_BYZANTIUM"].ID or
0204
civType == GameInfo.Civilizations["CIVILIZATION_RUSSIA"].ID) then
0205
Game.SetFounder(GameInfoTypes["RELIGION_ORTHODOXY"], iNewOwner);
0206
else
0207
local pNewHolyCity = FindNextOrthodoxHolyCity();
0208
if (pNewHolyCity == nil) then
0209
popupInfo.Text = Locale.ConvertTextKey("TXT_KEY_MEDIEVAL_SCENARIO_NO_ORTHODOX_CITIES", pOrthodoxHolyCity:GetName(), pOrthodoxHolyCity:GetName());
0210
UI.AddPopup(popupInfo);
0211
else
0212
Game.SetHolyCity (GameInfoTypes["RELIGION_ORTHODOXY"], pNewHolyCity);
0213
Game.SetFounder(GameInfoTypes["RELIGION_ORTHODOXY"], pNewHolyCity:GetOwner());
0214
popupInfo.Text = Locale.ConvertTextKey("TXT_KEY_MEDIEVAL_SCENARIO_NEW_ORTHODOX_HOLY_CITY", pOrthodoxHolyCity:GetName(), pNewHolyCity:GetName());
0215
UI.AddPopup(popupInfo);
0216
end
0217
end
0219
elseif (cCity == pIslamHolyCity) then
0220
if (civType == GameInfo.Civilizations["CIVILIZATION_SONGHAI"].ID or
0221
civType == GameInfo.Civilizations["CIVILIZATION_OTTOMAN"].ID or
0222
civType == GameInfo.Civilizations["CIVILIZATION_ARABIA"].ID) then
0223
Game.SetFounder(GameInfoTypes["RELIGION_ISLAM"], iNewOwner);
0224
else
0225
Game.SetFounder(GameInfoTypes["RELIGION_ISLAM"], GetPersistentProperty("MeccaPlayer"));
0226
end
0228
elseif (cCity == pChristianityHolyCity) then
0229
if (MyCurrentReligion(iNewOwner) == 2 and
0230
(civType == GameInfo.Civilizations["CIVILIZATION_FRANCE"].ID or
0231
civType == GameInfo.Civilizations["CIVILIZATION_CELTS"].ID or
0232
civType == GameInfo.Civilizations["CIVILIZATION_ENGLAND"].ID or
0233
civType == GameInfo.Civilizations["CIVILIZATION_SPAIN"].ID or
0234
civType == GameInfo.Civilizations["CIVILIZATION_NETHERLANDS"].ID or
0235
civType == GameInfo.Civilizations["CIVILIZATION_AUSTRIA"].ID or
0236
civType == GameInfo.Civilizations["CIVILIZATION_SWEDEN"].ID)) then
0237
Game.SetFounder(GameInfoTypes["RELIGION_CHRISTIANITY"], iNewOwner);
0238
else
0239
Game.SetFounder(GameInfoTypes["RELIGION_CHRISTIANITY"], GetPersistentProperty("VaticanPlayer"));
0240
end
0242
elseif (cCity == pProtestantHolyCity) then
0243
if (MyCurrentReligion(iNewOwner) == 13 and
0244
(civType == GameInfo.Civilizations["CIVILIZATION_FRANCE"].ID or
0245
civType == GameInfo.Civilizations["CIVILIZATION_CELTS"].ID or
0246
civType == GameInfo.Civilizations["CIVILIZATION_ENGLAND"].ID or
0247
civType == GameInfo.Civilizations["CIVILIZATION_SPAIN"].ID or
0248
civType == GameInfo.Civilizations["CIVILIZATION_NETHERLANDS"].ID or
0249
civType == GameInfo.Civilizations["CIVILIZATION_AUSTRIA"].ID or
0250
civType == GameInfo.Civilizations["CIVILIZATION_SWEDEN"].ID)) then
0251
Game.SetFounder(GameInfoTypes["RELIGION_PROTESTANTISM"], iNewOwner);
0252
else
0253
Game.SetFounder(GameInfoTypes["RELIGION_PROTESTANTISM"], GetPersistentProperty("ProtestantHolyCityPlayer"));
0254
end
0256
end
0258
-- VP for capture?
0259
local eCityReligion = cCity:GetReligiousMajority();
0260
local eCapturingPlayerReligion = MyCurrentReligion(iNewOwner);
0261
local player = Players[iNewOwner];
0262
local pJerusalemPlot = Map.GetPlot(GetPersistentProperty("JerusalemX"), GetPersistentProperty("JerusalemY"));
0264
if (bConquest and eCityReligion ~= eCapturingPlayerReligion and eCityReligion > 0 and iNewOwner < 22) then
0266
local iVPReceived = iPop * 25;
0268
-- Put up dialog box
0269
local popupInfo = {
0270
Data1 = 500,
0271
Type = ButtonPopupTypes.BUTTONPOPUP_TEXT,
0272
}
0274
-- Human player?
0275
if (cCity:IsHolyCityAnyReligion() or cCity:Plot() == pJerusalemPlot) then
0277
iVPReceived = iVPReceived * 2;
0278
player:ChangeScoreFromFutureTech(iVPReceived);
0280
if (iPlayer == 0) then
0281
popupInfo.Text = Locale.ConvertTextKey("TXT_KEY_MEDIEVAL_SCENARIO_VP_HOLY_CITY_CAPTURE_HUMAN", iVPReceived, cCity:GetName(), iPop);
0282
else
0283
if (Teams[player:GetTeam()]:IsHasMet(Game.GetActiveTeam())) then
0284
popupInfo.Text = Locale.ConvertTextKey("TXT_KEY_MEDIEVAL_SCENARIO_VP_HOLY_CITY_CAPTURE", player:GetCivilizationDescriptionKey(), iVPReceived, cCity:GetName(), iPop);
0285
else
0286
popupInfo.Text = Locale.ConvertTextKey("TXT_KEY_MEDIEVAL_SCENARIO_VP_HOLY_CITY_CAPTURE", "TXT_KEY_UNMET_PLAYER", iVPReceived, cCity:GetName(), iPop);
0287
end
0288
end
0289
else
0291
player:ChangeScoreFromFutureTech(iVPReceived);
0293
if (iPlayer == 0) then
0294
popupInfo.Text = Locale.ConvertTextKey("TXT_KEY_MEDIEVAL_SCENARIO_VP_CITY_CAPTURE_HUMAN", iVPReceived, cCity:GetName(), iPop);
0295
else
0296
if (Teams[player:GetTeam()]:IsHasMet(Game.GetActiveTeam())) then
0297
popupInfo.Text = Locale.ConvertTextKey("TXT_KEY_MEDIEVAL_SCENARIO_VP_CITY_CAPTURE", player:GetCivilizationDescriptionKey(), iVPReceived, cCity:GetName(), iPop);
0298
else
0299
popupInfo.Text = Locale.ConvertTextKey("TXT_KEY_MEDIEVAL_SCENARIO_VP_CITY_CAPTURE", "TXT_KEY_UNMET_PLAYER", iVPReceived, cCity:GetName(), iPop);
0300
end
0301
end
0302
end
0303
UI.AddPopup(popupInfo);
0304
end
0305
end);



The initial version of this page was created by the Civ5 API Bot, see the Civ5 API Reference FAQ. Some of the texts come from the 2kgames' wiki and most of code samples are copyrighted to Firaxis.
Functions' signatures were either copied from the 2kgames' wiki, or infered from the Lua source files and the binaries. Errors are possible.
Contributors may find help in the Contributors guide to the Civ5 API.