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