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