Start a civ with no units.

Mike4Life

Chieftain
Joined
May 15, 2012
Messages
9
I'm working on a mod where a civ needs to initially spawn with nothing. I have code that will spawn units later, but for now this is a roadblock in my mod.
I have tried using the "kill" function on units in the starting turn but for some strange reason that does not work.
 
I'm working on a mod where a civ needs to initially spawn with nothing. I have code that will spawn units later, but for now this is a roadblock in my mod.
I have tried using the "kill" function on units in the starting turn but for some strange reason that does not work.

check function GetGameInitialItemsOverrides()
 
killing units at first turn should work (using it in some of my mods)
 
killing units at first turn should work (using it in some of my mods)
The way I originally tried to write the code was:
Spoiler :
if (totalturns) == 0 then
pPlot = Map.GetPlot(75,34);
pPlot:GetUnit(0):Kill(true, -1);
end

Am I doing this right?
 
assuming 75,34 is the starting plot, you'll only kill the settler this way, the second unit is on another (random) nearby plot.

To remove all units for a specific player, I do

Code:
for unit in player:Units() do
	unit:Kill(true, -1)
end
 
Still not working. What am I doing wrong now?
function GreeceRemoveCiv (Greece_PlayerID)
local player = Players[Greece_PlayerID]
-- kill all units
for unit in player:Units() do
unit:Kill(true, -1)
end
end
 
Without seeing how the parameter to GreeceRemoveCiv is determined and where/when the function is called, impossible to say.
 
Without seeing how the parameter to GreeceRemoveCiv is determined and where/when the function is called, impossible to say.

Here's the portion of the parameter:
elseif(playerCiv == GetCivID("CIVILIZATION_GREECE")) then
Greece_PlayerID = i;
And here's the portion where the function is called:
GameEvents.PlayerDoTurn.Add(function(iPlayer)
local totalturns = Game.GetGameTurn();
if (totalturns) == 0 then
GreeceRemoveCiv();
end
 
PlayerDoTurn is not fired before the beginning of the second turn of the game (for the AI), that's your problem here.
 
Events.SequenceGameInitComplete
Events.LoadScreenClose
 
I think that function GetGameInitialItemsOverrides() is more useful then killing units, just see this example from Inca DLC. You can use it in map script.

Code:
function GetGameInitialItemsOverrides()
    return {
        -- Prevent granting initial techs since we are explicitly setting them here.
        GrantInitialFreeTechsPerTeam = {
            [Spain_PlayerID] = false,
            [France_PlayerID] = false,
            [England_PlayerID] = false,
            [Inca_PlayerID] = false,
            [Aztec_PlayerID] = false,
            [Iroquois_PlayerID] = false
        },

        -- Prevent setting initial gold since we are setting it explicitly in this script.
        GrantInitialGoldPerPlayer = {
            [Spain_PlayerID] = false,
            [France_PlayerID] = false,
            [England_PlayerID] = false,
            [Inca_PlayerID] = false,
            [Aztec_PlayerID] = false,
            [Iroquois_PlayerID] = false
        },
        
        -- Prevent initial units per player since we are placing them in this script.
        GrantInitialUnitsPerPlayer = {
            [Spain_PlayerID] = false,
            [France_PlayerID] = false,
            [England_PlayerID] = false,
            [Inca_PlayerID] = false,
            [Aztec_PlayerID] = false,
            [Iroquois_PlayerID] = false
        }    
    };
end
 
Back
Top Bottom