author | unc0rr |
Wed, 11 Jun 2008 15:42:53 +0000 | |
changeset 987 | 0fcd3fadda41 |
parent 984 | dd5f16f69926 |
child 994 | ea415d03968c |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like 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; |
|
27 |
TGearStepProcedure = procedure (Gear: PGear); |
|
28 |
TGear = record |
|
29 |
NextGear, PrevGear: PGear; |
|
30 |
Active: Boolean; |
|
930 | 31 |
Ammo : PAmmo; |
188 | 32 |
State : Longword; |
351 | 33 |
X : hwFloat; |
34 |
Y : hwFloat; |
|
35 |
dX: hwFloat; |
|
36 |
dY: hwFloat; |
|
42 | 37 |
Kind: TGearType; |
38 |
Pos: Longword; |
|
4 | 39 |
doStep: TGearStepProcedure; |
371 | 40 |
Radius: LongInt; |
188 | 41 |
Angle, Power : Longword; |
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
775
diff
changeset
|
42 |
DirAngle: real; |
4 | 43 |
Timer : LongWord; |
351 | 44 |
Elasticity: hwFloat; |
45 |
Friction : hwFloat; |
|
783 | 46 |
Message, MsgParam : Longword; |
4 | 47 |
Hedgehog: pointer; |
371 | 48 |
Health, Damage: LongInt; |
511 | 49 |
CollisionIndex: LongInt; |
371 | 50 |
Tag: LongInt; |
762 | 51 |
Tex: PTexture; |
293 | 52 |
Z: Longword; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
503
diff
changeset
|
53 |
IntersectGear: PGear; |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
593
diff
changeset
|
54 |
TriggerId: Longword; |
4 | 55 |
end; |
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, |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
809
diff
changeset
|
74 |
uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers, GL, |
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
809
diff
changeset
|
75 |
uStats; |
789 | 76 |
|
77 |
const MAXROPEPOINTS = 300; |
|
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 = ( |
|
351 | 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, |
|
409 | 132 |
@doStepBlowTorch, |
520 | 133 |
@doStepGirder, |
522 | 134 |
@doStepTeleport, |
534 | 135 |
@doStepHealthTag, |
590 | 136 |
@doStepSwitcher, |
924 | 137 |
@doStepCase, |
925 | 138 |
@doStepMortar, |
984 | 139 |
@doStepWhip, |
140 |
@doStepKamikaze |
|
4 | 141 |
); |
142 |
||
294 | 143 |
procedure InsertGearToList(Gear: PGear); |
803 | 144 |
var tmp, ptmp: PGear; |
294 | 145 |
begin |
146 |
if GearsList = nil then |
|
147 |
GearsList:= Gear |
|
148 |
else begin |
|
149 |
tmp:= GearsList; |
|
803 | 150 |
ptmp:= GearsList; |
151 |
while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do |
|
152 |
begin |
|
153 |
ptmp:= tmp; |
|
154 |
tmp:= tmp^.NextGear |
|
155 |
end; |
|
294 | 156 |
|
803 | 157 |
if ptmp <> nil then |
158 |
begin |
|
159 |
Gear^.NextGear:= ptmp^.NextGear; |
|
160 |
Gear^.PrevGear:= ptmp; |
|
161 |
if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear; |
|
162 |
ptmp^.NextGear:= Gear |
|
163 |
end |
|
164 |
else GearsList:= Gear |
|
294 | 165 |
end |
166 |
end; |
|
167 |
||
168 |
procedure RemoveGearFromList(Gear: PGear); |
|
169 |
begin |
|
351 | 170 |
if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear; |
171 |
if Gear^.PrevGear <> nil then Gear^.PrevGear^.NextGear:= Gear^.NextGear |
|
809 | 172 |
else GearsList:= Gear^.NextGear |
294 | 173 |
end; |
174 |
||
371 | 175 |
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
79 | 176 |
const Counter: Longword = 0; |
351 | 177 |
var Result: PGear; |
4 | 178 |
begin |
79 | 179 |
inc(Counter); |
108 | 180 |
{$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+'), d('+floattostr(dX)+','+floattostr(dY)+')');{$ENDIF} |
4 | 181 |
New(Result); |
357 | 182 |
{$IFDEF DEBUGFILE}AddFileLog('AddGear: type = ' + inttostr(ord(Kind)));{$ENDIF} |
4 | 183 |
FillChar(Result^, sizeof(TGear), 0); |
498 | 184 |
Result^.X:= int2hwFloat(X); |
185 |
Result^.Y:= int2hwFloat(Y); |
|
351 | 186 |
Result^.Kind := Kind; |
187 |
Result^.State:= State; |
|
188 |
Result^.Active:= true; |
|
189 |
Result^.dX:= dX; |
|
190 |
Result^.dY:= dY; |
|
191 |
Result^.doStep:= doStepHandlers[Kind]; |
|
511 | 192 |
Result^.CollisionIndex:= -1; |
351 | 193 |
Result^.Timer:= Timer; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
503
diff
changeset
|
194 |
|
4 | 195 |
if CurrentTeam <> nil then |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
503
diff
changeset
|
196 |
begin |
602 | 197 |
Result^.Hedgehog:= CurrentHedgehog; |
198 |
Result^.IntersectGear:= CurrentHedgehog^.Gear |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
503
diff
changeset
|
199 |
end; |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
789
diff
changeset
|
200 |
|
4 | 201 |
case Kind of |
915 | 202 |
gtAmmo_Bomb, |
203 |
gtClusterBomb: begin |
|
351 | 204 |
Result^.Radius:= 4; |
205 |
Result^.Elasticity:= _0_6; |
|
206 |
Result^.Friction:= _0_995; |
|
4 | 207 |
end; |
208 |
gtHedgehog: begin |
|
351 | 209 |
Result^.Radius:= cHHRadius; |
210 |
Result^.Elasticity:= _0_35; |
|
211 |
Result^.Friction:= _0_999; |
|
212 |
Result^.Angle:= cMaxAngle div 2; |
|
213 |
Result^.Z:= cHHZ; |
|
4 | 214 |
end; |
215 |
gtAmmo_Grenade: begin |
|
351 | 216 |
Result^.Radius:= 4; |
4 | 217 |
end; |
218 |
gtHealthTag: begin |
|
351 | 219 |
Result^.Timer:= 1500; |
522 | 220 |
Result^.Z:= 2001; |
4 | 221 |
end; |
222 |
gtGrave: begin |
|
351 | 223 |
Result^.Radius:= 10; |
224 |
Result^.Elasticity:= _0_6; |
|
4 | 225 |
end; |
226 |
gtUFO: begin |
|
351 | 227 |
Result^.Radius:= 5; |
228 |
Result^.Timer:= 500; |
|
229 |
Result^.Elasticity:= _0_9 |
|
4 | 230 |
end; |
231 |
gtShotgunShot: begin |
|
351 | 232 |
Result^.Timer:= 900; |
233 |
Result^.Radius:= 2 |
|
4 | 234 |
end; |
235 |
gtPickHammer: begin |
|
351 | 236 |
Result^.Radius:= 10; |
237 |
Result^.Timer:= 4000 |
|
4 | 238 |
end; |
239 |
gtSmokeTrace: begin |
|
498 | 240 |
Result^.X:= Result^.X - _16; |
241 |
Result^.Y:= Result^.Y - _16; |
|
351 | 242 |
Result^.State:= 8 |
4 | 243 |
end; |
244 |
gtRope: begin |
|
351 | 245 |
Result^.Radius:= 3; |
498 | 246 |
Result^.Friction:= _450; |
4 | 247 |
RopePoints.Count:= 0; |
248 |
end; |
|
9 | 249 |
gtExplosion: begin |
498 | 250 |
Result^.X:= Result^.X - _25; |
251 |
Result^.Y:= Result^.Y - _25; |
|
9 | 252 |
end; |
10 | 253 |
gtMine: begin |
503 | 254 |
Result^.State:= Result^.State or gstMoving; |
915 | 255 |
Result^.Radius:= 2; |
351 | 256 |
Result^.Elasticity:= _0_55; |
257 |
Result^.Friction:= _0_995; |
|
258 |
Result^.Timer:= 3000; |
|
10 | 259 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset
|
260 |
gtCase: begin |
351 | 261 |
Result^.Radius:= 16; |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
262 |
Result^.Elasticity:= _0_3 |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset
|
263 |
end; |
37 | 264 |
gtDEagleShot: begin |
351 | 265 |
Result^.Radius:= 1; |
266 |
Result^.Health:= 50 |
|
37 | 267 |
end; |
39 | 268 |
gtDynamite: begin |
351 | 269 |
Result^.Radius:= 3; |
270 |
Result^.Elasticity:= _0_55; |
|
271 |
Result^.Friction:= _0_03; |
|
272 |
Result^.Timer:= 5000; |
|
39 | 273 |
end; |
910 | 274 |
gtCluster: Result^.Radius:= 2; |
878 | 275 |
gtShover: Result^.Radius:= 20; |
79 | 276 |
gtFlame: begin |
351 | 277 |
Result^.Angle:= Counter mod 64; |
278 |
Result^.Radius:= 1; |
|
279 |
Result^.Health:= 2; |
|
280 |
Result^.dY:= (getrandom - _0_8) * _0_03; |
|
281 |
Result^.dX:= (getrandom - _0_5) * _0_4 |
|
79 | 282 |
end; |
82 | 283 |
gtFirePunch: begin |
351 | 284 |
Result^.Radius:= 15; |
285 |
Result^.Tag:= Y |
|
82 | 286 |
end; |
302 | 287 |
gtAirBomb: begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
288 |
Result^.Radius:= 5; |
302 | 289 |
end; |
290 |
gtBlowTorch: begin |
|
511 | 291 |
Result^.Radius:= cHHRadius + cBlowTorchC; |
351 | 292 |
Result^.Timer:= 7500; |
302 | 293 |
end; |
522 | 294 |
gtSmallDamage: begin |
295 |
Result^.Timer:= 1100; |
|
296 |
Result^.Z:= 2000; |
|
297 |
end; |
|
540 | 298 |
gtSwitcher: begin |
299 |
Result^.Z:= cCurrHHZ |
|
300 |
end; |
|
593 | 301 |
gtTarget: begin |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
302 |
Result^.Radius:= 16; |
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
595
diff
changeset
|
303 |
Result^.Elasticity:= _0_3 |
593 | 304 |
end; |
924 | 305 |
gtMortar: begin |
306 |
Result^.Elasticity:= _0_2; |
|
307 |
Result^.Friction:= _0_08 |
|
308 |
end; |
|
925 | 309 |
gtWhip: Result^.Radius:= 20; |
984 | 310 |
gtKamikaze: begin |
311 |
Result^.Health:= 2048; |
|
312 |
Result^.Radius:= 20 |
|
313 |
end; |
|
4 | 314 |
end; |
351 | 315 |
InsertGearToList(Result); |
316 |
AddGear:= Result |
|
4 | 317 |
end; |
318 |
||
319 |
procedure DeleteGear(Gear: PGear); |
|
48 | 320 |
var team: PTeam; |
307 | 321 |
t: Longword; |
4 | 322 |
begin |
503 | 323 |
DeleteCI(Gear); |
762 | 324 |
|
325 |
if Gear^.Tex <> nil then |
|
522 | 326 |
begin |
762 | 327 |
FreeTexture(Gear^.Tex); |
328 |
Gear^.Tex:= nil |
|
522 | 329 |
end; |
762 | 330 |
|
351 | 331 |
if Gear^.Kind = gtHedgehog then |
4 | 332 |
if CurAmmoGear <> nil then |
333 |
begin |
|
351 | 334 |
Gear^.Message:= gm_Destroy; |
335 |
CurAmmoGear^.Message:= gm_Destroy; |
|
4 | 336 |
exit |
47 | 337 |
end else |
338 |
begin |
|
498 | 339 |
if not (hwRound(Gear^.Y) < cWaterLine) then |
307 | 340 |
begin |
351 | 341 |
t:= max(Gear^.Damage, Gear^.Health); |
867 | 342 |
Gear^.Damage:= t; |
498 | 343 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
867 | 344 |
uStats.HedgehogDamaged(Gear) |
307 | 345 |
end; |
351 | 346 |
team:= PHedgehog(Gear^.Hedgehog)^.Team; |
602 | 347 |
if CurrentHedgehog^.Gear = Gear then |
145 | 348 |
FreeActionsList; // to avoid ThinkThread on drawned gear |
351 | 349 |
PHedgehog(Gear^.Hedgehog)^.Gear:= nil; |
307 | 350 |
inc(KilledHHs); |
48 | 351 |
RecountTeamHealth(team); |
47 | 352 |
end; |
357 | 353 |
{$IFDEF DEBUGFILE}AddFileLog('DeleteGear');{$ENDIF} |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
593
diff
changeset
|
354 |
if Gear^.TriggerId <> 0 then TickTrigger(Gear^.TriggerId); |
82 | 355 |
if CurAmmoGear = Gear then CurAmmoGear:= nil; |
4 | 356 |
if FollowGear = Gear then FollowGear:= nil; |
294 | 357 |
RemoveGearFromList(Gear); |
4 | 358 |
Dispose(Gear) |
359 |
end; |
|
360 |
||
361 |
function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs |
|
362 |
var Gear: PGear; |
|
363 |
begin |
|
351 | 364 |
CheckNoDamage:= true; |
4 | 365 |
Gear:= GearsList; |
366 |
while Gear <> nil do |
|
867 | 367 |
begin |
368 |
if Gear^.Kind = gtHedgehog then |
|
369 |
if Gear^.Damage <> 0 then |
|
370 |
begin |
|
371 |
CheckNoDamage:= false; |
|
372 |
uStats.HedgehogDamaged(Gear); |
|
351 | 373 |
|
867 | 374 |
if Gear^.Health < Gear^.Damage then |
375 |
Gear^.Health:= 0 |
|
376 |
else |
|
377 |
dec(Gear^.Health, Gear^.Damage); |
|
378 |
||
379 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12, |
|
380 |
gtHealthTag, Gear^.Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
381 |
RenderHealth(PHedgehog(Gear^.Hedgehog)^); |
|
382 |
RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team); |
|
383 |
||
384 |
Gear^.Damage:= 0 |
|
385 |
end; |
|
386 |
Gear:= Gear^.NextGear |
|
387 |
end; |
|
4 | 388 |
end; |
389 |
||
522 | 390 |
procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear); |
391 |
begin |
|
529 | 392 |
if cAltDamage then |
393 |
AddGear(X, Y, gtSmallDamage, Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
522 | 394 |
end; |
395 |
||
4 | 396 |
procedure ProcessGears; |
614 | 397 |
const delay: LongWord = 0; |
869 | 398 |
step: (stDelay, stChDmg, stTurnReact, |
399 |
stAfterDelay, stChWin, stSpawn, stNTurn) = stDelay; |
|
4 | 400 |
var Gear, t: PGear; |
401 |
begin |
|
868 | 402 |
PrvInactive:= AllInactive; |
4 | 403 |
AllInactive:= true; |
404 |
t:= GearsList; |
|
405 |
while t<>nil do |
|
406 |
begin |
|
407 |
Gear:= t; |
|
351 | 408 |
t:= Gear^.NextGear; |
409 |
if Gear^.Active then Gear^.doStep(Gear); |
|
4 | 410 |
end; |
89 | 411 |
|
4 | 412 |
if AllInactive then |
15 | 413 |
case step of |
414 |
stDelay: begin |
|
415 |
if delay = 0 then |
|
416 |
delay:= cInactDelay |
|
614 | 417 |
else |
418 |
dec(delay); |
|
419 |
||
420 |
if delay = 0 then |
|
421 |
inc(step) |
|
15 | 422 |
end; |
423 |
stChDmg: if CheckNoDamage then inc(step) else step:= stDelay; |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
809
diff
changeset
|
424 |
stTurnReact: begin |
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
425 |
if not isInMultiShoot then |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
426 |
begin |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
427 |
uStats.TurnReaction; |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
428 |
inc(step) |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
429 |
end else |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
430 |
inc(step, 2); |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
809
diff
changeset
|
431 |
end; |
815 | 432 |
stAfterDelay: begin |
433 |
if delay = 0 then |
|
434 |
delay:= cInactDelay |
|
435 |
else |
|
436 |
dec(delay); |
|
437 |
||
438 |
if delay = 0 then |
|
439 |
inc(step) |
|
440 |
end; |
|
869 | 441 |
stChWin: if not CheckForWin then inc(step) else step:= stDelay; |
15 | 442 |
stSpawn: begin |
443 |
if not isInMultiShoot then SpawnBoxOfSmth; |
|
444 |
inc(step) |
|
445 |
end; |
|
446 |
stNTurn: begin |
|
447 |
if isInMultiShoot then isInMultiShoot:= false |
|
307 | 448 |
else begin |
351 | 449 |
ParseCommand('/nextturn', true); |
307 | 450 |
end; |
15 | 451 |
step:= Low(step) |
452 |
end; |
|
453 |
end; |
|
454 |
||
4 | 455 |
if TurnTimeLeft > 0 then |
870 | 456 |
if CurrentHedgehog^.Gear <> nil then |
457 |
if ((CurrentHedgehog^.Gear^.State and gstAttacking) = 0) |
|
458 |
and not isInMultiShoot then |
|
459 |
begin |
|
460 |
if (TurnTimeLeft = 5000) |
|
461 |
and (CurrentHedgehog^.Gear <> nil) |
|
462 |
and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0) then PlaySound(sndHurry, false); |
|
463 |
dec(TurnTimeLeft) |
|
464 |
end; |
|
351 | 465 |
|
651 | 466 |
if (not CurrentTeam^.ExtDriven) and |
917 | 467 |
((GameTicks and $FFFF) = $FFFF) then |
468 |
begin |
|
469 |
SendIPCTimeInc; |
|
470 |
inc(hiTicks) // we do not recieve a message for this |
|
471 |
end; |
|
656
6d6d9d7b1054
Fix network game bug caused by recent protocol changes
unc0rr
parents:
651
diff
changeset
|
472 |
|
515 | 473 |
inc(GameTicks) |
4 | 474 |
end; |
475 |
||
476 |
procedure SetAllToActive; |
|
477 |
var t: PGear; |
|
478 |
begin |
|
479 |
AllInactive:= false; |
|
480 |
t:= GearsList; |
|
351 | 481 |
while t <> nil do |
4 | 482 |
begin |
351 | 483 |
t^.Active:= true; |
484 |
t:= t^.NextGear |
|
4 | 485 |
end |
486 |
end; |
|
487 |
||
488 |
procedure SetAllHHToActive; |
|
489 |
var t: PGear; |
|
490 |
begin |
|
491 |
AllInactive:= false; |
|
492 |
t:= GearsList; |
|
351 | 493 |
while t <> nil do |
4 | 494 |
begin |
351 | 495 |
if t^.Kind = gtHedgehog then t^.Active:= true; |
496 |
t:= t^.NextGear |
|
4 | 497 |
end |
498 |
end; |
|
499 |
||
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
500 |
procedure DrawHH(Gear: PGear); |
371 | 501 |
var t: LongInt; |
822 | 502 |
amt: TAmmoType; |
862 | 503 |
hx, hy, m: LongInt; |
504 |
aAngle, dAngle: real; |
|
824 | 505 |
defaultPos: boolean; |
292 | 506 |
begin |
868 | 507 |
if (Gear^.State and gstHHDeath) <> 0 then |
508 |
begin |
|
509 |
DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos); |
|
510 |
exit |
|
511 |
end; |
|
824 | 512 |
defaultPos:= true; |
847 | 513 |
|
821
e6c0408b54ed
Use 'regular standing' and 'rope swing' hedgehog sprites
unc0rr
parents:
815
diff
changeset
|
514 |
if (Gear^.State and gstHHDriven) <> 0 then |
966 | 515 |
begin |
516 |
hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx; |
|
517 |
hy:= hwRound(Gear^.Y) - 2 + WorldDy; |
|
518 |
aangle:= Gear^.Angle * 180 / cMaxAngle - 90; |
|
874 | 519 |
|
966 | 520 |
if CurAmmoGear <> nil then |
521 |
begin |
|
522 |
case CurAmmoGear^.Kind of |
|
523 |
gtShotgunShot: if (CurAmmoGear^.State and gstAnimation <> 0) then |
|
524 |
DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle) |
|
525 |
else |
|
526 |
DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); |
|
527 |
gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle); |
|
528 |
gtRope: begin |
|
529 |
if Gear^.X < CurAmmoGear^.X then |
|
530 |
begin |
|
531 |
dAngle:= 0; |
|
532 |
m:= 1 |
|
533 |
end else |
|
534 |
begin |
|
535 |
dAngle:= 180; |
|
536 |
m:= -1 |
|
537 |
end; |
|
538 |
DrawHedgehog(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
|
539 |
m, |
|
540 |
1, |
|
541 |
0, |
|
542 |
DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle); |
|
543 |
defaultPos:= false |
|
862 | 544 |
end; |
966 | 545 |
gtBlowTorch: begin |
546 |
DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); |
|
547 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
548 |
hwSign(Gear^.dX), |
|
549 |
1, |
|
550 |
3, |
|
551 |
0); |
|
552 |
defaultPos:= false |
|
553 |
end; |
|
554 |
gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180); |
|
555 |
gtFirePunch: begin |
|
556 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
557 |
hwSign(Gear^.dX), |
|
558 |
1, |
|
559 |
4, |
|
560 |
0); |
|
561 |
defaultPos:= false |
|
562 |
end; |
|
563 |
gtPickHammer, |
|
564 |
gtTeleport: defaultPos:= false; |
|
987 | 565 |
gtKamikaze: begin |
566 |
if CurAmmoGear^.Pos = 0 then |
|
567 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
568 |
hwSign(Gear^.dX), |
|
569 |
1, |
|
570 |
6, |
|
571 |
0) |
|
572 |
else |
|
573 |
DrawRotatedF(sprKamikaze, |
|
574 |
hwRound(Gear^.X) + WorldDx, |
|
575 |
hwRound(Gear^.Y) + WorldDy, |
|
576 |
CurAmmoGear^.Pos - 1, |
|
577 |
1, |
|
578 |
DxDy2Angle(Gear^.dY, Gear^.dX)); |
|
579 |
||
580 |
defaultPos:= false |
|
581 |
end; |
|
966 | 582 |
end; |
876 | 583 |
|
966 | 584 |
case CurAmmoGear^.Kind of |
585 |
gtShotgunShot, |
|
586 |
gtDEagleShot, |
|
587 |
gtShover: begin |
|
588 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
589 |
hwSign(Gear^.dX), |
|
590 |
0, |
|
591 |
4, |
|
592 |
0); |
|
593 |
defaultPos:= false |
|
594 |
end |
|
876 | 595 |
end |
966 | 596 |
end else |
874 | 597 |
|
966 | 598 |
if ((Gear^.State and gstHHJumping) <> 0) then |
824 | 599 |
begin |
874 | 600 |
if ((Gear^.State and gstHHHJump) <> 0) then |
601 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
602 |
- hwSign(Gear^.dX), |
|
603 |
1, |
|
604 |
1, |
|
605 |
0) |
|
606 |
else |
|
607 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
608 |
hwSign(Gear^.dX), |
|
609 |
1, |
|
610 |
1, |
|
611 |
0); |
|
824 | 612 |
defaultPos:= false |
613 |
end else |
|
966 | 614 |
|
615 |
if (Gear^.Message and (gm_Left or gm_Right) <> 0) then |
|
616 |
begin |
|
822 | 617 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
618 |
hwSign(Gear^.dX), |
|
619 |
0, |
|
966 | 620 |
PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, |
822 | 621 |
0); |
966 | 622 |
defaultPos:= false |
623 |
end |
|
624 |
else |
|
625 |
||
626 |
if ((Gear^.State and gstAttacked) = 0) then |
|
627 |
begin |
|
628 |
amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType; |
|
629 |
case amt of |
|
630 |
amBazooka, |
|
631 |
amMortar: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle); |
|
632 |
amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle); |
|
633 |
amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); |
|
634 |
amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle); |
|
635 |
amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); |
|
636 |
end; |
|
637 |
||
638 |
case amt of |
|
639 |
amAirAttack, |
|
640 |
amMineStrike: DrawRotated(sprHandAirAttack, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0); |
|
641 |
amPickHammer: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
642 |
hwSign(Gear^.dX), |
|
643 |
1, |
|
644 |
2, |
|
645 |
0); |
|
646 |
amBlowTorch: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
647 |
hwSign(Gear^.dX), |
|
648 |
1, |
|
649 |
3, |
|
650 |
0); |
|
651 |
amTeleport: DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, 0, hwSign(Gear^.dX), 0); |
|
987 | 652 |
amKamikaze: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
653 |
hwSign(Gear^.dX), |
|
654 |
1, |
|
655 |
5, |
|
656 |
0); |
|
966 | 657 |
else |
658 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
659 |
hwSign(Gear^.dX), |
|
660 |
0, |
|
661 |
4, |
|
662 |
0); |
|
663 |
end; |
|
664 |
||
665 |
case amt of |
|
666 |
amBaseballBat: DrawRotated(sprHandBaseball, |
|
667 |
hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx, |
|
668 |
hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle); |
|
669 |
end; |
|
670 |
||
671 |
defaultPos:= false |
|
672 |
end |
|
673 |
end else // not gstHHDriven |
|
674 |
if ((Gear^.State and gstHHJumping) <> 0) then |
|
675 |
begin |
|
676 |
if ((Gear^.State and gstHHHJump) <> 0) then |
|
677 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
678 |
- hwSign(Gear^.dX), |
|
679 |
1, |
|
680 |
1, |
|
681 |
0) |
|
682 |
else |
|
683 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
684 |
hwSign(Gear^.dX), |
|
685 |
1, |
|
686 |
1, |
|
687 |
0); |
|
688 |
defaultPos:= false |
|
834 | 689 |
end; |
690 |
||
824 | 691 |
|
845 | 692 |
if defaultPos then |
970 | 693 |
begin |
954 | 694 |
DrawRotatedF(sprHHIdle, |
695 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
696 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
957 | 697 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
822 | 698 |
hwSign(Gear^.dX), |
699 |
0); |
|
970 | 700 |
DrawRotatedF(sprHat, |
701 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
702 |
hwRound(Gear^.Y) - 8 + WorldDy, |
|
703 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
|
704 |
hwSign(Gear^.dX), |
|
705 |
0); |
|
706 |
end; |
|
292 | 707 |
|
351 | 708 |
with PHedgehog(Gear^.Hedgehog)^ do |
958 | 709 |
if (Gear^.State{ and not gstAnimation}) = 0 then |
710 |
begin |
|
976 | 711 |
t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy; |
958 | 712 |
if (cTagsMask and 1) <> 0 then |
713 |
begin |
|
714 |
dec(t, HealthTagTex^.h + 2); |
|
715 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex) |
|
716 |
end; |
|
717 |
if (cTagsMask and 2) <> 0 then |
|
718 |
begin |
|
719 |
dec(t, NameTagTex^.h + 2); |
|
720 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTagTex) |
|
721 |
end; |
|
722 |
if (cTagsMask and 4) <> 0 then |
|
723 |
begin |
|
724 |
dec(t, Team^.NameTagTex^.h + 2); |
|
725 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex) |
|
726 |
end |
|
727 |
end else // Current hedgehog |
|
728 |
if (Gear^.State and gstHHDriven) <> 0 then |
|
729 |
begin |
|
730 |
if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then |
|
731 |
DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy, |
|
732 |
GameTicks div 32 mod 16); |
|
821
e6c0408b54ed
Use 'regular standing' and 'rope swing' hedgehog sprites
unc0rr
parents:
815
diff
changeset
|
733 |
|
958 | 734 |
if (Gear^.State and gstDrowning) = 0 then |
735 |
if (Gear^.State and gstHHThinking) <> 0 then |
|
736 |
DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, 0) |
|
737 |
else |
|
738 |
if ShowCrosshair and ((Gear^.State and gstAttacked) = 0) then |
|
739 |
begin |
|
740 |
if ((Gear^.State and gstHHHJump) <> 0) then m:= -1 else m:= 1; |
|
741 |
DrawRotatedTex(Team^.CrosshairTex, |
|
742 |
12, 12, |
|
743 |
Round(hwRound(Gear^.X) + hwSign(Gear^.dX) * m * Sin(Gear^.Angle*pi/cMaxAngle) * 60) + WorldDx, |
|
744 |
Round(hwRound(Gear^.Y) - Cos(Gear^.Angle*pi/cMaxAngle) * 60) + WorldDy, 0, |
|
745 |
hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle) |
|
746 |
end |
|
747 |
end; |
|
292 | 748 |
end; |
749 |
||
956 | 750 |
procedure DrawGears; |
853 | 751 |
var Gear, HHGear: PGear; |
4 | 752 |
i: Longword; |
371 | 753 |
roplen: LongInt; |
4 | 754 |
|
371 | 755 |
procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt); |
756 |
var eX, eY, dX, dY: LongInt; |
|
757 |
i, sX, sY, x, y, d: LongInt; |
|
366 | 758 |
b: boolean; |
4 | 759 |
begin |
37 | 760 |
if (X1 = X2) and (Y1 = Y2) then |
761 |
begin |
|
351 | 762 |
OutError('WARNING: zero length rope line!', false); |
37 | 763 |
exit |
764 |
end; |
|
366 | 765 |
eX:= 0; |
766 |
eY:= 0; |
|
767 |
dX:= X2 - X1; |
|
768 |
dY:= Y2 - Y1; |
|
769 |
||
770 |
if (dX > 0) then sX:= 1 |
|
771 |
else |
|
772 |
if (dX < 0) then |
|
773 |
begin |
|
774 |
sX:= -1; |
|
775 |
dX:= -dX |
|
776 |
end else sX:= dX; |
|
777 |
||
778 |
if (dY > 0) then sY:= 1 |
|
779 |
else |
|
780 |
if (dY < 0) then |
|
4 | 781 |
begin |
366 | 782 |
sY:= -1; |
783 |
dY:= -dY |
|
784 |
end else sY:= dY; |
|
785 |
||
786 |
if (dX > dY) then d:= dX |
|
787 |
else d:= dY; |
|
788 |
||
789 |
x:= X1; |
|
790 |
y:= Y1; |
|
791 |
||
792 |
for i:= 0 to d do |
|
793 |
begin |
|
794 |
inc(eX, dX); |
|
795 |
inc(eY, dY); |
|
796 |
b:= false; |
|
797 |
if (eX > d) then |
|
35 | 798 |
begin |
366 | 799 |
dec(eX, d); |
800 |
inc(x, sX); |
|
801 |
b:= true |
|
35 | 802 |
end; |
366 | 803 |
if (eY > d) then |
35 | 804 |
begin |
366 | 805 |
dec(eY, d); |
806 |
inc(y, sY); |
|
807 |
b:= true |
|
35 | 808 |
end; |
366 | 809 |
if b then |
810 |
begin |
|
811 |
inc(roplen); |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
812 |
if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0) |
366 | 813 |
end |
4 | 814 |
end |
366 | 815 |
end; |
4 | 816 |
|
817 |
begin |
|
818 |
Gear:= GearsList; |
|
819 |
while Gear<>nil do |
|
820 |
begin |
|
351 | 821 |
case Gear^.Kind of |
822 | 822 |
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
|
823 |
gtHedgehog: DrawHH(Gear); |
822 | 824 |
gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
522 | 825 |
gtHealthTag, |
762 | 826 |
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
|
827 |
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
|
828 |
gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4); |
848 | 829 |
gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0); |
4 | 830 |
gtRope: begin |
35 | 831 |
roplen:= 0; |
4 | 832 |
if RopePoints.Count > 0 then |
833 |
begin |
|
834 |
i:= 0; |
|
835 |
while i < Pred(RopePoints.Count) do |
|
836 |
begin |
|
351 | 837 |
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
838 |
hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy); |
|
4 | 839 |
inc(i) |
840 |
end; |
|
351 | 841 |
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
842 |
hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy); |
|
843 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
|
844 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 845 |
DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) |
4 | 846 |
end else |
35 | 847 |
begin |
351 | 848 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
849 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 850 |
DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
35 | 851 |
end; |
4 | 852 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
853 |
gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
854 |
gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
351 | 855 |
gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420) |
822 | 856 |
then DrawRotated(sprMineOff, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle) |
857 |
else DrawRotated(sprMineOn, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
|
351 | 858 |
gtCase: case Gear^.Pos of |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
859 |
posCaseAmmo : DrawSprite(sprCase, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
860 |
posCaseHealth: DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, (GameTicks shr 6) mod 13); |
42 | 861 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
862 |
gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1); |
822 | 863 |
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
|
864 |
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
|
865 |
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
|
866 |
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
|
867 |
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
|
868 |
else DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 1); |
822 | 869 |
gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
853 | 870 |
gtTeleport: begin |
871 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
872 |
DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
873 |
DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
874 |
end; |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
875 |
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
|
876 |
gtTarget: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
959 | 877 |
gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
4 | 878 |
end; |
351 | 879 |
Gear:= Gear^.NextGear |
4 | 880 |
end; |
881 |
end; |
|
882 |
||
883 |
procedure FreeGearsList; |
|
884 |
var t, tt: PGear; |
|
885 |
begin |
|
886 |
tt:= GearsList; |
|
887 |
GearsList:= nil; |
|
888 |
while tt<>nil do |
|
889 |
begin |
|
890 |
t:= tt; |
|
351 | 891 |
tt:= tt^.NextGear; |
4 | 892 |
Dispose(t) |
893 |
end; |
|
894 |
end; |
|
895 |
||
10 | 896 |
procedure AddMiscGears; |
371 | 897 |
var i: LongInt; |
4 | 898 |
begin |
498 | 899 |
AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000); |
22 | 900 |
if (GameFlags and gfForts) = 0 then |
622 | 901 |
for i:= 0 to Pred(cLandAdditions) do |
498 | 902 |
FindPlace(AddGear(0, 0, gtMine, 0, _0, _0, 0), false, 0, 2048); |
4 | 903 |
end; |
904 |
||
371 | 905 |
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); |
4 | 906 |
var Gear: PGear; |
506 | 907 |
dmg, dmgRadius: LongInt; |
4 | 908 |
begin |
909 |
TargetPoint.X:= NoPointX; |
|
910 |
{$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF} |
|
498 | 911 |
if Radius = 50 then AddGear(X, Y, gtExplosion, 0, _0, _0, 0); |
355 | 912 |
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false); |
506 | 913 |
if (Mask and EXPLAllDamageInRadius)=0 then dmgRadius:= Radius shl 1 |
914 |
else dmgRadius:= Radius; |
|
4 | 915 |
Gear:= GearsList; |
916 |
while Gear <> nil do |
|
917 |
begin |
|
506 | 918 |
dmg:= dmgRadius - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
538 | 919 |
if (dmg > 1) and |
522 | 920 |
((Gear^.State and gstNoDamage) = 0) then |
4 | 921 |
begin |
355 | 922 |
dmg:= dmg div 2; |
351 | 923 |
case Gear^.Kind of |
10 | 924 |
gtHedgehog, |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset
|
925 |
gtMine, |
79 | 926 |
gtCase, |
593 | 927 |
gtTarget, |
79 | 928 |
gtFlame: begin |
355 | 929 |
{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} |
522 | 930 |
if (Mask and EXPLNoDamage) = 0 then |
931 |
begin |
|
932 |
inc(Gear^.Damage, dmg); |
|
933 |
if Gear^.Kind = gtHedgehog then |
|
934 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, Gear) |
|
935 |
end; |
|
351 | 936 |
if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then |
42 | 937 |
begin |
506 | 938 |
DeleteCI(Gear); |
498 | 939 |
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X)); |
940 |
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y)); |
|
503 | 941 |
Gear^.State:= Gear^.State or gstMoving; |
351 | 942 |
Gear^.Active:= true; |
42 | 943 |
FollowGear:= Gear |
944 |
end; |
|
4 | 945 |
end; |
51 | 946 |
gtGrave: begin |
351 | 947 |
Gear^.dY:= - _0_004 * dmg; |
948 |
Gear^.Active:= true; |
|
51 | 949 |
end; |
4 | 950 |
end; |
951 |
end; |
|
351 | 952 |
Gear:= Gear^.NextGear |
80 | 953 |
end; |
621 | 954 |
if (Mask and EXPLDontDraw) = 0 then |
955 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(X, Y, Radius); |
|
498 | 956 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
4 | 957 |
end; |
958 |
||
506 | 959 |
procedure ShotgunShot(Gear: PGear); |
960 |
var t: PGear; |
|
955 | 961 |
dmg: LongInt; |
506 | 962 |
begin |
509 | 963 |
Gear^.Radius:= cShotgunRadius; |
506 | 964 |
t:= GearsList; |
965 |
while t <> nil do |
|
966 |
begin |
|
967 |
dmg:= min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25); |
|
538 | 968 |
if dmg > 0 then |
506 | 969 |
case t^.Kind of |
970 |
gtHedgehog, |
|
971 |
gtMine, |
|
593 | 972 |
gtCase, |
973 |
gtTarget: begin |
|
506 | 974 |
inc(t^.Damage, dmg); |
867 | 975 |
|
522 | 976 |
if t^.Kind = gtHedgehog then |
531 | 977 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, t); |
867 | 978 |
|
506 | 979 |
DeleteCI(t); |
856 | 980 |
t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); |
506 | 981 |
t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; |
982 |
t^.State:= t^.State or gstMoving; |
|
983 |
t^.Active:= true; |
|
984 |
FollowGear:= t |
|
985 |
end; |
|
986 |
gtGrave: begin |
|
987 |
t^.dY:= - _0_1; |
|
988 |
t^.Active:= true |
|
989 |
end; |
|
990 |
end; |
|
991 |
t:= t^.NextGear |
|
992 |
end; |
|
621 | 993 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) |
506 | 994 |
end; |
995 |
||
371 | 996 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
53 | 997 |
var t: PGearArray; |
371 | 998 |
i: LongInt; |
38 | 999 |
begin |
53 | 1000 |
t:= CheckGearsCollision(Ammo); |
351 | 1001 |
i:= t^.Count; |
53 | 1002 |
while i > 0 do |
981 | 1003 |
begin |
1004 |
dec(i); |
|
1005 |
if (t^.ar[i]^.State and gstNoDamage) = 0 then |
|
1006 |
case t^.ar[i]^.Kind of |
|
1007 |
gtHedgehog, |
|
1008 |
gtMine, |
|
1009 |
gtTarget, |
|
1010 |
gtCase: begin |
|
1011 |
inc(t^.ar[i]^.Damage, Damage); |
|
1012 |
||
1013 |
if t^.ar[i]^.Kind = gtHedgehog then |
|
1014 |
AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, t^.ar[i]); |
|
867 | 1015 |
|
981 | 1016 |
DeleteCI(t^.ar[i]); |
1017 |
t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01; |
|
1018 |
t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01; |
|
1019 |
t^.ar[i]^.Active:= true; |
|
1020 |
t^.ar[i]^.State:= t^.ar[i]^.State or gstMoving; |
|
867 | 1021 |
|
982 | 1022 |
if TestCollisionXwithGear(t^.ar[i], hwSign(t^.ar[i]^.dX)) then |
981 | 1023 |
begin |
1024 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -3, hwSign(t^.ar[i]^.dX)) |
|
1025 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1026 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX)) |
|
1027 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1028 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX)) |
|
1029 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1030 |
end; |
|
982 | 1031 |
|
981 | 1032 |
FollowGear:= t^.ar[i] |
1033 |
end; |
|
1034 |
end |
|
1035 |
end; |
|
126 | 1036 |
SetAllToActive |
38 | 1037 |
end; |
1038 |
||
4 | 1039 |
procedure AssignHHCoords; |
955 | 1040 |
var i, t, p, j: LongInt; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1041 |
ar: array[0..Pred(cMaxHHs)] of PGear; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1042 |
Count: Longword; |
4 | 1043 |
begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1044 |
if (GameFlags and gfForts) <> 0 then |
955 | 1045 |
begin |
1046 |
t:= 0; |
|
1047 |
for p:= 0 to 1 do |
|
1048 |
begin |
|
1049 |
with ClansArray[p]^ do |
|
1050 |
for j:= 0 to Pred(TeamsNumber) do |
|
1051 |
with Teams[j]^ do |
|
1052 |
for i:= 0 to cMaxHHIndex do |
|
1053 |
with Hedgehogs[i] do |
|
958 | 1054 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
1055 |
begin |
|
1056 |
FindPlace(Gear, false, t, t + 1024); |
|
959 | 1057 |
Gear^.Pos:= GetRandom(19) |
958 | 1058 |
end; |
955 | 1059 |
inc(t, 1024) |
1060 |
end |
|
1061 |
end else // mix hedgehogs |
|
1062 |
begin |
|
1063 |
Count:= 0; |
|
1064 |
for p:= 0 to Pred(TeamsCount) do |
|
1065 |
with TeamsArray[p]^ do |
|
1066 |
begin |
|
1067 |
for i:= 0 to cMaxHHIndex do |
|
1068 |
with Hedgehogs[i] do |
|
1069 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
|
1070 |
begin |
|
1071 |
ar[Count]:= Gear; |
|
1072 |
inc(Count) |
|
1073 |
end; |
|
1074 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1075 |
|
955 | 1076 |
while (Count > 0) do |
1077 |
begin |
|
1078 |
i:= GetRandom(Count); |
|
1079 |
FindPlace(ar[i], false, 0, 2048); |
|
959 | 1080 |
ar[i]^.Pos:= GetRandom(19); |
955 | 1081 |
ar[i]:= ar[Count - 1]; |
1082 |
dec(Count) |
|
1083 |
end |
|
1084 |
end |
|
4 | 1085 |
end; |
1086 |
||
371 | 1087 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
10 | 1088 |
var t: PGear; |
1089 |
begin |
|
1090 |
t:= GearsList; |
|
1091 |
rX:= sqr(rX); |
|
1092 |
rY:= sqr(rY); |
|
1093 |
while t <> nil do |
|
1094 |
begin |
|
351 | 1095 |
if (t <> Gear) and (t^.Kind = Kind) then |
498 | 1096 |
if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then |
351 | 1097 |
exit(t); |
1098 |
t:= t^.NextGear |
|
10 | 1099 |
end; |
351 | 1100 |
CheckGearNear:= nil |
15 | 1101 |
end; |
1102 |
||
79 | 1103 |
procedure AmmoFlameWork(Ammo: PGear); |
1104 |
var t: PGear; |
|
1105 |
begin |
|
1106 |
t:= GearsList; |
|
1107 |
while t <> nil do |
|
1108 |
begin |
|
351 | 1109 |
if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then |
498 | 1110 |
if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then |
79 | 1111 |
begin |
351 | 1112 |
inc(t^.Damage, 5); |
1113 |
t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; |
|
1114 |
t^.dY:= - _0_25; |
|
1115 |
t^.Active:= true; |
|
79 | 1116 |
DeleteCI(t); |
1117 |
FollowGear:= t |
|
1118 |
end; |
|
351 | 1119 |
t:= t^.NextGear |
79 | 1120 |
end; |
1121 |
end; |
|
1122 |
||
371 | 1123 |
function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; |
16 | 1124 |
var t: PGear; |
1125 |
begin |
|
1126 |
t:= GearsList; |
|
1127 |
rX:= sqr(rX); |
|
1128 |
rY:= sqr(rY); |
|
1129 |
while t <> nil do |
|
1130 |
begin |
|
351 | 1131 |
if t^.Kind in Kind then |
498 | 1132 |
if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then |
351 | 1133 |
exit(t); |
1134 |
t:= t^.NextGear |
|
16 | 1135 |
end; |
351 | 1136 |
CheckGearsNear:= nil |
16 | 1137 |
end; |
1138 |
||
1139 |
function CountGears(Kind: TGearType): Longword; |
|
1140 |
var t: PGear; |
|
351 | 1141 |
Result: Longword; |
16 | 1142 |
begin |
1143 |
Result:= 0; |
|
1144 |
t:= GearsList; |
|
1145 |
while t <> nil do |
|
1146 |
begin |
|
351 | 1147 |
if t^.Kind = Kind then inc(Result); |
1148 |
t:= t^.NextGear |
|
16 | 1149 |
end; |
351 | 1150 |
CountGears:= Result |
16 | 1151 |
end; |
1152 |
||
15 | 1153 |
procedure SpawnBoxOfSmth; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1154 |
var t: LongInt; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1155 |
i: TAmmoType; |
15 | 1156 |
begin |
614 | 1157 |
if (cCaseFactor = 0) or |
1158 |
(CountGears(gtCase) >= 5) or |
|
1159 |
(getrandom(cCaseFactor) <> 0) then exit; |
|
498 | 1160 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
295 | 1161 |
case getrandom(2) of |
1162 |
0: begin |
|
351 | 1163 |
FollowGear^.Health:= 25; |
1164 |
FollowGear^.Pos:= posCaseHealth |
|
295 | 1165 |
end; |
1166 |
1: begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1167 |
t:= 0; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1168 |
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
|
1169 |
inc(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1170 |
t:= GetRandom(t); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1171 |
i:= Low(TAmmoType); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1172 |
dec(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1173 |
while t >= 0 do |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1174 |
begin |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1175 |
inc(i); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1176 |
dec(t, Ammoz[i].Probability) |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1177 |
end; |
865 | 1178 |
PlaySound(sndReinforce, false); |
351 | 1179 |
FollowGear^.Pos:= posCaseAmmo; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1180 |
FollowGear^.State:= Longword(i) |
295 | 1181 |
end; |
1182 |
end; |
|
70 | 1183 |
FindPlace(FollowGear, true, 0, 2048) |
1184 |
end; |
|
1185 |
||
371 | 1186 |
procedure FindPlace(Gear: PGear; withFall: boolean; Left, Right: LongInt); |
70 | 1187 |
|
371 | 1188 |
function CountNonZeroz(x, y, r: LongInt): LongInt; |
1189 |
var i: LongInt; |
|
1190 |
Result: LongInt; |
|
70 | 1191 |
begin |
1192 |
Result:= 0; |
|
701 | 1193 |
if (y and $FFFFFC00) = 0 then |
1194 |
for i:= max(x - r, 0) to min(x + r, 2043) do |
|
351 | 1195 |
if Land[y, i] <> 0 then inc(Result); |
1196 |
CountNonZeroz:= Result |
|
70 | 1197 |
end; |
1198 |
||
495 | 1199 |
var x: LongInt; |
371 | 1200 |
y, sy: LongInt; |
386 | 1201 |
ar: array[0..511] of TPoint; |
1202 |
ar2: array[0..1023] of TPoint; |
|
392 | 1203 |
cnt, cnt2: Longword; |
1204 |
delta: LongInt; |
|
70 | 1205 |
begin |
386 | 1206 |
delta:= 250; |
1207 |
cnt2:= 0; |
|
16 | 1208 |
repeat |
392 | 1209 |
x:= Left + LongInt(GetRandom(Delta)); |
70 | 1210 |
repeat |
386 | 1211 |
inc(x, Delta); |
70 | 1212 |
cnt:= 0; |
351 | 1213 |
y:= -Gear^.Radius * 2; |
70 | 1214 |
while y < 1023 do |
16 | 1215 |
begin |
70 | 1216 |
repeat |
701 | 1217 |
inc(y, 2); |
351 | 1218 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0); |
70 | 1219 |
sy:= y; |
1220 |
repeat |
|
1221 |
inc(y); |
|
351 | 1222 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0); |
1223 |
if (y - sy > Gear^.Radius * 2) |
|
70 | 1224 |
and (y < 1023) |
351 | 1225 |
and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then |
70 | 1226 |
begin |
1227 |
ar[cnt].X:= x; |
|
351 | 1228 |
if withFall then ar[cnt].Y:= sy + Gear^.Radius |
1229 |
else ar[cnt].Y:= y - Gear^.Radius; |
|
70 | 1230 |
inc(cnt) |
1231 |
end; |
|
386 | 1232 |
inc(y, 45) |
16 | 1233 |
end; |
70 | 1234 |
if cnt > 0 then |
1235 |
with ar[GetRandom(cnt)] do |
|
1236 |
begin |
|
386 | 1237 |
ar2[cnt2].x:= x; |
1238 |
ar2[cnt2].y:= y; |
|
1239 |
inc(cnt2) |
|
70 | 1240 |
end |
386 | 1241 |
until (x + Delta > Right); |
1242 |
dec(Delta, 60) |
|
1243 |
until (cnt2 > 0) or (Delta < 70); |
|
1244 |
if cnt2 > 0 then |
|
1245 |
with ar2[GetRandom(cnt2)] do |
|
1246 |
begin |
|
498 | 1247 |
Gear^.X:= int2hwFloat(x); |
1248 |
Gear^.Y:= int2hwFloat(y); |
|
386 | 1249 |
{$IFDEF DEBUGFILE} |
1250 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
1251 |
{$ENDIF} |
|
1252 |
end |
|
1253 |
else |
|
1254 |
begin |
|
1255 |
OutError('Can''t find place for Gear', false); |
|
1256 |
DeleteGear(Gear) |
|
1257 |
end |
|
10 | 1258 |
end; |
1259 |
||
4 | 1260 |
initialization |
1261 |
||
1262 |
finalization |
|
95 | 1263 |
FreeGearsList; |
4 | 1264 |
|
1265 |
end. |