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