author | unc0rr |
Tue, 12 Aug 2008 19:41:16 +0000 | |
changeset 1200 | b92323ccce45 |
parent 1141 | 44d4d6aaecb5 |
child 1207 | ceaab010269e |
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 |
|
1200 | 1081 |
begin |
1082 |
dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
|
1083 |
if (dmg > 1) and |
|
1084 |
((Gear^.State and gstNoDamage) = 0) then |
|
1085 |
begin |
|
1086 |
dmg:= min(dmg div 2, Radius); |
|
1087 |
case Gear^.Kind of |
|
1088 |
gtHedgehog, |
|
1089 |
gtMine, |
|
1090 |
gtCase, |
|
1091 |
gtTarget, |
|
1092 |
gtFlame: begin |
|
1093 |
{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} |
|
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; |
|
1100 |
if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then |
|
1101 |
begin |
|
1102 |
DeleteCI(Gear); |
|
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)); |
|
1105 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); |
|
1106 |
Gear^.Active:= true; |
|
1107 |
FollowGear:= Gear |
|
1108 |
end; |
|
1109 |
end; |
|
1110 |
gtGrave: begin |
|
1111 |
Gear^.dY:= - _0_004 * dmg; |
|
1112 |
Gear^.Active:= true; |
|
1113 |
end; |
|
1114 |
end; |
|
1115 |
end; |
|
1116 |
Gear:= Gear^.NextGear |
|
1117 |
end; |
|
1118 |
||
621 | 1119 |
if (Mask and EXPLDontDraw) = 0 then |
1200 | 1120 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(X, Y, Radius); |
1121 |
||
498 | 1122 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
4 | 1123 |
end; |
1124 |
||
506 | 1125 |
procedure ShotgunShot(Gear: PGear); |
1126 |
var t: PGear; |
|
955 | 1127 |
dmg: LongInt; |
506 | 1128 |
begin |
509 | 1129 |
Gear^.Radius:= cShotgunRadius; |
506 | 1130 |
t:= GearsList; |
1131 |
while t <> nil do |
|
1132 |
begin |
|
1133 |
dmg:= min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25); |
|
538 | 1134 |
if dmg > 0 then |
506 | 1135 |
case t^.Kind of |
1136 |
gtHedgehog, |
|
1137 |
gtMine, |
|
593 | 1138 |
gtCase, |
1139 |
gtTarget: begin |
|
506 | 1140 |
inc(t^.Damage, dmg); |
867 | 1141 |
|
522 | 1142 |
if t^.Kind = gtHedgehog then |
531 | 1143 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, t); |
867 | 1144 |
|
506 | 1145 |
DeleteCI(t); |
856 | 1146 |
t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); |
506 | 1147 |
t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; |
1148 |
t^.State:= t^.State or gstMoving; |
|
1149 |
t^.Active:= true; |
|
1150 |
FollowGear:= t |
|
1151 |
end; |
|
1152 |
gtGrave: begin |
|
1153 |
t^.dY:= - _0_1; |
|
1154 |
t^.Active:= true |
|
1155 |
end; |
|
1156 |
end; |
|
1157 |
t:= t^.NextGear |
|
1158 |
end; |
|
621 | 1159 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) |
506 | 1160 |
end; |
1161 |
||
371 | 1162 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
53 | 1163 |
var t: PGearArray; |
371 | 1164 |
i: LongInt; |
38 | 1165 |
begin |
53 | 1166 |
t:= CheckGearsCollision(Ammo); |
351 | 1167 |
i:= t^.Count; |
53 | 1168 |
while i > 0 do |
981 | 1169 |
begin |
1170 |
dec(i); |
|
1171 |
if (t^.ar[i]^.State and gstNoDamage) = 0 then |
|
1172 |
case t^.ar[i]^.Kind of |
|
1173 |
gtHedgehog, |
|
1174 |
gtMine, |
|
1175 |
gtTarget, |
|
1176 |
gtCase: begin |
|
1177 |
inc(t^.ar[i]^.Damage, Damage); |
|
1178 |
||
1179 |
if t^.ar[i]^.Kind = gtHedgehog then |
|
1180 |
AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, t^.ar[i]); |
|
867 | 1181 |
|
981 | 1182 |
DeleteCI(t^.ar[i]); |
1183 |
t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01; |
|
1184 |
t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01; |
|
1185 |
t^.ar[i]^.Active:= true; |
|
1186 |
t^.ar[i]^.State:= t^.ar[i]^.State or gstMoving; |
|
867 | 1187 |
|
982 | 1188 |
if TestCollisionXwithGear(t^.ar[i], hwSign(t^.ar[i]^.dX)) then |
981 | 1189 |
begin |
1190 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -3, 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, -2, hwSign(t^.ar[i]^.dX)) |
|
1193 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1194 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX)) |
|
1195 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1196 |
end; |
|
982 | 1197 |
|
981 | 1198 |
FollowGear:= t^.ar[i] |
1199 |
end; |
|
1200 |
end |
|
1201 |
end; |
|
126 | 1202 |
SetAllToActive |
38 | 1203 |
end; |
1204 |
||
4 | 1205 |
procedure AssignHHCoords; |
955 | 1206 |
var i, t, p, j: LongInt; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1207 |
ar: array[0..Pred(cMaxHHs)] of PGear; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1208 |
Count: Longword; |
4 | 1209 |
begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1210 |
if (GameFlags and gfForts) <> 0 then |
955 | 1211 |
begin |
1212 |
t:= 0; |
|
1213 |
for p:= 0 to 1 do |
|
1214 |
begin |
|
1215 |
with ClansArray[p]^ do |
|
1216 |
for j:= 0 to Pred(TeamsNumber) do |
|
1217 |
with Teams[j]^ do |
|
1218 |
for i:= 0 to cMaxHHIndex do |
|
1219 |
with Hedgehogs[i] do |
|
958 | 1220 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
1221 |
begin |
|
1222 |
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
|
1223 |
Gear^.Pos:= GetRandom(19); |
8dcf263c9e8f
In forts mode, hedgehogs on the left look at the right, and vice-versa
unc0rr
parents:
997
diff
changeset
|
1224 |
Gear^.dX.isNegative:= p = 1; |
958 | 1225 |
end; |
955 | 1226 |
inc(t, 1024) |
1227 |
end |
|
1228 |
end else // mix hedgehogs |
|
1229 |
begin |
|
1230 |
Count:= 0; |
|
1231 |
for p:= 0 to Pred(TeamsCount) do |
|
1232 |
with TeamsArray[p]^ do |
|
1233 |
begin |
|
1234 |
for i:= 0 to cMaxHHIndex do |
|
1235 |
with Hedgehogs[i] do |
|
1236 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
|
1237 |
begin |
|
1238 |
ar[Count]:= Gear; |
|
1239 |
inc(Count) |
|
1240 |
end; |
|
1241 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1242 |
|
955 | 1243 |
while (Count > 0) do |
1244 |
begin |
|
1245 |
i:= GetRandom(Count); |
|
1246 |
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
|
1247 |
ar[i]^.dX.isNegative:= ar[i]^.X > _1024; |
959 | 1248 |
ar[i]^.Pos:= GetRandom(19); |
955 | 1249 |
ar[i]:= ar[Count - 1]; |
1250 |
dec(Count) |
|
1251 |
end |
|
1252 |
end |
|
4 | 1253 |
end; |
1254 |
||
371 | 1255 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
10 | 1256 |
var t: PGear; |
1257 |
begin |
|
1258 |
t:= GearsList; |
|
1259 |
rX:= sqr(rX); |
|
1260 |
rY:= sqr(rY); |
|
1261 |
while t <> nil do |
|
1262 |
begin |
|
351 | 1263 |
if (t <> Gear) and (t^.Kind = Kind) then |
498 | 1264 |
if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then |
351 | 1265 |
exit(t); |
1266 |
t:= t^.NextGear |
|
10 | 1267 |
end; |
351 | 1268 |
CheckGearNear:= nil |
15 | 1269 |
end; |
1270 |
||
79 | 1271 |
procedure AmmoFlameWork(Ammo: PGear); |
1272 |
var t: PGear; |
|
1273 |
begin |
|
1274 |
t:= GearsList; |
|
1275 |
while t <> nil do |
|
1276 |
begin |
|
351 | 1277 |
if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then |
498 | 1278 |
if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then |
79 | 1279 |
begin |
351 | 1280 |
inc(t^.Damage, 5); |
1281 |
t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; |
|
1282 |
t^.dY:= - _0_25; |
|
1283 |
t^.Active:= true; |
|
79 | 1284 |
DeleteCI(t); |
1285 |
FollowGear:= t |
|
1286 |
end; |
|
351 | 1287 |
t:= t^.NextGear |
79 | 1288 |
end; |
1289 |
end; |
|
1290 |
||
371 | 1291 |
function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; |
16 | 1292 |
var t: PGear; |
1293 |
begin |
|
1294 |
t:= GearsList; |
|
1295 |
rX:= sqr(rX); |
|
1296 |
rY:= sqr(rY); |
|
1297 |
while t <> nil do |
|
1298 |
begin |
|
351 | 1299 |
if t^.Kind in Kind then |
498 | 1300 |
if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then |
351 | 1301 |
exit(t); |
1302 |
t:= t^.NextGear |
|
16 | 1303 |
end; |
351 | 1304 |
CheckGearsNear:= nil |
16 | 1305 |
end; |
1306 |
||
1307 |
function CountGears(Kind: TGearType): Longword; |
|
1308 |
var t: PGear; |
|
351 | 1309 |
Result: Longword; |
16 | 1310 |
begin |
1311 |
Result:= 0; |
|
1312 |
t:= GearsList; |
|
1313 |
while t <> nil do |
|
1314 |
begin |
|
351 | 1315 |
if t^.Kind = Kind then inc(Result); |
1316 |
t:= t^.NextGear |
|
16 | 1317 |
end; |
351 | 1318 |
CountGears:= Result |
16 | 1319 |
end; |
1320 |
||
15 | 1321 |
procedure SpawnBoxOfSmth; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1322 |
var t: LongInt; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1323 |
i: TAmmoType; |
15 | 1324 |
begin |
614 | 1325 |
if (cCaseFactor = 0) or |
1326 |
(CountGears(gtCase) >= 5) or |
|
1327 |
(getrandom(cCaseFactor) <> 0) then exit; |
|
498 | 1328 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
295 | 1329 |
case getrandom(2) of |
1330 |
0: begin |
|
351 | 1331 |
FollowGear^.Health:= 25; |
1332 |
FollowGear^.Pos:= posCaseHealth |
|
295 | 1333 |
end; |
1334 |
1: begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1335 |
t:= 0; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1336 |
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
|
1337 |
inc(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1338 |
t:= GetRandom(t); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1339 |
i:= Low(TAmmoType); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1340 |
dec(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1341 |
while t >= 0 do |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1342 |
begin |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1343 |
inc(i); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1344 |
dec(t, Ammoz[i].Probability) |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1345 |
end; |
865 | 1346 |
PlaySound(sndReinforce, false); |
351 | 1347 |
FollowGear^.Pos:= posCaseAmmo; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1348 |
FollowGear^.State:= Longword(i) |
295 | 1349 |
end; |
1350 |
end; |
|
70 | 1351 |
FindPlace(FollowGear, true, 0, 2048) |
1352 |
end; |
|
1353 |
||
371 | 1354 |
procedure FindPlace(Gear: PGear; withFall: boolean; Left, Right: LongInt); |
70 | 1355 |
|
371 | 1356 |
function CountNonZeroz(x, y, r: LongInt): LongInt; |
1357 |
var i: LongInt; |
|
1358 |
Result: LongInt; |
|
70 | 1359 |
begin |
1360 |
Result:= 0; |
|
701 | 1361 |
if (y and $FFFFFC00) = 0 then |
1362 |
for i:= max(x - r, 0) to min(x + r, 2043) do |
|
351 | 1363 |
if Land[y, i] <> 0 then inc(Result); |
1364 |
CountNonZeroz:= Result |
|
70 | 1365 |
end; |
1366 |
||
495 | 1367 |
var x: LongInt; |
371 | 1368 |
y, sy: LongInt; |
386 | 1369 |
ar: array[0..511] of TPoint; |
1370 |
ar2: array[0..1023] of TPoint; |
|
392 | 1371 |
cnt, cnt2: Longword; |
1372 |
delta: LongInt; |
|
70 | 1373 |
begin |
386 | 1374 |
delta:= 250; |
1375 |
cnt2:= 0; |
|
16 | 1376 |
repeat |
392 | 1377 |
x:= Left + LongInt(GetRandom(Delta)); |
70 | 1378 |
repeat |
386 | 1379 |
inc(x, Delta); |
70 | 1380 |
cnt:= 0; |
351 | 1381 |
y:= -Gear^.Radius * 2; |
70 | 1382 |
while y < 1023 do |
16 | 1383 |
begin |
70 | 1384 |
repeat |
701 | 1385 |
inc(y, 2); |
351 | 1386 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0); |
70 | 1387 |
sy:= y; |
1388 |
repeat |
|
1389 |
inc(y); |
|
351 | 1390 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0); |
1391 |
if (y - sy > Gear^.Radius * 2) |
|
70 | 1392 |
and (y < 1023) |
351 | 1393 |
and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then |
70 | 1394 |
begin |
1395 |
ar[cnt].X:= x; |
|
351 | 1396 |
if withFall then ar[cnt].Y:= sy + Gear^.Radius |
1397 |
else ar[cnt].Y:= y - Gear^.Radius; |
|
70 | 1398 |
inc(cnt) |
1399 |
end; |
|
386 | 1400 |
inc(y, 45) |
16 | 1401 |
end; |
70 | 1402 |
if cnt > 0 then |
1403 |
with ar[GetRandom(cnt)] do |
|
1404 |
begin |
|
386 | 1405 |
ar2[cnt2].x:= x; |
1406 |
ar2[cnt2].y:= y; |
|
1407 |
inc(cnt2) |
|
70 | 1408 |
end |
386 | 1409 |
until (x + Delta > Right); |
1410 |
dec(Delta, 60) |
|
1411 |
until (cnt2 > 0) or (Delta < 70); |
|
1412 |
if cnt2 > 0 then |
|
1413 |
with ar2[GetRandom(cnt2)] do |
|
1414 |
begin |
|
498 | 1415 |
Gear^.X:= int2hwFloat(x); |
1416 |
Gear^.Y:= int2hwFloat(y); |
|
386 | 1417 |
{$IFDEF DEBUGFILE} |
1418 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
1419 |
{$ENDIF} |
|
1420 |
end |
|
1421 |
else |
|
1422 |
begin |
|
1423 |
OutError('Can''t find place for Gear', false); |
|
1424 |
DeleteGear(Gear) |
|
1425 |
end |
|
10 | 1426 |
end; |
1427 |
||
4 | 1428 |
initialization |
1429 |
||
1430 |
finalization |
|
95 | 1431 |
FreeGearsList; |
4 | 1432 |
|
1433 |
end. |