author | unc0rr |
Fri, 25 Jul 2008 13:52:35 +0000 | |
changeset 1089 | 24e9e1ca0394 |
parent 1088 | 9702e17146e6 |
child 1103 | 1ff3db3c12af |
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 |
317 |
Result^.Health:= 3072; |
|
318 |
Result^.Radius:= 5; |
|
319 |
if hwSign(dX) > 0 then Result^.Angle:= 1 else Result^.Angle:= 3 |
|
320 |
end; |
|
4 | 321 |
end; |
351 | 322 |
InsertGearToList(Result); |
323 |
AddGear:= Result |
|
4 | 324 |
end; |
325 |
||
326 |
procedure DeleteGear(Gear: PGear); |
|
48 | 327 |
var team: PTeam; |
307 | 328 |
t: Longword; |
4 | 329 |
begin |
503 | 330 |
DeleteCI(Gear); |
762 | 331 |
|
332 |
if Gear^.Tex <> nil then |
|
522 | 333 |
begin |
762 | 334 |
FreeTexture(Gear^.Tex); |
335 |
Gear^.Tex:= nil |
|
522 | 336 |
end; |
762 | 337 |
|
351 | 338 |
if Gear^.Kind = gtHedgehog then |
4 | 339 |
if CurAmmoGear <> nil then |
340 |
begin |
|
351 | 341 |
Gear^.Message:= gm_Destroy; |
342 |
CurAmmoGear^.Message:= gm_Destroy; |
|
4 | 343 |
exit |
47 | 344 |
end else |
345 |
begin |
|
498 | 346 |
if not (hwRound(Gear^.Y) < cWaterLine) then |
307 | 347 |
begin |
351 | 348 |
t:= max(Gear^.Damage, Gear^.Health); |
867 | 349 |
Gear^.Damage:= t; |
498 | 350 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
867 | 351 |
uStats.HedgehogDamaged(Gear) |
307 | 352 |
end; |
351 | 353 |
team:= PHedgehog(Gear^.Hedgehog)^.Team; |
602 | 354 |
if CurrentHedgehog^.Gear = Gear then |
145 | 355 |
FreeActionsList; // to avoid ThinkThread on drawned gear |
351 | 356 |
PHedgehog(Gear^.Hedgehog)^.Gear:= nil; |
307 | 357 |
inc(KilledHHs); |
48 | 358 |
RecountTeamHealth(team); |
47 | 359 |
end; |
357 | 360 |
{$IFDEF DEBUGFILE}AddFileLog('DeleteGear');{$ENDIF} |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
593
diff
changeset
|
361 |
if Gear^.TriggerId <> 0 then TickTrigger(Gear^.TriggerId); |
82 | 362 |
if CurAmmoGear = Gear then CurAmmoGear:= nil; |
4 | 363 |
if FollowGear = Gear then FollowGear:= nil; |
294 | 364 |
RemoveGearFromList(Gear); |
4 | 365 |
Dispose(Gear) |
366 |
end; |
|
367 |
||
368 |
function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs |
|
369 |
var Gear: PGear; |
|
370 |
begin |
|
351 | 371 |
CheckNoDamage:= true; |
4 | 372 |
Gear:= GearsList; |
373 |
while Gear <> nil do |
|
867 | 374 |
begin |
375 |
if Gear^.Kind = gtHedgehog then |
|
376 |
if Gear^.Damage <> 0 then |
|
377 |
begin |
|
378 |
CheckNoDamage:= false; |
|
379 |
uStats.HedgehogDamaged(Gear); |
|
351 | 380 |
|
867 | 381 |
if Gear^.Health < Gear^.Damage then |
382 |
Gear^.Health:= 0 |
|
383 |
else |
|
384 |
dec(Gear^.Health, Gear^.Damage); |
|
385 |
||
386 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12, |
|
387 |
gtHealthTag, Gear^.Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
388 |
RenderHealth(PHedgehog(Gear^.Hedgehog)^); |
|
389 |
RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team); |
|
390 |
||
391 |
Gear^.Damage:= 0 |
|
392 |
end; |
|
393 |
Gear:= Gear^.NextGear |
|
394 |
end; |
|
4 | 395 |
end; |
396 |
||
1054 | 397 |
procedure HealthMachine; |
398 |
var Gear: PGear; |
|
399 |
begin |
|
400 |
Gear:= GearsList; |
|
401 |
||
402 |
while Gear <> nil do |
|
403 |
begin |
|
404 |
if Gear^.Kind = gtHedgehog then |
|
405 |
Gear^.Damage:= min(cHealthDecrease, Gear^.Health - 1); |
|
406 |
||
407 |
Gear:= Gear^.NextGear |
|
408 |
end; |
|
409 |
end; |
|
410 |
||
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
411 |
function WaterMachine: boolean; |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
412 |
const |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
413 |
decStep: Longword = 0; |
1070 | 414 |
LastTurn: LongInt = 0; |
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
415 |
var i: LongWord; |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
416 |
begin |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
417 |
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
|
418 |
begin |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
419 |
LastTurn:= FinishedTurnsTotal; |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
420 |
decStep:= 40 |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
421 |
end; |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
422 |
|
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
423 |
if decStep <> 0 then |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
424 |
begin |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
425 |
dec(decStep); |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
426 |
dec(cWaterLine); |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
427 |
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
|
428 |
Land[cWaterLine, i]:= 0; |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
429 |
SetAllToActive |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
430 |
end; |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
431 |
|
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
432 |
WaterMachine:= decStep <> 0; |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
433 |
end; |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
434 |
|
522 | 435 |
procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear); |
436 |
begin |
|
529 | 437 |
if cAltDamage then |
438 |
AddGear(X, Y, gtSmallDamage, Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
522 | 439 |
end; |
440 |
||
4 | 441 |
procedure ProcessGears; |
614 | 442 |
const delay: LongWord = 0; |
869 | 443 |
step: (stDelay, stChDmg, stTurnReact, |
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
444 |
stAfterDelay, stChWin, stWater, stHealth, |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
445 |
stSpawn, stNTurn) = stDelay; |
1054 | 446 |
|
4 | 447 |
var Gear, t: PGear; |
448 |
begin |
|
868 | 449 |
PrvInactive:= AllInactive; |
4 | 450 |
AllInactive:= true; |
451 |
t:= GearsList; |
|
1054 | 452 |
while t <> nil do |
4 | 453 |
begin |
454 |
Gear:= t; |
|
351 | 455 |
t:= Gear^.NextGear; |
456 |
if Gear^.Active then Gear^.doStep(Gear); |
|
4 | 457 |
end; |
89 | 458 |
|
4 | 459 |
if AllInactive then |
15 | 460 |
case step of |
461 |
stDelay: begin |
|
462 |
if delay = 0 then |
|
463 |
delay:= cInactDelay |
|
614 | 464 |
else |
465 |
dec(delay); |
|
466 |
||
467 |
if delay = 0 then |
|
468 |
inc(step) |
|
15 | 469 |
end; |
470 |
stChDmg: if CheckNoDamage then inc(step) else step:= stDelay; |
|
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
809
diff
changeset
|
471 |
stTurnReact: begin |
1054 | 472 |
if (not bBetweenTurns) and (not isInMultiShoot) then |
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
473 |
begin |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
474 |
uStats.TurnReaction; |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
475 |
inc(step) |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
476 |
end else |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
477 |
inc(step, 2); |
814
7fb4417b7bc1
Start implementing better statistics implementation (does nothing yet)
unc0rr
parents:
809
diff
changeset
|
478 |
end; |
815 | 479 |
stAfterDelay: begin |
480 |
if delay = 0 then |
|
481 |
delay:= cInactDelay |
|
482 |
else |
|
483 |
dec(delay); |
|
484 |
||
485 |
if delay = 0 then |
|
486 |
inc(step) |
|
487 |
end; |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1056
diff
changeset
|
488 |
stChWin: if not CheckForWin then |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1056
diff
changeset
|
489 |
begin |
1064
9e0701c56fb3
Fix another regression arising from splitting switchhedgehog
unc0rr
parents:
1063
diff
changeset
|
490 |
if not (bBetweenTurns or isInMultiShoot) then |
1060 | 491 |
begin |
1061 | 492 |
ParseCommand('/nextturn', true); |
1060 | 493 |
SwitchHedgehog; |
494 |
end; |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1056
diff
changeset
|
495 |
inc(step) |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1056
diff
changeset
|
496 |
end else step:= stDelay; |
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
497 |
stWater: begin |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1056
diff
changeset
|
498 |
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
|
499 |
|
1056 | 500 |
if not bWaterRising then |
501 |
inc(step) |
|
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
502 |
else |
1056 | 503 |
begin |
504 |
if delay = 0 then |
|
505 |
delay:= 17 |
|
506 |
else |
|
507 |
dec(delay); |
|
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
508 |
|
1056 | 509 |
if delay = 0 then |
510 |
if not WaterMachine then inc(step) |
|
511 |
end |
|
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
512 |
end; |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
513 |
stHealth: begin |
1063 | 514 |
if (TotalRounds = 15) and (cHealthDecrease = 0) then |
515 |
begin |
|
516 |
cHealthDecrease:= 5; |
|
517 |
AddCaption(trmsg[sidSuddenDeath], $FFFFFF, capgrpGameState) |
|
518 |
end; |
|
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
519 |
|
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
520 |
if (cHealthDecrease = 0) |
1054 | 521 |
or bBetweenTurns |
522 |
or isInMultiShoot |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1056
diff
changeset
|
523 |
or (TotalRounds = 0) then inc(step) |
1054 | 524 |
else begin |
525 |
bBetweenTurns:= true; |
|
526 |
HealthMachine; |
|
527 |
step:= stChDmg |
|
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
528 |
end |
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset
|
529 |
end; |
15 | 530 |
stSpawn: begin |
531 |
if not isInMultiShoot then SpawnBoxOfSmth; |
|
532 |
inc(step) |
|
533 |
end; |
|
534 |
stNTurn: begin |
|
535 |
if isInMultiShoot then isInMultiShoot:= false |
|
307 | 536 |
else begin |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1056
diff
changeset
|
537 |
AfterSwitchHedgehog; |
1054 | 538 |
bBetweenTurns:= false |
307 | 539 |
end; |
15 | 540 |
step:= Low(step) |
541 |
end; |
|
542 |
end; |
|
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 |
4 | 571 |
begin |
351 | 572 |
t^.Active:= true; |
573 |
t:= t^.NextGear |
|
4 | 574 |
end |
575 |
end; |
|
576 |
||
577 |
procedure SetAllHHToActive; |
|
578 |
var t: PGear; |
|
579 |
begin |
|
580 |
AllInactive:= false; |
|
581 |
t:= GearsList; |
|
351 | 582 |
while t <> nil do |
4 | 583 |
begin |
351 | 584 |
if t^.Kind = gtHedgehog then t^.Active:= true; |
585 |
t:= t^.NextGear |
|
4 | 586 |
end |
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; |
|
824 | 594 |
defaultPos: 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; |
847 | 603 |
|
1002 | 604 |
if (Gear^.State and gstDrowning) <> 0 then |
605 |
begin |
|
606 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
607 |
hwSign(Gear^.dX), |
|
608 |
1, |
|
609 |
7, |
|
610 |
0); |
|
611 |
defaultPos:= false |
|
612 |
end else |
|
613 |
||
1011 | 614 |
if (Gear^.State and gstWinner) <> 0 then |
615 |
begin |
|
616 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
617 |
hwSign(Gear^.dX), |
|
618 |
2, |
|
619 |
0, |
|
620 |
0); |
|
621 |
defaultPos:= false |
|
622 |
end else |
|
623 |
||
821
e6c0408b54ed
Use 'regular standing' and 'rope swing' hedgehog sprites
unc0rr
parents:
815
diff
changeset
|
624 |
if (Gear^.State and gstHHDriven) <> 0 then |
966 | 625 |
begin |
1002 | 626 |
hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx; |
627 |
hy:= hwRound(Gear^.Y) - 2 + WorldDy; |
|
628 |
aangle:= Gear^.Angle * 180 / cMaxAngle - 90; |
|
874 | 629 |
|
1002 | 630 |
if CurAmmoGear <> nil then |
631 |
begin |
|
632 |
case CurAmmoGear^.Kind of |
|
633 |
gtShotgunShot: if (CurAmmoGear^.State and gstAnimation <> 0) then |
|
634 |
DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle) |
|
635 |
else |
|
636 |
DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); |
|
637 |
gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle); |
|
638 |
gtRope: begin |
|
639 |
if Gear^.X < CurAmmoGear^.X then |
|
640 |
begin |
|
641 |
dAngle:= 0; |
|
642 |
m:= 1 |
|
643 |
end else |
|
644 |
begin |
|
645 |
dAngle:= 180; |
|
646 |
m:= -1 |
|
966 | 647 |
end; |
1002 | 648 |
DrawHedgehog(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
649 |
m, |
|
650 |
1, |
|
651 |
0, |
|
652 |
DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle); |
|
653 |
defaultPos:= false |
|
654 |
end; |
|
655 |
gtBlowTorch: begin |
|
656 |
DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); |
|
657 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
658 |
hwSign(Gear^.dX), |
|
659 |
1, |
|
660 |
3, |
|
661 |
0); |
|
662 |
defaultPos:= false |
|
663 |
end; |
|
664 |
gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180); |
|
665 |
gtFirePunch: begin |
|
666 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
667 |
hwSign(Gear^.dX), |
|
668 |
1, |
|
669 |
4, |
|
670 |
0); |
|
671 |
defaultPos:= false |
|
672 |
end; |
|
673 |
gtPickHammer, |
|
674 |
gtTeleport: defaultPos:= false; |
|
1010 | 675 |
gtWhip: begin |
676 |
DrawRotatedF(sprWhip, |
|
677 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
678 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
679 |
1, |
|
680 |
hwSign(Gear^.dX), |
|
681 |
0); |
|
682 |
defaultPos:= false |
|
683 |
end; |
|
1002 | 684 |
gtKamikaze: begin |
685 |
if CurAmmoGear^.Pos = 0 then |
|
686 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
687 |
hwSign(Gear^.dX), |
|
688 |
1, |
|
689 |
6, |
|
690 |
0) |
|
691 |
else |
|
692 |
DrawRotatedF(sprKamikaze, |
|
693 |
hwRound(Gear^.X) + WorldDx, |
|
694 |
hwRound(Gear^.Y) + WorldDy, |
|
695 |
CurAmmoGear^.Pos - 1, |
|
696 |
1, |
|
697 |
DxDy2Angle(Gear^.dY, Gear^.dX)); |
|
698 |
||
699 |
defaultPos:= false |
|
700 |
end; |
|
701 |
end; |
|
702 |
||
703 |
case CurAmmoGear^.Kind of |
|
704 |
gtShotgunShot, |
|
705 |
gtDEagleShot, |
|
706 |
gtShover: begin |
|
707 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
708 |
hwSign(Gear^.dX), |
|
709 |
0, |
|
710 |
4, |
|
711 |
0); |
|
712 |
defaultPos:= false |
|
713 |
end |
|
714 |
end |
|
715 |
end else |
|
876 | 716 |
|
1002 | 717 |
if ((Gear^.State and gstHHJumping) <> 0) then |
718 |
begin |
|
719 |
if ((Gear^.State and gstHHHJump) <> 0) then |
|
720 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
721 |
- hwSign(Gear^.dX), |
|
722 |
1, |
|
723 |
1, |
|
724 |
0) |
|
725 |
else |
|
726 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
727 |
hwSign(Gear^.dX), |
|
728 |
1, |
|
729 |
1, |
|
730 |
0); |
|
731 |
defaultPos:= false |
|
732 |
end else |
|
874 | 733 |
|
1002 | 734 |
if (Gear^.Message and (gm_Left or gm_Right) <> 0) then |
824 | 735 |
begin |
1002 | 736 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
737 |
hwSign(Gear^.dX), |
|
738 |
0, |
|
739 |
PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, |
|
740 |
0); |
|
824 | 741 |
defaultPos:= false |
1002 | 742 |
end |
743 |
else |
|
744 |
||
1033 | 745 |
if ((Gear^.State and gstAnimation) <> 0) then |
746 |
begin |
|
1034 | 747 |
DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite, |
1033 | 748 |
hwRound(Gear^.X) + 1 + WorldDx, |
749 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
750 |
Gear^.Pos, |
|
751 |
hwSign(Gear^.dX), |
|
752 |
0.0); |
|
753 |
defaultPos:= false |
|
754 |
end |
|
755 |
else |
|
1002 | 756 |
if ((Gear^.State and gstAttacked) = 0) then |
757 |
begin |
|
758 |
amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType; |
|
759 |
case amt of |
|
760 |
amBazooka, |
|
761 |
amMortar: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle); |
|
762 |
amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle); |
|
763 |
amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); |
|
764 |
amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle); |
|
765 |
amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); |
|
766 |
end; |
|
767 |
||
768 |
case amt of |
|
769 |
amAirAttack, |
|
770 |
amMineStrike: DrawRotated(sprHandAirAttack, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0); |
|
771 |
amPickHammer: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
772 |
hwSign(Gear^.dX), |
|
773 |
1, |
|
774 |
2, |
|
775 |
0); |
|
776 |
amBlowTorch: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
777 |
hwSign(Gear^.dX), |
|
778 |
1, |
|
779 |
3, |
|
780 |
0); |
|
781 |
amTeleport: DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, 0, hwSign(Gear^.dX), 0); |
|
782 |
amKamikaze: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
|
783 |
hwSign(Gear^.dX), |
|
784 |
1, |
|
785 |
5, |
|
786 |
0); |
|
1010 | 787 |
amWhip: begin |
788 |
DrawRotatedF(sprWhip, |
|
789 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
790 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
791 |
0, |
|
792 |
hwSign(Gear^.dX), |
|
793 |
0); |
|
794 |
defaultPos:= false |
|
795 |
end; |
|
1002 | 796 |
else |
822 | 797 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
798 |
hwSign(Gear^.dX), |
|
799 |
0, |
|
1002 | 800 |
4, |
822 | 801 |
0); |
1002 | 802 |
end; |
966 | 803 |
|
1002 | 804 |
case amt of |
805 |
amBaseballBat: DrawRotated(sprHandBaseball, |
|
806 |
hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx, |
|
807 |
hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle); |
|
808 |
end; |
|
966 | 809 |
|
1002 | 810 |
defaultPos:= false |
811 |
end |
|
812 |
end else // not gstHHDriven |
|
1012 | 813 |
begin |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
814 |
if (Gear^.Damage > 0) |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
815 |
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
|
816 |
begin |
1012 | 817 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
818 |
hwSign(Gear^.dX), |
|
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
819 |
2, |
1012 | 820 |
1, |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
821 |
Gear^.DirAngle); |
1012 | 822 |
defaultPos:= false |
1020 | 823 |
end else |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
824 |
|
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
825 |
if ((Gear^.State and gstHHJumping) <> 0) then |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
826 |
begin |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
827 |
if ((Gear^.State and gstHHHJump) <> 0) then |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
828 |
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
|
829 |
- hwSign(Gear^.dX), |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
830 |
1, |
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 |
0) |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
833 |
else |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
834 |
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
|
835 |
hwSign(Gear^.dX), |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
836 |
1, |
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 |
0); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
839 |
defaultPos:= false |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
840 |
end; |
1012 | 841 |
end; |
834 | 842 |
|
824 | 843 |
|
845 | 844 |
if defaultPos then |
970 | 845 |
begin |
954 | 846 |
DrawRotatedF(sprHHIdle, |
847 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
848 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
957 | 849 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
822 | 850 |
hwSign(Gear^.dX), |
851 |
0); |
|
970 | 852 |
DrawRotatedF(sprHat, |
853 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
854 |
hwRound(Gear^.Y) - 8 + WorldDy, |
|
855 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
|
856 |
hwSign(Gear^.dX), |
|
857 |
0); |
|
858 |
end; |
|
292 | 859 |
|
351 | 860 |
with PHedgehog(Gear^.Hedgehog)^ do |
994 | 861 |
begin |
1011 | 862 |
if ((Gear^.State and not gstWinner) = 0) |
994 | 863 |
or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then |
958 | 864 |
begin |
976 | 865 |
t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy; |
958 | 866 |
if (cTagsMask and 1) <> 0 then |
867 |
begin |
|
868 |
dec(t, HealthTagTex^.h + 2); |
|
869 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex) |
|
870 |
end; |
|
871 |
if (cTagsMask and 2) <> 0 then |
|
872 |
begin |
|
873 |
dec(t, NameTagTex^.h + 2); |
|
874 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTagTex) |
|
875 |
end; |
|
876 |
if (cTagsMask and 4) <> 0 then |
|
877 |
begin |
|
878 |
dec(t, Team^.NameTagTex^.h + 2); |
|
879 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex) |
|
880 |
end |
|
994 | 881 |
end; |
882 |
if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog |
|
958 | 883 |
begin |
884 |
if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then |
|
885 |
DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy, |
|
886 |
GameTicks div 32 mod 16); |
|
821
e6c0408b54ed
Use 'regular standing' and 'rope swing' hedgehog sprites
unc0rr
parents:
815
diff
changeset
|
887 |
|
958 | 888 |
if (Gear^.State and gstDrowning) = 0 then |
889 |
if (Gear^.State and gstHHThinking) <> 0 then |
|
890 |
DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, 0) |
|
891 |
else |
|
1033 | 892 |
if ShowCrosshair and ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then |
958 | 893 |
begin |
894 |
if ((Gear^.State and gstHHHJump) <> 0) then m:= -1 else m:= 1; |
|
895 |
DrawRotatedTex(Team^.CrosshairTex, |
|
896 |
12, 12, |
|
897 |
Round(hwRound(Gear^.X) + hwSign(Gear^.dX) * m * Sin(Gear^.Angle*pi/cMaxAngle) * 60) + WorldDx, |
|
898 |
Round(hwRound(Gear^.Y) - Cos(Gear^.Angle*pi/cMaxAngle) * 60) + WorldDy, 0, |
|
899 |
hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle) |
|
900 |
end |
|
994 | 901 |
end |
902 |
end |
|
292 | 903 |
end; |
904 |
||
956 | 905 |
procedure DrawGears; |
853 | 906 |
var Gear, HHGear: PGear; |
4 | 907 |
i: Longword; |
371 | 908 |
roplen: LongInt; |
4 | 909 |
|
371 | 910 |
procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt); |
911 |
var eX, eY, dX, dY: LongInt; |
|
912 |
i, sX, sY, x, y, d: LongInt; |
|
366 | 913 |
b: boolean; |
4 | 914 |
begin |
37 | 915 |
if (X1 = X2) and (Y1 = Y2) then |
916 |
begin |
|
351 | 917 |
OutError('WARNING: zero length rope line!', false); |
37 | 918 |
exit |
919 |
end; |
|
366 | 920 |
eX:= 0; |
921 |
eY:= 0; |
|
922 |
dX:= X2 - X1; |
|
923 |
dY:= Y2 - Y1; |
|
924 |
||
925 |
if (dX > 0) then sX:= 1 |
|
926 |
else |
|
927 |
if (dX < 0) then |
|
928 |
begin |
|
929 |
sX:= -1; |
|
930 |
dX:= -dX |
|
931 |
end else sX:= dX; |
|
932 |
||
933 |
if (dY > 0) then sY:= 1 |
|
934 |
else |
|
935 |
if (dY < 0) then |
|
4 | 936 |
begin |
366 | 937 |
sY:= -1; |
938 |
dY:= -dY |
|
939 |
end else sY:= dY; |
|
940 |
||
941 |
if (dX > dY) then d:= dX |
|
942 |
else d:= dY; |
|
943 |
||
944 |
x:= X1; |
|
945 |
y:= Y1; |
|
946 |
||
947 |
for i:= 0 to d do |
|
948 |
begin |
|
949 |
inc(eX, dX); |
|
950 |
inc(eY, dY); |
|
951 |
b:= false; |
|
952 |
if (eX > d) then |
|
35 | 953 |
begin |
366 | 954 |
dec(eX, d); |
955 |
inc(x, sX); |
|
956 |
b:= true |
|
35 | 957 |
end; |
366 | 958 |
if (eY > d) then |
35 | 959 |
begin |
366 | 960 |
dec(eY, d); |
961 |
inc(y, sY); |
|
962 |
b:= true |
|
35 | 963 |
end; |
366 | 964 |
if b then |
965 |
begin |
|
966 |
inc(roplen); |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
967 |
if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0) |
366 | 968 |
end |
4 | 969 |
end |
366 | 970 |
end; |
4 | 971 |
|
972 |
begin |
|
973 |
Gear:= GearsList; |
|
974 |
while Gear<>nil do |
|
975 |
begin |
|
351 | 976 |
case Gear^.Kind of |
822 | 977 |
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
|
978 |
gtHedgehog: DrawHH(Gear); |
822 | 979 |
gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
522 | 980 |
gtHealthTag, |
762 | 981 |
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
|
982 |
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
|
983 |
gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4); |
848 | 984 |
gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0); |
4 | 985 |
gtRope: begin |
35 | 986 |
roplen:= 0; |
4 | 987 |
if RopePoints.Count > 0 then |
988 |
begin |
|
989 |
i:= 0; |
|
990 |
while i < Pred(RopePoints.Count) do |
|
991 |
begin |
|
351 | 992 |
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
993 |
hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy); |
|
4 | 994 |
inc(i) |
995 |
end; |
|
351 | 996 |
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
997 |
hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy); |
|
998 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
|
999 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 1000 |
DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) |
4 | 1001 |
end else |
35 | 1002 |
begin |
351 | 1003 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
1004 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 1005 |
DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
35 | 1006 |
end; |
4 | 1007 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1008 |
gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
1012 | 1009 |
gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State); |
351 | 1010 |
gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420) |
822 | 1011 |
then DrawRotated(sprMineOff, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle) |
1012 |
else DrawRotated(sprMineOn, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
|
351 | 1013 |
gtCase: case Gear^.Pos of |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1014 |
posCaseAmmo : DrawSprite(sprCase, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
1009 | 1015 |
posCaseHealth: begin |
1016 |
i:= (GameTicks shr 6) mod 64; |
|
1017 |
if i > 12 then i:= 0; |
|
1018 |
DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i); |
|
1019 |
end; |
|
42 | 1020 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1021 |
gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1); |
822 | 1022 |
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
|
1023 |
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
|
1024 |
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
|
1025 |
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
|
1026 |
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
|
1027 |
else DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 1); |
822 | 1028 |
gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
853 | 1029 |
gtTeleport: begin |
1030 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1031 |
DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
1032 |
DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
1033 |
end; |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1034 |
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
|
1035 |
gtTarget: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
959 | 1036 |
gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1089 | 1037 |
gtCake: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
4 | 1038 |
end; |
351 | 1039 |
Gear:= Gear^.NextGear |
4 | 1040 |
end; |
1041 |
end; |
|
1042 |
||
1043 |
procedure FreeGearsList; |
|
1044 |
var t, tt: PGear; |
|
1045 |
begin |
|
1046 |
tt:= GearsList; |
|
1047 |
GearsList:= nil; |
|
1048 |
while tt<>nil do |
|
1049 |
begin |
|
1050 |
t:= tt; |
|
351 | 1051 |
tt:= tt^.NextGear; |
4 | 1052 |
Dispose(t) |
1053 |
end; |
|
1054 |
end; |
|
1055 |
||
10 | 1056 |
procedure AddMiscGears; |
371 | 1057 |
var i: LongInt; |
4 | 1058 |
begin |
498 | 1059 |
AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000); |
22 | 1060 |
if (GameFlags and gfForts) = 0 then |
622 | 1061 |
for i:= 0 to Pred(cLandAdditions) do |
498 | 1062 |
FindPlace(AddGear(0, 0, gtMine, 0, _0, _0, 0), false, 0, 2048); |
4 | 1063 |
end; |
1064 |
||
371 | 1065 |
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); |
4 | 1066 |
var Gear: PGear; |
506 | 1067 |
dmg, dmgRadius: LongInt; |
4 | 1068 |
begin |
1069 |
TargetPoint.X:= NoPointX; |
|
1070 |
{$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF} |
|
1049 | 1071 |
if (Radius > 10) then AddGear(X, Y, gtExplosion, 0, _0, _0, 0); |
355 | 1072 |
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false); |
506 | 1073 |
if (Mask and EXPLAllDamageInRadius)=0 then dmgRadius:= Radius shl 1 |
1074 |
else dmgRadius:= Radius; |
|
4 | 1075 |
Gear:= GearsList; |
1076 |
while Gear <> nil do |
|
1077 |
begin |
|
506 | 1078 |
dmg:= dmgRadius - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
538 | 1079 |
if (dmg > 1) and |
522 | 1080 |
((Gear^.State and gstNoDamage) = 0) then |
4 | 1081 |
begin |
355 | 1082 |
dmg:= dmg div 2; |
351 | 1083 |
case Gear^.Kind of |
10 | 1084 |
gtHedgehog, |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset
|
1085 |
gtMine, |
79 | 1086 |
gtCase, |
593 | 1087 |
gtTarget, |
79 | 1088 |
gtFlame: begin |
355 | 1089 |
{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} |
522 | 1090 |
if (Mask and EXPLNoDamage) = 0 then |
1091 |
begin |
|
1092 |
inc(Gear^.Damage, dmg); |
|
1093 |
if Gear^.Kind = gtHedgehog then |
|
1094 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, Gear) |
|
1095 |
end; |
|
351 | 1096 |
if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then |
42 | 1097 |
begin |
506 | 1098 |
DeleteCI(Gear); |
498 | 1099 |
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X)); |
1100 |
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y)); |
|
503 | 1101 |
Gear^.State:= Gear^.State or gstMoving; |
351 | 1102 |
Gear^.Active:= true; |
42 | 1103 |
FollowGear:= Gear |
1104 |
end; |
|
4 | 1105 |
end; |
51 | 1106 |
gtGrave: begin |
351 | 1107 |
Gear^.dY:= - _0_004 * dmg; |
1108 |
Gear^.Active:= true; |
|
51 | 1109 |
end; |
4 | 1110 |
end; |
1111 |
end; |
|
351 | 1112 |
Gear:= Gear^.NextGear |
80 | 1113 |
end; |
621 | 1114 |
if (Mask and EXPLDontDraw) = 0 then |
1115 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(X, Y, Radius); |
|
498 | 1116 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
4 | 1117 |
end; |
1118 |
||
506 | 1119 |
procedure ShotgunShot(Gear: PGear); |
1120 |
var t: PGear; |
|
955 | 1121 |
dmg: LongInt; |
506 | 1122 |
begin |
509 | 1123 |
Gear^.Radius:= cShotgunRadius; |
506 | 1124 |
t:= GearsList; |
1125 |
while t <> nil do |
|
1126 |
begin |
|
1127 |
dmg:= min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25); |
|
538 | 1128 |
if dmg > 0 then |
506 | 1129 |
case t^.Kind of |
1130 |
gtHedgehog, |
|
1131 |
gtMine, |
|
593 | 1132 |
gtCase, |
1133 |
gtTarget: begin |
|
506 | 1134 |
inc(t^.Damage, dmg); |
867 | 1135 |
|
522 | 1136 |
if t^.Kind = gtHedgehog then |
531 | 1137 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, t); |
867 | 1138 |
|
506 | 1139 |
DeleteCI(t); |
856 | 1140 |
t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); |
506 | 1141 |
t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; |
1142 |
t^.State:= t^.State or gstMoving; |
|
1143 |
t^.Active:= true; |
|
1144 |
FollowGear:= t |
|
1145 |
end; |
|
1146 |
gtGrave: begin |
|
1147 |
t^.dY:= - _0_1; |
|
1148 |
t^.Active:= true |
|
1149 |
end; |
|
1150 |
end; |
|
1151 |
t:= t^.NextGear |
|
1152 |
end; |
|
621 | 1153 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) |
506 | 1154 |
end; |
1155 |
||
371 | 1156 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
53 | 1157 |
var t: PGearArray; |
371 | 1158 |
i: LongInt; |
38 | 1159 |
begin |
53 | 1160 |
t:= CheckGearsCollision(Ammo); |
351 | 1161 |
i:= t^.Count; |
53 | 1162 |
while i > 0 do |
981 | 1163 |
begin |
1164 |
dec(i); |
|
1165 |
if (t^.ar[i]^.State and gstNoDamage) = 0 then |
|
1166 |
case t^.ar[i]^.Kind of |
|
1167 |
gtHedgehog, |
|
1168 |
gtMine, |
|
1169 |
gtTarget, |
|
1170 |
gtCase: begin |
|
1171 |
inc(t^.ar[i]^.Damage, Damage); |
|
1172 |
||
1173 |
if t^.ar[i]^.Kind = gtHedgehog then |
|
1174 |
AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, t^.ar[i]); |
|
867 | 1175 |
|
981 | 1176 |
DeleteCI(t^.ar[i]); |
1177 |
t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01; |
|
1178 |
t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01; |
|
1179 |
t^.ar[i]^.Active:= true; |
|
1180 |
t^.ar[i]^.State:= t^.ar[i]^.State or gstMoving; |
|
867 | 1181 |
|
982 | 1182 |
if TestCollisionXwithGear(t^.ar[i], hwSign(t^.ar[i]^.dX)) then |
981 | 1183 |
begin |
1184 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -3, hwSign(t^.ar[i]^.dX)) |
|
1185 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1186 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX)) |
|
1187 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1188 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX)) |
|
1189 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1190 |
end; |
|
982 | 1191 |
|
981 | 1192 |
FollowGear:= t^.ar[i] |
1193 |
end; |
|
1194 |
end |
|
1195 |
end; |
|
126 | 1196 |
SetAllToActive |
38 | 1197 |
end; |
1198 |
||
4 | 1199 |
procedure AssignHHCoords; |
955 | 1200 |
var i, t, p, j: LongInt; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1201 |
ar: array[0..Pred(cMaxHHs)] of PGear; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1202 |
Count: Longword; |
4 | 1203 |
begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1204 |
if (GameFlags and gfForts) <> 0 then |
955 | 1205 |
begin |
1206 |
t:= 0; |
|
1207 |
for p:= 0 to 1 do |
|
1208 |
begin |
|
1209 |
with ClansArray[p]^ do |
|
1210 |
for j:= 0 to Pred(TeamsNumber) do |
|
1211 |
with Teams[j]^ do |
|
1212 |
for i:= 0 to cMaxHHIndex do |
|
1213 |
with Hedgehogs[i] do |
|
958 | 1214 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
1215 |
begin |
|
1216 |
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
|
1217 |
Gear^.Pos:= GetRandom(19); |
8dcf263c9e8f
In forts mode, hedgehogs on the left look at the right, and vice-versa
unc0rr
parents:
997
diff
changeset
|
1218 |
Gear^.dX.isNegative:= p = 1; |
958 | 1219 |
end; |
955 | 1220 |
inc(t, 1024) |
1221 |
end |
|
1222 |
end else // mix hedgehogs |
|
1223 |
begin |
|
1224 |
Count:= 0; |
|
1225 |
for p:= 0 to Pred(TeamsCount) do |
|
1226 |
with TeamsArray[p]^ do |
|
1227 |
begin |
|
1228 |
for i:= 0 to cMaxHHIndex do |
|
1229 |
with Hedgehogs[i] do |
|
1230 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
|
1231 |
begin |
|
1232 |
ar[Count]:= Gear; |
|
1233 |
inc(Count) |
|
1234 |
end; |
|
1235 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1236 |
|
955 | 1237 |
while (Count > 0) do |
1238 |
begin |
|
1239 |
i:= GetRandom(Count); |
|
1240 |
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
|
1241 |
ar[i]^.dX.isNegative:= ar[i]^.X > _1024; |
959 | 1242 |
ar[i]^.Pos:= GetRandom(19); |
955 | 1243 |
ar[i]:= ar[Count - 1]; |
1244 |
dec(Count) |
|
1245 |
end |
|
1246 |
end |
|
4 | 1247 |
end; |
1248 |
||
371 | 1249 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
10 | 1250 |
var t: PGear; |
1251 |
begin |
|
1252 |
t:= GearsList; |
|
1253 |
rX:= sqr(rX); |
|
1254 |
rY:= sqr(rY); |
|
1255 |
while t <> nil do |
|
1256 |
begin |
|
351 | 1257 |
if (t <> Gear) and (t^.Kind = Kind) then |
498 | 1258 |
if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then |
351 | 1259 |
exit(t); |
1260 |
t:= t^.NextGear |
|
10 | 1261 |
end; |
351 | 1262 |
CheckGearNear:= nil |
15 | 1263 |
end; |
1264 |
||
79 | 1265 |
procedure AmmoFlameWork(Ammo: PGear); |
1266 |
var t: PGear; |
|
1267 |
begin |
|
1268 |
t:= GearsList; |
|
1269 |
while t <> nil do |
|
1270 |
begin |
|
351 | 1271 |
if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then |
498 | 1272 |
if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then |
79 | 1273 |
begin |
351 | 1274 |
inc(t^.Damage, 5); |
1275 |
t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; |
|
1276 |
t^.dY:= - _0_25; |
|
1277 |
t^.Active:= true; |
|
79 | 1278 |
DeleteCI(t); |
1279 |
FollowGear:= t |
|
1280 |
end; |
|
351 | 1281 |
t:= t^.NextGear |
79 | 1282 |
end; |
1283 |
end; |
|
1284 |
||
371 | 1285 |
function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; |
16 | 1286 |
var t: PGear; |
1287 |
begin |
|
1288 |
t:= GearsList; |
|
1289 |
rX:= sqr(rX); |
|
1290 |
rY:= sqr(rY); |
|
1291 |
while t <> nil do |
|
1292 |
begin |
|
351 | 1293 |
if t^.Kind in Kind then |
498 | 1294 |
if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then |
351 | 1295 |
exit(t); |
1296 |
t:= t^.NextGear |
|
16 | 1297 |
end; |
351 | 1298 |
CheckGearsNear:= nil |
16 | 1299 |
end; |
1300 |
||
1301 |
function CountGears(Kind: TGearType): Longword; |
|
1302 |
var t: PGear; |
|
351 | 1303 |
Result: Longword; |
16 | 1304 |
begin |
1305 |
Result:= 0; |
|
1306 |
t:= GearsList; |
|
1307 |
while t <> nil do |
|
1308 |
begin |
|
351 | 1309 |
if t^.Kind = Kind then inc(Result); |
1310 |
t:= t^.NextGear |
|
16 | 1311 |
end; |
351 | 1312 |
CountGears:= Result |
16 | 1313 |
end; |
1314 |
||
15 | 1315 |
procedure SpawnBoxOfSmth; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1316 |
var t: LongInt; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1317 |
i: TAmmoType; |
15 | 1318 |
begin |
614 | 1319 |
if (cCaseFactor = 0) or |
1320 |
(CountGears(gtCase) >= 5) or |
|
1321 |
(getrandom(cCaseFactor) <> 0) then exit; |
|
498 | 1322 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
295 | 1323 |
case getrandom(2) of |
1324 |
0: begin |
|
351 | 1325 |
FollowGear^.Health:= 25; |
1326 |
FollowGear^.Pos:= posCaseHealth |
|
295 | 1327 |
end; |
1328 |
1: begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1329 |
t:= 0; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1330 |
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
|
1331 |
inc(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1332 |
t:= GetRandom(t); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1333 |
i:= Low(TAmmoType); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1334 |
dec(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1335 |
while t >= 0 do |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1336 |
begin |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1337 |
inc(i); |
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 |
end; |
865 | 1340 |
PlaySound(sndReinforce, false); |
351 | 1341 |
FollowGear^.Pos:= posCaseAmmo; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1342 |
FollowGear^.State:= Longword(i) |
295 | 1343 |
end; |
1344 |
end; |
|
70 | 1345 |
FindPlace(FollowGear, true, 0, 2048) |
1346 |
end; |
|
1347 |
||
371 | 1348 |
procedure FindPlace(Gear: PGear; withFall: boolean; Left, Right: LongInt); |
70 | 1349 |
|
371 | 1350 |
function CountNonZeroz(x, y, r: LongInt): LongInt; |
1351 |
var i: LongInt; |
|
1352 |
Result: LongInt; |
|
70 | 1353 |
begin |
1354 |
Result:= 0; |
|
701 | 1355 |
if (y and $FFFFFC00) = 0 then |
1356 |
for i:= max(x - r, 0) to min(x + r, 2043) do |
|
351 | 1357 |
if Land[y, i] <> 0 then inc(Result); |
1358 |
CountNonZeroz:= Result |
|
70 | 1359 |
end; |
1360 |
||
495 | 1361 |
var x: LongInt; |
371 | 1362 |
y, sy: LongInt; |
386 | 1363 |
ar: array[0..511] of TPoint; |
1364 |
ar2: array[0..1023] of TPoint; |
|
392 | 1365 |
cnt, cnt2: Longword; |
1366 |
delta: LongInt; |
|
70 | 1367 |
begin |
386 | 1368 |
delta:= 250; |
1369 |
cnt2:= 0; |
|
16 | 1370 |
repeat |
392 | 1371 |
x:= Left + LongInt(GetRandom(Delta)); |
70 | 1372 |
repeat |
386 | 1373 |
inc(x, Delta); |
70 | 1374 |
cnt:= 0; |
351 | 1375 |
y:= -Gear^.Radius * 2; |
70 | 1376 |
while y < 1023 do |
16 | 1377 |
begin |
70 | 1378 |
repeat |
701 | 1379 |
inc(y, 2); |
351 | 1380 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0); |
70 | 1381 |
sy:= y; |
1382 |
repeat |
|
1383 |
inc(y); |
|
351 | 1384 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0); |
1385 |
if (y - sy > Gear^.Radius * 2) |
|
70 | 1386 |
and (y < 1023) |
351 | 1387 |
and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then |
70 | 1388 |
begin |
1389 |
ar[cnt].X:= x; |
|
351 | 1390 |
if withFall then ar[cnt].Y:= sy + Gear^.Radius |
1391 |
else ar[cnt].Y:= y - Gear^.Radius; |
|
70 | 1392 |
inc(cnt) |
1393 |
end; |
|
386 | 1394 |
inc(y, 45) |
16 | 1395 |
end; |
70 | 1396 |
if cnt > 0 then |
1397 |
with ar[GetRandom(cnt)] do |
|
1398 |
begin |
|
386 | 1399 |
ar2[cnt2].x:= x; |
1400 |
ar2[cnt2].y:= y; |
|
1401 |
inc(cnt2) |
|
70 | 1402 |
end |
386 | 1403 |
until (x + Delta > Right); |
1404 |
dec(Delta, 60) |
|
1405 |
until (cnt2 > 0) or (Delta < 70); |
|
1406 |
if cnt2 > 0 then |
|
1407 |
with ar2[GetRandom(cnt2)] do |
|
1408 |
begin |
|
498 | 1409 |
Gear^.X:= int2hwFloat(x); |
1410 |
Gear^.Y:= int2hwFloat(y); |
|
386 | 1411 |
{$IFDEF DEBUGFILE} |
1412 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
1413 |
{$ENDIF} |
|
1414 |
end |
|
1415 |
else |
|
1416 |
begin |
|
1417 |
OutError('Can''t find place for Gear', false); |
|
1418 |
DeleteGear(Gear) |
|
1419 |
end |
|
10 | 1420 |
end; |
1421 |
||
4 | 1422 |
initialization |
1423 |
||
1424 |
finalization |
|
95 | 1425 |
FreeGearsList; |
4 | 1426 |
|
1427 |
end. |