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