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