-- ExampleMainLua
-- Author: LeeS Update: Bernard Vink and Troller0001
-- DateCreated: 5/11/2015 7:44:55 AM
--------------------------------------------------------------
--function SpawnSettleTestChina()
--Dprint ("-------------------------------------")
--Dprint ("Spawning units!")
--local player = Players[iPlayer]
--local SETTLER = GameInfo.Units.UNIT_UNMOVEABLE_SETTLER.ID
--local SWEDEN = GameInfo.Civilizations.CIVILIZATION_SWEDEN
--local player = Players[iPlayer]
--if Game.GetGameTurn() == 1 then
--Dprint ("Attempting to Spawn Test Chinese Settler!")
--SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_SETTLER"], 9, 43, 0, 0, "Swedish South Company3", "PROMOTION_MORALE")
--local unitPlot = unit:GetPlot()
--unit:PopMission()
--unit:PushMission(GameInfoTypes.MISSION_FOUND, thisX, thisY, 9, 43, 0, 0, MissionTypes.MISSION_FOUND, thisPlot, unit)
--end
--end
include("UnitSpawnHandler.lua")
function TokyoExpress(iPlayer)
local pPlayer = Players[iPlayer]
if not pPlayer:IsAlive() then return end
---------------------------------------------------------------------------------------------------------
--CODE FOR JAPAN
---------------------------------------------------------------------------------------------------------
if pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_JAPAN"] then
if Game.GetGameTurn() == 1 then
--here is where we would create the units
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 109, 47, 0, 0, "NO_NAME", "NO_PROMOTION")
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 109, 47, 0, 0, "NO_NAME", "NO_PROMOTION")
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 109, 47, 0, 0, "NO_NAME", "NO_PROMOTION")
--1634 Poland peace with Ottoman and Russia
local pPlayer = Players[10];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[5];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pOtherTeam:MakePeace( iTeam, true );
pTeam:MakePeace( iOtherTeam, true );
local pPlayer = Players[10];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[12];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pOtherTeam:MakePeace( iTeam, true );
pTeam:MakePeace( iOtherTeam, true );
if (pPlayer:IsHuman()) then
local TokyoExpress = "Tokyo Express Units Added!"
Events.GameplayAlertMessage(TokyoExpress)
end
print("French declare war on Spanish and join allies against The House of Habsburg in the Thirty Years' War ")
elseif Game.GetGameTurn() == 2 then
print("No Tokyo Express Units Added")
--1635 France declar war on Spain / Austria
local pPlayer = Players[1];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[2];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pTeam:DeclareWar( iOtherTeam, true );
local pPlayer = Players[1];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[4];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pTeam:DeclareWar( iOtherTeam, true );
local pPlayer = Players[6];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[13];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pOtherTeam:MakePeace( iTeam, true );
pTeam:MakePeace( iOtherTeam, true );
elseif Game.GetGameTurn() == 6 then
print("No Tokyo Express Units Added")
--1640 Portugal declar war on Spain
local pPlayer = Players[7];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[2];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pTeam:DeclareWar( iOtherTeam, true );
elseif Game.GetGameTurn() == 14 then
print("No Tokyo Express Units Added")
--1648 Peace of Munster and the end of eight years war and thirty years war
local pPlayer = Players[3];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[5];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pOtherTeam:MakePeace( iTeam, true );
pTeam:MakePeace( iOtherTeam, true );
local pPlayer = Players[3];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[2];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pOtherTeam:MakePeace( iTeam, true );
pTeam:MakePeace( iOtherTeam, true );
local pPlayer = Players[6];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[2];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pOtherTeam:MakePeace( iTeam, true );
pTeam:MakePeace( iOtherTeam, true );
local pPlayer = Players[6];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[5];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pOtherTeam:MakePeace( iTeam, true );
pTeam:MakePeace( iOtherTeam, true );
local pPlayer = Players[5];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[8];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pOtherTeam:MakePeace( iTeam, true );
pTeam:MakePeace( iOtherTeam, true );
local pPlayer = Players[2];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[8];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pOtherTeam:MakePeace( iTeam, true );
pTeam:MakePeace( iOtherTeam, true );
end
end
---------------------------------------------------------------------------------------------------------
--CODE FOR ENGLAND
---------------------------------------------------------------------------------------------------------
if pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_OTTOMAN"] then
if Game.GetGameTurn() == 1 then
--here is where we would create the units
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 48, 50, 0, 0, "Ottomans", "PROMOTION_MORALE")
if (pPlayer:IsHuman()) then
local BritishUnits = "British Units Added!"
Events.GameplayAlertMessage(BritishUnits)
end
print("Peace with Ottomans empire and the Persian Empire ")
elseif Game.GetGameTurn() == 5 then
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 48, 50, 0, 0, "Ottomans", "NO_PROMOTION")
print("No Tokyo Express Units Added")
--1635
local pPlayer = Players[12];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[15];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pOtherTeam:MakePeace( iTeam, true );
pTeam:MakePeace( iOtherTeam, true );
local pPlayer = Players[14];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[40];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pTeam:DeclareWar( iOtherTeam, true );
end
end
---------------------------------------------------------------------------------------------------------
--CODE FOR FRANCE
if pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_FRANCE"] then
if Game.GetGameTurn() == 1 then
--here is where we would create the units
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 55, 9, 0, 0, "French East Indie Company1")
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_SETTLER"], 55, 9, 0, 0, "French East Indie Company3", "PROMOTION_MORALE")
--SpawnInitialCity(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 160, 66, 0, 0, "Swedish South Company", "PROMOTION_MORALE")
--pPlayer ~= -1 and iPlayer or Map:GetPlot(iX,iY):GetOwner()
--local eOwner = playerStartPlot:GetOwner();
--local eOwner = pPlayerPlot:GetOwner(160, 66);
--if (plot:GetOwner() ~160, 66) then
--if (adjPlot:GetOwner() ~= 160, 66) then
--local initialSettler = player:InitUnit(SETTLER, startX, startY)
--if settler:GetPlot() == plot then
--settler:PushMission( MissionTypes.MISSION_FOUND )
--return
--pUnit:PushOrder (OrderTypes.ORDER_MISSION_FOUND, GameInfo.Units["UNIT_SETTLER"].ID, -1, 0, false, false);
--local city = pPlayer:InitCity(start_plot:GetX(73), start_plot:GetY(68));
--city:SetPopulation(5, true);
--SetInitialCityBuilds();
--function OnFirstCity(iPlayer, x, y)
--Dprint ("-------------------------------------")
--Dprint ("New city founded...")
--local player = Players[iPlayer]
----local city = GetPlot(x,y):GetPlotCity()
--local pCity = Map.GetPlot(29,59):GetPlotCity();
--if (player:GetNumCities() == 1 and not player:IsMinorCiv()) then
--Dprint ("-------------------------------------")
--Dprint ("Initializing first city for " .. tostring(player:GetName()))
--if Game.GetElapsedGameTurns() > ELAPSED_TURNS_FOR_BALANCE then
-- SpawnInitialCity(city)
--end
--end
--end
-- GameEvents.PlayerCityFounded.Add(OnFirstCity) -- in main Lua
if (pPlayer:IsHuman()) then
local FrenchUnits = "French Units Added!"
Events.GameplayAlertMessage(French East Indie CompanyUnits)
end
print("Peace with Ottomans empire and the Persian Empire ")
elseif Game.GetGameTurn() == 2 then
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 162, 64, 0, 0, "French East Indie Company")
print("No Tokyo Express Units Added")
elseif Game.GetGameTurn() == 3 then
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 162, 64, 0, 0, "French East Indie Company")
print("No Tokyo Express Units Added")
end
end
---------------------------------------------------------------------------------------------------------
if pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_SWEDEN"] then
if Game.GetGameTurn() == 1 then
--here is where we would create the units
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 162, 64, 0, 0, "Swedish South Company1")
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 162, 64, 0, 0, "Swedish South Company2", "PROMOTION_MORALE")
--SpawnInitialCity(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 160, 66, 0, 0, "Swedish South Company", "PROMOTION_MORALE")
--pPlayer ~= -1 and iPlayer or Map:GetPlot(iX,iY):GetOwner()
--local eOwner = playerStartPlot:GetOwner();
--local eOwner = pPlayerPlot:GetOwner(160, 66);
--if (plot:GetOwner() ~160, 66) then
--if (adjPlot:GetOwner() ~= 160, 66) then
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_SETTLER"], 162, 64, 0, 0, "Swedish South Company3", "PROMOTION_MORALE")
--local initialSettler = player:InitUnit(SETTLER, startX, startY)
--if settler:GetPlot() == plot then
--settler:PushMission( MissionTypes.MISSION_FOUND )
--return
--pUnit:PushOrder (OrderTypes.ORDER_MISSION_FOUND, GameInfo.Units["UNIT_SETTLER"].ID, -1, 0, false, false);
--local city = pPlayer:InitCity(start_plot:GetX(73), start_plot:GetY(68));
--city:SetPopulation(5, true);
--SetInitialCityBuilds();
--function OnFirstCity(iPlayer, x, y)
--Dprint ("-------------------------------------")
--Dprint ("New city founded...")
--local player = Players[iPlayer]
----local city = GetPlot(x,y):GetPlotCity()
--local pCity = Map.GetPlot(29,59):GetPlotCity();
--if (player:GetNumCities() == 1 and not player:IsMinorCiv()) then
--Dprint ("-------------------------------------")
--Dprint ("Initializing first city for " .. tostring(player:GetName()))
--if Game.GetElapsedGameTurns() > ELAPSED_TURNS_FOR_BALANCE then
-- SpawnInitialCity(city)
--end
--end
--end
-- GameEvents.PlayerCityFounded.Add(OnFirstCity) -- in main Lua
-- function CreateCities ()
-- for lnum=0, GameDefines.MAX_CIV_PLAYERS-1, 1 do
-- local player=Players [lnum];
-- if player:IsAlive () and player:IsMinorCiv () then
-- the conditions for adding a city are set here
-- if player:GetExcessHappiness () >= 5 and player:GetNumCities () > 0 and player:GetNumCities () < 2 then
-- local iW, iH = Map.GetGridSize ();
-- local max = 0;
-- local max_x = -73;
-- local max_y = -68;
-- for y = 0, iH - 1 do
-- for x = 0, iW - 1 do
-- local v = player:AI_foundValue (x,y);
-- if v > max then
-- max = v;
-- max_x = x;
-- max_y = y;
-- end
-- end
-- end
-- if max_x > -1 then
-- player:Found (max_x,max_y);
-- end
-- end
-- end
-- end
-- end
--Events.ActivePlayerTurnStart.Add (CreateCities);
if (pPlayer:IsHuman()) then
local BritishUnits = "British Units Added!"
Events.GameplayAlertMessage(BritishUnits)
end
print("Swedish South Company colonization of the Americas ")
elseif Game.GetGameTurn() == 2 then
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 160, 66, 0, 0, "Swedish South Company", "PROMOTION_MORALE")
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 160, 66, 0, 0, "Swedish South Company", "PROMOTION_MORALE")
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_SWEDISH_GALLEON"], 159, 65, 0, 0, "Swedish South Company", "PROMOTION_MORALE")
print("No Tokyo Express Units Added")
print("British Units Added")
elseif Game.GetGameTurn() == 9 then
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 160, 66, 0, 0)
print("British Infantry Added")
--1643 Sweden and Netherlands declar war on Denmark
local pPlayer = Players[6];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[9];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pTeam:DeclareWar( iOtherTeam, true );
local pPlayer = Players[8];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[9];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pTeam:DeclareWar( iOtherTeam, true );
end
print("British Units Added")
elseif Game.GetGameTurn() == 12 then
SpawnAtPlot(pPlayer, GameInfoTypes["UNIT_MUSKETMAN"], 23, 27, 0, 0)
print("British Infantry Added")
--1645 Ottoman declare war on Venetia and France - Papestate
local pPlayer = Players[12];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[11];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pTeam:DeclareWar( iOtherTeam, true );
local pPlayer = Players[12];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[1];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pTeam:DeclareWar( iOtherTeam, true );
--1645 Sweden and Netherlands peach with Denmark
local pPlayer = Players[6];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[9];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pOtherTeam:MakePeace( iTeam, true );
pTeam:MakePeace( iOtherTeam, true );
local pPlayer = Players[8];
local iTeam = pPlayer:GetTeam();
local pTeam = Teams[iTeam];
local pOtherPlayer = Players[9];
local iOtherTeam = pOtherPlayer:GetTeam();
local pOtherTeam = Teams[iOtherTeam];
pTeam:Meet( iOtherTeam, true );
pOtherTeam:Meet( iTeam, true );
pOtherTeam:MakePeace( iTeam, true );
pTeam:MakePeace( iOtherTeam, true );
end
--CODE FOR AMERICA
end
GameEvents.PlayerDoTurn.Add(TokyoExpress)
print("Sample Main Lua Loaded")