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