author | unC0Rr |
Tue, 29 Mar 2016 11:16:54 +0300 | |
changeset 11627 | 221691bede23 |
parent 11623 | 515d2d38ab8b |
child 11635 | 2a53e219bc1a |
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 |
|
11613 | 64 |
if params["delayheight"] ~= nil then |
10811 | 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() |
|
11623
515d2d38ab8b
Declare achievements alongwith EndGame call, since it would skip SendStats
unc0rr
parents:
11615
diff
changeset
|
393 |
onAchievementsDeclaration() |
10581 | 394 |
YouWon = true |
395 |
end |
|
396 |
elseif distanceFromWater < 0 and not YouLost then |
|
397 |
makeMultiPlayerLoserStat(CurrentHedgehog) |
|
398 |
deadHedgehogs = deadHedgehogs + 1 |
|
399 |
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
|
400 |
if deadHedgehogs >= totalHedgehogs then |
10581 | 401 |
makeFinalMultiPlayerStats() |
402 |
EndGame() |
|
11623
515d2d38ab8b
Declare achievements alongwith EndGame call, since it would skip SendStats
unc0rr
parents:
11615
diff
changeset
|
403 |
onAchievementsDeclaration() |
10581 | 404 |
end |
405 |
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
|
406 |
|
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 |
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
|
408 |
--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
|
409 |
-- 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
|
410 |
--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
|
411 |
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
|
412 |
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
|
413 |
end |
10632
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
414 |
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
|
415 |
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
|
416 |
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
|
417 |
else |
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
418 |
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
|
419 |
end |
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
420 |
end |
10581 | 421 |
|
422 |
-- play taunts |
|
423 |
if not YouWon and not YouLost then |
|
424 |
local nooDistance = 500 |
|
425 |
if ((x < -nooDistance and vx < 0) or (x > LAND_WIDTH+nooDistance and vx > 0)) then |
|
426 |
if (tauntNoo == false and distanceFromWater > 80) then |
|
427 |
PlaySound(sndNooo, CurrentHedgehog) |
|
428 |
tauntNoo = true |
|
429 |
end |
|
430 |
end |
|
431 |
end |
|
432 |
||
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
|
433 |
if addCake and CakeTries < 10 and y < 32600 and y > 3000 and Cake == nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then |
10581 | 434 |
-- doing this just after the start the first time to take advantage of randomness sources |
435 |
-- Pick a clear y to start with |
|
436 |
if y > 31000 then cy = 24585 elseif |
|
437 |
y > 28000 then cy = 21500 elseif |
|
438 |
y > 24000 then cy = 19000 elseif |
|
439 |
y > 21500 then cy = 16000 elseif |
|
440 |
y > 19000 then cy = 12265 elseif |
|
441 |
y > 16000 then cy = 8800 elseif |
|
442 |
y > 12000 then cy = 5700 else |
|
443 |
cy = 400 end |
|
444 |
Cake = AddGear(GetRandom(2048), cy, gtCake, 0, 0, 0, 0) |
|
445 |
SetHealth(Cake,999999) |
|
446 |
CakeTries = CakeTries + 1 |
|
447 |
end |
|
448 |
||
449 |
if (y > 286) or (y < 286 and MaxHeight > 286) then |
|
450 |
if y < MaxHeight and y > 286 then MaxHeight = y end |
|
451 |
if y < 286 then MaxHeight = 286 end |
|
452 |
if MaxHeight < hTagHeight then |
|
453 |
hTagHeight = MaxHeight |
|
454 |
if hTag ~= nil then DeleteVisualGear(hTag) end |
|
455 |
hTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
456 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag) |
|
457 |
-- snagged from space invasion |
|
458 |
SetVisualGearValues ( |
|
459 |
hTag, --id |
|
460 |
-(ScreenWidth/2) + 40, --xoffset |
|
461 |
ScreenHeight - 60, --yoffset |
|
462 |
0, --dx |
|
463 |
0, --dy |
|
464 |
1.1, --zoom |
|
465 |
1, --~= 0 means align to screen |
|
466 |
g7, --frameticks |
|
467 |
-- 116px off bottom for lowest rock, 286 or so off top for position of chair |
|
468 |
-- 32650 is "0" |
|
469 |
32640-hTagHeight, --value |
|
470 |
99999999999,--timer |
|
471 |
GetClanColor(GetHogClan(CurrentHedgehog)) |
|
472 |
) |
|
473 |
end |
|
474 |
||
475 |
if MaxHeight < RecordHeight then |
|
476 |
RecordHeight = MaxHeight |
|
477 |
local oldName = RecordHeightHogName |
|
478 |
RecordHeightHogName = GetHogName(CurrentHedgehog) |
|
479 |
if oldName == nil then recordBroken = true end |
|
480 |
if not isSinglePlayer and RecordHeight > 1500 and not recordBroken then |
|
481 |
recordBroken = true |
|
482 |
AddCaption(string.format(loc("%s has passed the best height of %s!"), RecordHeightHogName, oldName)) |
|
483 |
end |
|
484 |
if not isSinglePlayer then |
|
485 |
if rTag ~= nil then DeleteVisualGear(rTag) end |
|
486 |
rTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
487 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag) |
|
488 |
-- snagged from space invasion |
|
489 |
SetVisualGearValues ( |
|
490 |
rTag, --id |
|
491 |
-(ScreenWidth/2) + 100, --xoffset |
|
492 |
ScreenHeight - 60, --yoffset |
|
493 |
0, --dx |
|
494 |
0, --dy |
|
495 |
1.1, --zoom |
|
496 |
1, --~= 0 means align to screen |
|
497 |
g7, --frameticks |
|
498 |
-- 116px off bottom for lowest rock, 286 or so off top for position of chair |
|
499 |
-- 32650 is "0" |
|
500 |
getActualHeight(RecordHeight), --value |
|
501 |
99999999999,--timer |
|
502 |
GetClanColor(GetHogClan(CurrentHedgehog)) |
|
503 |
) |
|
504 |
end |
|
505 |
end |
|
506 |
end |
|
507 |
if MaxHeight > 286 then |
|
508 |
if tTag ~= nil then DeleteVisualGear(tTag) end |
|
509 |
tTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
510 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tTag) |
|
10413 | 511 |
-- snagged from space invasion |
512 |
SetVisualGearValues ( |
|
513 |
tTag, --id |
|
514 |
-(ScreenWidth/2) + 40, --xoffset |
|
515 |
ScreenHeight - 100, --yoffset |
|
516 |
0, --dx |
|
517 |
0, --dy |
|
518 |
1.1, --zoom |
|
519 |
1, --~= 0 means align to screen |
|
520 |
g7, --frameticks |
|
521 |
(GameTime-startTime)/1000, --value |
|
522 |
99999999999,--timer |
|
523 |
0xffffffff |
|
524 |
) |
|
10581 | 525 |
end |
10413 | 526 |
end |
527 |
end |
|
528 |
end |
|
10581 | 529 |
|
530 |
function onGearDamage(gear, damage) |
|
531 |
if GetGearType(gear) == gtHedgehog and not YouLost and not YouWon then |
|
532 |
-- Joke award for largest damage to hog |
|
533 |
local qualifyDamage = 50 |
|
534 |
if (damage >= qualifyDamage) then |
|
535 |
local awarded = false |
|
536 |
if jokeAwardDamage == nil or damage > jokeAwardDamage.damage then |
|
537 |
awarded = true |
|
538 |
end |
|
539 |
if awarded == true then |
|
540 |
jokeAwardDamage = { |
|
541 |
hogName = GetHogName(CurrentHedgehog), |
|
542 |
teamName = GetHogTeamName(CurrentHedgehog), |
|
543 |
damage = damage |
|
544 |
} |
|
545 |
end |
|
546 |
end |
|
547 |
||
548 |
if isSinglePlayer then |
|
549 |
makeSinglePlayerLoserStats() |
|
550 |
else |
|
551 |
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
|
552 |
if deadHedgehogs >= totalHedgehogs then |
10581 | 553 |
makeFinalMultiPlayerStats() |
554 |
EndGame() |
|
11623
515d2d38ab8b
Declare achievements alongwith EndGame call, since it would skip SendStats
unc0rr
parents:
11615
diff
changeset
|
555 |
onAchievementsDeclaration() |
10581 | 556 |
end |
557 |
makeMultiPlayerLoserStat(gear) |
|
558 |
end |
|
559 |
YouLost = true |
|
560 |
end |
|
561 |
end |
|
562 |
||
563 |
function makeLoserComment() |
|
564 |
local m |
|
565 |
if isSinglePlayer then m = 10 else m = 6 end |
|
566 |
local r = math.random(1,m) |
|
567 |
if r == 1 then text = loc("%s never got the ninja diploma.") |
|
568 |
elseif r == 2 then text = loc("You have to move upwards, not downwards, %s!") |
|
569 |
elseif r == 3 then text = loc("%s never wanted to reach for the sky in the first place.") |
|
570 |
elseif r == 4 then text = loc("%s should try the rope training mission first.") |
|
571 |
elseif r == 5 then text = loc("%s skipped ninja classes.") |
|
572 |
elseif r == 6 then text = loc("%s doesn’t really know how to handle a rope properly.") |
|
573 |
elseif r == 7 then text = loc("Better luck next time!") |
|
574 |
elseif r == 8 then text = loc("It was all just bad luck!") |
|
575 |
elseif r == 9 then text = loc("Well, that escalated quickly!") |
|
576 |
elseif r == 10 then text = loc("What? Is it over already?") end |
|
577 |
return text |
|
578 |
end |
|
579 |
||
580 |
function makeSinglePlayerLoserStats() |
|
581 |
local actualHeight = getActualHeight(RecordHeight) |
|
582 |
SendStat(siGameResult, loc("You lose!")) |
|
583 |
SendStat(siGraphTitle, loc("Your height over time")) |
|
584 |
local text |
|
585 |
if actualHeight > 30000 then text = loc("%s was damn close to home.") |
|
586 |
elseif actualHeight > 28000 then text = loc("%s was close to home.") |
|
587 |
elseif actualHeight > 24265 then text = loc("%s was good, but not good enough.") |
|
588 |
elseif actualHeight > 16177 then text = loc("%s managed to pass half of the distance towards home.") |
|
589 |
elseif actualHeight > 8088 then text = loc("%s went over a quarter of the way towards home.") |
|
590 |
elseif actualHeight > 5100 then text = loc("%s still had a long way to go.") |
|
591 |
elseif actualHeight > 2000 then text = loc("%s made it past the hogosphere.") |
|
592 |
elseif actualHeight > 1500 then text = loc("%s barely made it past the hogosphere.") |
|
593 |
else |
|
594 |
text = makeLoserComment() |
|
595 |
end |
|
596 |
if actualHeight > 1500 then |
|
597 |
SendStat(siCustomAchievement, string.format(text, RecordHeightHogName, actualHeight)) |
|
598 |
else |
|
599 |
SendStat(siCustomAchievement, string.format(text, RecordHeightHogName)) |
|
600 |
end |
|
11067
c632b47b8ff0
Trying to get these scripts to behave properly, still WIP though.
nemo
parents:
10824
diff
changeset
|
601 |
SendStat(siPointType, loc("points")) |
10581 | 602 |
SendStat(siPlayerKills, actualHeight, loc(GetHogTeamName(CurrentHedgehog))) |
603 |
EndGame() |
|
11623
515d2d38ab8b
Declare achievements alongwith EndGame call, since it would skip SendStats
unc0rr
parents:
11615
diff
changeset
|
604 |
onAchievementsDeclaration() |
10581 | 605 |
end |
606 |
||
607 |
function makeMultiPlayerLoserStat(gear) |
|
608 |
local teamName = GetHogTeamName(gear) |
|
609 |
local actualHeight = getActualHeight(MaxHeight) |
|
610 |
if teamBests[teamName] == nil then teamBests[teamName] = actualHeight end |
|
611 |
if teamBests[teamName] < actualHeight then teamBests[teamName] = actualHeight end |
|
612 |
if teamScoreStats[teamName] == nil then teamScoreStats[teamName] = {} end |
|
613 |
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
|
614 |
--SendStat(siClanHealth, tostring(teamBests[teamName]), teamName) |
10581 | 615 |
end |
616 |
||
617 |
function makeFinalMultiPlayerStats() |
|
618 |
local ranking = {} |
|
619 |
for k,v in pairs(teamBests) do |
|
620 |
table.insert(ranking, {name=k, score=v}) |
|
621 |
end |
|
622 |
local comp = function(table1, table2) |
|
623 |
if table1.score < table2.score then |
|
624 |
return true |
|
625 |
else |
|
626 |
return false |
|
627 |
end |
|
628 |
end |
|
629 |
table.sort(ranking, comp) |
|
630 |
||
631 |
local winner = ranking[#ranking] |
|
632 |
local loser = ranking[1] |
|
633 |
SendStat(siGameResult, string.format(loc("%s wins!"), winner.name)) |
|
634 |
SendStat(siGraphTitle, string.format(loc("Team’s best heights per round"))) |
|
635 |
||
636 |
if winner.score < 1500 then |
|
11067
c632b47b8ff0
Trying to get these scripts to behave properly, still WIP though.
nemo
parents:
10824
diff
changeset
|
637 |
SendStat(siCustomAchievement, string.format(loc("This round’s award for ultimate disappointment goes to: Everyone!"))) |
10581 | 638 |
else |
639 |
if winner.score > 30000 then text = loc("%s (%s) reached for the sky and beyond with a height of %d!") |
|
640 |
elseif winner.score > 24750 then text = loc("%s (%s) was certainly not afraid of heights: Peak height of %d!") |
|
641 |
elseif winner.score > 16500 then text = loc("%s (%s) does not have to feel ashamed for their best height of %d.") |
|
642 |
elseif winner.score > 8250 then text = loc("%s (%s) reached a decent peak height of %d.") |
|
643 |
else text = loc("%s (%s) reached a peak height of %d.") end |
|
644 |
SendStat(siCustomAchievement, string.format(text, RecordHeightHogName, winner.name, winner.score)) |
|
645 |
||
646 |
if loser.score < 1500 then |
|
647 |
text = makeLoserComment() |
|
648 |
SendStat(siCustomAchievement, string.format(text, loser.name)) |
|
649 |
end |
|
650 |
end |
|
651 |
checkAwards() |
|
652 |
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
|
653 |
SendStat(siPointType, loc("points")) |
10581 | 654 |
SendStat(siPlayerKills, tostring(ranking[i].score), ranking[i].name) |
655 |
end |
|
656 |
end |
|
657 |
||
658 |
function checkAwards() |
|
659 |
if jokeAwardNavy ~= nil then |
|
660 |
if isSinglePlayer then |
|
661 |
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)) |
|
662 |
else |
|
663 |
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)) |
|
664 |
end |
|
665 |
end |
|
666 |
if jokeAwardSpeed ~= nil then |
|
667 |
if isSinglePlayer then |
|
668 |
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)) |
|
669 |
else |
|
670 |
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)) |
|
671 |
end |
|
672 |
end |
|
673 |
if jokeAwardDamage ~= nil then |
|
674 |
if isSinglePlayer then |
|
675 |
SendStat(siCustomAchievement, string.format(loc("Ouch! That must have hurt. You mutilated your poor hedgehog hog with %d damage."), jokeAwardDamage.damage)) |
|
676 |
else |
|
677 |
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)) |
|
678 |
end |
|
679 |
end |
|
680 |
end |
|
681 |
||
682 |
function getActualHeight(height) |
|
683 |
return 32640-height |
|
684 |
end |
|
11615 | 685 |
|
686 |
function onAchievementsDeclaration() |
|
687 |
for teamname, score in pairs(teamBests) do |
|
11627 | 688 |
DeclareAchievement("height reached", teamname, "ClimbHome", -score) |
11615 | 689 |
end |
690 |
end |