author | unc0rr |
Sun, 31 Aug 2008 17:22:50 +0000 | |
changeset 1242 | 4aca5f7b2504 |
parent 1221 | 51e3f3cfdca5 |
child 1251 | 1f545d9a10ca |
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 |
|
1207
ceaab010269e
Some adjusting... it still doesn't solve problem fully
unc0rr
parents:
1200
diff
changeset
|
77 |
const MAXROPEPOINTS = 384; |
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); |
|
1221 | 788 |
amWhip: DrawRotatedF(sprWhip, |
1010 | 789 |
hwRound(Gear^.X) + 1 + WorldDx, |
790 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
791 |
0, |
|
792 |
hwSign(Gear^.dX), |
|
793 |
0); |
|
1221 | 794 |
amSeduction: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
795 |
hwSign(Gear^.dX), |
|
796 |
2, |
|
797 |
2, |
|
798 |
0); |
|
1002 | 799 |
else |
822 | 800 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
801 |
hwSign(Gear^.dX), |
|
802 |
0, |
|
1002 | 803 |
4, |
822 | 804 |
0); |
1002 | 805 |
end; |
966 | 806 |
|
1002 | 807 |
case amt of |
808 |
amBaseballBat: DrawRotated(sprHandBaseball, |
|
809 |
hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx, |
|
810 |
hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle); |
|
811 |
end; |
|
966 | 812 |
|
1002 | 813 |
defaultPos:= false |
814 |
end |
|
815 |
end else // not gstHHDriven |
|
1012 | 816 |
begin |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
817 |
if (Gear^.Damage > 0) |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
818 |
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
|
819 |
begin |
1012 | 820 |
DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, |
821 |
hwSign(Gear^.dX), |
|
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
822 |
2, |
1012 | 823 |
1, |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
824 |
Gear^.DirAngle); |
1012 | 825 |
defaultPos:= false |
1020 | 826 |
end else |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
827 |
|
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
828 |
if ((Gear^.State and gstHHJumping) <> 0) then |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
829 |
begin |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
830 |
if ((Gear^.State and gstHHHJump) <> 0) then |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
831 |
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
|
832 |
- hwSign(Gear^.dX), |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
833 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
834 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
835 |
0) |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
836 |
else |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
837 |
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
|
838 |
hwSign(Gear^.dX), |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
839 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
840 |
1, |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
841 |
0); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
842 |
defaultPos:= false |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
1013
diff
changeset
|
843 |
end; |
1012 | 844 |
end; |
834 | 845 |
|
824 | 846 |
|
845 | 847 |
if defaultPos then |
970 | 848 |
begin |
954 | 849 |
DrawRotatedF(sprHHIdle, |
850 |
hwRound(Gear^.X) + 1 + WorldDx, |
|
851 |
hwRound(Gear^.Y) - 3 + WorldDy, |
|
957 | 852 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
822 | 853 |
hwSign(Gear^.dX), |
854 |
0); |
|
1242 | 855 |
DrawTextureF(PHedgehog(Gear^.Hedgehog)^.HatTex, |
970 | 856 |
hwRound(Gear^.X) + 1 + WorldDx, |
857 |
hwRound(Gear^.Y) - 8 + WorldDy, |
|
858 |
(RealTicks div 128 + Gear^.Pos) mod 19, |
|
859 |
hwSign(Gear^.dX), |
|
1242 | 860 |
32); |
970 | 861 |
end; |
292 | 862 |
|
351 | 863 |
with PHedgehog(Gear^.Hedgehog)^ do |
994 | 864 |
begin |
1011 | 865 |
if ((Gear^.State and not gstWinner) = 0) |
994 | 866 |
or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then |
958 | 867 |
begin |
976 | 868 |
t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy; |
958 | 869 |
if (cTagsMask and 1) <> 0 then |
870 |
begin |
|
871 |
dec(t, HealthTagTex^.h + 2); |
|
872 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex) |
|
873 |
end; |
|
874 |
if (cTagsMask and 2) <> 0 then |
|
875 |
begin |
|
876 |
dec(t, NameTagTex^.h + 2); |
|
877 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTagTex) |
|
878 |
end; |
|
879 |
if (cTagsMask and 4) <> 0 then |
|
880 |
begin |
|
881 |
dec(t, Team^.NameTagTex^.h + 2); |
|
882 |
DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex) |
|
883 |
end |
|
994 | 884 |
end; |
885 |
if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog |
|
958 | 886 |
begin |
887 |
if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then |
|
888 |
DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy, |
|
889 |
GameTicks div 32 mod 16); |
|
821
e6c0408b54ed
Use 'regular standing' and 'rope swing' hedgehog sprites
unc0rr
parents:
815
diff
changeset
|
890 |
|
958 | 891 |
if (Gear^.State and gstDrowning) = 0 then |
892 |
if (Gear^.State and gstHHThinking) <> 0 then |
|
893 |
DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, 0) |
|
894 |
else |
|
1033 | 895 |
if ShowCrosshair and ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then |
958 | 896 |
begin |
897 |
if ((Gear^.State and gstHHHJump) <> 0) then m:= -1 else m:= 1; |
|
898 |
DrawRotatedTex(Team^.CrosshairTex, |
|
899 |
12, 12, |
|
900 |
Round(hwRound(Gear^.X) + hwSign(Gear^.dX) * m * Sin(Gear^.Angle*pi/cMaxAngle) * 60) + WorldDx, |
|
901 |
Round(hwRound(Gear^.Y) - Cos(Gear^.Angle*pi/cMaxAngle) * 60) + WorldDy, 0, |
|
902 |
hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle) |
|
903 |
end |
|
994 | 904 |
end |
905 |
end |
|
292 | 906 |
end; |
907 |
||
956 | 908 |
procedure DrawGears; |
853 | 909 |
var Gear, HHGear: PGear; |
4 | 910 |
i: Longword; |
371 | 911 |
roplen: LongInt; |
4 | 912 |
|
371 | 913 |
procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt); |
914 |
var eX, eY, dX, dY: LongInt; |
|
915 |
i, sX, sY, x, y, d: LongInt; |
|
366 | 916 |
b: boolean; |
4 | 917 |
begin |
37 | 918 |
if (X1 = X2) and (Y1 = Y2) then |
919 |
begin |
|
351 | 920 |
OutError('WARNING: zero length rope line!', false); |
37 | 921 |
exit |
922 |
end; |
|
366 | 923 |
eX:= 0; |
924 |
eY:= 0; |
|
925 |
dX:= X2 - X1; |
|
926 |
dY:= Y2 - Y1; |
|
927 |
||
928 |
if (dX > 0) then sX:= 1 |
|
929 |
else |
|
930 |
if (dX < 0) then |
|
931 |
begin |
|
932 |
sX:= -1; |
|
933 |
dX:= -dX |
|
934 |
end else sX:= dX; |
|
935 |
||
936 |
if (dY > 0) then sY:= 1 |
|
937 |
else |
|
938 |
if (dY < 0) then |
|
4 | 939 |
begin |
366 | 940 |
sY:= -1; |
941 |
dY:= -dY |
|
942 |
end else sY:= dY; |
|
943 |
||
944 |
if (dX > dY) then d:= dX |
|
945 |
else d:= dY; |
|
946 |
||
947 |
x:= X1; |
|
948 |
y:= Y1; |
|
949 |
||
950 |
for i:= 0 to d do |
|
951 |
begin |
|
952 |
inc(eX, dX); |
|
953 |
inc(eY, dY); |
|
954 |
b:= false; |
|
955 |
if (eX > d) then |
|
35 | 956 |
begin |
366 | 957 |
dec(eX, d); |
958 |
inc(x, sX); |
|
959 |
b:= true |
|
35 | 960 |
end; |
366 | 961 |
if (eY > d) then |
35 | 962 |
begin |
366 | 963 |
dec(eY, d); |
964 |
inc(y, sY); |
|
965 |
b:= true |
|
35 | 966 |
end; |
366 | 967 |
if b then |
968 |
begin |
|
969 |
inc(roplen); |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
970 |
if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0) |
366 | 971 |
end |
4 | 972 |
end |
366 | 973 |
end; |
4 | 974 |
|
975 |
begin |
|
976 |
Gear:= GearsList; |
|
977 |
while Gear<>nil do |
|
978 |
begin |
|
351 | 979 |
case Gear^.Kind of |
822 | 980 |
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
|
981 |
gtHedgehog: DrawHH(Gear); |
822 | 982 |
gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
522 | 983 |
gtHealthTag, |
762 | 984 |
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
|
985 |
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
|
986 |
gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4); |
848 | 987 |
gtPickHammer: DrawSprite(sprPHammer, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 50 + LongInt(((GameTicks shr 5) and 1) * 2) + WorldDy, 0); |
4 | 988 |
gtRope: begin |
35 | 989 |
roplen:= 0; |
4 | 990 |
if RopePoints.Count > 0 then |
991 |
begin |
|
992 |
i:= 0; |
|
993 |
while i < Pred(RopePoints.Count) do |
|
994 |
begin |
|
351 | 995 |
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
996 |
hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy); |
|
4 | 997 |
inc(i) |
998 |
end; |
|
351 | 999 |
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
1000 |
hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy); |
|
1001 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
|
1002 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 1003 |
DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) |
4 | 1004 |
end else |
35 | 1005 |
begin |
351 | 1006 |
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
1007 |
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); |
|
822 | 1008 |
DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
35 | 1009 |
end; |
4 | 1010 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1011 |
gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State); |
1012 | 1012 |
gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State); |
351 | 1013 |
gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420) |
822 | 1014 |
then DrawRotated(sprMineOff, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle) |
1015 |
else DrawRotated(sprMineOn, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); |
|
351 | 1016 |
gtCase: case Gear^.Pos of |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1017 |
posCaseAmmo : DrawSprite(sprCase, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
1009 | 1018 |
posCaseHealth: begin |
1019 |
i:= (GameTicks shr 6) mod 64; |
|
1020 |
if i > 12 then i:= 0; |
|
1021 |
DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i); |
|
1022 |
end; |
|
42 | 1023 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1024 |
gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1); |
822 | 1025 |
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
|
1026 |
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
|
1027 |
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
|
1028 |
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
|
1029 |
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
|
1030 |
else DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 1); |
822 | 1031 |
gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
853 | 1032 |
gtTeleport: begin |
1033 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1034 |
DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
1035 |
DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0); |
|
1036 |
end; |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
840
diff
changeset
|
1037 |
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
|
1038 |
gtTarget: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); |
959 | 1039 |
gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); |
1108 | 1040 |
gtCake: if Gear^.Pos = 6 then |
1041 |
DrawRotatedf(sprCakeWalk, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle + hwSign(Gear^.dX) * 90) |
|
1042 |
else |
|
1109 | 1043 |
DrawRotatedf(sprCakeDown, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 5 - Gear^.Pos, hwSign(Gear^.dX), 0) |
4 | 1044 |
end; |
351 | 1045 |
Gear:= Gear^.NextGear |
4 | 1046 |
end; |
1047 |
end; |
|
1048 |
||
1049 |
procedure FreeGearsList; |
|
1050 |
var t, tt: PGear; |
|
1051 |
begin |
|
1052 |
tt:= GearsList; |
|
1053 |
GearsList:= nil; |
|
1054 |
while tt<>nil do |
|
1055 |
begin |
|
1056 |
t:= tt; |
|
351 | 1057 |
tt:= tt^.NextGear; |
4 | 1058 |
Dispose(t) |
1059 |
end; |
|
1060 |
end; |
|
1061 |
||
10 | 1062 |
procedure AddMiscGears; |
371 | 1063 |
var i: LongInt; |
4 | 1064 |
begin |
498 | 1065 |
AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000); |
22 | 1066 |
if (GameFlags and gfForts) = 0 then |
622 | 1067 |
for i:= 0 to Pred(cLandAdditions) do |
498 | 1068 |
FindPlace(AddGear(0, 0, gtMine, 0, _0, _0, 0), false, 0, 2048); |
4 | 1069 |
end; |
1070 |
||
371 | 1071 |
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); |
4 | 1072 |
var Gear: PGear; |
506 | 1073 |
dmg, dmgRadius: LongInt; |
4 | 1074 |
begin |
1075 |
TargetPoint.X:= NoPointX; |
|
1076 |
{$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF} |
|
1049 | 1077 |
if (Radius > 10) then AddGear(X, Y, gtExplosion, 0, _0, _0, 0); |
355 | 1078 |
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false); |
506 | 1079 |
if (Mask and EXPLAllDamageInRadius)=0 then dmgRadius:= Radius shl 1 |
1080 |
else dmgRadius:= Radius; |
|
4 | 1081 |
Gear:= GearsList; |
1082 |
while Gear <> nil do |
|
1200 | 1083 |
begin |
1084 |
dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
|
1085 |
if (dmg > 1) and |
|
1086 |
((Gear^.State and gstNoDamage) = 0) then |
|
1087 |
begin |
|
1088 |
dmg:= min(dmg div 2, Radius); |
|
1089 |
case Gear^.Kind of |
|
1090 |
gtHedgehog, |
|
1091 |
gtMine, |
|
1092 |
gtCase, |
|
1093 |
gtTarget, |
|
1094 |
gtFlame: begin |
|
1095 |
{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} |
|
1096 |
if (Mask and EXPLNoDamage) = 0 then |
|
1097 |
begin |
|
1098 |
inc(Gear^.Damage, dmg); |
|
1099 |
if Gear^.Kind = gtHedgehog then |
|
1100 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, Gear) |
|
1101 |
end; |
|
1102 |
if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then |
|
1103 |
begin |
|
1104 |
DeleteCI(Gear); |
|
1105 |
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X)); |
|
1106 |
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y)); |
|
1107 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); |
|
1108 |
Gear^.Active:= true; |
|
1109 |
FollowGear:= Gear |
|
1110 |
end; |
|
1111 |
end; |
|
1112 |
gtGrave: begin |
|
1113 |
Gear^.dY:= - _0_004 * dmg; |
|
1114 |
Gear^.Active:= true; |
|
1115 |
end; |
|
1116 |
end; |
|
1117 |
end; |
|
1118 |
Gear:= Gear^.NextGear |
|
1119 |
end; |
|
1120 |
||
621 | 1121 |
if (Mask and EXPLDontDraw) = 0 then |
1200 | 1122 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(X, Y, Radius); |
1123 |
||
498 | 1124 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
4 | 1125 |
end; |
1126 |
||
506 | 1127 |
procedure ShotgunShot(Gear: PGear); |
1128 |
var t: PGear; |
|
955 | 1129 |
dmg: LongInt; |
506 | 1130 |
begin |
509 | 1131 |
Gear^.Radius:= cShotgunRadius; |
506 | 1132 |
t:= GearsList; |
1133 |
while t <> nil do |
|
1134 |
begin |
|
1135 |
dmg:= min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25); |
|
538 | 1136 |
if dmg > 0 then |
506 | 1137 |
case t^.Kind of |
1138 |
gtHedgehog, |
|
1139 |
gtMine, |
|
593 | 1140 |
gtCase, |
1141 |
gtTarget: begin |
|
506 | 1142 |
inc(t^.Damage, dmg); |
867 | 1143 |
|
522 | 1144 |
if t^.Kind = gtHedgehog then |
531 | 1145 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), dmg, t); |
867 | 1146 |
|
506 | 1147 |
DeleteCI(t); |
856 | 1148 |
t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); |
506 | 1149 |
t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; |
1150 |
t^.State:= t^.State or gstMoving; |
|
1151 |
t^.Active:= true; |
|
1152 |
FollowGear:= t |
|
1153 |
end; |
|
1154 |
gtGrave: begin |
|
1155 |
t^.dY:= - _0_1; |
|
1156 |
t^.Active:= true |
|
1157 |
end; |
|
1158 |
end; |
|
1159 |
t:= t^.NextGear |
|
1160 |
end; |
|
621 | 1161 |
if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) |
506 | 1162 |
end; |
1163 |
||
371 | 1164 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
53 | 1165 |
var t: PGearArray; |
371 | 1166 |
i: LongInt; |
38 | 1167 |
begin |
53 | 1168 |
t:= CheckGearsCollision(Ammo); |
351 | 1169 |
i:= t^.Count; |
53 | 1170 |
while i > 0 do |
981 | 1171 |
begin |
1172 |
dec(i); |
|
1173 |
if (t^.ar[i]^.State and gstNoDamage) = 0 then |
|
1174 |
case t^.ar[i]^.Kind of |
|
1175 |
gtHedgehog, |
|
1176 |
gtMine, |
|
1177 |
gtTarget, |
|
1178 |
gtCase: begin |
|
1179 |
inc(t^.ar[i]^.Damage, Damage); |
|
1180 |
||
1181 |
if t^.ar[i]^.Kind = gtHedgehog then |
|
1182 |
AddDamageTag(hwRound(t^.ar[i]^.X), hwRound(t^.ar[i]^.Y), Damage, t^.ar[i]); |
|
867 | 1183 |
|
981 | 1184 |
DeleteCI(t^.ar[i]); |
1185 |
t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01; |
|
1186 |
t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01; |
|
1187 |
t^.ar[i]^.Active:= true; |
|
1188 |
t^.ar[i]^.State:= t^.ar[i]^.State or gstMoving; |
|
867 | 1189 |
|
982 | 1190 |
if TestCollisionXwithGear(t^.ar[i], hwSign(t^.ar[i]^.dX)) then |
981 | 1191 |
begin |
1192 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -3, 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, -2, hwSign(t^.ar[i]^.dX)) |
|
1195 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1196 |
if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX)) |
|
1197 |
or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1; |
|
1198 |
end; |
|
982 | 1199 |
|
981 | 1200 |
FollowGear:= t^.ar[i] |
1201 |
end; |
|
1202 |
end |
|
1203 |
end; |
|
126 | 1204 |
SetAllToActive |
38 | 1205 |
end; |
1206 |
||
4 | 1207 |
procedure AssignHHCoords; |
955 | 1208 |
var i, t, p, j: LongInt; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1209 |
ar: array[0..Pred(cMaxHHs)] of PGear; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1210 |
Count: Longword; |
4 | 1211 |
begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1212 |
if (GameFlags and gfForts) <> 0 then |
955 | 1213 |
begin |
1214 |
t:= 0; |
|
1215 |
for p:= 0 to 1 do |
|
1216 |
begin |
|
1217 |
with ClansArray[p]^ do |
|
1218 |
for j:= 0 to Pred(TeamsNumber) do |
|
1219 |
with Teams[j]^ do |
|
1220 |
for i:= 0 to cMaxHHIndex do |
|
1221 |
with Hedgehogs[i] do |
|
958 | 1222 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
1223 |
begin |
|
1224 |
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
|
1225 |
Gear^.Pos:= GetRandom(19); |
8dcf263c9e8f
In forts mode, hedgehogs on the left look at the right, and vice-versa
unc0rr
parents:
997
diff
changeset
|
1226 |
Gear^.dX.isNegative:= p = 1; |
958 | 1227 |
end; |
955 | 1228 |
inc(t, 1024) |
1229 |
end |
|
1230 |
end else // mix hedgehogs |
|
1231 |
begin |
|
1232 |
Count:= 0; |
|
1233 |
for p:= 0 to Pred(TeamsCount) do |
|
1234 |
with TeamsArray[p]^ do |
|
1235 |
begin |
|
1236 |
for i:= 0 to cMaxHHIndex do |
|
1237 |
with Hedgehogs[i] do |
|
1238 |
if (Gear <> nil) and (Gear^.X.QWordValue = 0) then |
|
1239 |
begin |
|
1240 |
ar[Count]:= Gear; |
|
1241 |
inc(Count) |
|
1242 |
end; |
|
1243 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1244 |
|
955 | 1245 |
while (Count > 0) do |
1246 |
begin |
|
1247 |
i:= GetRandom(Count); |
|
1248 |
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
|
1249 |
ar[i]^.dX.isNegative:= ar[i]^.X > _1024; |
959 | 1250 |
ar[i]^.Pos:= GetRandom(19); |
955 | 1251 |
ar[i]:= ar[Count - 1]; |
1252 |
dec(Count) |
|
1253 |
end |
|
1254 |
end |
|
4 | 1255 |
end; |
1256 |
||
371 | 1257 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
10 | 1258 |
var t: PGear; |
1259 |
begin |
|
1260 |
t:= GearsList; |
|
1261 |
rX:= sqr(rX); |
|
1262 |
rY:= sqr(rY); |
|
1263 |
while t <> nil do |
|
1264 |
begin |
|
351 | 1265 |
if (t <> Gear) and (t^.Kind = Kind) then |
498 | 1266 |
if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then |
351 | 1267 |
exit(t); |
1268 |
t:= t^.NextGear |
|
10 | 1269 |
end; |
351 | 1270 |
CheckGearNear:= nil |
15 | 1271 |
end; |
1272 |
||
79 | 1273 |
procedure AmmoFlameWork(Ammo: PGear); |
1274 |
var t: PGear; |
|
1275 |
begin |
|
1276 |
t:= GearsList; |
|
1277 |
while t <> nil do |
|
1278 |
begin |
|
351 | 1279 |
if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then |
498 | 1280 |
if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then |
79 | 1281 |
begin |
351 | 1282 |
inc(t^.Damage, 5); |
1283 |
t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; |
|
1284 |
t^.dY:= - _0_25; |
|
1285 |
t^.Active:= true; |
|
79 | 1286 |
DeleteCI(t); |
1287 |
FollowGear:= t |
|
1288 |
end; |
|
351 | 1289 |
t:= t^.NextGear |
79 | 1290 |
end; |
1291 |
end; |
|
1292 |
||
371 | 1293 |
function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; |
16 | 1294 |
var t: PGear; |
1295 |
begin |
|
1296 |
t:= GearsList; |
|
1297 |
rX:= sqr(rX); |
|
1298 |
rY:= sqr(rY); |
|
1299 |
while t <> nil do |
|
1300 |
begin |
|
351 | 1301 |
if t^.Kind in Kind then |
498 | 1302 |
if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then |
351 | 1303 |
exit(t); |
1304 |
t:= t^.NextGear |
|
16 | 1305 |
end; |
351 | 1306 |
CheckGearsNear:= nil |
16 | 1307 |
end; |
1308 |
||
1309 |
function CountGears(Kind: TGearType): Longword; |
|
1310 |
var t: PGear; |
|
351 | 1311 |
Result: Longword; |
16 | 1312 |
begin |
1313 |
Result:= 0; |
|
1314 |
t:= GearsList; |
|
1315 |
while t <> nil do |
|
1316 |
begin |
|
351 | 1317 |
if t^.Kind = Kind then inc(Result); |
1318 |
t:= t^.NextGear |
|
16 | 1319 |
end; |
351 | 1320 |
CountGears:= Result |
16 | 1321 |
end; |
1322 |
||
15 | 1323 |
procedure SpawnBoxOfSmth; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1324 |
var t: LongInt; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1325 |
i: TAmmoType; |
15 | 1326 |
begin |
614 | 1327 |
if (cCaseFactor = 0) or |
1328 |
(CountGears(gtCase) >= 5) or |
|
1329 |
(getrandom(cCaseFactor) <> 0) then exit; |
|
498 | 1330 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
295 | 1331 |
case getrandom(2) of |
1332 |
0: begin |
|
351 | 1333 |
FollowGear^.Health:= 25; |
1334 |
FollowGear^.Pos:= posCaseHealth |
|
295 | 1335 |
end; |
1336 |
1: begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1337 |
t:= 0; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1338 |
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
|
1339 |
inc(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1340 |
t:= GetRandom(t); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1341 |
i:= Low(TAmmoType); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1342 |
dec(t, Ammoz[i].Probability); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1343 |
while t >= 0 do |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1344 |
begin |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1345 |
inc(i); |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1346 |
dec(t, Ammoz[i].Probability) |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1347 |
end; |
865 | 1348 |
PlaySound(sndReinforce, false); |
351 | 1349 |
FollowGear^.Pos:= posCaseAmmo; |
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
1350 |
FollowGear^.State:= Longword(i) |
295 | 1351 |
end; |
1352 |
end; |
|
70 | 1353 |
FindPlace(FollowGear, true, 0, 2048) |
1354 |
end; |
|
1355 |
||
371 | 1356 |
procedure FindPlace(Gear: PGear; withFall: boolean; Left, Right: LongInt); |
70 | 1357 |
|
371 | 1358 |
function CountNonZeroz(x, y, r: LongInt): LongInt; |
1359 |
var i: LongInt; |
|
1360 |
Result: LongInt; |
|
70 | 1361 |
begin |
1362 |
Result:= 0; |
|
701 | 1363 |
if (y and $FFFFFC00) = 0 then |
1364 |
for i:= max(x - r, 0) to min(x + r, 2043) do |
|
351 | 1365 |
if Land[y, i] <> 0 then inc(Result); |
1366 |
CountNonZeroz:= Result |
|
70 | 1367 |
end; |
1368 |
||
495 | 1369 |
var x: LongInt; |
371 | 1370 |
y, sy: LongInt; |
386 | 1371 |
ar: array[0..511] of TPoint; |
1372 |
ar2: array[0..1023] of TPoint; |
|
392 | 1373 |
cnt, cnt2: Longword; |
1374 |
delta: LongInt; |
|
70 | 1375 |
begin |
386 | 1376 |
delta:= 250; |
1377 |
cnt2:= 0; |
|
16 | 1378 |
repeat |
392 | 1379 |
x:= Left + LongInt(GetRandom(Delta)); |
70 | 1380 |
repeat |
386 | 1381 |
inc(x, Delta); |
70 | 1382 |
cnt:= 0; |
351 | 1383 |
y:= -Gear^.Radius * 2; |
70 | 1384 |
while y < 1023 do |
16 | 1385 |
begin |
70 | 1386 |
repeat |
701 | 1387 |
inc(y, 2); |
351 | 1388 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0); |
70 | 1389 |
sy:= y; |
1390 |
repeat |
|
1391 |
inc(y); |
|
351 | 1392 |
until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0); |
1393 |
if (y - sy > Gear^.Radius * 2) |
|
70 | 1394 |
and (y < 1023) |
351 | 1395 |
and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then |
70 | 1396 |
begin |
1397 |
ar[cnt].X:= x; |
|
351 | 1398 |
if withFall then ar[cnt].Y:= sy + Gear^.Radius |
1399 |
else ar[cnt].Y:= y - Gear^.Radius; |
|
70 | 1400 |
inc(cnt) |
1401 |
end; |
|
386 | 1402 |
inc(y, 45) |
16 | 1403 |
end; |
70 | 1404 |
if cnt > 0 then |
1405 |
with ar[GetRandom(cnt)] do |
|
1406 |
begin |
|
386 | 1407 |
ar2[cnt2].x:= x; |
1408 |
ar2[cnt2].y:= y; |
|
1409 |
inc(cnt2) |
|
70 | 1410 |
end |
386 | 1411 |
until (x + Delta > Right); |
1412 |
dec(Delta, 60) |
|
1413 |
until (cnt2 > 0) or (Delta < 70); |
|
1414 |
if cnt2 > 0 then |
|
1415 |
with ar2[GetRandom(cnt2)] do |
|
1416 |
begin |
|
498 | 1417 |
Gear^.X:= int2hwFloat(x); |
1418 |
Gear^.Y:= int2hwFloat(y); |
|
386 | 1419 |
{$IFDEF DEBUGFILE} |
1420 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
1421 |
{$ENDIF} |
|
1422 |
end |
|
1423 |
else |
|
1424 |
begin |
|
1425 |
OutError('Can''t find place for Gear', false); |
|
1426 |
DeleteGear(Gear) |
|
1427 |
end |
|
10 | 1428 |
end; |
1429 |
||
4 | 1430 |
initialization |
1431 |
||
1432 |
finalization |
|
95 | 1433 |
FreeGearsList; |
4 | 1434 |
|
1435 |
end. |