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