Go Back   Savage 2: A Tortured Soul Forum > Savage 2 Modding > Documentation

Notices

Documentation Post useful tutorials and other informative material.

Reply
 
Thread Tools Display Modes
Old 03-20-2013, 02:16 PM   #1
Durwyn

 
Join Date: Jul 2011
Location: Belgium
Posts: 264
Thanks: 47
Thanked 67 Times in 54 Posts
Default Map dimensions

Quote:
createvar int map_posX 0
createvar int map_posY 0

@Loop
set map_posX [map_posX + 1]

if [map_posX > 50000] "goto end"

set height #GetTerrainHeight(|#map_posX|#,|#map_posY|#)#
if [height != 0] "set stop #map_posX#"
goto Loop
@end
set map_dimension_X #stop#
Quote:
createvar int map_posX 0
createvar int map_posY 0

@Loop
set map_posY [map_posY + 1]

if [map_posY > 50000] "goto end"

set height #GetTerrainHeight(|#map_posX|#,|#map_posY|#)#
if [height != 0] "set stop #map_posY#"
goto Loop
@end
set map_dimension_Y #stop#
And type the following after the values are set:

Quote:
if [(map_dimension_X != map_dimension_Y) & (map_dimension_X < map_dimension_Y)] "set map_dimension_X #map_dimension_Y#"
if [(map_dimension_X != map_dimension_Y) & (map_dimension_Y < map_dimension_X)] "set map_dimension_Y #map_dimension_X#"
Saves in map_dimension_X & map_dimension_Y, the map dimensions.
__________________
Operating System: Windows 7 x64
Graphic card : Geforce GT 540M
RAM : 8gb
Savage2MapsAI

Last edited by Durwyn; 04-30-2013 at 09:35 PM.
Durwyn is offline   Reply With Quote
The Following 2 Users Say Thank You to Durwyn For This Useful Post:
meankitty2 (05-04-2013), rohezal (03-20-2013)
Old 03-20-2013, 04:53 PM   #2
rohezal

rohezal's Avatar
 
Join Date: Mar 2008
Posts: 2,610
Thanks: 112
Thanked 136 Times in 106 Posts
Default

Cant you get the map dimension from the map name?
__________________

http://xs229.xs.to/xs229/08295/image_get.php939.jpeg

I love VOIP
sing: "base, base, base, base, base, base, base"

Why only 15 year old girls? Since 4 Years, damn I'm doing something wrong...

One day I will find out who is responsible for the K2 scripting "language" and the modding "support". And then...

rohezal is offline   Reply With Quote
Old 03-20-2013, 05:06 PM   #3
Durwyn

 
Join Date: Jul 2011
Location: Belgium
Posts: 264
Thanks: 47
Thanked 67 Times in 54 Posts
Default

There is another way? Tell meeee D:
__________________
Operating System: Windows 7 x64
Graphic card : Geforce GT 540M
RAM : 8gb
Savage2MapsAI
Durwyn is offline   Reply With Quote
Old 03-20-2013, 05:27 PM   #4
rohezal

rohezal's Avatar
 
Join Date: Mar 2008
Posts: 2,610
Thanks: 112
Thanked 136 Times in 106 Posts
Default

Old55 had once a way. I am not sure how he did it. But you can get the current mapname via scripting right? You can save all the dimension Data from maps in number of Variables.

CreateVar int eden_dimensionX 64
CreateVar int eden_dimensionY 64
CreateVar int eden_scale 16

CreateVar int _currentDimensionX #getMapName()#_dimensionX
CreateVar int _currentDimensionY #getMapName()#_dimensionY
CreateVar int _currentScale #getMapName()#eden_scale

CreateVar int _dimensionX [currentDimensionX * currentScale]
CreateVar int _dimensionY [currentDimensionY * currentScale]

#getMapName()#_dimensionX and #getMapName()#_dimensionY are the same I think.

But if I am honest, I think it is more easy to use your script^^.
__________________

http://xs229.xs.to/xs229/08295/image_get.php939.jpeg

I love VOIP
sing: "base, base, base, base, base, base, base"

Why only 15 year old girls? Since 4 Years, damn I'm doing something wrong...

One day I will find out who is responsible for the K2 scripting "language" and the modding "support". And then...

rohezal is offline   Reply With Quote
Old 03-20-2013, 05:31 PM   #5
Durwyn

 
Join Date: Jul 2011
Location: Belgium
Posts: 264
Thanks: 47
Thanked 67 Times in 54 Posts
Default

if it saves some calcul time, i'm willing to use it :-P

i just need the code to compare D:
__________________
Operating System: Windows 7 x64
Graphic card : Geforce GT 540M
RAM : 8gb
Savage2MapsAI
Durwyn is offline   Reply With Quote
Old 03-21-2013, 01:31 AM   #6
Old55

Old55's Avatar
 
Join Date: Jun 2009
Posts: 2,586
Thanks: 14
Thanked 428 Times in 209 Posts
Default

My old way was similar to what you have done. I just worked backwards from a map size of 10 (131072).

This is the python code from the wrapper. It was assuming there would be no map size over 11

Quote:
def getMapSize(self,**kwargs):


checkdimension = 131071
self.MAPSIZE = 10
while not self.MAPSIZESET:
time.sleep(0.5)
self.MAPSIZESET = True
checkdimension = checkdimension/2
kwargs['Broadcast'].broadcast("echo #GetTerrainHeight(%s,0)#" % (checkdimension))
print 'Map Size =', self.MAPSIZE
time.sleep(1)
And the max coordinates for the map are:
maxcoord = ((mapsize - 1) * 64 * 64)So you can scale fractional coordinates to absolute.
__________________

Last edited by Old55; 03-21-2013 at 02:14 AM.
Old55 is offline   Reply With Quote
Old 04-30-2013, 09:37 PM   #7
Durwyn

 
Join Date: Jul 2011
Location: Belgium
Posts: 264
Thanks: 47
Thanked 67 Times in 54 Posts
Default

Added two "If" to execute after the values are set. (Necessary if you play on Mirakar for example)
__________________
Operating System: Windows 7 x64
Graphic card : Geforce GT 540M
RAM : 8gb
Savage2MapsAI
Durwyn is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 10:50 PM.