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