author | Wuzzy <almikes@aol.com> |
Thu, 05 Oct 2017 18:26:08 +0200 | |
changeset 12655 | 913d25669131 |
parent 12654 | 26b0d3b76dea |
child 12753 | 327f71313e04 |
permissions | -rw-r--r-- |
10413 | 1 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
2 |
HedgewarsScriptLoad("/Scripts/Utils.lua") |
|
10810
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
3 |
HedgewarsScriptLoad("/Scripts/Params.lua") |
10413 | 4 |
|
5 |
local hTag = nil |
|
6 |
local hTagHeight = 33000 |
|
7 |
local tTag = nil |
|
8 |
local rTag = nil |
|
9 |
local startTime = 0 |
|
10 |
local MaxHeight = 32640 |
|
11 |
local RecordHeight = 33000 |
|
10581 | 12 |
local RecordHeightHogName = nil |
10413 | 13 |
local Fire = {} |
14 |
--local BoomFire = nil |
|
15 |
local HH = {} |
|
10581 | 16 |
local totalHedgehogs = 0 |
17 |
local deadHedgehogs = 0 |
|
10632
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
18 |
local currTeam = '' |
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
19 |
local teams = {} |
10581 | 20 |
local teamScoreStats = {} |
21 |
local teamBests = {} |
|
11635 | 22 |
local teamTimes = {} |
10413 | 23 |
local MrMine -- in honour of sparkle's first arrival in the cabin |
24 |
local YouWon = false |
|
10581 | 25 |
local YouLost = false |
10580
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
26 |
local HogsAreInvulnerable = false |
10413 | 27 |
local WaterRise = nil |
28 |
local Cake = nil |
|
29 |
local CakeTries = 0 |
|
10810
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
30 |
local addCake = true |
10413 | 31 |
local Stars = {} |
10581 | 32 |
local tauntNoo = false |
33 |
local jokeAwardNavy = nil |
|
34 |
local jokeAwardSpeed = nil |
|
35 |
local jokeAwardDamage = nil |
|
36 |
local recordBroken = false |
|
37 |
local ready = false |
|
38 |
local dummyHog = nil |
|
10592 | 39 |
local dummySkip = 0 |
10810
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
40 |
local baseWaterSpeed = 2 |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
41 |
local waterSpeed = 0 |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
42 |
local waterAccel = 0 |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
43 |
local delayHeight = 32000 |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
44 |
local delayTime = 0 |
10824 | 45 |
local airMineX = {} |
46 |
local airMineY = {} |
|
47 |
local airMine = {} |
|
48 |
local init = true |
|
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
49 |
local multiplayerVictoryDelay = -1 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
50 |
local multiplayerWinningHogs = {} |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
51 |
local multiplayerWins = 0 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
52 |
|
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
53 |
-- Placement positions of winning hogs |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
54 |
local victoryPosses = { } |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
55 |
do |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
56 |
local m = 0 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
57 |
for y=108, 39, -32 do |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
58 |
for x=1820+m, 1972-m, 22 do |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
59 |
table.insert(victoryPosses, {x=x, y=y}) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
60 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
61 |
m = m + 32 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
62 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
63 |
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
|
64 |
|
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
|
65 |
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
|
66 |
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
|
67 |
|
10811 | 68 |
if params["speed"] ~= nil then |
69 |
baseWaterSpeed = params["speed"] |
|
70 |
end |
|
10812 | 71 |
if params["accel"] ~= nil then |
10811 | 72 |
waterAccel = params["accel"] |
73 |
if waterAccel ~= 0 then waterAccel = div(32640000,waterAccel) end |
|
74 |
end |
|
75 |
if params["delaytime"] ~= nil then |
|
76 |
delayTime = params["delaytime"] |
|
77 |
end |
|
11613 | 78 |
if params["delayheight"] ~= nil then |
10811 | 79 |
delayHeight = 32768-params["delayheight"] |
80 |
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
|
81 |
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
|
82 |
end |
10413 | 83 |
|
84 |
function onGameInit() |
|
85 |
-- Ensure people get same map for same theme |
|
86 |
TurnTime = 999999999 |
|
87 |
CaseFreq = 0 |
|
88 |
Explosives = 0 |
|
89 |
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
|
90 |
EnableGameFlags(gfOneClanMode) |
10413 | 91 |
DisableGameFlags(gfBottomBorder+gfBorder) |
92 |
--This reduced startup time by only about 15% and looked ugly |
|
93 |
--EnableGameFlags(gfDisableLandObjects) |
|
94 |
-- force seed instead. Some themes will still be easier, but at least you won't luck out on the same theme |
|
95 |
Seed = ClimbHome |
|
12079
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12077
diff
changeset
|
96 |
-- Disable Sudden Death |
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12077
diff
changeset
|
97 |
WaterRise = 0 |
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12077
diff
changeset
|
98 |
HealthDecrease = 0 |
10413 | 99 |
end |
100 |
||
101 |
function onGearAdd(gear) |
|
102 |
if GetGearType(gear) == gtHedgehog then |
|
103 |
HH[gear] = 1 |
|
10581 | 104 |
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
|
105 |
teams[GetHogTeamName(gear)] = 1 |
10824 | 106 |
elseif init and GetGearType(gear) == gtAirMine then |
107 |
airMine[gear] = 1 |
|
10413 | 108 |
end |
109 |
end |
|
110 |
||
111 |
function onGearDelete(gear) |
|
112 |
if gear == MrMine then |
|
12392
78ad1119eb6c
Make the Mr Mine message in ClimbHome translatable
Wuzzy <almikes@aol.com>
parents:
12188
diff
changeset
|
113 |
AddCaption(loc("Once you set off the proximity trigger, Mr. Mine is not your friend"), 0xFFFFFFFF, capgrpMessage) |
10413 | 114 |
MrMine = nil |
115 |
elseif gear == Cake then |
|
116 |
Cake = nil |
|
10581 | 117 |
elseif GetGearType(gear) == gtHedgehog then |
11067
c632b47b8ff0
Trying to get these scripts to behave properly, still WIP though.
nemo
parents:
10824
diff
changeset
|
118 |
onGameTick20() |
c632b47b8ff0
Trying to get these scripts to behave properly, still WIP though.
nemo
parents:
10824
diff
changeset
|
119 |
onGearDamage(gear, 0) |
10581 | 120 |
HH[gear] = nil |
10413 | 121 |
end |
122 |
end |
|
123 |
||
124 |
function onGameStart() |
|
10581 | 125 |
--SetClanColor(ClansCount-1, 0x0000ffff) appears to be broken |
126 |
SendHealthStatsOff() |
|
10413 | 127 |
ShowMission(loc("Climb Home"), |
12077
ce3860c82c8b
Rewrite 2nd line of mission panel of most missions for consistency
Wuzzy <almikes@aol.com>
parents:
11889
diff
changeset
|
128 |
loc("Challenge"), |
10581 | 129 |
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 | 130 |
-amRope, 0) |
131 |
local x = 1818 |
|
132 |
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
|
133 |
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
|
134 |
-- 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
|
135 |
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
|
136 |
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
|
137 |
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
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
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
|
142 |
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
|
143 |
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
|
144 |
end |
10413 | 145 |
end |
146 |
-- 1925,263 - Mr. Mine position |
|
147 |
MrMine = AddGear(1925,263,gtMine,0,0,0,0) |
|
148 |
end |
|
10581 | 149 |
|
10413 | 150 |
function onAmmoStoreInit() |
151 |
SetAmmo(amRope, 9, 0, 0, 0) |
|
152 |
end |
|
153 |
||
154 |
function onNewTurn() |
|
10824 | 155 |
if init then |
156 |
init = false |
|
157 |
for a,i in pairs(airMine) do |
|
158 |
x,y = GetGearPosition(a) |
|
159 |
airMineX[a] = x |
|
160 |
airMineY[a] = y |
|
161 |
end |
|
162 |
else |
|
163 |
for a,i in pairs(airMine) do |
|
164 |
local x,y = GetGearPosition(a) |
|
165 |
if not x or airMineX[a] ~= x or airMineY[a] ~= y then |
|
166 |
DeleteGear(a) |
|
167 |
AddGear(airMineX[a],airMineY[a], gtAirMine, gsttmpFlag, 0, 0, 0) |
|
168 |
end |
|
169 |
end |
|
170 |
end |
|
171 |
||
10581 | 172 |
ready = false |
10413 | 173 |
startTime = GameTime |
174 |
--disable to preserve highest over multiple turns |
|
175 |
--will need to change water check too ofc |
|
176 |
MaxHeight = 32640 |
|
177 |
hTagHeight = 33000 |
|
178 |
SetWaterLine(32768) |
|
10581 | 179 |
YouWon = false |
180 |
YouLost = false |
|
181 |
tauntNoo = false |
|
182 |
recordBroken = false |
|
10632
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
183 |
currTeam = GetHogTeamName(CurrentHedgehog) |
10592 | 184 |
if CurrentHedgehog ~= nil then |
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
185 |
if CurrentHedgehog ~= dummyHog or multiplayerWinningHogs[CurrentHedgehog] == true then |
10592 | 186 |
SetGearPosition(CurrentHedgehog, 1951,32640) |
12654
26b0d3b76dea
ClimbHome: Make sure hog faces left on turn start
Wuzzy <almikes@aol.com>
parents:
12653
diff
changeset
|
187 |
HogTurnLeft(CurrentHedgehog, true) |
10592 | 188 |
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
|
189 |
AddVisualGear(1951,32640,vgtExplosion,0,false) |
10592 | 190 |
SetState(CurrentHedgehog,band(GetState(CurrentHedgehog),bnot(gstInvisible))) |
191 |
SetWeapon(amRope) |
|
192 |
ready = true |
|
193 |
else |
|
194 |
dummySkip = GameTime+1 |
|
195 |
end |
|
10413 | 196 |
end |
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
197 |
for hog, _ in pairs(multiplayerWinningHogs) do |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
198 |
SetEffect(hog, heInvulnerable, 1) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
199 |
end |
10413 | 200 |
for f,i in pairs(Fire) do |
201 |
DeleteGear(f) |
|
202 |
end |
|
203 |
for s,i in pairs(Stars) do |
|
204 |
DeleteVisualGear(s) |
|
205 |
Stars[s] = nil |
|
206 |
end |
|
207 |
||
10581 | 208 |
if CurrentHedgehog ~= dummyHog then |
209 |
for i = 0,12 do |
|
210 |
flame = AddGear(2000+i*2,308, gtFlame, gsttmpFlag, 0, 0, 0) |
|
211 |
SetTag(flame, 999999+i) |
|
212 |
Fire[flame]=1 |
|
213 |
end |
|
10413 | 214 |
end |
215 |
if Cake ~= nil then DeleteGear(Cake) end |
|
216 |
CakeTries = 0 |
|
217 |
end |
|
218 |
||
219 |
--function onGearDelete(gear) |
|
220 |
-- if gear == WaterRise and MaxHeight > 500 and CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then |
|
221 |
-- WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0) |
|
222 |
-- end |
|
223 |
--end |
|
224 |
||
225 |
function FireBoom(x,y,d) -- going to add for rockets too |
|
226 |
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
|
227 |
-- should approximate circle by removing corners |
10581 | 228 |
--if BoomFire == nil then BoomFire = {} end |
10413 | 229 |
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
|
230 |
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
|
231 |
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
|
232 |
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
|
233 |
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
|
234 |
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
|
235 |
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
|
236 |
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
|
237 |
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
|
238 |
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
|
239 |
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
|
240 |
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
|
241 |
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
|
242 |
flame = AddGear(x+fx, y+fy, gtFlame, gsttmpFlag, fdx, fdy, 0) |
10413 | 243 |
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
|
244 |
SetFlightTime(flame, 0) |
10413 | 245 |
Fire[flame]=1 |
246 |
-- BoomFire[flame]=1 |
|
247 |
end |
|
248 |
end |
|
249 |
||
250 |
||
251 |
function onGameTick20() |
|
10824 | 252 |
local x,y |
10581 | 253 |
if math.random(20) == 1 then AddVisualGear(2012,56,vgtSmoke,0,false) end |
10592 | 254 |
if CurrentHedgehog == dummyHog and dummySkip ~= 0 and dummySkip < GameTime then |
10585 | 255 |
ParseCommand("/skip") |
10592 | 256 |
dummySkip = 0 |
10585 | 257 |
end |
10581 | 258 |
|
10413 | 259 |
--if BoomFire ~= nil then |
260 |
-- for f,i in pairs(BoomFire) do |
|
261 |
-- if band(GetState(f),gstCollision~=0) then DeleteGear(f) end |
|
262 |
-- end |
|
263 |
-- BoomFire = nil |
|
264 |
--end |
|
265 |
||
266 |
for s,i in pairs(Stars) do |
|
267 |
g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(s) |
|
268 |
if g1 > WaterLine + 500 then |
|
269 |
DeleteVisualGear(s) |
|
270 |
Stars[s] = nil |
|
271 |
end |
|
272 |
--else wasn't really visible, pointless. |
|
273 |
-- g5 = g5+1 |
|
274 |
-- if g5 > 360 then g5 = 0 end |
|
275 |
-- SetVisualGearValues(s, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10) |
|
276 |
--end |
|
277 |
end |
|
278 |
||
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
279 |
-- This will be executed if a player reached home in multiplayer |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
280 |
if multiplayerVictoryDelay > 0 then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
281 |
multiplayerVictoryDelay = multiplayerVictoryDelay - 20 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
282 |
if multiplayerVictoryDelay <= 0 then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
283 |
-- If delay's over, the game will continue with the next hog |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
284 |
if CurrentHedgehog then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
285 |
|
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
286 |
multiplayerWinningHogs[CurrentHedgehog] = true |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
287 |
multiplayerWins = multiplayerWins + 1 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
288 |
|
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
289 |
local victoryX, victoryY |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
290 |
if multiplayerWins <= #victoryPosses then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
291 |
victoryX, victoryY = victoryPosses[multiplayerWins].x, victoryPosses[multiplayerWins].y |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
292 |
else |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
293 |
victoryX, victoryY = victoryPosses[#victoryPosses].x, victoryPosses[#victoryPosses].y |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
294 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
295 |
SetGearPosition(CurrentHedgehog, victoryX, victoryY) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
296 |
SetEffect(CurrentHedgehog, heInvulnerable, 1) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
297 |
SetHealth(CurrentHedgehog, 1) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
298 |
|
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
299 |
if (deadHedgehogs + multiplayerWins) >= totalHedgehogs then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
300 |
makeFinalMultiPlayerStats() |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
301 |
EndGame() |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
302 |
onAchievementsDeclaration() |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
303 |
else |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
304 |
EndTurn(true) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
305 |
SetInputMask(0xFFFFFFFF) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
306 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
307 |
return |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
308 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
309 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
310 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
311 |
|
10581 | 312 |
if CurrentHedgehog ~= nil then x,y = GetGearPosition(CurrentHedgehog) end |
10413 | 313 |
if Cake ~= nil and CurrentHedgehog ~= nil then |
314 |
local cx,cy = GetGearPosition(Cake) |
|
315 |
if y < cy-1500 then |
|
316 |
DeleteGear(Cake) |
|
317 |
Cake = nil |
|
318 |
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
|
319 |
|
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
|
320 |
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
|
321 |
FireBoom(cx,cy,200) -- todo animate |
10413 | 322 |
DeleteGear(Cake) |
323 |
Cake = nil |
|
324 |
end |
|
325 |
end |
|
326 |
||
327 |
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
|
328 |
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
|
329 |
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
|
330 |
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
|
331 |
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
|
332 |
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
|
333 |
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
|
334 |
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
|
335 |
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
|
336 |
end |
10413 | 337 |
if y > 0 and y < 30000 and MaxHeight > 286 and math.random(y) < 500 then |
338 |
local s = AddVisualGear(0, 0, vgtStraightShot, 0, true) |
|
339 |
local c = div(250000,y) |
|
340 |
if c > 255 then c = 255 end |
|
341 |
c = c * 0x10000 + 0xFF0000FF |
|
342 |
SetVisualGearValues(s, |
|
343 |
math.random(2048), -5000, 0, -1-(1/y*1000), |
|
344 |
math.random(360), |
|
345 |
0, |
|
346 |
999999999, -- frameticks |
|
12188
099e59894671
Fix CPU level sprites falling down in ClimbHome (instead of stars)
Wuzzy <almikes@aol.com>
parents:
12079
diff
changeset
|
347 |
sprStar, -- star |
10413 | 348 |
0, c) |
349 |
--, 0xFFCC00FF) -- could be fun to make colour shift as you rise... |
|
350 |
Stars[s] = 1 |
|
351 |
end |
|
352 |
end |
|
353 |
||
354 |
if CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) == 0 then |
|
355 |
for f,i in pairs(Fire) do -- takes too long to fall otherwise |
|
356 |
DeleteGear(f) |
|
357 |
end |
|
358 |
if Cake ~= nil then |
|
359 |
DeleteGear(Cake) |
|
360 |
Cake = nil |
|
361 |
end |
|
362 |
end |
|
363 |
||
10581 | 364 |
if CurrentHedgehog ~= nil and TurnTimeLeft > 0 then |
365 |
local vx, vy = GetGearVelocity(CurrentHedgehog) |
|
366 |
local distanceFromWater = WaterLine - y |
|
367 |
||
368 |
--[[ check joke awards ]] |
|
369 |
-- navy award: when distance from main map is over 1000 |
|
370 |
local navyDistance = 1250 |
|
371 |
if x < -navyDistance or x > LAND_WIDTH+navyDistance then |
|
372 |
local awarded = false |
|
373 |
local dist = 0 |
|
374 |
if jokeAwardNavy == nil then |
|
375 |
awarded = true |
|
376 |
else |
|
377 |
if x < 0 then |
|
378 |
dist = math.abs(x) |
|
379 |
else |
|
380 |
dist = x - LAND_WIDTH |
|
381 |
end |
|
382 |
if dist > jokeAwardNavy.distance then |
|
383 |
awarded = true |
|
384 |
end |
|
385 |
end |
|
386 |
if awarded == true then |
|
387 |
jokeAwardNavy = { |
|
388 |
hogName = GetHogName(CurrentHedgehog), |
|
389 |
teamName = GetHogTeamName(CurrentHedgehog), |
|
390 |
distance = dist |
|
391 |
} |
|
392 |
end |
|
393 |
end |
|
394 |
||
395 |
-- Speed award for largest distance from water |
|
396 |
if distanceFromWater > 3000 and WaterLine < 32000 then |
|
397 |
local awarded = false |
|
398 |
if jokeAwardSpeed == nil or distanceFromWater > jokeAwardSpeed.distance then |
|
399 |
awarded = true |
|
400 |
end |
|
401 |
if awarded == true then |
|
402 |
jokeAwardSpeed = { |
|
403 |
hogName = GetHogName(CurrentHedgehog), |
|
404 |
teamName = GetHogTeamName(CurrentHedgehog), |
|
405 |
distance = distanceFromWater |
|
406 |
} |
|
407 |
end |
|
10413 | 408 |
end |
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
409 |
local finishTime = (GameTime-startTime)/1000 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
410 |
local roundedFinishTime = math.ceil(math.floor(finishTime+0.5)) |
10581 | 411 |
if isSinglePlayer then |
412 |
if distanceFromWater < 0 and not YouLost and not YouWon then |
|
413 |
makeSinglePlayerLoserStats() |
|
414 |
YouLost = true |
|
415 |
end |
|
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
416 |
-- FIXME: Hog is also in winning box if it just walks into the chair from the left, touching it. Intentional? |
10581 | 417 |
if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then |
418 |
AddCaption(loc("Victory!")) |
|
419 |
ShowMission(loc("Climb Home"), |
|
420 |
loc("Made it!"), |
|
421 |
string.format(loc("Ahhh, home, sweet home. Made it in %d seconds."), roundedFinishTime), |
|
422 |
-amRope, 0) |
|
423 |
PlaySound(sndVictory,CurrentHedgehog) |
|
424 |
SetState(CurrentHedgehog, gstWinner) |
|
425 |
SendStat(siGameResult, loc("You have beaten the challenge!")) |
|
426 |
SendStat(siGraphTitle, loc("Your height over time")) |
|
12424
b9cc405541c1
Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents:
12392
diff
changeset
|
427 |
SendStat(siCustomAchievement, string.format(loc("%s reached home in %.3f seconds. Congratulations!"), GetHogName(CurrentHedgehog), finishTime)) |
b9cc405541c1
Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents:
12392
diff
changeset
|
428 |
SendStat(siCustomAchievement, string.format(loc("%s bravely climbed up to a dizzy height of %d to reach home."), GetHogName(CurrentHedgehog), getActualHeight(RecordHeight))) |
10581 | 429 |
SendStat(siPointType, loc("seconds")) |
12424
b9cc405541c1
Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents:
12392
diff
changeset
|
430 |
SendStat(siPlayerKills, tostring(roundedFinishTime), GetHogTeamName(CurrentHedgehog)) |
10581 | 431 |
|
432 |
EndGame() |
|
11623
515d2d38ab8b
Declare achievements alongwith EndGame call, since it would skip SendStats
unc0rr
parents:
11615
diff
changeset
|
433 |
onAchievementsDeclaration() |
10581 | 434 |
YouWon = true |
435 |
end |
|
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
436 |
else |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
437 |
if distanceFromWater < 0 and not YouLost and not YouWon then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
438 |
makeMultiPlayerLoserStat(CurrentHedgehog) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
439 |
deadHedgehogs = deadHedgehogs + 1 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
440 |
YouLost = true |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
441 |
if deadHedgehogs >= totalHedgehogs then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
442 |
makeFinalMultiPlayerStats() |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
443 |
EndGame() |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
444 |
onAchievementsDeclaration() |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
445 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
446 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
447 |
-- Check victory |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
448 |
if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) and |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
449 |
-- Delay victory if MrMine is triggered |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
450 |
(not MrMine or (MrMine and band(GetState(MrMine), gstAttacking) == 0)) then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
451 |
-- Player managed to reach home in multiplayer. |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
452 |
-- Stop hog, disable controls, celebrate victory and continue the game after 4 seconds. |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
453 |
AddCaption(string.format(loc("%s climbed home in %d seconds!"), GetHogName(CurrentHedgehog), roundedFinishTime)) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
454 |
SendStat(siCustomAchievement, string.format(loc("%s (%s) reached home in %.3f seconds."), GetHogName(CurrentHedgehog), GetHogTeamName(CurrentHedgehog), finishTime)) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
455 |
makeMultiPlayerWinnerStat(CurrentHedgehog) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
456 |
PlaySound(sndVictory, CurrentHedgehog) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
457 |
-- TODO: Unselect weapon. |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
458 |
-- Note: SetWeapon(amNothing) does not work. :-( |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
459 |
SetGearMessage(CurrentHedgehog, band(GetGearMessage(CurrentHedgehog), bnot(gmLeft+gmRight+gmUp+gmDown+gmHJump+gmLJump+gmPrecise))) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
460 |
SetInputMask(0x00) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
461 |
-- TODO: Add stupid winner grin. |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
462 |
multiplayerVictoryDelay = 4000 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
463 |
YouWon = true |
10581 | 464 |
end |
465 |
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
|
466 |
|
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
|
467 |
if GameTime % 500 == 0 then |
11889
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
468 |
if not isSinglePlayer then |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
469 |
for t,i in pairs(teams) do |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
470 |
if currTeam == t then |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
471 |
SendStat(siClanHealth, tostring(getActualHeight(y)), t) |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
472 |
else |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
473 |
SendStat(siClanHealth, '0', t) |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
474 |
end |
10632
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
475 |
end |
11889
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
476 |
elseif CurrentHedgehog ~= nil then |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
477 |
SendStat(siClanHealth, tostring(getActualHeight(y)), GetHogTeamName(CurrentHedgehog)) |
10632
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
478 |
end |
10581 | 479 |
|
480 |
-- play taunts |
|
481 |
if not YouWon and not YouLost then |
|
482 |
local nooDistance = 500 |
|
483 |
if ((x < -nooDistance and vx < 0) or (x > LAND_WIDTH+nooDistance and vx > 0)) then |
|
484 |
if (tauntNoo == false and distanceFromWater > 80) then |
|
485 |
PlaySound(sndNooo, CurrentHedgehog) |
|
486 |
tauntNoo = true |
|
487 |
end |
|
488 |
end |
|
489 |
end |
|
490 |
||
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
|
491 |
if addCake and CakeTries < 10 and y < 32600 and y > 3000 and Cake == nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then |
10581 | 492 |
-- doing this just after the start the first time to take advantage of randomness sources |
493 |
-- Pick a clear y to start with |
|
494 |
if y > 31000 then cy = 24585 elseif |
|
495 |
y > 28000 then cy = 21500 elseif |
|
496 |
y > 24000 then cy = 19000 elseif |
|
497 |
y > 21500 then cy = 16000 elseif |
|
498 |
y > 19000 then cy = 12265 elseif |
|
499 |
y > 16000 then cy = 8800 elseif |
|
500 |
y > 12000 then cy = 5700 else |
|
501 |
cy = 400 end |
|
502 |
Cake = AddGear(GetRandom(2048), cy, gtCake, 0, 0, 0, 0) |
|
503 |
SetHealth(Cake,999999) |
|
504 |
CakeTries = CakeTries + 1 |
|
505 |
end |
|
506 |
||
507 |
if (y > 286) or (y < 286 and MaxHeight > 286) then |
|
11635 | 508 |
if MaxHeight > 286 and y <= 286 then |
509 |
-- wow, reached top |
|
510 |
local teamName = GetHogTeamName(CurrentHedgehog) |
|
511 |
if teamTimes[teamName] == nil or teamTimes[teamName] > GameTime - startTime then |
|
512 |
teamTimes[teamName] = GameTime - startTime |
|
513 |
end |
|
514 |
MaxHeight = 286 |
|
515 |
end |
|
10581 | 516 |
if y < MaxHeight and y > 286 then MaxHeight = y end |
517 |
if MaxHeight < hTagHeight then |
|
518 |
hTagHeight = MaxHeight |
|
519 |
if hTag ~= nil then DeleteVisualGear(hTag) end |
|
520 |
hTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
521 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag) |
|
522 |
-- snagged from space invasion |
|
523 |
SetVisualGearValues ( |
|
524 |
hTag, --id |
|
525 |
-(ScreenWidth/2) + 40, --xoffset |
|
526 |
ScreenHeight - 60, --yoffset |
|
527 |
0, --dx |
|
528 |
0, --dy |
|
529 |
1.1, --zoom |
|
530 |
1, --~= 0 means align to screen |
|
531 |
g7, --frameticks |
|
532 |
-- 116px off bottom for lowest rock, 286 or so off top for position of chair |
|
533 |
-- 32650 is "0" |
|
534 |
32640-hTagHeight, --value |
|
535 |
99999999999,--timer |
|
536 |
GetClanColor(GetHogClan(CurrentHedgehog)) |
|
537 |
) |
|
538 |
end |
|
539 |
||
540 |
if MaxHeight < RecordHeight then |
|
541 |
RecordHeight = MaxHeight |
|
542 |
local oldName = RecordHeightHogName |
|
543 |
RecordHeightHogName = GetHogName(CurrentHedgehog) |
|
544 |
if oldName == nil then recordBroken = true end |
|
545 |
if not isSinglePlayer and RecordHeight > 1500 and not recordBroken then |
|
546 |
recordBroken = true |
|
547 |
AddCaption(string.format(loc("%s has passed the best height of %s!"), RecordHeightHogName, oldName)) |
|
548 |
end |
|
549 |
if not isSinglePlayer then |
|
550 |
if rTag ~= nil then DeleteVisualGear(rTag) end |
|
551 |
rTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
552 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag) |
|
553 |
-- snagged from space invasion |
|
554 |
SetVisualGearValues ( |
|
555 |
rTag, --id |
|
556 |
-(ScreenWidth/2) + 100, --xoffset |
|
557 |
ScreenHeight - 60, --yoffset |
|
558 |
0, --dx |
|
559 |
0, --dy |
|
560 |
1.1, --zoom |
|
561 |
1, --~= 0 means align to screen |
|
562 |
g7, --frameticks |
|
563 |
-- 116px off bottom for lowest rock, 286 or so off top for position of chair |
|
564 |
-- 32650 is "0" |
|
565 |
getActualHeight(RecordHeight), --value |
|
566 |
99999999999,--timer |
|
567 |
GetClanColor(GetHogClan(CurrentHedgehog)) |
|
568 |
) |
|
569 |
end |
|
570 |
end |
|
571 |
end |
|
572 |
if MaxHeight > 286 then |
|
573 |
if tTag ~= nil then DeleteVisualGear(tTag) end |
|
574 |
tTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
575 |
local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tTag) |
|
10413 | 576 |
-- snagged from space invasion |
577 |
SetVisualGearValues ( |
|
578 |
tTag, --id |
|
579 |
-(ScreenWidth/2) + 40, --xoffset |
|
580 |
ScreenHeight - 100, --yoffset |
|
581 |
0, --dx |
|
582 |
0, --dy |
|
583 |
1.1, --zoom |
|
584 |
1, --~= 0 means align to screen |
|
585 |
g7, --frameticks |
|
586 |
(GameTime-startTime)/1000, --value |
|
587 |
99999999999,--timer |
|
588 |
0xffffffff |
|
589 |
) |
|
10581 | 590 |
end |
10413 | 591 |
end |
592 |
end |
|
593 |
end |
|
10581 | 594 |
|
595 |
function onGearDamage(gear, damage) |
|
596 |
if GetGearType(gear) == gtHedgehog and not YouLost and not YouWon then |
|
597 |
-- Joke award for largest damage to hog |
|
598 |
local qualifyDamage = 50 |
|
599 |
if (damage >= qualifyDamage) then |
|
600 |
local awarded = false |
|
601 |
if jokeAwardDamage == nil or damage > jokeAwardDamage.damage then |
|
602 |
awarded = true |
|
603 |
end |
|
604 |
if awarded == true then |
|
605 |
jokeAwardDamage = { |
|
606 |
hogName = GetHogName(CurrentHedgehog), |
|
607 |
teamName = GetHogTeamName(CurrentHedgehog), |
|
608 |
damage = damage |
|
609 |
} |
|
610 |
end |
|
611 |
end |
|
612 |
||
613 |
if isSinglePlayer then |
|
614 |
makeSinglePlayerLoserStats() |
|
615 |
else |
|
616 |
deadHedgehogs = deadHedgehogs + 1 |
|
12655
913d25669131
ClimbHome: Fix final team scoring 0 if hog took damage
Wuzzy <almikes@aol.com>
parents:
12654
diff
changeset
|
617 |
makeMultiPlayerLoserStat(gear) |
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
618 |
if (deadHedgehogs + multiplayerWins) >= totalHedgehogs then |
10581 | 619 |
makeFinalMultiPlayerStats() |
620 |
EndGame() |
|
11623
515d2d38ab8b
Declare achievements alongwith EndGame call, since it would skip SendStats
unc0rr
parents:
11615
diff
changeset
|
621 |
onAchievementsDeclaration() |
10581 | 622 |
end |
623 |
end |
|
624 |
YouLost = true |
|
625 |
end |
|
626 |
end |
|
627 |
||
628 |
function makeLoserComment() |
|
629 |
local m |
|
630 |
if isSinglePlayer then m = 10 else m = 6 end |
|
631 |
local r = math.random(1,m) |
|
632 |
if r == 1 then text = loc("%s never got the ninja diploma.") |
|
633 |
elseif r == 2 then text = loc("You have to move upwards, not downwards, %s!") |
|
634 |
elseif r == 3 then text = loc("%s never wanted to reach for the sky in the first place.") |
|
635 |
elseif r == 4 then text = loc("%s should try the rope training mission first.") |
|
636 |
elseif r == 5 then text = loc("%s skipped ninja classes.") |
|
637 |
elseif r == 6 then text = loc("%s doesn’t really know how to handle a rope properly.") |
|
638 |
elseif r == 7 then text = loc("Better luck next time!") |
|
639 |
elseif r == 8 then text = loc("It was all just bad luck!") |
|
640 |
elseif r == 9 then text = loc("Well, that escalated quickly!") |
|
641 |
elseif r == 10 then text = loc("What? Is it over already?") end |
|
642 |
return text |
|
643 |
end |
|
644 |
||
645 |
function makeSinglePlayerLoserStats() |
|
646 |
local actualHeight = getActualHeight(RecordHeight) |
|
647 |
SendStat(siGameResult, loc("You lose!")) |
|
648 |
SendStat(siGraphTitle, loc("Your height over time")) |
|
649 |
local text |
|
650 |
if actualHeight > 30000 then text = loc("%s was damn close to home.") |
|
651 |
elseif actualHeight > 28000 then text = loc("%s was close to home.") |
|
652 |
elseif actualHeight > 24265 then text = loc("%s was good, but not good enough.") |
|
653 |
elseif actualHeight > 16177 then text = loc("%s managed to pass half of the distance towards home.") |
|
654 |
elseif actualHeight > 8088 then text = loc("%s went over a quarter of the way towards home.") |
|
655 |
elseif actualHeight > 5100 then text = loc("%s still had a long way to go.") |
|
656 |
elseif actualHeight > 2000 then text = loc("%s made it past the hogosphere.") |
|
657 |
elseif actualHeight > 1500 then text = loc("%s barely made it past the hogosphere.") |
|
658 |
else |
|
659 |
text = makeLoserComment() |
|
660 |
end |
|
661 |
if actualHeight > 1500 then |
|
662 |
SendStat(siCustomAchievement, string.format(text, RecordHeightHogName, actualHeight)) |
|
663 |
else |
|
664 |
SendStat(siCustomAchievement, string.format(text, RecordHeightHogName)) |
|
665 |
end |
|
11067
c632b47b8ff0
Trying to get these scripts to behave properly, still WIP though.
nemo
parents:
10824
diff
changeset
|
666 |
SendStat(siPointType, loc("points")) |
12424
b9cc405541c1
Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents:
12392
diff
changeset
|
667 |
SendStat(siPlayerKills, actualHeight, GetHogTeamName(CurrentHedgehog)) |
10581 | 668 |
EndGame() |
11623
515d2d38ab8b
Declare achievements alongwith EndGame call, since it would skip SendStats
unc0rr
parents:
11615
diff
changeset
|
669 |
onAchievementsDeclaration() |
10581 | 670 |
end |
671 |
||
672 |
function makeMultiPlayerLoserStat(gear) |
|
673 |
local teamName = GetHogTeamName(gear) |
|
674 |
local actualHeight = getActualHeight(MaxHeight) |
|
675 |
if teamBests[teamName] == nil then teamBests[teamName] = actualHeight end |
|
676 |
if teamBests[teamName] < actualHeight then teamBests[teamName] = actualHeight end |
|
677 |
if teamScoreStats[teamName] == nil then teamScoreStats[teamName] = {} end |
|
678 |
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
|
679 |
--SendStat(siClanHealth, tostring(teamBests[teamName]), teamName) |
10581 | 680 |
end |
681 |
||
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
682 |
function makeMultiPlayerWinnerStat(gear) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
683 |
return makeMultiPlayerLoserStat(gear) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
684 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
685 |
|
10581 | 686 |
function makeFinalMultiPlayerStats() |
687 |
local ranking = {} |
|
688 |
for k,v in pairs(teamBests) do |
|
689 |
table.insert(ranking, {name=k, score=v}) |
|
690 |
end |
|
691 |
local comp = function(table1, table2) |
|
692 |
if table1.score < table2.score then |
|
693 |
return true |
|
694 |
else |
|
695 |
return false |
|
696 |
end |
|
697 |
end |
|
698 |
table.sort(ranking, comp) |
|
699 |
||
700 |
local winner = ranking[#ranking] |
|
701 |
local loser = ranking[1] |
|
702 |
SendStat(siGameResult, string.format(loc("%s wins!"), winner.name)) |
|
11889
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
703 |
SendStat(siGraphTitle, string.format(loc("Height over time"))) |
10581 | 704 |
|
705 |
if winner.score < 1500 then |
|
11067
c632b47b8ff0
Trying to get these scripts to behave properly, still WIP though.
nemo
parents:
10824
diff
changeset
|
706 |
SendStat(siCustomAchievement, string.format(loc("This round’s award for ultimate disappointment goes to: Everyone!"))) |
10581 | 707 |
else |
708 |
if winner.score > 30000 then text = loc("%s (%s) reached for the sky and beyond with a height of %d!") |
|
709 |
elseif winner.score > 24750 then text = loc("%s (%s) was certainly not afraid of heights: Peak height of %d!") |
|
710 |
elseif winner.score > 16500 then text = loc("%s (%s) does not have to feel ashamed for their best height of %d.") |
|
711 |
elseif winner.score > 8250 then text = loc("%s (%s) reached a decent peak height of %d.") |
|
712 |
else text = loc("%s (%s) reached a peak height of %d.") end |
|
713 |
SendStat(siCustomAchievement, string.format(text, RecordHeightHogName, winner.name, winner.score)) |
|
714 |
||
715 |
if loser.score < 1500 then |
|
716 |
text = makeLoserComment() |
|
717 |
SendStat(siCustomAchievement, string.format(text, loser.name)) |
|
718 |
end |
|
719 |
end |
|
720 |
checkAwards() |
|
721 |
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
|
722 |
SendStat(siPointType, loc("points")) |
10581 | 723 |
SendStat(siPlayerKills, tostring(ranking[i].score), ranking[i].name) |
724 |
end |
|
725 |
end |
|
726 |
||
727 |
function checkAwards() |
|
728 |
if jokeAwardNavy ~= nil then |
|
729 |
if isSinglePlayer then |
|
730 |
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)) |
|
731 |
else |
|
732 |
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)) |
|
733 |
end |
|
734 |
end |
|
735 |
if jokeAwardSpeed ~= nil then |
|
736 |
if isSinglePlayer then |
|
737 |
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)) |
|
738 |
else |
|
739 |
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)) |
|
740 |
end |
|
741 |
end |
|
742 |
if jokeAwardDamage ~= nil then |
|
743 |
if isSinglePlayer then |
|
744 |
SendStat(siCustomAchievement, string.format(loc("Ouch! That must have hurt. You mutilated your poor hedgehog hog with %d damage."), jokeAwardDamage.damage)) |
|
745 |
else |
|
746 |
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)) |
|
747 |
end |
|
748 |
end |
|
749 |
end |
|
750 |
||
751 |
function getActualHeight(height) |
|
752 |
return 32640-height |
|
753 |
end |
|
11615 | 754 |
|
755 |
function onAchievementsDeclaration() |
|
756 |
for teamname, score in pairs(teamBests) do |
|
11627 | 757 |
DeclareAchievement("height reached", teamname, "ClimbHome", -score) |
11615 | 758 |
end |
11635 | 759 |
for teamname, score in pairs(teamTimes) do |
760 |
DeclareAchievement("rope race", teamname, "ClimbHome", score) |
|
761 |
end |
|
11615 | 762 |
end |