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