Page 1 of 1

AI kills its army

Posted: 07 Jul 2017, 12:03
by Bogdan
Hi, trying to make a new scenario now and have a problem with AI. I gave AI a big army but AI gets rid of it to produce citizens. I know it's a common problem, but is there any script to solve this?

Re: AI kills its army

Posted: 07 Jul 2017, 18:17
by Dr.MonaLisa
Hi. Are you sure that AI deletes it's army? I have never seen/heard about this problem before.
Basically, AI should respect population limits and just not produce new units when population is reached.

Re: AI kills its army

Posted: 08 Jul 2017, 13:24
by Bogdan
Well, it should respect, but it doesn't. I could see what actually AI does after new game is started and in 10 cases out of 10 AI prefers to kill ~60-80% of its army (one or several times) to produce citizens. It depends on pop limit AI has. This problem is well known and you can reproduce it if you give AI no resources, but a big army and city.

UPD: Managed to solve this problem! Just deprived AI of all its cities but left some citizens and storehouses (preventing AI to capitulate). In my scenario there're no spare territories for AI, it can't just built a new city and produce citizens, so now it saves all units it has! Maybe someone will find it helpful

Re: AI kills its army

Posted: 08 Jul 2017, 14:36
by Dr.MonaLisa
I found something in AIPs files, but it won't fix the problem. Just some information:
In files:
aips\AIPDefaults.h
aips\aips\Mil_Default.h

Code: Select all

// do we kill off our units if we get close to popcap?
int killsUnitsForPopcap = 0;
It means, by default this option is disabled. So by default AI should not kill units.

However, for example in file: aips\Skirmish_Default.aip:

Code: Select all

// do we kill off our units if we get close to popcap?
int killsUnitsForPopcap = 1;
So then units might be killed.

What's interesting, this "killsUnitsForPopcap = 1" is present only in 1 file, however this file is probably read by all other scripts.

I could change it with a minor update, but I'm not sure if it wouldn't cause more problems in normal games.

However, I know that it's possible to load custom .aips scripts to scenarios by the Map Editor -> Mission Properties (AI Script tab). The new AI script should be pasted to some folder in Documents/Empire Earth II, but I don't know where exactly. So then you could copy that Skirmish_Default.aip, rename it, modify and try to load for the AI. Also, maybe selecting the other default script would solve the problem? By default it's set to "Mil_Crown".
And yes, I'm sure that custom AI scripts can be loaded, because TheGrouchDE used to do it in the past to control AI behavior. I'll ask him to look into this case, since he's the Minister of the Department of Mods. Maybe he'll give some tips how to load a custom ai script in map editor.

Re: AI kills its army

Posted: 09 Mar 2019, 14:56
by Bogdan
It's interesting that even turning citizens off like

Code: Select all

SetTechEnabled(OTTOMAN_TURKS, "Citizen", false);
doesn't stop AI from killing it's army.

It's just awful. What did developers think about? What's the reason of eliminating your own army function when you've already got a big one?

Re: AI kills its army

Posted: 09 Mar 2019, 16:19
by TheGrouchDE
Hi Bogdan,

i've had already cases when playing the game in which the AI just deleted some of his units. So you're not the only one noticing that sort of behaviour by the AI.
That folder that Dr.MonaLisa mentioned in the post above is the "aips" folder in your installation folder. You edit a copy of a aip file to your wishes and load it with the script AI_ChangePersonality(playerID, "bully.aip"); You just have to change playerID with the name or the number of the AI according to the list of players in EE2 Scenario Editor and the exact name of the your edited .aip file. It then will do exactly what it is told in there. But if you want to play online you need to remove it out of the folder. Otherwise you'll get error about aip files not being the same.

Greetings,

Re: AI kills its army

Posted: 07 Jul 2019, 18:02
by Bogdan
TheGrouchDE wrote: 09 Mar 2019, 16:19 You edit a copy of a aip file to your wishes and load it with the script
I've put my .aip file to 'aips' folder and add that command, but Skirmish_Default .aip file still has a priority. May be this command no longer works?

Re: AI kills its army

Posted: 10 Jul 2019, 00:53
by Dr.MonaLisa
99% of AI behavior is in the .exe file (compiled, impossible to make any edits). I wouldn't be surprised if citizens deletion is also defined there when a specified condition is triggered.

It's similar with Missile Silo. In UP1.5 "Super ICBM Silo" there is a bug which sets missiles number to 0, after you click "attack" with the right mouse button. If you ordered to produce more than 1 missile - it was reset and you lost resources. For few years I was trying to fix it by editing .ddf files, and then one day figured out that "Missile_Silo" has entries in the .exe file which decide about this behavior. So I don't even try to fix it by assembly anymore. it's just hardcoded.
I would say EE2 is not very mod-friendly game. For the last years UP1.5 is good only because of modifications made in assembly. Without it there would be nothing fixed/added except few units and buildings.

Re: AI kills its army

Posted: 10 Jul 2019, 07:14
by Bogdan
Well, I understand you. However, I succeeded to change AI behavior, but only in case of the Skirmish_Default .aip file replacement. It’s just a problem to load a custom .aip with higher priority