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