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