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