Morale unit freezers

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

Morale unit freezers

Post by Kossatx »

Any idea about why the first script works for immobilize a british garrison from the beginning of the game, and the russian garrison of the second one begins unfreezed? (These modifications are over the great POTZBLITZ MOD, done by Robotron).

Code: Select all

local quebec = game:GetHex(8, 35)
if quebec.alliance.id == 1 
	and quebec.unit ~= nil
	and unit.hex ~= nil
	and unit.hex.x == 8
	and unit.hex.y == 35
	and britain.morale > 50
	and unit.type == Unit.LAND then
		unit.mp = 0
end	

Code: Select all

local reval = game:GetHex(118, 10)
if reval.alliance.id == 1 
	and reval.unit ~= nil
	and unit.hex ~= nil
	and unit.hex.x == 118
	and unit.hex.y == 10
	and russia.morale > 30
	and unit.type == Unit.LAND then
		unit.mp = 0
end
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Morale unit freezers

Post by Robotron »

Until Russia has joined Entente, Russia is neutral, therefore Reval is neutral too, therefore the check for Reval must be

Code: Select all

reval.alliance.id == 0
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: Morale unit freezers

Post by Kossatx »

Robotron wrote: Fri Aug 21, 2020 1:15 pm Until Russia has joined Entente, Russia is neutral, therefore Reval is neutral too, therefore the check for Reval must be

Code: Select all

reval.alliance.id == 0
But Britain also starts neutral, not? And if I do what you say, once Russia joins Entente the units will be unfreeze, not?
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Morale unit freezers

Post by Robotron »

So, are both nations already in the war when you tested your script? You forgot to tell me.
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: Morale unit freezers

Post by Kossatx »

I suppose "reval.alliance.id == 0" means "reval alliance is neutral at this turn", so althought Russia starts the war neutral (and its units don't move while neutral), once joins Entente its alliance is 1 and the script is triggered (so the garrison should be freezed... but not). I don't understand why I'm wrong :?:
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Morale unit freezers

Post by Robotron »

I have a theory that sometimes when a nation enters the war the alliance.id is not properly registered until the next turn. Don't ask me why.

So in your example Russia is still alliance.id == 0 on turn 5 even when having joined Entente. It will be alliance.id == 1 on all further turns, including all Russian cities.

You could try to check reval.alliance.id for being ~= 2, this should work if reval is still neutral or has joined Entente.

Code: Select all

local reval = game:GetHex(118, 10)
if reval.alliance.id ~= 2  
	and reval.unit ~= nil
	and unit.hex ~= nil
	and unit.hex.x == 118
	and unit.hex.y == 10
	and russia.morale > 30
	and unit.type == Unit.LAND then
		unit.mp = 0
end
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: Morale unit freezers

Post by Kossatx »

Robotron wrote: Fri Aug 21, 2020 4:12 pm I have a theory that sometimes when a nation enters the war the alliance.id is not properly registered until the next turn. Don't ask me why.
Stranger things, but "~= 2" option neither works :|

I have many "freeze scripts" for russian units and all of them work correctly, except these with reference to russian morale. I think something happens with russian morale when enters at war... but I can't prove it :|
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Morale unit freezers

Post by Robotron »

How do you know your freeze scripts work correctly? The AI might haven chosen to keep the fleet in port.
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: Morale unit freezers

Post by Kossatx »

Above 8 russian units are detached at neutral borders (Romania, Turkey and Persia) and the AI sends none to the front. Without including the scripts the AI always send all these troops to the front. Not only Russia do it, but all the nations in the game. That's because I decided to include these scripts to mantain some troops defending borders while neutral.
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Morale unit freezers

Post by Robotron »

Last attempt:

Code: Select all

local reval = game:GetHex(118, 10)
 if     unit.hex ~= nil
 	and unit.hex == reval
 	and unit.faction.id == 4
	and GetEvent("DOWrussia") >0
	and russia.morale > 30  then
		unit.mp = 0
end
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: Morale unit freezers

Post by Kossatx »

Robotron wrote: Fri Aug 21, 2020 6:54 pm Last attempt:

Code: Select all

local reval = game:GetHex(118, 10)
 if     unit.hex ~= nil
 	and unit.hex == reval
 	and unit.faction.id == 4
	and GetEvent("DOWrussia") >0
	and russia.morale > 30  then
		unit.mp = 0
end
No way, it does'nt work :?
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Morale unit freezers

Post by Robotron »

If it does work without morale check, like you said above, then there's just not much else you can do than to remove the morale check, I guess.
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: Morale unit freezers

Post by Kossatx »

Very strange, is not morale the problem, with Reval, Riga and Abo neither works yor "in range" script:

Code: Select all

local reval = game:GetHex(118, 10)
local check = 0
local hexes = game.map:GetHexesInRange(reval, 3)
		for _, hex in pairs(hexes) do
			if hex.unit ~= nil
			and hex.unit.type == Unit.LAND
			and hex.unit.alliance.id == 2 then
				check = 1
				break	
			end
		end
		
		if reval.unit ~= nil 
		and reval.unit.prototype.name == "garrison"
		and reval.unit.faction.id == 1 
		and check == 0	then
			reval.unit.mp = 0
		end	
Post Reply

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