28 local jokeAwardNavy = nil |
28 local jokeAwardNavy = nil |
29 local jokeAwardSpeed = nil |
29 local jokeAwardSpeed = nil |
30 local jokeAwardDamage = nil |
30 local jokeAwardDamage = nil |
31 local recordBroken = false |
31 local recordBroken = false |
32 local ready = false |
32 local ready = false |
|
33 -- TODO. Fix use of dummy team for scaling the graph. |
33 local showWaterStats = false -- uses the AI team to draw water height. |
34 local showWaterStats = false -- uses the AI team to draw water height. |
|
35 local scaleGraph = false |
34 local dummyHog = nil |
36 local dummyHog = nil |
35 local dummySkip = 0 |
37 local dummySkip = 0 |
36 |
38 |
37 function onGameInit() |
39 function onGameInit() |
38 -- Ensure people get same map for same theme |
40 -- Ensure people get same map for same theme |
39 TurnTime = 999999999 |
41 TurnTime = 999999999 |
40 CaseFreq = 0 |
42 CaseFreq = 0 |
41 Explosives = 0 |
43 Explosives = 0 |
42 MineDudPercent = 0 |
44 MineDudPercent = 0 |
|
45 EnableGameFlags(gfOneClanMode) |
43 DisableGameFlags(gfBottomBorder+gfBorder) |
46 DisableGameFlags(gfBottomBorder+gfBorder) |
44 --This reduced startup time by only about 15% and looked ugly |
47 --This reduced startup time by only about 15% and looked ugly |
45 --EnableGameFlags(gfDisableLandObjects) |
48 --EnableGameFlags(gfDisableLandObjects) |
46 -- force seed instead. Some themes will still be easier, but at least you won't luck out on the same theme |
49 -- force seed instead. Some themes will still be easier, but at least you won't luck out on the same theme |
47 Seed = ClimbHome |
50 Seed = ClimbHome |
48 AddTeam(loc("Water Gods"), 0x0000AC, "Simple", "Island", "Default") |
51 if showWaterStats then |
49 dummyHog = AddHog("Poseidon", 0, 1, "NoHat") |
52 AddTeam(" ", 0x545C9D, "Simple", "Island", "Default") |
50 SendStat(siClanHealth, tostring(32640), loc("Water Gods")) |
53 elseif scaleGraph then |
51 SendStat(siClanHealth, tostring(32640), loc("Water Gods")) |
54 AddTeam(" ", 0x050505, "Simple", "Island", "Default") |
52 --HideHog(dummyHog) |
55 end |
|
56 if showWaterStats or scaleGraph then |
|
57 dummyHog = AddHog(" ", 0, 1, "NoHat") |
|
58 HH[dummyHog] = nil |
|
59 totalHedgehogs = totalHedgehogs - 1 |
|
60 if not showWaterStates then |
|
61 SendStat(siClanHealth, tostring(32640), " ") |
|
62 end |
|
63 SendStat(siClanHealth, tostring(32640), " ") |
|
64 end |
53 end |
65 end |
54 |
66 |
55 function onGearAdd(gear) |
67 function onGearAdd(gear) |
56 if GetGearType(gear) == gtHedgehog then |
68 if GetGearType(gear) == gtHedgehog then |
57 HH[gear] = 1 |
69 HH[gear] = 1 |
69 HH[gear] = nil |
81 HH[gear] = nil |
70 end |
82 end |
71 end |
83 end |
72 |
84 |
73 function onGameStart() |
85 function onGameStart() |
|
86 if showWaterStats or scaleGraph then |
|
87 DeleteGear(dummyHog) |
|
88 end |
74 --SetClanColor(ClansCount-1, 0x0000ffff) appears to be broken |
89 --SetClanColor(ClansCount-1, 0x0000ffff) appears to be broken |
75 SendHealthStatsOff() |
90 SendHealthStatsOff() |
76 ShowMission(loc("Climb Home"), |
91 ShowMission(loc("Climb Home"), |
77 loc("Rope to safety"), |
92 loc("Rope to safety"), |
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."), |
93 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."), |
79 -amRope, 0) |
94 -amRope, 0) |
80 local x = 1818 |
95 local x = 1818 |
81 for h,i in pairs(HH) do |
96 for h,i in pairs(HH) do |
82 -- SetGearPosition(h,x,32549) |
97 if h ~= nil then |
83 SetGearPosition(h,x,108) |
98 -- SetGearPosition(h,x,32549) |
84 SetHealth(h,1) |
99 SetGearPosition(h,x,108) |
85 if x < 1978 then x = x+32 else x = 1818 end |
100 SetHealth(h,1) |
86 if GetEffect(h,heInvulnerable) == 0 then |
101 if x < 1978 then x = x+32 else x = 1818 end |
87 SetEffect(h,heInvulnerable,1) |
102 if GetEffect(h,heInvulnerable) == 0 then |
88 else |
103 SetEffect(h,heInvulnerable,1) |
89 HogsAreInvulnerable = true |
104 else |
90 end |
105 HogsAreInvulnerable = true |
91 SetState(h,bor(GetState(h),gstInvisible)) |
106 end |
|
107 SetState(h,bor(GetState(h),gstInvisible)) |
|
108 end |
92 end |
109 end |
93 -- 1925,263 - Mr. Mine position |
110 -- 1925,263 - Mr. Mine position |
94 MrMine = AddGear(1925,263,gtMine,0,0,0,0) |
111 MrMine = AddGear(1925,263,gtMine,0,0,0,0) |
95 end |
112 end |
96 |
113 |
112 recordBroken = false |
129 recordBroken = false |
113 if CurrentHedgehog ~= nil then |
130 if CurrentHedgehog ~= nil then |
114 if CurrentHedgehog ~= dummyHog then |
131 if CurrentHedgehog ~= dummyHog then |
115 SetGearPosition(CurrentHedgehog, 1951,32640) |
132 SetGearPosition(CurrentHedgehog, 1951,32640) |
116 if not HogsAreInvulnerable then SetEffect(CurrentHedgehog,heInvulnerable,0) end |
133 if not HogsAreInvulnerable then SetEffect(CurrentHedgehog,heInvulnerable,0) end |
117 AddVisualGear(19531,32640,vgtExplosion,0,false) |
134 AddVisualGear(1951,32640,vgtExplosion,0,false) |
118 SetState(CurrentHedgehog,band(GetState(CurrentHedgehog),bnot(gstInvisible))) |
135 SetState(CurrentHedgehog,band(GetState(CurrentHedgehog),bnot(gstInvisible))) |
119 SetWeapon(amRope) |
136 SetWeapon(amRope) |
120 ready = true |
137 ready = true |
121 else |
138 else |
122 dummySkip = GameTime+1 |
139 dummySkip = GameTime+1 |
289 distance = distanceFromWater |
306 distance = distanceFromWater |
290 } |
307 } |
291 end |
308 end |
292 end |
309 end |
293 |
310 |
294 if GameTime % 500 == 0 then |
311 -- this block was moved out of the % 500 below because it was not triggering fast enough to give correct stats for all teams. |
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 |
312 if isSinglePlayer then |
303 if distanceFromWater < 0 and not YouLost and not YouWon then |
313 if distanceFromWater < 0 and not YouLost and not YouWon then |
304 makeSinglePlayerLoserStats() |
314 makeSinglePlayerLoserStats() |
305 YouLost = true |
315 YouLost = true |
306 end |
316 end |
319 SendStat(siCustomAchievement, string.format(loc("%s reached home in %.3f seconds. Congratulations!"), loc(GetHogName(CurrentHedgehog)), finishTime)) |
329 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))) |
330 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")) |
331 SendStat(siPointType, loc("seconds")) |
322 SendStat(siPlayerKills, tostring(roundedFinishTime), loc(GetHogTeamName(CurrentHedgehog))) |
332 SendStat(siPlayerKills, tostring(roundedFinishTime), loc(GetHogTeamName(CurrentHedgehog))) |
323 |
333 |
324 if not showWaterStats == true then |
|
325 SendStat(siClanHealth, tostring(32640), loc("Water Gods")) |
|
326 end |
|
327 EndGame() |
334 EndGame() |
328 YouWon = true |
335 YouWon = true |
329 end |
336 end |
330 elseif distanceFromWater < 0 and not YouLost then |
337 elseif distanceFromWater < 0 and not YouLost then |
331 makeMultiPlayerLoserStat(CurrentHedgehog) |
338 makeMultiPlayerLoserStat(CurrentHedgehog) |
332 deadHedgehogs = deadHedgehogs + 1 |
339 deadHedgehogs = deadHedgehogs + 1 |
333 YouLost = true |
340 YouLost = true |
334 if deadHedgehogs >= totalHedgehogs-1 then |
341 if deadHedgehogs >= totalHedgehogs then |
335 makeFinalMultiPlayerStats() |
342 makeFinalMultiPlayerStats() |
336 EndGame() |
343 EndGame() |
337 end |
344 end |
338 end |
345 end |
|
346 |
|
347 if GameTime % 500 == 0 then |
|
348 --if isSinglePlayer and MaxHeight < 32000 and WaterRise == nil then |
|
349 -- WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0) |
|
350 --end |
|
351 if showWaterStats == true then |
|
352 SendStat(siClanHealth, tostring(getActualHeight(WaterLine)), " ") |
|
353 end |
|
354 SendStat(siClanHealth, tostring(getActualHeight(y)), GetHogTeamName(CurrentHedgehog)) |
339 |
355 |
340 -- play taunts |
356 -- play taunts |
341 if not YouWon and not YouLost then |
357 if not YouWon and not YouLost then |
342 local nooDistance = 500 |
358 local nooDistance = 500 |
343 if ((x < -nooDistance and vx < 0) or (x > LAND_WIDTH+nooDistance and vx > 0)) then |
359 if ((x < -nooDistance and vx < 0) or (x > LAND_WIDTH+nooDistance and vx > 0)) then |
465 |
481 |
466 if isSinglePlayer then |
482 if isSinglePlayer then |
467 makeSinglePlayerLoserStats() |
483 makeSinglePlayerLoserStats() |
468 else |
484 else |
469 deadHedgehogs = deadHedgehogs + 1 |
485 deadHedgehogs = deadHedgehogs + 1 |
470 if deadHedgehogs >= totalHedgehogs-1 then |
486 if deadHedgehogs >= totalHedgehogs then |
471 makeFinalMultiPlayerStats() |
487 makeFinalMultiPlayerStats() |
472 EndGame() |
488 EndGame() |
473 end |
489 end |
474 makeMultiPlayerLoserStat(gear) |
490 makeMultiPlayerLoserStat(gear) |
475 end |
491 end |
525 local actualHeight = getActualHeight(MaxHeight) |
541 local actualHeight = getActualHeight(MaxHeight) |
526 if teamBests[teamName] == nil then teamBests[teamName] = actualHeight end |
542 if teamBests[teamName] == nil then teamBests[teamName] = actualHeight end |
527 if teamBests[teamName] < actualHeight then teamBests[teamName] = actualHeight end |
543 if teamBests[teamName] < actualHeight then teamBests[teamName] = actualHeight end |
528 if teamScoreStats[teamName] == nil then teamScoreStats[teamName] = {} end |
544 if teamScoreStats[teamName] == nil then teamScoreStats[teamName] = {} end |
529 table.insert(teamScoreStats[teamName], actualHeight) |
545 table.insert(teamScoreStats[teamName], actualHeight) |
530 SendStat(siClanHealth, tostring(teamBests[teamName]), teamName) |
546 --SendStat(siClanHealth, tostring(teamBests[teamName]), teamName) |
531 end |
547 end |
532 |
548 |
533 function makeFinalMultiPlayerStats() |
549 function makeFinalMultiPlayerStats() |
534 local ranking = {} |
550 local ranking = {} |
535 for k,v in pairs(teamBests) do |
551 for k,v in pairs(teamBests) do |