author | unc0rr |
Fri, 31 Oct 2008 20:48:09 +0000 | |
changeset 1456 | 2539dd079be1 |
parent 1435 | d4b32ee3caa6 |
child 1495 | 2b2b89bdb5f3 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2004-2008 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; |
|
31 |
Ammo : PAmmo; |
|
32 |
State : Longword; |
|
33 |
X : hwFloat; |
|
34 |
Y : hwFloat; |
|
35 |
dX: hwFloat; |
|
36 |
dY: hwFloat; |
|
37 |
Kind: TGearType; |
|
38 |
Pos: Longword; |
|
39 |
doStep: TGearStepProcedure; |
|
40 |
Radius: LongInt; |
|
41 |
Angle, Power : Longword; |
|
42 |
DirAngle: real; |
|
43 |
Timer : LongWord; |
|
44 |
Elasticity: hwFloat; |
|
45 |
Friction : hwFloat; |
|
46 |
Message, MsgParam : Longword; |
|
47 |
Hedgehog: pointer; |
|
48 |
Health, Damage: LongInt; |
|
49 |
CollisionIndex: LongInt; |
|
50 |
Tag: LongInt; |
|
51 |
Tex: PTexture; |
|
52 |
Z: Longword; |
|
53 |
IntersectGear: PGear; |
|
54 |
TriggerId: Longword; |
|
55 |
end; |
|
4 | 56 |
|
371 | 57 |
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
4 | 58 |
procedure ProcessGears; |
59 |
procedure SetAllToActive; |
|
60 |
procedure SetAllHHToActive; |
|
956 | 61 |
procedure DrawGears; |
4 | 62 |
procedure FreeGearsList; |
10 | 63 |
procedure AddMiscGears; |
4 | 64 |
procedure AssignHHCoords; |
294 | 65 |
procedure InsertGearToList(Gear: PGear); |
66 |
procedure RemoveGearFromList(Gear: PGear); |
|
4 | 67 |
|
68 |
var CurAmmoGear: PGear = nil; |
|
68 | 69 |
GearsList: PGear = nil; |
307 | 70 |
KilledHHs: Longword = 0; |
70 | 71 |
|
4 | 72 |
implementation |
81 | 73 |
uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, |
1259 | 74 |
uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers, GL, |
75 |
uStats, uVisualGears; |
|
789 | 76 |
|
1207
ceaab010269e
Some adjusting... it still doesn't solve problem fully
unc0rr
parents:
1200
diff
changeset
|
77 |
const MAXROPEPOINTS = 384; |
68 | 78 |
var RopePoints: record |
4 | 79 |
Count: Longword; |
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
775
diff
changeset
|
80 |
HookAngle: GLfloat; |
789 | 81 |
ar: array[0..MAXROPEPOINTS] of record |
351 | 82 |
X, Y: hwFloat; |
83 |
dLen: hwFloat; |
|
4 | 84 |
b: boolean; |
85 |
end; |
|
86 |
end; |
|
87 |
||
1435
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
88 |
procedure DeleteGear(var Gear: PGear); forward; |
371 | 89 |
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); forward; |
90 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward; |
|
1433 | 91 |
//procedure AmmoFlameWork(Ammo: PGear); forward; |
371 | 92 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; forward; |
15 | 93 |
procedure SpawnBoxOfSmth; forward; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
24
diff
changeset
|
94 |
procedure AfterAttack; forward; |
371 | 95 |
procedure FindPlace(Gear: PGear; withFall: boolean; Left, Right: LongInt); forward; |
302 | 96 |
procedure HedgehogStep(Gear: PGear); forward; |
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
97 |
procedure HedgehogChAngle(Gear: PGear); forward; |
506 | 98 |
procedure ShotgunShot(Gear: PGear); forward; |
522 | 99 |
procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear); forward; |
4 | 100 |
|
101 |
{$INCLUDE GSHandlers.inc} |
|
102 |
{$INCLUDE HHHandlers.inc} |
|
103 |
||
104 |
const doStepHandlers: array[TGearType] of TGearStepProcedure = ( |
|
1259 | 105 |
@doStepBomb, |
106 |
@doStepHedgehog, |
|
107 |
@doStepGrenade, |
|
108 |
@doStepHealthTag, |
|
109 |
@doStepGrave, |
|
110 |
@doStepUFO, |
|
111 |
@doStepShotgunShot, |
|
112 |
@doStepPickHammer, |
|
113 |
@doStepRope, |
|
114 |
@doStepSmokeTrace, |
|
115 |
@doStepExplosion, |
|
116 |
@doStepMine, |
|
117 |
@doStepCase, |
|
118 |
@doStepDEagleShot, |
|
119 |
@doStepDynamite, |
|
120 |
@doStepTeamHealthSorter, |
|
121 |
@doStepBomb, |
|
122 |
@doStepCluster, |
|
123 |
@doStepShover, |
|
124 |
@doStepFlame, |
|
125 |
@doStepFirePunch, |
|
126 |
@doStepActionTimer, |
|
127 |
@doStepActionTimer, |
|
128 |
@doStepActionTimer, |
|
129 |
@doStepParachute, |
|
130 |
@doStepAirAttack, |
|
131 |
@doStepAirBomb, |
|
132 |
@doStepBlowTorch, |
|
133 |
@doStepGirder, |
|
134 |
@doStepTeleport, |
|
135 |
@doStepHealthTag, |
|
136 |
@doStepSwitcher, |
|
137 |
@doStepCase, |
|
138 |
@doStepMortar, |
|
139 |
@doStepWhip, |
|
140 |
@doStepKamikaze, |
|
141 |
@doStepCake, |
|
1261 | 142 |
@doStepSeduction, |
1279 | 143 |
@doStepWatermelon, |
1263 | 144 |
@doStepCluster, |
145 |
@doStepBomb, |
|
1298 | 146 |
@doStepSmokeTrace, |
147 |
@doStepWaterUp |
|
1259 | 148 |
); |
4 | 149 |
|
294 | 150 |
procedure InsertGearToList(Gear: PGear); |
803 | 151 |
var tmp, ptmp: PGear; |
294 | 152 |
begin |
153 |
if GearsList = nil then |
|
154 |
GearsList:= Gear |
|
155 |
else begin |
|
156 |
tmp:= GearsList; |
|
803 | 157 |
ptmp:= GearsList; |
158 |
while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do |
|
159 |
begin |
|
160 |
ptmp:= tmp; |
|
161 |
tmp:= tmp^.NextGear |
|
162 |
end; |
|
294 | 163 |
|
803 | 164 |
if ptmp <> nil then |
165 |
begin |
|
166 |
Gear^.NextGear:= ptmp^.NextGear; |
|
167 |
Gear^.PrevGear:= ptmp; |
|
168 |
if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear; |
|
169 |
ptmp^.NextGear:= Gear |
|
170 |
end |
|
171 |
else GearsList:= Gear |
|
294 | 172 |
end |
173 |
end; |
|
174 |
||
175 |
procedure RemoveGearFromList(Gear: PGear); |
|
176 |
begin |
|
351 | 177 |
if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear; |
178 |
if Gear^.PrevGear <> nil then Gear^.PrevGear^.NextGear:= Gear^.NextGear |
|
809 | 179 |
else GearsList:= Gear^.NextGear |
294 | 180 |
end; |
181 |
||
371 | 182 |
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
79 | 183 |
const Counter: Longword = 0; |
351 | 184 |
var Result: PGear; |
4 | 185 |
begin |
79 | 186 |
inc(Counter); |
108 | 187 |
{$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+'), d('+floattostr(dX)+','+floattostr(dY)+')');{$ENDIF} |
4 | 188 |
New(Result); |
357 | 189 |
{$IFDEF DEBUGFILE}AddFileLog('AddGear: type = ' + inttostr(ord(Kind)));{$ENDIF} |
4 | 190 |
FillChar(Result^, sizeof(TGear), 0); |
498 | 191 |
Result^.X:= int2hwFloat(X); |
192 |
Result^.Y:= int2hwFloat(Y); |
|
351 | 193 |
Result^.Kind := Kind; |
194 |
Result^.State:= State; |
|
195 |
Result^.Active:= true; |
|
196 |
Result^.dX:= dX; |
|
197 |
Result^.dY:= dY; |
|
198 |
Result^.doStep:= doStepHandlers[Kind]; |
|
511 | 199 |
Result^.CollisionIndex:= -1; |
351 | 200 |
Result^.Timer:= Timer; |
1270 | 201 |
Result^.Z:= cUsualZ; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
503
diff
changeset
|
202 |
|
4 | 203 |
if CurrentTeam <> nil then |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
503
diff
changeset
|
204 |
begin |
602 | 205 |
Result^.Hedgehog:= CurrentHedgehog; |
206 |
Result^.IntersectGear:= CurrentHedgehog^.Gear |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
503
diff
changeset
|
207 |
end; |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
789
diff
changeset
|
208 |
|
4 | 209 |
case Kind of |
915 | 210 |
gtAmmo_Bomb, |
211 |
gtClusterBomb: begin |
|
351 | 212 |
Result^.Radius:= 4; |
213 |
Result^.Elasticity:= _0_6; |
|
997 | 214 |
Result^.Friction:= _0_96; |
4 | 215 |
end; |
1261 | 216 |
gtWatermelon: begin |
217 |
Result^.Radius:= 4; |
|
218 |
Result^.Elasticity:= _0_8; |
|
219 |
Result^.Friction:= _0_995; |
|
220 |
end; |
|
4 | 221 |
gtHedgehog: begin |
351 | 222 |
Result^.Radius:= cHHRadius; |
223 |
Result^.Elasticity:= _0_35; |
|
224 |
Result^.Friction:= _0_999; |
|
225 |
Result^.Angle:= cMaxAngle div 2; |
|
226 |
Result^.Z:= cHHZ; |
|
4 | 227 |
end; |
228 |
gtAmmo_Grenade: begin |
|
351 | 229 |
Result^.Radius:= 4; |
4 | 230 |
end; |
231 |
gtHealthTag: begin |
|
351 | 232 |
Result^.Timer:= 1500; |
522 | 233 |
Result^.Z:= 2001; |
4 | 234 |
end; |
235 |
gtGrave: begin |
|
351 | 236 |
Result^.Radius:= 10; |
237 |
Result^.Elasticity:= _0_6; |
|
4 | 238 |
end; |
239 |
gtUFO: begin |
|
351 | 240 |
Result^.Radius:= 5; |
241 |
Result^.Timer:= 500; |
|
242 |
Result^.Elasticity:= _0_9 |
|
4 | 243 |
end; |
244 |
gtShotgunShot: begin |
|
351 | 245 |
Result^.Timer:= 900; |
246 |
Result^.Radius:= 2 |
|
4 | 247 |
end; |
248 |
gtPickHammer: begin |
|
351 | 249 |
Result^.Radius:= 10; |
250 |
Result^.Timer:= 4000 |
|
4 | 251 |
end; |
1263 | 252 |
gtSmokeTrace, |
253 |
gtEvilTrace: begin |
|
498 | 254 |
Result^.X:= Result^.X - _16; |
255 |
Result^.Y:= Result^.Y - _16; |
|
1270 | 256 |
Result^.State:= 8; |
257 |
Result^.Z:= cSmokeZ |
|
4 | 258 |
end; |
259 |
gtRope: begin |
|
351 | 260 |
Result^.Radius:= 3; |
498 | 261 |
Result^.Friction:= _450; |
4 | 262 |
RopePoints.Count:= 0; |
263 |
end; |
|
9 | 264 |
gtExplosion: begin |
1012 | 265 |
Result^.X:= Result^.X; |
266 |
Result^.Y:= Result^.Y; |
|
9 | 267 |
end; |
10 | 268 |
gtMine: begin |
503 | 269 |
Result^.State:= Result^.State or gstMoving; |
915 | 270 |
Result^.Radius:= 2; |
351 | 271 |
Result^.Elasticity:= _0_55; |
272 |
Result^.Friction:= _0_995; |
|
273 |
Result^.Timer:= 3000; |
|
10 | 274 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset
|
275 |
gtCase: begin |
351 | 276 |
Result^.Radius:= 16; |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
277 |
Result^.Elasticity:= _0_3 |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset
|
278 |
end; |
37 | 279 |
gtDEagleShot: begin |
351 | 280 |
Result^.Radius:= 1; |
281 |
Result^.Health:= 50 |
|
37 | 282 |
end; |
39 | 283 |
gtDynamite: begin |
351 | 284 |
Result^.Radius:= 3; |
285 |
Result^.Elasticity:= _0_55; |
|
286 |
Result^.Friction:= _0_03; |
|
287 |
Result^.Timer:= 5000; |
|
39 | 288 |
end; |
910 | 289 |
gtCluster: Result^.Radius:= 2; |
878 | 290 |
gtShover: Result^.Radius:= 20; |
79 | 291 |
gtFlame: begin |
1295 | 292 |
Result^.Tag:= Counter mod 64; |
351 | 293 |
Result^.Radius:= 1; |
294 |
Result^.Health:= 2; |
|
295 |
Result^.dY:= (getrandom - _0_8) * _0_03; |
|
296 |
Result^.dX:= (getrandom - _0_5) * _0_4 |
|
79 | 297 |
end; |
82 | 298 |
gtFirePunch: begin |
351 | 299 |
Result^.Radius:= 15; |
300 |
Result^.Tag:= Y |
|
82 | 301 |
end; |
302 | 302 |
gtAirBomb: begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
303 |
Result^.Radius:= 5; |
302 | 304 |
end; |
305 |
gtBlowTorch: begin |
|
511 | 306 |
Result^.Radius:= cHHRadius + cBlowTorchC; |
351 | 307 |
Result^.Timer:= 7500; |
302 | 308 |
end; |
522 | 309 |
gtSmallDamage: begin |
310 |
Result^.Timer:= 1100; |
|
311 |
Result^.Z:= 2000; |
|
312 |
end; |
|
540 | 313 |
gtSwitcher: begin |
314 |
Result^.Z:= cCurrHHZ |
|
315 |
end; |
|
593 | 316 |
gtTarget: begin |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
317 |
Result^.Radius:= 16; |
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
318 |
Result^.Elasticity:= _0_3 |
593 | 319 |
end; |
924 | 320 |
gtMortar: begin |
994 | 321 |
Result^.Radius:= 4; |
924 | 322 |
Result^.Elasticity:= _0_2; |
323 |
Result^.Friction:= _0_08 |
|
324 |
end; |
|
925 | 325 |
gtWhip: Result^.Radius:= 20; |
984 | 326 |
gtKamikaze: begin |
327 |
Result^.Health:= 2048; |
|
328 |
Result^.Radius:= 20 |
|
329 |
end; |
|
1089 | 330 |
gtCake: begin |
1261 | 331 |
Result^.Health:= 2048; |
1103 | 332 |
Result^.Radius:= 7; |
1109 | 333 |
Result^.Z:= cOnHHZ; |
1089 | 334 |
if hwSign(dX) > 0 then Result^.Angle:= 1 else Result^.Angle:= 3 |
335 |
end; |
|
1263 | 336 |
gtHellishBomb: begin |
337 |
Result^.Radius:= 4; |
|
338 |
Result^.Elasticity:= _0_5; |
|
339 |
Result^.Friction:= _0_96; |
|
340 |
end; |
|
4 | 341 |
end; |
351 | 342 |
InsertGearToList(Result); |
343 |
AddGear:= Result |
|
4 | 344 |
end; |
345 |
||
1435
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
346 |
procedure DeleteGear(var Gear: PGear); |
48 | 347 |
var team: PTeam; |
307 | 348 |
t: Longword; |
4 | 349 |
begin |
503 | 350 |
DeleteCI(Gear); |
762 | 351 |
|
352 |
if Gear^.Tex <> nil then |
|
522 | 353 |
begin |
762 | 354 |
FreeTexture(Gear^.Tex); |
355 |
Gear^.Tex:= nil |
|
522 | 356 |
end; |
762 | 357 |
|
351 | 358 |
if Gear^.Kind = gtHedgehog then |
4 | 359 |
if CurAmmoGear <> nil then |
360 |
begin |
|
351 | 361 |
Gear^.Message:= gm_Destroy; |
362 |
CurAmmoGear^.Message:= gm_Destroy; |
|
4 | 363 |
exit |
47 | 364 |
end else |
365 |
begin |
|
498 | 366 |
if not (hwRound(Gear^.Y) < cWaterLine) then |
307 | 367 |
begin |
351 | 368 |
t:= max(Gear^.Damage, Gear^.Health); |
867 | 369 |
Gear^.Damage:= t; |
498 | 370 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
867 | 371 |
uStats.HedgehogDamaged(Gear) |
307 | 372 |
end; |
351 | 373 |
team:= PHedgehog(Gear^.Hedgehog)^.Team; |
602 | 374 |
if CurrentHedgehog^.Gear = Gear then |
145 | 375 |
FreeActionsList; // to avoid ThinkThread on drawned gear |
351 | 376 |
PHedgehog(Gear^.Hedgehog)^.Gear:= nil; |
307 | 377 |
inc(KilledHHs); |
48 | 378 |
RecountTeamHealth(team); |
47 | 379 |
end; |
357 | 380 |
{$IFDEF DEBUGFILE}AddFileLog('DeleteGear');{$ENDIF} |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
593
diff
changeset
|
381 |
if Gear^.TriggerId <> 0 then TickTrigger(Gear^.TriggerId); |
82 | 382 |
if CurAmmoGear = Gear then CurAmmoGear:= nil; |
4 | 383 |
if FollowGear = Gear then FollowGear:= nil; |
294 | 384 |
RemoveGearFromList(Gear); |
1435
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
385 |
|
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
386 |
Dispose(Gear); |
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
387 |
|
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
388 |
Gear:= nil |
4 | 389 |
end; |
390 |
||
391 |
function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs |
|
392 |
var Gear: PGear; |
|
393 |
begin |
|
351 | 394 |
CheckNoDamage:= true; |
4 | 395 |
Gear:= GearsList; |
396 |
while Gear <> nil do |
|
867 | 397 |
begin |
398 |
if Gear^.Kind = gtHedgehog then |
|
399 |
if Gear^.Damage <> 0 then |
|
400 |
begin |
|
401 |
CheckNoDamage:= false; |
|
402 |
uStats.HedgehogDamaged(Gear); |
|
351 | 403 |
|
867 | 404 |
if Gear^.Health < Gear^.Damage then |
405 |
Gear^.Health:= 0 |
|
406 |
else |
|
407 |
dec(Gear^.Health, Gear^.Damage); |
|
408 |
||
409 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12, |
|
410 |
gtHealthTag, Gear^.Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
411 |
RenderHealth(PHedgehog(Gear^.Hedgehog)^); |
|
412 |
RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team); |
|
413 |
||
414 |
Gear^.Damage:= 0 |
|
415 |
end; |
|
416 |
Gear:= Gear^.NextGear |
|
417 |
end; |
|
4 | 418 |
end; |
419 |
||
1054 | 420 |
procedure HealthMachine; |
421 |
var Gear: PGear; |
|
422 |
begin |
|
423 |
Gear:= GearsList; |
|
424 |
||
425 |
while Gear <> nil do |
|
426 |
begin |
|
427 |
if Gear^.Kind = gtHedgehog then |
|
428 |
Gear^.Damage:= min(cHealthDecrease, Gear^.Health - 1); |
|
429 |
||
430 |
Gear:= Gear^.NextGear |
|
431 |
end; |
|
432 |
end; |
|
433 |
||
522 | 434 |
procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear); |
435 |
begin |
|
529 | 436 |
if cAltDamage then |
437 |
AddGear(X, Y, gtSmallDamage, Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
522 | 438 |
end; |
439 |
||
4 | 440 |
procedure ProcessGears; |
614 | 441 |
const delay: LongWord = 0; |
869 | 442 |
step: (stDelay, stChDmg, stTurnReact, |
1298 | 443 |
stAfterDelay, stChWin, stWater, stChWin2, stHealth, |
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
444 |
stSpawn, stNTurn) = stDelay; |
1054 | 445 |
|
4 | 446 |
var Gear, t: PGear; |
447 |
begin |
|
868 | 448 |
PrvInactive:= AllInactive; |
4 | 449 |
AllInactive:= true; |
450 |
t:= GearsList; |
|
1054 | 451 |
while t <> nil do |
1352
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
452 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
453 |
Gear:= t; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
454 |
t:= Gear^.NextGear; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
455 |
if Gear^.Active then Gear^.doStep(Gear); |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
456 |
end; |
89 | 457 |
|
4 | 458 |
if AllInactive then |
1343 | 459 |
case step of |
460 |
stDelay: begin |
|
461 |
if delay = 0 then |
|
462 |
delay:= cInactDelay |
|
463 |
else |
|
464 |
dec(delay); |
|
614 | 465 |
|
1343 | 466 |
if delay = 0 then |
467 |
inc(step) |
|
468 |
end; |
|
469 |
stChDmg: if CheckNoDamage then inc(step) else step:= stDelay; |
|
470 |
stTurnReact: begin |
|
471 |
if (not bBetweenTurns) and (not isInMultiShoot) then |
|
472 |
begin |
|
473 |
uStats.TurnReaction; |
|
474 |
inc(step) |
|
475 |
end else |
|
476 |
inc(step, 2); |
|
477 |
end; |
|
478 |
stAfterDelay: begin |
|
479 |
if delay = 0 then |
|
480 |
delay:= cInactDelay |
|
481 |
else |
|
482 |
dec(delay); |
|
815 | 483 |
|
1343 | 484 |
if delay = 0 then |
485 |
inc(step) |
|
486 |
end; |
|
487 |
stChWin: begin |
|
488 |
CheckForWin; |
|
489 |
inc(step) |
|
490 |
end; |
|
491 |
stWater: if (not bBetweenTurns) and (not isInMultiShoot) then |
|
492 |
begin |
|
493 |
if TotalRounds = 17 then bWaterRising:= true; |
|
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
494 |
|
1343 | 495 |
if bWaterRising then |
496 |
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
|
497 |
|
1343 | 498 |
inc(step) |
499 |
end else inc(step); |
|
500 |
stChWin2: begin |
|
501 |
CheckForWin; |
|
502 |
inc(step) |
|
503 |
end; |
|
504 |
stHealth: begin |
|
505 |
if (TotalRounds = 15) and (cHealthDecrease = 0) then |
|
506 |
begin |
|
507 |
cHealthDecrease:= 5; |
|
508 |
AddCaption(trmsg[sidSuddenDeath], $FFFFFF, capgrpGameState) |
|
509 |
end; |
|
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
510 |
|
1343 | 511 |
if (cHealthDecrease = 0) |
512 |
or bBetweenTurns |
|
513 |
or isInMultiShoot |
|
514 |
or (TotalRounds = 0) then inc(step) |
|
515 |
else begin |
|
516 |
bBetweenTurns:= true; |
|
517 |
HealthMachine; |
|
518 |
step:= stChDmg |
|
519 |
end |
|
520 |
end; |
|
521 |
stSpawn: begin |
|
522 |
if not isInMultiShoot then SpawnBoxOfSmth; |
|
523 |
inc(step) |
|
524 |
end; |
|
525 |
stNTurn: begin |
|
526 |
if isInMultiShoot then isInMultiShoot:= false |
|
527 |
else begin |
|
528 |
ParseCommand('/nextturn', true); |
|
529 |
SwitchHedgehog; |
|
1298 | 530 |
|
1343 | 531 |
inc(step); |
1298 | 532 |
|
1343 | 533 |
AfterSwitchHedgehog; |
534 |
bBetweenTurns:= false |
|
535 |
end; |
|
536 |
step:= Low(step) |
|
537 |
end; |
|
538 |
end; |
|
15 | 539 |
|
4 | 540 |
if TurnTimeLeft > 0 then |
870 | 541 |
if CurrentHedgehog^.Gear <> nil then |
542 |
if ((CurrentHedgehog^.Gear^.State and gstAttacking) = 0) |
|
543 |
and not isInMultiShoot then |
|
544 |
begin |
|
545 |
if (TurnTimeLeft = 5000) |
|
546 |
and (CurrentHedgehog^.Gear <> nil) |
|
547 |
and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0) then PlaySound(sndHurry, false); |
|
548 |
dec(TurnTimeLeft) |
|
549 |
end; |
|
351 | 550 |
|
651 | 551 |
if (not CurrentTeam^.ExtDriven) and |
917 | 552 |
((GameTicks and $FFFF) = $FFFF) then |
553 |
begin |
|
554 |
SendIPCTimeInc; |
|
555 |
inc(hiTicks) // we do not recieve a message for this |
|
556 |
end; |
|
656
6d6d9d7b1054
Fix network game bug caused by recent protocol changes
unc0rr
parents:
651
diff
changeset
|
557 |
|
515 | 558 |
inc(GameTicks) |
4 | 559 |
end; |
560 |
||
561 |
procedure SetAllToActive; |
|
562 |
var t: PGear; |
|
563 |
begin |
|
564 |
AllInactive:= false; |
|
565 |
t:= GearsList; |
|
351 | 566 |
while t <> nil do |
4 | 567 |
begin |
351 | 568 |
t^.Active:= true; |
569 |
t:= t^.NextGear |
|
4 | 570 |
end |
571 |
end; |
|
572 |
||
573 |
procedure SetAllHHToActive; |
|
574 |
var t: PGear; |
|
575 |
begin |
|
576 |
AllInactive:= false; |
|
577 |
t:= GearsList; |
|
351 | 578 |
while t <> nil do |
4 | 579 |
begin |
351 | 580 |
if t^.Kind = gtHedgehog then t^.Active:= true; |
581 |
t:= t^.NextGear |
|
4 | 582 |
end |
583 |
end; |
|
584 |
||
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
585 |
procedure DrawHH(Gear: PGear); |
371 | 586 |
var t: LongInt; |
822 | 587 |
amt: TAmmoType; |
862 | 588 |
hx, hy, m: LongInt; |
589 |
aAngle, dAngle: real; |
|
1253 | 590 |
defaultPos, HatVisible: boolean; |
292 | 591 |
begin |
868 | 592 |
if (Gear^.State and gstHHDeath) <> 0 then |
593 |
begin |
|
594 |
DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos); |
|
595 |
exit |
|
596 |
end; |
|
1002 | 597 |
|
824 | 598 |
defaultPos:= true; |
1253 | 599 |
HatVisible:= false; |
847 | 600 |
|
1002 | 601 |
if (Gear^.State and gstDrowning) <> 0 then |
602 |
begin |
|
603 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
604 |
hwSign(Gear^.dX), |
|
605 |
1, |
|
606 |
7, |
|
607 |
0); |
|
608 |
defaultPos:= false |
|
609 |
end else |
|
610 |
||
1011 | 611 |
if (Gear^.State and gstWinner) <> 0 then |
612 |
begin |
|
613 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
614 |
hwSign(Gear^.dX), |
|
615 |
2, |
|
616 |
0, |
|
617 |
0); |
|
618 |
defaultPos:= false |
|
619 |
end else |
|
620 |
||
821
e6c0408b54ed
Use 'regular standing' and 'rope swing' hedgehog sprites
unc0rr
parents:
815
diff
changeset
|
621 |
if (Gear^.State and gstHHDriven) <> 0 then |
966 | 622 |
begin |
1002 | 623 |
hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx; |
624 |
hy:= hwRound(Gear^.Y) - 2 + WorldDy; |
|
625 |
aangle:= Gear^.Angle * 180 / cMaxAngle - 90; |
|
874 | 626 |
|
1002 | 627 |
if CurAmmoGear <> nil then |
628 |
begin |
|
629 |
case CurAmmoGear^.Kind of |
|
1294
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
630 |
gtShotgunShot: begin |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
631 |
if (CurAmmoGear^.State and gstAnimation <> 0) then |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
632 |
DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle) |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
633 |
else |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
634 |
DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
635 |
HatVisible:= true |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
636 |
end; |
1002 | 637 |
gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle); |
638 |
gtRope: begin |
|
639 |
if Gear^.X < CurAmmoGear^.X then |
|
640 |
begin |
|
641 |
dAngle:= 0; |
|
642 |
m:= 1 |
|
643 |
end else |
|
644 |
begin |
|
645 |
dAngle:= 180; |
|
646 |
m:= -1 |
|
966 | 647 |
end; |
1002 | 648 |
DrawHedgehog(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
649 |
m, |
|
650 |
1, |
|
651 |
0, |
|
652 |
DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle); |
|
653 |
defaultPos:= false |
|
654 |
end; |
|
655 |
gtBlowTorch: begin |
|
656 |
DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); |
|
657 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
658 |
hwSign(Gear^.dX), |
|
659 |
3, |
|
1113 | 660 |
PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, |
1002 | 661 |
0); |
662 |
defaultPos:= false |
|
663 |
end; |
|
664 |
gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180); |
|
665 |
gtFirePunch: begin |
|
666 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
667 |
hwSign(Gear^.dX), |
|
668 |
1, |
|
669 |
4, |
|
670 |
0); |
|
671 |
defaultPos:= false |
|
672 |
end; |
|
673 |
gtPickHammer, |
|
674 |
gtTeleport: defaultPos:= false; |
|
1010 | 675 |
gtWhip: begin |
676 |
DrawRotatedF(sprWhip, |
|
677 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
678 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
679 |
1, |
|
680 |
hwSign(Gear^.dX), |
|
681 |
0); |
|
682 |
defaultPos:= false |
|
683 |
end; |
|
1002 | 684 |
gtKamikaze: begin |
1286 | 685 |
if CurAmmoGear^.Pos = 0 then |
686 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
687 |
hwSign(Gear^.dX), |
|
688 |
1, |
|
689 |
6, |
|
690 |
0) |
|
691 |
else |
|
692 |
DrawRotatedF(sprKamikaze, |
|
693 |
hwRound(Gear^.X) + WorldDx, |
|
694 |
hwRound(Gear^.Y) + WorldDy, |
|
695 |
CurAmmoGear^.Pos - 1, |
|
696 |
1, |
|
697 |
DxDy2Angle(Gear^.dY, Gear^.dX)); |
|
1002 | 698 |
|
1286 | 699 |
defaultPos:= false |
700 |
end; |
|
701 |
gtSeduction: begin |
|
702 |
if CurAmmoGear^.Pos >= 6 then |
|
703 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
704 |
hwSign(Gear^.dX), |
|
705 |
2, |
|
706 |
2, |
|
707 |
0) |
|
708 |
else |
|
709 |
begin |
|
710 |
DrawRotatedF(sprDress, |
|
711 |
hwRound(Gear^.X) + WorldDx, |
|
712 |
hwRound(Gear^.Y) + WorldDy, |
|
713 |
CurAmmoGear^.Pos, |
|
714 |
hwSign(Gear^.dX), |
|
715 |
0); |
|
716 |
DrawSprite(sprCensored, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 20 + WorldDy, 0) |
|
717 |
end; |
|
718 |
defaultPos:= false |
|
719 |
end; |
|
1002 | 720 |
end; |
721 |
||
722 |
case CurAmmoGear^.Kind of |
|
723 |
gtShotgunShot, |
|
724 |
gtDEagleShot, |
|
725 |
gtShover: begin |
|
726 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
727 |
hwSign(Gear^.dX), |
|
728 |
0, |
|
729 |
4, |
|
730 |
0); |
|
731 |
defaultPos:= false |
|
732 |
end |
|
733 |
end |
|
734 |
end else |
|
876 | 735 |
|
1002 | 736 |
if ((Gear^.State and gstHHJumping) <> 0) then |
737 |
begin |
|
738 |
if ((Gear^.State and gstHHHJump) <> 0) then |
|
739 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
740 |
- hwSign(Gear^.dX), |
|
741 |
1, |
|
742 |
1, |
|
743 |
0) |
|
744 |
else |
|
745 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
746 |
hwSign(Gear^.dX), |
|
747 |
1, |
|
748 |
1, |
|
749 |
0); |
|
750 |
defaultPos:= false |
|
751 |
end else |
|
874 | 752 |
|
1002 | 753 |
if (Gear^.Message and (gm_Left or gm_Right) <> 0) then |
824 | 754 |
begin |
1002 | 755 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
756 |
hwSign(Gear^.dX), |
|
757 |
0, |
|
758 |
PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, |
|
759 |
0); |
|
1257 | 760 |
defaultPos:= false; |
761 |
HatVisible:= true |
|
1002 | 762 |
end |
763 |
else |
|
764 |
||
1033 | 765 |
if ((Gear^.State and gstAnimation) <> 0) then |
766 |
begin |
|
1034 | 767 |
DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite, |
1033 | 768 |
hwRound(Gear^.X) + 1 + WorldDx, |
769 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
770 |
Gear^.Pos, |
|
771 |
hwSign(Gear^.dX), |
|
772 |
0.0); |
|
773 |
defaultPos:= false |
|
774 |
end |
|
775 |
else |
|
1002 | 776 |
if ((Gear^.State and gstAttacked) = 0) then |
777 |
begin |
|
778 |
amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType; |
|
779 |
case amt of |
|
780 |
amBazooka, |
|
781 |
amMortar: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle); |
|
782 |
amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle); |
|
783 |
amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); |
|
784 |
amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle); |
|
785 |
amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); |
|
786 |
end; |
|
787 |
||
788 |
case amt of |
|
789 |
amAirAttack, |
|
790 |
amMineStrike: DrawRotated(sprHandAirAttack, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0); |
|
791 |
amPickHammer: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
792 |
hwSign(Gear^.dX), |
|
793 |
1, |
|
794 |
2, |
|
795 |
0); |
|
796 |
amBlowTorch: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
797 |
hwSign(Gear^.dX), |
|
798 |
1, |
|
799 |
3, |
|
800 |
0); |
|
801 |
amTeleport: DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, 0, hwSign(Gear^.dX), 0); |
|
802 |
amKamikaze: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
803 |
hwSign(Gear^.dX), |
|
804 |
1, |
|
805 |
5, |
|
806 |
0); |
|
1221 | 807 |
amWhip: DrawRotatedF(sprWhip, |
1010 | 808 |
hwRound(Gear^.X) + 1 + WorldDx, |
809 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
810 |
0, |
|
811 |
hwSign(Gear^.dX), |
|
812 |
0); |
|
1002 | 813 |
else |
822 | 814 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
815 |
hwSign(Gear^.dX), |
|
816 |
0, |
|
1002 | 817 |
4, |
822 | 818 |
0); |
1253 | 819 |
|
820 |
HatVisible:= true; |
|
821 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
1294
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
822 |
if (HatTex <> nil) |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
823 |
and (HatVisibility > 0) then |
1253 | 824 |
DrawTextureF(HatTex, |
825 |
HatVisibility, |
|
826 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
827 |
hwRound(Gear^.Y) - 8 + WorldDy, |
|
828 |
0, |
|
829 |
hwSign(Gear^.dX), |
|
830 |
32); |
|
1002 | 831 |
end; |
966 | 832 |
|
1002 | 833 |
case amt of |
834 |
amBaseballBat: DrawRotated(sprHandBaseball, |
|
835 |
hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx, |
|
836 |
hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle); |
|
837 |
end; |
|
966 | 838 |
|
1002 | 839 |
defaultPos:= false |
840 |
end |
|
841 |
end else // not gstHHDriven |
|
1012 | 842 |
begin |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
843 |
if (Gear^.Damage > 0) |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
844 |
and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
845 |
begin |
1012 | 846 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
847 |
hwSign(Gear^.dX), |
|
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
848 |
2, |
1012 | 849 |
1, |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
850 |
Gear^.DirAngle); |
1012 | 851 |
defaultPos:= false |
1020 | 852 |
end else |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
853 |
|
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
854 |
if ((Gear^.State and gstHHJumping) <> 0) then |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
855 |
begin |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
856 |
if ((Gear^.State and gstHHHJump) <> 0) then |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
857 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
858 |
- hwSign(Gear^.dX), |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
859 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
860 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
861 |
0) |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
862 |
else |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
863 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
864 |
hwSign(Gear^.dX), |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
865 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
866 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
867 |
0); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
868 |
defaultPos:= false |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
869 |
end; |
1012 | 870 |
end; |
834 | 871 |
|
1251 | 872 |
with PHedgehog(Gear^.Hedgehog)^ do |
970 | 873 |
begin |
1251 | 874 |
if defaultPos then |
875 |
begin |
|
876 |
DrawRotatedF(sprHHIdle, |
|
877 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
878 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
879 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
|
880 |
hwSign(Gear^.dX), |
|
881 |
0); |
|
1253 | 882 |
HatVisible:= true; |
883 |
end; |
|
884 |
||
885 |
if HatVisible then |
|
1251 | 886 |
if HatVisibility < 1.0 then |
1254 | 887 |
HatVisibility:= HatVisibility + 0.2 |
1253 | 888 |
else |
1251 | 889 |
else |
890 |
if HatVisibility > 0.0 then |
|
1254 | 891 |
HatVisibility:= HatVisibility - 0.2; |
1253 | 892 |
|
1294
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
893 |
if (HatTex <> nil) |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
894 |
and (HatVisibility > 0) then |
1255 | 895 |
if DefaultPos then |
896 |
DrawTextureF(HatTex, |
|
897 |
HatVisibility, |
|
898 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
899 |
hwRound(Gear^.Y) - 8 + WorldDy, |
|
900 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
|
901 |
hwSign(Gear^.dX), |
|
902 |
32) |
|
903 |
else |
|
904 |
DrawTextureF(HatTex, |
|
905 |
HatVisibility, |
|
906 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
907 |
hwRound(Gear^.Y) - 8 + WorldDy, |
|
908 |
0, |
|
909 |
hwSign(Gear^.dX), |
|
910 |
32); |
|
970 | 911 |
end; |
292 | 912 |
|
1251 | 913 |
|
351 | 914 |
with PHedgehog(Gear^.Hedgehog)^ do |
994 | 915 |
begin |
1011 | 916 |
if ((Gear^.State and not gstWinner) = 0) |
994 | 917 |
or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then |
958 | 918 |
begin |
976 | 919 |
t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy; |
958 | 920 |
if (cTagsMask and 1) <> 0 then |
921 |
begin |
|
922 |
dec(t, HealthTagTex^.h + 2); |
|
923 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex) |
|
924 |
end; |
|
925 |
if (cTagsMask and 2) <> 0 then |
|
926 |
begin |
|
927 |
dec(t, NameTagTex^.h + 2); |
|
928 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTagTex) |
|
929 |
end; |
|
930 |
if (cTagsMask and 4) <> 0 then |
|
931 |
begin |
|
932 |
dec(t, Team^.NameTagTex^.h + 2); |
|
933 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex) |
|
934 |
end |
|
994 | 935 |
end; |
936 |
if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog |
|
958 | 937 |
begin |
938 |
if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then |
|
939 |
DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy, |
|
940 |
GameTicks div 32 mod 16); |
|
821
e6c0408b54ed
Use 'regular standing' and 'rope swing' hedgehog sprites
unc0rr
parents:
815
diff
changeset
|
941 |
|
958 | 942 |
if (Gear^.State and gstDrowning) = 0 then |
943 |
if (Gear^.State and gstHHThinking) <> 0 then |
|
944 |
DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, 0) |
|
945 |
else |
|
1033 | 946 |
if ShowCrosshair and ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then |
958 | 947 |
begin |
948 |
if ((Gear^.State and gstHHHJump) <> 0) then m:= -1 else m:= 1; |
|
949 |
DrawRotatedTex(Team^.CrosshairTex, |
|
950 |
12, 12, |
|
1283
a1e99d1e4fd3
Enable back the ability to see chosen team color in team widget
unc0rr
parents:
1279
diff
changeset
|
951 |
Round(hwRound(Gear^.X) + hwSign(Gear^.dX) * m * Sin(Gear^.Angle*pi/cMaxAngle) * 80) + WorldDx, |
a1e99d1e4fd3
Enable back the ability to see chosen team color in team widget
unc0rr
parents:
1279
diff
changeset
|
952 |
Round(hwRound(Gear^.Y) - Cos(Gear^.Angle*pi/cMaxAngle) * 80) + WorldDy, 0, |
958 | 953 |
hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle) |
954 |
end |
|
994 | 955 |
end |
956 |
end |
|
292 | 957 |
end; |
958 |
||
956 | 959 |
procedure DrawGears; |
853 | 960 |
var Gear, HHGear: PGear; |
4 | 961 |
i: Longword; |
371 | 962 |
roplen: LongInt; |
4 | 963 |
|
371 | 964 |
procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt); |
965 |
var eX, eY, dX, dY: LongInt; |
|
966 |
i, sX, sY, x, y, d: LongInt; |
|
366 | 967 |
b: boolean; |
4 | 968 |
begin |
37 | 969 |
if (X1 = X2) and (Y1 = Y2) then |
970 |
begin |
|
351 | 971 |
OutError('WARNING: zero length rope line!', false); |
37 | 972 |
exit |
973 |
end; |
|
366 | 974 |
eX:= 0; |
975 |
eY:= 0; |
|
976 |
dX:= X2 - X1; |
|
977 |
dY:= Y2 - Y1; |
|
978 |
||
979 |
if (dX > 0) then sX:= 1 |
|
980 |
else |
|
981 |
if (dX < 0) then |
|
982 |
begin |
|
983 |
sX:= -1; |
|
984 |
dX:= -dX |
|
985 |
end else sX:= dX; |
|
986 |
||
987 |
if (dY > 0) then sY:= 1 |
|
988 |
else |
|
989 |
if (dY < 0) then |
|
4 | 990 |
begin |
366 | 991 |
sY:= -1; |
992 |
dY:= -dY |
|
993 |
end else sY:= dY; |
|
994 |
||
995 |
if (dX > dY) then d:= dX |
|
996 |
else d:= dY; |
|
997 |
||
998 |
x:= X1; |
|
999 |
y:= Y1; |
|
1000 |
||
1001 |
for i:= 0 to d do |
|
1002 |
begin |
|
1003 |
inc(eX, dX); |
|
1004 |
inc(eY, dY); |
|
1005 |
b:= false; |
|
1006 |
if (eX > d) then |
|
35 | 1007 |
begin |
366 | 1008 |
dec(eX, d); |
1009 |
inc(x, sX); |
|
1010 |
b:= true |
|
35 | 1011 |
end; |
366 | 1012 |
if (eY > d) then |
35 | 1013 |
begin |
366 | 1014 |
dec(eY, d); |
1015 |
inc(y, sY); |
|
1016 |
b:= true |
|
35 | 1017 |
end; |
366 | 1018 |
if b then |
1019 |
begin |
|
1020 |
inc(roplen); |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1021 |
if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0) |
366 | 1022 |
end |
4 | 1023 |
end |
366 | 1024 |
end; |
4 | 1025 |
|
1026 |
begin |
|
1027 |
Gear:= GearsList; |
|
1028 |
while Gear<>nil do |
|
1029 |
begin |
|
351 | 1030 |
case Gear^.Kind of |
822 | 1031 |
gtAmmo_Bomb: DrawRotated(sprBomb, 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
|
1032 |
gtHedgehog: DrawHH(Gear); |
822 | 1033 |
gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
522 | 1034 |
gtHealthTag, |
762 | 1035 |
gtSmallDamage: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex); |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1036 |
gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex); |
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1037 |
gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4); |
848 | 1038 |
gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0); |
4 | 1039 |
gtRope: begin |
35 | 1040 |
roplen:= 0; |
4 | 1041 |
if RopePoints.Count > 0 then |
1042 |
begin |
|
1043 |
i:= 0; |
|
1044 |
while i < Pred(RopePoints.Count) do |
|
1045 |
begin |
|
351 | 1046 |
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
1047 |
hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy); |
|
4 | 1048 |
inc(i) |
1049 |
end; |
|
351 | 1050 |
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
1051 |
hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy); |
|
1052 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
|
1053 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 1054 |
DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) |
4 | 1055 |
end else |
35 | 1056 |
begin |
351 | 1057 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
1058 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 1059 |
DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
35 | 1060 |
end; |
4 | 1061 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1062 |
gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
1012 | 1063 |
gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State); |
351 | 1064 |
gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420) |
822 | 1065 |
then DrawRotated(sprMineOff, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle) |
1066 |
else DrawRotated(sprMineOn, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
|
351 | 1067 |
gtCase: case Gear^.Pos of |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1068 |
posCaseAmmo : DrawSprite(sprCase, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
1009 | 1069 |
posCaseHealth: begin |
1070 |
i:= (GameTicks shr 6) mod 64; |
|
1071 |
if i > 12 then i:= 0; |
|
1072 |
DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i); |
|
1073 |
end; |
|
42 | 1074 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1075 |
gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1); |
822 | 1076 |
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
|
1077 |
gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0); |
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1078 |
gtFlame: DrawSprite(sprFlame, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy,(GameTicks div 128 + Gear^.Angle) mod 8); |
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1079 |
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
|
1080 |
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
|
1081 |
else DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 1); |
822 | 1082 |
gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
853 | 1083 |
gtTeleport: begin |
1084 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1085 |
DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
1086 |
DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
1087 |
end; |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1088 |
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
|
1089 |
gtTarget: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
959 | 1090 |
gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1108 | 1091 |
gtCake: if Gear^.Pos = 6 then |
1092 |
DrawRotatedf(sprCakeWalk, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle + hwSign(Gear^.dX) * 90) |
|
1093 |
else |
|
1262 | 1094 |
DrawRotatedf(sprCakeDown, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 5 - Gear^.Pos, hwSign(Gear^.dX), 0); |
1367 | 1095 |
gtSeduction: if Gear^.Pos >= 14 then DrawSprite(sprSeduction, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
1262 | 1096 |
gtWatermelon: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 0, Gear^.DirAngle); |
1097 |
gtMelonPiece: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 1, 0, Gear^.DirAngle); |
|
1263 | 1098 |
gtHellishBomb: DrawRotated(sprHellishBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
1099 |
gtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
|
1100 |
end; |
|
351 | 1101 |
Gear:= Gear^.NextGear |
4 | 1102 |
end; |
1103 |
end; |
|
1104 |
||
1105 |
procedure FreeGearsList; |
|
1106 |
var t, tt: PGear; |
|
1107 |
begin |
|
1108 |
tt:= GearsList; |
|
1109 |
GearsList:= nil; |
|
1110 |
while tt<>nil do |
|
1111 |
begin |
|
1112 |
t:= tt; |
|
351 | 1113 |
tt:= tt^.NextGear; |
4 | 1114 |
Dispose(t) |
1115 |
end; |
|
1116 |
end; |
|
1117 |
||
10 | 1118 |
procedure AddMiscGears; |
371 | 1119 |
var i: LongInt; |
4 | 1120 |
begin |
498 | 1121 |
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
|
1122 |
|
22 | 1123 |
if (GameFlags and gfForts) = 0 then |
1435
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
1124 |
for i:= 0 to Pred(cLandAdditions) do |
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
1125 |
FindPlace(AddGear(0, 0, gtMine, 0, _0, _0, 0), false, 0, 2048); |
4 | 1126 |
end; |
1127 |
||
371 | 1128 |
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); |
4 | 1129 |
var Gear: PGear; |
506 | 1130 |
dmg, dmgRadius: LongInt; |
4 | 1131 |
begin |
1132 |
TargetPoint.X:= NoPointX; |
|
1434 | 1133 |
{$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF} |
1049 | 1134 |
if (Radius > 10) then AddGear(X, Y, gtExplosion, 0, _0, _0, 0); |
355 | 1135 |
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false); |
1433 | 1136 |
|
1137 |
if (Mask and EXPLAllDamageInRadius) = 0 then |
|
1138 |
dmgRadius:= Radius shl 1 |
|
1139 |
else |
|
1140 |
dmgRadius:= Radius; |
|
1141 |
||
4 | 1142 |
Gear:= GearsList; |
1143 |
while Gear <> nil do |
|
1200 | 1144 |
begin |
1145 |
dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
|
1146 |
if (dmg > 1) and |
|
1147 |
((Gear^.State and gstNoDamage) = 0) then |
|
1148 |
begin |
|
1149 |
dmg:= min(dmg div 2, Radius); |
|
1150 |
case Gear^.Kind of |
|
1151 |
gtHedgehog, |
|
1152 |
gtMine, |
|
1153 |
gtCase, |
|
1154 |
gtTarget, |
|
1155 |
gtFlame: begin |
|
1346 | 1156 |
//{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} |
1200 | 1157 |
if (Mask and EXPLNoDamage) = 0 then |
1158 |
begin |
|
1159 |
inc(Gear^.Damage, dmg); |
|
1160 |
if Gear^.Kind = gtHedgehog then |
|
1161 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, Gear) |
|
1162 |
end; |
|
1163 |
if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then |
|
1164 |
begin |
|
1165 |
DeleteCI(Gear); |
|
1166 |
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X)); |
|
1167 |
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y)); |
|
1168 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); |
|
1169 |
Gear^.Active:= true; |
|
1170 |
FollowGear:= Gear |
|
1171 |
end; |
|
1172 |
end; |
|
1173 |
gtGrave: begin |
|
1174 |
Gear^.dY:= - _0_004 * dmg; |
|
1175 |
Gear^.Active:= true; |
|
1176 |
end; |
|
1177 |
end; |
|
1178 |
end; |
|
1179 |
Gear:= Gear^.NextGear |
|
1180 |
end; |
|
1181 |
||
621 | 1182 |
if (Mask and EXPLDontDraw) = 0 then |
1200 | 1183 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(X, Y, Radius); |
1184 |
||
498 | 1185 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
4 | 1186 |
end; |
1187 |
||
506 | 1188 |
procedure ShotgunShot(Gear: PGear); |
1189 |
var t: PGear; |
|
955 | 1190 |
dmg: LongInt; |
506 | 1191 |
begin |
509 | 1192 |
Gear^.Radius:= cShotgunRadius; |
506 | 1193 |
t:= GearsList; |
1194 |
while t <> nil do |
|
1286 | 1195 |
begin |
1196 |
dmg:= min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25); |
|
1197 |
if dmg > 0 then |
|
1198 |
case t^.Kind of |
|
1199 |
gtHedgehog, |
|
1200 |
gtMine, |
|
1201 |
gtCase, |
|
1202 |
gtTarget: begin |
|
1203 |
inc(t^.Damage, dmg); |
|
867 | 1204 |
|
1286 | 1205 |
if t^.Kind = gtHedgehog then |
1206 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, t); |
|
867 | 1207 |
|
1286 | 1208 |
DeleteCI(t); |
1209 |
t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); |
|
1210 |
t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; |
|
1211 |
t^.State:= t^.State or gstMoving; |
|
1212 |
t^.Active:= true; |
|
1213 |
FollowGear:= t |
|
1214 |
end; |
|
1215 |
gtGrave: begin |
|
1216 |
t^.dY:= - _0_1; |
|
1217 |
t^.Active:= true |
|
1218 |
end; |
|
1219 |
end; |
|
1220 |
t:= t^.NextGear |
|
1221 |
end; |
|
621 | 1222 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) |
506 | 1223 |
end; |
1224 |
||
371 | 1225 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
53 | 1226 |
var t: PGearArray; |
371 | 1227 |
i: LongInt; |
38 | 1228 |
begin |
53 | 1229 |
t:= CheckGearsCollision(Ammo); |
351 | 1230 |
i:= t^.Count; |
53 | 1231 |
while i > 0 do |
981 | 1232 |
begin |
1233 |
dec(i); |
|
1234 |
if (t^.ar[i]^.State and gstNoDamage) = 0 then |
|
1235 |
case t^.ar[i]^.Kind of |
|
1236 |
gtHedgehog, |
|
1237 |
gtMine, |
|
1238 |
gtTarget, |
|
1239 |
gtCase: begin |
|
1240 |
inc(t^.ar[i]^.Damage, Damage); |
|
1241 |
||
1284 | 1242 |
if (t^.ar[i]^.Kind = gtHedgehog) and (Damage > 0) then |
981 | 1243 |
AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, t^.ar[i]); |
867 | 1244 |
|
981 | 1245 |
DeleteCI(t^.ar[i]); |
1246 |
t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01; |
|
1247 |
t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01; |
|
1248 |
t^.ar[i]^.Active:= true; |
|
1249 |
t^.ar[i]^.State:= t^.ar[i]^.State or gstMoving; |
|
867 | 1250 |
|
982 | 1251 |
if TestCollisionXwithGear(t^.ar[i], hwSign(t^.ar[i]^.dX)) then |
981 | 1252 |
begin |
1253 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -3, hwSign(t^.ar[i]^.dX)) |
|
1254 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1255 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX)) |
|
1256 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1257 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX)) |
|
1258 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1259 |
end; |
|
982 | 1260 |
|
981 | 1261 |
FollowGear:= t^.ar[i] |
1262 |
end; |
|
1263 |
end |
|
1264 |
end; |
|
126 | 1265 |
SetAllToActive |
38 | 1266 |
end; |
1267 |
||
4 | 1268 |
procedure AssignHHCoords; |
955 | 1269 |
var i, t, p, j: LongInt; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1270 |
ar: array[0..Pred(cMaxHHs)] of PGear; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1271 |
Count: Longword; |
4 | 1272 |
begin |
1428 | 1273 |
if (GameFlags and (gfForts or gfDivideTeams)) <> 0 then |
955 | 1274 |
begin |
1275 |
t:= 0; |
|
1428 | 1276 |
TryDo(ClansCount = 2, 'More or less than 2 clans on map in divided teams mode!', true); |
955 | 1277 |
for p:= 0 to 1 do |
1278 |
begin |
|
1279 |
with ClansArray[p]^ do |
|
1280 |
for j:= 0 to Pred(TeamsNumber) do |
|
1281 |
with Teams[j]^ do |
|
1282 |
for i:= 0 to cMaxHHIndex do |
|
1283 |
with Hedgehogs[i] do |
|
958 | 1284 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
1285 |
begin |
|
1286 |
FindPlace(Gear, false, t, t + 1024); |
|
999
8dcf263c9e8f
In forts mode, hedgehogs on the left look at the right, and vice-versa
unc0rr
parents:
997
diff
changeset
|
1287 |
Gear^.Pos:= GetRandom(19); |
8dcf263c9e8f
In forts mode, hedgehogs on the left look at the right, and vice-versa
unc0rr
parents:
997
diff
changeset
|
1288 |
Gear^.dX.isNegative:= p = 1; |
958 | 1289 |
end; |
955 | 1290 |
inc(t, 1024) |
1291 |
end |
|
1292 |
end else // mix hedgehogs |
|
1293 |
begin |
|
1294 |
Count:= 0; |
|
1295 |
for p:= 0 to Pred(TeamsCount) do |
|
1296 |
with TeamsArray[p]^ do |
|
1297 |
begin |
|
1298 |
for i:= 0 to cMaxHHIndex do |
|
1299 |
with Hedgehogs[i] do |
|
1300 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
|
1301 |
begin |
|
1302 |
ar[Count]:= Gear; |
|
1303 |
inc(Count) |
|
1304 |
end; |
|
1305 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1306 |
|
955 | 1307 |
while (Count > 0) do |
1308 |
begin |
|
1309 |
i:= GetRandom(Count); |
|
1310 |
FindPlace(ar[i], false, 0, 2048); |
|
1000
e7b204880318
Hedgehogs on the left side of the map look to the right and vice-versa
unc0rr
parents:
999
diff
changeset
|
1311 |
ar[i]^.dX.isNegative:= ar[i]^.X > _1024; |
959 | 1312 |
ar[i]^.Pos:= GetRandom(19); |
955 | 1313 |
ar[i]:= ar[Count - 1]; |
1314 |
dec(Count) |
|
1315 |
end |
|
1316 |
end |
|
4 | 1317 |
end; |
1318 |
||
371 | 1319 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
10 | 1320 |
var t: PGear; |
1321 |
begin |
|
1322 |
t:= GearsList; |
|
1323 |
rX:= sqr(rX); |
|
1324 |
rY:= sqr(rY); |
|
1433 | 1325 |
|
10 | 1326 |
while t <> nil do |
1433 | 1327 |
begin |
1328 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
1329 |
if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then |
|
1330 |
exit(t); |
|
1331 |
t:= t^.NextGear |
|
1332 |
end; |
|
1333 |
||
351 | 1334 |
CheckGearNear:= nil |
15 | 1335 |
end; |
1336 |
||
1433 | 1337 |
{procedure AmmoFlameWork(Ammo: PGear); |
79 | 1338 |
var t: PGear; |
1339 |
begin |
|
1340 |
t:= GearsList; |
|
1341 |
while t <> nil do |
|
1295 | 1342 |
begin |
1343 |
if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then |
|
1344 |
if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then |
|
1345 |
begin |
|
1346 |
inc(t^.Damage, 5); |
|
1347 |
t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; |
|
1348 |
t^.dY:= - _0_25; |
|
1349 |
t^.Active:= true; |
|
1350 |
DeleteCI(t); |
|
1351 |
FollowGear:= t |
|
1352 |
end; |
|
1353 |
t:= t^.NextGear |
|
1354 |
end; |
|
1433 | 1355 |
end;} |
79 | 1356 |
|
371 | 1357 |
function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; |
16 | 1358 |
var t: PGear; |
1359 |
begin |
|
1360 |
t:= GearsList; |
|
1361 |
rX:= sqr(rX); |
|
1362 |
rY:= sqr(rY); |
|
1363 |
while t <> nil do |
|
1364 |
begin |
|
351 | 1365 |
if t^.Kind in Kind then |
498 | 1366 |
if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then |
351 | 1367 |
exit(t); |
1368 |
t:= t^.NextGear |
|
16 | 1369 |
end; |
351 | 1370 |
CheckGearsNear:= nil |
16 | 1371 |
end; |
1372 |
||
1373 |
function CountGears(Kind: TGearType): Longword; |
|
1374 |
var t: PGear; |
|
351 | 1375 |
Result: Longword; |
16 | 1376 |
begin |
1377 |
Result:= 0; |
|
1378 |
t:= GearsList; |
|
1379 |
while t <> nil do |
|
1380 |
begin |
|
351 | 1381 |
if t^.Kind = Kind then inc(Result); |
1382 |
t:= t^.NextGear |
|
16 | 1383 |
end; |
351 | 1384 |
CountGears:= Result |
16 | 1385 |
end; |
1386 |
||
15 | 1387 |
procedure SpawnBoxOfSmth; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1388 |
var t: LongInt; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1389 |
i: TAmmoType; |
15 | 1390 |
begin |
614 | 1391 |
if (cCaseFactor = 0) or |
1392 |
(CountGears(gtCase) >= 5) or |
|
1393 |
(getrandom(cCaseFactor) <> 0) then exit; |
|
1295 | 1394 |
|
498 | 1395 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
295 | 1396 |
case getrandom(2) of |
1397 |
0: begin |
|
351 | 1398 |
FollowGear^.Health:= 25; |
1399 |
FollowGear^.Pos:= posCaseHealth |
|
295 | 1400 |
end; |
1401 |
1: begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1402 |
t:= 0; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1403 |
for i:= Low(TAmmoType) to High(TAmmoType) do |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1404 |
inc(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1405 |
t:= GetRandom(t); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1406 |
i:= Low(TAmmoType); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1407 |
dec(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1408 |
while t >= 0 do |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1409 |
begin |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1410 |
inc(i); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1411 |
dec(t, Ammoz[i].Probability) |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1412 |
end; |
865 | 1413 |
PlaySound(sndReinforce, false); |
351 | 1414 |
FollowGear^.Pos:= posCaseAmmo; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1415 |
FollowGear^.State:= Longword(i) |
295 | 1416 |
end; |
1417 |
end; |
|
70 | 1418 |
FindPlace(FollowGear, true, 0, 2048) |
1419 |
end; |
|
1420 |
||
371 | 1421 |
procedure FindPlace(Gear: PGear; withFall: boolean; Left, Right: LongInt); |
70 | 1422 |
|
371 | 1423 |
function CountNonZeroz(x, y, r: LongInt): LongInt; |
1424 |
var i: LongInt; |
|
1425 |
Result: LongInt; |
|
70 | 1426 |
begin |
1427 |
Result:= 0; |
|
701 | 1428 |
if (y and $FFFFFC00) = 0 then |
1429 |
for i:= max(x - r, 0) to min(x + r, 2043) do |
|
351 | 1430 |
if Land[y, i] <> 0 then inc(Result); |
1431 |
CountNonZeroz:= Result |
|
70 | 1432 |
end; |
1433 |
||
495 | 1434 |
var x: LongInt; |
371 | 1435 |
y, sy: LongInt; |
386 | 1436 |
ar: array[0..511] of TPoint; |
1437 |
ar2: array[0..1023] of TPoint; |
|
392 | 1438 |
cnt, cnt2: Longword; |
1439 |
delta: LongInt; |
|
70 | 1440 |
begin |
386 | 1441 |
delta:= 250; |
1442 |
cnt2:= 0; |
|
16 | 1443 |
repeat |
392 | 1444 |
x:= Left + LongInt(GetRandom(Delta)); |
70 | 1445 |
repeat |
386 | 1446 |
inc(x, Delta); |
70 | 1447 |
cnt:= 0; |
351 | 1448 |
y:= -Gear^.Radius * 2; |
70 | 1449 |
while y < 1023 do |
16 | 1450 |
begin |
70 | 1451 |
repeat |
701 | 1452 |
inc(y, 2); |
351 | 1453 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0); |
70 | 1454 |
sy:= y; |
1455 |
repeat |
|
1456 |
inc(y); |
|
351 | 1457 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0); |
1458 |
if (y - sy > Gear^.Radius * 2) |
|
70 | 1459 |
and (y < 1023) |
351 | 1460 |
and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then |
70 | 1461 |
begin |
1462 |
ar[cnt].X:= x; |
|
351 | 1463 |
if withFall then ar[cnt].Y:= sy + Gear^.Radius |
1464 |
else ar[cnt].Y:= y - Gear^.Radius; |
|
70 | 1465 |
inc(cnt) |
1466 |
end; |
|
386 | 1467 |
inc(y, 45) |
16 | 1468 |
end; |
70 | 1469 |
if cnt > 0 then |
1470 |
with ar[GetRandom(cnt)] do |
|
1471 |
begin |
|
386 | 1472 |
ar2[cnt2].x:= x; |
1473 |
ar2[cnt2].y:= y; |
|
1474 |
inc(cnt2) |
|
70 | 1475 |
end |
386 | 1476 |
until (x + Delta > Right); |
1477 |
dec(Delta, 60) |
|
1478 |
until (cnt2 > 0) or (Delta < 70); |
|
1479 |
if cnt2 > 0 then |
|
1480 |
with ar2[GetRandom(cnt2)] do |
|
1481 |
begin |
|
498 | 1482 |
Gear^.X:= int2hwFloat(x); |
1483 |
Gear^.Y:= int2hwFloat(y); |
|
386 | 1484 |
{$IFDEF DEBUGFILE} |
1485 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
1486 |
{$ENDIF} |
|
1487 |
end |
|
1488 |
else |
|
1489 |
begin |
|
1490 |
OutError('Can''t find place for Gear', false); |
|
1491 |
DeleteGear(Gear) |
|
1492 |
end |
|
10 | 1493 |
end; |
1494 |
||
4 | 1495 |
initialization |
1496 |
||
1497 |
finalization |
|
95 | 1498 |
FreeGearsList; |
4 | 1499 |
|
1500 |
end. |