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