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
|
|
16 |
local WaterRise = nil
|
|
17 |
local Cake = nil
|
|
18 |
local CakeWasJustAdded = false
|
|
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
|
|
61 |
SetState(h,bor(GetState(h),gstInvisible))
|
|
62 |
end
|
|
63 |
-- 1925,263 - Mr. Mine position
|
|
64 |
MrMine = AddGear(1925,263,gtMine,0,0,0,0)
|
|
65 |
end
|
|
66 |
function onAmmoStoreInit()
|
|
67 |
SetAmmo(amRope, 9, 0, 0, 0)
|
|
68 |
end
|
|
69 |
|
|
70 |
function onNewTurn()
|
|
71 |
startTime = GameTime
|
|
72 |
--disable to preserve highest over multiple turns
|
|
73 |
--will need to change water check too ofc
|
|
74 |
MaxHeight = 32640
|
|
75 |
hTagHeight = 33000
|
|
76 |
SetWaterLine(32768)
|
|
77 |
if CurrentHedgehog ~= nil then
|
|
78 |
SetGearPosition(CurrentHedgehog, 1951,32640)
|
|
79 |
AddVisualGear(19531,32640,vgtExplosion,0,false)
|
|
80 |
SetState(CurrentHedgehog,band(GetState(CurrentHedgehog),bnot(gstInvisible)))
|
|
81 |
end
|
|
82 |
for f,i in pairs(Fire) do
|
|
83 |
DeleteGear(f)
|
|
84 |
end
|
|
85 |
for s,i in pairs(Stars) do
|
|
86 |
DeleteVisualGear(s)
|
|
87 |
Stars[s] = nil
|
|
88 |
end
|
|
89 |
|
|
90 |
for i = 0,12 do
|
|
91 |
flame = AddGear(2000+i*2,308, gtFlame, gsttmpFlag, 0, 0, 0)
|
|
92 |
SetTag(flame, 999999+i)
|
|
93 |
Fire[flame]=1
|
|
94 |
end
|
|
95 |
if Cake ~= nil then DeleteGear(Cake) end
|
|
96 |
CakeTries = 0
|
|
97 |
end
|
|
98 |
|
|
99 |
--function onGearDelete(gear)
|
|
100 |
-- if gear == WaterRise and MaxHeight > 500 and CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then
|
|
101 |
-- WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0)
|
|
102 |
-- end
|
|
103 |
--end
|
|
104 |
|
|
105 |
function FireBoom(x,y,d) -- going to add for rockets too
|
|
106 |
AddVisualGear(x,y,vgtExplosion,0,false)
|
|
107 |
-- going to approximate circle by removing corners
|
|
108 |
if BoomFire == nil then BoomFire = {} end
|
|
109 |
for i = 0,50 do
|
|
110 |
flame = AddGear(x+GetRandom(d),y+GetRandom(d), gtFlame, gsttmpFlag, 0, 0, 0)
|
|
111 |
SetTag(flame, 999999+i)
|
|
112 |
Fire[flame]=1
|
|
113 |
-- BoomFire[flame]=1
|
|
114 |
end
|
|
115 |
end
|
|
116 |
|
|
117 |
|
|
118 |
function onGameTick20()
|
|
119 |
if math.random(20) == 1 then
|
|
120 |
AddVisualGear(2012,56,vgtSmoke,0,false)
|
|
121 |
end
|
|
122 |
if CakeWasJustAdded then
|
|
123 |
FollowGear(CurrentHedgehog)
|
|
124 |
CakeWasJustAdded = false
|
|
125 |
end
|
|
126 |
--if BoomFire ~= nil then
|
|
127 |
-- for f,i in pairs(BoomFire) do
|
|
128 |
-- if band(GetState(f),gstCollision~=0) then DeleteGear(f) end
|
|
129 |
-- end
|
|
130 |
-- BoomFire = nil
|
|
131 |
--end
|
|
132 |
|
|
133 |
for s,i in pairs(Stars) do
|
|
134 |
g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(s)
|
|
135 |
if g1 > WaterLine + 500 then
|
|
136 |
DeleteVisualGear(s)
|
|
137 |
Stars[s] = nil
|
|
138 |
end
|
|
139 |
--else wasn't really visible, pointless.
|
|
140 |
-- g5 = g5+1
|
|
141 |
-- if g5 > 360 then g5 = 0 end
|
|
142 |
-- SetVisualGearValues(s, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10)
|
|
143 |
--end
|
|
144 |
end
|
|
145 |
|
|
146 |
if Cake ~= nil and CurrentHedgehog ~= nil then
|
|
147 |
local cx,cy = GetGearPosition(Cake)
|
|
148 |
local x,y = GetGearPosition(CurrentHedgehog)
|
|
149 |
if y < cy-1500 then
|
|
150 |
DeleteGear(Cake)
|
|
151 |
Cake = nil
|
|
152 |
end
|
|
153 |
if gearIsInCircle(CurrentHedgehog,cx,cy,450) then
|
|
154 |
FireBoom(cx,cy,350) -- todo animate
|
|
155 |
DeleteGear(Cake)
|
|
156 |
Cake = nil
|
|
157 |
end
|
|
158 |
end
|
|
159 |
|
|
160 |
if CurrentHedgehog ~= nil and TurnTimeLeft > 0 and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then
|
|
161 |
if MaxHeight < 32000 and MaxHeight > 286 and WaterLine > 286 then SetWaterLine(WaterLine-2) end
|
|
162 |
local x,y = GetGearPosition(CurrentHedgehog)
|
|
163 |
if y > 0 and y < 30000 and MaxHeight > 286 and math.random(y) < 500 then
|
|
164 |
local s = AddVisualGear(0, 0, vgtStraightShot, 0, true)
|
|
165 |
local c = div(250000,y)
|
|
166 |
if c > 255 then c = 255 end
|
|
167 |
c = c * 0x10000 + 0xFF0000FF
|
|
168 |
SetVisualGearValues(s,
|
|
169 |
math.random(2048), -5000, 0, -1-(1/y*1000),
|
|
170 |
math.random(360),
|
|
171 |
0,
|
|
172 |
999999999, -- frameticks
|
|
173 |
171, -- star
|
|
174 |
0, c)
|
|
175 |
--, 0xFFCC00FF) -- could be fun to make colour shift as you rise...
|
|
176 |
Stars[s] = 1
|
|
177 |
end
|
|
178 |
end
|
|
179 |
|
|
180 |
if CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) == 0 then
|
|
181 |
for f,i in pairs(Fire) do -- takes too long to fall otherwise
|
|
182 |
DeleteGear(f)
|
|
183 |
end
|
|
184 |
if Cake ~= nil then
|
|
185 |
DeleteGear(Cake)
|
|
186 |
Cake = nil
|
|
187 |
end
|
|
188 |
end
|
|
189 |
|
|
190 |
if GameTime % 500 == 0 and CurrentHedgehog ~= nil and TurnTimeLeft > 0 then
|
|
191 |
--if isSinglePlayer and MaxHeight < 32000 and WaterRise == nil then
|
|
192 |
-- WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0)
|
|
193 |
--end
|
|
194 |
if isSinglePlayer and not YouWon and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then
|
|
195 |
ShowMission(loc("Climb Home"),
|
|
196 |
loc("Made it!"),
|
|
197 |
string.format(loc("AHHh, home sweet home. Made it in %d seconds."),(GameTime-startTime)/1000),
|
|
198 |
-amRope, 0)
|
|
199 |
PlaySound(sndVictory,CurrentHedgehog)
|
|
200 |
EndGame()
|
|
201 |
YouWon = true
|
|
202 |
end
|
|
203 |
|
|
204 |
local x,y = GetGearPosition(CurrentHedgehog)
|
|
205 |
if CakeTries < 10 and y < 32600 and y > 3000 and Cake == nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then
|
|
206 |
-- doing this just after the start the first time to take advantage of randomness sources
|
|
207 |
-- there's a small chance it'll jiggle the camera though, so trying not to do it too often
|
|
208 |
-- Pick a clear y to start with
|
|
209 |
if y > 31000 then cy = 24585 elseif
|
|
210 |
y > 28000 then cy = 21500 elseif
|
|
211 |
y > 24000 then cy = 19000 elseif
|
|
212 |
y > 21500 then cy = 16000 elseif
|
|
213 |
y > 19000 then cy = 12265 elseif
|
|
214 |
y > 16000 then cy = 8800 elseif
|
|
215 |
y > 12000 then cy = 5700 else
|
|
216 |
cy = 400 end
|
|
217 |
Cake = AddGear(GetRandom(2048), cy, gtCake, 0, 0, 0, 0)
|
|
218 |
SetHealth(Cake,999999)
|
|
219 |
CakeWasJustAdded = true
|
|
220 |
CakeTries = CakeTries + 1 -- just try twice right now
|
|
221 |
end
|
|
222 |
if (y > 286) or (y < 286 and MaxHeight > 286) then
|
|
223 |
if y < MaxHeight and y > 286 then MaxHeight = y end
|
|
224 |
if y < 286 then MaxHeight = 286 end
|
|
225 |
if MaxHeight < hTagHeight then
|
|
226 |
hTagHeight = MaxHeight
|
|
227 |
if hTag ~= nil then DeleteVisualGear(hTag) end
|
|
228 |
hTag = AddVisualGear(0, 0, vgtHealthTag, 0, true)
|
|
229 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag)
|
|
230 |
-- snagged from space invasion
|
|
231 |
SetVisualGearValues (
|
|
232 |
hTag, --id
|
|
233 |
-(ScreenWidth/2) + 40, --xoffset
|
|
234 |
ScreenHeight - 60, --yoffset
|
|
235 |
0, --dx
|
|
236 |
0, --dy
|
|
237 |
1.1, --zoom
|
|
238 |
1, --~= 0 means align to screen
|
|
239 |
g7, --frameticks
|
|
240 |
-- 116px off bottom for lowest rock, 286 or so off top for position of chair
|
|
241 |
-- 32650 is "0"
|
|
242 |
32640-hTagHeight, --value
|
|
243 |
99999999999,--timer
|
|
244 |
GetClanColor(GetHogClan(CurrentHedgehog))
|
|
245 |
)
|
|
246 |
end
|
|
247 |
if MaxHeight < RecordHeight then
|
|
248 |
RecordHeight = MaxHeight
|
|
249 |
if rTag ~= nil then DeleteVisualGear(rTag) end
|
|
250 |
rTag = AddVisualGear(0, 0, vgtHealthTag, 0, true)
|
|
251 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag)
|
|
252 |
-- snagged from space invasion
|
|
253 |
SetVisualGearValues (
|
|
254 |
rTag, --id
|
|
255 |
-(ScreenWidth/2) + 100, --xoffset
|
|
256 |
ScreenHeight - 60, --yoffset
|
|
257 |
0, --dx
|
|
258 |
0, --dy
|
|
259 |
1.1, --zoom
|
|
260 |
1, --~= 0 means align to screen
|
|
261 |
g7, --frameticks
|
|
262 |
-- 116px off bottom for lowest rock, 286 or so off top for position of chair
|
|
263 |
-- 32650 is "0"
|
|
264 |
32640-RecordHeight, --value
|
|
265 |
99999999999,--timer
|
|
266 |
GetClanColor(GetHogClan(CurrentHedgehog))
|
|
267 |
)
|
|
268 |
end
|
|
269 |
end
|
|
270 |
if MaxHeight > 286 then
|
|
271 |
if tTag ~= nil then DeleteVisualGear(tTag) end
|
|
272 |
tTag = AddVisualGear(0, 0, vgtHealthTag, 0, true)
|
|
273 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tTag)
|
|
274 |
-- snagged from space invasion
|
|
275 |
SetVisualGearValues (
|
|
276 |
tTag, --id
|
|
277 |
-(ScreenWidth/2) + 40, --xoffset
|
|
278 |
ScreenHeight - 100, --yoffset
|
|
279 |
0, --dx
|
|
280 |
0, --dy
|
|
281 |
1.1, --zoom
|
|
282 |
1, --~= 0 means align to screen
|
|
283 |
g7, --frameticks
|
|
284 |
(GameTime-startTime)/1000, --value
|
|
285 |
99999999999,--timer
|
|
286 |
0xffffffff
|
|
287 |
)
|
|
288 |
end
|
|
289 |
end
|
|
290 |
end
|