author | nemo |
Sat, 29 Nov 2014 15:30:33 -0500 | |
changeset 10580 | 17560eb73b4c |
parent 10413 | afd746a538ef |
child 10581 | f0b4c14a3c62 |
permissions | -rw-r--r-- |
10413 | 1 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
2 |
HedgewarsScriptLoad("/Scripts/Utils.lua") |
|
3 |
||
4 |
local hTag = nil |
|
5 |
local hTagHeight = 33000 |
|
6 |
local tTag = nil |
|
7 |
local rTag = nil |
|
8 |
local startTime = 0 |
|
9 |
local MaxHeight = 32640 |
|
10 |
local RecordHeight = 33000 |
|
11 |
local Fire = {} |
|
12 |
--local BoomFire = nil |
|
13 |
local HH = {} |
|
14 |
local MrMine -- in honour of sparkle's first arrival in the cabin |
|
15 |
local YouWon = false |
|
10580
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
16 |
local HogsAreInvulnerable = false |
10413 | 17 |
local WaterRise = nil |
18 |
local Cake = nil |
|
19 |
local CakeTries = 0 |
|
20 |
local Stars = {} |
|
21 |
||
22 |
function onGameInit() |
|
23 |
-- Ensure people get same map for same theme |
|
24 |
TurnTime = 999999999 |
|
25 |
CaseFreq = 0 |
|
26 |
Explosives = 0 |
|
27 |
MineDudPercent = 0 |
|
28 |
DisableGameFlags(gfBottomBorder+gfBorder) |
|
29 |
--This reduced startup time by only about 15% and looked ugly |
|
30 |
--EnableGameFlags(gfDisableLandObjects) |
|
31 |
-- force seed instead. Some themes will still be easier, but at least you won't luck out on the same theme |
|
32 |
Seed = ClimbHome |
|
33 |
end |
|
34 |
||
35 |
function onGearAdd(gear) |
|
36 |
if GetGearType(gear) == gtHedgehog then |
|
37 |
HH[gear] = 1 |
|
38 |
end |
|
39 |
end |
|
40 |
||
41 |
function onGearDelete(gear) |
|
42 |
if gear == MrMine then |
|
43 |
AddCaption("Once you set off the proximity trigger, Mr. Mine is not your friend",0xffffff,0) |
|
44 |
MrMine = nil |
|
45 |
elseif gear == Cake then |
|
46 |
Cake = nil |
|
47 |
end |
|
48 |
end |
|
49 |
||
50 |
function onGameStart() |
|
51 |
ShowMission(loc("Climb Home"), |
|
52 |
loc("Rope to safety"), |
|
53 |
loc("You are far from home, and the water is rising, climb up as high as you can!"), |
|
54 |
-amRope, 0) |
|
55 |
local x = 1818 |
|
56 |
for h,i in pairs(HH) do |
|
57 |
-- SetGearPosition(h,x,32549) |
|
58 |
SetGearPosition(h,x,108) |
|
59 |
SetHealth(h,1) |
|
60 |
if x < 1978 then x = x+32 else x = 1818 end |
|
10580
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
61 |
if GetEffect(h,heInvulnerable) == 0 then |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
62 |
SetEffect(h,heInvulnerable,1) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
63 |
else |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
64 |
HogsAreInvulnerable = true |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
65 |
end |
10413 | 66 |
SetState(h,bor(GetState(h),gstInvisible)) |
67 |
end |
|
68 |
-- 1925,263 - Mr. Mine position |
|
69 |
MrMine = AddGear(1925,263,gtMine,0,0,0,0) |
|
70 |
end |
|
71 |
function onAmmoStoreInit() |
|
72 |
SetAmmo(amRope, 9, 0, 0, 0) |
|
73 |
end |
|
74 |
||
75 |
function onNewTurn() |
|
76 |
startTime = GameTime |
|
77 |
--disable to preserve highest over multiple turns |
|
78 |
--will need to change water check too ofc |
|
79 |
MaxHeight = 32640 |
|
80 |
hTagHeight = 33000 |
|
81 |
SetWaterLine(32768) |
|
82 |
if CurrentHedgehog ~= nil then |
|
83 |
SetGearPosition(CurrentHedgehog, 1951,32640) |
|
10580
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
84 |
if not HogsAreInvulnerable then |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
85 |
SetEffect(CurrentHedgehog,heInvulnerable,0) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
86 |
end |
10413 | 87 |
AddVisualGear(19531,32640,vgtExplosion,0,false) |
88 |
SetState(CurrentHedgehog,band(GetState(CurrentHedgehog),bnot(gstInvisible))) |
|
89 |
end |
|
90 |
for f,i in pairs(Fire) do |
|
91 |
DeleteGear(f) |
|
92 |
end |
|
93 |
for s,i in pairs(Stars) do |
|
94 |
DeleteVisualGear(s) |
|
95 |
Stars[s] = nil |
|
96 |
end |
|
97 |
||
98 |
for i = 0,12 do |
|
99 |
flame = AddGear(2000+i*2,308, gtFlame, gsttmpFlag, 0, 0, 0) |
|
100 |
SetTag(flame, 999999+i) |
|
101 |
Fire[flame]=1 |
|
102 |
end |
|
103 |
if Cake ~= nil then DeleteGear(Cake) end |
|
104 |
CakeTries = 0 |
|
105 |
end |
|
106 |
||
107 |
--function onGearDelete(gear) |
|
108 |
-- if gear == WaterRise and MaxHeight > 500 and CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then |
|
109 |
-- WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0) |
|
110 |
-- end |
|
111 |
--end |
|
112 |
||
113 |
function FireBoom(x,y,d) -- going to add for rockets too |
|
114 |
AddVisualGear(x,y,vgtExplosion,0,false) |
|
10580
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
115 |
-- should approximate circle by removing corners |
10413 | 116 |
if BoomFire == nil then BoomFire = {} end |
117 |
for i = 0,50 do |
|
10580
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
118 |
fx = GetRandom(d)-div(d,2) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
119 |
fy = GetRandom(d)-div(d,2) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
120 |
if fx<0 then |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
121 |
fdx = -5000-GetRandom(3000) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
122 |
else |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
123 |
fdx = 5000+GetRandom(3000) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
124 |
end |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
125 |
if fy<0 then |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
126 |
fdy = -5000-GetRandom(3000) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
127 |
else |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
128 |
fdy = 5000+GetRandom(3000) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
129 |
end |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
130 |
flame = AddGear(x+fx, y+fy, gtFlame, gsttmpFlag, fdx, fdy, 0) |
10413 | 131 |
SetTag(flame, 999999+i) |
132 |
Fire[flame]=1 |
|
133 |
-- BoomFire[flame]=1 |
|
134 |
end |
|
135 |
end |
|
136 |
||
137 |
||
138 |
function onGameTick20() |
|
139 |
if math.random(20) == 1 then |
|
140 |
AddVisualGear(2012,56,vgtSmoke,0,false) |
|
141 |
end |
|
142 |
--if BoomFire ~= nil then |
|
143 |
-- for f,i in pairs(BoomFire) do |
|
144 |
-- if band(GetState(f),gstCollision~=0) then DeleteGear(f) end |
|
145 |
-- end |
|
146 |
-- BoomFire = nil |
|
147 |
--end |
|
148 |
||
149 |
for s,i in pairs(Stars) do |
|
150 |
g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(s) |
|
151 |
if g1 > WaterLine + 500 then |
|
152 |
DeleteVisualGear(s) |
|
153 |
Stars[s] = nil |
|
154 |
end |
|
155 |
--else wasn't really visible, pointless. |
|
156 |
-- g5 = g5+1 |
|
157 |
-- if g5 > 360 then g5 = 0 end |
|
158 |
-- SetVisualGearValues(s, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10) |
|
159 |
--end |
|
160 |
end |
|
161 |
||
162 |
if Cake ~= nil and CurrentHedgehog ~= nil then |
|
163 |
local cx,cy = GetGearPosition(Cake) |
|
164 |
local x,y = GetGearPosition(CurrentHedgehog) |
|
165 |
if y < cy-1500 then |
|
166 |
DeleteGear(Cake) |
|
167 |
Cake = nil |
|
168 |
end |
|
169 |
if gearIsInCircle(CurrentHedgehog,cx,cy,450) then |
|
10580
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
170 |
FireBoom(cx,cy,200) -- todo animate |
10413 | 171 |
DeleteGear(Cake) |
172 |
Cake = nil |
|
173 |
end |
|
174 |
end |
|
175 |
||
176 |
if CurrentHedgehog ~= nil and TurnTimeLeft > 0 and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then |
|
177 |
if MaxHeight < 32000 and MaxHeight > 286 and WaterLine > 286 then SetWaterLine(WaterLine-2) end |
|
178 |
local x,y = GetGearPosition(CurrentHedgehog) |
|
179 |
if y > 0 and y < 30000 and MaxHeight > 286 and math.random(y) < 500 then |
|
180 |
local s = AddVisualGear(0, 0, vgtStraightShot, 0, true) |
|
181 |
local c = div(250000,y) |
|
182 |
if c > 255 then c = 255 end |
|
183 |
c = c * 0x10000 + 0xFF0000FF |
|
184 |
SetVisualGearValues(s, |
|
185 |
math.random(2048), -5000, 0, -1-(1/y*1000), |
|
186 |
math.random(360), |
|
187 |
0, |
|
188 |
999999999, -- frameticks |
|
189 |
171, -- star |
|
190 |
0, c) |
|
191 |
--, 0xFFCC00FF) -- could be fun to make colour shift as you rise... |
|
192 |
Stars[s] = 1 |
|
193 |
end |
|
194 |
end |
|
195 |
||
196 |
if CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) == 0 then |
|
197 |
for f,i in pairs(Fire) do -- takes too long to fall otherwise |
|
198 |
DeleteGear(f) |
|
199 |
end |
|
200 |
if Cake ~= nil then |
|
201 |
DeleteGear(Cake) |
|
202 |
Cake = nil |
|
203 |
end |
|
204 |
end |
|
205 |
||
206 |
if GameTime % 500 == 0 and CurrentHedgehog ~= nil and TurnTimeLeft > 0 then |
|
207 |
--if isSinglePlayer and MaxHeight < 32000 and WaterRise == nil then |
|
208 |
-- WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0) |
|
209 |
--end |
|
210 |
if isSinglePlayer and not YouWon and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then |
|
211 |
ShowMission(loc("Climb Home"), |
|
212 |
loc("Made it!"), |
|
213 |
string.format(loc("AHHh, home sweet home. Made it in %d seconds."),(GameTime-startTime)/1000), |
|
214 |
-amRope, 0) |
|
215 |
PlaySound(sndVictory,CurrentHedgehog) |
|
216 |
EndGame() |
|
217 |
YouWon = true |
|
218 |
end |
|
219 |
||
220 |
local x,y = GetGearPosition(CurrentHedgehog) |
|
221 |
if CakeTries < 10 and y < 32600 and y > 3000 and Cake == nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then |
|
222 |
-- doing this just after the start the first time to take advantage of randomness sources |
|
223 |
-- there's a small chance it'll jiggle the camera though, so trying not to do it too often |
|
224 |
-- Pick a clear y to start with |
|
225 |
if y > 31000 then cy = 24585 elseif |
|
226 |
y > 28000 then cy = 21500 elseif |
|
227 |
y > 24000 then cy = 19000 elseif |
|
228 |
y > 21500 then cy = 16000 elseif |
|
229 |
y > 19000 then cy = 12265 elseif |
|
230 |
y > 16000 then cy = 8800 elseif |
|
231 |
y > 12000 then cy = 5700 else |
|
232 |
cy = 400 end |
|
233 |
Cake = AddGear(GetRandom(2048), cy, gtCake, 0, 0, 0, 0) |
|
234 |
SetHealth(Cake,999999) |
|
10580
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
235 |
CakeTries = CakeTries + 1 |
10413 | 236 |
end |
237 |
if (y > 286) or (y < 286 and MaxHeight > 286) then |
|
238 |
if y < MaxHeight and y > 286 then MaxHeight = y end |
|
239 |
if y < 286 then MaxHeight = 286 end |
|
240 |
if MaxHeight < hTagHeight then |
|
241 |
hTagHeight = MaxHeight |
|
242 |
if hTag ~= nil then DeleteVisualGear(hTag) end |
|
243 |
hTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
244 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag) |
|
245 |
-- snagged from space invasion |
|
246 |
SetVisualGearValues ( |
|
247 |
hTag, --id |
|
248 |
-(ScreenWidth/2) + 40, --xoffset |
|
249 |
ScreenHeight - 60, --yoffset |
|
250 |
0, --dx |
|
251 |
0, --dy |
|
252 |
1.1, --zoom |
|
253 |
1, --~= 0 means align to screen |
|
254 |
g7, --frameticks |
|
255 |
-- 116px off bottom for lowest rock, 286 or so off top for position of chair |
|
256 |
-- 32650 is "0" |
|
257 |
32640-hTagHeight, --value |
|
258 |
99999999999,--timer |
|
259 |
GetClanColor(GetHogClan(CurrentHedgehog)) |
|
260 |
) |
|
261 |
end |
|
262 |
if MaxHeight < RecordHeight then |
|
263 |
RecordHeight = MaxHeight |
|
264 |
if rTag ~= nil then DeleteVisualGear(rTag) end |
|
265 |
rTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
266 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag) |
|
267 |
-- snagged from space invasion |
|
268 |
SetVisualGearValues ( |
|
269 |
rTag, --id |
|
270 |
-(ScreenWidth/2) + 100, --xoffset |
|
271 |
ScreenHeight - 60, --yoffset |
|
272 |
0, --dx |
|
273 |
0, --dy |
|
274 |
1.1, --zoom |
|
275 |
1, --~= 0 means align to screen |
|
276 |
g7, --frameticks |
|
277 |
-- 116px off bottom for lowest rock, 286 or so off top for position of chair |
|
278 |
-- 32650 is "0" |
|
279 |
32640-RecordHeight, --value |
|
280 |
99999999999,--timer |
|
281 |
GetClanColor(GetHogClan(CurrentHedgehog)) |
|
282 |
) |
|
283 |
end |
|
284 |
end |
|
285 |
if MaxHeight > 286 then |
|
286 |
if tTag ~= nil then DeleteVisualGear(tTag) end |
|
287 |
tTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
288 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tTag) |
|
289 |
-- snagged from space invasion |
|
290 |
SetVisualGearValues ( |
|
291 |
tTag, --id |
|
292 |
-(ScreenWidth/2) + 40, --xoffset |
|
293 |
ScreenHeight - 100, --yoffset |
|
294 |
0, --dx |
|
295 |
0, --dy |
|
296 |
1.1, --zoom |
|
297 |
1, --~= 0 means align to screen |
|
298 |
g7, --frameticks |
|
299 |
(GameTime-startTime)/1000, --value |
|
300 |
99999999999,--timer |
|
301 |
0xffffffff |
|
302 |
) |
|
303 |
end |
|
304 |
end |
|
305 |
end |