author | unc0rr |
Wed, 10 Dec 2008 18:47:16 +0000 | |
changeset 1543 | 2e800851cb8f |
parent 1528 | 3fee15104c1d |
child 1555 | 0a62938e695a |
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; |
1528 | 98 |
procedure doStepHedgehogMoving(Gear: PGear); forward; |
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
99 |
procedure HedgehogChAngle(Gear: PGear); forward; |
506 | 100 |
procedure ShotgunShot(Gear: PGear); forward; |
4 | 101 |
|
102 |
{$INCLUDE GSHandlers.inc} |
|
103 |
{$INCLUDE HHHandlers.inc} |
|
104 |
||
105 |
const doStepHandlers: array[TGearType] of TGearStepProcedure = ( |
|
1259 | 106 |
@doStepBomb, |
107 |
@doStepHedgehog, |
|
108 |
@doStepGrenade, |
|
109 |
@doStepHealthTag, |
|
110 |
@doStepGrave, |
|
111 |
@doStepUFO, |
|
112 |
@doStepShotgunShot, |
|
113 |
@doStepPickHammer, |
|
114 |
@doStepRope, |
|
115 |
@doStepSmokeTrace, |
|
116 |
@doStepExplosion, |
|
117 |
@doStepMine, |
|
118 |
@doStepCase, |
|
119 |
@doStepDEagleShot, |
|
120 |
@doStepDynamite, |
|
121 |
@doStepTeamHealthSorter, |
|
122 |
@doStepBomb, |
|
123 |
@doStepCluster, |
|
124 |
@doStepShover, |
|
125 |
@doStepFlame, |
|
126 |
@doStepFirePunch, |
|
127 |
@doStepActionTimer, |
|
128 |
@doStepActionTimer, |
|
129 |
@doStepActionTimer, |
|
130 |
@doStepParachute, |
|
131 |
@doStepAirAttack, |
|
132 |
@doStepAirBomb, |
|
133 |
@doStepBlowTorch, |
|
134 |
@doStepGirder, |
|
135 |
@doStepTeleport, |
|
136 |
@doStepSwitcher, |
|
137 |
@doStepCase, |
|
138 |
@doStepMortar, |
|
139 |
@doStepWhip, |
|
140 |
@doStepKamikaze, |
|
141 |
@doStepCake, |
|
1261 | 142 |
@doStepSeduction, |
1279 | 143 |
@doStepWatermelon, |
1263 | 144 |
@doStepCluster, |
145 |
@doStepBomb, |
|
1298 | 146 |
@doStepSmokeTrace, |
147 |
@doStepWaterUp |
|
1259 | 148 |
); |
4 | 149 |
|
294 | 150 |
procedure InsertGearToList(Gear: PGear); |
803 | 151 |
var tmp, ptmp: PGear; |
294 | 152 |
begin |
153 |
if GearsList = nil then |
|
1505 | 154 |
GearsList:= Gear |
155 |
else begin |
|
156 |
tmp:= GearsList; |
|
157 |
ptmp:= GearsList; |
|
158 |
while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do |
|
159 |
begin |
|
160 |
ptmp:= tmp; |
|
161 |
tmp:= tmp^.NextGear |
|
162 |
end; |
|
294 | 163 |
|
1505 | 164 |
if ptmp <> nil then |
165 |
begin |
|
166 |
Gear^.NextGear:= ptmp^.NextGear; |
|
167 |
Gear^.PrevGear:= ptmp; |
|
168 |
if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear; |
|
169 |
ptmp^.NextGear:= Gear |
|
170 |
end |
|
171 |
else GearsList:= Gear |
|
172 |
end |
|
294 | 173 |
end; |
174 |
||
175 |
procedure RemoveGearFromList(Gear: PGear); |
|
176 |
begin |
|
351 | 177 |
if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear; |
1505 | 178 |
if Gear^.PrevGear <> nil then |
179 |
Gear^.PrevGear^.NextGear:= Gear^.NextGear |
|
180 |
else |
|
181 |
GearsList:= Gear^.NextGear |
|
294 | 182 |
end; |
183 |
||
371 | 184 |
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
79 | 185 |
const Counter: Longword = 0; |
351 | 186 |
var Result: PGear; |
4 | 187 |
begin |
79 | 188 |
inc(Counter); |
1495 | 189 |
{$IFDEF DEBUGFILE} |
1503 | 190 |
AddFileLog('AddGear: #' + inttostr(Counter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + inttostr(ord(Kind))); |
1495 | 191 |
{$ENDIF} |
192 |
||
4 | 193 |
New(Result); |
194 |
FillChar(Result^, sizeof(TGear), 0); |
|
498 | 195 |
Result^.X:= int2hwFloat(X); |
196 |
Result^.Y:= int2hwFloat(Y); |
|
351 | 197 |
Result^.Kind := Kind; |
198 |
Result^.State:= State; |
|
199 |
Result^.Active:= true; |
|
200 |
Result^.dX:= dX; |
|
201 |
Result^.dY:= dY; |
|
202 |
Result^.doStep:= doStepHandlers[Kind]; |
|
511 | 203 |
Result^.CollisionIndex:= -1; |
351 | 204 |
Result^.Timer:= Timer; |
1270 | 205 |
Result^.Z:= cUsualZ; |
1503 | 206 |
Result^.uid:= Counter; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
503
diff
changeset
|
207 |
|
4 | 208 |
if CurrentTeam <> nil then |
1505 | 209 |
begin |
210 |
Result^.Hedgehog:= CurrentHedgehog; |
|
211 |
Result^.IntersectGear:= CurrentHedgehog^.Gear |
|
212 |
end; |
|
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
789
diff
changeset
|
213 |
|
4 | 214 |
case Kind of |
915 | 215 |
gtAmmo_Bomb, |
216 |
gtClusterBomb: begin |
|
351 | 217 |
Result^.Radius:= 4; |
218 |
Result^.Elasticity:= _0_6; |
|
997 | 219 |
Result^.Friction:= _0_96; |
4 | 220 |
end; |
1261 | 221 |
gtWatermelon: begin |
222 |
Result^.Radius:= 4; |
|
223 |
Result^.Elasticity:= _0_8; |
|
224 |
Result^.Friction:= _0_995; |
|
225 |
end; |
|
4 | 226 |
gtHedgehog: begin |
351 | 227 |
Result^.Radius:= cHHRadius; |
228 |
Result^.Elasticity:= _0_35; |
|
229 |
Result^.Friction:= _0_999; |
|
230 |
Result^.Angle:= cMaxAngle div 2; |
|
231 |
Result^.Z:= cHHZ; |
|
4 | 232 |
end; |
233 |
gtAmmo_Grenade: begin |
|
351 | 234 |
Result^.Radius:= 4; |
4 | 235 |
end; |
236 |
gtHealthTag: begin |
|
351 | 237 |
Result^.Timer:= 1500; |
522 | 238 |
Result^.Z:= 2001; |
4 | 239 |
end; |
240 |
gtGrave: begin |
|
351 | 241 |
Result^.Radius:= 10; |
242 |
Result^.Elasticity:= _0_6; |
|
4 | 243 |
end; |
244 |
gtUFO: begin |
|
351 | 245 |
Result^.Radius:= 5; |
246 |
Result^.Timer:= 500; |
|
247 |
Result^.Elasticity:= _0_9 |
|
4 | 248 |
end; |
249 |
gtShotgunShot: begin |
|
351 | 250 |
Result^.Timer:= 900; |
251 |
Result^.Radius:= 2 |
|
4 | 252 |
end; |
253 |
gtPickHammer: begin |
|
351 | 254 |
Result^.Radius:= 10; |
255 |
Result^.Timer:= 4000 |
|
4 | 256 |
end; |
1263 | 257 |
gtSmokeTrace, |
258 |
gtEvilTrace: begin |
|
498 | 259 |
Result^.X:= Result^.X - _16; |
260 |
Result^.Y:= Result^.Y - _16; |
|
1270 | 261 |
Result^.State:= 8; |
262 |
Result^.Z:= cSmokeZ |
|
4 | 263 |
end; |
264 |
gtRope: begin |
|
351 | 265 |
Result^.Radius:= 3; |
498 | 266 |
Result^.Friction:= _450; |
4 | 267 |
RopePoints.Count:= 0; |
268 |
end; |
|
9 | 269 |
gtExplosion: begin |
1012 | 270 |
Result^.X:= Result^.X; |
271 |
Result^.Y:= Result^.Y; |
|
9 | 272 |
end; |
10 | 273 |
gtMine: begin |
503 | 274 |
Result^.State:= Result^.State or gstMoving; |
915 | 275 |
Result^.Radius:= 2; |
351 | 276 |
Result^.Elasticity:= _0_55; |
277 |
Result^.Friction:= _0_995; |
|
278 |
Result^.Timer:= 3000; |
|
10 | 279 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset
|
280 |
gtCase: begin |
351 | 281 |
Result^.Radius:= 16; |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
282 |
Result^.Elasticity:= _0_3 |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset
|
283 |
end; |
37 | 284 |
gtDEagleShot: begin |
351 | 285 |
Result^.Radius:= 1; |
286 |
Result^.Health:= 50 |
|
37 | 287 |
end; |
39 | 288 |
gtDynamite: begin |
351 | 289 |
Result^.Radius:= 3; |
290 |
Result^.Elasticity:= _0_55; |
|
291 |
Result^.Friction:= _0_03; |
|
292 |
Result^.Timer:= 5000; |
|
39 | 293 |
end; |
910 | 294 |
gtCluster: Result^.Radius:= 2; |
878 | 295 |
gtShover: Result^.Radius:= 20; |
79 | 296 |
gtFlame: begin |
1295 | 297 |
Result^.Tag:= Counter mod 64; |
351 | 298 |
Result^.Radius:= 1; |
299 |
Result^.Health:= 2; |
|
300 |
Result^.dY:= (getrandom - _0_8) * _0_03; |
|
301 |
Result^.dX:= (getrandom - _0_5) * _0_4 |
|
79 | 302 |
end; |
82 | 303 |
gtFirePunch: begin |
351 | 304 |
Result^.Radius:= 15; |
305 |
Result^.Tag:= Y |
|
82 | 306 |
end; |
302 | 307 |
gtAirBomb: begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
308 |
Result^.Radius:= 5; |
302 | 309 |
end; |
310 |
gtBlowTorch: begin |
|
511 | 311 |
Result^.Radius:= cHHRadius + cBlowTorchC; |
351 | 312 |
Result^.Timer:= 7500; |
302 | 313 |
end; |
540 | 314 |
gtSwitcher: begin |
315 |
Result^.Z:= cCurrHHZ |
|
316 |
end; |
|
593 | 317 |
gtTarget: begin |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
318 |
Result^.Radius:= 16; |
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
319 |
Result^.Elasticity:= _0_3 |
593 | 320 |
end; |
924 | 321 |
gtMortar: begin |
994 | 322 |
Result^.Radius:= 4; |
924 | 323 |
Result^.Elasticity:= _0_2; |
324 |
Result^.Friction:= _0_08 |
|
325 |
end; |
|
925 | 326 |
gtWhip: Result^.Radius:= 20; |
984 | 327 |
gtKamikaze: begin |
328 |
Result^.Health:= 2048; |
|
329 |
Result^.Radius:= 20 |
|
330 |
end; |
|
1089 | 331 |
gtCake: begin |
1261 | 332 |
Result^.Health:= 2048; |
1103 | 333 |
Result^.Radius:= 7; |
1109 | 334 |
Result^.Z:= cOnHHZ; |
1089 | 335 |
if hwSign(dX) > 0 then Result^.Angle:= 1 else Result^.Angle:= 3 |
336 |
end; |
|
1263 | 337 |
gtHellishBomb: begin |
338 |
Result^.Radius:= 4; |
|
339 |
Result^.Elasticity:= _0_5; |
|
340 |
Result^.Friction:= _0_96; |
|
341 |
end; |
|
4 | 342 |
end; |
351 | 343 |
InsertGearToList(Result); |
344 |
AddGear:= Result |
|
4 | 345 |
end; |
346 |
||
1515 | 347 |
procedure DeleteGear(Gear: PGear); |
48 | 348 |
var team: PTeam; |
1515 | 349 |
t: Longword; |
4 | 350 |
begin |
503 | 351 |
DeleteCI(Gear); |
762 | 352 |
|
353 |
if Gear^.Tex <> nil then |
|
1495 | 354 |
begin |
355 |
FreeTexture(Gear^.Tex); |
|
356 |
Gear^.Tex:= nil |
|
357 |
end; |
|
762 | 358 |
|
351 | 359 |
if Gear^.Kind = gtHedgehog then |
1495 | 360 |
if CurAmmoGear <> nil then |
361 |
begin |
|
362 |
Gear^.Message:= gm_Destroy; |
|
363 |
CurAmmoGear^.Message:= gm_Destroy; |
|
364 |
exit |
|
365 |
end |
|
366 |
else |
|
367 |
begin |
|
368 |
if not (hwRound(Gear^.Y) < cWaterLine) then |
|
369 |
begin |
|
370 |
t:= max(Gear^.Damage, Gear^.Health); |
|
371 |
Gear^.Damage:= t; |
|
372 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
373 |
uStats.HedgehogDamaged(Gear) |
|
374 |
end; |
|
1515 | 375 |
|
1495 | 376 |
team:= PHedgehog(Gear^.Hedgehog)^.Team; |
377 |
if CurrentHedgehog^.Gear = Gear then |
|
378 |
FreeActionsList; // to avoid ThinkThread on drawned gear |
|
1515 | 379 |
|
1495 | 380 |
PHedgehog(Gear^.Hedgehog)^.Gear:= nil; |
381 |
inc(KilledHHs); |
|
1515 | 382 |
RecountTeamHealth(team) |
1495 | 383 |
end; |
384 |
{$IFDEF DEBUGFILE} |
|
1503 | 385 |
with Gear^ do AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + inttostr(ord(Kind))); |
1495 | 386 |
{$ENDIF} |
387 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
593
diff
changeset
|
388 |
if Gear^.TriggerId <> 0 then TickTrigger(Gear^.TriggerId); |
82 | 389 |
if CurAmmoGear = Gear then CurAmmoGear:= nil; |
4 | 390 |
if FollowGear = Gear then FollowGear:= nil; |
294 | 391 |
RemoveGearFromList(Gear); |
1435
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
392 |
|
1515 | 393 |
Dispose(Gear) |
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; |
1515 | 1120 |
Gear: PGear; |
4 | 1121 |
begin |
498 | 1122 |
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
|
1123 |
|
22 | 1124 |
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
|
1125 |
for i:= 0 to Pred(cLandAdditions) do |
1515 | 1126 |
begin |
1127 |
Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0); |
|
1128 |
FindPlace(Gear, false, 0, 2048) |
|
1129 |
end |
|
4 | 1130 |
end; |
1131 |
||
371 | 1132 |
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); |
4 | 1133 |
var Gear: PGear; |
506 | 1134 |
dmg, dmgRadius: LongInt; |
4 | 1135 |
begin |
1136 |
TargetPoint.X:= NoPointX; |
|
1434 | 1137 |
{$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF} |
1049 | 1138 |
if (Radius > 10) then AddGear(X, Y, gtExplosion, 0, _0, _0, 0); |
355 | 1139 |
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false); |
1433 | 1140 |
|
1141 |
if (Mask and EXPLAllDamageInRadius) = 0 then |
|
1142 |
dmgRadius:= Radius shl 1 |
|
1143 |
else |
|
1144 |
dmgRadius:= Radius; |
|
1145 |
||
4 | 1146 |
Gear:= GearsList; |
1147 |
while Gear <> nil do |
|
1200 | 1148 |
begin |
1149 |
dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
|
1150 |
if (dmg > 1) and |
|
1151 |
((Gear^.State and gstNoDamage) = 0) then |
|
1152 |
begin |
|
1153 |
dmg:= min(dmg div 2, Radius); |
|
1154 |
case Gear^.Kind of |
|
1155 |
gtHedgehog, |
|
1156 |
gtMine, |
|
1157 |
gtCase, |
|
1158 |
gtTarget, |
|
1159 |
gtFlame: begin |
|
1346 | 1160 |
//{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} |
1200 | 1161 |
if (Mask and EXPLNoDamage) = 0 then |
1162 |
begin |
|
1163 |
inc(Gear^.Damage, dmg); |
|
1164 |
if Gear^.Kind = gtHedgehog then |
|
1505 | 1165 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color) |
1200 | 1166 |
end; |
1167 |
if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then |
|
1168 |
begin |
|
1169 |
DeleteCI(Gear); |
|
1170 |
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X)); |
|
1171 |
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y)); |
|
1172 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); |
|
1173 |
Gear^.Active:= true; |
|
1174 |
FollowGear:= Gear |
|
1175 |
end; |
|
1176 |
end; |
|
1177 |
gtGrave: begin |
|
1178 |
Gear^.dY:= - _0_004 * dmg; |
|
1179 |
Gear^.Active:= true; |
|
1180 |
end; |
|
1181 |
end; |
|
1182 |
end; |
|
1183 |
Gear:= Gear^.NextGear |
|
1184 |
end; |
|
1185 |
||
621 | 1186 |
if (Mask and EXPLDontDraw) = 0 then |
1200 | 1187 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(X, Y, Radius); |
1188 |
||
498 | 1189 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
4 | 1190 |
end; |
1191 |
||
506 | 1192 |
procedure ShotgunShot(Gear: PGear); |
1193 |
var t: PGear; |
|
955 | 1194 |
dmg: LongInt; |
506 | 1195 |
begin |
509 | 1196 |
Gear^.Radius:= cShotgunRadius; |
506 | 1197 |
t:= GearsList; |
1198 |
while t <> nil do |
|
1286 | 1199 |
begin |
1200 |
dmg:= min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25); |
|
1201 |
if dmg > 0 then |
|
1202 |
case t^.Kind of |
|
1203 |
gtHedgehog, |
|
1204 |
gtMine, |
|
1205 |
gtCase, |
|
1206 |
gtTarget: begin |
|
1207 |
inc(t^.Damage, dmg); |
|
867 | 1208 |
|
1286 | 1209 |
if t^.Kind = gtHedgehog then |
1505 | 1210 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, PHedgehog(t^.Hedgehog)^.Team^.Clan^.Color); |
867 | 1211 |
|
1286 | 1212 |
DeleteCI(t); |
1213 |
t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); |
|
1214 |
t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; |
|
1215 |
t^.State:= t^.State or gstMoving; |
|
1216 |
t^.Active:= true; |
|
1217 |
FollowGear:= t |
|
1218 |
end; |
|
1219 |
gtGrave: begin |
|
1220 |
t^.dY:= - _0_1; |
|
1221 |
t^.Active:= true |
|
1222 |
end; |
|
1223 |
end; |
|
1224 |
t:= t^.NextGear |
|
1225 |
end; |
|
621 | 1226 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) |
506 | 1227 |
end; |
1228 |
||
371 | 1229 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
53 | 1230 |
var t: PGearArray; |
371 | 1231 |
i: LongInt; |
38 | 1232 |
begin |
53 | 1233 |
t:= CheckGearsCollision(Ammo); |
351 | 1234 |
i:= t^.Count; |
1506 | 1235 |
|
53 | 1236 |
while i > 0 do |
981 | 1237 |
begin |
1238 |
dec(i); |
|
1239 |
if (t^.ar[i]^.State and gstNoDamage) = 0 then |
|
1240 |
case t^.ar[i]^.Kind of |
|
1241 |
gtHedgehog, |
|
1242 |
gtMine, |
|
1243 |
gtTarget, |
|
1244 |
gtCase: begin |
|
1245 |
inc(t^.ar[i]^.Damage, Damage); |
|
1246 |
||
1284 | 1247 |
if (t^.ar[i]^.Kind = gtHedgehog) and (Damage > 0) then |
1505 | 1248 |
AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, PHedgehog(t^.ar[i]^.Hedgehog)^.Team^.Clan^.Color); |
867 | 1249 |
|
981 | 1250 |
DeleteCI(t^.ar[i]); |
1251 |
t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01; |
|
1252 |
t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01; |
|
1253 |
t^.ar[i]^.Active:= true; |
|
1254 |
t^.ar[i]^.State:= t^.ar[i]^.State or gstMoving; |
|
867 | 1255 |
|
982 | 1256 |
if TestCollisionXwithGear(t^.ar[i], hwSign(t^.ar[i]^.dX)) then |
981 | 1257 |
begin |
1258 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -3, hwSign(t^.ar[i]^.dX)) |
|
1259 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1260 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX)) |
|
1261 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1262 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX)) |
|
1263 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1264 |
end; |
|
982 | 1265 |
|
981 | 1266 |
FollowGear:= t^.ar[i] |
1267 |
end; |
|
1268 |
end |
|
1269 |
end; |
|
126 | 1270 |
SetAllToActive |
38 | 1271 |
end; |
1272 |
||
4 | 1273 |
procedure AssignHHCoords; |
955 | 1274 |
var i, t, p, j: LongInt; |
1515 | 1275 |
ar: array[0..Pred(cMaxHHs)] of PHedgehog; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1276 |
Count: Longword; |
4 | 1277 |
begin |
1428 | 1278 |
if (GameFlags and (gfForts or gfDivideTeams)) <> 0 then |
955 | 1279 |
begin |
1280 |
t:= 0; |
|
1428 | 1281 |
TryDo(ClansCount = 2, 'More or less than 2 clans on map in divided teams mode!', true); |
955 | 1282 |
for p:= 0 to 1 do |
1283 |
begin |
|
1284 |
with ClansArray[p]^ do |
|
1285 |
for j:= 0 to Pred(TeamsNumber) do |
|
1286 |
with Teams[j]^ do |
|
1287 |
for i:= 0 to cMaxHHIndex do |
|
1288 |
with Hedgehogs[i] do |
|
958 | 1289 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
1290 |
begin |
|
1515 | 1291 |
FindPlace(Gear, false, t, t + 1024);// could make Gear == nil |
1292 |
if Gear <> nil then |
|
1293 |
begin |
|
1294 |
Gear^.Pos:= GetRandom(19); |
|
1295 |
Gear^.dX.isNegative:= p = 1; |
|
1296 |
end |
|
958 | 1297 |
end; |
955 | 1298 |
inc(t, 1024) |
1299 |
end |
|
1300 |
end else // mix hedgehogs |
|
1301 |
begin |
|
1302 |
Count:= 0; |
|
1303 |
for p:= 0 to Pred(TeamsCount) do |
|
1304 |
with TeamsArray[p]^ do |
|
1305 |
begin |
|
1306 |
for i:= 0 to cMaxHHIndex do |
|
1307 |
with Hedgehogs[i] do |
|
1308 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
|
1309 |
begin |
|
1515 | 1310 |
ar[Count]:= @Hedgehogs[i]; |
955 | 1311 |
inc(Count) |
1312 |
end; |
|
1313 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1314 |
|
955 | 1315 |
while (Count > 0) do |
1316 |
begin |
|
1317 |
i:= GetRandom(Count); |
|
1515 | 1318 |
FindPlace(ar[i]^.Gear, false, 0, 2048); |
1319 |
if ar[i]^.Gear <> nil then |
|
1320 |
begin |
|
1321 |
ar[i]^.Gear^.dX.isNegative:= ar[i]^.Gear^.X > _1024; |
|
1322 |
ar[i]^.Gear^.Pos:= GetRandom(19); |
|
1323 |
ar[i]:= ar[Count - 1] |
|
1324 |
end; |
|
955 | 1325 |
dec(Count) |
1326 |
end |
|
1327 |
end |
|
4 | 1328 |
end; |
1329 |
||
371 | 1330 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
10 | 1331 |
var t: PGear; |
1332 |
begin |
|
1333 |
t:= GearsList; |
|
1334 |
rX:= sqr(rX); |
|
1335 |
rY:= sqr(rY); |
|
1433 | 1336 |
|
10 | 1337 |
while t <> nil do |
1433 | 1338 |
begin |
1339 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
1340 |
if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then |
|
1341 |
exit(t); |
|
1342 |
t:= t^.NextGear |
|
1343 |
end; |
|
1344 |
||
351 | 1345 |
CheckGearNear:= nil |
15 | 1346 |
end; |
1347 |
||
1433 | 1348 |
{procedure AmmoFlameWork(Ammo: PGear); |
79 | 1349 |
var t: PGear; |
1350 |
begin |
|
1351 |
t:= GearsList; |
|
1352 |
while t <> nil do |
|
1295 | 1353 |
begin |
1354 |
if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then |
|
1355 |
if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then |
|
1356 |
begin |
|
1357 |
inc(t^.Damage, 5); |
|
1358 |
t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; |
|
1359 |
t^.dY:= - _0_25; |
|
1360 |
t^.Active:= true; |
|
1361 |
DeleteCI(t); |
|
1362 |
FollowGear:= t |
|
1363 |
end; |
|
1364 |
t:= t^.NextGear |
|
1365 |
end; |
|
1433 | 1366 |
end;} |
79 | 1367 |
|
371 | 1368 |
function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; |
16 | 1369 |
var t: PGear; |
1370 |
begin |
|
1371 |
t:= GearsList; |
|
1372 |
rX:= sqr(rX); |
|
1373 |
rY:= sqr(rY); |
|
1374 |
while t <> nil do |
|
1515 | 1375 |
begin |
1376 |
if t^.Kind in Kind then |
|
1377 |
if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then |
|
1378 |
exit(t); |
|
1379 |
t:= t^.NextGear |
|
1380 |
end; |
|
351 | 1381 |
CheckGearsNear:= nil |
16 | 1382 |
end; |
1383 |
||
1384 |
function CountGears(Kind: TGearType): Longword; |
|
1385 |
var t: PGear; |
|
351 | 1386 |
Result: Longword; |
16 | 1387 |
begin |
1388 |
Result:= 0; |
|
1389 |
t:= GearsList; |
|
1390 |
while t <> nil do |
|
1515 | 1391 |
begin |
1392 |
if t^.Kind = Kind then inc(Result); |
|
1393 |
t:= t^.NextGear |
|
1394 |
end; |
|
351 | 1395 |
CountGears:= Result |
16 | 1396 |
end; |
1397 |
||
15 | 1398 |
procedure SpawnBoxOfSmth; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1399 |
var t: LongInt; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1400 |
i: TAmmoType; |
15 | 1401 |
begin |
614 | 1402 |
if (cCaseFactor = 0) or |
1403 |
(CountGears(gtCase) >= 5) or |
|
1404 |
(getrandom(cCaseFactor) <> 0) then exit; |
|
1295 | 1405 |
|
498 | 1406 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
295 | 1407 |
case getrandom(2) of |
1408 |
0: begin |
|
351 | 1409 |
FollowGear^.Health:= 25; |
1410 |
FollowGear^.Pos:= posCaseHealth |
|
295 | 1411 |
end; |
1412 |
1: begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1413 |
t:= 0; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1414 |
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
|
1415 |
inc(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1416 |
t:= GetRandom(t); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1417 |
i:= Low(TAmmoType); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1418 |
dec(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1419 |
while t >= 0 do |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1420 |
begin |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1421 |
inc(i); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1422 |
dec(t, Ammoz[i].Probability) |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1423 |
end; |
865 | 1424 |
PlaySound(sndReinforce, false); |
351 | 1425 |
FollowGear^.Pos:= posCaseAmmo; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1426 |
FollowGear^.State:= Longword(i) |
295 | 1427 |
end; |
1428 |
end; |
|
70 | 1429 |
FindPlace(FollowGear, true, 0, 2048) |
1430 |
end; |
|
1431 |
||
1515 | 1432 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); |
70 | 1433 |
|
1515 | 1434 |
function CountNonZeroz(x, y, r: LongInt): LongInt; |
1435 |
var i: LongInt; |
|
1436 |
Result: LongInt; |
|
1437 |
begin |
|
1438 |
Result:= 0; |
|
1439 |
if (y and $FFFFFC00) = 0 then |
|
1440 |
for i:= max(x - r, 0) to min(x + r, 2043) do |
|
1441 |
if Land[y, i] <> 0 then inc(Result); |
|
1442 |
CountNonZeroz:= Result |
|
1443 |
end; |
|
70 | 1444 |
|
495 | 1445 |
var x: LongInt; |
1515 | 1446 |
y, sy: LongInt; |
1447 |
ar: array[0..511] of TPoint; |
|
1448 |
ar2: array[0..1023] of TPoint; |
|
1449 |
cnt, cnt2: Longword; |
|
1450 |
delta: LongInt; |
|
70 | 1451 |
begin |
386 | 1452 |
delta:= 250; |
1453 |
cnt2:= 0; |
|
16 | 1454 |
repeat |
1515 | 1455 |
x:= Left + LongInt(GetRandom(Delta)); |
1456 |
repeat |
|
1457 |
inc(x, Delta); |
|
1458 |
cnt:= 0; |
|
1459 |
y:= -Gear^.Radius * 2; |
|
1460 |
while y < 1023 do |
|
1461 |
begin |
|
1462 |
repeat |
|
1463 |
inc(y, 2); |
|
1464 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0); |
|
1465 |
||
1466 |
sy:= y; |
|
1467 |
||
1468 |
repeat |
|
1469 |
inc(y); |
|
1470 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0); |
|
1471 |
||
1472 |
if (y - sy > Gear^.Radius * 2) |
|
1473 |
and (y < 1023) |
|
1474 |
and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then |
|
1475 |
begin |
|
1476 |
ar[cnt].X:= x; |
|
1477 |
if withFall then ar[cnt].Y:= sy + Gear^.Radius |
|
1478 |
else ar[cnt].Y:= y - Gear^.Radius; |
|
1479 |
inc(cnt) |
|
1480 |
end; |
|
1481 |
||
1482 |
inc(y, 45) |
|
1483 |
end; |
|
1484 |
||
1485 |
if cnt > 0 then |
|
1486 |
with ar[GetRandom(cnt)] do |
|
1487 |
begin |
|
1488 |
ar2[cnt2].x:= x; |
|
1489 |
ar2[cnt2].y:= y; |
|
1490 |
inc(cnt2) |
|
1491 |
end |
|
1492 |
until (x + Delta > Right); |
|
1493 |
dec(Delta, 60) |
|
386 | 1494 |
until (cnt2 > 0) or (Delta < 70); |
1515 | 1495 |
|
386 | 1496 |
if cnt2 > 0 then |
1515 | 1497 |
with ar2[GetRandom(cnt2)] do |
1498 |
begin |
|
1499 |
Gear^.X:= int2hwFloat(x); |
|
1500 |
Gear^.Y:= int2hwFloat(y); |
|
1501 |
{$IFDEF DEBUGFILE} |
|
1502 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
1503 |
{$ENDIF} |
|
1504 |
end |
|
1505 |
else |
|
1506 |
begin |
|
1507 |
OutError('Can''t find place for Gear', false); |
|
1508 |
DeleteGear(Gear); |
|
1509 |
Gear:= nil |
|
1510 |
end |
|
10 | 1511 |
end; |
1512 |
||
4 | 1513 |
initialization |
1514 |
||
1515 |
finalization |
|
95 | 1516 |
FreeGearsList; |
4 | 1517 |
|
1518 |
end. |