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