Forum

> > Stranded II > Scripts > Massive Maps
Forums overviewStranded II overview Scripts overviewLog in to reply

English Massive Maps

9 replies
To the start Previous 1 Next To the start

old Massive Maps

Lion_Hearted
User Off Offline

Quote
Hello!

I wanted to make extremely huge maps in Stranded 2, that way I can make a chains of islands, a huge ocean biome, and make it a lot more interesting to explore in my mod.

However... to do this I would have to edit the source code, and from the fact that no-one else has done it already I'm assuming it's not that easy to add a 5000 by 5000 map into the game, not to mention the extra lag it'd probably cause.

So, I came up with another idea. What if I just simply made everything smaller, to be able to mimic the idea of a huge game?

I reduced the size of the player model by a factor of 10, as well as the eyes height value. However now I have a really big issue where my eyes don't go above the water level.

Anyone know how to solve this?

old Re: Massive Maps

Jawohl
User Off Offline

Quote
yeah that could work, someone i used to speak with about 8ish years ago made a mod doing just that.

very much possible, but you need to scale down field of vision/attack range/scale/ect.

but otherwise you could feasibly scale the random maps/ custom maps up like crazy, just that it would lower the ground texture, and further spread models through random maps

old Re: Massive Maps

DC
Admin Off Offline

Quote
Scaling everything down is certainly not a good solution. It would be much easier to allow bigger maps (= bigger terrains) by changing just a few values in the source code.

But this won't help either because of the very simplistic map structure in Stranded II. It holds the whole map with all its objects and the entire terrain in memory all the time. And iterates over all these objects frequently to perform certain operations.

This means: The more objects you have on the map the slower things will get. So the actual limit is not the terrain size but the amount of objects.

A lot more changes would be required to allow handling large maps with acceptable performance. These changes wouldn't be trivial and you would have to touch a lot of places in the source code. They would also break a lot of things which would then have to be handled differently as well.

old Re: Massive Maps

Lion_Hearted
User Off Offline

Quote
Thank you for the response DC.

In light of this, would it be possible to have a map chunk rendering system? Like for example you walk to the edge of the map, and you load a new map that is just simply an additional part of the island?

Note that I would also like time to pass on the previous chunk of the island as well.

For example. I have a Kiwi Breeder, that is supposed to spawn 10 Kiwis over the course of 5 days. I make it, and go to a different part of the island which requires me to save this map, and load a different one in a chunk loading type of system.

5 days later, I come back to my Kiwi breeder, however seeing as those 5 days passed in a different map, the Kiwi breeder has obviously done nothing. Is there any suggestion you have for getting around this problem?

old Re: Massive Maps

JasJack67
Super User Off Offline

Quote
i have a source code edited from massive mod that has HUGE maps. They tend to lag severely due to the fact that my mod loads the map with vegetation randomly. So the whole map is full of trees, bushes, and weeds.

You might be able to reduce the lag on these maps by designating "areas" that have trees, bushes and weeds... and other areas that do not..."fields". Fields of empty grass texture.

This way only parts of the map have "objects" and other parts are baron. In totality, having less objects spawn and less lag?

Or at least my idea would be to control the amount of objects that spawn in density, and location.

Lastly, if you did not use massive mod source code you may have to start over (put this .exe in your folder n see if you don't get editor errors), I have not found anyone else with the source but me, everyone else has been long gone.

Here the link: > Huge Maps .exe

Should be able to right-click n "rename" it too. Let me know how it goes if you use it. Just start your mod with this .exe in the main folder instead of your old .exe. The other obstacle i see here though would be what if the player chooses the SMALL map? You might need someone to edit the source to have only 1 default map size i think...huge.
edited 2×, last 25.05.17 08:15:55 am

old Re: Massive Maps

DC
Admin Off Offline

Quote
@user Lion_Hearted: Yes, using chunks which are only loaded on demand is the common solution to tackle this problem and the problem you are mentioning is one of many which will be caused by using such a system. Therefore it's a lot of work to rewrite it.

In theory this particular problem can be solved by using timestamps (with game time, not real time). You save the game time a chunk was unloaded (it's 0 by default for all tiles which have not been loaded yet) and when you load it again you check how much time passed since then and execute the required actions.

This solution however only works for local actions (like the kiwi breeders). If for instance you have a volcano script which kills all trees on the map after 5 days and which shows a message you would run into 2 new problems:
• the script is only executed as soon as the volcano chunk is loaded
• it's not possible to simply kill all trees because their chunks are not loaded

So you would need a lot more mechanics to handle such things. Interacting with objects on unloaded chunks like getting/setting values or creating/deleting them is a problem is also a problem.

But of course you could also just say: I don't need such things. It's okay to be restricted to local actions. If a script tries to do something on unloaded chunks I'll just ignore it. In that case it would still be a ton of work to change the game but it would be a lot easier already.

Another approach would be to do the chunking system only for the visible meshes/terrains and to keep the actual data behind the things still in memory for everything. Your total map size will then be limited again by available RAM (and also CPU speed) but - if done correctly - it should give you a significant performance boost in rendering. Rendering is commonly the bottleneck for FPS.

old Re: Massive Maps

Lion_Hearted
User Off Offline

Quote
Ok, firstly I gotta say that I do not have enough knowledge or ability to edit the source code. I have tried and that code simply blows my mind.

However, I think I have found a way to fix the problem with the ingame source code.

I also need answers to the following questions though.

1: Is there any way to store variables between maps? Such as the time of the map that I am leaving. This would allow me to keep track of the sun, and the amount of daylight left. This is really the only global variable that I need.

2: What's the line of code needed to actually get the daily hour time stamp? And what format is it in?

3: Is it possible to save a variable within a map, that is then updated by a global variable when you log in? This would be used to change the time of day on an island that you supposedly just came back to, to the same time of day as the island that you just left.

old Re: Massive Maps

JasJack67
Super User Off Offline

Quote
Here is an example code you may be able to work with. It is from MassiveMod and is used at the old MINE (hut). When the player "uses" the mine(hut) it saves the current player "important data" and loads a new map underground...when the player exits the mine that same data is restored to the player(unit).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
### Mine 
id=4998
name=Mine
group=building
icon=gfx\hut.bmp
model=gfx\hut.b3d
health=500
mat=wood
scale=.65
behaviour=cover
script=start
	on:use {
		event "idcreation";
		if ($time <= 0){
			//saving important info to respawn player correctly later
			$savedx=getx("unit",1);
			$savedy=gety("unit",1);
			$savedz=getz("unit",1);
			$saved_health=getplayervalue(1);
			$saved_hunger=getplayervalue(2);
			$saved_thirst=getplayervalue(3);
			$saved_sleep=getplayervalue(4);
			$time=1;
			$mineentered=1;
			$day=day();
			$hour=hour();
			$minute=minute();
			savemap "maps\data\gameid $s2g_mapid.s2",0,0,0,0,0,0;
			loadmap "maps\underground\01.s2",1,1,1,1,1,1;
		}elseif ($time == 1){
			//saving important info to respawn player correctly later
			$savedx=getx("unit",1);
			$savedy=gety("unit",1);
			$savedz=getz("unit",1);
			$saved_health=getplayervalue(1);
			$saved_hunger=getplayervalue(2);
			$saved_thirst=getplayervalue(3);
			$saved_sleep=getplayervalue(4);
			$mineentered=1;
			$day=day();
			$hour=hour();
			$minute=minute();
			savemap "maps\data\gameid $s2g_mapid.s2",0,0,0,0,0,0;
			loadmap "maps\data\ugnd01 $s2g_mapid.s2",1,1,1,1,1,1;
		}
	}
	on:idcreation {
		if ($s2g_mapid == 0){
			local $i,$x,$y,$z,$day,$hp,$h,$s,$t,$cskill,$fskill,$skill,$w,$gt,$hr,$m,$map,$px,$py,$pz,$r1,$r2,$r3,$mapid;
			$i=currentid();
			$x=getx("self");
			$y=gety("self");
			$z=getz("self");
			$w=getweather();
			$gt=gt();
			$hr=hour();
			$m=minute();
			$map=mapsize();
			$px=getx("unit",1);
			$py=gety("unit",1);
			$pz=getz("unit",1);
			$mapid=((($i*10)+($x+$y+$z)+($px+$py+$pz)+$map+$m+$hr+$gt)*($w+1));
			$s2g_mapid=abs($mapid);
			msg "Your ID is: $mapid $s2g_mapid",3,10000;
			freevar $i,$x,$y,$z,$w,$gt,$hr,$map,$m,$px,$py,$pz,$mapid;
		}
	}
	on:load {
		if ($mineused == 1){
			setpos "unit",1, $savedx,$savedy,$savedz;
			local $hem;
			$tmp1=skillvalue("survivor");
			if ($tmp1 >= 60){
				$hem=150-$saved_health;
				maxhealth "unit",1,50;
			}else{
				$hem=100-$saved_health;
			}
			setday $day;
			sethour $hour;
			setminute $minute;
			consume 200,0,0,0;
			consume -$hem,-$saved_hunger,-$saved_thirst,-$saved_sleep;
			freevar $savedx,$savedy,$savedz,$saved_health,$saved_hunger,$saved_thirst,$saved_sleep,$hem,$mineused,$day,$hour,$minute;
		}
	}
script=end

When I used this script I attempted to add to it so the players inventory was saved and re-assigned, but there where a few broken things about it...the players inventory would lose items for some reason if the capacity was to large, and a couple things like related to items lost...I'm sure it can be fixed to work, but I was just a rookie back then

I remember years back I fixed it to work by limiting the player to how much stuff they could carry when entering the mine and exiting the mine...i do not remember the edits and do not have the old script I made from this one.

It is however a good representation of what your talking about...but you will have to fix it/work on it to make it function exactly how you need it.

When the player enters(uses) the mine the variables are created , appointed data, and saved globally...when the mine map is loaded those variables are re-assigned to the player/map. After the player is done in the mine and upon exiting, new variables are created with the data the player got in the mine...so now when the player exited, the OLD map is loaded...and BOTH variables should then be compared and calculated....cuz the player may have a hammer when he went IN the mine...dropped it in the mine, and NOT have the hammer when he left the mine. Or maybe he had full health when he went in and now only half health when he came out of the mine.

save variable example: the time of day when the player went into the mine($gt=gt();) is saved as global variables $hr $min, re-assign this time as the current time when the mine map is loaded, and the player is spawned...then what time of day the player exited the mine is saved again, so when the old map is loaded that current time is then re-assigned to the map.

you have to do this for every variable that is holding data you need to save between maps.

lastly, I'll mention the idea of using "switches". You see in the script it uses a couple "switch" variables. If the variable is 1 the mine was used and the player is in the mine on the mine map...if the variable is 0 the player is on the surface map (original map)...you will probably need to utilize these type variables to keep track of the players actual location as they move from map to map.

Here is a link to download MassiveMod from my archives: > MM.zip

You might want to download it, start a game and get to building the mine and save the game, so you can edit the script and test n re-test it loading the save...and make it do what you want to exactly.
edited 6×, last 26.05.17 03:50:13 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview