author | nemo |
Sun, 30 Nov 2014 16:06:39 -0500 | |
changeset 10592 | 2da35f88db23 |
parent 10589 | 98ea597e5cd9 |
child 10593 | 7d41b0446706 |
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 |
|
10581 | 11 |
local RecordHeightHogName = nil |
10413 | 12 |
local Fire = {} |
13 |
--local BoomFire = nil |
|
14 |
local HH = {} |
|
10581 | 15 |
local totalHedgehogs = 0 |
16 |
local deadHedgehogs = 0 |
|
17 |
local teamScoreStats = {} |
|
18 |
local teamBests = {} |
|
10413 | 19 |
local MrMine -- in honour of sparkle's first arrival in the cabin |
20 |
local YouWon = false |
|
10581 | 21 |
local YouLost = 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
|
22 |
local HogsAreInvulnerable = false |
10413 | 23 |
local WaterRise = nil |
24 |
local Cake = nil |
|
25 |
local CakeTries = 0 |
|
26 |
local Stars = {} |
|
10581 | 27 |
local tauntNoo = false |
28 |
local jokeAwardNavy = nil |
|
29 |
local jokeAwardSpeed = nil |
|
30 |
local jokeAwardDamage = nil |
|
31 |
local recordBroken = false |
|
32 |
local ready = false |
|
33 |
local showWaterStats = false -- uses the AI team to draw water height. |
|
34 |
local dummyHog = nil |
|
10592 | 35 |
local dummySkip = 0 |
10413 | 36 |
|
37 |
function onGameInit() |
|
38 |
-- Ensure people get same map for same theme |
|
39 |
TurnTime = 999999999 |
|
40 |
CaseFreq = 0 |
|
41 |
Explosives = 0 |
|
42 |
MineDudPercent = 0 |
|
43 |
DisableGameFlags(gfBottomBorder+gfBorder) |
|
44 |
--This reduced startup time by only about 15% and looked ugly |
|
45 |
--EnableGameFlags(gfDisableLandObjects) |
|
46 |
-- force seed instead. Some themes will still be easier, but at least you won't luck out on the same theme |
|
47 |
Seed = ClimbHome |
|
10581 | 48 |
AddTeam(loc("Water Gods"), 0x0000AC, "Simple", "Island", "Default") |
49 |
dummyHog = AddHog("Poseidon", 0, 1, "NoHat") |
|
50 |
SendStat(siClanHealth, tostring(32640), loc("Water Gods")) |
|
51 |
SendStat(siClanHealth, tostring(32640), loc("Water Gods")) |
|
52 |
--HideHog(dummyHog) |
|
10413 | 53 |
end |
54 |
||
55 |
function onGearAdd(gear) |
|
56 |
if GetGearType(gear) == gtHedgehog then |
|
57 |
HH[gear] = 1 |
|
10581 | 58 |
totalHedgehogs = totalHedgehogs + 1 |
10413 | 59 |
end |
60 |
end |
|
61 |
||
62 |
function onGearDelete(gear) |
|
63 |
if gear == MrMine then |
|
64 |
AddCaption("Once you set off the proximity trigger, Mr. Mine is not your friend",0xffffff,0) |
|
65 |
MrMine = nil |
|
66 |
elseif gear == Cake then |
|
67 |
Cake = nil |
|
10581 | 68 |
elseif GetGearType(gear) == gtHedgehog then |
69 |
HH[gear] = nil |
|
10413 | 70 |
end |
71 |
end |
|
72 |
||
73 |
function onGameStart() |
|
10581 | 74 |
--SetClanColor(ClansCount-1, 0x0000ffff) appears to be broken |
75 |
SendHealthStatsOff() |
|
10413 | 76 |
ShowMission(loc("Climb Home"), |
77 |
loc("Rope to safety"), |
|
10581 | 78 |
loc("You are far from home, and the water is rising, climb up as high as you can!|Your score will be based on your height."), |
10413 | 79 |
-amRope, 0) |
80 |
local x = 1818 |
|
81 |
for h,i in pairs(HH) do |
|
82 |
-- SetGearPosition(h,x,32549) |
|
83 |
SetGearPosition(h,x,108) |
|
84 |
SetHealth(h,1) |
|
85 |
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
|
86 |
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
|
87 |
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
|
88 |
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
|
89 |
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
|
90 |
end |
10413 | 91 |
SetState(h,bor(GetState(h),gstInvisible)) |
92 |
end |
|
93 |
-- 1925,263 - Mr. Mine position |
|
94 |
MrMine = AddGear(1925,263,gtMine,0,0,0,0) |
|
95 |
end |
|
10581 | 96 |
|
10413 | 97 |
function onAmmoStoreInit() |
98 |
SetAmmo(amRope, 9, 0, 0, 0) |
|
99 |
end |
|
100 |
||
101 |
function onNewTurn() |
|
10581 | 102 |
ready = false |
10413 | 103 |
startTime = GameTime |
104 |
--disable to preserve highest over multiple turns |
|
105 |
--will need to change water check too ofc |
|
106 |
MaxHeight = 32640 |
|
107 |
hTagHeight = 33000 |
|
108 |
SetWaterLine(32768) |
|
10581 | 109 |
YouWon = false |
110 |
YouLost = false |
|
111 |
tauntNoo = false |
|
112 |
recordBroken = false |
|
10592 | 113 |
if CurrentHedgehog ~= nil then |
114 |
if CurrentHedgehog ~= dummyHog then |
|
115 |
SetGearPosition(CurrentHedgehog, 1951,32640) |
|
116 |
if not HogsAreInvulnerable then SetEffect(CurrentHedgehog,heInvulnerable,0) end |
|
117 |
AddVisualGear(19531,32640,vgtExplosion,0,false) |
|
118 |
SetState(CurrentHedgehog,band(GetState(CurrentHedgehog),bnot(gstInvisible))) |
|
119 |
SetWeapon(amRope) |
|
120 |
ready = true |
|
121 |
else |
|
122 |
dummySkip = GameTime+1 |
|
123 |
end |
|
10413 | 124 |
end |
125 |
for f,i in pairs(Fire) do |
|
126 |
DeleteGear(f) |
|
127 |
end |
|
128 |
for s,i in pairs(Stars) do |
|
129 |
DeleteVisualGear(s) |
|
130 |
Stars[s] = nil |
|
131 |
end |
|
132 |
||
10581 | 133 |
if CurrentHedgehog ~= dummyHog then |
134 |
for i = 0,12 do |
|
135 |
flame = AddGear(2000+i*2,308, gtFlame, gsttmpFlag, 0, 0, 0) |
|
136 |
SetTag(flame, 999999+i) |
|
137 |
Fire[flame]=1 |
|
138 |
end |
|
10413 | 139 |
end |
140 |
if Cake ~= nil then DeleteGear(Cake) end |
|
141 |
CakeTries = 0 |
|
142 |
end |
|
143 |
||
144 |
--function onGearDelete(gear) |
|
145 |
-- if gear == WaterRise and MaxHeight > 500 and CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then |
|
146 |
-- WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0) |
|
147 |
-- end |
|
148 |
--end |
|
149 |
||
150 |
function FireBoom(x,y,d) -- going to add for rockets too |
|
151 |
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
|
152 |
-- should approximate circle by removing corners |
10581 | 153 |
--if BoomFire == nil then BoomFire = {} end |
10413 | 154 |
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
|
155 |
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
|
156 |
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
|
157 |
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
|
158 |
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
|
159 |
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
|
160 |
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
|
161 |
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
|
162 |
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
|
163 |
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
|
164 |
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
|
165 |
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
|
166 |
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
|
167 |
flame = AddGear(x+fx, y+fy, gtFlame, gsttmpFlag, fdx, fdy, 0) |
10413 | 168 |
SetTag(flame, 999999+i) |
10589
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10587
diff
changeset
|
169 |
SetFlightTime(flame, 0) |
10413 | 170 |
Fire[flame]=1 |
171 |
-- BoomFire[flame]=1 |
|
172 |
end |
|
173 |
end |
|
174 |
||
175 |
||
176 |
function onGameTick20() |
|
10581 | 177 |
local x,y; |
178 |
if math.random(20) == 1 then AddVisualGear(2012,56,vgtSmoke,0,false) end |
|
10592 | 179 |
if CurrentHedgehog == dummyHog and dummySkip ~= 0 and dummySkip < GameTime then |
10585 | 180 |
ParseCommand("/skip") |
10592 | 181 |
dummySkip = 0 |
10585 | 182 |
end |
10581 | 183 |
|
10413 | 184 |
--if BoomFire ~= nil then |
185 |
-- for f,i in pairs(BoomFire) do |
|
186 |
-- if band(GetState(f),gstCollision~=0) then DeleteGear(f) end |
|
187 |
-- end |
|
188 |
-- BoomFire = nil |
|
189 |
--end |
|
190 |
||
191 |
for s,i in pairs(Stars) do |
|
192 |
g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(s) |
|
193 |
if g1 > WaterLine + 500 then |
|
194 |
DeleteVisualGear(s) |
|
195 |
Stars[s] = nil |
|
196 |
end |
|
197 |
--else wasn't really visible, pointless. |
|
198 |
-- g5 = g5+1 |
|
199 |
-- if g5 > 360 then g5 = 0 end |
|
200 |
-- SetVisualGearValues(s, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10) |
|
201 |
--end |
|
202 |
end |
|
203 |
||
10581 | 204 |
if CurrentHedgehog ~= nil then x,y = GetGearPosition(CurrentHedgehog) end |
10413 | 205 |
if Cake ~= nil and CurrentHedgehog ~= nil then |
206 |
local cx,cy = GetGearPosition(Cake) |
|
207 |
if y < cy-1500 then |
|
208 |
DeleteGear(Cake) |
|
209 |
Cake = nil |
|
210 |
end |
|
10587
1dac23b5fe3b
delay cake boom until it has walked a little bit. also fix accidental drowning of watergods in last commit
nemo
parents:
10585
diff
changeset
|
211 |
|
1dac23b5fe3b
delay cake boom until it has walked a little bit. also fix accidental drowning of watergods in last commit
nemo
parents:
10585
diff
changeset
|
212 |
if GetHealth(Cake) < 999990 and 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
|
213 |
FireBoom(cx,cy,200) -- todo animate |
10413 | 214 |
DeleteGear(Cake) |
215 |
Cake = nil |
|
216 |
end |
|
217 |
end |
|
218 |
||
219 |
if CurrentHedgehog ~= nil and TurnTimeLeft > 0 and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then |
|
220 |
if MaxHeight < 32000 and MaxHeight > 286 and WaterLine > 286 then SetWaterLine(WaterLine-2) end |
|
221 |
if y > 0 and y < 30000 and MaxHeight > 286 and math.random(y) < 500 then |
|
222 |
local s = AddVisualGear(0, 0, vgtStraightShot, 0, true) |
|
223 |
local c = div(250000,y) |
|
224 |
if c > 255 then c = 255 end |
|
225 |
c = c * 0x10000 + 0xFF0000FF |
|
226 |
SetVisualGearValues(s, |
|
227 |
math.random(2048), -5000, 0, -1-(1/y*1000), |
|
228 |
math.random(360), |
|
229 |
0, |
|
230 |
999999999, -- frameticks |
|
231 |
171, -- star |
|
232 |
0, c) |
|
233 |
--, 0xFFCC00FF) -- could be fun to make colour shift as you rise... |
|
234 |
Stars[s] = 1 |
|
235 |
end |
|
236 |
end |
|
237 |
||
238 |
if CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) == 0 then |
|
239 |
for f,i in pairs(Fire) do -- takes too long to fall otherwise |
|
240 |
DeleteGear(f) |
|
241 |
end |
|
242 |
if Cake ~= nil then |
|
243 |
DeleteGear(Cake) |
|
244 |
Cake = nil |
|
245 |
end |
|
246 |
end |
|
247 |
||
10581 | 248 |
if CurrentHedgehog ~= nil and TurnTimeLeft > 0 then |
249 |
local vx, vy = GetGearVelocity(CurrentHedgehog) |
|
250 |
local distanceFromWater = WaterLine - y |
|
251 |
||
252 |
--[[ check joke awards ]] |
|
253 |
-- navy award: when distance from main map is over 1000 |
|
254 |
local navyDistance = 1250 |
|
255 |
if x < -navyDistance or x > LAND_WIDTH+navyDistance then |
|
256 |
local awarded = false |
|
257 |
local dist = 0 |
|
258 |
if jokeAwardNavy == nil then |
|
259 |
awarded = true |
|
260 |
else |
|
261 |
if x < 0 then |
|
262 |
dist = math.abs(x) |
|
263 |
else |
|
264 |
dist = x - LAND_WIDTH |
|
265 |
end |
|
266 |
if dist > jokeAwardNavy.distance then |
|
267 |
awarded = true |
|
268 |
end |
|
269 |
end |
|
270 |
if awarded == true then |
|
271 |
jokeAwardNavy = { |
|
272 |
hogName = GetHogName(CurrentHedgehog), |
|
273 |
teamName = GetHogTeamName(CurrentHedgehog), |
|
274 |
distance = dist |
|
275 |
} |
|
276 |
end |
|
277 |
end |
|
278 |
||
279 |
-- Speed award for largest distance from water |
|
280 |
if distanceFromWater > 3000 and WaterLine < 32000 then |
|
281 |
local awarded = false |
|
282 |
if jokeAwardSpeed == nil or distanceFromWater > jokeAwardSpeed.distance then |
|
283 |
awarded = true |
|
284 |
end |
|
285 |
if awarded == true then |
|
286 |
jokeAwardSpeed = { |
|
287 |
hogName = GetHogName(CurrentHedgehog), |
|
288 |
teamName = GetHogTeamName(CurrentHedgehog), |
|
289 |
distance = distanceFromWater |
|
290 |
} |
|
291 |
end |
|
10413 | 292 |
end |
293 |
||
10581 | 294 |
if GameTime % 500 == 0 then |
295 |
--if isSinglePlayer and MaxHeight < 32000 and WaterRise == nil then |
|
296 |
-- WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0) |
|
297 |
--end |
|
298 |
if showWaterStats == true then |
|
299 |
SendStat(siClanHealth, tostring(getActualHeight(WaterLine)), loc("Water Gods")) |
|
300 |
end |
|
301 |
SendStat(siClanHealth, tostring(getActualHeight(y)), loc(GetHogTeamName(CurrentHedgehog))) |
|
302 |
if isSinglePlayer then |
|
303 |
if distanceFromWater < 0 and not YouLost and not YouWon then |
|
304 |
makeSinglePlayerLoserStats() |
|
305 |
YouLost = true |
|
306 |
end |
|
307 |
if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then |
|
308 |
local finishTime = (GameTime-startTime)/1000 |
|
309 |
local roundedFinishTime = math.ceil(math.floor(finishTime+0.5)) |
|
310 |
AddCaption(loc("Victory!")) |
|
311 |
ShowMission(loc("Climb Home"), |
|
312 |
loc("Made it!"), |
|
313 |
string.format(loc("Ahhh, home, sweet home. Made it in %d seconds."), roundedFinishTime), |
|
314 |
-amRope, 0) |
|
315 |
PlaySound(sndVictory,CurrentHedgehog) |
|
316 |
SetState(CurrentHedgehog, gstWinner) |
|
317 |
SendStat(siGameResult, loc("You have beaten the challenge!")) |
|
318 |
SendStat(siGraphTitle, loc("Your height over time")) |
|
319 |
SendStat(siCustomAchievement, string.format(loc("%s reached home in %.3f seconds. Congratulations!"), loc(GetHogName(CurrentHedgehog)), finishTime)) |
|
320 |
SendStat(siCustomAchievement, string.format(loc("%s bravely climbed up to a dizzy height of %d to reach home."),loc(GetHogName(CurrentHedgehog)), getActualHeight(RecordHeight))) |
|
321 |
SendStat(siPointType, loc("seconds")) |
|
322 |
SendStat(siPlayerKills, tostring(roundedFinishTime), loc(GetHogTeamName(CurrentHedgehog))) |
|
323 |
||
324 |
if not showWaterStats == true then |
|
325 |
SendStat(siClanHealth, tostring(32640), loc("Water Gods")) |
|
326 |
end |
|
327 |
EndGame() |
|
328 |
YouWon = true |
|
329 |
end |
|
330 |
elseif distanceFromWater < 0 and not YouLost then |
|
331 |
makeMultiPlayerLoserStat(CurrentHedgehog) |
|
332 |
deadHedgehogs = deadHedgehogs + 1 |
|
333 |
YouLost = true |
|
334 |
if deadHedgehogs >= totalHedgehogs-1 then |
|
335 |
makeFinalMultiPlayerStats() |
|
336 |
EndGame() |
|
337 |
end |
|
338 |
end |
|
339 |
||
340 |
-- play taunts |
|
341 |
if not YouWon and not YouLost then |
|
342 |
local nooDistance = 500 |
|
343 |
if ((x < -nooDistance and vx < 0) or (x > LAND_WIDTH+nooDistance and vx > 0)) then |
|
344 |
if (tauntNoo == false and distanceFromWater > 80) then |
|
345 |
PlaySound(sndNooo, CurrentHedgehog) |
|
346 |
tauntNoo = true |
|
347 |
end |
|
348 |
end |
|
349 |
end |
|
350 |
||
351 |
if CakeTries < 10 and y < 32600 and y > 3000 and Cake == nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then |
|
352 |
-- doing this just after the start the first time to take advantage of randomness sources |
|
353 |
-- Pick a clear y to start with |
|
354 |
if y > 31000 then cy = 24585 elseif |
|
355 |
y > 28000 then cy = 21500 elseif |
|
356 |
y > 24000 then cy = 19000 elseif |
|
357 |
y > 21500 then cy = 16000 elseif |
|
358 |
y > 19000 then cy = 12265 elseif |
|
359 |
y > 16000 then cy = 8800 elseif |
|
360 |
y > 12000 then cy = 5700 else |
|
361 |
cy = 400 end |
|
362 |
Cake = AddGear(GetRandom(2048), cy, gtCake, 0, 0, 0, 0) |
|
363 |
SetHealth(Cake,999999) |
|
364 |
CakeTries = CakeTries + 1 |
|
365 |
end |
|
366 |
||
367 |
if (y > 286) or (y < 286 and MaxHeight > 286) then |
|
368 |
if y < MaxHeight and y > 286 then MaxHeight = y end |
|
369 |
if y < 286 then MaxHeight = 286 end |
|
370 |
if MaxHeight < hTagHeight then |
|
371 |
hTagHeight = MaxHeight |
|
372 |
if hTag ~= nil then DeleteVisualGear(hTag) end |
|
373 |
hTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
374 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag) |
|
375 |
-- snagged from space invasion |
|
376 |
SetVisualGearValues ( |
|
377 |
hTag, --id |
|
378 |
-(ScreenWidth/2) + 40, --xoffset |
|
379 |
ScreenHeight - 60, --yoffset |
|
380 |
0, --dx |
|
381 |
0, --dy |
|
382 |
1.1, --zoom |
|
383 |
1, --~= 0 means align to screen |
|
384 |
g7, --frameticks |
|
385 |
-- 116px off bottom for lowest rock, 286 or so off top for position of chair |
|
386 |
-- 32650 is "0" |
|
387 |
32640-hTagHeight, --value |
|
388 |
99999999999,--timer |
|
389 |
GetClanColor(GetHogClan(CurrentHedgehog)) |
|
390 |
) |
|
391 |
end |
|
392 |
||
393 |
if MaxHeight < RecordHeight then |
|
394 |
RecordHeight = MaxHeight |
|
395 |
local oldName = RecordHeightHogName |
|
396 |
RecordHeightHogName = GetHogName(CurrentHedgehog) |
|
397 |
if oldName == nil then recordBroken = true end |
|
398 |
if not isSinglePlayer and RecordHeight > 1500 and not recordBroken then |
|
399 |
recordBroken = true |
|
400 |
AddCaption(string.format(loc("%s has passed the best height of %s!"), RecordHeightHogName, oldName)) |
|
401 |
end |
|
402 |
if not isSinglePlayer then |
|
403 |
if rTag ~= nil then DeleteVisualGear(rTag) end |
|
404 |
rTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
405 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag) |
|
406 |
-- snagged from space invasion |
|
407 |
SetVisualGearValues ( |
|
408 |
rTag, --id |
|
409 |
-(ScreenWidth/2) + 100, --xoffset |
|
410 |
ScreenHeight - 60, --yoffset |
|
411 |
0, --dx |
|
412 |
0, --dy |
|
413 |
1.1, --zoom |
|
414 |
1, --~= 0 means align to screen |
|
415 |
g7, --frameticks |
|
416 |
-- 116px off bottom for lowest rock, 286 or so off top for position of chair |
|
417 |
-- 32650 is "0" |
|
418 |
getActualHeight(RecordHeight), --value |
|
419 |
99999999999,--timer |
|
420 |
GetClanColor(GetHogClan(CurrentHedgehog)) |
|
421 |
) |
|
422 |
end |
|
423 |
end |
|
424 |
end |
|
425 |
if MaxHeight > 286 then |
|
426 |
if tTag ~= nil then DeleteVisualGear(tTag) end |
|
427 |
tTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
428 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tTag) |
|
10413 | 429 |
-- snagged from space invasion |
430 |
SetVisualGearValues ( |
|
431 |
tTag, --id |
|
432 |
-(ScreenWidth/2) + 40, --xoffset |
|
433 |
ScreenHeight - 100, --yoffset |
|
434 |
0, --dx |
|
435 |
0, --dy |
|
436 |
1.1, --zoom |
|
437 |
1, --~= 0 means align to screen |
|
438 |
g7, --frameticks |
|
439 |
(GameTime-startTime)/1000, --value |
|
440 |
99999999999,--timer |
|
441 |
0xffffffff |
|
442 |
) |
|
10581 | 443 |
end |
10413 | 444 |
end |
445 |
end |
|
446 |
end |
|
10581 | 447 |
|
448 |
function onGearDamage(gear, damage) |
|
449 |
if GetGearType(gear) == gtHedgehog and not YouLost and not YouWon then |
|
450 |
-- Joke award for largest damage to hog |
|
451 |
local qualifyDamage = 50 |
|
452 |
if (damage >= qualifyDamage) then |
|
453 |
local awarded = false |
|
454 |
if jokeAwardDamage == nil or damage > jokeAwardDamage.damage then |
|
455 |
awarded = true |
|
456 |
end |
|
457 |
if awarded == true then |
|
458 |
jokeAwardDamage = { |
|
459 |
hogName = GetHogName(CurrentHedgehog), |
|
460 |
teamName = GetHogTeamName(CurrentHedgehog), |
|
461 |
damage = damage |
|
462 |
} |
|
463 |
end |
|
464 |
end |
|
465 |
||
466 |
if isSinglePlayer then |
|
467 |
makeSinglePlayerLoserStats() |
|
468 |
else |
|
469 |
deadHedgehogs = deadHedgehogs + 1 |
|
470 |
if deadHedgehogs >= totalHedgehogs-1 then |
|
471 |
makeFinalMultiPlayerStats() |
|
472 |
EndGame() |
|
473 |
end |
|
474 |
makeMultiPlayerLoserStat(gear) |
|
475 |
end |
|
476 |
YouLost = true |
|
477 |
end |
|
478 |
end |
|
479 |
||
480 |
function makeLoserComment() |
|
481 |
local m |
|
482 |
if isSinglePlayer then m = 10 else m = 6 end |
|
483 |
local r = math.random(1,m) |
|
484 |
if r == 1 then text = loc("%s never got the ninja diploma.") |
|
485 |
elseif r == 2 then text = loc("You have to move upwards, not downwards, %s!") |
|
486 |
elseif r == 3 then text = loc("%s never wanted to reach for the sky in the first place.") |
|
487 |
elseif r == 4 then text = loc("%s should try the rope training mission first.") |
|
488 |
elseif r == 5 then text = loc("%s skipped ninja classes.") |
|
489 |
elseif r == 6 then text = loc("%s doesn’t really know how to handle a rope properly.") |
|
490 |
elseif r == 7 then text = loc("Better luck next time!") |
|
491 |
elseif r == 8 then text = loc("It was all just bad luck!") |
|
492 |
elseif r == 9 then text = loc("Well, that escalated quickly!") |
|
493 |
elseif r == 10 then text = loc("What? Is it over already?") end |
|
494 |
return text |
|
495 |
end |
|
496 |
||
497 |
function makeSinglePlayerLoserStats() |
|
498 |
local actualHeight = getActualHeight(RecordHeight) |
|
499 |
SendStat(siGameResult, loc("You lose!")) |
|
500 |
SendStat(siGraphTitle, loc("Your height over time")) |
|
501 |
local text |
|
502 |
if actualHeight > 30000 then text = loc("%s was damn close to home.") |
|
503 |
elseif actualHeight > 28000 then text = loc("%s was close to home.") |
|
504 |
elseif actualHeight > 24265 then text = loc("%s was good, but not good enough.") |
|
505 |
elseif actualHeight > 16177 then text = loc("%s managed to pass half of the distance towards home.") |
|
506 |
elseif actualHeight > 8088 then text = loc("%s went over a quarter of the way towards home.") |
|
507 |
elseif actualHeight > 5100 then text = loc("%s still had a long way to go.") |
|
508 |
elseif actualHeight > 2000 then text = loc("%s made it past the hogosphere.") |
|
509 |
elseif actualHeight > 1500 then text = loc("%s barely made it past the hogosphere.") |
|
510 |
else |
|
511 |
text = makeLoserComment() |
|
512 |
end |
|
513 |
if actualHeight > 1500 then |
|
514 |
SendStat(siCustomAchievement, string.format(text, RecordHeightHogName, actualHeight)) |
|
515 |
else |
|
516 |
SendStat(siCustomAchievement, string.format(text, RecordHeightHogName)) |
|
517 |
end |
|
518 |
SendStat(siPointType, "points") |
|
519 |
SendStat(siPlayerKills, actualHeight, loc(GetHogTeamName(CurrentHedgehog))) |
|
520 |
EndGame() |
|
521 |
end |
|
522 |
||
523 |
function makeMultiPlayerLoserStat(gear) |
|
524 |
local teamName = GetHogTeamName(gear) |
|
525 |
local actualHeight = getActualHeight(MaxHeight) |
|
526 |
if teamBests[teamName] == nil then teamBests[teamName] = actualHeight end |
|
527 |
if teamBests[teamName] < actualHeight then teamBests[teamName] = actualHeight end |
|
528 |
if teamScoreStats[teamName] == nil then teamScoreStats[teamName] = {} end |
|
529 |
table.insert(teamScoreStats[teamName], actualHeight) |
|
530 |
SendStat(siClanHealth, tostring(teamBests[teamName]), teamName) |
|
531 |
end |
|
532 |
||
533 |
function makeFinalMultiPlayerStats() |
|
534 |
local ranking = {} |
|
535 |
for k,v in pairs(teamBests) do |
|
536 |
table.insert(ranking, {name=k, score=v}) |
|
537 |
end |
|
538 |
local comp = function(table1, table2) |
|
539 |
if table1.score < table2.score then |
|
540 |
return true |
|
541 |
else |
|
542 |
return false |
|
543 |
end |
|
544 |
end |
|
545 |
table.sort(ranking, comp) |
|
546 |
||
547 |
local winner = ranking[#ranking] |
|
548 |
local loser = ranking[1] |
|
549 |
SendStat(siGameResult, string.format(loc("%s wins!"), winner.name)) |
|
550 |
SendStat(siGraphTitle, string.format(loc("Team’s best heights per round"))) |
|
551 |
||
552 |
if winner.score < 1500 then |
|
553 |
SendStat(siCustomAchievement, string.format(loc("This round’s award for ulitmate disappointment goes to: Everyone!"))) |
|
554 |
else |
|
555 |
if winner.score > 30000 then text = loc("%s (%s) reached for the sky and beyond with a height of %d!") |
|
556 |
elseif winner.score > 24750 then text = loc("%s (%s) was certainly not afraid of heights: Peak height of %d!") |
|
557 |
elseif winner.score > 16500 then text = loc("%s (%s) does not have to feel ashamed for their best height of %d.") |
|
558 |
elseif winner.score > 8250 then text = loc("%s (%s) reached a decent peak height of %d.") |
|
559 |
else text = loc("%s (%s) reached a peak height of %d.") end |
|
560 |
SendStat(siCustomAchievement, string.format(text, RecordHeightHogName, winner.name, winner.score)) |
|
561 |
||
562 |
if loser.score < 1500 then |
|
563 |
text = makeLoserComment() |
|
564 |
SendStat(siCustomAchievement, string.format(text, loser.name)) |
|
565 |
end |
|
566 |
end |
|
567 |
checkAwards() |
|
568 |
for i = #ranking, 1, -1 do |
|
569 |
SendStat(siPlayerKills, tostring(ranking[i].score), ranking[i].name) |
|
570 |
SendStat(siPointType, "points") |
|
571 |
end |
|
572 |
end |
|
573 |
||
574 |
function checkAwards() |
|
575 |
if jokeAwardNavy ~= nil then |
|
576 |
if isSinglePlayer then |
|
577 |
SendStat(siCustomAchievement, string.format(loc("The Navy greets %s for managing to get in a distance of %d away from the mainland!"), jokeAwardNavy.hogName, jokeAwardNavy.distance)) |
|
578 |
else |
|
579 |
SendStat(siCustomAchievement, string.format(loc("Greetings from the Navy, %s (%s), for being a distance of %d away from the mainland!"), jokeAwardNavy.hogName, jokeAwardNavy.teamName, jokeAwardNavy.distance)) |
|
580 |
end |
|
581 |
end |
|
582 |
if jokeAwardSpeed ~= nil then |
|
583 |
if isSinglePlayer then |
|
584 |
SendStat(siCustomAchievement, string.format(loc("Your hedgehog was panicly afraid of the water and decided to go in a safe distance of %d from it."), jokeAwardSpeed.distance)) |
|
585 |
else |
|
586 |
SendStat(siCustomAchievement, string.format(loc("%s (%s) was panicly afraid of the water and decided to get in a safe distance of %d from it."), jokeAwardSpeed.hogName, jokeAwardSpeed.teamName, jokeAwardSpeed.distance)) |
|
587 |
end |
|
588 |
end |
|
589 |
if jokeAwardDamage ~= nil then |
|
590 |
if isSinglePlayer then |
|
591 |
SendStat(siCustomAchievement, string.format(loc("Ouch! That must have hurt. You mutilated your poor hedgehog hog with %d damage."), jokeAwardDamage.damage)) |
|
592 |
else |
|
593 |
SendStat(siCustomAchievement, string.format(loc("Ouch! That must have hurt. %s (%s) hit the ground with %d damage points."), jokeAwardDamage.hogName, jokeAwardDamage.teamName, jokeAwardDamage.damage)) |
|
594 |
end |
|
595 |
end |
|
596 |
end |
|
597 |
||
598 |
function getActualHeight(height) |
|
599 |
return 32640-height |
|
600 |
end |