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