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
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 132
Joined: Wed Nov 27, 2013 3:27 pm

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

Post by Kossatx » 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)

Robotron
Lieutenant Colonel - Panther D
Lieutenant Colonel - Panther D
Posts: 1219
Joined: Tue Nov 23, 2010 3:35 pm

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

Post by Robotron » 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.
Slitherine's Commander the Great War on steroids: POTZBLITZ mod!
http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610

Kossatx
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 132
Joined: Wed Nov 27, 2013 3:27 pm

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

Post by Kossatx » Wed Aug 01, 2018 11:53 am

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”