author | unc0rr |
Fri, 12 Nov 2010 19:39:45 +0300 | |
branch | 0.9.9 |
changeset 1734 | ee7059418043 |
parent 1717 | f4cf7e36ae3e |
child 1738 | 00e8dadce69a |
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); |
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 |
35 | 1110 |
begin |
351 | 1111 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
1112 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 1113 |
DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
35 | 1114 |
end; |
4 | 1115 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1116 |
gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
1012 | 1117 |
gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State); |
351 | 1118 |
gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420) |
822 | 1119 |
then DrawRotated(sprMineOff, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle) |
1120 |
else DrawRotated(sprMineOn, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
|
351 | 1121 |
gtCase: case Gear^.Pos of |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1122 |
posCaseAmmo : DrawSprite(sprCase, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
1009 | 1123 |
posCaseHealth: begin |
1124 |
i:= (GameTicks shr 6) mod 64; |
|
1125 |
if i > 12 then i:= 0; |
|
1126 |
DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i); |
|
1127 |
end; |
|
42 | 1128 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1129 |
gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1); |
822 | 1130 |
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
|
1131 |
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
|
1132 |
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
|
1133 |
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
|
1134 |
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
|
1135 |
else DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 1); |
822 | 1136 |
gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
853 | 1137 |
gtTeleport: begin |
1138 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1139 |
DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
1140 |
DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
1141 |
end; |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1142 |
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
|
1143 |
gtTarget: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
959 | 1144 |
gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1108 | 1145 |
gtCake: if Gear^.Pos = 6 then |
1146 |
DrawRotatedf(sprCakeWalk, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle + hwSign(Gear^.dX) * 90) |
|
1147 |
else |
|
1262 | 1148 |
DrawRotatedf(sprCakeDown, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 5 - Gear^.Pos, hwSign(Gear^.dX), 0); |
1367 | 1149 |
gtSeduction: if Gear^.Pos >= 14 then DrawSprite(sprSeduction, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
1262 | 1150 |
gtWatermelon: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 0, Gear^.DirAngle); |
1151 |
gtMelonPiece: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 1, 0, Gear^.DirAngle); |
|
1263 | 1152 |
gtHellishBomb: DrawRotated(sprHellishBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
1153 |
gtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
|
1154 |
end; |
|
351 | 1155 |
Gear:= Gear^.NextGear |
4 | 1156 |
end; |
1157 |
end; |
|
1158 |
||
1159 |
procedure FreeGearsList; |
|
1160 |
var t, tt: PGear; |
|
1161 |
begin |
|
1162 |
tt:= GearsList; |
|
1163 |
GearsList:= nil; |
|
1505 | 1164 |
while tt <> nil do |
1165 |
begin |
|
1166 |
t:= tt; |
|
1167 |
tt:= tt^.NextGear; |
|
1168 |
Dispose(t) |
|
1169 |
end; |
|
4 | 1170 |
end; |
1171 |
||
10 | 1172 |
procedure AddMiscGears; |
371 | 1173 |
var i: LongInt; |
1515 | 1174 |
Gear: PGear; |
4 | 1175 |
begin |
498 | 1176 |
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
|
1177 |
|
22 | 1178 |
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
|
1179 |
for i:= 0 to Pred(cLandAdditions) do |
1515 | 1180 |
begin |
1181 |
Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0); |
|
1182 |
FindPlace(Gear, false, 0, 2048) |
|
1183 |
end |
|
4 | 1184 |
end; |
1185 |
||
371 | 1186 |
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); |
4 | 1187 |
var Gear: PGear; |
506 | 1188 |
dmg, dmgRadius: LongInt; |
4 | 1189 |
begin |
1190 |
TargetPoint.X:= NoPointX; |
|
1434 | 1191 |
{$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF} |
1049 | 1192 |
if (Radius > 10) then AddGear(X, Y, gtExplosion, 0, _0, _0, 0); |
1669 | 1193 |
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false, nil); |
1433 | 1194 |
|
1195 |
if (Mask and EXPLAllDamageInRadius) = 0 then |
|
1196 |
dmgRadius:= Radius shl 1 |
|
1197 |
else |
|
1198 |
dmgRadius:= Radius; |
|
1199 |
||
4 | 1200 |
Gear:= GearsList; |
1201 |
while Gear <> nil do |
|
1200 | 1202 |
begin |
1203 |
dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
|
1204 |
if (dmg > 1) and |
|
1205 |
((Gear^.State and gstNoDamage) = 0) then |
|
1206 |
begin |
|
1207 |
dmg:= min(dmg div 2, Radius); |
|
1208 |
case Gear^.Kind of |
|
1209 |
gtHedgehog, |
|
1210 |
gtMine, |
|
1211 |
gtCase, |
|
1212 |
gtTarget, |
|
1213 |
gtFlame: begin |
|
1346 | 1214 |
//{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} |
1200 | 1215 |
if (Mask and EXPLNoDamage) = 0 then |
1216 |
begin |
|
1217 |
inc(Gear^.Damage, dmg); |
|
1218 |
if Gear^.Kind = gtHedgehog then |
|
1505 | 1219 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color) |
1200 | 1220 |
end; |
1221 |
if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then |
|
1222 |
begin |
|
1223 |
DeleteCI(Gear); |
|
1224 |
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X)); |
|
1225 |
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y)); |
|
1226 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); |
|
1227 |
Gear^.Active:= true; |
|
1228 |
FollowGear:= Gear |
|
1229 |
end; |
|
1230 |
end; |
|
1231 |
gtGrave: begin |
|
1232 |
Gear^.dY:= - _0_004 * dmg; |
|
1233 |
Gear^.Active:= true; |
|
1234 |
end; |
|
1235 |
end; |
|
1236 |
end; |
|
1237 |
Gear:= Gear^.NextGear |
|
1238 |
end; |
|
1239 |
||
621 | 1240 |
if (Mask and EXPLDontDraw) = 0 then |
1200 | 1241 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(X, Y, Radius); |
1242 |
||
498 | 1243 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
4 | 1244 |
end; |
1245 |
||
506 | 1246 |
procedure ShotgunShot(Gear: PGear); |
1247 |
var t: PGear; |
|
955 | 1248 |
dmg: LongInt; |
506 | 1249 |
begin |
509 | 1250 |
Gear^.Radius:= cShotgunRadius; |
506 | 1251 |
t:= GearsList; |
1252 |
while t <> nil do |
|
1286 | 1253 |
begin |
1254 |
dmg:= min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25); |
|
1255 |
if dmg > 0 then |
|
1256 |
case t^.Kind of |
|
1257 |
gtHedgehog, |
|
1258 |
gtMine, |
|
1259 |
gtCase, |
|
1260 |
gtTarget: begin |
|
1261 |
inc(t^.Damage, dmg); |
|
867 | 1262 |
|
1286 | 1263 |
if t^.Kind = gtHedgehog then |
1505 | 1264 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, PHedgehog(t^.Hedgehog)^.Team^.Clan^.Color); |
867 | 1265 |
|
1286 | 1266 |
DeleteCI(t); |
1267 |
t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); |
|
1268 |
t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; |
|
1269 |
t^.State:= t^.State or gstMoving; |
|
1270 |
t^.Active:= true; |
|
1271 |
FollowGear:= t |
|
1272 |
end; |
|
1273 |
gtGrave: begin |
|
1274 |
t^.dY:= - _0_1; |
|
1275 |
t^.Active:= true |
|
1276 |
end; |
|
1277 |
end; |
|
1278 |
t:= t^.NextGear |
|
1279 |
end; |
|
621 | 1280 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) |
506 | 1281 |
end; |
1282 |
||
371 | 1283 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
53 | 1284 |
var t: PGearArray; |
371 | 1285 |
i: LongInt; |
38 | 1286 |
begin |
53 | 1287 |
t:= CheckGearsCollision(Ammo); |
351 | 1288 |
i:= t^.Count; |
1506 | 1289 |
|
53 | 1290 |
while i > 0 do |
981 | 1291 |
begin |
1292 |
dec(i); |
|
1293 |
if (t^.ar[i]^.State and gstNoDamage) = 0 then |
|
1294 |
case t^.ar[i]^.Kind of |
|
1295 |
gtHedgehog, |
|
1296 |
gtMine, |
|
1297 |
gtTarget, |
|
1298 |
gtCase: begin |
|
1573 | 1299 |
if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end; |
981 | 1300 |
inc(t^.ar[i]^.Damage, Damage); |
1301 |
||
1284 | 1302 |
if (t^.ar[i]^.Kind = gtHedgehog) and (Damage > 0) then |
1505 | 1303 |
AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, PHedgehog(t^.ar[i]^.Hedgehog)^.Team^.Clan^.Color); |
867 | 1304 |
|
981 | 1305 |
DeleteCI(t^.ar[i]); |
1306 |
t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01; |
|
1307 |
t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01; |
|
1308 |
t^.ar[i]^.Active:= true; |
|
1309 |
t^.ar[i]^.State:= t^.ar[i]^.State or gstMoving; |
|
867 | 1310 |
|
982 | 1311 |
if TestCollisionXwithGear(t^.ar[i], hwSign(t^.ar[i]^.dX)) then |
981 | 1312 |
begin |
1313 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -3, hwSign(t^.ar[i]^.dX)) |
|
1314 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1315 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX)) |
|
1316 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1317 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX)) |
|
1318 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1319 |
end; |
|
982 | 1320 |
|
981 | 1321 |
FollowGear:= t^.ar[i] |
1322 |
end; |
|
1323 |
end |
|
1324 |
end; |
|
126 | 1325 |
SetAllToActive |
38 | 1326 |
end; |
1327 |
||
4 | 1328 |
procedure AssignHHCoords; |
955 | 1329 |
var i, t, p, j: LongInt; |
1515 | 1330 |
ar: array[0..Pred(cMaxHHs)] of PHedgehog; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1331 |
Count: Longword; |
4 | 1332 |
begin |
1428 | 1333 |
if (GameFlags and (gfForts or gfDivideTeams)) <> 0 then |
955 | 1334 |
begin |
1335 |
t:= 0; |
|
1428 | 1336 |
TryDo(ClansCount = 2, 'More or less than 2 clans on map in divided teams mode!', true); |
955 | 1337 |
for p:= 0 to 1 do |
1338 |
begin |
|
1339 |
with ClansArray[p]^ do |
|
1340 |
for j:= 0 to Pred(TeamsNumber) do |
|
1341 |
with Teams[j]^ do |
|
1342 |
for i:= 0 to cMaxHHIndex do |
|
1343 |
with Hedgehogs[i] do |
|
958 | 1344 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
1345 |
begin |
|
1515 | 1346 |
FindPlace(Gear, false, t, t + 1024);// could make Gear == nil |
1347 |
if Gear <> nil then |
|
1348 |
begin |
|
1349 |
Gear^.Pos:= GetRandom(19); |
|
1350 |
Gear^.dX.isNegative:= p = 1; |
|
1351 |
end |
|
958 | 1352 |
end; |
955 | 1353 |
inc(t, 1024) |
1354 |
end |
|
1355 |
end else // mix hedgehogs |
|
1356 |
begin |
|
1357 |
Count:= 0; |
|
1358 |
for p:= 0 to Pred(TeamsCount) do |
|
1359 |
with TeamsArray[p]^ do |
|
1360 |
begin |
|
1361 |
for i:= 0 to cMaxHHIndex do |
|
1362 |
with Hedgehogs[i] do |
|
1363 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
|
1364 |
begin |
|
1515 | 1365 |
ar[Count]:= @Hedgehogs[i]; |
955 | 1366 |
inc(Count) |
1367 |
end; |
|
1368 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1369 |
|
955 | 1370 |
while (Count > 0) do |
1371 |
begin |
|
1372 |
i:= GetRandom(Count); |
|
1515 | 1373 |
FindPlace(ar[i]^.Gear, false, 0, 2048); |
1374 |
if ar[i]^.Gear <> nil then |
|
1375 |
begin |
|
1376 |
ar[i]^.Gear^.dX.isNegative:= ar[i]^.Gear^.X > _1024; |
|
1377 |
ar[i]^.Gear^.Pos:= GetRandom(19); |
|
1378 |
ar[i]:= ar[Count - 1] |
|
1379 |
end; |
|
955 | 1380 |
dec(Count) |
1381 |
end |
|
1382 |
end |
|
4 | 1383 |
end; |
1384 |
||
371 | 1385 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
10 | 1386 |
var t: PGear; |
1387 |
begin |
|
1388 |
t:= GearsList; |
|
1389 |
rX:= sqr(rX); |
|
1390 |
rY:= sqr(rY); |
|
1433 | 1391 |
|
10 | 1392 |
while t <> nil do |
1433 | 1393 |
begin |
1394 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
1395 |
if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then |
|
1396 |
exit(t); |
|
1397 |
t:= t^.NextGear |
|
1398 |
end; |
|
1399 |
||
351 | 1400 |
CheckGearNear:= nil |
15 | 1401 |
end; |
1402 |
||
1433 | 1403 |
{procedure AmmoFlameWork(Ammo: PGear); |
79 | 1404 |
var t: PGear; |
1405 |
begin |
|
1406 |
t:= GearsList; |
|
1407 |
while t <> nil do |
|
1295 | 1408 |
begin |
1409 |
if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then |
|
1410 |
if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then |
|
1411 |
begin |
|
1412 |
inc(t^.Damage, 5); |
|
1413 |
t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; |
|
1414 |
t^.dY:= - _0_25; |
|
1415 |
t^.Active:= true; |
|
1416 |
DeleteCI(t); |
|
1417 |
FollowGear:= t |
|
1418 |
end; |
|
1419 |
t:= t^.NextGear |
|
1420 |
end; |
|
1433 | 1421 |
end;} |
79 | 1422 |
|
371 | 1423 |
function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; |
16 | 1424 |
var t: PGear; |
1425 |
begin |
|
1426 |
t:= GearsList; |
|
1427 |
rX:= sqr(rX); |
|
1428 |
rY:= sqr(rY); |
|
1429 |
while t <> nil do |
|
1515 | 1430 |
begin |
1431 |
if t^.Kind in Kind then |
|
1432 |
if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then |
|
1433 |
exit(t); |
|
1434 |
t:= t^.NextGear |
|
1435 |
end; |
|
351 | 1436 |
CheckGearsNear:= nil |
16 | 1437 |
end; |
1438 |
||
1439 |
function CountGears(Kind: TGearType): Longword; |
|
1440 |
var t: PGear; |
|
351 | 1441 |
Result: Longword; |
16 | 1442 |
begin |
1443 |
Result:= 0; |
|
1444 |
t:= GearsList; |
|
1445 |
while t <> nil do |
|
1515 | 1446 |
begin |
1447 |
if t^.Kind = Kind then inc(Result); |
|
1448 |
t:= t^.NextGear |
|
1449 |
end; |
|
351 | 1450 |
CountGears:= Result |
16 | 1451 |
end; |
1452 |
||
15 | 1453 |
procedure SpawnBoxOfSmth; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1454 |
var t: LongInt; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1455 |
i: TAmmoType; |
15 | 1456 |
begin |
614 | 1457 |
if (cCaseFactor = 0) or |
1458 |
(CountGears(gtCase) >= 5) or |
|
1459 |
(getrandom(cCaseFactor) <> 0) then exit; |
|
1295 | 1460 |
|
498 | 1461 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
295 | 1462 |
case getrandom(2) of |
1463 |
0: begin |
|
351 | 1464 |
FollowGear^.Health:= 25; |
1465 |
FollowGear^.Pos:= posCaseHealth |
|
295 | 1466 |
end; |
1467 |
1: begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1468 |
t:= 0; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1469 |
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
|
1470 |
inc(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1471 |
t:= GetRandom(t); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1472 |
i:= Low(TAmmoType); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1473 |
dec(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1474 |
while t >= 0 do |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1475 |
begin |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1476 |
inc(i); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1477 |
dec(t, Ammoz[i].Probability) |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1478 |
end; |
1669 | 1479 |
PlaySound(sndReinforce, false, CurrentTeam^.voicepack); |
351 | 1480 |
FollowGear^.Pos:= posCaseAmmo; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1481 |
FollowGear^.State:= Longword(i) |
295 | 1482 |
end; |
1483 |
end; |
|
70 | 1484 |
FindPlace(FollowGear, true, 0, 2048) |
1485 |
end; |
|
1486 |
||
1515 | 1487 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); |
70 | 1488 |
|
1515 | 1489 |
function CountNonZeroz(x, y, r: LongInt): LongInt; |
1490 |
var i: LongInt; |
|
1491 |
Result: LongInt; |
|
1492 |
begin |
|
1493 |
Result:= 0; |
|
1494 |
if (y and $FFFFFC00) = 0 then |
|
1495 |
for i:= max(x - r, 0) to min(x + r, 2043) do |
|
1496 |
if Land[y, i] <> 0 then inc(Result); |
|
1497 |
CountNonZeroz:= Result |
|
1498 |
end; |
|
70 | 1499 |
|
495 | 1500 |
var x: LongInt; |
1515 | 1501 |
y, sy: LongInt; |
1502 |
ar: array[0..511] of TPoint; |
|
1503 |
ar2: array[0..1023] of TPoint; |
|
1504 |
cnt, cnt2: Longword; |
|
1505 |
delta: LongInt; |
|
70 | 1506 |
begin |
386 | 1507 |
delta:= 250; |
1508 |
cnt2:= 0; |
|
16 | 1509 |
repeat |
1515 | 1510 |
x:= Left + LongInt(GetRandom(Delta)); |
1511 |
repeat |
|
1512 |
inc(x, Delta); |
|
1513 |
cnt:= 0; |
|
1514 |
y:= -Gear^.Radius * 2; |
|
1515 |
while y < 1023 do |
|
1516 |
begin |
|
1517 |
repeat |
|
1518 |
inc(y, 2); |
|
1519 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0); |
|
1520 |
||
1521 |
sy:= y; |
|
1522 |
||
1523 |
repeat |
|
1524 |
inc(y); |
|
1525 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0); |
|
1526 |
||
1527 |
if (y - sy > Gear^.Radius * 2) |
|
1528 |
and (y < 1023) |
|
1529 |
and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then |
|
1530 |
begin |
|
1531 |
ar[cnt].X:= x; |
|
1532 |
if withFall then ar[cnt].Y:= sy + Gear^.Radius |
|
1533 |
else ar[cnt].Y:= y - Gear^.Radius; |
|
1534 |
inc(cnt) |
|
1535 |
end; |
|
1536 |
||
1537 |
inc(y, 45) |
|
1538 |
end; |
|
1539 |
||
1540 |
if cnt > 0 then |
|
1541 |
with ar[GetRandom(cnt)] do |
|
1542 |
begin |
|
1543 |
ar2[cnt2].x:= x; |
|
1544 |
ar2[cnt2].y:= y; |
|
1545 |
inc(cnt2) |
|
1546 |
end |
|
1547 |
until (x + Delta > Right); |
|
1548 |
dec(Delta, 60) |
|
386 | 1549 |
until (cnt2 > 0) or (Delta < 70); |
1515 | 1550 |
|
386 | 1551 |
if cnt2 > 0 then |
1515 | 1552 |
with ar2[GetRandom(cnt2)] do |
1553 |
begin |
|
1554 |
Gear^.X:= int2hwFloat(x); |
|
1555 |
Gear^.Y:= int2hwFloat(y); |
|
1556 |
{$IFDEF DEBUGFILE} |
|
1557 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
1558 |
{$ENDIF} |
|
1559 |
end |
|
1560 |
else |
|
1561 |
begin |
|
1562 |
OutError('Can''t find place for Gear', false); |
|
1563 |
DeleteGear(Gear); |
|
1564 |
Gear:= nil |
|
1565 |
end |
|
10 | 1566 |
end; |
1567 |
||
4 | 1568 |
initialization |
1569 |
||
1570 |
finalization |
|
95 | 1571 |
FreeGearsList; |
4 | 1572 |
|
1573 |
end. |