Page 4 of 10

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

Posted: 14 Jul 2018, 19:02
by Bogdan
Heh, nevermind, it's not really important)

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

Posted: 14 Jul 2018, 21:13
by Loewenherz
Can you share the scenario with us? :-D

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

Posted: 14 Jul 2018, 21:20
by Bogdan
It's not yet ready :) I need to test it from A to Z first and also add some story, tips.

Here you can find all scenarios that I've already made (the latest 3 are mine):
http://ee.heavengames.com/downloads/lis ... =0&s=d&o=d

Also, I didn't make such awesome scripts before, so those scenarios are simple. The new one will be the best!

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

Posted: 15 Jul 2018, 12:16
by Bogdan
So, as expected, the bug was found :?
Despite the fact that all of the players (except human player, of course) are now AI players, the error message is still here. How it could be that player 7 is not an AI player when all 2-8 players are AI players in Map Editor?

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

Posted: 15 Jul 2018, 12:23
by Dr.MonaLisa
What is in KingDeadAction7? Could you paste it?

Did you Save the scenario before clicking on Test Mission?

Have you tried the solution from my previous post?: viewtopic.php?p=23981#p23981
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(..., ...);
}

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

Posted: 15 Jul 2018, 12:45
by Bogdan
I don't understand how to apply this solution. For example, I have this:

Code: Select all

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

ACTION KingDeadAction2
SCRIPT WORLD
  ForceSurrenderOffer(2, 1);
END_SCRIPT
END_ACTION
How should I change it to check human player?

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

Posted: 15 Jul 2018, 13:28
by Dr.MonaLisa
As in the example:

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)){
  ForceSurrenderOffer(2, 1);
}
else {
//Other stuff to kill this player. CreateGroup, etc.
}
END_SCRIPT
END_ACTION
Not sure if it should be 2 or 1 (I don't remember all functions syntax).

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

Posted: 15 Jul 2018, 16:18
by Bogdan
Hm, problem is still here. It's also strange that it appears not every time.

Here's my script:

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)){
  ForceSurrenderOffer(2, 1);
}
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
Where Group_Korea_1 is the group created in Map Editor that includes all buildings and units of AI player North Korea 1;
and 2 is the number of North Korea 1 in script

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

Posted: 15 Jul 2018, 16:29
by Dr.MonaLisa
And did you follow the SCRIPTING.doc?
// void ForceSurrenderOffer(int in_iPlayerAI, int in_iPlayerHuman)
// force the AI in_iPlayerAI to surrender to in_iPlayerHuman
// YOU HAVE TO ENABLE STRATEGIC LEVEL DIPLOMACY FOR THIS PLAYER, OR YOU
// WILL GET A WEIRD CRASH WITH A NON OBVIOUS ERROR MESSAGE:
// DO THIS FIRST: SetAIDiplomacyEnabled()


ForceSurrenderOffer(2, 1);
Was AI Diplomacy Enabled in Initialization?

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

Posted: 15 Jul 2018, 16:44
by Bogdan
Nope, I thought
SetAIDiplomacyEnabled(true);
would change Diplomacy conditions