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