You must be logged in to post messages.
Please login or register

Scenario Design
Moderated by MosheLevi, Mister SCP

Hop to:    
Welcome! You are not logged in. Please Login or Register.736 replies, Sticky
Age of Empires III Heaven » Forums » Scenario Design » The RMS question Thread
Bottom
Topic Subject:The RMS question Thread
« Previous Page  1 ··· 10 ··· 20 ··· 28 29 30  Next Page »
RF_Gandalf
Skirmisher
posted 04-27-06 06:09 AM EDT (US)         
This thread is intended for discussion of questions regarding Random Map Scripting for AOE3. Instead of posting questions separately in the forum, use this thread which will serve as a collection of (?)wisdom for those looking for information. I will be checking this thread at least several times per week, and I hope that the other experienced scripters will join in to add their wisdom.

For those seeking some basic starting help, try these links to some helpful information:
The Age of Wiki has a useful section on Random Map Scripting.

An AOE3RMS Tutorial by MOnTy PyThOn is a pretty complete guide to help you understand the various commands.

Finally, try downloading some of the map scripts at the Age of Empires IIIHeaven RMS Download section and open the map scripts in a text editor and check them out to see how it is done. You could also open the map scripts that came with the game to study their commands; these will be found in the directory: Program Files\Microsoft Games\Age of Empires III\rm.

So post any RMS questions here, we will try to help!

AuthorReplies:
Mister SCP
Scenario Reviewer
posted 08-22-14 01:03 AM EDT (US)     726 / 736       
the caravel isnt hard but requires modding. The simplest thing one could do is a trigger that let a ship permantly follow the travois. It could even upgrade fishingboat->caravel->ironclad?


ESO2 Name:Sir_ConstantinESO Name:Sir_Pacman
Trigger Freak and Modder for AOE3

SCP Editor Tools---my map pack---Some incomplete stuff
My trigger Pack
dietermoreno
Skirmisher
posted 08-30-14 03:35 AM EDT (US)     727 / 736       
The simplest thing one could do is a trigger that let a ship permantly follow the travois
Could you please tell me how to do it? (functions and parameters explained so I learn)

So maybe Knb did it that way, but I'm not looking at their triggers because then I would be commiting plagerism.


So the lake would be given coherence to be circular, the trade route way points would all be in a circle on the water, and the invisible travois (underwater) would be followed by a trade caravel.

So the trade route sockets would ring the lake.

I don't think the trade route way points actually have to be right next to the trade route sockets to still work.

When I played Dalmatia in Knb, I saw that the trade route sockets are scattered on islands all over far from the trade route way points and it still works.

Mummy zombies on the Nile map is actually more historically accurate than tanks being destroyed by pikemen.

Want denser forests and a huge Amazon?

[This message has been edited by dietermoreno (edited 08-30-2014 @ 03:37 AM).]

dietermoreno
Skirmisher
posted 09-10-14 03:01 AM EDT (US)     728 / 736       
I tried to make the ice go around the islands and it didn't work, intialization failed.

The changes I made that caused the map to not work appear in these lines:

// ************************ ICE LAKE *******************************

//Defines the ice sheet, not the water.

//I'm strongly considering getting rid of the lake ice, or at least keeping it much closer to the shore so the islands still place in winter.//


// Place Ice sheet if Winter.




if (seasonPicker >= 0.5)
>=0.5is ice. <0.5 is no ice.
{
int IceArea1ID=rmCreateArea("Ice Area 1");
//rmSetAreaSize(IceArea1ID, 0.14, 0.14);// - old
//How wide the ice is.
//rmSetAreaLocation(IceArea1ID, 0.45, 0.50);// - old
//Where to put the ice before rotating the ice around the lake.
rmSetAreaSize(IceArea1ID, 0.025, 0.03);
//Made the icea area the same width of the original tiny water area, 0.025, 0.03.
rmSetAreaLocation(IceArea1ID, 0.40, 0.40);
//Made the ice area a lower # than the #s of the water area.
rmSetAreaTerrainType(IceArea1ID, "great_lakes\ground_ice1_gl");
rmSetAreaMix(IceArea1ID, "great_lakes_ice");
rmAddAreaToClass(IceArea1ID, classGreatLake);
rmSetAreaBaseHeight(IceArea1ID, 0.0);
rmAddAreaInfluencePoint(IceArea1ID, 0.55, 0.5);
//Stretches the ice around the lake.
rmSetAreaObeyWorldCircleConstraint(IceArea1ID, false);
rmSetAreaMinBlobs(IceArea1ID, 2);
rmSetAreaMaxBlobs(IceArea1ID, 4);
rmSetAreaMinBlobDistance(IceArea1ID, 5);
rmSetAreaMaxBlobDistance(IceArea1ID, 8);
rmSetAreaSmoothDistance(IceArea1ID, 8);
rmSetAreaCoherence(IceArea1ID, 0.8);
rmBuildArea(IceArea1ID);
}

// ********************************* SPRING/FROZEN LAKE *************************************

//Defines the water.

//The lake is covered in ice with very small open water in the middle.


//I'm strongly considering getting rid of the lake ice, or at least keeping it much closer to the shore so the islands still place in winter.//

//I decided to make the ice stay near shore in a ring around the islands.
//The trade route waypoints for the water (invisible underwater travois) can use the ice ring as a reference!

int michiganID=rmCreateArea("Lake Michigan 1");
//The lake water is created.
// 0.37, 0.47
if (seasonPicker < 0.5)
//The lake with no ice cover.
//The "else" condition of the loop above for completely frozen lake is the "if" condition of this loop here!
//Note that there is no "else" in the loop above for the completely frozen lake.
//An "else" is not required in a loop. Only an "if" is required in a loop.
{
rmSetAreaWaterType(michiganID, "great lakes");
rmSetAreaSize(michiganID, 0.15, 0.15);
if (cNumberNonGaiaPlayers >= 4)
rmSetAreaCoherence(michiganID, 0.8);
else
rmSetAreaCoherence(michiganID, 0.9);
rmSetAreaLocation(michiganID, 0.47, 0.52);
rmAddAreaInfluencePoint(michiganID, 0.55, 0.48);
}
else
//If season picker > 0.5, then add ice. This is the else condition, because the season picker goes from 0.0 to 1.0
{
//rmSetAreaSize(michiganID, 0.025, 0.03);
//Notice that the michiganID (the water) is smaller than the water area size in the water random possibility above in the "if" part of the loop.
//Old water area values above.
rmSetAreaSize(michiganID, 0.14, 0.14);

rmSetAreaWaterType(michiganID, "great lakes ice");
//michiganID is not water at all, but actually ice.
rmSetAreaCoherence(michiganID, 0.90);
rmSetAreaLocation(michiganID, 0.50, 0.50);
}
rmAddAreaToClass(michiganID, classGreatLake);
rmSetAreaBaseHeight(michiganID, 0.0);
rmSetAreaObeyWorldCircleConstraint(michiganID, false);
rmSetAreaMinBlobs(michiganID, 2);
rmSetAreaMaxBlobs(michiganID, 4);
rmSetAreaMinBlobDistance(michiganID, 5);
rmSetAreaMaxBlobDistance(michiganID, 8);
rmSetAreaSmoothDistance(michiganID, 0);
rmBuildArea(michiganID);
//build the ice. Now the ice is built. The lake or ice is placed before the lake islands.
//So the lake islands don't place if ice is already placed where the islands belong.


Edit: oh silly me, this is what happens when I'm lazy at 3 AM and just post code here without first checking for dumb mistakes.

The error is I forgot to comment off a comment.

if (seasonPicker >= 0.5)
>=0.5is ice. <0.5 is no ice.
The second line of that should have a //.

Mummy zombies on the Nile map is actually more historically accurate than tanks being destroyed by pikemen.

Want denser forests and a huge Amazon?

[This message has been edited by dietermoreno (edited 09-10-2014 @ 07:19 PM).]

dietermoreno
Skirmisher
posted 01-13-15 10:28 PM EDT (US)     729 / 736       
Any RMS guys still alive in this thread?

I keep getting map failed to load when placing forest blobs

Mummy zombies on the Nile map is actually more historically accurate than tanks being destroyed by pikemen.

Want denser forests and a huge Amazon?
FiscalBasilisk
Skirmisher
posted 04-10-15 05:17 PM EDT (US)     730 / 736       
This might be a stupid question, but is there any way to make an RMS be the same every time? My friends and I are looking to play on a map that will be consistently good, but we want to play with our supremacy accounts, not scenario accounts.
Neuron
Skirmisher
posted 04-10-15 09:23 PM EDT (US)     731 / 736       
Yeah, it's possible to make an RMS spawn fixed. If it's just resources, you can try this map I made for 1v1:

Siberia 1v1

It has perfect balance on both sides. Only the trees are random. The outpost was taken out, but if it's a big deal I can put it back.
FiscalBasilisk
Skirmisher
posted 04-11-15 10:10 AM EDT (US)     732 / 736       
Thank you! That's good to hear. Do you know where I could get the RMS scripts for the built-in maps? I was thinking of modifying Large Deccan or Large Texas to be more stable.
Neuron
Skirmisher
posted 04-11-15 03:41 PM EDT (US)     733 / 736       
You can find them in one of these folders (depending on how you installed the game, CD or Steam):

C:\Program Files (x86)\Microsoft Games\Age of Empires III\RM3
C:\Program Files (x86)\Steam\steamapps\common\Age Of Empires 3\bin\RM3

Then you can open them with a text editor or some IDE. The language is similar with a C/C++ type of language.

Make sure you make backups if u modify anything. Better just copy those and make custom maps, so you are still able to play online.
jparrish
Skirmisher
posted 05-14-15 03:01 PM EDT (US)     734 / 736       
All of the links I can find of the RMS tutorial are dead. Can anyone upload a copy for me somewhere?

*

Yeah, thanks for the help. You won't be hearing from me again.

[This message has been edited by jparrish (edited 05-16-2015 @ 08:50 PM).]

Neuron
Skirmisher
posted 05-18-15 07:12 AM EDT (US)     735 / 736       
If you had a little patience, I could have told you. If you are interested enough, you will find the sources yourself, since everyone who started learning how to code random maps had to go through this problem of not finding resources to learn from.

This is a concise collection of random maps functions:

Japanese community random maps scripting reference (in English)

A complete reference of functions for the game engine for RM, AI, UI, etc. It was made for AOM, but since a huge part of the AOE3 game engine is the same, it's useful.

Mythic Freak's AOM code reference

A simple starter map script I made for everyone who wants a quick way of making a map from zero

http://aoe3.heavengames.com/downloads/showfile.php?fileid=3653
murdilator
Skirmisher
posted 08-20-20 02:23 PM EDT (US)     736 / 736       
I have on my maps a different setup: Adding extra units, extra resources, and enabling units to start with. This example is Legend Incan Sea v2, an Andes-Themed Carolina. Note Starting Trigger 3 seconds (to delay bugged loading issues), Changes (a custom version of the game), Trade Route (adding sockets), AvoidAll2, 2.0 (allows startingunits2 to spawn) and AvoidTESTFactory 5.0 (allows for units to spawn with Factory), and avoidLlama, 60.0 (allows for random livestock placement):
// CAROLINA

// The First Age of Empires III Random Map
// Jan 2003
// Mar 2005
// Nov 2006 - Update to include Asians

include "mercenaries.xs";
include "ypAsianInclude.xs";
include "ypKOTHInclude.xs";

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//Balance Start

/*
An attempt to fix only the biggest flaws in AOE 3 Vanilla Balance
Using only Scenario Triggers inside the Random Map Scripts for maximum compatibility
Draws some Ideas from the Community ESOC for TAD
and took some changes from the Asian Dynasties
Original Idea by Rikikipu: https://eso-community.net/viewtopic.php?t=6550
This Version fixes some remaining issues with Cards and Tech not taking changes into consideration
and adds some additional Balance Changes

Changes:
1. Halb -10 Food Cost, Ruyters -5 food, -5 gold
2. TP -50 Wood Cost(from the Asian Dynasties)
3. Gendarm -25 Base HP and -5 Gold and -5 Food Cost (taken from ESOC Treaty Patch)
4. Oprichnik -25 Base HP and +30 Food Cost, Strelet -5s train time
5. Indian Rajputs -20 wood, Mahouts -50 food and -50 wood, Gurkha -10 gold, +20 HP
6. Monitor Cost decreased by 200 Gold (Reducing Range like in ESOC was not possible)
7. Ports start the game with +50 Wood (Idea of Rikiki to make them viable)
8. Tomahawks -25 food, Kanya Horsemen -25 wood, Mantlets -25 wood
9. Ashigarus +10 gold, Yabusames -20 gold
10. Dog Soldiers -45s train time, Skull Knights -35s train time

*/

void balanceVanilla(void)
{
for(i=1; <cNumberPlayers)
{
rmCreateTrigger("OverallBalance"+i);
rmSwitchToTrigger(rmTriggerID("OverallBalance"+i));
rmAddTriggerCondition("Timer");
rmSetTriggerPriority(3);
rmSetTriggerActive(true);
rmSetTriggerRunImmediately(true);
rmSetTriggerLoop(false);
rmSetTriggerConditionParamInt("Param1", 3);

rmAddTriggerEffect("Unforbid and Enable Unit");
rmSetTriggerEffectParam("ProtoUnit", "MercFusilier");
rmSetTriggerEffectParamInt("PlayerID", i);

rmAddTriggerEffect("Unforbid and Enable Unit");
rmSetTriggerEffectParam("ProtoUnit", "ypRepentantFusilier");
rmSetTriggerEffectParamInt("PlayerID", i);

rmAddTriggerEffect("Unforbid and Enable Unit");
rmSetTriggerEffectParam("ProtoUnit", "ypGroveBuilding");
rmSetTriggerEffectParamInt("PlayerID", i);

rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "TradingPost");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 16);
rmSetTriggerEffectParamInt("Delta", -50);


rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "Monitor");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 15);
rmSetTriggerEffectParamInt("Delta", -200);

if ( rmGetPlayerCiv(i) == 3){
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "Cuirassier");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 15);
rmSetTriggerEffectParamInt("Delta", -5);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "Cuirassier");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 17);
rmSetTriggerEffectParamInt("Delta", -5);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "Cuirassier");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 0);
rmSetTriggerEffectParamInt("Delta", -25);
rmAddTriggerEffect("Modify Protounit");
}

if ( rmGetPlayerCiv(i) == 21){
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "ypMahout");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 16);
rmSetTriggerEffectParamInt("Delta", -50);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "ypMahout");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 17);
rmSetTriggerEffectParamInt("Delta", -50);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "ypRajput");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 16);
rmSetTriggerEffectParamInt("Delta", -20);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "ypNatMercGurkha");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 15);
rmSetTriggerEffectParamInt("Delta", -10);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "ypNatMercGurkha");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 0);
rmSetTriggerEffectParamInt("Delta", 20);
}

if ( rmGetPlayerCiv(i) == 3
|| rmGetPlayerCiv(i) == 4
|| rmGetPlayerCiv(i) == 5
|| rmGetPlayerCiv(i) == 1
){

rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "Halberdier");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 17);
rmSetTriggerEffectParamInt("Delta", -10);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "Ruyter");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 15);
rmSetTriggerEffectParamInt("Delta", -5);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "Ruyter");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 17);
rmSetTriggerEffectParamInt("Delta", -5);
}


if ( rmGetPlayerCiv(i) == rmGetCivID("Portuguese")){
rmCreateTrigger("Wood babe"+i);
rmSwitchToTrigger(rmTriggerID("Wood babe"+i));
rmSetTriggerPriority(3);
rmSetTriggerActive(true);
rmSetTriggerRunImmediately(true);
rmSetTriggerLoop(false);
rmAddTriggerCondition("Always");
rmAddTriggerEffect("Grant Resources");
rmSetTriggerEffectParamInt("PlayerID", i, false);
rmSetTriggerEffectParam("ResName", "Wood", false);
rmSetTriggerEffectParam("Amount", "50", false);
}

if ( rmGetPlayerCiv(i) == rmGetCivID("XPSioux")){
//Uhlan 35s +5 +4
//WarWagon 60 +9 +6

rmCreateTrigger("DogTrainTime"+i);
rmSwitchToTrigger(rmTriggerID("DogTrainTime"+i));
rmSetTriggerPriority(3);
rmSetTriggerActive(true);
rmSetTriggerRunImmediately(false);
rmSetTriggerLoop(false);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "xpDogSoldier");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 3);
rmSetTriggerEffectParamInt("Delta", -40);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "xpMedicineMan");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 3);
rmSetTriggerEffectParamInt("Delta", -15);
}

if ( rmGetPlayerCiv(i) == rmGetCivID("XPAztec")){
//Uhlan 35s +5 +4
//WarWagon 60 +9 +6

rmCreateTrigger("SkullTrainTime"+i);
rmSwitchToTrigger(rmTriggerID("SkullTrainTime"+i));
rmSetTriggerPriority(3);
rmSetTriggerActive(true);
rmSetTriggerRunImmediately(false);
rmSetTriggerLoop(false);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "xpSkullKnight");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 3);
rmSetTriggerEffectParamInt("Delta", -30);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "xpMedicineManAztec");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 3);
rmSetTriggerEffectParamInt("Delta", -10);
}

if ( rmGetPlayerCiv(i) == 6){

rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "Halberdier");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 17);
rmSetTriggerEffectParamInt("Delta", -8);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "Oprichnik");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 17);
rmSetTriggerEffectParamInt("Delta", 30);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "Oprichnik");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 0);
rmSetTriggerEffectParamInt("Delta", -25);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "Strelet");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 3);
rmSetTriggerEffectParamInt("Delta", -5);
}

if ( rmGetPlayerCiv(i) == 19){
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "ypAshigaru");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 15);
rmSetTriggerEffectParamInt("Delta", 10);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "ypYabusame");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 15);
rmSetTriggerEffectParamInt("Delta", -20);
}

if ( rmGetPlayerCiv(i) == rmGetCivID("XPIroquois")){
//Uhlan 35s +5 +4
//WarWagon 60 +9 +6
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "xpTomahawk");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 17);
rmSetTriggerEffectParamInt("Delta", -25);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "xpHorseman");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 16);
rmSetTriggerEffectParamInt("Delta", -25);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "xpMantlet");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 16);
rmSetTriggerEffectParamInt("Delta", -25);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "xpBuilder");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 3);
rmSetTriggerEffectParamInt("Delta", -15);
rmAddTriggerEffect("Modify Protounit");
rmSetTriggerEffectParam("ProtoUnit", "xpMedicineMan");
rmSetTriggerEffectParamInt("PlayerID", i);
rmSetTriggerEffectParamInt("Field", 3);
rmSetTriggerEffectParamInt("Delta", -15);
}


}
}
//Balance Ende
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


// Main entry point for random map script
void main(void)
{

// Text
// These status text lines are used to manually animate the map generation progress bar
rmSetStatusText("",0.01);

//Chooses which natives appear on the map
int subCiv0=-1;
int subCiv1=-1;
int subCiv2=-1;
int subCiv3=-1;

if (rmAllocateSubCivs(4) == true)
{
subCiv0=rmGetCivID("Incas");
rmEchoInfo("subCiv0 is Seminoles "+subCiv0);
if (subCiv0 >= 0)
rmSetSubCiv(0, "Incas");

// Seminoles only half the time
if(rmRandFloat(0,1) < 0.5)
{
subCiv1=rmGetCivID("Incas");
rmEchoInfo("subCiv1 is Seminoles "+subCiv1);
if (subCiv1 >= 0)
rmSetSubCiv(1, "Incas");
}

// Subciv2 is Cherokee
subCiv2=rmGetCivID("Incas");
rmEchoInfo("subCiv2 is Cherokee "+subCiv2);
if (subCiv2 >= 0)
rmSetSubCiv(2, "Incas");

// Subciv 3 is Cherokee
subCiv3=rmGetCivID("Incas");
rmEchoInfo("subCiv3 is Cherokee "+subCiv3);
if (subCiv3 >= 0)
rmSetSubCiv(3, "Incas");

}

float handedness = rmRandFloat(0.0, 1.0);
// > 0.5 is ocean to SE
// < 0.5 is ocean to NE


// Picks the map size
int playerTiles = 17250;
if (cNumberNonGaiaPlayers >4)
playerTiles = 17250;
if (cNumberNonGaiaPlayers >6)
playerTiles = 15750;

int size=2.1*sqrt(cNumberNonGaiaPlayers*playerTiles);
rmEchoInfo("Map size="+size+"m x "+size+"m");
rmSetMapSize(size, size);

// Picks a default water height
rmSetSeaLevel(3);

// Picks default terrain and water
rmSetSeaType("caribbean coast");
rmEnableLocalWater(false);
rmTerrainInitialize("water");
rmSetBaseTerrainMix("caribbean grass");
rmSetMapType("carolina");
rmSetMapType("andes");
rmSetMapType("water");
rmSetWorldCircleConstraint(true);
rmSetMapType("grass");
rmSetMapType("land");
rmSetLightingSet("sonora");

chooseMercs();

//day and night cycle

rmSetLightingSet("sonora");

// Define some classes. These are used later for constraints.
int classPlayer=rmDefineClass("player");
rmDefineClass("classCliff");
int classbigContinent=rmDefineClass("big continent");
rmDefineClass("corner");
rmDefineClass("startingUnit");
rmDefineClass("classForest");
rmDefineClass("importantItem");
rmDefineClass("secrets");
rmDefineClass("flag");
rmDefineClass("classInvis");

// -------------Define constraints
// These are used to have objects and areas avoid each other

// Map edge constraints
int longPlayerConstraint=rmCreateClassDistanceConstraint("continent stays away from players", classPlayer, rmXFractionToMeters(0.15));
//rmEchoInfo("long player constraint = "+rmXFractionToMeters(0.15));


// Player constraints
int playerConstraint=rmCreateClassDistanceConstraint("player vs. player", classPlayer, 20.0);

int TCvsTC=rmCreateTypeDistanceConstraint("TC avoid same", "TownCenter", 50.0);
int CWvsCW=rmCreateTypeDistanceConstraint("CW avoid same", "CoveredWagon", 50.0);
int forestvsTC=rmCreateTypeDistanceConstraint("forest vs. TC", "TownCenter", 20.0);
int forestvsCW=rmCreateTypeDistanceConstraint("forest vs. CW", "CoveredWagon", 20.0);
int avoidTC=rmCreateTypeDistanceConstraint("stuff vs TC", "TownCenter", 60.0);
int shortAvoidTC=rmCreateTypeDistanceConstraint("stuff less vs TC", "TownCenter", 20.0);
int avoidCW=rmCreateTypeDistanceConstraint("stuff vs CW", "CoveredWagon", 60.0);

int flagConstraint=rmCreateHCGPConstraint("flags avoid same", 20.0);
int nearWater10 = rmCreateTerrainDistanceConstraint("near water", "Water", true, 10.0);
int invisConstraint=rmCreateClassDistanceConstraint("continent avoid invis continent", rmClassID("classInvis"), rmXFractionToMeters(0.15));
if (cNumberNonGaiaPlayers >6)
invisConstraint=rmCreateClassDistanceConstraint("continent avoid invis continent large map", rmClassID("classInvis"), rmXFractionToMeters(0.20));

// Bonus area constraint.
int bigContinentConstraint=rmCreateClassDistanceConstraint("avoid bonus island", classbigContinent, 20.0);

// Resource avoidance
int forestConstraint=rmCreateClassDistanceConstraint("forest vs. forest", rmClassID("classForest"), 20.0);
int avoidDeer=rmCreateTypeDistanceConstraint("deer avoids deer", "guanaco", 40.0);
int avoidBerries=rmCreateTypeDistanceConstraint("berry vs berry", "berryBush", 60.0);
int avoidSheep=rmCreateTypeDistanceConstraint("sheep avoids sheep", "sheep", 40.0);
int avoidFastCoin=rmCreateTypeDistanceConstraint("fast coin avoids coin", "gold", 40.0);
int avoidNugget=rmCreateTypeDistanceConstraint("nugget avoid nugget", "abstractNugget", 30.0);
int avoidLlama=rmCreateTypeDistanceConstraint("llama avoids llama", "Llama", 60.0);

// Avoid impassable land
int avoidImpassableLand=rmCreateTerrainDistanceConstraint("avoid impassable land", "Land", false, 6.0);
int longAvoidImpassableLand=rmCreateTerrainDistanceConstraint("long avoid impassable land", "Land", false, 20.0);
if (cNumberNonGaiaPlayers < 3)
longAvoidImpassableLand=rmCreateTerrainDistanceConstraint("long avoid impassable land small map", "Land", false, 12.0);
int shortAvoidImpassableLand=rmCreateTerrainDistanceConstraint("short avoid impassable land", "Land", false, 2.0);
int fishVsFishID=rmCreateTypeDistanceConstraint("fish v fish", "abstractFish", 10.0);
int whaleVsWhaleID=rmCreateTypeDistanceConstraint("whale v whale", "humpbackWhale", 25.0);
int fishLand = rmCreateTerrainDistanceConstraint("fish land", "land", true, 6.0);
int whaleLand = rmCreateTerrainDistanceConstraint("whale v. land", "land", true, 20.0);
int flagVsFlag = rmCreateTypeDistanceConstraint("flag avoid same", "HomeCityWaterSpawnFlag", 20);
int flagEdgeConstraint = rmCreatePieConstraint("flags stay near edge of map", 0.5, 0.5, rmGetMapXSize()-20, rmGetMapXSize()-10, 0, 0, 0);
int avoidCliff=rmCreateClassDistanceConstraint("stuff vs. cliff", rmClassID("classCliff"), 12.0);
int avoidCliffFar=rmCreateClassDistanceConstraint("stuff vs. cliff far", rmClassID("classCliff"), 22.0);
int cliffAvoidCliff=rmCreateClassDistanceConstraint("cliff vs. cliff", rmClassID("classCliff"), 30.0);

// Unit avoidance
int avoidAll=rmCreateTypeDistanceConstraint("avoid all", "all", 4.0);
int avoidAll2=rmCreateTypeDistanceConstraint("avoid all", "all", 2.0);
int avoidTESTFactory=rmCreateTypeDistanceConstraint("avoid Factory", "TESTFactory", 5.0);

// Important object avoidance
int avoidTradeRoute = rmCreateTradeRouteDistanceConstraint("trade route", 8.0);
int nativeAvoidTradeRouteSocket = rmCreateTypeDistanceConstraint("avoid trade route socket", "socketTradeRoute", 20.0);
int avoidImportantItem=rmCreateClassDistanceConstraint("sockets avoid each other", rmClassID("importantItem"), 40.0);
int silverAvoidImportantItem=rmCreateClassDistanceConstraint("silver avoids sockets", rmClassID("importantItem"), 12.0);

// Constraint to avoid water.
int avoidWater8 = rmCreateTerrainDistanceConstraint("avoid water short", "Land", false, 8.0);
int avoidWater16 = rmCreateTerrainDistanceConstraint("avoid water medium", "Land", false, 16.0);
int avoidWater20 = rmCreateTerrainDistanceConstraint("avoid water long", "Land", false, 20.0);


// Text
rmSetStatusText("",0.10);

// DEFINE AREAS

// Complex placement to avoid water and enemy players

if(handedness < 0.5) // NE ocean
{
// If only 2 players place as 2 points
if(cNumberNonGaiaPlayers == 2)
{
rmPlacePlayer(1, 0.5, 0.85);
rmPlacePlayer(2, 0.5, 0.15);
}
// Place by team if 2 teams and sane teams
else if(cNumberTeams == 2 && rmGetNumberPlayersOnTeam(0) < 5 && rmGetNumberPlayersOnTeam(1) < 5)
{
rmSetPlacementTeam(0);
rmSetPlacementSection(0.85, 0.05);
rmPlacePlayersCircular(0.4, 0.4, rmDegreesToRadians(5.0));
rmSetPlacementTeam(1);
rmSetPlacementSection(0.45, 0.65);
rmPlacePlayersCircular(0.4, 0.4, rmDegreesToRadians(5.0));
}
// otherwise just place in one arc FFA style
else
{
rmSetPlacementSection(0.45, 0.05);
rmPlacePlayersCircular(0.4, 0.4, rmDegreesToRadians(5.0));
}
}
else // SE ocean
{
// If only 2 players place as 2 points
if(cNumberNonGaiaPlayers == 2)
{
rmPlacePlayer(1, 0.85, 0.5);
rmPlacePlayer(2, 0.15, 0.5);
}
// Place by team if 2 teams and sane teams
else if(cNumberTeams == 2 && rmGetNumberPlayersOnTeam(0) < 5 && rmGetNumberPlayersOnTeam(1) < 5)
{
rmSetPlacementTeam(0);
rmSetPlacementSection(0.10, 0.30);
rmPlacePlayersCircular(0.4, 0.4, rmDegreesToRadians(5.0));
rmSetPlacementTeam(1);
rmSetPlacementSection(0.70, 0.90);
rmPlacePlayersCircular(0.4, 0.4, rmDegreesToRadians(5.0));
}
// otherwise just place in one arc FFA style
else
{
rmSetPlacementSection(0.70, 0.30);
rmPlacePlayersCircular(0.4, 0.4, rmDegreesToRadians(5.0));
}
}

// Set up player areas.
float playerFraction=rmAreaTilesToFraction(1000);
for(i=1; <cNumberPlayers){
int id=rmCreateArea("Player"+i);
rmSetPlayerArea(i, id);
rmSetAreaWarnFailure(id, false);
rmSetAreaSize(id, playerFraction, playerFraction);
rmAddAreaToClass(id, classPlayer);
rmSetAreaMinBlobs(id, 1);
rmSetAreaMaxBlobs(id, 1);
rmAddAreaConstraint(id, playerConstraint);
rmAddAreaConstraint(id, avoidWater8);
rmSetAreaLocPlayer(id, i);
rmSetAreaCoherence(id, 0.9);
}

rmBuildAllAreas();


// Text
rmSetStatusText("",0.20);

// Invisible continent added to have big continent avoid player areas

int invisContinentID=rmCreateArea("invisible continent for constraint");
rmSetAreaSize(invisContinentID, 0.01, 0.01);
rmSetAreaWarnFailure(invisContinentID, false);

if(handedness < 0.5) // NE ocean
{
rmSetAreaLocation(invisContinentID, 0.99, 0.5);
rmAddAreaInfluenceSegment(invisContinentID, 0.95, 0.30, 0.99, 0.5);
rmAddAreaInfluenceSegment(invisContinentID, 0.99, 0.5, 0.95, 0.70);
}
else{
rmSetAreaLocation(invisContinentID, 0.5, 0.01);
rmAddAreaInfluenceSegment(invisContinentID, 0.30, 0.05, 0.5, 0.01);
rmAddAreaInfluenceSegment(invisContinentID, 0.5, 0.01, 0.70, 0.05);
}
rmAddAreaToClass(invisContinentID, rmClassID("classInvis"));
rmSetAreaCoherence(invisContinentID, 0.8);

//rmSetAreaBaseHeight(invisContinentID, 3);
//rmSetAreaMix(invisContinentID, "carolina_grass");

// Build the areas.
rmBuildArea(invisContinentID);

// Build up big continent called "big continent"
int bigContinentID = -1;
bigContinentID=rmCreateArea("big continent");
rmSetAreaSize(bigContinentID, 0.40, 0.47); // 0.38 0.47
rmSetAreaWarnFailure(bigContinentID, false);
rmAddAreaConstraint(bigContinentID, invisConstraint);
rmAddAreaToClass(bigContinentID, classbigContinent);

rmSetAreaMinBlobs(bigContinentID, 10);
rmSetAreaMaxBlobs(bigContinentID, 10);
rmSetAreaMinBlobDistance(bigContinentID, rmXFractionToMeters(0.1));
rmSetAreaMaxBlobDistance(bigContinentID, rmXFractionToMeters(0.4));

rmSetAreaSmoothDistance(bigContinentID, 50);
rmSetAreaMix(bigContinentID, "andes_grass_a");
rmSetAreaElevationType(bigContinentID, cElevTurbulence);
rmSetAreaElevationVariation(bigContinentID, 4.0);
rmSetAreaBaseHeight(bigContinentID, 3.5);
rmSetAreaElevationMinFrequency(bigContinentID, 0.09);
rmSetAreaElevationOctaves(bigContinentID, 3);
rmSetAreaElevationPersistence(bigContinentID, 0.2);
rmSetAreaElevationNoiseBias(bigContinentID, 1);

rmSetAreaCoherence(bigContinentID, 0.15);

// CHOOSE RIGHT OR LEFT-HANDED CONTINENT
if(handedness < 0.5) // NE ocean
{
rmSetAreaLocation(bigContinentID, 0.25, 0.5);
rmAddAreaInfluenceSegment(bigContinentID, 0.5, 0.0, 0.5, 1.0);
rmAddAreaInfluenceSegment(bigContinentID, 0.0, 0.5, 0.4, 0.5);
}
else // SE ocean
{
rmSetAreaLocation(bigContinentID, 0.5, 0.75);
rmAddAreaInfluenceSegment(bigContinentID, 0.0, 0.5, 1.0, 0.5);
rmAddAreaInfluenceSegment(bigContinentID, 0.5, 1.0, 0.5, 0.6);
}

rmSetAreaEdgeFilling(bigContinentID, 10);
rmSetAreaObeyWorldCircleConstraint(bigContinentID, false);

rmBuildArea(bigContinentID);

// Text
rmSetStatusText("",0.30);

// TRADE ROUTES
int tradeRouteID = rmCreateTradeRoute();

int socketID=rmCreateObjectDef("sockets for Trade Route");
rmAddObjectDefItem(socketID, "SocketTradeRoute", 1, 0.0);
rmAddObjectDefConstraint(socketID, avoidWater8);
rmAddObjectDefToClass(socketID, rmClassID("importantItem"));
rmSetObjectDefAllowOverlap(socketID, true);
rmSetObjectDefMinDistance(socketID, 0.0);
rmSetObjectDefMaxDistance(socketID, 8.0);

rmAddClosestPointConstraint(avoidWater16);
vector tradeRoutePoint = cOriginVector;

if(handedness < 0.5) // Ocean to NE
{
tradeRoutePoint = rmFindClosestPoint(0.3, 0.05, 20.0);
rmAddTradeRouteWaypoint(tradeRouteID, rmXMetersToFraction(xsVectorGetX(tradeRoutePoint)), rmZMetersToFraction(xsVectorGetZ(tradeRoutePoint)));

rmAddRandomTradeRouteWaypoints(tradeRouteID, 0.5, 0.5, 6, 6);

tradeRoutePoint = rmFindClosestPoint(0.3, 0.95, 20.0);
rmAddRandomTradeRouteWaypoints(tradeRouteID, rmXMetersToFraction(xsVectorGetX(tradeRoutePoint)), rmZMetersToFraction(xsVectorGetZ(tradeRoutePoint)), 4, 6);
}
else // Ocean to SE
{
tradeRoutePoint = rmFindClosestPoint(0.05, 0.7, 20.0);
rmAddTradeRouteWaypoint(tradeRouteID, rmXMetersToFraction(xsVectorGetX(tradeRoutePoint)), rmZMetersToFraction(xsVectorGetZ(tradeRoutePoint)));

rmAddRandomTradeRouteWaypoints(tradeRouteID, 0.5, 0.5, 6, 6);

tradeRoutePoint = rmFindClosestPoint(0.95, 0.7, 20.0);
rmAddRandomTradeRouteWaypoints(tradeRouteID, rmXMetersToFraction(xsVectorGetX(tradeRoutePoint)), rmZMetersToFraction(xsVectorGetZ(tradeRoutePoint)), 4, 6);
}

bool placedTradeRoute = rmBuildTradeRoute(tradeRouteID, "dirt");
if(placedTradeRoute == false)
rmEchoError("Failed to place trade route");

// Text
rmSetStatusText("",0.40);

// add the sockets along the trade route.
rmSetObjectDefTradeRouteID(socketID, tradeRouteID);
vector socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.05);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.09);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.15);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.20);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.25);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.31);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.36);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.40);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.45);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.55);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.60);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.64);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.69);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.75);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.80);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.85);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.91);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.95);
rmPlaceObjectDefAtPoint(socketID, 0, socketLoc);

rmClearClosestPointConstraints();

// PLAYER STARTING RESOURCES

// Place TC or CW now. Find location later to place other resources.

int TCID = rmCreateObjectDef("player TC");
if ( rmGetNomadStart())
rmAddObjectDefItem(TCID, "coveredWagon", 1, 0);
else
rmAddObjectDefItem(TCID, "townCenter", 1, 0);
rmSetObjectDefMinDistance(TCID, 0.0);
rmSetObjectDefMaxDistance(TCID, 20.0);
rmAddObjectDefConstraint(TCID, avoidTradeRoute);
rmAddObjectDefConstraint(TCID, TCvsTC);
rmAddObjectDefConstraint(TCID, CWvsCW);
rmAddObjectDefConstraint(TCID, avoidImpassableLand);
for(i=1; <cNumberPlayers)
{
rmPlaceObjectDefAtLoc(TCID, i, rmPlayerLocXFraction(i), rmPlayerLocZFraction(i));

}

int startingUnits = rmCreateStartingUnitsObjectDef(15.0);
rmSetObjectDefMinDistance(startingUnits, 6.0);
rmSetObjectDefMaxDistance(startingUnits, 20.0);
rmAddObjectDefConstraint(startingUnits, avoidAll2);
rmAddObjectDefConstraint(startingUnits, shortAvoidImpassableLand);

int startingUnits2 = rmCreateObjectDef("extra units");
rmAddObjectDefItem(startingUnits2, "Bank", rmRandInt(1,2), 18.0);
rmAddObjectDefItem(startingUnits2, "TESTFactory", rmRandInt(1,1), 20.0);
rmAddObjectDefItem(startingUnits2, "SettlerWagon", rmRandInt(13,15), 20.0);
rmAddObjectDefItem(startingUnits2, "Pilgrim", rmRandInt(17,18), 20.0);
rmAddObjectDefItem(startingUnits2, "Pilgrim", rmRandInt(12,13), 20.0);
rmAddObjectDefItem(startingUnits2, "Miner", rmRandInt(15,20), 19.0);
rmAddObjectDefItem(startingUnits2, "CoureurCree", rmRandInt(14,15), 25.0);
rmAddObjectDefItem(startingUnits2, "Coureur", rmRandInt(12,13), 25.0);
rmAddObjectDefItem(startingUnits2, "Coureur", rmRandInt(8,9), 25.0);
rmAddObjectDefItem(startingUnits2, "SPCPopBlock", rmRandInt(20,20), 20.0);
rmAddObjectDefItem(startingUnits2, "ypDockWagon", rmRandInt(3,4), 20.0);
rmAddObjectDefItem(startingUnits2, "TownCenter", rmRandInt(3,4), 30.0);
rmAddObjectDefItem(startingUnits2, "ypOutpostAsian", rmRandInt(5,6), 30.0);
rmAddObjectDefItem(startingUnits2, "YPGroveWagon", rmRandInt(1,2), 30.0);
rmSetObjectDefMinDistance(startingUnits2, 12.0);
rmSetObjectDefMaxDistance(startingUnits2, 27.0);
rmAddObjectDefConstraint(startingUnits2, avoidAll2);
rmAddObjectDefConstraint(startingUnits2, avoidTESTFactory);
rmAddObjectDefConstraint(startingUnits2, avoidImpassableLand);
rmAddObjectDefToClass(startingUnits, rmClassID("startingUnit"));

int playerSilverID = rmCreateObjectDef("player silver");
rmAddObjectDefItem(playerSilverID, "mine", 1, 5.0);
rmAddObjectDefItem(playerSilverID, "mine", 1, 8.0);
rmAddObjectDefConstraint(playerSilverID, avoidTradeRoute);
rmSetObjectDefMinDistance(playerSilverID, 18.0);
rmSetObjectDefMaxDistance(playerSilverID, 25.0);
rmAddObjectDefConstraint(playerSilverID, avoidAll);
rmAddObjectDefConstraint(playerSilverID, shortAvoidImpassableLand);

int playerCrateID=rmCreateObjectDef("bonus starting crates");
rmAddObjectDefItem(playerCrateID, "crateOfFood", rmRandInt(2, 3), 4.0);
rmAddObjectDefItem(playerCrateID, "crateOfWood", rmRandInt(2, 3), 4.0);
rmAddObjectDefItem(playerCrateID, "crateOfCoin", rmRandInt(2, 3), 4.0);
rmSetObjectDefMinDistance(playerCrateID, 6);
rmSetObjectDefMaxDistance(playerCrateID, 10);
rmAddObjectDefConstraint(playerCrateID, avoidAll);
rmAddObjectDefConstraint(playerCrateID, shortAvoidImpassableLand);

int playerBerryID=rmCreateObjectDef("player berries");
rmAddObjectDefItem(playerBerryID, "berryBush", rmRandInt(2,3), 2.5);
rmAddObjectDefItem(playerBerryID, "CrateOfFoodLarge", rmRandInt(2,2), 2.5);
rmAddObjectDefItem(playerBerryID, "CrateOfWoodLarge", rmRandInt(2,2), 2.5);
rmSetObjectDefMinDistance(playerBerryID, 10);
rmSetObjectDefMaxDistance(playerBerryID, 15);
rmAddObjectDefConstraint(playerBerryID, avoidAll);
rmAddObjectDefConstraint(playerBerryID, shortAvoidImpassableLand);

int farBerriesID=rmCreateObjectDef("far berries");
rmAddObjectDefItem(farBerriesID, "berryBush", rmRandInt(5,8), 8.0);
rmAddObjectDefItem(farBerriesID, "CrateOfFoodLarge", rmRandInt(2,3), 5.0);
rmAddObjectDefItem(farBerriesID, "CrateOfWoodLarge", rmRandInt(2,3), 5.0);
rmAddObjectDefItem(farBerriesID, "CrateOfCoinLarge", rmRandInt(2,3), 5.0);
rmSetObjectDefMinDistance(farBerriesID, 80);
rmSetObjectDefMaxDistance(farBerriesID, 120);
rmAddObjectDefConstraint(farBerriesID, avoidAll);
rmAddObjectDefConstraint(farBerriesID, avoidTC);
rmAddObjectDefConstraint(farBerriesID, avoidCW);
rmAddObjectDefConstraint(farBerriesID, avoidBerries);
rmAddObjectDefConstraint(farBerriesID, avoidImpassableLand);

int playerTreeID=rmCreateObjectDef("player trees");
rmAddObjectDefItem(playerTreeID, "TreeAndes", 1, 0.0);
rmSetObjectDefMinDistance(playerTreeID, 8);
rmSetObjectDefMaxDistance(playerTreeID, 12);
rmAddObjectDefConstraint(playerTreeID, avoidAll);
rmAddObjectDefConstraint(playerTreeID, shortAvoidImpassableLand);

int waterFlagID=rmCreateObjectDef("HC water flag "+i);
rmAddObjectDefItem(waterFlagID, "HomeCityWaterSpawnFlag", 1, 0.0);
rmAddClosestPointConstraint(flagEdgeConstraint);
rmAddClosestPointConstraint(flagVsFlag);
rmAddClosestPointConstraint(bigContinentConstraint);
rmAddClosestPointConstraint(fishLand);

// Nuggets per player
int nugget1= rmCreateObjectDef("nugget easy");
rmAddObjectDefItem(nugget1, "Nugget", 1, 0.0);
rmSetNuggetDifficulty(1, 1);
rmAddObjectDefConstraint(nugget1, shortAvoidImpassableLand);
rmAddObjectDefConstraint(nugget1, avoidNugget);
rmAddObjectDefConstraint(nugget1, avoidTradeRoute);
rmAddObjectDefConstraint(nugget1, avoidAll);
rmSetObjectDefMinDistance(nugget1, 40.0);
rmSetObjectDefMaxDistance(nugget1, 60.0);

int nugget2= rmCreateObjectDef("nugget medium");
rmAddObjectDefItem(nugget2, "Nugget", 1, 0.0);
rmSetNuggetDifficulty(2, 2);
rmSetObjectDefMinDistance(nugget2, 0.0);
rmSetObjectDefMaxDistance(nugget2, rmXFractionToMeters(0.5));
rmAddObjectDefConstraint(nugget2, shortAvoidImpassableLand);
rmAddObjectDefConstraint(nugget2, avoidNugget);
rmAddObjectDefConstraint(nugget2, avoidTC);
rmAddObjectDefConstraint(nugget2, avoidCW);
rmAddObjectDefConstraint(nugget2, avoidTradeRoute);
rmAddObjectDefConstraint(nugget2, avoidAll);
rmAddObjectDefConstraint(nugget2, avoidWater20);
rmSetObjectDefMinDistance(nugget2, 80.0);
rmSetObjectDefMaxDistance(nugget2, 120.0);

// Text
rmSetStatusText("",0.50);

// FOOD
int nearDeerID=rmCreateObjectDef("deer herds near town");
rmAddObjectDefItem(nearDeerID, "guanaco", rmRandInt(20,24), 10.0);
rmSetObjectDefMinDistance(nearDeerID, 30);
rmSetObjectDefMaxDistance(nearDeerID, 40);
rmAddObjectDefConstraint(nearDeerID, avoidDeer);
rmAddObjectDefConstraint(nearDeerID, avoidAll);
rmAddObjectDefConstraint(nearDeerID, avoidImpassableLand);
rmSetObjectDefCreateHerd(nearDeerID, true);

int farDeerID=rmCreateObjectDef("deer herds far away");
int bonusChance=rmRandFloat(0, 1);
if(bonusChance<0.5)
rmAddObjectDefItem(farDeerID, "guanaco", rmRandInt(20,24), 10.0);
else
rmAddObjectDefItem(farDeerID, "guanaco", rmRandInt(25,28), 10.0);
rmSetObjectDefMinDistance(farDeerID, 60);
rmSetObjectDefMaxDistance(farDeerID, 90);
rmAddObjectDefConstraint(farDeerID, avoidDeer);
rmAddObjectDefConstraint(farDeerID, avoidAll);
rmAddObjectDefConstraint(farDeerID, avoidTC);
rmAddObjectDefConstraint(farDeerID, avoidCW);
rmAddObjectDefConstraint(farDeerID, avoidImpassableLand);
rmSetObjectDefCreateHerd(farDeerID, true);

// NATIVE AMERICANS

// Text
rmSetStatusText("",0.60);

if (subCiv0 == rmGetCivID("Incas")) // center
{
int seminoleVillageID = -1;
int seminoleVillageType = rmRandInt(1,5);
seminoleVillageID = rmCreateGrouping("inca village 1", "native inca village "+seminoleVillageType);
rmSetGroupingMinDistance(seminoleVillageID, 0.0);
rmSetGroupingMaxDistance(seminoleVillageID, 30);
rmAddGroupingConstraint(seminoleVillageID, avoidImpassableLand);
rmAddGroupingToClass(seminoleVillageID, rmClassID("importantItem"));
rmAddGroupingConstraint(seminoleVillageID, avoidTradeRoute);
rmAddGroupingConstraint(seminoleVillageID, avoidImportantItem);
rmAddGroupingConstraint(seminoleVillageID, nativeAvoidTradeRouteSocket);
rmAddGroupingConstraint(seminoleVillageID, avoidTC);
rmAddGroupingConstraint(seminoleVillageID, avoidCW);
if (handedness < 0.5)
rmPlaceGroupingAtLoc(seminoleVillageID, 0, 0.05, 0.5);
else //handedness > 0.5
rmPlaceGroupingAtLoc(seminoleVillageID, 0, 0.5, 0.95);
}

if (subCiv1 == rmGetCivID("Incas")) // beach
{
int seminole2VillageID = -1;
int seminole2VillageType = rmRandInt(1,5);
seminole2VillageID = rmCreateGrouping("inca village", "native inca village "+seminole2VillageType);
rmSetGroupingMinDistance(seminole2VillageID, 0.0);
rmSetGroupingMaxDistance(seminole2VillageID, 40);
rmAddGroupingConstraint(seminole2VillageID, avoidImpassableLand);
rmAddGroupingToClass(seminole2VillageID, rmClassID("importantItem"));
rmAddGroupingConstraint(seminole2VillageID, avoidTradeRoute);
rmAddGroupingConstraint(seminole2VillageID, avoidImportantItem);
rmAddGroupingConstraint(seminole2VillageID, nativeAvoidTradeRouteSocket);
rmAddGroupingConstraint(seminole2VillageID, avoidTC);
rmAddGroupingConstraint(seminole2VillageID, avoidCW);
if (handedness < 0.5)
rmPlaceGroupingAtLoc(seminole2VillageID, 0, 0.65, 0.5);
else //handedness > 0.5
rmPlaceGroupingAtLoc(seminole2VillageID, 0, 0.5, 0.35);
}

if (subCiv2 == rmGetCivID("Incas")) // edge
{
int cherokeeVillageID = -1;
int cherokeeVillageType = rmRandInt(1,5);
cherokeeVillageID = rmCreateGrouping("inca village 2", "native inca village "+cherokeeVillageType);
rmSetGroupingMinDistance(cherokeeVillageID, 0.0);
rmSetGroupingMaxDistance(cherokeeVillageID, 30);
rmAddGroupingConstraint(cherokeeVillageID, avoidImpassableLand);
rmAddGroupingToClass(cherokeeVillageID, rmClassID("importantItem"));
rmAddGroupingConstraint(cherokeeVillageID, avoidTradeRoute);
rmAddGroupingConstraint(cherokeeVillageID, avoidImportantItem);
rmAddGroupingConstraint(cherokeeVillageID, nativeAvoidTradeRouteSocket);
rmAddGroupingConstraint(cherokeeVillageID, shortAvoidTC);

if (handedness < 0.5)
{
rmPlaceGroupingAtLoc(cherokeeVillageID, 0, 0.25, 0.30); // NE
}
else
{
rmPlaceGroupingAtLoc(cherokeeVillageID, 0, 0.30, 0.75); // SE
}
}

if(subCiv3 == rmGetCivID("Incas")) // edge
{
int cherokee2VillageID = -1;
int cherokee2VillageType = rmRandInt(1,5);
cherokee2VillageID = rmCreateGrouping("inca village 3", "native inca village "+cherokee2VillageType);
rmSetGroupingMinDistance(cherokee2VillageID, 0.0);
rmSetGroupingMaxDistance(cherokee2VillageID, 30);
rmAddGroupingConstraint(cherokee2VillageID, avoidImpassableLand);
rmAddGroupingToClass(cherokee2VillageID, rmClassID("importantItem"));
rmAddGroupingConstraint(cherokee2VillageID, avoidTradeRoute);
rmAddGroupingConstraint(cherokee2VillageID, avoidImportantItem);
rmAddGroupingConstraint(cherokee2VillageID, nativeAvoidTradeRouteSocket);
rmAddGroupingConstraint(cherokee2VillageID, shortAvoidTC);

if (handedness < 0.5){
rmPlaceGroupingAtLoc(cherokee2VillageID, 0, 0.25, 0.70); // NE
}
else{
rmPlaceGroupingAtLoc(cherokee2VillageID, 0, 0.70, 0.75); //SE
}
}

// Text
rmSetStatusText("",0.70);

// Place Far Silver

int silverID = -1;
int silverCount = (cNumberNonGaiaPlayers*2 + rmRandInt(4,6));
rmEchoInfo("silver count = "+silverCount);

for(i=0; < silverCount){
silverID = rmCreateObjectDef("silver "+i);
rmAddObjectDefItem(silverID, "mine", 1, 5.0);
rmAddObjectDefItem(silverID, "mine", 1, 8.0);
rmSetObjectDefMinDistance(silverID, 0.0);
rmSetObjectDefMaxDistance(silverID, rmXFractionToMeters(0.5));
rmAddObjectDefConstraint(silverID, avoidFastCoin);
rmAddObjectDefConstraint(silverID, avoidAll);
rmAddObjectDefConstraint(silverID, avoidTC);
rmAddObjectDefConstraint(silverID, avoidCW);
rmAddObjectDefConstraint(silverID, silverAvoidImportantItem);
rmAddObjectDefConstraint(silverID, longAvoidImpassableLand);
rmAddObjectDefConstraint(silverID, avoidTradeRoute);
rmPlaceObjectDefAtLoc(silverID, 0, 0.5, 0.5);
}

// Create an island with crates

if(rmRandFloat(0,1) < 0.75){
int shipwreckIslandID=rmCreateArea("shipwreck island");
rmSetAreaSize(shipwreckIslandID, rmAreaTilesToFraction(200), rmAreaTilesToFraction(200));
rmSetAreaTerrainType(shipwreckIslandID, "Caribbean\shoreline1");
rmSetAreaBaseHeight(shipwreckIslandID, 3.5);
rmSetAreaHeightBlend(shipwreckIslandID, 1.0);
rmSetAreaSmoothDistance(shipwreckIslandID, 10);
rmSetAreaWarnFailure(shipwreckIslandID, false);
rmSetAreaCoherence(shipwreckIslandID, 1.0);
rmAddAreaConstraint(shipwreckIslandID, bigContinentConstraint);
rmAddAreaConstraint(shipwreckIslandID, longPlayerConstraint);
rmBuildArea(shipwreckIslandID);

int islandCrateID= rmCreateObjectDef("island crates");
rmAddObjectDefItem(islandCrateID, "TreeAndes", rmRandInt(1,2), 1);
rmAddObjectDefItem(islandCrateID, "CrateofFood", rmRandInt(1,2), 3);
rmAddObjectDefItem(islandCrateID, "CrateofWood", rmRandInt(1,2), 4);
rmAddObjectDefItem(islandCrateID, "CrateofCoin", rmRandInt(1,2), 4);
rmPlaceObjectDefInArea(islandCrateID, 0, rmAreaID("shipwreck island"), 1);
}

// fish

int fishID=rmCreateObjectDef("sardine");
rmAddObjectDefItem(fishID, "FishSardine", 2, 3.0);
rmSetObjectDefMinDistance(fishID, 0.0);
rmSetObjectDefMaxDistance(fishID, rmXFractionToMeters(0.5));
rmAddObjectDefConstraint(fishID, fishVsFishID);
rmAddObjectDefConstraint(fishID, fishLand);
rmPlaceObjectDefAtLoc(fishID, 0, 0.5, 0.5, 8*cNumberNonGaiaPlayers);

int fish2ID=rmCreateObjectDef("tarpon");
rmAddObjectDefItem(fish2ID, "FishTarpon", 2, 3.0);
rmSetObjectDefMinDistance(fish2ID, 0.0);
rmSetObjectDefMaxDistance(fish2ID, rmXFractionToMeters(0.5));
rmAddObjectDefConstraint(fish2ID, fishVsFishID);
rmAddObjectDefConstraint(fish2ID, fishLand);
rmPlaceObjectDefAtLoc(fish2ID, 0, 0.5, 0.5, 4*cNumberNonGaiaPlayers);

int whaleID=rmCreateObjectDef("whale");
rmAddObjectDefItem(whaleID, "humpbackWhale", 1, 9.0);
rmSetObjectDefMinDistance(whaleID, 0.0);
rmSetObjectDefMaxDistance(whaleID, rmXFractionToMeters(0.5));
rmAddObjectDefConstraint(whaleID, whaleVsWhaleID);
rmAddObjectDefConstraint(whaleID, whaleLand);
rmPlaceObjectDefAtLoc(whaleID, 0, 0.5, 0.5, 5*cNumberNonGaiaPlayers);

// Text
rmSetStatusText("",0.80);

// Place player starting resources

for(i=1; <cNumberPlayers)
{

vector TCLocation = rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TCID, i));
vector closestPoint = rmFindClosestPointVector(TCLocation, rmXFractionToMeters(1.0));

rmPlaceObjectDefAtLoc(startingUnits, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(startingUnits2, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));

if (rmGetNomadStart() == false)
rmPlaceObjectDefAtLoc(playerCrateID, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));

rmPlaceObjectDefAtLoc(playerTreeID, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(playerTreeID, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(playerTreeID, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(playerTreeID, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));

rmPlaceObjectDefAtLoc(playerBerryID, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(farBerriesID, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));

rmPlaceObjectDefAtLoc(playerSilverID, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));

rmPlaceObjectDefAtLoc(nugget1, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(nugget1, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(nugget2, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));

if(ypIsAsian(i) && rmGetNomadStart() == false)
rmPlaceObjectDefAtLoc(ypMonasteryBuilder(i), i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));

rmPlaceObjectDefAtLoc(nearDeerID, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(farDeerID, 0, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));

rmPlaceObjectDefAtLoc(waterFlagID, i, rmXMetersToFraction(xsVectorGetX(closestPoint)), rmZMetersToFraction(xsVectorGetZ(closestPoint)));
}

rmClearClosestPointConstraints();

// Text
rmSetStatusText("",0.90);

// Place extra nuggets not per player

// check for KOTH game mode
if(rmGetIsKOTH()) {

int randLoc = rmRandInt(1,2);
float xLoc = 0.5;
float yLoc = 0.5;
float walk = 0.075;

//~ if(randLoc == 1)
//~ yLoc = .5;

//~ else
//~ yLoc = .8;

//~ if(cNumberTeams > 2) {
//~ yLoc = rmRandFloat(.1, .9);
//~ walk = 0.25;
//~ }

ypKingsHillPlacer(xLoc, yLoc, walk, 0);
rmEchoInfo("XLOC = "+xLoc);
rmEchoInfo("XLOC = "+yLoc);
}

int nugget3= rmCreateObjectDef("nugget hard");
rmAddObjectDefItem(nugget3, "Nugget", 1, 0.0);
rmSetNuggetDifficulty(3, 3);
rmSetObjectDefMinDistance(nugget3, 0.0);
rmSetObjectDefMaxDistance(nugget3, rmXFractionToMeters(0.5));
rmAddObjectDefConstraint(nugget3, shortAvoidImpassableLand);
rmAddObjectDefConstraint(nugget3, avoidNugget);
rmAddObjectDefConstraint(nugget3, avoidTC);
rmAddObjectDefConstraint(nugget3, avoidCW);
rmAddObjectDefConstraint(nugget3, avoidTradeRoute);
rmAddObjectDefConstraint(nugget3, avoidAll);
rmAddObjectDefConstraint(nugget3, avoidWater20);
rmPlaceObjectDefAtLoc(nugget3, 0, 0.5, 0.5, cNumberNonGaiaPlayers);

if (rmRandFloat(0,1) < 0.1)
{
int nugget4= rmCreateObjectDef("nugget nuts");
rmAddObjectDefItem(nugget4, "Nugget", 1, 0.0);
rmSetNuggetDifficulty(4, 4);
rmSetObjectDefMinDistance(nugget4, 0.0);
rmSetObjectDefMaxDistance(nugget4, rmXFractionToMeters(0.5));
rmAddObjectDefConstraint(nugget4, shortAvoidImpassableLand);
rmAddObjectDefConstraint(nugget4, avoidNugget);
rmAddObjectDefConstraint(nugget4, avoidTC);
rmAddObjectDefConstraint(nugget4, avoidCW);
rmAddObjectDefConstraint(nugget4, avoidTradeRoute);
rmAddObjectDefConstraint(nugget4, avoidAll);
rmAddObjectDefConstraint(nugget4, avoidWater20);
rmPlaceObjectDefAtLoc(nugget4, 0, 0.5, 0.5, rmRandInt(0,3));
}

// FORESTS
int forestTreeID = 0;
int numTries=10*cNumberNonGaiaPlayers;
int failCount=0;
for (i=0; <numTries) {
int forest=rmCreateArea("forest "+i, rmAreaID("big continent"));
rmSetAreaWarnFailure(forest, false);
rmSetAreaSize(forest, rmAreaTilesToFraction(150), rmAreaTilesToFraction(400));
rmSetAreaForestType(forest, "andes forest");
// rmSetAreaForestType(forest, "dunes");
rmSetAreaForestDensity(forest, 0.8);
rmSetAreaForestClumpiness(forest, 0.6);
rmSetAreaForestUnderbrush(forest, 0.0);
rmSetAreaMinBlobs(forest, 1);
rmSetAreaMaxBlobs(forest, 5);
rmSetAreaMinBlobDistance(forest, 16.0);
rmSetAreaMaxBlobDistance(forest, 70.0);
rmSetAreaCoherence(forest, 0.4);
rmSetAreaSmoothDistance(forest, 0);
rmAddAreaToClass(forest, rmClassID("classForest"));
rmAddAreaConstraint(forest, forestConstraint);
rmAddAreaConstraint(forest, avoidAll);
rmAddAreaConstraint(forest, forestvsTC);
rmAddAreaConstraint(forest, forestvsCW);
rmAddAreaConstraint(forest, longAvoidImpassableLand);
rmAddAreaConstraint(forest, avoidTradeRoute);

if(rmBuildArea(forest)==false) {
// Stop trying once we fail 3 times in a row.
failCount++;
if(failCount==5)
break;
}
else
failCount=0;
}

if(rmRandFloat(0,1) <= 0.9) //place llamas 90% of the time
{
if (cNumberNonGaiaPlayers<5)
int llamaCount =4.0*cNumberNonGaiaPlayers;
else
llamaCount =3.00*cNumberNonGaiaPlayers;
rmEchoInfo("llama count = "+llamaCount);
for (i=0; <llamaCount)
{
int llamaID = rmCreateObjectDef("llama herd "+i);
rmAddObjectDefItem(llamaID, "llama", rmRandInt(5,6), 5);
rmSetObjectDefMinDistance(llamaID, 0.0);
rmSetObjectDefMaxDistance(llamaID, rmXFractionToMeters(0.5));
rmAddObjectDefConstraint(llamaID, avoidLlama);
rmAddObjectDefConstraint(llamaID, avoidAll);
//rmAddObjectDefConstraint(llamaID, SEconstraint);
rmAddObjectDefConstraint(llamaID, avoidCliffFar);
rmSetObjectDefCreateHerd(llamaID, false);

rmPlaceObjectDefAtLoc(llamaID, 0, 0.5, 0.5);
}
}

balanceVanilla();

// Starter shipment triggers
for(i = 1; < cNumberPlayers) {
rmCreateTrigger("XP"+i);
rmSwitchToTrigger(rmTriggerID("XP"+i));
rmSetTriggerPriority(3);
rmSetTriggerActive(true);
rmSetTriggerRunImmediately(true);
rmSetTriggerLoop(false);

rmAddTriggerCondition("Always");

rmAddTriggerEffect("Grant Resources");
rmSetTriggerEffectParamInt("PlayerID", i, false);
rmSetTriggerEffectParam("ResName", "XP", false);
rmSetTriggerEffectParam("Amount", "15000", false);

rmAddTriggerEffect("Grant Resources");
rmSetTriggerEffectParamInt("PlayerID", i, false);
rmSetTriggerEffectParam("ResName", "Trade", false);
rmSetTriggerEffectParam("Amount", "15000", false);

rmAddTriggerEffect("Grant Resources");
rmSetTriggerEffectParamInt("PlayerID", i, false);
rmSetTriggerEffectParam("ResName", "Food", false);
rmSetTriggerEffectParam("Amount", "40000", false);

rmAddTriggerEffect("Grant Resources");
rmSetTriggerEffectParamInt("PlayerID", i, false);
rmSetTriggerEffectParam("ResName", "Wood", false);
rmSetTriggerEffectParam("Amount", "40000", false);

rmAddTriggerEffect("Grant Resources");
rmSetTriggerEffectParamInt("PlayerID", i, false);
rmSetTriggerEffectParam("ResName", "Gold", false);
rmSetTriggerEffectParam("Amount", "40000", false);
}

rmCreateTrigger("BackToNormalTrigger");
rmAddTriggerCondition("Timer");
rmSetTriggerPriority(4);
rmSetTriggerActive(true);
rmSetTriggerRunImmediately(true);
rmSetTriggerLoop(false);
rmSwitchToTrigger(rmTriggerID("BackToNormalTrigger"));
rmSetTriggerConditionParamInt("Param1", 20);
rmAddTriggerEffect("Message");
rmSetTriggerEffectParam("Text",
"You love women and you are a fine hussar! This version made by murdilator, aka Justus_Pacificia");


// Text
rmSetStatusText("",1.0);
}

The last part is the extra resources and flavor text. When you create your map, you can sign it either in the xml or here in the code with a message that pops up in game. Be sure to put resources and the message before "",1.0 and after "",0.80 or "",0.90. In this case, it will load the map properly. Be sure also to place startingunits2 at this line:
rmPlaceObjectDefAtLoc(startingUnits, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));
rmPlaceObjectDefAtLoc(startingUnits2, i, rmXMetersToFraction(xsVectorGetX(TCLocation)), rmZMetersToFraction(xsVectorGetZ(TCLocation)));

Or else your extra units will not load. Another factor is this one:
   rmSetObjectDefMinDistance(startingUnits2, 12.0);
rmSetObjectDefMaxDistance(startingUnits2, 27.0);
rmAddObjectDefConstraint(startingUnits2, avoidAll2);
rmAddObjectDefConstraint(startingUnits2, avoidTESTFactory);
rmAddObjectDefConstraint(startingUnits2, avoidImpassableLand);
rmAddObjectDefToClass(startingUnits, rmClassID("startingUnit"));

Very important to placement of units. A difference of 11.0 or 26.0 could mean that 30-50 extra units don't spawn.

On some maps, you need startingTCID or TCID rather than startingunits2:
else
{
rmAddObjectDefItem(TCID, "TownCenter", 2, 10.0);
rmAddObjectDefItem(TCID, "Pilgrim", rmRandInt(25,30), 20.0);
rmAddObjectDefItem(TCID, "Coureur", rmRandInt(22,25), 20.0);
rmAddObjectDefItem(TCID, "SPCPopBlock", rmRandInt(15,15), 15.0);
rmAddObjectDefItem(TCID, "Miner", rmRandInt(15,20), 20.0);
rmAddObjectDefItem(TCID, "SettlerWagon", rmRandInt(12,15), 15.0);
rmAddObjectDefItem(TCID, "ypDockWagon", rmRandInt(2,3), 20.0);
rmAddObjectDefItem(TCID, "YPGroveWagon", rmRandInt(1,2), 20.0);
rmAddObjectDefItem(TCID, "CoureurCree", rmRandInt(6,7), 20.0);
}

rmSetObjectDefMinDistance(TCID, 0.0);
rmSetObjectDefMaxDistance(TCID, TCfloat);

This concludes the study I wanted to share.
« Previous Page  1 ··· 10 ··· 20 ··· 28 29 30  Next Page »
You must be logged in to post messages.
Please login or register

Hop to:    

Age of Empires III Heaven | HeavenGames