author | unc0rr |
Sat, 17 Jan 2009 14:35:20 +0000 | |
changeset 1689 | 3d0eee01f734 |
parent 1669 | b709e061577e |
child 1696 | bb1e305320a1 |
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); |
1435
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset
|
419 |
|
1515 | 420 |
Dispose(Gear) |
4 | 421 |
end; |
422 |
||
423 |
function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs |
|
424 |
var Gear: PGear; |
|
425 |
begin |
|
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 |
|
521 |
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
|
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 |
|
533 |
if (TotalRounds = 15) and (cHealthDecrease = 0) then |
|
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); |
1002 | 668 |
gtRope: begin |
669 |
if Gear^.X < CurAmmoGear^.X then |
|
670 |
begin |
|
671 |
dAngle:= 0; |
|
672 |
m:= 1 |
|
673 |
end else |
|
674 |
begin |
|
675 |
dAngle:= 180; |
|
676 |
m:= -1 |
|
966 | 677 |
end; |
1002 | 678 |
DrawHedgehog(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
679 |
m, |
|
680 |
1, |
|
681 |
0, |
|
682 |
DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle); |
|
683 |
defaultPos:= false |
|
684 |
end; |
|
685 |
gtBlowTorch: begin |
|
686 |
DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); |
|
687 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
688 |
hwSign(Gear^.dX), |
|
689 |
3, |
|
1113 | 690 |
PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, |
1002 | 691 |
0); |
692 |
defaultPos:= false |
|
693 |
end; |
|
694 |
gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180); |
|
695 |
gtFirePunch: begin |
|
696 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
697 |
hwSign(Gear^.dX), |
|
698 |
1, |
|
699 |
4, |
|
700 |
0); |
|
701 |
defaultPos:= false |
|
702 |
end; |
|
703 |
gtPickHammer, |
|
704 |
gtTeleport: defaultPos:= false; |
|
1010 | 705 |
gtWhip: begin |
706 |
DrawRotatedF(sprWhip, |
|
707 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
708 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
709 |
1, |
|
710 |
hwSign(Gear^.dX), |
|
711 |
0); |
|
712 |
defaultPos:= false |
|
713 |
end; |
|
1002 | 714 |
gtKamikaze: begin |
1286 | 715 |
if CurAmmoGear^.Pos = 0 then |
716 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
717 |
hwSign(Gear^.dX), |
|
718 |
1, |
|
719 |
6, |
|
720 |
0) |
|
721 |
else |
|
722 |
DrawRotatedF(sprKamikaze, |
|
723 |
hwRound(Gear^.X) + WorldDx, |
|
724 |
hwRound(Gear^.Y) + WorldDy, |
|
725 |
CurAmmoGear^.Pos - 1, |
|
726 |
1, |
|
727 |
DxDy2Angle(Gear^.dY, Gear^.dX)); |
|
1002 | 728 |
|
1286 | 729 |
defaultPos:= false |
730 |
end; |
|
731 |
gtSeduction: begin |
|
732 |
if CurAmmoGear^.Pos >= 6 then |
|
733 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
734 |
hwSign(Gear^.dX), |
|
735 |
2, |
|
736 |
2, |
|
737 |
0) |
|
738 |
else |
|
739 |
begin |
|
740 |
DrawRotatedF(sprDress, |
|
741 |
hwRound(Gear^.X) + WorldDx, |
|
742 |
hwRound(Gear^.Y) + WorldDy, |
|
743 |
CurAmmoGear^.Pos, |
|
744 |
hwSign(Gear^.dX), |
|
745 |
0); |
|
746 |
DrawSprite(sprCensored, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 20 + WorldDy, 0) |
|
747 |
end; |
|
748 |
defaultPos:= false |
|
749 |
end; |
|
1002 | 750 |
end; |
751 |
||
752 |
case CurAmmoGear^.Kind of |
|
753 |
gtShotgunShot, |
|
754 |
gtDEagleShot, |
|
755 |
gtShover: begin |
|
756 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
757 |
hwSign(Gear^.dX), |
|
758 |
0, |
|
759 |
4, |
|
760 |
0); |
|
761 |
defaultPos:= false |
|
762 |
end |
|
763 |
end |
|
764 |
end else |
|
876 | 765 |
|
1002 | 766 |
if ((Gear^.State and gstHHJumping) <> 0) then |
767 |
begin |
|
768 |
if ((Gear^.State and gstHHHJump) <> 0) then |
|
769 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
770 |
- hwSign(Gear^.dX), |
|
771 |
1, |
|
772 |
1, |
|
773 |
0) |
|
774 |
else |
|
775 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
776 |
hwSign(Gear^.dX), |
|
777 |
1, |
|
778 |
1, |
|
779 |
0); |
|
780 |
defaultPos:= false |
|
781 |
end else |
|
874 | 782 |
|
1002 | 783 |
if (Gear^.Message and (gm_Left or gm_Right) <> 0) then |
824 | 784 |
begin |
1002 | 785 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
786 |
hwSign(Gear^.dX), |
|
787 |
0, |
|
788 |
PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, |
|
789 |
0); |
|
1257 | 790 |
defaultPos:= false; |
791 |
HatVisible:= true |
|
1002 | 792 |
end |
793 |
else |
|
794 |
||
1033 | 795 |
if ((Gear^.State and gstAnimation) <> 0) then |
796 |
begin |
|
1034 | 797 |
DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite, |
1033 | 798 |
hwRound(Gear^.X) + 1 + WorldDx, |
799 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
800 |
Gear^.Pos, |
|
801 |
hwSign(Gear^.dX), |
|
802 |
0.0); |
|
803 |
defaultPos:= false |
|
804 |
end |
|
805 |
else |
|
1002 | 806 |
if ((Gear^.State and gstAttacked) = 0) then |
807 |
begin |
|
808 |
amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType; |
|
809 |
case amt of |
|
810 |
amBazooka, |
|
1689 | 811 |
amMortar,amRCPlane: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle); |
1601 | 812 |
amBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle); |
1573 | 813 |
amDrill: DrawRotated(sprHandDrill, hx, hy, hwSign(Gear^.dX), aangle); |
1002 | 814 |
amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle); |
815 |
amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); |
|
816 |
amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle); |
|
817 |
amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); |
|
818 |
end; |
|
819 |
||
820 |
case amt of |
|
821 |
amAirAttack, |
|
822 |
amMineStrike: DrawRotated(sprHandAirAttack, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0); |
|
823 |
amPickHammer: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
824 |
hwSign(Gear^.dX), |
|
825 |
1, |
|
826 |
2, |
|
827 |
0); |
|
828 |
amBlowTorch: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
829 |
hwSign(Gear^.dX), |
|
830 |
1, |
|
831 |
3, |
|
832 |
0); |
|
833 |
amTeleport: DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, 0, hwSign(Gear^.dX), 0); |
|
834 |
amKamikaze: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
835 |
hwSign(Gear^.dX), |
|
836 |
1, |
|
837 |
5, |
|
838 |
0); |
|
1221 | 839 |
amWhip: DrawRotatedF(sprWhip, |
1010 | 840 |
hwRound(Gear^.X) + 1 + WorldDx, |
841 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
842 |
0, |
|
843 |
hwSign(Gear^.dX), |
|
844 |
0); |
|
1002 | 845 |
else |
822 | 846 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
847 |
hwSign(Gear^.dX), |
|
848 |
0, |
|
1002 | 849 |
4, |
822 | 850 |
0); |
1253 | 851 |
|
852 |
HatVisible:= true; |
|
853 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
1294
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
854 |
if (HatTex <> nil) |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
855 |
and (HatVisibility > 0) then |
1253 | 856 |
DrawTextureF(HatTex, |
857 |
HatVisibility, |
|
858 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
859 |
hwRound(Gear^.Y) - 8 + WorldDy, |
|
860 |
0, |
|
861 |
hwSign(Gear^.dX), |
|
862 |
32); |
|
1002 | 863 |
end; |
966 | 864 |
|
1002 | 865 |
case amt of |
866 |
amBaseballBat: DrawRotated(sprHandBaseball, |
|
867 |
hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx, |
|
868 |
hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle); |
|
869 |
end; |
|
966 | 870 |
|
1002 | 871 |
defaultPos:= false |
872 |
end |
|
873 |
end else // not gstHHDriven |
|
1012 | 874 |
begin |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
875 |
if (Gear^.Damage > 0) |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
876 |
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
|
877 |
begin |
1012 | 878 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
879 |
hwSign(Gear^.dX), |
|
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
880 |
2, |
1012 | 881 |
1, |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
882 |
Gear^.DirAngle); |
1012 | 883 |
defaultPos:= false |
1020 | 884 |
end else |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
885 |
|
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
886 |
if ((Gear^.State and gstHHJumping) <> 0) then |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
887 |
begin |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
888 |
if ((Gear^.State and gstHHHJump) <> 0) then |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
889 |
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
|
890 |
- hwSign(Gear^.dX), |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
891 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
892 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
893 |
0) |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
894 |
else |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
895 |
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
|
896 |
hwSign(Gear^.dX), |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
897 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
898 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
899 |
0); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
900 |
defaultPos:= false |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
901 |
end; |
1012 | 902 |
end; |
834 | 903 |
|
1251 | 904 |
with PHedgehog(Gear^.Hedgehog)^ do |
970 | 905 |
begin |
1251 | 906 |
if defaultPos then |
907 |
begin |
|
908 |
DrawRotatedF(sprHHIdle, |
|
909 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
910 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
911 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
|
912 |
hwSign(Gear^.dX), |
|
913 |
0); |
|
1253 | 914 |
HatVisible:= true; |
915 |
end; |
|
916 |
||
917 |
if HatVisible then |
|
1251 | 918 |
if HatVisibility < 1.0 then |
1254 | 919 |
HatVisibility:= HatVisibility + 0.2 |
1253 | 920 |
else |
1251 | 921 |
else |
922 |
if HatVisibility > 0.0 then |
|
1254 | 923 |
HatVisibility:= HatVisibility - 0.2; |
1253 | 924 |
|
1294
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
925 |
if (HatTex <> nil) |
50198e5c7f02
- Hedgehog doesn't take off hat when shooting from shotgun
unc0rr
parents:
1286
diff
changeset
|
926 |
and (HatVisibility > 0) then |
1255 | 927 |
if DefaultPos then |
928 |
DrawTextureF(HatTex, |
|
929 |
HatVisibility, |
|
930 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
931 |
hwRound(Gear^.Y) - 8 + WorldDy, |
|
932 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
|
933 |
hwSign(Gear^.dX), |
|
934 |
32) |
|
935 |
else |
|
936 |
DrawTextureF(HatTex, |
|
937 |
HatVisibility, |
|
938 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
939 |
hwRound(Gear^.Y) - 8 + WorldDy, |
|
940 |
0, |
|
941 |
hwSign(Gear^.dX), |
|
942 |
32); |
|
970 | 943 |
end; |
292 | 944 |
|
1251 | 945 |
|
351 | 946 |
with PHedgehog(Gear^.Hedgehog)^ do |
994 | 947 |
begin |
1011 | 948 |
if ((Gear^.State and not gstWinner) = 0) |
994 | 949 |
or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then |
958 | 950 |
begin |
1660 | 951 |
t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy; |
952 |
if (cTagsMask and 1) <> 0 then |
|
953 |
begin |
|
954 |
dec(t, HealthTagTex^.h + 2); |
|
955 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex) |
|
956 |
end; |
|
957 |
if (cTagsMask and 2) <> 0 then |
|
958 |
begin |
|
959 |
dec(t, NameTagTex^.h + 2); |
|
960 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTagTex) |
|
961 |
end; |
|
962 |
if (cTagsMask and 4) <> 0 then |
|
963 |
begin |
|
964 |
dec(t, Team^.NameTagTex^.h + 2); |
|
965 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex) |
|
966 |
end |
|
958 | 967 |
end; |
994 | 968 |
if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog |
958 | 969 |
begin |
970 |
if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then |
|
971 |
DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy, |
|
972 |
GameTicks div 32 mod 16); |
|
821
e6c0408b54ed
Use 'regular standing' and 'rope swing' hedgehog sprites
unc0rr
parents:
815
diff
changeset
|
973 |
|
958 | 974 |
if (Gear^.State and gstDrowning) = 0 then |
975 |
if (Gear^.State and gstHHThinking) <> 0 then |
|
976 |
DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, 0) |
|
977 |
else |
|
1033 | 978 |
if ShowCrosshair and ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then |
958 | 979 |
begin |
980 |
if ((Gear^.State and gstHHHJump) <> 0) then m:= -1 else m:= 1; |
|
981 |
DrawRotatedTex(Team^.CrosshairTex, |
|
982 |
12, 12, |
|
1283
a1e99d1e4fd3
Enable back the ability to see chosen team color in team widget
unc0rr
parents:
1279
diff
changeset
|
983 |
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
|
984 |
Round(hwRound(Gear^.Y) - Cos(Gear^.Angle*pi/cMaxAngle) * 80) + WorldDy, 0, |
958 | 985 |
hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle) |
986 |
end |
|
994 | 987 |
end |
988 |
end |
|
292 | 989 |
end; |
990 |
||
956 | 991 |
procedure DrawGears; |
853 | 992 |
var Gear, HHGear: PGear; |
4 | 993 |
i: Longword; |
371 | 994 |
roplen: LongInt; |
4 | 995 |
|
371 | 996 |
procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt); |
997 |
var eX, eY, dX, dY: LongInt; |
|
998 |
i, sX, sY, x, y, d: LongInt; |
|
366 | 999 |
b: boolean; |
4 | 1000 |
begin |
37 | 1001 |
if (X1 = X2) and (Y1 = Y2) then |
1002 |
begin |
|
351 | 1003 |
OutError('WARNING: zero length rope line!', false); |
37 | 1004 |
exit |
1005 |
end; |
|
366 | 1006 |
eX:= 0; |
1007 |
eY:= 0; |
|
1008 |
dX:= X2 - X1; |
|
1009 |
dY:= Y2 - Y1; |
|
1010 |
||
1011 |
if (dX > 0) then sX:= 1 |
|
1012 |
else |
|
1013 |
if (dX < 0) then |
|
1014 |
begin |
|
1015 |
sX:= -1; |
|
1016 |
dX:= -dX |
|
1017 |
end else sX:= dX; |
|
1018 |
||
1019 |
if (dY > 0) then sY:= 1 |
|
1020 |
else |
|
1021 |
if (dY < 0) then |
|
4 | 1022 |
begin |
366 | 1023 |
sY:= -1; |
1024 |
dY:= -dY |
|
1025 |
end else sY:= dY; |
|
1026 |
||
1027 |
if (dX > dY) then d:= dX |
|
1028 |
else d:= dY; |
|
1029 |
||
1030 |
x:= X1; |
|
1031 |
y:= Y1; |
|
1032 |
||
1033 |
for i:= 0 to d do |
|
1034 |
begin |
|
1035 |
inc(eX, dX); |
|
1036 |
inc(eY, dY); |
|
1037 |
b:= false; |
|
1038 |
if (eX > d) then |
|
35 | 1039 |
begin |
366 | 1040 |
dec(eX, d); |
1041 |
inc(x, sX); |
|
1042 |
b:= true |
|
35 | 1043 |
end; |
366 | 1044 |
if (eY > d) then |
35 | 1045 |
begin |
366 | 1046 |
dec(eY, d); |
1047 |
inc(y, sY); |
|
1048 |
b:= true |
|
35 | 1049 |
end; |
366 | 1050 |
if b then |
1051 |
begin |
|
1052 |
inc(roplen); |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1053 |
if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0) |
366 | 1054 |
end |
4 | 1055 |
end |
366 | 1056 |
end; |
4 | 1057 |
|
1058 |
begin |
|
1059 |
Gear:= GearsList; |
|
1060 |
while Gear<>nil do |
|
1689 | 1061 |
begin |
1062 |
case Gear^.Kind of |
|
822 | 1063 |
gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
1689 | 1064 |
|
1065 |
gtRCPlane: if (PHedgehog(Gear^.Hedgehog)^.Gear^.dX.isNegative) then |
|
1066 |
DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, -1, DxDy2Angle(Gear^.dX, Gear^.dY) + 90) |
|
1067 |
else |
|
1068 |
DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,0,DxDy2Angle(Gear^.dY, Gear^.dX)); |
|
1069 |
||
1601 | 1070 |
gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1689 | 1071 |
|
1573 | 1072 |
gtDrill: DrawRotated(sprDrill, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1689 | 1073 |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1074 |
gtHedgehog: DrawHH(Gear); |
1689 | 1075 |
|
822 | 1076 |
gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1689 | 1077 |
|
1505 | 1078 |
gtHealthTag: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex); |
1689 | 1079 |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1080 |
gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex); |
1689 | 1081 |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1082 |
gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4); |
1689 | 1083 |
|
848 | 1084 |
gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0); |
4 | 1085 |
gtRope: begin |
35 | 1086 |
roplen:= 0; |
4 | 1087 |
if RopePoints.Count > 0 then |
1088 |
begin |
|
1089 |
i:= 0; |
|
1090 |
while i < Pred(RopePoints.Count) do |
|
1091 |
begin |
|
351 | 1092 |
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
1093 |
hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy); |
|
4 | 1094 |
inc(i) |
1095 |
end; |
|
351 | 1096 |
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
1097 |
hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy); |
|
1098 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
|
1099 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 1100 |
DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) |
4 | 1101 |
end else |
35 | 1102 |
begin |
351 | 1103 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
1104 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 1105 |
DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
35 | 1106 |
end; |
4 | 1107 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1108 |
gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
1012 | 1109 |
gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State); |
351 | 1110 |
gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420) |
822 | 1111 |
then DrawRotated(sprMineOff, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle) |
1112 |
else DrawRotated(sprMineOn, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
|
351 | 1113 |
gtCase: case Gear^.Pos of |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1114 |
posCaseAmmo : DrawSprite(sprCase, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
1009 | 1115 |
posCaseHealth: begin |
1116 |
i:= (GameTicks shr 6) mod 64; |
|
1117 |
if i > 12 then i:= 0; |
|
1118 |
DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i); |
|
1119 |
end; |
|
42 | 1120 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1121 |
gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1); |
822 | 1122 |
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
|
1123 |
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
|
1124 |
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
|
1125 |
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
|
1126 |
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
|
1127 |
else DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 1); |
822 | 1128 |
gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
853 | 1129 |
gtTeleport: begin |
1130 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1131 |
DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
1132 |
DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
1133 |
end; |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1134 |
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
|
1135 |
gtTarget: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
959 | 1136 |
gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1108 | 1137 |
gtCake: if Gear^.Pos = 6 then |
1138 |
DrawRotatedf(sprCakeWalk, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle + hwSign(Gear^.dX) * 90) |
|
1139 |
else |
|
1262 | 1140 |
DrawRotatedf(sprCakeDown, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 5 - Gear^.Pos, hwSign(Gear^.dX), 0); |
1367 | 1141 |
gtSeduction: if Gear^.Pos >= 14 then DrawSprite(sprSeduction, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
1262 | 1142 |
gtWatermelon: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 0, Gear^.DirAngle); |
1143 |
gtMelonPiece: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 1, 0, Gear^.DirAngle); |
|
1263 | 1144 |
gtHellishBomb: DrawRotated(sprHellishBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
1145 |
gtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
|
1146 |
end; |
|
351 | 1147 |
Gear:= Gear^.NextGear |
4 | 1148 |
end; |
1149 |
end; |
|
1150 |
||
1151 |
procedure FreeGearsList; |
|
1152 |
var t, tt: PGear; |
|
1153 |
begin |
|
1154 |
tt:= GearsList; |
|
1155 |
GearsList:= nil; |
|
1505 | 1156 |
while tt <> nil do |
1157 |
begin |
|
1158 |
t:= tt; |
|
1159 |
tt:= tt^.NextGear; |
|
1160 |
Dispose(t) |
|
1161 |
end; |
|
4 | 1162 |
end; |
1163 |
||
10 | 1164 |
procedure AddMiscGears; |
371 | 1165 |
var i: LongInt; |
1515 | 1166 |
Gear: PGear; |
4 | 1167 |
begin |
498 | 1168 |
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
|
1169 |
|
22 | 1170 |
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
|
1171 |
for i:= 0 to Pred(cLandAdditions) do |
1515 | 1172 |
begin |
1173 |
Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0); |
|
1174 |
FindPlace(Gear, false, 0, 2048) |
|
1175 |
end |
|
4 | 1176 |
end; |
1177 |
||
371 | 1178 |
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); |
4 | 1179 |
var Gear: PGear; |
506 | 1180 |
dmg, dmgRadius: LongInt; |
4 | 1181 |
begin |
1182 |
TargetPoint.X:= NoPointX; |
|
1434 | 1183 |
{$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF} |
1049 | 1184 |
if (Radius > 10) then AddGear(X, Y, gtExplosion, 0, _0, _0, 0); |
1669 | 1185 |
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false, nil); |
1433 | 1186 |
|
1187 |
if (Mask and EXPLAllDamageInRadius) = 0 then |
|
1188 |
dmgRadius:= Radius shl 1 |
|
1189 |
else |
|
1190 |
dmgRadius:= Radius; |
|
1191 |
||
4 | 1192 |
Gear:= GearsList; |
1193 |
while Gear <> nil do |
|
1200 | 1194 |
begin |
1195 |
dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
|
1196 |
if (dmg > 1) and |
|
1197 |
((Gear^.State and gstNoDamage) = 0) then |
|
1198 |
begin |
|
1199 |
dmg:= min(dmg div 2, Radius); |
|
1200 |
case Gear^.Kind of |
|
1201 |
gtHedgehog, |
|
1202 |
gtMine, |
|
1203 |
gtCase, |
|
1204 |
gtTarget, |
|
1205 |
gtFlame: begin |
|
1346 | 1206 |
//{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} |
1200 | 1207 |
if (Mask and EXPLNoDamage) = 0 then |
1208 |
begin |
|
1209 |
inc(Gear^.Damage, dmg); |
|
1210 |
if Gear^.Kind = gtHedgehog then |
|
1505 | 1211 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color) |
1200 | 1212 |
end; |
1213 |
if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then |
|
1214 |
begin |
|
1215 |
DeleteCI(Gear); |
|
1216 |
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X)); |
|
1217 |
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y)); |
|
1218 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); |
|
1219 |
Gear^.Active:= true; |
|
1220 |
FollowGear:= Gear |
|
1221 |
end; |
|
1222 |
end; |
|
1223 |
gtGrave: begin |
|
1224 |
Gear^.dY:= - _0_004 * dmg; |
|
1225 |
Gear^.Active:= true; |
|
1226 |
end; |
|
1227 |
end; |
|
1228 |
end; |
|
1229 |
Gear:= Gear^.NextGear |
|
1230 |
end; |
|
1231 |
||
621 | 1232 |
if (Mask and EXPLDontDraw) = 0 then |
1200 | 1233 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(X, Y, Radius); |
1234 |
||
498 | 1235 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
4 | 1236 |
end; |
1237 |
||
506 | 1238 |
procedure ShotgunShot(Gear: PGear); |
1239 |
var t: PGear; |
|
955 | 1240 |
dmg: LongInt; |
506 | 1241 |
begin |
509 | 1242 |
Gear^.Radius:= cShotgunRadius; |
506 | 1243 |
t:= GearsList; |
1244 |
while t <> nil do |
|
1286 | 1245 |
begin |
1246 |
dmg:= min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25); |
|
1247 |
if dmg > 0 then |
|
1248 |
case t^.Kind of |
|
1249 |
gtHedgehog, |
|
1250 |
gtMine, |
|
1251 |
gtCase, |
|
1252 |
gtTarget: begin |
|
1253 |
inc(t^.Damage, dmg); |
|
867 | 1254 |
|
1286 | 1255 |
if t^.Kind = gtHedgehog then |
1505 | 1256 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, PHedgehog(t^.Hedgehog)^.Team^.Clan^.Color); |
867 | 1257 |
|
1286 | 1258 |
DeleteCI(t); |
1259 |
t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); |
|
1260 |
t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; |
|
1261 |
t^.State:= t^.State or gstMoving; |
|
1262 |
t^.Active:= true; |
|
1263 |
FollowGear:= t |
|
1264 |
end; |
|
1265 |
gtGrave: begin |
|
1266 |
t^.dY:= - _0_1; |
|
1267 |
t^.Active:= true |
|
1268 |
end; |
|
1269 |
end; |
|
1270 |
t:= t^.NextGear |
|
1271 |
end; |
|
621 | 1272 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) |
506 | 1273 |
end; |
1274 |
||
371 | 1275 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
53 | 1276 |
var t: PGearArray; |
371 | 1277 |
i: LongInt; |
38 | 1278 |
begin |
53 | 1279 |
t:= CheckGearsCollision(Ammo); |
351 | 1280 |
i:= t^.Count; |
1506 | 1281 |
|
53 | 1282 |
while i > 0 do |
981 | 1283 |
begin |
1284 |
dec(i); |
|
1285 |
if (t^.ar[i]^.State and gstNoDamage) = 0 then |
|
1286 |
case t^.ar[i]^.Kind of |
|
1287 |
gtHedgehog, |
|
1288 |
gtMine, |
|
1289 |
gtTarget, |
|
1290 |
gtCase: begin |
|
1573 | 1291 |
if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end; |
981 | 1292 |
inc(t^.ar[i]^.Damage, Damage); |
1293 |
||
1284 | 1294 |
if (t^.ar[i]^.Kind = gtHedgehog) and (Damage > 0) then |
1505 | 1295 |
AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, PHedgehog(t^.ar[i]^.Hedgehog)^.Team^.Clan^.Color); |
867 | 1296 |
|
981 | 1297 |
DeleteCI(t^.ar[i]); |
1298 |
t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01; |
|
1299 |
t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01; |
|
1300 |
t^.ar[i]^.Active:= true; |
|
1301 |
t^.ar[i]^.State:= t^.ar[i]^.State or gstMoving; |
|
867 | 1302 |
|
982 | 1303 |
if TestCollisionXwithGear(t^.ar[i], hwSign(t^.ar[i]^.dX)) then |
981 | 1304 |
begin |
1305 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -3, hwSign(t^.ar[i]^.dX)) |
|
1306 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1307 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX)) |
|
1308 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1309 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX)) |
|
1310 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1311 |
end; |
|
982 | 1312 |
|
981 | 1313 |
FollowGear:= t^.ar[i] |
1314 |
end; |
|
1315 |
end |
|
1316 |
end; |
|
126 | 1317 |
SetAllToActive |
38 | 1318 |
end; |
1319 |
||
4 | 1320 |
procedure AssignHHCoords; |
955 | 1321 |
var i, t, p, j: LongInt; |
1515 | 1322 |
ar: array[0..Pred(cMaxHHs)] of PHedgehog; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1323 |
Count: Longword; |
4 | 1324 |
begin |
1428 | 1325 |
if (GameFlags and (gfForts or gfDivideTeams)) <> 0 then |
955 | 1326 |
begin |
1327 |
t:= 0; |
|
1428 | 1328 |
TryDo(ClansCount = 2, 'More or less than 2 clans on map in divided teams mode!', true); |
955 | 1329 |
for p:= 0 to 1 do |
1330 |
begin |
|
1331 |
with ClansArray[p]^ do |
|
1332 |
for j:= 0 to Pred(TeamsNumber) do |
|
1333 |
with Teams[j]^ do |
|
1334 |
for i:= 0 to cMaxHHIndex do |
|
1335 |
with Hedgehogs[i] do |
|
958 | 1336 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
1337 |
begin |
|
1515 | 1338 |
FindPlace(Gear, false, t, t + 1024);// could make Gear == nil |
1339 |
if Gear <> nil then |
|
1340 |
begin |
|
1341 |
Gear^.Pos:= GetRandom(19); |
|
1342 |
Gear^.dX.isNegative:= p = 1; |
|
1343 |
end |
|
958 | 1344 |
end; |
955 | 1345 |
inc(t, 1024) |
1346 |
end |
|
1347 |
end else // mix hedgehogs |
|
1348 |
begin |
|
1349 |
Count:= 0; |
|
1350 |
for p:= 0 to Pred(TeamsCount) do |
|
1351 |
with TeamsArray[p]^ do |
|
1352 |
begin |
|
1353 |
for i:= 0 to cMaxHHIndex do |
|
1354 |
with Hedgehogs[i] do |
|
1355 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
|
1356 |
begin |
|
1515 | 1357 |
ar[Count]:= @Hedgehogs[i]; |
955 | 1358 |
inc(Count) |
1359 |
end; |
|
1360 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1361 |
|
955 | 1362 |
while (Count > 0) do |
1363 |
begin |
|
1364 |
i:= GetRandom(Count); |
|
1515 | 1365 |
FindPlace(ar[i]^.Gear, false, 0, 2048); |
1366 |
if ar[i]^.Gear <> nil then |
|
1367 |
begin |
|
1368 |
ar[i]^.Gear^.dX.isNegative:= ar[i]^.Gear^.X > _1024; |
|
1369 |
ar[i]^.Gear^.Pos:= GetRandom(19); |
|
1370 |
ar[i]:= ar[Count - 1] |
|
1371 |
end; |
|
955 | 1372 |
dec(Count) |
1373 |
end |
|
1374 |
end |
|
4 | 1375 |
end; |
1376 |
||
371 | 1377 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
10 | 1378 |
var t: PGear; |
1379 |
begin |
|
1380 |
t:= GearsList; |
|
1381 |
rX:= sqr(rX); |
|
1382 |
rY:= sqr(rY); |
|
1433 | 1383 |
|
10 | 1384 |
while t <> nil do |
1433 | 1385 |
begin |
1386 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
1387 |
if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then |
|
1388 |
exit(t); |
|
1389 |
t:= t^.NextGear |
|
1390 |
end; |
|
1391 |
||
351 | 1392 |
CheckGearNear:= nil |
15 | 1393 |
end; |
1394 |
||
1433 | 1395 |
{procedure AmmoFlameWork(Ammo: PGear); |
79 | 1396 |
var t: PGear; |
1397 |
begin |
|
1398 |
t:= GearsList; |
|
1399 |
while t <> nil do |
|
1295 | 1400 |
begin |
1401 |
if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then |
|
1402 |
if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then |
|
1403 |
begin |
|
1404 |
inc(t^.Damage, 5); |
|
1405 |
t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; |
|
1406 |
t^.dY:= - _0_25; |
|
1407 |
t^.Active:= true; |
|
1408 |
DeleteCI(t); |
|
1409 |
FollowGear:= t |
|
1410 |
end; |
|
1411 |
t:= t^.NextGear |
|
1412 |
end; |
|
1433 | 1413 |
end;} |
79 | 1414 |
|
371 | 1415 |
function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; |
16 | 1416 |
var t: PGear; |
1417 |
begin |
|
1418 |
t:= GearsList; |
|
1419 |
rX:= sqr(rX); |
|
1420 |
rY:= sqr(rY); |
|
1421 |
while t <> nil do |
|
1515 | 1422 |
begin |
1423 |
if t^.Kind in Kind then |
|
1424 |
if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then |
|
1425 |
exit(t); |
|
1426 |
t:= t^.NextGear |
|
1427 |
end; |
|
351 | 1428 |
CheckGearsNear:= nil |
16 | 1429 |
end; |
1430 |
||
1431 |
function CountGears(Kind: TGearType): Longword; |
|
1432 |
var t: PGear; |
|
351 | 1433 |
Result: Longword; |
16 | 1434 |
begin |
1435 |
Result:= 0; |
|
1436 |
t:= GearsList; |
|
1437 |
while t <> nil do |
|
1515 | 1438 |
begin |
1439 |
if t^.Kind = Kind then inc(Result); |
|
1440 |
t:= t^.NextGear |
|
1441 |
end; |
|
351 | 1442 |
CountGears:= Result |
16 | 1443 |
end; |
1444 |
||
15 | 1445 |
procedure SpawnBoxOfSmth; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1446 |
var t: LongInt; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1447 |
i: TAmmoType; |
15 | 1448 |
begin |
614 | 1449 |
if (cCaseFactor = 0) or |
1450 |
(CountGears(gtCase) >= 5) or |
|
1451 |
(getrandom(cCaseFactor) <> 0) then exit; |
|
1295 | 1452 |
|
498 | 1453 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
295 | 1454 |
case getrandom(2) of |
1455 |
0: begin |
|
351 | 1456 |
FollowGear^.Health:= 25; |
1457 |
FollowGear^.Pos:= posCaseHealth |
|
295 | 1458 |
end; |
1459 |
1: begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1460 |
t:= 0; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1461 |
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
|
1462 |
inc(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1463 |
t:= GetRandom(t); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1464 |
i:= Low(TAmmoType); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1465 |
dec(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1466 |
while t >= 0 do |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1467 |
begin |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1468 |
inc(i); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1469 |
dec(t, Ammoz[i].Probability) |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1470 |
end; |
1669 | 1471 |
PlaySound(sndReinforce, false, CurrentTeam^.voicepack); |
351 | 1472 |
FollowGear^.Pos:= posCaseAmmo; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1473 |
FollowGear^.State:= Longword(i) |
295 | 1474 |
end; |
1475 |
end; |
|
70 | 1476 |
FindPlace(FollowGear, true, 0, 2048) |
1477 |
end; |
|
1478 |
||
1515 | 1479 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); |
70 | 1480 |
|
1515 | 1481 |
function CountNonZeroz(x, y, r: LongInt): LongInt; |
1482 |
var i: LongInt; |
|
1483 |
Result: LongInt; |
|
1484 |
begin |
|
1485 |
Result:= 0; |
|
1486 |
if (y and $FFFFFC00) = 0 then |
|
1487 |
for i:= max(x - r, 0) to min(x + r, 2043) do |
|
1488 |
if Land[y, i] <> 0 then inc(Result); |
|
1489 |
CountNonZeroz:= Result |
|
1490 |
end; |
|
70 | 1491 |
|
495 | 1492 |
var x: LongInt; |
1515 | 1493 |
y, sy: LongInt; |
1494 |
ar: array[0..511] of TPoint; |
|
1495 |
ar2: array[0..1023] of TPoint; |
|
1496 |
cnt, cnt2: Longword; |
|
1497 |
delta: LongInt; |
|
70 | 1498 |
begin |
386 | 1499 |
delta:= 250; |
1500 |
cnt2:= 0; |
|
16 | 1501 |
repeat |
1515 | 1502 |
x:= Left + LongInt(GetRandom(Delta)); |
1503 |
repeat |
|
1504 |
inc(x, Delta); |
|
1505 |
cnt:= 0; |
|
1506 |
y:= -Gear^.Radius * 2; |
|
1507 |
while y < 1023 do |
|
1508 |
begin |
|
1509 |
repeat |
|
1510 |
inc(y, 2); |
|
1511 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0); |
|
1512 |
||
1513 |
sy:= y; |
|
1514 |
||
1515 |
repeat |
|
1516 |
inc(y); |
|
1517 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0); |
|
1518 |
||
1519 |
if (y - sy > Gear^.Radius * 2) |
|
1520 |
and (y < 1023) |
|
1521 |
and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then |
|
1522 |
begin |
|
1523 |
ar[cnt].X:= x; |
|
1524 |
if withFall then ar[cnt].Y:= sy + Gear^.Radius |
|
1525 |
else ar[cnt].Y:= y - Gear^.Radius; |
|
1526 |
inc(cnt) |
|
1527 |
end; |
|
1528 |
||
1529 |
inc(y, 45) |
|
1530 |
end; |
|
1531 |
||
1532 |
if cnt > 0 then |
|
1533 |
with ar[GetRandom(cnt)] do |
|
1534 |
begin |
|
1535 |
ar2[cnt2].x:= x; |
|
1536 |
ar2[cnt2].y:= y; |
|
1537 |
inc(cnt2) |
|
1538 |
end |
|
1539 |
until (x + Delta > Right); |
|
1540 |
dec(Delta, 60) |
|
386 | 1541 |
until (cnt2 > 0) or (Delta < 70); |
1515 | 1542 |
|
386 | 1543 |
if cnt2 > 0 then |
1515 | 1544 |
with ar2[GetRandom(cnt2)] do |
1545 |
begin |
|
1546 |
Gear^.X:= int2hwFloat(x); |
|
1547 |
Gear^.Y:= int2hwFloat(y); |
|
1548 |
{$IFDEF DEBUGFILE} |
|
1549 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
1550 |
{$ENDIF} |
|
1551 |
end |
|
1552 |
else |
|
1553 |
begin |
|
1554 |
OutError('Can''t find place for Gear', false); |
|
1555 |
DeleteGear(Gear); |
|
1556 |
Gear:= nil |
|
1557 |
end |
|
10 | 1558 |
end; |
1559 |
||
4 | 1560 |
initialization |
1561 |
||
1562 |
finalization |
|
95 | 1563 |
FreeGearsList; |
4 | 1564 |
|
1565 |
end. |