Making a scenario using "Regicide" type of victory

Modding, Map Editor, IES Scripting and Other Questions
User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

Re: Making a scenario using "Regicide" type of victory

Post by Loewenherz »

The EE2 "ies" scripting language usually has all command from that what you has seen in the Campaign. So you should not make the AI to a "human" player to stop the AI. Read the doc more or use the search function from you word program, to find the right function.

Code: Select all

  // Pause Players for a while
  PausePlayerAI(2, true);
  PausePlayerAI(3, true);
  PausePlayerAI(4, true);
  PausePlayerAI(5, true);
A AI player can not lose a scenario. Only he can have a stopped AI. :geek:
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160

User avatar
Bogdan
Posts: 149
Joined: 25 Feb 2017, 17:26
Location: Kyiv, Ukraine
Been thanked: 3 times

Re: Making a scenario using "Regicide" type of victory

Post by Bogdan »

Everything is working! Thank you.
Also, I've found these miraculous strings in BFME scenario script:

Code: Select all

GiveAttackBasePreference(5, "areaSarumanAttack", 3.0);
GiveAttackBasePreference(4, "areaGondor", 3.0);
GiveAttackBasePreference(8, "areaGondor", 3.0);
GiveAttackBasePreference(2, "areaBlackGate", 3.0);
As far as I know, these values from 1.0 to 10.0 can be used to prioritize AI actions. I'd like to use them too, but my code:

Code: Select all

GiveAttackBasePreference(4, "tx_terr_korean_11", 7.0);
GiveAttackBasePreference(5, "tx_terr_korean_13", 7.0);
GiveAttackBasePreference(8, "tx_terr_korean_15", 10.0);
GiveDefendBasePreference(7, "tx_terr_korean_11", 8.0);
just doesn't work, despite the fact, that I gave tx names to the required territories :( What could possibly went wrong?
Attachments
Screenshot 2.PNG
Screenshot 2.PNG (3.91 KiB) Viewed 1592 times
EE2_ScreenShot3.jpg
EE2_ScreenShot3.jpg (508 KiB) Viewed 1592 times
User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

Re: Making a scenario using "Regicide" type of victory

Post by Loewenherz »

That are a command for areas, not for territories. Areas are blue "areas" that you place on map, to use them in effects or rules. By the way, the string with tx at beginning like tx_bar_foo_orblblbla are names for strings the are connected with a text in EE2. Use better for scripts name a simple name like "areaWisky" or "UnitDrMonaLisa" or "TerritoryfromLoewenherz" or what ever....
Last edited by Loewenherz on 14 Jul 2018, 15:29, edited 2 times in total.
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160
User avatar
Dr.MonaLisa
High Representative
Posts: 8697
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 49 times
Been thanked: 108 times

Re: Making a scenario using "Regicide" type of victory

Post by Dr.MonaLisa »

Areas are not territory Script Names.
Create new areas by the Map Editor (you will find the option for it).

About removing human players from game... Did you check if there's no other option that would cause resign-alike behavior?

I would simply kill all units and buildings of the selected player.
Something like this (replace iPLAYER1 with player numbers):

Code: Select all

CreateNamedGroup("KillUnitsOfPlayer1");
AddUnitsByTypeToGroup("KillUnitsOfPlayer1", "Everything", iPLAYER1, kPlayerMode_Self, NULL);
or:
AddUnitsByAttributeToGroup("KillUnitsOfPlayer1", "Everything", iPLAYER1, kPlayerMode_Self, NULL);
if(NumUnitsInGroup("KillUnitsOfPlayer1") > 0){
SelectGroupForPlayer("KillUnitsOfPlayer1", iPLAYER1);
KillSelection();
ClearSelection();
}
I'm not sure if Type or Attribute "Everything" is correct.
You can check in file: zips\dbunittypeattributes.ddf
UnitTypeAttribute "MobileUnits" seems to contain everything except Projectiles.
Same for buildings, I think "BareBoneBuilding" would select them all.
So finally it could look like this:

Code: Select all

AddUnitsByAttributeToGroup("KillUnitsOfPlayer1", "MobileUnits", iPLAYER1, kPlayerMode_Self, NULL);
AddUnitsByTypeToGroup("KillUnitsOfPlayer1", "BareBoneBuilding", iPLAYER1, kPlayerMode_Self, NULL);
Remember that AddUnitsByAttributeToGroup and AddUnitsByTypeToGroup can be used as many times as you like, to make sure everything is added to that group.
Also don't forget to use:

Code: Select all

PrintMessage("Player 1 has been eliminated - removing all units!");
to know if script works correctly. PrintMessage is very useful when scripting, and at the end, when your script is ready you could remove all those messages.

To prevent your previous error, there is a function called: IsPlayerHumanControlled().
So it could look like this to prevent debug message displaying:

Code: Select all

if(!IsPlayerHumanControlled(US_ARMY)){
ForceSurrenderOffer(..., ...);
}
The " ! " before function name, means to execute it when it's FALSE.
So same effect as:

Code: Select all

if(IsPlayerHumanControlled(US_ARMY)){
//do nothing
}
else {
ForceSurrenderOffer(..., ...);
}
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
User avatar
Bogdan
Posts: 149
Joined: 25 Feb 2017, 17:26
Location: Kyiv, Ukraine
Been thanked: 3 times

Re: Making a scenario using "Regicide" type of victory

Post by Bogdan »

My script is ready) Thank you all guys! :D
User avatar
Dr.MonaLisa
High Representative
Posts: 8697
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 49 times
Been thanked: 108 times

Re: Making a scenario using "Regicide" type of victory

Post by Dr.MonaLisa »

Just one more tip.
You could place city centers to generate Kings, and then Kill those city centere with SelectUnit(); KillSeletion(). Then Regicide mode would work normally, without any workarounds.
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
User avatar
Bogdan
Posts: 149
Joined: 25 Feb 2017, 17:26
Location: Kyiv, Ukraine
Been thanked: 3 times

Re: Making a scenario using "Regicide" type of victory

Post by Bogdan »

One more problem :(
KingDeadAction command doesn't work as expected.

After AI players lost their Kings and surrender (all units and buildings perish properly), AI players stays at the Diplomacy list and scenario can't be finished! Is there any command to end the game?
User avatar
Dr.MonaLisa
High Representative
Posts: 8697
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 49 times
Been thanked: 108 times

Re: Making a scenario using "Regicide" type of victory

Post by Dr.MonaLisa »

Maybe change "Edit" -> "Victory Conditions..." from "Script Says So" to "Conquest"?
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
User avatar
Bogdan
Posts: 149
Joined: 25 Feb 2017, 17:26
Location: Kyiv, Ukraine
Been thanked: 3 times

Re: Making a scenario using "Regicide" type of victory

Post by Bogdan »

Hm, seems to work now

Added after 2 minutes 20 seconds:
Funny is, SetAITauntsEnabled(false); command doesn't work either. No errors appeared, AI just continue to taunt :lol:
Is it known issue?
User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

Re: Making a scenario using "Regicide" type of victory

Post by Loewenherz »

Unfortunately some commands in the script language doesn't work. Seems that SetAITauntsEnabled belongs to it.
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160
Post Reply

Return to “Questions”