Preventing AI major player from declaring war on minor

ww2commander

Emperor
Joined
Aug 23, 2003
Messages
1,243
Location
Australia
I am just stumbling into new territory with my Eastern Front scenario and need some quick pointers in order to continue coding my supply system model.

In the scenario, neutral Sweden will provide Germany with surplus iron ore quantities and I need to ensure that Germany does not DoW Sweden as this iron ore bonus would then be illogical.

Given the AI does dumb things, I want to capture any DOW from Germany on Sweden and nullify it. How would I go about this?
 
Lua


function NoGermanyDOWOnSweden(myTeam, theirTeam)
// if myTeam is (germany or sweden) and theirteam is (sweden or germany) then
// return false
// end

return true
end
GameEvents.CanDeclareWar.Add(NoGermanyDOWOnSweden)

(or something like that - see the DLC2 (Spain and Incas) scenario for an example
 
Thanks. I knew there was a way but could not remember what to look for in the wiki.....late night programming brain block!

Follow-up question: Can you lock the relations between majors and minors, or are they dynamic and tend to shift throughout the game.

I.e. Can Germany and Sweden be coded to stay on neutral terms throughout the whole game (like in real life)??
 
Thanks. I knew there was a way but could not remember what to look for in the wiki.....late night programming brain block!

Follow-up question: Can you lock the relations between majors and minors, or are they dynamic and tend to shift throughout the game.

I.e. Can Germany and Sweden be coded to stay on neutral terms throughout the whole game (like in real life)??

change "MINOR_FRIENDSHIP_DROP_PER_TURN%" value in defines

SQL:
Code:
UPDATE Defines SET Value = 0 WHERE Name LIKE 'MINOR_FRIENDSHIP_DROP_PER_TURN%';
 
Thanks Gedemon.

It seems I need to do some more reading into diplomacy. I am trying to recycle your code but I am still getting my head around what it does. CS interaction seems to be the area I least understand.

Hopefully you can fill in the blanks...Can city states:

1) Capture cities (I have 'no city razing allowed' selected)
2) Declare war on majors
 
1) yes (I had a strange occurence when Germany DoWed France before the date of DoW for Poland in one of my test game in free mode, and because it's troops were occupied on the french front, Poland actually started to invade Germany, taking 2 cities...)

2/ not independently, but you can force it using
Code:
team:DeclareWar( iTeam2 )

edit : and yes, those parts of the code need cleaning, started to do it a bit on current development version.
 
Back
Top Bottom