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