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