author | unc0rr |
Fri, 21 Nov 2008 15:58:36 +0000 | |
changeset 1505 | 3a96e93572cb |
parent 1503 | a40b871d506b |
child 1506 | a4ab75470ce1 |
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; |
|
1503 | 55 |
uid: Longword; |
1259 | 56 |
end; |
4 | 57 |
|
371 | 58 |
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
4 | 59 |
procedure ProcessGears; |
60 |
procedure SetAllToActive; |
|
61 |
procedure SetAllHHToActive; |
|
956 | 62 |
procedure DrawGears; |
4 | 63 |
procedure FreeGearsList; |
10 | 64 |
procedure AddMiscGears; |
4 | 65 |
procedure AssignHHCoords; |
294 | 66 |
procedure InsertGearToList(Gear: PGear); |
67 |
procedure RemoveGearFromList(Gear: PGear); |
|
4 | 68 |
|
69 |
var CurAmmoGear: PGear = nil; |
|
68 | 70 |
GearsList: PGear = nil; |
307 | 71 |
KilledHHs: Longword = 0; |
70 | 72 |
|
4 | 73 |
implementation |
81 | 74 |
uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, |
1259 | 75 |
uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers, GL, |
76 |
uStats, uVisualGears; |
|
789 | 77 |
|
1207
ceaab010269e
Some adjusting... it still doesn't solve problem fully
unc0rr
parents:
1200
diff
changeset
|
78 |
const MAXROPEPOINTS = 384; |
68 | 79 |
var RopePoints: record |
4 | 80 |
Count: Longword; |
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
775
diff
changeset
|
81 |
HookAngle: GLfloat; |
789 | 82 |
ar: array[0..MAXROPEPOINTS] of record |
351 | 83 |
X, Y: hwFloat; |
84 |
dLen: hwFloat; |
|
4 | 85 |
b: boolean; |
86 |
end; |
|
87 |
end; |
|
88 |
||
1435
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
89 |
procedure DeleteGear(var Gear: PGear); forward; |
371 | 90 |
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); forward; |
91 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward; |
|
1433 | 92 |
//procedure AmmoFlameWork(Ammo: PGear); forward; |
371 | 93 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; forward; |
15 | 94 |
procedure SpawnBoxOfSmth; forward; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
24
diff
changeset
|
95 |
procedure AfterAttack; forward; |
371 | 96 |
procedure FindPlace(Gear: PGear; withFall: boolean; Left, Right: LongInt); forward; |
302 | 97 |
procedure HedgehogStep(Gear: PGear); forward; |
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
98 |
procedure HedgehogChAngle(Gear: PGear); forward; |
506 | 99 |
procedure ShotgunShot(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 |
@doStepSwitcher, |
|
136 |
@doStepCase, |
|
137 |
@doStepMortar, |
|
138 |
@doStepWhip, |
|
139 |
@doStepKamikaze, |
|
140 |
@doStepCake, |
|
1261 | 141 |
@doStepSeduction, |
1279 | 142 |
@doStepWatermelon, |
1263 | 143 |
@doStepCluster, |
144 |
@doStepBomb, |
|
1298 | 145 |
@doStepSmokeTrace, |
146 |
@doStepWaterUp |
|
1259 | 147 |
); |
4 | 148 |
|
294 | 149 |
procedure InsertGearToList(Gear: PGear); |
803 | 150 |
var tmp, ptmp: PGear; |
294 | 151 |
begin |
152 |
if GearsList = nil then |
|
1505 | 153 |
GearsList:= Gear |
154 |
else begin |
|
155 |
tmp:= GearsList; |
|
156 |
ptmp:= GearsList; |
|
157 |
while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do |
|
158 |
begin |
|
159 |
ptmp:= tmp; |
|
160 |
tmp:= tmp^.NextGear |
|
161 |
end; |
|
294 | 162 |
|
1505 | 163 |
if ptmp <> nil then |
164 |
begin |
|
165 |
Gear^.NextGear:= ptmp^.NextGear; |
|
166 |
Gear^.PrevGear:= ptmp; |
|
167 |
if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear; |
|
168 |
ptmp^.NextGear:= Gear |
|
169 |
end |
|
170 |
else GearsList:= Gear |
|
171 |
end |
|
294 | 172 |
end; |
173 |
||
174 |
procedure RemoveGearFromList(Gear: PGear); |
|
175 |
begin |
|
351 | 176 |
if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear; |
1505 | 177 |
if Gear^.PrevGear <> nil then |
178 |
Gear^.PrevGear^.NextGear:= Gear^.NextGear |
|
179 |
else |
|
180 |
GearsList:= Gear^.NextGear |
|
294 | 181 |
end; |
182 |
||
371 | 183 |
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
79 | 184 |
const Counter: Longword = 0; |
351 | 185 |
var Result: PGear; |
4 | 186 |
begin |
79 | 187 |
inc(Counter); |
1495 | 188 |
{$IFDEF DEBUGFILE} |
1503 | 189 |
AddFileLog('AddGear: #' + inttostr(Counter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + inttostr(ord(Kind))); |
1495 | 190 |
{$ENDIF} |
191 |
||
4 | 192 |
New(Result); |
193 |
FillChar(Result^, sizeof(TGear), 0); |
|
498 | 194 |
Result^.X:= int2hwFloat(X); |
195 |
Result^.Y:= int2hwFloat(Y); |
|
351 | 196 |
Result^.Kind := Kind; |
197 |
Result^.State:= State; |
|
198 |
Result^.Active:= true; |
|
199 |
Result^.dX:= dX; |
|
200 |
Result^.dY:= dY; |
|
201 |
Result^.doStep:= doStepHandlers[Kind]; |
|
511 | 202 |
Result^.CollisionIndex:= -1; |
351 | 203 |
Result^.Timer:= Timer; |
1270 | 204 |
Result^.Z:= cUsualZ; |
1503 | 205 |
Result^.uid:= Counter; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
503
diff
changeset
|
206 |
|
4 | 207 |
if CurrentTeam <> nil then |
1505 | 208 |
begin |
209 |
Result^.Hedgehog:= CurrentHedgehog; |
|
210 |
Result^.IntersectGear:= CurrentHedgehog^.Gear |
|
211 |
end; |
|
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
789
diff
changeset
|
212 |
|
4 | 213 |
case Kind of |
915 | 214 |
gtAmmo_Bomb, |
215 |
gtClusterBomb: begin |
|
351 | 216 |
Result^.Radius:= 4; |
217 |
Result^.Elasticity:= _0_6; |
|
997 | 218 |
Result^.Friction:= _0_96; |
4 | 219 |
end; |
1261 | 220 |
gtWatermelon: begin |
221 |
Result^.Radius:= 4; |
|
222 |
Result^.Elasticity:= _0_8; |
|
223 |
Result^.Friction:= _0_995; |
|
224 |
end; |
|
4 | 225 |
gtHedgehog: begin |
351 | 226 |
Result^.Radius:= cHHRadius; |
227 |
Result^.Elasticity:= _0_35; |
|
228 |
Result^.Friction:= _0_999; |
|
229 |
Result^.Angle:= cMaxAngle div 2; |
|
230 |
Result^.Z:= cHHZ; |
|
4 | 231 |
end; |
232 |
gtAmmo_Grenade: begin |
|
351 | 233 |
Result^.Radius:= 4; |
4 | 234 |
end; |
235 |
gtHealthTag: begin |
|
351 | 236 |
Result^.Timer:= 1500; |
522 | 237 |
Result^.Z:= 2001; |
4 | 238 |
end; |
239 |
gtGrave: begin |
|
351 | 240 |
Result^.Radius:= 10; |
241 |
Result^.Elasticity:= _0_6; |
|
4 | 242 |
end; |
243 |
gtUFO: begin |
|
351 | 244 |
Result^.Radius:= 5; |
245 |
Result^.Timer:= 500; |
|
246 |
Result^.Elasticity:= _0_9 |
|
4 | 247 |
end; |
248 |
gtShotgunShot: begin |
|
351 | 249 |
Result^.Timer:= 900; |
250 |
Result^.Radius:= 2 |
|
4 | 251 |
end; |
252 |
gtPickHammer: begin |
|
351 | 253 |
Result^.Radius:= 10; |
254 |
Result^.Timer:= 4000 |
|
4 | 255 |
end; |
1263 | 256 |
gtSmokeTrace, |
257 |
gtEvilTrace: begin |
|
498 | 258 |
Result^.X:= Result^.X - _16; |
259 |
Result^.Y:= Result^.Y - _16; |
|
1270 | 260 |
Result^.State:= 8; |
261 |
Result^.Z:= cSmokeZ |
|
4 | 262 |
end; |
263 |
gtRope: begin |
|
351 | 264 |
Result^.Radius:= 3; |
498 | 265 |
Result^.Friction:= _450; |
4 | 266 |
RopePoints.Count:= 0; |
267 |
end; |
|
9 | 268 |
gtExplosion: begin |
1012 | 269 |
Result^.X:= Result^.X; |
270 |
Result^.Y:= Result^.Y; |
|
9 | 271 |
end; |
10 | 272 |
gtMine: begin |
503 | 273 |
Result^.State:= Result^.State or gstMoving; |
915 | 274 |
Result^.Radius:= 2; |
351 | 275 |
Result^.Elasticity:= _0_55; |
276 |
Result^.Friction:= _0_995; |
|
277 |
Result^.Timer:= 3000; |
|
10 | 278 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset
|
279 |
gtCase: begin |
351 | 280 |
Result^.Radius:= 16; |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
281 |
Result^.Elasticity:= _0_3 |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset
|
282 |
end; |
37 | 283 |
gtDEagleShot: begin |
351 | 284 |
Result^.Radius:= 1; |
285 |
Result^.Health:= 50 |
|
37 | 286 |
end; |
39 | 287 |
gtDynamite: begin |
351 | 288 |
Result^.Radius:= 3; |
289 |
Result^.Elasticity:= _0_55; |
|
290 |
Result^.Friction:= _0_03; |
|
291 |
Result^.Timer:= 5000; |
|
39 | 292 |
end; |
910 | 293 |
gtCluster: Result^.Radius:= 2; |
878 | 294 |
gtShover: Result^.Radius:= 20; |
79 | 295 |
gtFlame: begin |
1295 | 296 |
Result^.Tag:= Counter mod 64; |
351 | 297 |
Result^.Radius:= 1; |
298 |
Result^.Health:= 2; |
|
299 |
Result^.dY:= (getrandom - _0_8) * _0_03; |
|
300 |
Result^.dX:= (getrandom - _0_5) * _0_4 |
|
79 | 301 |
end; |
82 | 302 |
gtFirePunch: begin |
351 | 303 |
Result^.Radius:= 15; |
304 |
Result^.Tag:= Y |
|
82 | 305 |
end; |
302 | 306 |
gtAirBomb: begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
307 |
Result^.Radius:= 5; |
302 | 308 |
end; |
309 |
gtBlowTorch: begin |
|
511 | 310 |
Result^.Radius:= cHHRadius + cBlowTorchC; |
351 | 311 |
Result^.Timer:= 7500; |
302 | 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 |
|
1495 | 353 |
begin |
354 |
FreeTexture(Gear^.Tex); |
|
355 |
Gear^.Tex:= nil |
|
356 |
end; |
|
762 | 357 |
|
351 | 358 |
if Gear^.Kind = gtHedgehog then |
1495 | 359 |
if CurAmmoGear <> nil then |
360 |
begin |
|
361 |
Gear^.Message:= gm_Destroy; |
|
362 |
CurAmmoGear^.Message:= gm_Destroy; |
|
363 |
exit |
|
364 |
end |
|
365 |
else |
|
366 |
begin |
|
367 |
if not (hwRound(Gear^.Y) < cWaterLine) then |
|
368 |
begin |
|
369 |
t:= max(Gear^.Damage, Gear^.Health); |
|
370 |
Gear^.Damage:= t; |
|
371 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
372 |
uStats.HedgehogDamaged(Gear) |
|
373 |
end; |
|
374 |
team:= PHedgehog(Gear^.Hedgehog)^.Team; |
|
375 |
if CurrentHedgehog^.Gear = Gear then |
|
376 |
FreeActionsList; // to avoid ThinkThread on drawned gear |
|
377 |
PHedgehog(Gear^.Hedgehog)^.Gear:= nil; |
|
378 |
inc(KilledHHs); |
|
379 |
RecountTeamHealth(team); |
|
380 |
end; |
|
381 |
||
382 |
{$IFDEF DEBUGFILE} |
|
1503 | 383 |
with Gear^ do AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + inttostr(ord(Kind))); |
1495 | 384 |
{$ENDIF} |
385 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
593
diff
changeset
|
386 |
if Gear^.TriggerId <> 0 then TickTrigger(Gear^.TriggerId); |
82 | 387 |
if CurAmmoGear = Gear then CurAmmoGear:= nil; |
4 | 388 |
if FollowGear = Gear then FollowGear:= nil; |
294 | 389 |
RemoveGearFromList(Gear); |
1435
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
390 |
|
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
391 |
Dispose(Gear); |
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 |
Gear:= nil |
4 | 394 |
end; |
395 |
||
396 |
function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs |
|
397 |
var Gear: PGear; |
|
398 |
begin |
|
351 | 399 |
CheckNoDamage:= true; |
4 | 400 |
Gear:= GearsList; |
401 |
while Gear <> nil do |
|
867 | 402 |
begin |
403 |
if Gear^.Kind = gtHedgehog then |
|
404 |
if Gear^.Damage <> 0 then |
|
405 |
begin |
|
406 |
CheckNoDamage:= false; |
|
407 |
uStats.HedgehogDamaged(Gear); |
|
351 | 408 |
|
867 | 409 |
if Gear^.Health < Gear^.Damage then |
410 |
Gear^.Health:= 0 |
|
411 |
else |
|
412 |
dec(Gear^.Health, Gear^.Damage); |
|
413 |
||
414 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12, |
|
415 |
gtHealthTag, Gear^.Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
1505 | 416 |
|
867 | 417 |
RenderHealth(PHedgehog(Gear^.Hedgehog)^); |
418 |
RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team); |
|
419 |
||
420 |
Gear^.Damage:= 0 |
|
421 |
end; |
|
422 |
Gear:= Gear^.NextGear |
|
423 |
end; |
|
4 | 424 |
end; |
425 |
||
1054 | 426 |
procedure HealthMachine; |
427 |
var Gear: PGear; |
|
428 |
begin |
|
429 |
Gear:= GearsList; |
|
430 |
||
431 |
while Gear <> nil do |
|
432 |
begin |
|
433 |
if Gear^.Kind = gtHedgehog then |
|
434 |
Gear^.Damage:= min(cHealthDecrease, Gear^.Health - 1); |
|
435 |
||
436 |
Gear:= Gear^.NextGear |
|
437 |
end; |
|
438 |
end; |
|
439 |
||
4 | 440 |
procedure ProcessGears; |
614 | 441 |
const delay: LongWord = 0; |
1495 | 442 |
step: (stDelay, stChDmg, stTurnReact, |
443 |
stAfterDelay, stChWin, stWater, stChWin2, stHealth, |
|
444 |
stSpawn, stNTurn) = stDelay; |
|
1054 | 445 |
|
4 | 446 |
var Gear, t: PGear; |
447 |
begin |
|
868 | 448 |
PrvInactive:= AllInactive; |
4 | 449 |
AllInactive:= true; |
1495 | 450 |
|
4 | 451 |
t:= GearsList; |
1054 | 452 |
while t <> nil do |
1352
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
453 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
454 |
Gear:= t; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
455 |
t:= Gear^.NextGear; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
456 |
if Gear^.Active then Gear^.doStep(Gear); |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1346
diff
changeset
|
457 |
end; |
89 | 458 |
|
4 | 459 |
if AllInactive then |
1343 | 460 |
case step of |
461 |
stDelay: begin |
|
462 |
if delay = 0 then |
|
463 |
delay:= cInactDelay |
|
464 |
else |
|
465 |
dec(delay); |
|
614 | 466 |
|
1343 | 467 |
if delay = 0 then |
468 |
inc(step) |
|
469 |
end; |
|
470 |
stChDmg: if CheckNoDamage then inc(step) else step:= stDelay; |
|
471 |
stTurnReact: begin |
|
472 |
if (not bBetweenTurns) and (not isInMultiShoot) then |
|
473 |
begin |
|
474 |
uStats.TurnReaction; |
|
475 |
inc(step) |
|
476 |
end else |
|
477 |
inc(step, 2); |
|
478 |
end; |
|
479 |
stAfterDelay: begin |
|
480 |
if delay = 0 then |
|
481 |
delay:= cInactDelay |
|
482 |
else |
|
483 |
dec(delay); |
|
815 | 484 |
|
1343 | 485 |
if delay = 0 then |
486 |
inc(step) |
|
487 |
end; |
|
488 |
stChWin: begin |
|
489 |
CheckForWin; |
|
490 |
inc(step) |
|
491 |
end; |
|
492 |
stWater: if (not bBetweenTurns) and (not isInMultiShoot) then |
|
493 |
begin |
|
494 |
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
|
495 |
|
1343 | 496 |
if bWaterRising then |
497 |
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
|
498 |
|
1343 | 499 |
inc(step) |
500 |
end else inc(step); |
|
501 |
stChWin2: begin |
|
502 |
CheckForWin; |
|
503 |
inc(step) |
|
504 |
end; |
|
505 |
stHealth: begin |
|
506 |
if (TotalRounds = 15) and (cHealthDecrease = 0) then |
|
507 |
begin |
|
508 |
cHealthDecrease:= 5; |
|
509 |
AddCaption(trmsg[sidSuddenDeath], $FFFFFF, capgrpGameState) |
|
510 |
end; |
|
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
511 |
|
1343 | 512 |
if (cHealthDecrease = 0) |
513 |
or bBetweenTurns |
|
514 |
or isInMultiShoot |
|
515 |
or (TotalRounds = 0) then inc(step) |
|
516 |
else begin |
|
517 |
bBetweenTurns:= true; |
|
518 |
HealthMachine; |
|
519 |
step:= stChDmg |
|
520 |
end |
|
521 |
end; |
|
522 |
stSpawn: begin |
|
523 |
if not isInMultiShoot then SpawnBoxOfSmth; |
|
524 |
inc(step) |
|
525 |
end; |
|
526 |
stNTurn: begin |
|
527 |
if isInMultiShoot then isInMultiShoot:= false |
|
528 |
else begin |
|
529 |
ParseCommand('/nextturn', true); |
|
530 |
SwitchHedgehog; |
|
1298 | 531 |
|
1343 | 532 |
inc(step); |
1298 | 533 |
|
1343 | 534 |
AfterSwitchHedgehog; |
535 |
bBetweenTurns:= false |
|
536 |
end; |
|
537 |
step:= Low(step) |
|
538 |
end; |
|
539 |
end; |
|
15 | 540 |
|
4 | 541 |
if TurnTimeLeft > 0 then |
870 | 542 |
if CurrentHedgehog^.Gear <> nil then |
543 |
if ((CurrentHedgehog^.Gear^.State and gstAttacking) = 0) |
|
544 |
and not isInMultiShoot then |
|
545 |
begin |
|
546 |
if (TurnTimeLeft = 5000) |
|
547 |
and (CurrentHedgehog^.Gear <> nil) |
|
548 |
and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0) then PlaySound(sndHurry, false); |
|
549 |
dec(TurnTimeLeft) |
|
550 |
end; |
|
351 | 551 |
|
651 | 552 |
if (not CurrentTeam^.ExtDriven) and |
917 | 553 |
((GameTicks and $FFFF) = $FFFF) then |
554 |
begin |
|
555 |
SendIPCTimeInc; |
|
556 |
inc(hiTicks) // we do not recieve a message for this |
|
557 |
end; |
|
656
6d6d9d7b1054
Fix network game bug caused by recent protocol changes
unc0rr
parents:
651
diff
changeset
|
558 |
|
515 | 559 |
inc(GameTicks) |
4 | 560 |
end; |
561 |
||
562 |
procedure SetAllToActive; |
|
563 |
var t: PGear; |
|
564 |
begin |
|
565 |
AllInactive:= false; |
|
566 |
t:= GearsList; |
|
351 | 567 |
while t <> nil do |
1505 | 568 |
begin |
569 |
t^.Active:= true; |
|
570 |
t:= t^.NextGear |
|
571 |
end |
|
4 | 572 |
end; |
573 |
||
574 |
procedure SetAllHHToActive; |
|
575 |
var t: PGear; |
|
576 |
begin |
|
577 |
AllInactive:= false; |
|
578 |
t:= GearsList; |
|
351 | 579 |
while t <> nil do |
1505 | 580 |
begin |
581 |
if t^.Kind = gtHedgehog then t^.Active:= true; |
|
582 |
t:= t^.NextGear |
|
583 |
end |
|
4 | 584 |
end; |
585 |
||
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
586 |
procedure DrawHH(Gear: PGear); |
371 | 587 |
var t: LongInt; |
822 | 588 |
amt: TAmmoType; |
862 | 589 |
hx, hy, m: LongInt; |
590 |
aAngle, dAngle: real; |
|
1253 | 591 |
defaultPos, HatVisible: boolean; |
292 | 592 |
begin |
868 | 593 |
if (Gear^.State and gstHHDeath) <> 0 then |
594 |
begin |
|
595 |
DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos); |
|
596 |
exit |
|
597 |
end; |
|
1002 | 598 |
|
824 | 599 |
defaultPos:= true; |
1253 | 600 |
HatVisible:= false; |
847 | 601 |
|
1002 | 602 |
if (Gear^.State and gstDrowning) <> 0 then |
603 |
begin |
|
604 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
605 |
hwSign(Gear^.dX), |
|
606 |
1, |
|
607 |
7, |
|
608 |
0); |
|
609 |
defaultPos:= false |
|
610 |
end else |
|
611 |
||
1011 | 612 |
if (Gear^.State and gstWinner) <> 0 then |
613 |
begin |
|
614 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
615 |
hwSign(Gear^.dX), |
|
616 |
2, |
|
617 |
0, |
|
618 |
0); |
|
619 |
defaultPos:= false |
|
620 |
end else |
|
621 |
||
821
e6c0408b54ed
Use 'regular standing' and 'rope swing' hedgehog sprites
unc0rr
parents:
815
diff
changeset
|
622 |
if (Gear^.State and gstHHDriven) <> 0 then |
966 | 623 |
begin |
1002 | 624 |
hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx; |
625 |
hy:= hwRound(Gear^.Y) - 2 + WorldDy; |
|
626 |
aangle:= Gear^.Angle * 180 / cMaxAngle - 90; |
|
874 | 627 |
|
1002 | 628 |
if CurAmmoGear <> nil then |
629 |
begin |
|
630 |
case CurAmmoGear^.Kind of |
|
1294
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
631 |
gtShotgunShot: begin |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
632 |
if (CurAmmoGear^.State and gstAnimation <> 0) then |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
633 |
DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle) |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
634 |
else |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
635 |
DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
636 |
HatVisible:= true |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
637 |
end; |
1002 | 638 |
gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle); |
639 |
gtRope: begin |
|
640 |
if Gear^.X < CurAmmoGear^.X then |
|
641 |
begin |
|
642 |
dAngle:= 0; |
|
643 |
m:= 1 |
|
644 |
end else |
|
645 |
begin |
|
646 |
dAngle:= 180; |
|
647 |
m:= -1 |
|
966 | 648 |
end; |
1002 | 649 |
DrawHedgehog(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
650 |
m, |
|
651 |
1, |
|
652 |
0, |
|
653 |
DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle); |
|
654 |
defaultPos:= false |
|
655 |
end; |
|
656 |
gtBlowTorch: begin |
|
657 |
DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); |
|
658 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
659 |
hwSign(Gear^.dX), |
|
660 |
3, |
|
1113 | 661 |
PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, |
1002 | 662 |
0); |
663 |
defaultPos:= false |
|
664 |
end; |
|
665 |
gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180); |
|
666 |
gtFirePunch: begin |
|
667 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
668 |
hwSign(Gear^.dX), |
|
669 |
1, |
|
670 |
4, |
|
671 |
0); |
|
672 |
defaultPos:= false |
|
673 |
end; |
|
674 |
gtPickHammer, |
|
675 |
gtTeleport: defaultPos:= false; |
|
1010 | 676 |
gtWhip: begin |
677 |
DrawRotatedF(sprWhip, |
|
678 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
679 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
680 |
1, |
|
681 |
hwSign(Gear^.dX), |
|
682 |
0); |
|
683 |
defaultPos:= false |
|
684 |
end; |
|
1002 | 685 |
gtKamikaze: begin |
1286 | 686 |
if CurAmmoGear^.Pos = 0 then |
687 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
688 |
hwSign(Gear^.dX), |
|
689 |
1, |
|
690 |
6, |
|
691 |
0) |
|
692 |
else |
|
693 |
DrawRotatedF(sprKamikaze, |
|
694 |
hwRound(Gear^.X) + WorldDx, |
|
695 |
hwRound(Gear^.Y) + WorldDy, |
|
696 |
CurAmmoGear^.Pos - 1, |
|
697 |
1, |
|
698 |
DxDy2Angle(Gear^.dY, Gear^.dX)); |
|
1002 | 699 |
|
1286 | 700 |
defaultPos:= false |
701 |
end; |
|
702 |
gtSeduction: begin |
|
703 |
if CurAmmoGear^.Pos >= 6 then |
|
704 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
705 |
hwSign(Gear^.dX), |
|
706 |
2, |
|
707 |
2, |
|
708 |
0) |
|
709 |
else |
|
710 |
begin |
|
711 |
DrawRotatedF(sprDress, |
|
712 |
hwRound(Gear^.X) + WorldDx, |
|
713 |
hwRound(Gear^.Y) + WorldDy, |
|
714 |
CurAmmoGear^.Pos, |
|
715 |
hwSign(Gear^.dX), |
|
716 |
0); |
|
717 |
DrawSprite(sprCensored, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 20 + WorldDy, 0) |
|
718 |
end; |
|
719 |
defaultPos:= false |
|
720 |
end; |
|
1002 | 721 |
end; |
722 |
||
723 |
case CurAmmoGear^.Kind of |
|
724 |
gtShotgunShot, |
|
725 |
gtDEagleShot, |
|
726 |
gtShover: begin |
|
727 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
728 |
hwSign(Gear^.dX), |
|
729 |
0, |
|
730 |
4, |
|
731 |
0); |
|
732 |
defaultPos:= false |
|
733 |
end |
|
734 |
end |
|
735 |
end else |
|
876 | 736 |
|
1002 | 737 |
if ((Gear^.State and gstHHJumping) <> 0) then |
738 |
begin |
|
739 |
if ((Gear^.State and gstHHHJump) <> 0) then |
|
740 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
741 |
- hwSign(Gear^.dX), |
|
742 |
1, |
|
743 |
1, |
|
744 |
0) |
|
745 |
else |
|
746 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
747 |
hwSign(Gear^.dX), |
|
748 |
1, |
|
749 |
1, |
|
750 |
0); |
|
751 |
defaultPos:= false |
|
752 |
end else |
|
874 | 753 |
|
1002 | 754 |
if (Gear^.Message and (gm_Left or gm_Right) <> 0) then |
824 | 755 |
begin |
1002 | 756 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
757 |
hwSign(Gear^.dX), |
|
758 |
0, |
|
759 |
PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, |
|
760 |
0); |
|
1257 | 761 |
defaultPos:= false; |
762 |
HatVisible:= true |
|
1002 | 763 |
end |
764 |
else |
|
765 |
||
1033 | 766 |
if ((Gear^.State and gstAnimation) <> 0) then |
767 |
begin |
|
1034 | 768 |
DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite, |
1033 | 769 |
hwRound(Gear^.X) + 1 + WorldDx, |
770 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
771 |
Gear^.Pos, |
|
772 |
hwSign(Gear^.dX), |
|
773 |
0.0); |
|
774 |
defaultPos:= false |
|
775 |
end |
|
776 |
else |
|
1002 | 777 |
if ((Gear^.State and gstAttacked) = 0) then |
778 |
begin |
|
779 |
amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType; |
|
780 |
case amt of |
|
781 |
amBazooka, |
|
782 |
amMortar: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle); |
|
783 |
amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle); |
|
784 |
amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); |
|
785 |
amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle); |
|
786 |
amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); |
|
787 |
end; |
|
788 |
||
789 |
case amt of |
|
790 |
amAirAttack, |
|
791 |
amMineStrike: DrawRotated(sprHandAirAttack, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0); |
|
792 |
amPickHammer: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
793 |
hwSign(Gear^.dX), |
|
794 |
1, |
|
795 |
2, |
|
796 |
0); |
|
797 |
amBlowTorch: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
798 |
hwSign(Gear^.dX), |
|
799 |
1, |
|
800 |
3, |
|
801 |
0); |
|
802 |
amTeleport: DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, 0, hwSign(Gear^.dX), 0); |
|
803 |
amKamikaze: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
804 |
hwSign(Gear^.dX), |
|
805 |
1, |
|
806 |
5, |
|
807 |
0); |
|
1221 | 808 |
amWhip: DrawRotatedF(sprWhip, |
1010 | 809 |
hwRound(Gear^.X) + 1 + WorldDx, |
810 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
811 |
0, |
|
812 |
hwSign(Gear^.dX), |
|
813 |
0); |
|
1002 | 814 |
else |
822 | 815 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
816 |
hwSign(Gear^.dX), |
|
817 |
0, |
|
1002 | 818 |
4, |
822 | 819 |
0); |
1253 | 820 |
|
821 |
HatVisible:= true; |
|
822 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
1294
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
823 |
if (HatTex <> nil) |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
824 |
and (HatVisibility > 0) then |
1253 | 825 |
DrawTextureF(HatTex, |
826 |
HatVisibility, |
|
827 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
828 |
hwRound(Gear^.Y) - 8 + WorldDy, |
|
829 |
0, |
|
830 |
hwSign(Gear^.dX), |
|
831 |
32); |
|
1002 | 832 |
end; |
966 | 833 |
|
1002 | 834 |
case amt of |
835 |
amBaseballBat: DrawRotated(sprHandBaseball, |
|
836 |
hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx, |
|
837 |
hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle); |
|
838 |
end; |
|
966 | 839 |
|
1002 | 840 |
defaultPos:= false |
841 |
end |
|
842 |
end else // not gstHHDriven |
|
1012 | 843 |
begin |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
844 |
if (Gear^.Damage > 0) |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
845 |
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
|
846 |
begin |
1012 | 847 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
848 |
hwSign(Gear^.dX), |
|
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
849 |
2, |
1012 | 850 |
1, |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
851 |
Gear^.DirAngle); |
1012 | 852 |
defaultPos:= false |
1020 | 853 |
end else |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
854 |
|
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
855 |
if ((Gear^.State and gstHHJumping) <> 0) then |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
856 |
begin |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
857 |
if ((Gear^.State and gstHHHJump) <> 0) then |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
858 |
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
|
859 |
- hwSign(Gear^.dX), |
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 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
862 |
0) |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
863 |
else |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
864 |
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
|
865 |
hwSign(Gear^.dX), |
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 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
868 |
0); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
869 |
defaultPos:= false |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
870 |
end; |
1012 | 871 |
end; |
834 | 872 |
|
1251 | 873 |
with PHedgehog(Gear^.Hedgehog)^ do |
970 | 874 |
begin |
1251 | 875 |
if defaultPos then |
876 |
begin |
|
877 |
DrawRotatedF(sprHHIdle, |
|
878 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
879 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
880 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
|
881 |
hwSign(Gear^.dX), |
|
882 |
0); |
|
1253 | 883 |
HatVisible:= true; |
884 |
end; |
|
885 |
||
886 |
if HatVisible then |
|
1251 | 887 |
if HatVisibility < 1.0 then |
1254 | 888 |
HatVisibility:= HatVisibility + 0.2 |
1253 | 889 |
else |
1251 | 890 |
else |
891 |
if HatVisibility > 0.0 then |
|
1254 | 892 |
HatVisibility:= HatVisibility - 0.2; |
1253 | 893 |
|
1294
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
894 |
if (HatTex <> nil) |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
895 |
and (HatVisibility > 0) then |
1255 | 896 |
if DefaultPos then |
897 |
DrawTextureF(HatTex, |
|
898 |
HatVisibility, |
|
899 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
900 |
hwRound(Gear^.Y) - 8 + WorldDy, |
|
901 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
|
902 |
hwSign(Gear^.dX), |
|
903 |
32) |
|
904 |
else |
|
905 |
DrawTextureF(HatTex, |
|
906 |
HatVisibility, |
|
907 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
908 |
hwRound(Gear^.Y) - 8 + WorldDy, |
|
909 |
0, |
|
910 |
hwSign(Gear^.dX), |
|
911 |
32); |
|
970 | 912 |
end; |
292 | 913 |
|
1251 | 914 |
|
351 | 915 |
with PHedgehog(Gear^.Hedgehog)^ do |
994 | 916 |
begin |
1011 | 917 |
if ((Gear^.State and not gstWinner) = 0) |
994 | 918 |
or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then |
958 | 919 |
begin |
976 | 920 |
t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy; |
958 | 921 |
if (cTagsMask and 1) <> 0 then |
922 |
begin |
|
923 |
dec(t, HealthTagTex^.h + 2); |
|
924 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex) |
|
925 |
end; |
|
926 |
if (cTagsMask and 2) <> 0 then |
|
927 |
begin |
|
928 |
dec(t, NameTagTex^.h + 2); |
|
929 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTagTex) |
|
930 |
end; |
|
931 |
if (cTagsMask and 4) <> 0 then |
|
932 |
begin |
|
933 |
dec(t, Team^.NameTagTex^.h + 2); |
|
934 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex) |
|
935 |
end |
|
994 | 936 |
end; |
937 |
if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog |
|
958 | 938 |
begin |
939 |
if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then |
|
940 |
DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy, |
|
941 |
GameTicks div 32 mod 16); |
|
821
e6c0408b54ed
Use 'regular standing' and 'rope swing' hedgehog sprites
unc0rr
parents:
815
diff
changeset
|
942 |
|
958 | 943 |
if (Gear^.State and gstDrowning) = 0 then |
944 |
if (Gear^.State and gstHHThinking) <> 0 then |
|
945 |
DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, 0) |
|
946 |
else |
|
1033 | 947 |
if ShowCrosshair and ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then |
958 | 948 |
begin |
949 |
if ((Gear^.State and gstHHHJump) <> 0) then m:= -1 else m:= 1; |
|
950 |
DrawRotatedTex(Team^.CrosshairTex, |
|
951 |
12, 12, |
|
1283
a1e99d1e4fd3
Enable back the ability to see chosen team color in team widget
unc0rr
parents:
1279
diff
changeset
|
952 |
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
|
953 |
Round(hwRound(Gear^.Y) - Cos(Gear^.Angle*pi/cMaxAngle) * 80) + WorldDy, 0, |
958 | 954 |
hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle) |
955 |
end |
|
994 | 956 |
end |
957 |
end |
|
292 | 958 |
end; |
959 |
||
956 | 960 |
procedure DrawGears; |
853 | 961 |
var Gear, HHGear: PGear; |
4 | 962 |
i: Longword; |
371 | 963 |
roplen: LongInt; |
4 | 964 |
|
371 | 965 |
procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt); |
966 |
var eX, eY, dX, dY: LongInt; |
|
967 |
i, sX, sY, x, y, d: LongInt; |
|
366 | 968 |
b: boolean; |
4 | 969 |
begin |
37 | 970 |
if (X1 = X2) and (Y1 = Y2) then |
971 |
begin |
|
351 | 972 |
OutError('WARNING: zero length rope line!', false); |
37 | 973 |
exit |
974 |
end; |
|
366 | 975 |
eX:= 0; |
976 |
eY:= 0; |
|
977 |
dX:= X2 - X1; |
|
978 |
dY:= Y2 - Y1; |
|
979 |
||
980 |
if (dX > 0) then sX:= 1 |
|
981 |
else |
|
982 |
if (dX < 0) then |
|
983 |
begin |
|
984 |
sX:= -1; |
|
985 |
dX:= -dX |
|
986 |
end else sX:= dX; |
|
987 |
||
988 |
if (dY > 0) then sY:= 1 |
|
989 |
else |
|
990 |
if (dY < 0) then |
|
4 | 991 |
begin |
366 | 992 |
sY:= -1; |
993 |
dY:= -dY |
|
994 |
end else sY:= dY; |
|
995 |
||
996 |
if (dX > dY) then d:= dX |
|
997 |
else d:= dY; |
|
998 |
||
999 |
x:= X1; |
|
1000 |
y:= Y1; |
|
1001 |
||
1002 |
for i:= 0 to d do |
|
1003 |
begin |
|
1004 |
inc(eX, dX); |
|
1005 |
inc(eY, dY); |
|
1006 |
b:= false; |
|
1007 |
if (eX > d) then |
|
35 | 1008 |
begin |
366 | 1009 |
dec(eX, d); |
1010 |
inc(x, sX); |
|
1011 |
b:= true |
|
35 | 1012 |
end; |
366 | 1013 |
if (eY > d) then |
35 | 1014 |
begin |
366 | 1015 |
dec(eY, d); |
1016 |
inc(y, sY); |
|
1017 |
b:= true |
|
35 | 1018 |
end; |
366 | 1019 |
if b then |
1020 |
begin |
|
1021 |
inc(roplen); |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1022 |
if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0) |
366 | 1023 |
end |
4 | 1024 |
end |
366 | 1025 |
end; |
4 | 1026 |
|
1027 |
begin |
|
1028 |
Gear:= GearsList; |
|
1029 |
while Gear<>nil do |
|
1030 |
begin |
|
351 | 1031 |
case Gear^.Kind of |
822 | 1032 |
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
|
1033 |
gtHedgehog: DrawHH(Gear); |
822 | 1034 |
gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1505 | 1035 |
gtHealthTag: 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; |
|
1505 | 1110 |
while tt <> nil do |
1111 |
begin |
|
1112 |
t:= tt; |
|
1113 |
tt:= tt^.NextGear; |
|
1114 |
Dispose(t) |
|
1115 |
end; |
|
4 | 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 |
|
1505 | 1161 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color) |
1200 | 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 |
1505 | 1206 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, PHedgehog(t^.Hedgehog)^.Team^.Clan^.Color); |
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 |
1505 | 1243 |
AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, PHedgehog(t^.ar[i]^.Hedgehog)^.Team^.Clan^.Color); |
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. |