Why this mod of french african army event don't works?

A forum to discuss custom scenarios, campaigns and modding in general.

Moderators: Slitherine Core, The Lordz

Post Reply
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

Why this mod of french african army event don't works?

Post by Kossatx »

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)
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Why this mod of french african army event don't works?

Post by Robotron »

I assume that's caused by the possibility of the event getting triggered on turn 0 which is a bad idea because it might conflict with the setup file.
Also I don't know what else you have changed in your mod, so alas after a certain point you are on your own since subtle changes elsewhere in the scripts can act up in bizarre ways with no obvious relation.

Try this:

if game.date.year == 1914 and math.random(0,4) <= game.turn and game.turn >= 1 then


Also note you should avoid spawning Entente land units in sea/port hexes as the game might crash with no error report.

That's all I can think about now, got a little bit rusty about the finer points of modding the game.
Image
Slitherine's Commander the Great War - Director's Cut: POTZBLITZ mod!
FIND IT HERE: http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

Re: Why this mod of french african army event don't works?

Post by Kossatx »

Robotron wrote: Wed Aug 01, 2018 9:08 am I assume that's caused by the possibility of the event getting triggered on turn 0 which is a bad idea because it might conflict with the setup file.
Also I don't know what else you have changed in your mod, so alas after a certain point you are on your own since subtle changes elsewhere in the scripts can act up in bizarre ways with no obvious relation.

Try this:

if game.date.year == 1914 and math.random(0,4) <= game.turn and game.turn >= 1 then


Also note you should avoid spawning Entente land units in sea/port hexes as the game might crash with no error report.

That's all I can think about now, got a little bit rusty about the finer points of modding the game.
I've tried to do what you say, but it still don't work. Thanks again anyway :)
Post Reply

Return to “Commander the Great War : Mods & Scenario Design”