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