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