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