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