Making a scenario using "Regicide" type of victory

Modding, Map Editor, IES Scripting and Other Questions
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 »

So enable it in script, and then disable.

SetAIDiplomacyEnabled(2,true);
ForceSurrenderOffer(2, 1);
SetAIDiplomacyEnabled(2,false);
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 »

Like this?

Code: Select all

RULE ruleObj_Korean_Peninsula2 ONESHOT
 if (!DoesUnitExist( "tx_King_Korean_1" )
   )
  then KingDeadAction2
END_RULE


ACTION KingDeadAction2
SCRIPT WORLD
SetAIDiplomacyEnabled(2,true);
if(!IsPlayerHumanControlled(2)){
  ForceSurrenderOffer(2, 1);
SetAIDiplomacyEnabled(2,false);
}
else {
CreateNamedGroup("Group_Korea_1");
AddUnitsByTypeToGroup("Group_Korea_1", "Everything", 2, kPlayerMode_Self, NULL);
AddUnitsByAttributeToGroup("Group_Korea_1", "Everything", 2, kPlayerMode_Self, NULL);
if(NumUnitsInGroup("Group_Korea_1") > 0){
SelectGroupForPlayer("Group_Korea_1", 2);
KillSelection();
ClearSelection();
}
}
END_SCRIPT
END_ACTION
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 »

Code: Select all

RULE ruleObj_Korean_Peninsula2 ONESHOT
 if (!DoesUnitExist( "tx_King_Korean_1" )
   )
  then KingDeadAction2
END_RULE


ACTION KingDeadAction2
SCRIPT WORLD
if(!IsPlayerHumanControlled(2)){
  SetAIDiplomacyEnabled(2,true);
  ForceSurrenderOffer(2, 1);
  SetAIDiplomacyEnabled(2,false);
}
else {
CreateNamedGroup("Group_Korea_1");
AddUnitsByTypeToGroup("Group_Korea_1", "Everything", 2, kPlayerMode_Self, NULL);
AddUnitsByAttributeToGroup("Group_Korea_1", "Everything", 2, kPlayerMode_Self, NULL);
if(NumUnitsInGroup("Group_Korea_1") > 0){
SelectGroupForPlayer("Group_Korea_1", 2);
KillSelection();
ClearSelection();
}
}
END_SCRIPT
END_ACTION
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 »



Added after 1 hour 39 minutes 27 seconds:
Haha

Added after 21 minutes 11 seconds:
Also, one of the players is now surrendering before its King is actually eliminated.
Attachments
Снимок.PNG
Снимок.PNG (4.2 KiB) Viewed 1578 times
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 »

Seems like you really don't read the documentation.

Code: Select all

if (PlayerInGame(7)){
//Do stuff
}
In my opinion it would be simpler to create city centers for all players and delete them with a script on game start. So the normal kings would be present in game.
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 »

Yeah, but in that case I will need to fixate them with something different than barbed wire. And also I will need a new map, cause everything here is really compact.
Still, any ideas what can cause the issue with AI players recognition?
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 the player is not in game already? Surrendered?
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 »

What do you mean "not in 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 »

Got killed / resigned / no units left.
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 »

I'll check it again now

Added after 27 minutes 59 seconds:
May be no units left. Anyway, it's not a problem; the real problem is quitting "not AI player" error.
As far as I will hardly continue testing in the near future (unfortunately), I'll just leave scenario here, in case you'll have some spare time to see it and may be rate my scripting fail)

https://drive.google.com/open?id=1lPXzz ... v5fbFgDseN

P.S. Can't attach .scn file here, so share it via cloud

Added after 1 minute 28 seconds:
I don't know, may be today I was close to get everything work:(
Post Reply

Return to “Questions”