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