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