Setting Map Editor Objectives

Modding, Map Editor, IES Scripting and Other Questions
Seven243
Posts: 17
Joined: 02 Nov 2022, 21:41
Has thanked: 2 times

Setting Map Editor Objectives

Post by Seven243 »

Hello, I'm making a China versus USA scenario and I was wondering if someone could help me set objectives for the scenario. I've figured out how to set maximum epoch , change the population capacity, and remove the map shroud, but I haven't been able to figure out to create objectives to defend Taiwan and capture Beijing.

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: Setting Map Editor Objectives

Post by Dr.MonaLisa »

Hi. Have you checked this topic: viewtopic.php?t=5589 ?

What exactly are you trying to do? Set objective as completed/ failed if some event occurs?
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
Seven243
Posts: 17
Joined: 02 Nov 2022, 21:41
Has thanked: 2 times

Re: Setting Map Editor Objectives

Post by Seven243 »

Keeping the Taiwan AI from losing control of their territory for 10 minutes or so, then probably just winning the scenario when the player captures the Beijing city center which should be indestructible.
I've looked at that but don't really know what I'm looking for.
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: Setting Map Editor Objectives

Post by Dr.MonaLisa »

Maybe this rule should help:

First, in the initialization section you would need:

Code: Select all

// bool AddUnitToGroup(const char *in_szGroupName,
// const char *in_szUnitName)
// bool RemoveUnitFromGroup(const char *in_szGroupName,
// const char *in_szUnitName)
// Adds/Removes the unit named in_szUnitName to the group
// in_szGroupName.

AddUnitToGroup("BeijingCityGroup", "BeijingCity");
"BeijingCity" should be a script name of the Beijing city center.

Then rule:

Code: Select all

// int GetGroupOwnerID(const char *in_szGroupName)
// If EVERY unit in in_szGroupName is owned by a single player, will
// return that player's ID. If in_szGroupName is empty or has mixed
// ownership, will return -1.
// example usage:

RULE PlayerConquers ONESHOT
if ( (GetGroupOwnerID("BuildingsToCapture") == 1))
then YouCapturedAllTheBuildingsFromThatGroupThatAreStillAlive
END_RULE
And then action:

Code: Select all

ACTION YouCapturedAllTheBuildingsFromThatGroupThatAreStillAlive
SCRIPT WORLD

  // void SetObjectiveCompleted(const char *in_szObjectiveName)
  // Mark the objective in_iObjectiveIndex as completed.
  // in_szObjectiveName must specify a valid objective
  // @NOTE you can only mark unlocked, unfailed objectives as completed
  SetObjectiveCompleted("ObjectiveName");

  // void WinScenario()
  // End scenario (with victory/failure message)
  // Sets the local player as having won the scenario. This will trigger
  // the end of the scenario, but only if there's a 'Script Says So'
  // victory condition set up for the scenario!
  // example usage:
  //You win!
  WinScenario();

END_SCRIPT
END_ACTION

I would recommend you to check the IES SCRIPT COLLECTION: viewtopic.php?p=23816#p23816

This way you can view the .ies scripts of other players and learn or copy from there. You simply find the command you're interested in, and then search in these existing .ies scripts to see how they were used :)
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
Seven243
Posts: 17
Joined: 02 Nov 2022, 21:41
Has thanked: 2 times

Re: Setting Map Editor Objectives

Post by Seven243 »

Thank you for your help, but i have some questions. // means the computer will ignore whatever comes next, right? Do I need to fill out the Definitions section? How can I make the Chinese AI attack a territory? I have " GiveCaptureTerritoryPreference (2, "tx_terr_chinese_21", 6.0); ", but I think I have the territory name wrong. I'm also getting problems with the objective saying stuff like "Symbol 'targetterritory' not found." I'd also like China and the USA to only be able to build 3 nuclear bombers each and North Korea only being able to build a single missile silo, but those are less important.
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: Setting Map Editor Objectives

Post by Dr.MonaLisa »

From what I remember all sections need to be filled up (like an empty IES script created first with all sections added).

I never used the "GiveCaptureTerritoryPreference" function, so unfortunately I can't help with that. I think it's a matter of trying all possibilities and testing yourself what works.

For limiting units, maybe there could be a rule to count units of selected type, and then SetTechEnabled to False, so they wouldn't be able to produce more of these units?
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
Seven243
Posts: 17
Joined: 02 Nov 2022, 21:41
Has thanked: 2 times

Re: Setting Map Editor Objectives

Post by Seven243 »

Okay I got the defend Taiwan objective to show up in the Scenario Objective section, but I don't think it gets marked as complete and I don't know how to make the next objective show. I also added a defeat objective and gave it kScenarioObjectiveType_Lose, but it still puts it in the primary objective section for some reason. I need to figure out how to get the game to recognize territory names in the script file.
User avatar
Loewenherz
Posts: 244
Joined: 23 Sep 2017, 17:26
Has thanked: 7 times
Been thanked: 21 times

Re: Setting Map Editor Objectives

Post by Loewenherz »

Territories can be named in the editor. Simply double-click on an empty space that contains a territory. I forgot to mention this in my tutorial. The rest is done by the script, which I have already listed in detail in the scripting list. So name the territory in the corresponding command.

See: viewtopic.php?p=27260#p27260

under --> Mission Objectives

Tip. You can also copy the script name in the editor with CTRL + C.
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
Seven243
Posts: 17
Joined: 02 Nov 2022, 21:41
Has thanked: 2 times

Re: Setting Map Editor Objectives

Post by Seven243 »

Okay, I don't know if I'm missing something, I gave the territories script names in the editor but I it always says "symbol targetTerritories
or ObjectiveSetTargetTerritory not found". :(
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: Setting Map Editor Objectives

Post by Dr.MonaLisa »

Can you attach the .scn and .ies files?
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
Post Reply

Return to “Questions”