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