Why this mod of french african army event don't works?
Posted: Sat Jul 28, 2018 2:59 pm
Hi people, I've mod a little this event, but it don't works and I don't know why
The idea is to eliminate three garrison units, replace them with small garrisons, and then deploy an infantry unit in hex 76, 55. But when is played (by human or CPU), the three garrisons remain and are not eliminated and replaced by smallgarrisons. The infantry unit is deployed, but in hex 78, 55!!!! Why?
Code: Select all
function FrenchArmyOfAfrica()
local france = game:GetFactionById(0)
local germany = game:GetFactionById(2)
if GetEvent("FrenchArmyOfAfrica") == 0 then
if game.date.year == 1914 and math.random(0,4) <= game.turn and game.turn <= 3 then
if player.alliance.id == 1 or game.type == Game.TYPE_SINGLE then
local hex = GetHex(54, 62)
hex.unit:Kill()
local hex = GetHex(77, 55)
hex.unit:Kill()
local hex = GetHex(89, 54)
hex.unit:Kill()
SpawnUnit(21, france, 54, 62, 0, 100)
SpawnUnit(21, france, 77, 55, 0, 100)
SpawnUnit(21, france, 89, 54, 0, 100)
SpawnUnit(1, france, 76, 55, 0, 100)
elseif player.alliance.id == 2 then
local hex = GetHex(54, 62)
hex.unit:Kill()
local hex = GetHex(77, 55)
hex.unit:Kill()
local hex = GetHex(89, 54)
hex.unit:Kill()
SpawnUnit(21, france, 54, 62, 0, 100)
SpawnUnit(21, france, 77, 55, 0, 100)
SpawnUnit(21, france, 89, 54, 0, 100)
SpawnUnit(1, france, 76, 55, 0, 100)
end
SetEvent("FrenchArmyOfAfrica", game.turn, hex)