author | nemo |
Sun, 21 Jun 2009 15:31:09 +0000 | |
changeset 2177 | c045698e044f |
parent 2168 | 5ffb01c3b176 |
child 2182 | ed7e7eb3f9ed |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1689 | 3 |
* Copyright (c) 2004-2009 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
4 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
4 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
19 |
unit uGears; |
|
20 |
interface |
|
351 | 21 |
uses SDLh, uConsts, uFloat; |
4 | 22 |
{$INCLUDE options.inc} |
23 |
const AllInactive: boolean = false; |
|
868 | 24 |
PrvInactive: boolean = false; |
4 | 25 |
|
26 |
type PGear = ^TGear; |
|
1259 | 27 |
TGearStepProcedure = procedure (Gear: PGear); |
28 |
TGear = record |
|
29 |
NextGear, PrevGear: PGear; |
|
30 |
Active: Boolean; |
|
1849 | 31 |
Invulnerable: Boolean; |
1259 | 32 |
Ammo : PAmmo; |
33 |
State : Longword; |
|
34 |
X : hwFloat; |
|
35 |
Y : hwFloat; |
|
36 |
dX: hwFloat; |
|
37 |
dY: hwFloat; |
|
38 |
Kind: TGearType; |
|
39 |
Pos: Longword; |
|
40 |
doStep: TGearStepProcedure; |
|
41 |
Radius: LongInt; |
|
42 |
Angle, Power : Longword; |
|
43 |
DirAngle: real; |
|
44 |
Timer : LongWord; |
|
45 |
Elasticity: hwFloat; |
|
46 |
Friction : hwFloat; |
|
47 |
Message, MsgParam : Longword; |
|
48 |
Hedgehog: pointer; |
|
2135
0b7972dfad01
Push karma application to end of round - should avoid problems w/ plane and kamikaze
nemo
parents:
2134
diff
changeset
|
49 |
Health, Damage, Karma: LongInt; |
1259 | 50 |
CollisionIndex: LongInt; |
51 |
Tag: LongInt; |
|
52 |
Tex: PTexture; |
|
53 |
Z: Longword; |
|
54 |
IntersectGear: PGear; |
|
55 |
TriggerId: Longword; |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2031
diff
changeset
|
56 |
uid: Longword |
1259 | 57 |
end; |
4 | 58 |
|
371 | 59 |
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
4 | 60 |
procedure ProcessGears; |
1849 | 61 |
procedure ResetUtilities; |
2017 | 62 |
procedure ApplyDamage(Gear: PGear; Damage: Longword); |
4 | 63 |
procedure SetAllToActive; |
64 |
procedure SetAllHHToActive; |
|
956 | 65 |
procedure DrawGears; |
4 | 66 |
procedure FreeGearsList; |
10 | 67 |
procedure AddMiscGears; |
4 | 68 |
procedure AssignHHCoords; |
294 | 69 |
procedure InsertGearToList(Gear: PGear); |
70 |
procedure RemoveGearFromList(Gear: PGear); |
|
4 | 71 |
|
72 |
var CurAmmoGear: PGear = nil; |
|
68 | 73 |
GearsList: PGear = nil; |
307 | 74 |
KilledHHs: Longword = 0; |
2017 | 75 |
SuddenDeathDmg: Boolean = false; |
76 |
SpeechType: Longword = 1; |
|
77 |
SpeechText: shortstring; |
|
70 | 78 |
|
4 | 79 |
implementation |
81 | 80 |
uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, |
1906 | 81 |
uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers, |
2152 | 82 |
{$IFDEF GLES11} |
1906 | 83 |
gles11, |
84 |
{$ELSE} |
|
85 |
GL, |
|
86 |
{$ENDIF} |
|
1259 | 87 |
uStats, uVisualGears; |
789 | 88 |
|
1207
ceaab010269e
Some adjusting... it still doesn't solve problem fully
unc0rr
parents:
1200
diff
changeset
|
89 |
const MAXROPEPOINTS = 384; |
68 | 90 |
var RopePoints: record |
4 | 91 |
Count: Longword; |
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
775
diff
changeset
|
92 |
HookAngle: GLfloat; |
789 | 93 |
ar: array[0..MAXROPEPOINTS] of record |
351 | 94 |
X, Y: hwFloat; |
95 |
dLen: hwFloat; |
|
4 | 96 |
b: boolean; |
97 |
end; |
|
98 |
end; |
|
99 |
||
1515 | 100 |
procedure DeleteGear(Gear: PGear); forward; |
371 | 101 |
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); forward; |
102 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward; |
|
1433 | 103 |
//procedure AmmoFlameWork(Ammo: PGear); forward; |
371 | 104 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; forward; |
15 | 105 |
procedure SpawnBoxOfSmth; forward; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
24
diff
changeset
|
106 |
procedure AfterAttack; forward; |
1515 | 107 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); forward; |
302 | 108 |
procedure HedgehogStep(Gear: PGear); forward; |
1528 | 109 |
procedure doStepHedgehogMoving(Gear: PGear); forward; |
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
110 |
procedure HedgehogChAngle(Gear: PGear); forward; |
506 | 111 |
procedure ShotgunShot(Gear: PGear); forward; |
1689 | 112 |
procedure PickUp(HH, Gear: PGear); forward; |
1964 | 113 |
procedure HHSetWeapon(Gear: PGear); forward; |
114 |
||
4 | 115 |
|
116 |
{$INCLUDE GSHandlers.inc} |
|
117 |
{$INCLUDE HHHandlers.inc} |
|
118 |
||
119 |
const doStepHandlers: array[TGearType] of TGearStepProcedure = ( |
|
1259 | 120 |
@doStepBomb, |
121 |
@doStepHedgehog, |
|
122 |
@doStepGrenade, |
|
123 |
@doStepHealthTag, |
|
124 |
@doStepGrave, |
|
125 |
@doStepUFO, |
|
126 |
@doStepShotgunShot, |
|
127 |
@doStepPickHammer, |
|
128 |
@doStepRope, |
|
129 |
@doStepSmokeTrace, |
|
130 |
@doStepExplosion, |
|
131 |
@doStepMine, |
|
132 |
@doStepCase, |
|
133 |
@doStepDEagleShot, |
|
134 |
@doStepDynamite, |
|
135 |
@doStepBomb, |
|
136 |
@doStepCluster, |
|
137 |
@doStepShover, |
|
138 |
@doStepFlame, |
|
139 |
@doStepFirePunch, |
|
140 |
@doStepActionTimer, |
|
141 |
@doStepActionTimer, |
|
142 |
@doStepActionTimer, |
|
143 |
@doStepParachute, |
|
144 |
@doStepAirAttack, |
|
145 |
@doStepAirBomb, |
|
146 |
@doStepBlowTorch, |
|
147 |
@doStepGirder, |
|
148 |
@doStepTeleport, |
|
149 |
@doStepSwitcher, |
|
150 |
@doStepCase, |
|
151 |
@doStepMortar, |
|
152 |
@doStepWhip, |
|
153 |
@doStepKamikaze, |
|
154 |
@doStepCake, |
|
1261 | 155 |
@doStepSeduction, |
1279 | 156 |
@doStepWatermelon, |
1263 | 157 |
@doStepCluster, |
158 |
@doStepBomb, |
|
1298 | 159 |
@doStepSmokeTrace, |
1573 | 160 |
@doStepWaterUp, |
1601 | 161 |
@doStepDrill, |
162 |
@doStepBallgun, |
|
1689 | 163 |
@doStepBomb, |
2017 | 164 |
@doStepRCPlane, |
2177
c045698e044f
Initial attempt at jetpack. Pluses, more like lunar lander (takes fall damage). Minuses, can't seem to cancel it or use alt weapon
nemo
parents:
2168
diff
changeset
|
165 |
@doStepSniperRifleShot, |
c045698e044f
Initial attempt at jetpack. Pluses, more like lunar lander (takes fall damage). Minuses, can't seem to cancel it or use alt weapon
nemo
parents:
2168
diff
changeset
|
166 |
@doStepJetpack |
1259 | 167 |
); |
4 | 168 |
|
294 | 169 |
procedure InsertGearToList(Gear: PGear); |
803 | 170 |
var tmp, ptmp: PGear; |
294 | 171 |
begin |
172 |
if GearsList = nil then |
|
1505 | 173 |
GearsList:= Gear |
174 |
else begin |
|
175 |
tmp:= GearsList; |
|
176 |
ptmp:= GearsList; |
|
177 |
while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do |
|
178 |
begin |
|
179 |
ptmp:= tmp; |
|
180 |
tmp:= tmp^.NextGear |
|
181 |
end; |
|
294 | 182 |
|
1505 | 183 |
if ptmp <> nil then |
184 |
begin |
|
185 |
Gear^.NextGear:= ptmp^.NextGear; |
|
186 |
Gear^.PrevGear:= ptmp; |
|
187 |
if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear; |
|
188 |
ptmp^.NextGear:= Gear |
|
189 |
end |
|
190 |
else GearsList:= Gear |
|
191 |
end |
|
294 | 192 |
end; |
193 |
||
194 |
procedure RemoveGearFromList(Gear: PGear); |
|
195 |
begin |
|
351 | 196 |
if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear; |
1505 | 197 |
if Gear^.PrevGear <> nil then |
198 |
Gear^.PrevGear^.NextGear:= Gear^.NextGear |
|
199 |
else |
|
200 |
GearsList:= Gear^.NextGear |
|
294 | 201 |
end; |
202 |
||
371 | 203 |
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
79 | 204 |
const Counter: Longword = 0; |
351 | 205 |
var Result: PGear; |
4 | 206 |
begin |
79 | 207 |
inc(Counter); |
1495 | 208 |
{$IFDEF DEBUGFILE} |
1503 | 209 |
AddFileLog('AddGear: #' + inttostr(Counter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + inttostr(ord(Kind))); |
1495 | 210 |
{$ENDIF} |
211 |
||
4 | 212 |
New(Result); |
213 |
FillChar(Result^, sizeof(TGear), 0); |
|
498 | 214 |
Result^.X:= int2hwFloat(X); |
215 |
Result^.Y:= int2hwFloat(Y); |
|
351 | 216 |
Result^.Kind := Kind; |
217 |
Result^.State:= State; |
|
218 |
Result^.Active:= true; |
|
219 |
Result^.dX:= dX; |
|
220 |
Result^.dY:= dY; |
|
221 |
Result^.doStep:= doStepHandlers[Kind]; |
|
511 | 222 |
Result^.CollisionIndex:= -1; |
351 | 223 |
Result^.Timer:= Timer; |
1270 | 224 |
Result^.Z:= cUsualZ; |
1503 | 225 |
Result^.uid:= Counter; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
503
diff
changeset
|
226 |
|
4 | 227 |
if CurrentTeam <> nil then |
1505 | 228 |
begin |
229 |
Result^.Hedgehog:= CurrentHedgehog; |
|
230 |
Result^.IntersectGear:= CurrentHedgehog^.Gear |
|
231 |
end; |
|
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
789
diff
changeset
|
232 |
|
4 | 233 |
case Kind of |
915 | 234 |
gtAmmo_Bomb, |
235 |
gtClusterBomb: begin |
|
351 | 236 |
Result^.Radius:= 4; |
237 |
Result^.Elasticity:= _0_6; |
|
997 | 238 |
Result^.Friction:= _0_96; |
4 | 239 |
end; |
1261 | 240 |
gtWatermelon: begin |
241 |
Result^.Radius:= 4; |
|
242 |
Result^.Elasticity:= _0_8; |
|
243 |
Result^.Friction:= _0_995; |
|
244 |
end; |
|
4 | 245 |
gtHedgehog: begin |
351 | 246 |
Result^.Radius:= cHHRadius; |
247 |
Result^.Elasticity:= _0_35; |
|
248 |
Result^.Friction:= _0_999; |
|
249 |
Result^.Angle:= cMaxAngle div 2; |
|
250 |
Result^.Z:= cHHZ; |
|
4 | 251 |
end; |
252 |
gtAmmo_Grenade: begin |
|
351 | 253 |
Result^.Radius:= 4; |
4 | 254 |
end; |
255 |
gtHealthTag: begin |
|
351 | 256 |
Result^.Timer:= 1500; |
2017 | 257 |
Result^.Z:= 2002; |
258 |
end; |
|
4 | 259 |
gtGrave: begin |
351 | 260 |
Result^.Radius:= 10; |
261 |
Result^.Elasticity:= _0_6; |
|
4 | 262 |
end; |
263 |
gtUFO: begin |
|
351 | 264 |
Result^.Radius:= 5; |
265 |
Result^.Timer:= 500; |
|
266 |
Result^.Elasticity:= _0_9 |
|
4 | 267 |
end; |
268 |
gtShotgunShot: begin |
|
351 | 269 |
Result^.Timer:= 900; |
270 |
Result^.Radius:= 2 |
|
4 | 271 |
end; |
272 |
gtPickHammer: begin |
|
351 | 273 |
Result^.Radius:= 10; |
274 |
Result^.Timer:= 4000 |
|
4 | 275 |
end; |
1263 | 276 |
gtSmokeTrace, |
277 |
gtEvilTrace: begin |
|
498 | 278 |
Result^.X:= Result^.X - _16; |
279 |
Result^.Y:= Result^.Y - _16; |
|
1270 | 280 |
Result^.State:= 8; |
281 |
Result^.Z:= cSmokeZ |
|
4 | 282 |
end; |
283 |
gtRope: begin |
|
351 | 284 |
Result^.Radius:= 3; |
498 | 285 |
Result^.Friction:= _450; |
4 | 286 |
RopePoints.Count:= 0; |
287 |
end; |
|
9 | 288 |
gtExplosion: begin |
1012 | 289 |
Result^.X:= Result^.X; |
290 |
Result^.Y:= Result^.Y; |
|
9 | 291 |
end; |
10 | 292 |
gtMine: begin |
503 | 293 |
Result^.State:= Result^.State or gstMoving; |
915 | 294 |
Result^.Radius:= 2; |
351 | 295 |
Result^.Elasticity:= _0_55; |
296 |
Result^.Friction:= _0_995; |
|
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2028
diff
changeset
|
297 |
if cMinesTime < 0 then |
2121 | 298 |
Result^.Timer:= getrandom(4)*1000 |
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2028
diff
changeset
|
299 |
else |
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2028
diff
changeset
|
300 |
Result^.Timer:= cMinesTime*1; |
10 | 301 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset
|
302 |
gtCase: begin |
351 | 303 |
Result^.Radius:= 16; |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
304 |
Result^.Elasticity:= _0_3 |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset
|
305 |
end; |
37 | 306 |
gtDEagleShot: begin |
351 | 307 |
Result^.Radius:= 1; |
308 |
Result^.Health:= 50 |
|
37 | 309 |
end; |
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
310 |
gtSniperRifleShot: begin |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
311 |
Result^.Radius:= 1; |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
312 |
Result^.Health:= 50 |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
313 |
end; |
39 | 314 |
gtDynamite: begin |
351 | 315 |
Result^.Radius:= 3; |
316 |
Result^.Elasticity:= _0_55; |
|
317 |
Result^.Friction:= _0_03; |
|
318 |
Result^.Timer:= 5000; |
|
39 | 319 |
end; |
910 | 320 |
gtCluster: Result^.Radius:= 2; |
878 | 321 |
gtShover: Result^.Radius:= 20; |
79 | 322 |
gtFlame: begin |
1586 | 323 |
Result^.Tag:= Counter mod 32; |
351 | 324 |
Result^.Radius:= 1; |
1586 | 325 |
Result^.Health:= 5; |
1555 | 326 |
if (Result^.dY.QWordValue = 0) and (Result^.dX.QWordValue = 0) then |
327 |
begin |
|
328 |
Result^.dY:= (getrandom - _0_8) * _0_03; |
|
329 |
Result^.dX:= (getrandom - _0_5) * _0_4 |
|
330 |
end |
|
79 | 331 |
end; |
82 | 332 |
gtFirePunch: begin |
351 | 333 |
Result^.Radius:= 15; |
334 |
Result^.Tag:= Y |
|
82 | 335 |
end; |
302 | 336 |
gtAirBomb: begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
337 |
Result^.Radius:= 5; |
302 | 338 |
end; |
339 |
gtBlowTorch: begin |
|
511 | 340 |
Result^.Radius:= cHHRadius + cBlowTorchC; |
351 | 341 |
Result^.Timer:= 7500; |
302 | 342 |
end; |
540 | 343 |
gtSwitcher: begin |
344 |
Result^.Z:= cCurrHHZ |
|
345 |
end; |
|
593 | 346 |
gtTarget: begin |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
347 |
Result^.Radius:= 16; |
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
348 |
Result^.Elasticity:= _0_3 |
593 | 349 |
end; |
924 | 350 |
gtMortar: begin |
994 | 351 |
Result^.Radius:= 4; |
924 | 352 |
Result^.Elasticity:= _0_2; |
353 |
Result^.Friction:= _0_08 |
|
354 |
end; |
|
925 | 355 |
gtWhip: Result^.Radius:= 20; |
984 | 356 |
gtKamikaze: begin |
357 |
Result^.Health:= 2048; |
|
358 |
Result^.Radius:= 20 |
|
359 |
end; |
|
1089 | 360 |
gtCake: begin |
1261 | 361 |
Result^.Health:= 2048; |
1103 | 362 |
Result^.Radius:= 7; |
1109 | 363 |
Result^.Z:= cOnHHZ; |
1089 | 364 |
if hwSign(dX) > 0 then Result^.Angle:= 1 else Result^.Angle:= 3 |
365 |
end; |
|
1263 | 366 |
gtHellishBomb: begin |
367 |
Result^.Radius:= 4; |
|
368 |
Result^.Elasticity:= _0_5; |
|
369 |
Result^.Friction:= _0_96; |
|
370 |
end; |
|
1573 | 371 |
gtDrill: begin |
372 |
Result^.Timer:= 5000; |
|
373 |
Result^.Radius:= 4; |
|
374 |
end; |
|
1601 | 375 |
gtBall: begin |
376 |
Result^.Radius:= 5; |
|
377 |
Result^.Tag:= random(8); |
|
378 |
Result^.Timer:= 5000; |
|
379 |
Result^.Elasticity:= _0_7; |
|
380 |
Result^.Friction:= _0_995; |
|
381 |
end; |
|
382 |
gtBallgun: begin |
|
383 |
Result^.Timer:= 5001; |
|
384 |
end; |
|
1689 | 385 |
gtRCPlane: begin |
386 |
Result^.Timer:= 15000; |
|
387 |
Result^.Health:= 3; |
|
388 |
Result^.Radius:= 8; |
|
389 |
end; |
|
2177
c045698e044f
Initial attempt at jetpack. Pluses, more like lunar lander (takes fall damage). Minuses, can't seem to cancel it or use alt weapon
nemo
parents:
2168
diff
changeset
|
390 |
gtJetpack: begin |
c045698e044f
Initial attempt at jetpack. Pluses, more like lunar lander (takes fall damage). Minuses, can't seem to cancel it or use alt weapon
nemo
parents:
2168
diff
changeset
|
391 |
Result^.Timer:= 20000; |
c045698e044f
Initial attempt at jetpack. Pluses, more like lunar lander (takes fall damage). Minuses, can't seem to cancel it or use alt weapon
nemo
parents:
2168
diff
changeset
|
392 |
Result^.Health:= 2000; |
c045698e044f
Initial attempt at jetpack. Pluses, more like lunar lander (takes fall damage). Minuses, can't seem to cancel it or use alt weapon
nemo
parents:
2168
diff
changeset
|
393 |
end; |
4 | 394 |
end; |
351 | 395 |
InsertGearToList(Result); |
396 |
AddGear:= Result |
|
4 | 397 |
end; |
398 |
||
1515 | 399 |
procedure DeleteGear(Gear: PGear); |
48 | 400 |
var team: PTeam; |
1515 | 401 |
t: Longword; |
4 | 402 |
begin |
503 | 403 |
DeleteCI(Gear); |
762 | 404 |
|
405 |
if Gear^.Tex <> nil then |
|
1495 | 406 |
begin |
407 |
FreeTexture(Gear^.Tex); |
|
408 |
Gear^.Tex:= nil |
|
409 |
end; |
|
762 | 410 |
|
351 | 411 |
if Gear^.Kind = gtHedgehog then |
2079 | 412 |
if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then |
1495 | 413 |
begin |
414 |
Gear^.Message:= gm_Destroy; |
|
415 |
CurAmmoGear^.Message:= gm_Destroy; |
|
416 |
exit |
|
417 |
end |
|
418 |
else |
|
419 |
begin |
|
2076
aa3263e57b8f
increase # of mines to 50, limit max depth of drowning damage tag
nemo
parents:
2074
diff
changeset
|
420 |
if (hwRound(Gear^.Y) >= cWaterLine) then |
1495 | 421 |
begin |
422 |
t:= max(Gear^.Damage, Gear^.Health); |
|
423 |
Gear^.Damage:= t; |
|
2076
aa3263e57b8f
increase # of mines to 50, limit max depth of drowning damage tag
nemo
parents:
2074
diff
changeset
|
424 |
AddGear(hwRound(Gear^.X), min(hwRound(Gear^.Y),cWaterLine+cVisibleWater+32), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
1495 | 425 |
uStats.HedgehogDamaged(Gear) |
426 |
end; |
|
1515 | 427 |
|
1495 | 428 |
team:= PHedgehog(Gear^.Hedgehog)^.Team; |
429 |
if CurrentHedgehog^.Gear = Gear then |
|
430 |
FreeActionsList; // to avoid ThinkThread on drawned gear |
|
1515 | 431 |
|
1495 | 432 |
PHedgehog(Gear^.Hedgehog)^.Gear:= nil; |
433 |
inc(KilledHHs); |
|
1515 | 434 |
RecountTeamHealth(team) |
1495 | 435 |
end; |
436 |
{$IFDEF DEBUGFILE} |
|
1503 | 437 |
with Gear^ do AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + inttostr(ord(Kind))); |
1495 | 438 |
{$ENDIF} |
439 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
593
diff
changeset
|
440 |
if Gear^.TriggerId <> 0 then TickTrigger(Gear^.TriggerId); |
82 | 441 |
if CurAmmoGear = Gear then CurAmmoGear:= nil; |
4 | 442 |
if FollowGear = Gear then FollowGear:= nil; |
294 | 443 |
RemoveGearFromList(Gear); |
1515 | 444 |
Dispose(Gear) |
4 | 445 |
end; |
446 |
||
447 |
function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs |
|
448 |
var Gear: PGear; |
|
1849 | 449 |
dmg: LongInt; |
4 | 450 |
begin |
351 | 451 |
CheckNoDamage:= true; |
4 | 452 |
Gear:= GearsList; |
453 |
while Gear <> nil do |
|
867 | 454 |
begin |
455 |
if Gear^.Kind = gtHedgehog then |
|
1861 | 456 |
begin |
2135
0b7972dfad01
Push karma application to end of round - should avoid problems w/ plane and kamikaze
nemo
parents:
2134
diff
changeset
|
457 |
if (not isInMultiShoot) then inc(Gear^.Damage, Gear^.Karma); |
1849 | 458 |
if (Gear^.Damage <> 0) and |
459 |
(not Gear^.Invulnerable) then |
|
1861 | 460 |
begin |
461 |
CheckNoDamage:= false; |
|
462 |
uStats.HedgehogDamaged(Gear); |
|
463 |
dmg:= Gear^.Damage; |
|
464 |
if Gear^.Health < dmg then |
|
465 |
Gear^.Health:= 0 |
|
466 |
else |
|
467 |
dec(Gear^.Health, dmg); |
|
351 | 468 |
|
2017 | 469 |
if (PHedgehog(Gear^.Hedgehog)^.Team = CurrentTeam) and |
2135
0b7972dfad01
Push karma application to end of round - should avoid problems w/ plane and kamikaze
nemo
parents:
2134
diff
changeset
|
470 |
(Gear^.Damage <> Gear^.Karma) and |
2017 | 471 |
not SuddenDeathDmg then |
472 |
Gear^.State:= Gear^.State or gstLoser; |
|
473 |
||
1861 | 474 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12, |
475 |
gtHealthTag, dmg, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
867 | 476 |
|
1861 | 477 |
RenderHealth(PHedgehog(Gear^.Hedgehog)^); |
478 |
RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team); |
|
1505 | 479 |
|
1861 | 480 |
end; |
2135
0b7972dfad01
Push karma application to end of round - should avoid problems w/ plane and kamikaze
nemo
parents:
2134
diff
changeset
|
481 |
if (not isInMultiShoot) then Gear^.Karma:= 0; |
0b7972dfad01
Push karma application to end of round - should avoid problems w/ plane and kamikaze
nemo
parents:
2134
diff
changeset
|
482 |
Gear^.Damage:= 0 |
1861 | 483 |
end; |
867 | 484 |
Gear:= Gear^.NextGear |
485 |
end; |
|
2017 | 486 |
SuddenDeathDmg:= false; |
4 | 487 |
end; |
488 |
||
1054 | 489 |
procedure HealthMachine; |
490 |
var Gear: PGear; |
|
491 |
begin |
|
492 |
Gear:= GearsList; |
|
493 |
||
494 |
while Gear <> nil do |
|
495 |
begin |
|
496 |
if Gear^.Kind = gtHedgehog then |
|
497 |
Gear^.Damage:= min(cHealthDecrease, Gear^.Health - 1); |
|
498 |
||
499 |
Gear:= Gear^.NextGear |
|
500 |
end; |
|
501 |
end; |
|
502 |
||
4 | 503 |
procedure ProcessGears; |
614 | 504 |
const delay: LongWord = 0; |
1797 | 505 |
step: (stDelay, stChDmg, stSweep, stTurnReact, |
1495 | 506 |
stAfterDelay, stChWin, stWater, stChWin2, stHealth, |
507 |
stSpawn, stNTurn) = stDelay; |
|
1054 | 508 |
|
4 | 509 |
var Gear, t: PGear; |
510 |
begin |
|
868 | 511 |
PrvInactive:= AllInactive; |
4 | 512 |
AllInactive:= true; |
1495 | 513 |
|
4 | 514 |
t:= GearsList; |
1054 | 515 |
while t <> nil do |
1352
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
516 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
517 |
Gear:= t; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
518 |
t:= Gear^.NextGear; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
519 |
if Gear^.Active then Gear^.doStep(Gear); |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
520 |
end; |
89 | 521 |
|
4 | 522 |
if AllInactive then |
1343 | 523 |
case step of |
524 |
stDelay: begin |
|
525 |
if delay = 0 then |
|
526 |
delay:= cInactDelay |
|
527 |
else |
|
528 |
dec(delay); |
|
614 | 529 |
|
1343 | 530 |
if delay = 0 then |
531 |
inc(step) |
|
532 |
end; |
|
1797 | 533 |
stChDmg: if CheckNoDamage then inc(step) else step:= stDelay; |
534 |
stSweep: if SweepDirty then |
|
1792 | 535 |
begin |
1918 | 536 |
SetAllToActive; |
1792 | 537 |
step:= stChDmg |
1797 | 538 |
end else inc(step); |
1343 | 539 |
stTurnReact: begin |
540 |
if (not bBetweenTurns) and (not isInMultiShoot) then |
|
541 |
begin |
|
542 |
uStats.TurnReaction; |
|
543 |
inc(step) |
|
544 |
end else |
|
545 |
inc(step, 2); |
|
546 |
end; |
|
547 |
stAfterDelay: begin |
|
548 |
if delay = 0 then |
|
549 |
delay:= cInactDelay |
|
550 |
else |
|
551 |
dec(delay); |
|
815 | 552 |
|
1343 | 553 |
if delay = 0 then |
554 |
inc(step) |
|
555 |
end; |
|
556 |
stChWin: begin |
|
557 |
CheckForWin; |
|
558 |
inc(step) |
|
559 |
end; |
|
560 |
stWater: if (not bBetweenTurns) and (not isInMultiShoot) then |
|
561 |
begin |
|
1782
e7589e37a6d6
Options for bonus box probability tuning and number of turn until sudden death
unc0rr
parents:
1781
diff
changeset
|
562 |
if TotalRounds = cSuddenDTurns + 2 then bWaterRising:= true; |
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
563 |
|
1343 | 564 |
if bWaterRising then |
565 |
AddGear(0, 0, gtWaterUp, 0, _0, _0, 0); |
|
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
566 |
|
1343 | 567 |
inc(step) |
568 |
end else inc(step); |
|
569 |
stChWin2: begin |
|
570 |
CheckForWin; |
|
571 |
inc(step) |
|
572 |
end; |
|
573 |
stHealth: begin |
|
1782
e7589e37a6d6
Options for bonus box probability tuning and number of turn until sudden death
unc0rr
parents:
1781
diff
changeset
|
574 |
if (TotalRounds = cSuddenDTurns) and (cHealthDecrease = 0) then |
1343 | 575 |
begin |
576 |
cHealthDecrease:= 5; |
|
577 |
AddCaption(trmsg[sidSuddenDeath], $FFFFFF, capgrpGameState) |
|
578 |
end; |
|
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
579 |
|
1343 | 580 |
if (cHealthDecrease = 0) |
581 |
or bBetweenTurns |
|
582 |
or isInMultiShoot |
|
583 |
or (TotalRounds = 0) then inc(step) |
|
584 |
else begin |
|
585 |
bBetweenTurns:= true; |
|
586 |
HealthMachine; |
|
2017 | 587 |
SuddenDeathDmg:= true; |
1343 | 588 |
step:= stChDmg |
589 |
end |
|
590 |
end; |
|
591 |
stSpawn: begin |
|
592 |
if not isInMultiShoot then SpawnBoxOfSmth; |
|
593 |
inc(step) |
|
594 |
end; |
|
595 |
stNTurn: begin |
|
596 |
if isInMultiShoot then isInMultiShoot:= false |
|
597 |
else begin |
|
1849 | 598 |
ResetUtilities; |
1343 | 599 |
ParseCommand('/nextturn', true); |
600 |
SwitchHedgehog; |
|
1298 | 601 |
|
2045
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
602 |
inc(step); // FIXME wtf is that, it overflows step, and does nothing |
1298 | 603 |
|
1343 | 604 |
AfterSwitchHedgehog; |
605 |
bBetweenTurns:= false |
|
606 |
end; |
|
607 |
step:= Low(step) |
|
608 |
end; |
|
609 |
end; |
|
15 | 610 |
|
4 | 611 |
if TurnTimeLeft > 0 then |
870 | 612 |
if CurrentHedgehog^.Gear <> nil then |
613 |
if ((CurrentHedgehog^.Gear^.State and gstAttacking) = 0) |
|
614 |
and not isInMultiShoot then |
|
615 |
begin |
|
616 |
if (TurnTimeLeft = 5000) |
|
617 |
and (CurrentHedgehog^.Gear <> nil) |
|
1669 | 618 |
and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0) then |
619 |
PlaySound(sndHurry, false, CurrentTeam^.voicepack); |
|
870 | 620 |
dec(TurnTimeLeft) |
621 |
end; |
|
351 | 622 |
|
2134 | 623 |
if ((GameTicks and $FFFF) = $FFFF) then |
917 | 624 |
begin |
2134 | 625 |
if (not CurrentTeam^.ExtDriven) then |
626 |
SendIPCTimeInc; |
|
627 |
||
628 |
if (not CurrentTeam^.ExtDriven) or CurrentTeam^.hasGone then |
|
629 |
inc(hiTicks) // we do not recieve a message for this |
|
917 | 630 |
end; |
656
6d6d9d7b1054
Fix network game bug caused by recent protocol changes
unc0rr
parents:
651
diff
changeset
|
631 |
|
515 | 632 |
inc(GameTicks) |
4 | 633 |
end; |
634 |
||
1854 | 635 |
//Purpose, to reset all transient attributes toggled by a utility. |
636 |
//If any of these are set as permanent toggles in the frontend, that needs to be checked and skipped here. |
|
1849 | 637 |
procedure ResetUtilities; |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
638 |
var i: LongInt; |
1849 | 639 |
begin |
2017 | 640 |
SpeechText:= ''; // in case it hasn't been consumed |
641 |
||
1895 | 642 |
if (GameFlags and gfLowGravity) = 0 then |
643 |
cGravity:= cMaxWindSpeed; |
|
644 |
||
2017 | 645 |
if (GameFlags and gfVampiric) = 0 then |
646 |
cVampiric:= false; |
|
647 |
||
1849 | 648 |
cDamageModifier:= _1; |
1895 | 649 |
|
650 |
if (GameFlags and gfLaserSight) = 0 then |
|
651 |
cLaserSighting:= false; |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
652 |
|
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
653 |
if (GameFlags and gfArtillery) = 0 then |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
654 |
cArtillery:= false; |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
655 |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
656 |
// have to sweep *all* current team hedgehogs since it is theoretically possible if you have enough invulnerabilities and switch turns to make your entire team invulnerable |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
657 |
if (CurrentTeam <> nil) then |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
658 |
with CurrentTeam^ do |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
659 |
for i:= 0 to cMaxHHIndex do |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
660 |
with Hedgehogs[i] do |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
661 |
begin |
2045
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
662 |
if (SpeechGear <> nil) then |
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
663 |
begin |
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
664 |
DeleteVisualGear(SpeechGear); // remove to restore persisting beyond end of turn. Tiy says was too much of a gameplay issue |
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
665 |
SpeechGear:= nil |
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
666 |
end; |
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
667 |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
668 |
if (Gear <> nil) then |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
669 |
if (GameFlags and gfInvulnerable) = 0 then |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
670 |
Gear^.Invulnerable:= false; |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
671 |
end; |
1849 | 672 |
end; |
2045
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
673 |
|
2017 | 674 |
procedure ApplyDamage(Gear: PGear; Damage: Longword); |
675 |
var s: shortstring; |
|
2067
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
676 |
vampDmg, tmpDmg: Longword; |
2017 | 677 |
begin |
2074 | 678 |
if (Gear^.Kind = gtHedgehog) and (Damage>=1) then |
2017 | 679 |
begin |
680 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color); |
|
2067
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
681 |
tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage)); |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
682 |
if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (tmpDmg >= 1) then |
2017 | 683 |
begin |
684 |
if cVampiric then |
|
685 |
begin |
|
2067
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
686 |
vampDmg:= hwRound(int2hwFloat(tmpDmg)*_0_8); |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
687 |
if vampDmg >= 1 then |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
688 |
begin |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
689 |
// was considering pulsing on attack, Tiy thinks it should be permanent while in play |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
690 |
//CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstVampiric; |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
691 |
inc(CurrentHedgehog^.Gear^.Health,vampDmg); |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
692 |
str(vampDmg, s); |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
693 |
s:= '+' + s; |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
694 |
AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
695 |
RenderHealth(CurrentHedgehog^); |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
696 |
RecountTeamHealth(CurrentHedgehog^.Team); |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
697 |
end |
2017 | 698 |
end; |
699 |
if ((GameFlags and gfKarma) <> 0) and |
|
700 |
((GameFlags and gfInvulnerable) = 0) and |
|
701 |
not CurrentHedgehog^.Gear^.Invulnerable then |
|
702 |
begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid |
|
2135
0b7972dfad01
Push karma application to end of round - should avoid problems w/ plane and kamikaze
nemo
parents:
2134
diff
changeset
|
703 |
inc(CurrentHedgehog^.Gear^.Karma, tmpDmg); |
2067
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
704 |
AddGear(hwRound(CurrentHedgehog^.Gear^.X), |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
705 |
hwRound(CurrentHedgehog^.Gear^.Y), |
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset
|
706 |
gtHealthTag, tmpDmg, _0, _0, 0)^.Hedgehog:= CurrentHedgehog; |
2017 | 707 |
end; |
708 |
end; |
|
709 |
end; |
|
2057
cf0d84479251
Prevent gaining more health than hedgehog actually has
nemo
parents:
2053
diff
changeset
|
710 |
inc(Gear^.Damage, Damage); |
2017 | 711 |
end; |
1849 | 712 |
|
4 | 713 |
procedure SetAllToActive; |
714 |
var t: PGear; |
|
715 |
begin |
|
716 |
AllInactive:= false; |
|
717 |
t:= GearsList; |
|
351 | 718 |
while t <> nil do |
1505 | 719 |
begin |
720 |
t^.Active:= true; |
|
721 |
t:= t^.NextGear |
|
722 |
end |
|
4 | 723 |
end; |
724 |
||
725 |
procedure SetAllHHToActive; |
|
726 |
var t: PGear; |
|
727 |
begin |
|
728 |
AllInactive:= false; |
|
729 |
t:= GearsList; |
|
351 | 730 |
while t <> nil do |
1505 | 731 |
begin |
732 |
if t^.Kind = gtHedgehog then t^.Active:= true; |
|
733 |
t:= t^.NextGear |
|
734 |
end |
|
4 | 735 |
end; |
736 |
||
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
737 |
procedure DrawHH(Gear: PGear); |
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
738 |
var i, t: LongInt; |
822 | 739 |
amt: TAmmoType; |
2020 | 740 |
hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt; // hedgehog, crosshair, temp, sprite, direction |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
741 |
lx, ly, dx, dy, ax, ay, aAngle, dAngle: real; // laser, change |
1253 | 742 |
defaultPos, HatVisible: boolean; |
1906 | 743 |
VertexBuffer: array [0..1] of TVertex2f; |
292 | 744 |
begin |
2020 | 745 |
m:= 1; |
2137 | 746 |
if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1; |
868 | 747 |
if (Gear^.State and gstHHDeath) <> 0 then |
748 |
begin |
|
749 |
DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos); |
|
750 |
exit |
|
751 |
end; |
|
1002 | 752 |
|
824 | 753 |
defaultPos:= true; |
1253 | 754 |
HatVisible:= false; |
847 | 755 |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
756 |
sx:= hwRound(Gear^.X) + 1 + WorldDx; |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
757 |
sy:= hwRound(Gear^.Y) - 3 + WorldDy; |
1002 | 758 |
if (Gear^.State and gstDrowning) <> 0 then |
759 |
begin |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
760 |
DrawHedgehog(sx, sy, |
1002 | 761 |
hwSign(Gear^.dX), |
762 |
1, |
|
763 |
7, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
764 |
0); |
1002 | 765 |
defaultPos:= false |
766 |
end else |
|
1892 | 767 |
if ((Gear^.State and gstWinner) <> 0) and |
768 |
((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then |
|
1011 | 769 |
begin |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
770 |
DrawHedgehog(sx, sy, |
1011 | 771 |
hwSign(Gear^.dX), |
772 |
2, |
|
773 |
0, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
774 |
0); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
775 |
defaultPos:= false |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
776 |
end else |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
777 |
if (Gear^.State and gstLoser) <> 0 then // for now using the jackhammer for its kind of bemused "oops" look |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
778 |
begin |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
779 |
DrawHedgehog(sx, sy, |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
780 |
hwSign(Gear^.dX), |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
781 |
2, |
2053
9a8a4add3eff
Use shrug frame for injuring yourself/team-mate, add custom theme music to Sheep theme
nemo
parents:
2045
diff
changeset
|
782 |
3, |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
783 |
0); |
1011 | 784 |
defaultPos:= false |
785 |
end else |
|
786 |
||
821
e6c0408b54ed
Use 'regular standing' and 'rope swing' hedgehog sprites
unc0rr
parents:
815
diff
changeset
|
787 |
if (Gear^.State and gstHHDriven) <> 0 then |
966 | 788 |
begin |
2028 | 789 |
if ((Gear^.State and gstHHThinking) = 0) and |
790 |
ShowCrosshair and |
|
791 |
((Gear^.State and (gstAttacked or gstAnimation)) = 0) then |
|
792 |
begin |
|
793 |
(* These calculations are a little complex for a few reasons: |
|
794 |
1: I need to draw the laser from weapon origin to nearest land |
|
795 |
2: I need to start the beam outside the hedgie for attractiveness. |
|
796 |
3: I need to extend the beam beyond land. |
|
797 |
This routine perhaps should be pushed into uStore or somesuch instead of continuuing the increase in size of this function. |
|
798 |
*) |
|
799 |
dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle); |
|
800 |
dy:= - Cos(Gear^.Angle * pi / cMaxAngle); |
|
801 |
if cLaserSighting then |
|
802 |
begin |
|
803 |
lx:= hwRound(Gear^.X); |
|
804 |
ly:= hwRound(Gear^.Y); |
|
805 |
lx:= lx + dx * 16; |
|
806 |
ly:= ly + dy * 16; |
|
807 |
||
808 |
ax:= dx * 4; |
|
809 |
ay:= dy * 4; |
|
810 |
||
811 |
tx:= round(lx); |
|
812 |
ty:= round(ly); |
|
813 |
hx:= tx; |
|
814 |
hy:= ty; |
|
815 |
while ((ty and LAND_HEIGHT_MASK) = 0) and |
|
816 |
((tx and LAND_WIDTH_MASK) = 0) and |
|
817 |
(Land[ty, tx] = 0) do |
|
818 |
begin |
|
819 |
lx:= lx + ax; |
|
820 |
ly:= ly + ay; |
|
821 |
tx:= round(lx); |
|
822 |
ty:= round(ly) |
|
823 |
end; |
|
824 |
// reached edge of land. assume infinite beam. Extend it way out past camera |
|
825 |
if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then |
|
826 |
begin |
|
827 |
tx:= round(lx + ax * (LAND_WIDTH div 4)); |
|
828 |
ty:= round(ly + ay * (LAND_WIDTH div 4)); |
|
829 |
end; |
|
830 |
||
831 |
//if (abs(lx-tx)>8) or (abs(ly-ty)>8) then |
|
832 |
begin |
|
833 |
glDisable(GL_TEXTURE_2D); |
|
834 |
glEnable(GL_LINE_SMOOTH); |
|
835 |
||
836 |
glColor4ub($FF, $00, $00, $C0); |
|
837 |
VertexBuffer[0].X:= hx + WorldDx; |
|
838 |
VertexBuffer[0].Y:= hy + WorldDy; |
|
839 |
VertexBuffer[1].X:= tx + WorldDx; |
|
840 |
VertexBuffer[1].Y:= ty + WorldDy; |
|
841 |
||
842 |
glEnableClientState(GL_VERTEX_ARRAY); |
|
843 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
844 |
glDrawArrays(GL_LINES, 0, Length(VertexBuffer)); |
|
845 |
glColor4f(1, 1, 1, 1); |
|
846 |
glEnable(GL_TEXTURE_2D); |
|
847 |
glDisable(GL_LINE_SMOOTH); |
|
848 |
end; |
|
849 |
end; |
|
850 |
// draw crosshair |
|
851 |
cx:= Round(hwRound(Gear^.X) + dx * 80); |
|
852 |
cy:= Round(hwRound(Gear^.Y) + dy * 80); |
|
853 |
DrawRotatedTex(PHedgehog(Gear^.Hedgehog)^.Team^.CrosshairTex, |
|
854 |
12, 12, cx + WorldDx, cy + WorldDy, 0, |
|
855 |
hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle); |
|
856 |
end; |
|
1002 | 857 |
hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx; |
858 |
hy:= hwRound(Gear^.Y) - 2 + WorldDy; |
|
859 |
aangle:= Gear^.Angle * 180 / cMaxAngle - 90; |
|
874 | 860 |
|
1002 | 861 |
if CurAmmoGear <> nil then |
862 |
begin |
|
863 |
case CurAmmoGear^.Kind of |
|
1294
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
864 |
gtShotgunShot: begin |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
865 |
if (CurAmmoGear^.State and gstAnimation <> 0) then |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
866 |
DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle) |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
867 |
else |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
868 |
DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
869 |
end; |
1002 | 870 |
gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle); |
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
871 |
gtSniperRifleShot: begin |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
872 |
if (CurAmmoGear^.State and gstAnimation <> 0) then |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
873 |
DrawRotatedF(sprSniperRifle, hx, hy, 1, hwSign(Gear^.dX), aangle) |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
874 |
else |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
875 |
DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle) |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
876 |
end; |
1601 | 877 |
gtBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle); |
1717 | 878 |
gtRCPlane: begin |
879 |
DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0); |
|
880 |
defaultPos:= false |
|
881 |
end; |
|
1002 | 882 |
gtRope: begin |
883 |
if Gear^.X < CurAmmoGear^.X then |
|
884 |
begin |
|
885 |
dAngle:= 0; |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
886 |
i:= 1 |
1002 | 887 |
end else |
888 |
begin |
|
889 |
dAngle:= 180; |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
890 |
i:= -1 |
966 | 891 |
end; |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
892 |
sx:= hwRound(Gear^.X) + WorldDx; |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
893 |
sy:= hwRound(Gear^.Y) + WorldDy; |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
894 |
DrawHedgehog(sx, sy, |
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
895 |
i, |
1002 | 896 |
1, |
897 |
0, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
898 |
DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle); |
1002 | 899 |
defaultPos:= false |
900 |
end; |
|
901 |
gtBlowTorch: begin |
|
902 |
DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
903 |
DrawHedgehog(sx, sy, |
1002 | 904 |
hwSign(Gear^.dX), |
905 |
3, |
|
1113 | 906 |
PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
907 |
0); |
1002 | 908 |
defaultPos:= false |
909 |
end; |
|
910 |
gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180); |
|
911 |
gtFirePunch: begin |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
912 |
DrawHedgehog(sx, sy, |
1002 | 913 |
hwSign(Gear^.dX), |
914 |
1, |
|
915 |
4, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
916 |
0); |
1002 | 917 |
defaultPos:= false |
918 |
end; |
|
1892 | 919 |
gtPickHammer: begin |
920 |
defaultPos:= false; |
|
921 |
dec(sy,20); |
|
922 |
end; |
|
1002 | 923 |
gtTeleport: defaultPos:= false; |
1010 | 924 |
gtWhip: begin |
925 |
DrawRotatedF(sprWhip, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
926 |
sx, |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
927 |
sy, |
1010 | 928 |
1, |
929 |
hwSign(Gear^.dX), |
|
930 |
0); |
|
931 |
defaultPos:= false |
|
932 |
end; |
|
1002 | 933 |
gtKamikaze: begin |
1286 | 934 |
if CurAmmoGear^.Pos = 0 then |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
935 |
DrawHedgehog(sx, sy, |
1286 | 936 |
hwSign(Gear^.dX), |
937 |
1, |
|
938 |
6, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
939 |
0) |
1286 | 940 |
else |
941 |
DrawRotatedF(sprKamikaze, |
|
942 |
hwRound(Gear^.X) + WorldDx, |
|
943 |
hwRound(Gear^.Y) + WorldDy, |
|
944 |
CurAmmoGear^.Pos - 1, |
|
2025
692308790912
Adjust routines impacted by DrawRotatedF modification, clear gstHHHJump in rope to avoid crosshair/hat drawing bug.
nemo
parents:
2023
diff
changeset
|
945 |
hwSign(Gear^.dX), |
692308790912
Adjust routines impacted by DrawRotatedF modification, clear gstHHHJump in rope to avoid crosshair/hat drawing bug.
nemo
parents:
2023
diff
changeset
|
946 |
aangle); |
1286 | 947 |
defaultPos:= false |
948 |
end; |
|
949 |
gtSeduction: begin |
|
950 |
if CurAmmoGear^.Pos >= 6 then |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
951 |
DrawHedgehog(sx, sy, |
1286 | 952 |
hwSign(Gear^.dX), |
953 |
2, |
|
954 |
2, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
955 |
0) |
1286 | 956 |
else |
957 |
begin |
|
958 |
DrawRotatedF(sprDress, |
|
959 |
hwRound(Gear^.X) + WorldDx, |
|
960 |
hwRound(Gear^.Y) + WorldDy, |
|
961 |
CurAmmoGear^.Pos, |
|
962 |
hwSign(Gear^.dX), |
|
963 |
0); |
|
964 |
DrawSprite(sprCensored, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 20 + WorldDy, 0) |
|
965 |
end; |
|
966 |
defaultPos:= false |
|
967 |
end; |
|
1002 | 968 |
end; |
969 |
||
970 |
case CurAmmoGear^.Kind of |
|
971 |
gtShotgunShot, |
|
972 |
gtDEagleShot, |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
973 |
gtSniperRifleShot, |
1002 | 974 |
gtShover: begin |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
975 |
DrawHedgehog(sx, sy, |
1002 | 976 |
hwSign(Gear^.dX), |
977 |
0, |
|
978 |
4, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
979 |
0); |
1977 | 980 |
defaultPos:= false; |
981 |
HatVisible:= true |
|
1002 | 982 |
end |
983 |
end |
|
984 |
end else |
|
876 | 985 |
|
1002 | 986 |
if ((Gear^.State and gstHHJumping) <> 0) then |
987 |
begin |
|
2020 | 988 |
DrawHedgehog(sx, sy, |
989 |
hwSign(Gear^.dX)*m, |
|
990 |
1, |
|
991 |
1, |
|
992 |
0); |
|
993 |
HatVisible:= true; |
|
2017 | 994 |
HatVisible:= true; |
1002 | 995 |
defaultPos:= false |
996 |
end else |
|
874 | 997 |
|
1913 | 998 |
if (Gear^.Message and (gm_Left or gm_Right) <> 0) and (not isCursorVisible) then |
824 | 999 |
begin |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1000 |
DrawHedgehog(sx, sy, |
1002 | 1001 |
hwSign(Gear^.dX), |
1002 |
0, |
|
1003 |
PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1004 |
0); |
1257 | 1005 |
defaultPos:= false; |
1006 |
HatVisible:= true |
|
1002 | 1007 |
end |
1008 |
else |
|
1009 |
||
1033 | 1010 |
if ((Gear^.State and gstAnimation) <> 0) then |
1011 |
begin |
|
1034 | 1012 |
DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite, |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1013 |
sx, |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1014 |
sy, |
1033 | 1015 |
Gear^.Pos, |
1016 |
hwSign(Gear^.dX), |
|
1017 |
0.0); |
|
1018 |
defaultPos:= false |
|
1019 |
end |
|
1020 |
else |
|
1002 | 1021 |
if ((Gear^.State and gstAttacked) = 0) then |
1022 |
begin |
|
1023 |
amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType; |
|
1024 |
case amt of |
|
1025 |
amBazooka, |
|
1717 | 1026 |
amMortar: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle); |
1027 |
amBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle); |
|
1028 |
amDrill: DrawRotated(sprHandDrill, hx, hy, hwSign(Gear^.dX), aangle); |
|
1002 | 1029 |
amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle); |
1030 |
amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); |
|
1031 |
amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle); |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
1032 |
amSniperRifle: DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle); |
1002 | 1033 |
amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); |
1717 | 1034 |
amRCPlane: begin |
1035 |
DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0); |
|
1036 |
defaultPos:= false |
|
1037 |
end; |
|
1939 | 1038 |
amGirder: begin |
1039 |
DrawSpriteClipped(sprGirder, |
|
1040 |
sx-256, |
|
1041 |
sy-256, |
|
1042 |
LongInt(topY)+WorldDy, |
|
1043 |
LongInt(rightX)+WorldDx, |
|
1044 |
cWaterLine+WorldDy, |
|
1045 |
LongInt(leftX)+WorldDx); |
|
1046 |
end; |
|
1002 | 1047 |
end; |
1048 |
||
1049 |
case amt of |
|
1050 |
amAirAttack, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1051 |
amMineStrike: DrawRotated(sprHandAirAttack, sx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1052 |
amPickHammer: DrawHedgehog(sx, sy, |
1002 | 1053 |
hwSign(Gear^.dX), |
1054 |
1, |
|
1055 |
2, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1056 |
0); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1057 |
amBlowTorch: DrawHedgehog(sx, sy, |
1002 | 1058 |
hwSign(Gear^.dX), |
1059 |
1, |
|
1060 |
3, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1061 |
0); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1062 |
amTeleport: DrawRotatedF(sprTeleport, sx, sy, 0, hwSign(Gear^.dX), 0); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1063 |
amKamikaze: DrawHedgehog(sx, sy, |
1002 | 1064 |
hwSign(Gear^.dX), |
1065 |
1, |
|
1066 |
5, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1067 |
0); |
1221 | 1068 |
amWhip: DrawRotatedF(sprWhip, |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1069 |
sx, |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1070 |
sy, |
1010 | 1071 |
0, |
1072 |
hwSign(Gear^.dX), |
|
1073 |
0); |
|
1002 | 1074 |
else |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1075 |
DrawHedgehog(sx, sy, |
822 | 1076 |
hwSign(Gear^.dX), |
1077 |
0, |
|
1002 | 1078 |
4, |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1079 |
0); |
1253 | 1080 |
|
1081 |
HatVisible:= true; |
|
1082 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
1294
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
1083 |
if (HatTex <> nil) |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1084 |
and (HatVisibility > 0) then |
1253 | 1085 |
DrawTextureF(HatTex, |
1086 |
HatVisibility, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1087 |
sx, |
1253 | 1088 |
hwRound(Gear^.Y) - 8 + WorldDy, |
1089 |
0, |
|
1090 |
hwSign(Gear^.dX), |
|
1091 |
32); |
|
1002 | 1092 |
end; |
966 | 1093 |
|
1002 | 1094 |
case amt of |
1095 |
amBaseballBat: DrawRotated(sprHandBaseball, |
|
1096 |
hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx, |
|
1097 |
hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle); |
|
1098 |
end; |
|
966 | 1099 |
|
1002 | 1100 |
defaultPos:= false |
1101 |
end |
|
1102 |
end else // not gstHHDriven |
|
1012 | 1103 |
begin |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
1104 |
if (Gear^.Damage > 0) |
2028 | 1105 |
and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
1106 |
begin |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1107 |
DrawHedgehog(sx, sy, |
1012 | 1108 |
hwSign(Gear^.dX), |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
1109 |
2, |
1012 | 1110 |
1, |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1111 |
Gear^.DirAngle); |
1012 | 1112 |
defaultPos:= false |
1020 | 1113 |
end else |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
1114 |
|
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
1115 |
if ((Gear^.State and gstHHJumping) <> 0) then |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
1116 |
begin |
2020 | 1117 |
DrawHedgehog(sx, sy, |
1118 |
hwSign(Gear^.dX)*m, |
|
1119 |
1, |
|
1120 |
1, |
|
1121 |
0); |
|
1122 |
defaultPos:= false |
|
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
1123 |
end; |
1012 | 1124 |
end; |
834 | 1125 |
|
1251 | 1126 |
with PHedgehog(Gear^.Hedgehog)^ do |
970 | 1127 |
begin |
1251 | 1128 |
if defaultPos then |
1129 |
begin |
|
1130 |
DrawRotatedF(sprHHIdle, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1131 |
sx, |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1132 |
sy, |
1251 | 1133 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
1134 |
hwSign(Gear^.dX), |
|
1135 |
0); |
|
1253 | 1136 |
HatVisible:= true; |
1137 |
end; |
|
1138 |
||
1139 |
if HatVisible then |
|
1251 | 1140 |
if HatVisibility < 1.0 then |
1254 | 1141 |
HatVisibility:= HatVisibility + 0.2 |
1253 | 1142 |
else |
1251 | 1143 |
else |
1144 |
if HatVisibility > 0.0 then |
|
1254 | 1145 |
HatVisibility:= HatVisibility - 0.2; |
1253 | 1146 |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1147 |
if (HatTex <> nil) |
1294
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
1148 |
and (HatVisibility > 0) then |
1255 | 1149 |
if DefaultPos then |
1150 |
DrawTextureF(HatTex, |
|
1151 |
HatVisibility, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1152 |
sx, |
1255 | 1153 |
hwRound(Gear^.Y) - 8 + WorldDy, |
1154 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
|
1155 |
hwSign(Gear^.dX), |
|
1156 |
32) |
|
1157 |
else |
|
1158 |
DrawTextureF(HatTex, |
|
1159 |
HatVisibility, |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1160 |
sx, |
1255 | 1161 |
hwRound(Gear^.Y) - 8 + WorldDy, |
1162 |
0, |
|
2020 | 1163 |
hwSign(Gear^.dX)*m, |
1255 | 1164 |
32); |
970 | 1165 |
end; |
292 | 1166 |
|
1251 | 1167 |
|
351 | 1168 |
with PHedgehog(Gear^.Hedgehog)^ do |
994 | 1169 |
begin |
1011 | 1170 |
if ((Gear^.State and not gstWinner) = 0) |
994 | 1171 |
or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then |
958 | 1172 |
begin |
1660 | 1173 |
t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy; |
1174 |
if (cTagsMask and 1) <> 0 then |
|
1175 |
begin |
|
1176 |
dec(t, HealthTagTex^.h + 2); |
|
1177 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex) |
|
1178 |
end; |
|
1179 |
if (cTagsMask and 2) <> 0 then |
|
1180 |
begin |
|
1181 |
dec(t, NameTagTex^.h + 2); |
|
1182 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTagTex) |
|
1183 |
end; |
|
1184 |
if (cTagsMask and 4) <> 0 then |
|
1185 |
begin |
|
1186 |
dec(t, Team^.NameTagTex^.h + 2); |
|
1187 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex) |
|
1188 |
end |
|
958 | 1189 |
end; |
994 | 1190 |
if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog |
958 | 1191 |
begin |
1192 |
if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then |
|
1193 |
DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy, |
|
1194 |
GameTicks div 32 mod 16); |
|
821
e6c0408b54ed
Use 'regular standing' and 'rope swing' hedgehog sprites
unc0rr
parents:
815
diff
changeset
|
1195 |
|
958 | 1196 |
if (Gear^.State and gstDrowning) = 0 then |
1197 |
if (Gear^.State and gstHHThinking) <> 0 then |
|
1198 |
DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, 0) |
|
2028 | 1199 |
end |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1200 |
end; |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1201 |
|
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1202 |
if Gear^.Invulnerable then |
2017 | 1203 |
begin |
1204 |
DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0); |
|
1205 |
end; |
|
1206 |
if cVampiric and |
|
1207 |
(CurrentHedgehog^.Gear <> nil) and |
|
1208 |
(CurrentHedgehog^.Gear = Gear) then |
|
1209 |
begin |
|
1210 |
DrawSprite(sprVampiric, sx - 24, sy - 24, 0); |
|
1211 |
end; |
|
292 | 1212 |
end; |
1213 |
||
956 | 1214 |
procedure DrawGears; |
853 | 1215 |
var Gear, HHGear: PGear; |
4 | 1216 |
i: Longword; |
371 | 1217 |
roplen: LongInt; |
4 | 1218 |
|
371 | 1219 |
procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt); |
1220 |
var eX, eY, dX, dY: LongInt; |
|
1221 |
i, sX, sY, x, y, d: LongInt; |
|
366 | 1222 |
b: boolean; |
4 | 1223 |
begin |
37 | 1224 |
if (X1 = X2) and (Y1 = Y2) then |
1225 |
begin |
|
2070 | 1226 |
//OutError('WARNING: zero length rope line!', false); |
37 | 1227 |
exit |
1228 |
end; |
|
366 | 1229 |
eX:= 0; |
1230 |
eY:= 0; |
|
1231 |
dX:= X2 - X1; |
|
1232 |
dY:= Y2 - Y1; |
|
1233 |
||
1234 |
if (dX > 0) then sX:= 1 |
|
1235 |
else |
|
1236 |
if (dX < 0) then |
|
1237 |
begin |
|
1238 |
sX:= -1; |
|
1239 |
dX:= -dX |
|
1240 |
end else sX:= dX; |
|
1241 |
||
1242 |
if (dY > 0) then sY:= 1 |
|
1243 |
else |
|
1244 |
if (dY < 0) then |
|
4 | 1245 |
begin |
366 | 1246 |
sY:= -1; |
1247 |
dY:= -dY |
|
1248 |
end else sY:= dY; |
|
1249 |
||
1250 |
if (dX > dY) then d:= dX |
|
1251 |
else d:= dY; |
|
1252 |
||
1253 |
x:= X1; |
|
1254 |
y:= Y1; |
|
1255 |
||
1256 |
for i:= 0 to d do |
|
1257 |
begin |
|
1258 |
inc(eX, dX); |
|
1259 |
inc(eY, dY); |
|
1260 |
b:= false; |
|
1261 |
if (eX > d) then |
|
35 | 1262 |
begin |
366 | 1263 |
dec(eX, d); |
1264 |
inc(x, sX); |
|
1265 |
b:= true |
|
35 | 1266 |
end; |
366 | 1267 |
if (eY > d) then |
35 | 1268 |
begin |
366 | 1269 |
dec(eY, d); |
1270 |
inc(y, sY); |
|
1271 |
b:= true |
|
35 | 1272 |
end; |
366 | 1273 |
if b then |
1274 |
begin |
|
1275 |
inc(roplen); |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1276 |
if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0) |
366 | 1277 |
end |
4 | 1278 |
end |
366 | 1279 |
end; |
4 | 1280 |
|
1281 |
begin |
|
1282 |
Gear:= GearsList; |
|
1283 |
while Gear<>nil do |
|
1689 | 1284 |
begin |
1285 |
case Gear^.Kind of |
|
822 | 1286 |
gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
1689 | 1287 |
|
1696 | 1288 |
gtRCPlane: if (Gear^.Tag = -1) then |
1689 | 1289 |
DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, -1, DxDy2Angle(Gear^.dX, Gear^.dY) + 90) |
1290 |
else |
|
1291 |
DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,0,DxDy2Angle(Gear^.dY, Gear^.dX)); |
|
1292 |
||
1601 | 1293 |
gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1689 | 1294 |
|
1573 | 1295 |
gtDrill: DrawRotated(sprDrill, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1689 | 1296 |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1297 |
gtHedgehog: DrawHH(Gear); |
1689 | 1298 |
|
822 | 1299 |
gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1689 | 1300 |
|
1505 | 1301 |
gtHealthTag: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex); |
2017 | 1302 |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1303 |
gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex); |
1689 | 1304 |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1305 |
gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4); |
1689 | 1306 |
|
848 | 1307 |
gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0); |
4 | 1308 |
gtRope: begin |
35 | 1309 |
roplen:= 0; |
4 | 1310 |
if RopePoints.Count > 0 then |
1311 |
begin |
|
1312 |
i:= 0; |
|
1313 |
while i < Pred(RopePoints.Count) do |
|
1314 |
begin |
|
351 | 1315 |
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
1316 |
hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy); |
|
4 | 1317 |
inc(i) |
1318 |
end; |
|
351 | 1319 |
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
1320 |
hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy); |
|
1321 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
|
1322 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 1323 |
DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) |
4 | 1324 |
end else |
1781 | 1325 |
if Gear^.Elasticity.QWordValue > 0 then |
35 | 1326 |
begin |
351 | 1327 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
1328 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 1329 |
DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
35 | 1330 |
end; |
4 | 1331 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1332 |
gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
1012 | 1333 |
gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State); |
351 | 1334 |
gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420) |
822 | 1335 |
then DrawRotated(sprMineOff, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle) |
1336 |
else DrawRotated(sprMineOn, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
|
351 | 1337 |
gtCase: case Gear^.Pos of |
1794 | 1338 |
posCaseAmmo : begin |
1339 |
i:= (GameTicks shr 6) mod 64; |
|
1340 |
if i > 18 then i:= 0; |
|
1341 |
DrawSprite(sprCase, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i); |
|
1342 |
end; |
|
1009 | 1343 |
posCaseHealth: begin |
1863 | 1344 |
i:= ((GameTicks shr 6) + 38) mod 64; |
1345 |
if i > 13 then i:= 0; |
|
1009 | 1346 |
DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i); |
1347 |
end; |
|
1861 | 1348 |
posCaseUtility: begin |
1863 | 1349 |
i:= (GameTicks shr 6) mod 70; |
1350 |
if i > 23 then i:= 0; |
|
1909 | 1351 |
i:= i mod 12; |
1863 | 1352 |
DrawSprite(sprUtility, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i); |
1861 | 1353 |
end; |
42 | 1354 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1355 |
gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1); |
822 | 1356 |
gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1357 |
gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0); |
1560
e140bc57ff68
Quick replay round to spectators until current move
unc0rr
parents:
1555
diff
changeset
|
1358 |
gtFlame: DrawSprite(sprFlame, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, (GameTicks div 128 + LongWord(Gear^.Tag)) mod 8); |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1359 |
gtParachute: DrawSprite(sprParachute, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 48 + WorldDy, 0); |
2168 | 1360 |
gtAirAttack: if Gear^.Tag > 0 then DrawSprite(sprAirplane, hwRound(Gear^.X) - SpritesData[sprAirplane].Width div 2 + WorldDx, hwRound(Gear^.Y) - SpritesData[sprAirplane].Height div 2 + WorldDy, 0) |
1361 |
else DrawSprite(sprAirplane, hwRound(Gear^.X) - SpritesData[sprAirplane].Width div 2 + WorldDx, hwRound(Gear^.Y) - SpritesData[sprAirplane].Height div 2 + WorldDy, 1); |
|
822 | 1362 |
gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
853 | 1363 |
gtTeleport: begin |
1364 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1365 |
DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
1366 |
DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
1367 |
end; |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1368 |
gtSwitcher: DrawSprite(sprSwitch, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 56 + WorldDy, (GameTicks shr 6) mod 12); |
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1369 |
gtTarget: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
959 | 1370 |
gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1108 | 1371 |
gtCake: if Gear^.Pos = 6 then |
2025
692308790912
Adjust routines impacted by DrawRotatedF modification, clear gstHHHJump in rope to avoid crosshair/hat drawing bug.
nemo
parents:
2023
diff
changeset
|
1372 |
DrawRotatedf(sprCakeWalk, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90) |
1108 | 1373 |
else |
1262 | 1374 |
DrawRotatedf(sprCakeDown, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 5 - Gear^.Pos, hwSign(Gear^.dX), 0); |
1367 | 1375 |
gtSeduction: if Gear^.Pos >= 14 then DrawSprite(sprSeduction, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
1262 | 1376 |
gtWatermelon: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 0, Gear^.DirAngle); |
1377 |
gtMelonPiece: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 1, 0, Gear^.DirAngle); |
|
1263 | 1378 |
gtHellishBomb: DrawRotated(sprHellishBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
1379 |
gtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
|
1380 |
end; |
|
351 | 1381 |
Gear:= Gear^.NextGear |
4 | 1382 |
end; |
1383 |
end; |
|
1384 |
||
1385 |
procedure FreeGearsList; |
|
1386 |
var t, tt: PGear; |
|
1387 |
begin |
|
1388 |
tt:= GearsList; |
|
1389 |
GearsList:= nil; |
|
1505 | 1390 |
while tt <> nil do |
1391 |
begin |
|
1392 |
t:= tt; |
|
1393 |
tt:= tt^.NextGear; |
|
1394 |
Dispose(t) |
|
1395 |
end; |
|
4 | 1396 |
end; |
1397 |
||
10 | 1398 |
procedure AddMiscGears; |
371 | 1399 |
var i: LongInt; |
1515 | 1400 |
Gear: PGear; |
4 | 1401 |
begin |
498 | 1402 |
AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000); |
1435
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
1403 |
|
1895 | 1404 |
if ((GameFlags and gfForts) = 0) and ((GameFlags and gfMines) <> 0) then |
1435
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
1405 |
for i:= 0 to Pred(cLandAdditions) do |
1515 | 1406 |
begin |
1407 |
Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0); |
|
1760 | 1408 |
FindPlace(Gear, false, 0, LAND_WIDTH) |
1895 | 1409 |
end; |
1410 |
||
1411 |
if (GameFlags and gfLowGravity) <> 0 then |
|
1412 |
cGravity:= cMaxWindSpeed / 2; |
|
1413 |
||
2017 | 1414 |
if (GameFlags and gfVampiric) <> 0 then |
1415 |
cVampiric:= true; |
|
1416 |
||
1895 | 1417 |
Gear:= GearsList; |
1418 |
if (GameFlags and gfInvulnerable) <> 0 then |
|
1419 |
while Gear <> nil do |
|
1420 |
begin |
|
1421 |
Gear^.Invulnerable:= true; // this is only checked on hogs right now, so no need for gear type check |
|
1422 |
Gear:= Gear^.NextGear |
|
1423 |
end; |
|
1424 |
||
1425 |
if (GameFlags and gfLaserSight) <> 0 then |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
1426 |
cLaserSighting:= true; |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
1427 |
|
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
1428 |
if (GameFlags and gfArtillery) <> 0 then |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset
|
1429 |
cArtillery:= true |
4 | 1430 |
end; |
1431 |
||
371 | 1432 |
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); |
4 | 1433 |
var Gear: PGear; |
506 | 1434 |
dmg, dmgRadius: LongInt; |
4 | 1435 |
begin |
1436 |
TargetPoint.X:= NoPointX; |
|
1434 | 1437 |
{$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF} |
1049 | 1438 |
if (Radius > 10) then AddGear(X, Y, gtExplosion, 0, _0, _0, 0); |
1669 | 1439 |
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false, nil); |
1433 | 1440 |
|
1441 |
if (Mask and EXPLAllDamageInRadius) = 0 then |
|
1442 |
dmgRadius:= Radius shl 1 |
|
1443 |
else |
|
1444 |
dmgRadius:= Radius; |
|
1445 |
||
4 | 1446 |
Gear:= GearsList; |
1447 |
while Gear <> nil do |
|
1200 | 1448 |
begin |
1449 |
dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
|
1450 |
if (dmg > 1) and |
|
1451 |
((Gear^.State and gstNoDamage) = 0) then |
|
1452 |
begin |
|
1861 | 1453 |
dmg:= modifyDamage(min(dmg div 2, Radius)); |
1200 | 1454 |
case Gear^.Kind of |
1455 |
gtHedgehog, |
|
1456 |
gtMine, |
|
1457 |
gtCase, |
|
1458 |
gtTarget, |
|
1459 |
gtFlame: begin |
|
1346 | 1460 |
//{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} |
1200 | 1461 |
if (Mask and EXPLNoDamage) = 0 then |
1462 |
begin |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1463 |
if not Gear^.Invulnerable then |
2017 | 1464 |
ApplyDamage(Gear, dmg) |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1465 |
else |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1466 |
Gear^.State:= Gear^.State or gstWinner; |
1200 | 1467 |
end; |
1468 |
if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then |
|
1469 |
begin |
|
1470 |
DeleteCI(Gear); |
|
1471 |
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X)); |
|
1472 |
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y)); |
|
1868 | 1473 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser); |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1474 |
if not Gear^.Invulnerable then |
1868 | 1475 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); |
1200 | 1476 |
Gear^.Active:= true; |
1477 |
FollowGear:= Gear |
|
1478 |
end; |
|
1479 |
end; |
|
1480 |
gtGrave: begin |
|
1481 |
Gear^.dY:= - _0_004 * dmg; |
|
1482 |
Gear^.Active:= true; |
|
1483 |
end; |
|
1484 |
end; |
|
1485 |
end; |
|
1486 |
Gear:= Gear^.NextGear |
|
1487 |
end; |
|
1488 |
||
621 | 1489 |
if (Mask and EXPLDontDraw) = 0 then |
1200 | 1490 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(X, Y, Radius); |
1491 |
||
498 | 1492 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
4 | 1493 |
end; |
1494 |
||
506 | 1495 |
procedure ShotgunShot(Gear: PGear); |
1496 |
var t: PGear; |
|
955 | 1497 |
dmg: LongInt; |
506 | 1498 |
begin |
509 | 1499 |
Gear^.Radius:= cShotgunRadius; |
506 | 1500 |
t:= GearsList; |
1501 |
while t <> nil do |
|
1286 | 1502 |
begin |
1861 | 1503 |
dmg:= modifyDamage(min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25)); |
1286 | 1504 |
if dmg > 0 then |
1505 |
case t^.Kind of |
|
1506 |
gtHedgehog, |
|
1507 |
gtMine, |
|
1508 |
gtCase, |
|
1509 |
gtTarget: begin |
|
1854 | 1510 |
if (not t^.Invulnerable) then |
2017 | 1511 |
ApplyDamage(t, dmg) |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1512 |
else |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1513 |
Gear^.State:= Gear^.State or gstWinner; |
867 | 1514 |
|
1286 | 1515 |
DeleteCI(t); |
1516 |
t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); |
|
1517 |
t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; |
|
1518 |
t^.State:= t^.State or gstMoving; |
|
1519 |
t^.Active:= true; |
|
1520 |
FollowGear:= t |
|
1521 |
end; |
|
1522 |
gtGrave: begin |
|
1523 |
t^.dY:= - _0_1; |
|
1524 |
t^.Active:= true |
|
1525 |
end; |
|
1526 |
end; |
|
1527 |
t:= t^.NextGear |
|
1528 |
end; |
|
621 | 1529 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) |
506 | 1530 |
end; |
1531 |
||
371 | 1532 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
53 | 1533 |
var t: PGearArray; |
371 | 1534 |
i: LongInt; |
38 | 1535 |
begin |
53 | 1536 |
t:= CheckGearsCollision(Ammo); |
351 | 1537 |
i:= t^.Count; |
1506 | 1538 |
|
1861 | 1539 |
Damage:= modifyDamage(Damage); |
1540 |
||
53 | 1541 |
while i > 0 do |
981 | 1542 |
begin |
1543 |
dec(i); |
|
1544 |
if (t^.ar[i]^.State and gstNoDamage) = 0 then |
|
1545 |
case t^.ar[i]^.Kind of |
|
1546 |
gtHedgehog, |
|
1547 |
gtMine, |
|
1548 |
gtTarget, |
|
1549 |
gtCase: begin |
|
1573 | 1550 |
if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end; |
1854 | 1551 |
if (not t^.ar[i]^.Invulnerable) then |
2017 | 1552 |
ApplyDamage(t^.ar[i], Damage) |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1553 |
else |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1554 |
t^.ar[i]^.State:= t^.ar[i]^.State or gstWinner; |
867 | 1555 |
|
981 | 1556 |
DeleteCI(t^.ar[i]); |
1557 |
t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01; |
|
1558 |
t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01; |
|
1559 |
t^.ar[i]^.Active:= true; |
|
1560 |
t^.ar[i]^.State:= t^.ar[i]^.State or gstMoving; |
|
867 | 1561 |
|
982 | 1562 |
if TestCollisionXwithGear(t^.ar[i], hwSign(t^.ar[i]^.dX)) then |
981 | 1563 |
begin |
1564 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -3, hwSign(t^.ar[i]^.dX)) |
|
1565 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1566 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX)) |
|
1567 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1568 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX)) |
|
1569 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1570 |
end; |
|
982 | 1571 |
|
981 | 1572 |
FollowGear:= t^.ar[i] |
1573 |
end; |
|
1574 |
end |
|
1575 |
end; |
|
126 | 1576 |
SetAllToActive |
38 | 1577 |
end; |
1578 |
||
4 | 1579 |
procedure AssignHHCoords; |
955 | 1580 |
var i, t, p, j: LongInt; |
1760 | 1581 |
ar: array[0..Pred(cMaxHHs)] of PHedgehog; |
1582 |
Count: Longword; |
|
4 | 1583 |
begin |
1428 | 1584 |
if (GameFlags and (gfForts or gfDivideTeams)) <> 0 then |
955 | 1585 |
begin |
1586 |
t:= 0; |
|
1428 | 1587 |
TryDo(ClansCount = 2, 'More or less than 2 clans on map in divided teams mode!', true); |
955 | 1588 |
for p:= 0 to 1 do |
1589 |
begin |
|
1590 |
with ClansArray[p]^ do |
|
1591 |
for j:= 0 to Pred(TeamsNumber) do |
|
1592 |
with Teams[j]^ do |
|
1593 |
for i:= 0 to cMaxHHIndex do |
|
1594 |
with Hedgehogs[i] do |
|
958 | 1595 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
1596 |
begin |
|
1760 | 1597 |
FindPlace(Gear, false, t, t + LAND_WIDTH div 2);// could make Gear == nil |
1515 | 1598 |
if Gear <> nil then |
1599 |
begin |
|
1784 | 1600 |
Gear^.Pos:= GetRandom(49); |
1515 | 1601 |
Gear^.dX.isNegative:= p = 1; |
1602 |
end |
|
958 | 1603 |
end; |
1760 | 1604 |
t:= LAND_WIDTH div 2 |
955 | 1605 |
end |
1606 |
end else // mix hedgehogs |
|
1607 |
begin |
|
1608 |
Count:= 0; |
|
1609 |
for p:= 0 to Pred(TeamsCount) do |
|
1610 |
with TeamsArray[p]^ do |
|
1611 |
begin |
|
1612 |
for i:= 0 to cMaxHHIndex do |
|
1613 |
with Hedgehogs[i] do |
|
1614 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
|
1615 |
begin |
|
1515 | 1616 |
ar[Count]:= @Hedgehogs[i]; |
955 | 1617 |
inc(Count) |
1618 |
end; |
|
1619 |
end; |
|
1792 | 1620 |
// unC0Rr, while it is true user can watch value on map screen, IMO this (and check above) should be enforced in UI |
1621 |
// - is there a good place to put values for the different widgets to check? Right now they are kind of disconnected. |
|
1965 | 1622 |
//it would be nice if divide teams, forts mode and hh per map could all be checked by the team widget, or maybe disable start button |
1795 | 1623 |
TryDo(Count <= MaxHedgehogs, 'Too many hedgehogs for this map! (max # is ' + inttostr(MaxHedgehogs) + ')', true); |
955 | 1624 |
while (Count > 0) do |
1625 |
begin |
|
1626 |
i:= GetRandom(Count); |
|
1760 | 1627 |
FindPlace(ar[i]^.Gear, false, 0, LAND_WIDTH); |
1515 | 1628 |
if ar[i]^.Gear <> nil then |
1629 |
begin |
|
1760 | 1630 |
ar[i]^.Gear^.dX.isNegative:= hwRound(ar[i]^.Gear^.X) > LAND_WIDTH div 2; |
1776 | 1631 |
ar[i]^.Gear^.Pos:= GetRandom(19) |
1515 | 1632 |
end; |
1776 | 1633 |
ar[i]:= ar[Count - 1]; |
955 | 1634 |
dec(Count) |
1635 |
end |
|
1636 |
end |
|
4 | 1637 |
end; |
1638 |
||
371 | 1639 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
10 | 1640 |
var t: PGear; |
1641 |
begin |
|
1642 |
t:= GearsList; |
|
1643 |
rX:= sqr(rX); |
|
1644 |
rY:= sqr(rY); |
|
1433 | 1645 |
|
10 | 1646 |
while t <> nil do |
1433 | 1647 |
begin |
1648 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
1649 |
if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then |
|
1650 |
exit(t); |
|
1651 |
t:= t^.NextGear |
|
1652 |
end; |
|
1653 |
||
351 | 1654 |
CheckGearNear:= nil |
15 | 1655 |
end; |
1656 |
||
1433 | 1657 |
{procedure AmmoFlameWork(Ammo: PGear); |
79 | 1658 |
var t: PGear; |
1659 |
begin |
|
1660 |
t:= GearsList; |
|
1661 |
while t <> nil do |
|
1295 | 1662 |
begin |
1663 |
if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then |
|
1664 |
if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then |
|
1665 |
begin |
|
2017 | 1666 |
ApplyDamage(t, 5); |
1295 | 1667 |
t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; |
1668 |
t^.dY:= - _0_25; |
|
1669 |
t^.Active:= true; |
|
1670 |
DeleteCI(t); |
|
1671 |
FollowGear:= t |
|
1672 |
end; |
|
1673 |
t:= t^.NextGear |
|
1674 |
end; |
|
1433 | 1675 |
end;} |
79 | 1676 |
|
371 | 1677 |
function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; |
16 | 1678 |
var t: PGear; |
1679 |
begin |
|
1680 |
t:= GearsList; |
|
1681 |
rX:= sqr(rX); |
|
1682 |
rY:= sqr(rY); |
|
1683 |
while t <> nil do |
|
1515 | 1684 |
begin |
1685 |
if t^.Kind in Kind then |
|
1686 |
if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then |
|
1687 |
exit(t); |
|
1688 |
t:= t^.NextGear |
|
1689 |
end; |
|
351 | 1690 |
CheckGearsNear:= nil |
16 | 1691 |
end; |
1692 |
||
1693 |
function CountGears(Kind: TGearType): Longword; |
|
1694 |
var t: PGear; |
|
351 | 1695 |
Result: Longword; |
16 | 1696 |
begin |
1697 |
Result:= 0; |
|
1698 |
t:= GearsList; |
|
1699 |
while t <> nil do |
|
1515 | 1700 |
begin |
1701 |
if t^.Kind = Kind then inc(Result); |
|
1702 |
t:= t^.NextGear |
|
1703 |
end; |
|
351 | 1704 |
CountGears:= Result |
16 | 1705 |
end; |
1706 |
||
15 | 1707 |
procedure SpawnBoxOfSmth; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1708 |
var t: LongInt; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1709 |
i: TAmmoType; |
15 | 1710 |
begin |
614 | 1711 |
if (cCaseFactor = 0) or |
1712 |
(CountGears(gtCase) >= 5) or |
|
1713 |
(getrandom(cCaseFactor) <> 0) then exit; |
|
1295 | 1714 |
|
1948 | 1715 |
FollowGear:= nil; |
1716 |
||
2145 | 1717 |
if shoppa then // FIXME - TEMPORARY REMOVE WHEN CRATE PROBABILITY IS ADDED |
1966 | 1718 |
t:= 7 |
1719 |
else |
|
1720 |
t:= getrandom(20); |
|
1721 |
||
1722 |
//case getrandom(20) of |
|
1723 |
case t of |
|
1861 | 1724 |
0..6: begin |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1725 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
351 | 1726 |
FollowGear^.Health:= 25; |
2143
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2137
diff
changeset
|
1727 |
FollowGear^.Pos:= posCaseHealth; |
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2137
diff
changeset
|
1728 |
AddCaption(GetEventString(eidNewHealthPack), $FFFFFF, capgrpGameState); |
295 | 1729 |
end; |
1861 | 1730 |
7..13: begin |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1731 |
t:= 0; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1732 |
for i:= Low(TAmmoType) to High(TAmmoType) do |
1861 | 1733 |
if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then |
1734 |
inc(t, Ammoz[i].Probability); |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1735 |
if (t > 0) then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1736 |
begin |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1737 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1738 |
t:= GetRandom(t); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1739 |
i:= Low(TAmmoType); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1740 |
if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1741 |
dec(t, Ammoz[i].Probability); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1742 |
while t >= 0 do |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1743 |
begin |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1744 |
inc(i); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1745 |
if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1746 |
dec(t, Ammoz[i].Probability) |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1747 |
end; |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1748 |
FollowGear^.Pos:= posCaseAmmo; |
2143
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2137
diff
changeset
|
1749 |
FollowGear^.State:= Longword(i); |
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2137
diff
changeset
|
1750 |
AddCaption(GetEventString(eidNewAmmoPack), $FFFFFF, capgrpGameState); |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1751 |
end |
295 | 1752 |
end; |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1753 |
14..19: begin |
1861 | 1754 |
t:= 0; |
1755 |
for i:= Low(TAmmoType) to High(TAmmoType) do |
|
1756 |
if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then |
|
1757 |
inc(t, Ammoz[i].Probability); |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1758 |
if (t > 0) then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1759 |
begin |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1760 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1761 |
t:= GetRandom(t); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1762 |
i:= Low(TAmmoType); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1763 |
if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1764 |
dec(t, Ammoz[i].Probability); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1765 |
while t >= 0 do |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1766 |
begin |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1767 |
inc(i); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1768 |
if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1769 |
dec(t, Ammoz[i].Probability) |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1770 |
end; |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1771 |
FollowGear^.Pos:= posCaseUtility; |
2143
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2137
diff
changeset
|
1772 |
FollowGear^.State:= Longword(i); |
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2137
diff
changeset
|
1773 |
AddCaption(GetEventString(eidNewUtilityPack), $FFFFFF, capgrpGameState); |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1774 |
end |
1861 | 1775 |
end; |
295 | 1776 |
end; |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1777 |
// handles case of no ammo or utility crates - considered also placing booleans in uAmmos and altering probabilities |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1778 |
if (FollowGear <> nil) then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1779 |
begin |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1780 |
FindPlace(FollowGear, true, 0, LAND_WIDTH); |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1781 |
|
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1782 |
if (FollowGear <> nil) then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1783 |
PlaySound(sndReinforce, false, CurrentTeam^.voicepack) |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset
|
1784 |
end |
70 | 1785 |
end; |
1786 |
||
1515 | 1787 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); |
70 | 1788 |
|
1515 | 1789 |
function CountNonZeroz(x, y, r: LongInt): LongInt; |
1790 |
var i: LongInt; |
|
1791 |
Result: LongInt; |
|
1792 |
begin |
|
1793 |
Result:= 0; |
|
1753 | 1794 |
if (y and LAND_HEIGHT_MASK) = 0 then |
1760 | 1795 |
for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 4) do |
1515 | 1796 |
if Land[y, i] <> 0 then inc(Result); |
1797 |
CountNonZeroz:= Result |
|
1798 |
end; |
|
70 | 1799 |
|
495 | 1800 |
var x: LongInt; |
1515 | 1801 |
y, sy: LongInt; |
1802 |
ar: array[0..511] of TPoint; |
|
1803 |
ar2: array[0..1023] of TPoint; |
|
1804 |
cnt, cnt2: Longword; |
|
1805 |
delta: LongInt; |
|
70 | 1806 |
begin |
386 | 1807 |
delta:= 250; |
1808 |
cnt2:= 0; |
|
16 | 1809 |
repeat |
1515 | 1810 |
x:= Left + LongInt(GetRandom(Delta)); |
1811 |
repeat |
|
1812 |
inc(x, Delta); |
|
1813 |
cnt:= 0; |
|
1939 | 1814 |
if topY > 1024 then |
1815 |
y:= 1024-Gear^.Radius * 2 |
|
1816 |
else |
|
1817 |
y:= topY-Gear^.Radius * 2; |
|
1753 | 1818 |
while y < LAND_HEIGHT do |
1515 | 1819 |
begin |
1820 |
repeat |
|
1821 |
inc(y, 2); |
|
1760 | 1822 |
until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0); |
1515 | 1823 |
|
1824 |
sy:= y; |
|
1825 |
||
1826 |
repeat |
|
1827 |
inc(y); |
|
1760 | 1828 |
until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0); |
1515 | 1829 |
|
1830 |
if (y - sy > Gear^.Radius * 2) |
|
1753 | 1831 |
and (y < LAND_HEIGHT) |
1515 | 1832 |
and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then |
1833 |
begin |
|
1834 |
ar[cnt].X:= x; |
|
1835 |
if withFall then ar[cnt].Y:= sy + Gear^.Radius |
|
1836 |
else ar[cnt].Y:= y - Gear^.Radius; |
|
1837 |
inc(cnt) |
|
1838 |
end; |
|
1839 |
||
1840 |
inc(y, 45) |
|
1841 |
end; |
|
1842 |
||
1843 |
if cnt > 0 then |
|
1844 |
with ar[GetRandom(cnt)] do |
|
1845 |
begin |
|
1846 |
ar2[cnt2].x:= x; |
|
1847 |
ar2[cnt2].y:= y; |
|
1848 |
inc(cnt2) |
|
1849 |
end |
|
1850 |
until (x + Delta > Right); |
|
1760 | 1851 |
|
1515 | 1852 |
dec(Delta, 60) |
386 | 1853 |
until (cnt2 > 0) or (Delta < 70); |
1515 | 1854 |
|
386 | 1855 |
if cnt2 > 0 then |
1515 | 1856 |
with ar2[GetRandom(cnt2)] do |
1857 |
begin |
|
1858 |
Gear^.X:= int2hwFloat(x); |
|
1859 |
Gear^.Y:= int2hwFloat(y); |
|
1860 |
{$IFDEF DEBUGFILE} |
|
1861 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
1862 |
{$ENDIF} |
|
1863 |
end |
|
1864 |
else |
|
1865 |
begin |
|
1866 |
OutError('Can''t find place for Gear', false); |
|
1867 |
DeleteGear(Gear); |
|
1868 |
Gear:= nil |
|
1869 |
end |
|
10 | 1870 |
end; |
1871 |
||
4 | 1872 |
initialization |
1873 |
||
1874 |
finalization |
|
95 | 1875 |
FreeGearsList; |
4 | 1876 |
|
1877 |
end. |