Page 1 of 3

Map Questions

Posted: 12 Sep 2016, 16:33
by mandosrex
Gentlemen, those who are into map making, I require assistance.

I wanted to fill a map with grass so I went and took the grass codes from Great Plains. Problem is, the grass on GP only spams on the middle of the map, while I want the grass the be on the entire map (except maybe the small pond in the middle).

I tried everything with the codes, changed every value, nothing. I get patches of grass all around the map but they are random and... they are not everywhere!

If someone could help me out it would be highly appreciated.

Here are the grass codes:

Code: Select all

   // Build grassy areas everywhere.  Whee! 
   numTries=6*cNumberNonGaiaPlayers;
   failCount=0;
   for (i=0; <numTries)
   {   
      int grassyArea=rmCreateArea("grassyArea"+i);
      rmSetAreaWarnFailure(grassyArea, false);
      rmSetAreaSize(grassyArea, rmAreaTilesToFraction(1000), rmAreaTilesToFraction(1000));
      rmSetAreaForestType(grassyArea, "Great Plains grass");
      rmSetAreaForestDensity(grassyArea, 0.3);
      rmSetAreaForestClumpiness(grassyArea, 0.1);
      rmAddAreaConstraint(grassyArea, avoidHills);
      rmAddAreaConstraint(grassyArea, avoidTradeRoute);
      rmAddAreaConstraint(grassyArea, avoidSocket);
      rmAddAreaConstraint(grassyArea, avoidNatives);
      rmAddAreaConstraint(grassyArea, avoidStartingUnits);
      rmAddAreaConstraint(grassyArea, avoidNuggetSmall);
      if(rmBuildArea(grassyArea)==false)
      {
         // Stop trying once we fail 5 times in a row.
         failCount++;
         if(failCount==5)
            break;
      }
      else
         failCount=0;
   }


(posted on NE's forum as well)

Re: Grassy areas not everywhere

Posted: 12 Sep 2016, 17:19
by HeatitUP_
The buffalo would get fatter and have more food in them =]

Re: Grassy areas not everywhere

Posted: 12 Sep 2016, 17:36
by Rikikipu
Increase numTries by x10000 and delete all the "avoidHills" line

Re: Grassy areas not everywhere

Posted: 12 Sep 2016, 17:39
by mandosrex
The map has no buffalo, it's a Savannah map. And it also has no hills.

I will try to increase numTries, funny enough it's the only one I didn't change...

:D

Re: Grassy areas not everywhere

Posted: 12 Sep 2016, 18:11
by Garja
EDIT: nvm

Ye just get rid of the avoidHills constraint.

Re: Grassy areas not everywhere

Posted: 12 Sep 2016, 18:55
by Durokan

Code: Select all

// Build grassy areas everywhere.  Whee!
   int numTries=2*cNumberNonGaiaPlayers;
   for (i=0; <numTries){   
      int grassyArea=rmCreateArea("grassyArea"+i);
      rmSetAreaSize(grassyArea, .2, .2);
      rmSetAreaForestType(grassyArea, "Great Plains grass");
      rmSetAreaForestDensity(grassyArea, .5);
      rmSetAreaForestClumpiness(grassyArea, 0.01);
      rmBuildArea(grassyArea);
   }


this is what i've used in the past.
it's used on my savanna grass map and to some extent highveld if you've ever made it over to my workshop

it gives this kind of distribution across the whole map

Image

if you want more grass increase the density.

Note: place this before all of your other items (hunts, tc, trees, gold, etc) on the map as the grass will be placed over the top of and "break" all of the other items and you will have a grassy map with nothing else on it. You want things placed on top of the grass which will not break it for the most part

Re: Grassy areas not everywhere

Posted: 12 Sep 2016, 20:01
by mandosrex
Oh, so many map scripters!

And here I was thinking no one will respond on this forum.
Apologies. :(


Back to business then, so by just editing numTries or removing the avoid codes, it didn't work. Same uneven placement.

I also tried using the codes Durokan posted but then the map breaks and fails to load, no matter where I put them.
Help.

Re: Grassy areas not everywhere

Posted: 12 Sep 2016, 20:44
by Rikikipu
mandosrex wrote:Oh, so many map scripters!

And here I was thinking no one will respond on this forum.
Apologies. :(


Back to business then, so by just editing numTries or removing the avoid codes, it didn't work. Same uneven placement.

I also tried using the codes Durokan posted but then the map breaks and fails to load, no matter where I put them.
Help.



Code: Select all

// Build grassy areas everywhere.  Whee!
   int numTries=2*cNumberNonGaiaPlayers;
   for (i=0; <numTries){   
      int grassyArea=rmCreateArea("grassyArea"+i);
      rmSetAreaSize(grassyArea, .2, .2);
      rmSetAreaForestType(grassyArea, "Great Plains grass");
      rmSetAreaForestDensity(grassyArea, .5);
      rmSetAreaForestClumpiness(grassyArea, 0.01);
      rmBuildArea(grassyArea);
   }


in Durokan code, replace int numtries for numtries only
So you'll have this and the map won't crash :

Code: Select all

// Build grassy areas everywhere.  Whee!
   numTries=2*cNumberNonGaiaPlayers;
   for (i=0; <numTries){   
      int grassyArea=rmCreateArea("grassy_Area"+i);
      rmSetAreaSize(grassyArea, .2, .2);
      rmSetAreaForestType(grassyArea, "Great Plains grass");
      rmSetAreaForestDensity(grassyArea, .5);
      rmSetAreaForestClumpiness(grassyArea, 0.01);
      rmBuildArea(grassyArea);
   }

Re: Grassy areas not everywhere

Posted: 12 Sep 2016, 20:52
by musketeer925
Oh hey Mandos. There are a lot of map scripters here, yes.

Re: Grassy areas not everywhere

Posted: 12 Sep 2016, 22:56
by _H2O
We have a whole team dedicated to it!

Re: Grassy areas not everywhere

Posted: 12 Sep 2016, 23:51
by mandosrex
So many awesome guys here!

H2O and Garja, I am honored, I am familiar with your work and it's awesome.

Agh, I keep getting distracted. Ok, so, the grass, it spawns correctly now but only if I put it at the end of the file (which is not good beause everything else gets erased).
I tried putting it in many places before everything else spawns but it keeps crashing the map.

I tried placing it before "// Define and place lake in middle", it crashes; tried placing it before "// Place players in FFA and team games", it crashes; tried placing them before and after "// Define and place players' areas", it crashes; tried placing it before "// Define starting objects and resources", it crashes; tried placing it before "// Define and place forests", it crashes...

I don't know what to try anymore.
I am such a noob...

Re: Grassy areas not everywhere

Posted: 13 Sep 2016, 00:01
by Durokan
mandosrex wrote:So many awesome guys here!

H2O and Garja, I am honored, I am familiar with your work and it's awesome.

Agh, I keep getting distracted. Ok, so, the grass, it spawns correctly now but only if I put it at the end of the file (which is not good beause everything else gets erased).
I tried putting it in many places before everything else spawns but it keeps crashing the map.

I tried placing it before "// Define and place lake in middle", it crashes; tried placing it before "// Place players in FFA and team games", it crashes; tried placing them before and after "// Define and place players' areas", it crashes; tried placing it before "// Define starting objects and resources", it crashes; tried placing it before "// Define and place forests", it crashes...

I don't know what to try anymore.
I am such a noob...


If you upload the map I'd be willing to look through it and see if I can help you out. Before you do that, go ahead and read and check the following.

The one think I can think of off of the top of my head is that due to how the code was crashing is that "numtries" is defined as an integer somewhere else in the code. (It was not in mine)
So if my theory is correct, the grass will only place after that definition. If you place it before the definition, it will crash.

To fix this I would suggest finding where "int numtries" is defined.

If you can't seem to find where numtries is or you want a new variable name, use the following.
(numtries was changed to a unique, uncommon variable name with the same meaning to avoid conflict with variables of the numtries name)

Code: Select all

// Build grassy areas everywhere.  Whee!
   int numberTries=2*cNumberNonGaiaPlayers;
   for (i=0; <numberTries){   
      int grassyArea=rmCreateArea("grassyArea"+i);
      rmSetAreaSize(grassyArea, .2, .2);
      rmSetAreaForestType(grassyArea, "Great Plains grass");
      rmSetAreaForestDensity(grassyArea, .5);
      rmSetAreaForestClumpiness(grassyArea, 0.01);
      rmBuildArea(grassyArea);
   }

Re: Grassy areas not everywhere

Posted: 13 Sep 2016, 00:15
by mandosrex
Huh, this is really weird.
So, the first place where it's mentioned is for trees, "// Define and place forests":

Code: Select all

   int numTries=20*cNumberNonGaiaPlayers;
   int failCount=0;
   for (i=0; <numTries)
   {   
      int forest=rmCreateArea("forest"+i);

etc


If I put it after this it works, but it's still not good as it erases everything above.
Now, my logic told me that if I just put back "int" before "numTries" for the grass codes then it will work, but it didn't.
So I really don't know how to fix this. Why is not defining that "int" thing for the first time in the grass codes working?


Oh, you changed your message as I was writing mine, trying now.

Re: Grassy areas not everywhere

Posted: 13 Sep 2016, 00:29
by Durokan
mandosrex wrote:Huh, this is really weird.
So, the first place where it's mentioned is for trees, "// Define and place forests":

Code: Select all

   int numTries=20*cNumberNonGaiaPlayers;
   int failCount=0;
   for (i=0; <numTries)
   {   
      int forest=rmCreateArea("forest"+i);

etc


If I put it after this it works, but it's still not good as it erases everything above.
Now, my logic told me that if I just put back "int" before "numTries" for the grass codes then it will work, but it didn't.
So I really don't know how to fix this. Why is not defining that "int" thing for the first time in the grass codes working?


Oh, you changed your message as I was writing mine, trying now.


Yeah, variable names are unique and the game will throw an error if you define the same variable twice. Variables can only be used after they are defined as this is a top down language. Generally, to avoid issues like this, good coding practice is to "initialize" all of the variables at the top of the code. For example, you might define a few things at the top of the map such as:

Code: Select all

//Example code
//To be changed later
int numTries = 0;
int someOtherVariable = 0;
float aDecimalVariable = 0.0;
//and so on

//the rest of your map's code

//hey we found a use for numTries, let's change it here!
numTries = 2 * cNumNonGaiaPlayers;
 for (i=0; <numberTries){
//and so on
}

When the variables are then later used, it is best to then do it as riki corrected. The error is partially my fault, but I also didn't know you would have the same variable used already. I guess it was code I modified from great plains or something so it was not a unique name (like I would normally use)

Re: Grassy areas not everywhere

Posted: 13 Sep 2016, 00:46
by mandosrex
So, everything seems to work now except for the northern part of the map which always lacks grass with 8 players for some reason. Can I tweak the codes for a better coverage?

Sadly, it now also suddenly started to lag. I mean, I was expecting this but so far it didn't lag.

How would a set of codes to spawn rocks and other ambiental stuff go (like the stuff from Great Plains or Texas)? The same as with grass?
I know I saw something similar on a map but forgot which.


Anyway, Durokan, I just saw your maps workshop and I have to ask if you allow their usage in mods? With full credit given of course.
And do the maps that don't have 1v1 or 2v2 in their names support all 8 players?
Thank you for your help!

Re: Grassy areas not everywhere

Posted: 13 Sep 2016, 01:14
by Durokan
mandosrex wrote:So, everything seems to work now except for the northern part of the map which always lacks grass with 8 players for some reason. Can I tweak the codes for a better coverage?

Sadly, it now also suddenly started to lag. I mean, I was expecting this but so far it didn't lag.

How would a set of codes to spawn rocks and other ambiental stuff go (like the stuff from Great Plains or Texas)? The same as with grass?
I know I saw something similar on a map but forgot which.


Anyway, Durokan, I just saw your maps workshop and I have to ask if you allow their usage in mods? With full credit given of course.
And do the maps that don't have 1v1 or 2v2 in their names support all 8 players?
Thank you for your help!


Yeah, the code should be editable.

To my knowledge, the grass is a forest type object. I doubt the ambiental stuff is classified as a forest, so they are most likely placed in a similar manner to any other object such as a gold mine, hunt, etc.

Code: Select all

      
   //this code places 8 lions per player randomly around the map per player and it obeys a defined constraint.
   //you can use something like this but instead of "ypLion" use "whateverTheRockNameIs" or "ambientTreeLogThingy"
   int variableName = rmCreateObjectDef("some string that tells you what it does");
        rmAddObjectDefItem(variableName, "ypLion", 1, 10.0);
        rmSetObjectDefMinDistance(variableName, 0);
   rmSetObjectDefMaxDistance(variableName, rmXFractionToMeters(0.5));
   rmAddObjectDefConstraint(variableName, constraintName);
   rmPlaceObjectDefAtLoc(variableName, 0, 0.5, 0.5, cNumberNonGaiaPlayers*8);


This is what I have said about using my maps in the past.
viewtopic.php?f=33&t=4748&start=100#post_content108084

Re: Grassy areas not everywhere

Posted: 13 Sep 2016, 01:28
by mandosrex
Awesome!
This is so exiting! I saw you also had a Savannah map so I tried yours and it's so much full of stuff, it's awesome!

But I saw that it had no loading screen so I fixed that by adding the loading bar codes. I also tweaked the look of the map and added zebras and fitting treasures with lions and rhinos and whatnot.

I want to add African maps in my mod and I will see what other maps for 8 players you have which can be converted into African maps.

I will give you full credit in the loading screen, immersion breaking or not. Your work is awesome.
Thank you!

Re: Grassy areas not everywhere

Posted: 13 Sep 2016, 02:42
by Durokan
mandosrex wrote:Awesome!
This is so exiting! I saw you also had a Savannah map so I tried yours and it's so much full of stuff, it's awesome!

But I saw that it had no loading screen so I fixed that by adding the loading bar codes. I also tweaked the look of the map and added zebras and fitting treasures with lions and rhinos and whatnot.

I want to add African maps in my mod and I will see what other maps for 8 players you have which can be converted into African maps.

I will give you full credit in the loading screen, immersion breaking or not. Your work is awesome.
Thank you!


Jebel Musa is the african side of the strait of gibaltrar if that interests you at all. It was the map that made me want to start RMS in the first place.

Your mod work sounds pretty cool, feel free to share screenshots whenever you are comfortable sharing :)

Re: Grassy areas not everywhere

Posted: 13 Sep 2016, 03:00
by adderbrain5
Durokan wrote:
mandosrex wrote:Awesome!
This is so exiting! I saw you also had a Savannah map so I tried yours and it's so much full of stuff, it's awesome!

But I saw that it had no loading screen so I fixed that by adding the loading bar codes. I also tweaked the look of the map and added zebras and fitting treasures with lions and rhinos and whatnot.

I want to add African maps in my mod and I will see what other maps for 8 players you have which can be converted into African maps.

I will give you full credit in the loading screen, immersion breaking or not. Your work is awesome.
Thank you!


Jebel Musa is the african side of the strait of gibaltrar if that interests you at all. It was the map that made me want to start RMS in the first place.

Your mod work sounds pretty cool, feel free to share screenshots whenever you are comfortable sharing :)

Jabal Musa is the quranic arabic name for "mount sinai" it literally means "Mount Moses"...EDIT which is not anywhere near gibraltar, but in the sinai peninsula between modern egypt and israel

Re: Grassy areas not everywhere

Posted: 13 Sep 2016, 08:28
by mandosrex
While I don't know how to make maps, I do know how to change their aspect, so any map can become an African map.

I could share screenshots, no problem!

Image

Image

Re: Grassy areas not everywhere

Posted: 13 Sep 2016, 09:58
by iNcog
Cool map you have there. ^^

Re: Grassy areas not everywhere

Posted: 13 Sep 2016, 12:34
by Durokan
adderbrain5 wrote:Jabal Musa is the quranic arabic name for "mount sinai" it literally means "Mount Moses"...EDIT which is not anywhere near gibraltar, but in the sinai peninsula between modern egypt and israel


Thanks for the help but thats the wrong Jebel Musa.

Im sure alexandria usa is the same place as alexandria greece xD (both named after alex the G)

Anyways ill explain the arabic.
Jebel means "mountain [range]" and the musa part comes from the name "Musa bin Nusayr", who some geographer named it in honor of. So yes, while mount moses is in fact a place in egypt this happens to be a different mount moses in morocco...

For reference

https://en.m.wikipedia.org/wiki/Jebel_Musa_(Morocco)

Re: Grassy areas not everywhere

Posted: 14 Sep 2016, 04:41
by adderbrain5
Durokan wrote:
adderbrain5 wrote:Jabal Musa is the quranic arabic name for "mount sinai" it literally means "Mount Moses"...EDIT which is not anywhere near gibraltar, but in the sinai peninsula between modern egypt and israel


Thanks for the help but thats the wrong Jebel Musa.

Im sure alexandria usa is the same place as alexandria greece xD (both named after alex the G)

Anyways ill explain the arabic.
Jebel means "mountain [range]" and the musa part comes from the name "Musa bin Nusayr", who some geographer named it in honor of. So yes, while mount moses is in fact a place in egypt this happens to be a different mount moses in morocco...

For reference

https://en.m.wikipedia.org/wiki/Jebel_Musa_(Morocco)

touché

Re: Grassy areas not everywhere

Posted: 14 Sep 2016, 14:41
by mandosrex
Durokan, I have to ask something.
For your Savannah map, you made a little island in the middle which holds a Jesuit camp, which is awesome, religious groups would often make settlements on islands, but I wonder if you could add something. Could you add like a shallow for units to be able to walk to the island, because no one is going to build a dock and a ship to go to that island only for the Jesuits, and so a shallow would be perfect!

(if a shallow is not possible then even a dry ground bridge could work, anything for easier access)

You could leave the codes here and I could add them to the map.
Thanks for your awesome work.

Re: Grassy areas not everywhere

Posted: 14 Sep 2016, 16:20
by Durokan
can do this in a bit, working on an essay right now sry deadlines hurt