Jump to content

Can't find something like getTerrain function


Recommended Posts

I don't know of any function for that, but we could add them to rmgen: getTerrainTexture(x, z) getTerrainObjects(x, z). In the meantime, you can access the data directly with g_Map.texture[x][z] and g_Map.terrainObjects[x][z]

I don't mind if it's a function or not, THX a lot, U made my day (and the next!) ^^

These are functions I am working on these days. But unfortunately, they are not reaching alpha 9's deadline. Probably in SVN after alpha 9

Doesn't matter, I can get the terrain for coordinates, everything's fine for me.

Why is it so important to have a function for that as well?

I often directly use the g_Map vars/consts, what is wrong with that?

I don't change them of cause x)

...wouldn't dare to!

Edited by FeXoR
Link to comment
Share on other sites

Doesn't matter, I can get the terrain for coordinates, everything's fine for me.

Why is it so important to have a function for that as well?

I often directly use the g_Map vars/consts, what is wrong with that?

I don't change them of cause x)

...wouldn't dare to!

It is not bad. In fact, it's good as it improves performance. But we want random map scripts be simple and understandable for newcomers. So all of the dirty work should go into rmgen library.

Link to comment
Share on other sites

It is not bad. In fact, it's good as it improves performance. But we want random map scripts be simple and understandable for newcomers. So all of the dirty work should go into rmgen library.

OK, Totally agree!

But I find many functions inside the rmgen libs HARDER to understand and use then the more basic functions.

In fact most of them take or need more arguments...

Example:

I mainly use "placeObject" to place entities.

It takes 5 arguments:

- x-coordinate(float)

- y-coordinate(float)

- template name(string, base filename)

- player index(integer, 0 for gaia, 1 for player 1 with default color blue, ...)

- orientation(float, 0 for top, PI/4 for top left 45°, PI/2 for right, ...)

Everything simple and clear to me.

In the RMGs included (for example latinum, great work BTW) uses:

	var group = new SimpleGroup(	// elements (type, min/max count, min/max distance, min/max angle)
[new SimpleObject(civEntities[0].Template, 1,1, 0,0, BUILDING_ANGlE, BUILDING_ANGlE)],
true, null, ix, iz
);
createObjectGroup(group, id);

Oooooookkkkkkkkk.... let me see.

"SimpleGroup" (astonishing name for that ^^) needs 5 arguments from witch one is "SimpleObject" (even better x)) that takes 7 arguments.

Even the RMG's author added a comment for the arguments...

This is not "simple" in my book, but AFAIK that was the purpose of that function...

Well, still getting to know the functions available better and try to get your idea behind it...

So, to say it clearly: U'r doing a great job!

I just don't always get it :sorry:

Edited by FeXoR
Link to comment
Share on other sites

True, for groups of object these functions are very helpful.

But they use sin/cos like I do (for example createObjectGroups) which is not really a good idea as I got to know in an other post you where involved in (THX for your time) :

getDistance(point1, point2) and getDirection(point1, point2) from one point to another

Sometimes units are very tight packed though.

I used functions that only uses tiles to place something but I doubt this is practicable for generating whole maps.

I look forward to the beta 9 :worship:

Link to comment
Share on other sites

To say it first: It was my fault!

I should have read all the rmgen functions.

I shouldn't have asked, I should have read the code...

Well, I didn't...

The result was about 5 hours writing and changing code with very strange outcome (I wont annoy you with that but I have to tell my odyssey to get rid of my aching head)

...that had an effect similar to what I wanted but with terrible side effects and left me totally confused (and I still don't know why the hell it somehow worked)

If you don't want to waste your time skip the rest of the post...

But if you want something to read, here's

The Story

Somehow it goes back to

QUOTE

I don't know of any function for that, but we could add them to rmgen: getTerrainTexture(x, z) getTerrainObjects(x, z). In the meantime, you can access the data directly with g_Map.texture[x][z] and g_Map.terrainObjects[x][z]

I was grateful and in the late evening started to rewrite my deep forest RMG, where I wanted to have paths going through deep wooded hills. Note that I paint the paths first, since I couldn't find a way to remove trees and wasn't very familiar with terrain back then, and first had tried to lower the terrain of the paths a bit and used the sunken terrains height to avoid placing trees and textures on roads and so. This resulted in water on the roads and that U couldn't build there any more. But with the new 'knowledge' I was determined to do this with the 'g_Map.texture' and/or 'g_Map.terrainObjects' functions by avoiding to place things on road terrain. I had seen the avoidance implementations more commonly known as constraints, but I wanted to do this myself! So I wrote pages over pages and added some functions here that could be useful and the 'g_Map.texture' to check versus my path terrain strings. As I was finished I tested a bit, removed some typos and finally the RMG run through. But there were still trees on the roads. Maybe I swapped some conditions... turned them from false into true and from 'and' into 'or', though I didn't thought it would work cause it felt strange, and tested and, AND... well it looked OK! Really what I had in mind! Woods thinned out at a circle at half the map radius and, finally, no trees or forest floor on roads! I felt relived and thought 'tomorrow you will post this, much better then the last one'. Though I was tired I tried to raise the density of the woods cause somehow it was much thinner than I had in mind. I didn't fear any kind of problem since I lowered the tree density often for generating bigger maps on my old laptop and to avoid lags while viewing the map. But as I looked closer to the code, the density was already at 0.5 (50%, about each second tile) what was quite tight. I reviewed the map in the editor and it was definitely NOT every second tile! I reviewed my tree derivation function, read it over and over again to find the mistake, but everything seamed in order. I added tons of log code to output the actual tree density for every single tile (on the x axis to be correct). But everything was fine. Hm, Perhaps still something wrong with the 'g_Map.texture' condition, well it felt strange. OK, let's take a look... log said it return... UH, numbers! And why does it work... well lets see the function's code. Oh, IDs... I only use strings and arrays of strings... And why does it... ah, let's get the terrain ID by 'g_Map.texture' for every road tile I place and store it into an array so I can check against. ...one hour later with my tired head barely raised above the keyboard the map ran through and... took ages to generate! No warning, no error, no out of memory... it just lasted... and finally run through! But now there where trees on the roads again. Angry I commented out the checks and generated, just to see what happens, nothing special on my sluggish mind. Took a while... why ever... - Oh, trees everywhere, packed so tight I couldn't even scroll, what's up???!!! :wacko:My tree derivation function did everything right, but the check versus the list of values got by 'g_Map.texture' at every tree placed just thins out the bunches of trees to barely deserve to be called woods! I deleted my hole check implementation, just was to frustrated. 'IT SEAMED TO WORK' it cried in my head. 'IT seamed!' :sorry:I stared at my code a bit, seeing nothing. Then started to read through all the rmgen files still determined to at least get the 'is road' check right this day. not to mention that it was already 4:50... Most code I already knew but then, out of the nowhere, I stumbled across a Map.getTexture function!!! It was there! All the time I was trying to enforce it by abominable functions and horrible workarounds, it was there.

Took me less then five minutes to figure out that it indeed returns a texture string, that 'g_Map' is an instance of 'Map' and to implement the 'not a path' checks needed with simply using 'g_Map.getTerrain'... which I COULD HAVE GUESSED!!!

Five hours versus 5 minutes. That's... I'm so bloody incompetent, a dull mangy cur.

I was relived though and added some base texture, tried to figure out a good derivation for secondary resources but finally dropped dad in bed.

And historic_bruno said 'I don't know of any function' not 'there is no function'...

Hope I learned from it though... well, hope dies last.

Edited by FeXoR
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...