author  nemo 
Fri, 12 Nov 2010 21:30:00 0500  
changeset 4299  d23f8a25fc3f 
parent 4295  1f5604cd99be 
child 4313  0690067bc5ff 
permissions  rwrr 
4  1 
(* 
1066  2 
* Hedgewars, a free turn based strategy game 
3236
4ab3917d7d44
Update (c) lines to 2010 as unc0rr requested  they all had varying values so I just took the first year mentioned, then tacked on 2010
nemo
parents:
3232
diff
changeset

3 
* Copyright (c) 20042010 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 021111307, USA 

4  17 
*) 
18 

2622  19 
{$INCLUDE "options.inc"} 
20 

4  21 
unit uGears; 
22 
interface 

3032  23 
uses SDLh, uConsts, uFloat, Math; 
4  24 

3697  25 

2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2699
diff
changeset

26 
type 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

27 
PGear = ^TGear; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

28 
TGearStepProcedure = procedure (Gear: PGear); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

29 
TGear = record 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

30 
NextGear, PrevGear: PGear; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

31 
Active: Boolean; 
3072
b18038b3a0f4
I don't know why I'm bothering. Sheepluva has a whole new approach in the works.
nemo
parents:
3065
diff
changeset

32 
AdvBounce: Longword; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

33 
Invulnerable: Boolean; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

34 
RenderTimer: Boolean; 
3836
833c0f32e326
Change all use of curslot/idx to CurAmmoType to try and avoid some bugs with use of last weapon.
nemo
parents:
3832
diff
changeset

35 
AmmoType : TAmmoType; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

36 
State : Longword; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

37 
X : hwFloat; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

38 
Y : hwFloat; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

39 
dX: hwFloat; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

40 
dY: hwFloat; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

41 
Kind: TGearType; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

42 
Pos: Longword; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

43 
doStep: TGearStepProcedure; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

44 
Radius: LongInt; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

45 
Angle, Power : Longword; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

46 
DirAngle: real; 
3030  47 
Timer : LongWord; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

48 
Elasticity: hwFloat; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

49 
Friction : hwFloat; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

50 
Message, MsgParam : Longword; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

51 
Hedgehog: pointer; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

52 
Health, Damage, Karma: LongInt; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

53 
CollisionIndex: LongInt; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

54 
Tag: LongInt; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

55 
Tex: PTexture; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

56 
Z: Longword; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

57 
IntersectGear: PGear; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

58 
FlightTime: Longword; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

59 
uid: Longword; 
3136  60 
ImpactSound: TSound; // first sound, others have to be after it in the sounds def. 
3180
724e094a8912
fix fpc 2.2.4 type related warning with unclear origin
sheepluva
parents:
3172
diff
changeset

61 
nImpactSounds: Word; // count of ImpactSounds 
3480
c4c3f3512404
Prevent all portal loops the guaranteed way, at least until sheepluva's tests yield something reliable.
nemo
parents:
3476
diff
changeset

62 
SoundChannel: LongInt; 
c4c3f3512404
Prevent all portal loops the guaranteed way, at least until sheepluva's tests yield something reliable.
nemo
parents:
3476
diff
changeset

63 
PortalCounter: LongWord // Hopefully temporary, but avoids infinite portal loops in a guaranteed fashion. 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

64 
end; 
3963
6090d2a2472e
New Weapon: Resurrector (TODO: ammo icon + sprites)
Tobias Neumann <mail@tobiasneumann.eu>
parents:
3957
diff
changeset

65 
TPGearArray = Array of PGear; 
4  66 

2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2699
diff
changeset

67 
var AllInactive: boolean; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2699
diff
changeset

68 
PrvInactive: boolean; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2699
diff
changeset

69 
CurAmmoGear: PGear; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2699
diff
changeset

70 
GearsList: PGear; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2699
diff
changeset

71 
KilledHHs: Longword; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2699
diff
changeset

72 
SuddenDeathDmg: Boolean; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2699
diff
changeset

73 
SpeechType: Longword; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2699
diff
changeset

74 
SpeechText: shortstring; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2699
diff
changeset

75 
TrainingTargetGear: PGear; 
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2699
diff
changeset

76 
skipFlag: boolean; 
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2760
diff
changeset

77 
PlacingHogs: boolean; // a convenience flag to indicate placement of hogs is still in progress 
2940  78 
StepSoundTimer: LongInt; 
79 
StepSoundChannel: LongInt; 

3697  80 

3038  81 
procedure initModule; 
82 
procedure freeModule; 

371  83 
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; 
3750
3aa85b5f3318
SpawnCustomCrateAt: spawn crate at random position for x=y=0, also let it return the gear, and luabindings the gear uid
burp
parents:
3749
diff
changeset

84 
function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword ): PGear; 
3768  85 
procedure ResurrectHedgehog(gear: PGear); 
4  86 
procedure ProcessGears; 
3396
e5b3e5f2818e
More portal changes. Allows for a multishoot utility. Hopefully not breaking anything.
nemo
parents:
3390
diff
changeset

87 
procedure EndTurnCleanup; 
3682  88 
procedure ApplyDamage(Gear: PGear; Damage: Longword; Source: TDamageSource); 
4  89 
procedure SetAllToActive; 
90 
procedure SetAllHHToActive; 

956  91 
procedure DrawGears; 
4  92 
procedure FreeGearsList; 
10  93 
procedure AddMiscGears; 
4  94 
procedure AssignHHCoords; 
3405  95 
function GearByUID(uid : Longword) : PGear; 
294  96 
procedure InsertGearToList(Gear: PGear); 
97 
procedure RemoveGearFromList(Gear: PGear); 

3405  98 
function ModifyDamage(dmg: Longword; Gear: PGear): Longword; 
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2760
diff
changeset

99 
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); 
3672
f225b94a4411
shrink confirmation button, double tap resets zoom and centers hog
koda
parents:
3615
diff
changeset

100 
function GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt; 
f225b94a4411
shrink confirmation button, double tap resets zoom and centers hog
koda
parents:
3615
diff
changeset

101 
function GetLaunchY(at: TAmmoType; angle: LongInt): LongInt; 
4  102 

103 
implementation 

2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset

104 
uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, uLand, uIO, uLandGraphics, 
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4024
diff
changeset

105 
uAIMisc, uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile; 
789  106 

1207
ceaab010269e
Some adjusting... it still doesn't solve problem fully
unc0rr
parents:
1200
diff
changeset

107 
const MAXROPEPOINTS = 384; 
68  108 
var RopePoints: record 
4  109 
Count: Longword; 
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
775
diff
changeset

110 
HookAngle: GLfloat; 
789  111 
ar: array[0..MAXROPEPOINTS] of record 
351  112 
X, Y: hwFloat; 
113 
dLen: hwFloat; 

4  114 
b: boolean; 
115 
end; 

2391  116 
rounded: array[0..MAXROPEPOINTS + 2] of TVertex2f; 
2362  117 
end; 
3697  118 

1515  119 
procedure DeleteGear(Gear: PGear); forward; 
371  120 
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); forward; 
3475  121 
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask, Tint: LongWord); forward; 
371  122 
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward; 
1433  123 
//procedure AmmoFlameWork(Ammo: PGear); forward; 
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
4024
diff
changeset

124 
function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): TPGearArray; forward; 
371  125 
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; forward; 
15  126 
procedure SpawnBoxOfSmth; forward; 
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
24
diff
changeset

127 
procedure AfterAttack; forward; 
302  128 
procedure HedgehogStep(Gear: PGear); forward; 
1528  129 
procedure doStepHedgehogMoving(Gear: PGear); forward; 
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset

130 
procedure HedgehogChAngle(Gear: PGear); forward; 
506  131 
procedure ShotgunShot(Gear: PGear); forward; 
1689  132 
procedure PickUp(HH, Gear: PGear); forward; 
1964  133 
procedure HHSetWeapon(Gear: PGear); forward; 
2941
566f967ec22f
White/Black smoke, break out rolling barrel into its own routine, adjust rolling barrel impact damage. NEEDS TESTING
nemo
parents:
2940
diff
changeset

134 
procedure doStepCase(Gear: PGear); forward; 
1964  135 

3483  136 
function GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt; 
137 
begin 

3499  138 
if (Ammoz[at].ejectX <> 0) or (Ammoz[at].ejectY <> 0) then 
139 
GetLaunchX:= sign(dir) * (8 + hwRound(AngleSin(angle) * Ammoz[at].ejectX) + hwRound(AngleCos(angle) * Ammoz[at].ejectY)) 

140 
else 

141 
GetLaunchX:= 0 

3483  142 
end; 
143 

144 
function GetLaunchY(at: TAmmoType; angle: LongInt): LongInt; 

145 
begin 

3499  146 
if (Ammoz[at].ejectX <> 0) or (Ammoz[at].ejectY <> 0) then 
147 
GetLaunchY:= hwRound(AngleSin(angle) * Ammoz[at].ejectY)  hwRound(AngleCos(angle) * Ammoz[at].ejectX)  2 

148 
else 

149 
GetLaunchY:= 0 

3483  150 
end; 
4  151 

2599  152 
{$INCLUDE "GSHandlers.inc"} 
153 
{$INCLUDE "HHHandlers.inc"} 

4  154 

155 
const doStepHandlers: array[TGearType] of TGearStepProcedure = ( 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

156 
@doStepBomb, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

157 
@doStepHedgehog, 
4168  158 
@doStepShell, 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

159 
@doStepGrave, 
3080  160 
@doStepBee, 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

161 
@doStepShotgunShot, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

162 
@doStepPickHammer, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

163 
@doStepRope, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

164 
@doStepMine, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

165 
@doStepCase, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

166 
@doStepDEagleShot, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

167 
@doStepDynamite, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

168 
@doStepBomb, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

169 
@doStepCluster, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

170 
@doStepShover, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

171 
@doStepFlame, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

172 
@doStepFirePunch, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

173 
@doStepActionTimer, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

174 
@doStepActionTimer, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

175 
@doStepActionTimer, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

176 
@doStepParachute, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

177 
@doStepAirAttack, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

178 
@doStepAirBomb, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

179 
@doStepBlowTorch, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

180 
@doStepGirder, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

181 
@doStepTeleport, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

182 
@doStepSwitcher, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

183 
@doStepTarget, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

184 
@doStepMortar, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

185 
@doStepWhip, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

186 
@doStepKamikaze, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

187 
@doStepCake, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

188 
@doStepSeduction, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

189 
@doStepWatermelon, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

190 
@doStepCluster, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

191 
@doStepBomb, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

192 
@doStepWaterUp, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

193 
@doStepDrill, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

194 
@doStepBallgun, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

195 
@doStepBomb, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

196 
@doStepRCPlane, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

197 
@doStepSniperRifleShot, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

198 
@doStepJetpack, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

199 
@doStepMolotov, 
2983  200 
@doStepCase, 
3032  201 
@doStepBirdy, 
3342
b4f01613dcd7
Some initial stubs for portal just so Tiy will quit nagging. Also let folks know what approximation of physics I plan to try, here.
nemo
parents:
3337
diff
changeset

202 
@doStepEggWork, 
3428  203 
@doStepPortalShot, 
3382  204 
@doStepPiano, 
3384  205 
@doStepBomb, 
3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

206 
@doStepSineGunShot, 
3710  207 
@doStepFlamethrower, 
3712  208 
@doStepSMine, 
3717  209 
@doStepPoisonCloud, 
3720  210 
@doStepHammer, 
3963
6090d2a2472e
New Weapon: Resurrector (TODO: ammo icon + sprites)
Tobias Neumann <mail@tobiasneumann.eu>
parents:
3957
diff
changeset

211 
@doStepHammerHit, 
6090d2a2472e
New Weapon: Resurrector (TODO: ammo icon + sprites)
Tobias Neumann <mail@tobiasneumann.eu>
parents:
3957
diff
changeset

212 
@doStepResurrector 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

213 
); 
4  214 

294  215 
procedure InsertGearToList(Gear: PGear); 
803  216 
var tmp, ptmp: PGear; 
294  217 
begin 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

218 
tmp:= GearsList; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

219 
ptmp:= GearsList; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

220 
while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

221 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

222 
ptmp:= tmp; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

223 
tmp:= tmp^.NextGear 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

224 
end; 
3697  225 

3442  226 
if ptmp <> tmp then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

227 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

228 
Gear^.NextGear:= ptmp^.NextGear; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

229 
Gear^.PrevGear:= ptmp; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

230 
if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

231 
ptmp^.NextGear:= Gear 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

232 
end 
3442  233 
else 
234 
begin 

235 
Gear^.NextGear:= GearsList; 

236 
if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear; 

237 
GearsList:= Gear; 

238 
end; 

294  239 
end; 
240 

241 
procedure RemoveGearFromList(Gear: PGear); 

242 
begin 

351  243 
if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear; 
1505  244 
if Gear^.PrevGear <> nil then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

245 
Gear^.PrevGear^.NextGear:= Gear^.NextGear 
1505  246 
else 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

247 
GearsList:= Gear^.NextGear 
294  248 
end; 
249 

3443
14d12df0d363
finishing the gtHealthTag > vgtHealthTag, no segfaults and hogzombies no more, hopefully
sheepluva
parents:
3442
diff
changeset

250 
procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); 
14d12df0d363
finishing the gtHealthTag > vgtHealthTag, no segfaults and hogzombies no more, hopefully
sheepluva
parents:
3442
diff
changeset

251 
var tag: PVisualGear; 
14d12df0d363
finishing the gtHealthTag > vgtHealthTag, no segfaults and hogzombies no more, hopefully
sheepluva
parents:
3442
diff
changeset

252 
begin 
3459
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3453
diff
changeset

253 
tag:= AddVisualGear(hwRound(HHGear^.X), hwRound(HHGear^.Y), vgtHealthTag, dmg); 
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3453
diff
changeset

254 
if (tag <> nil) then 
3450  255 
tag^.Hedgehog:= PHedgehog(HHGear^.Hedgehog); // the tag needs the tag to determine the text color 
3443
14d12df0d363
finishing the gtHealthTag > vgtHealthTag, no segfaults and hogzombies no more, hopefully
sheepluva
parents:
3442
diff
changeset

256 
AllInactive:= false; 
14d12df0d363
finishing the gtHealthTag > vgtHealthTag, no segfaults and hogzombies no more, hopefully
sheepluva
parents:
3442
diff
changeset

257 
HHGear^.Active:= true; 
14d12df0d363
finishing the gtHealthTag > vgtHealthTag, no segfaults and hogzombies no more, hopefully
sheepluva
parents:
3442
diff
changeset

258 
end; 
14d12df0d363
finishing the gtHealthTag > vgtHealthTag, no segfaults and hogzombies no more, hopefully
sheepluva
parents:
3442
diff
changeset

259 

371  260 
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; 
79  261 
const Counter: Longword = 0; 
2695  262 
var gear: PGear; 
4  263 
begin 
79  264 
inc(Counter); 
1495  265 
{$IFDEF DEBUGFILE} 
3337  266 
AddFileLog('AddGear: #' + inttostr(Counter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); 
1495  267 
{$ENDIF} 
268 

2695  269 
New(gear); 
270 
FillChar(gear^, sizeof(TGear), 0); 

271 
gear^.X:= int2hwFloat(X); 

272 
gear^.Y:= int2hwFloat(Y); 

273 
gear^.Kind := Kind; 

274 
gear^.State:= State; 

275 
gear^.Active:= true; 

276 
gear^.dX:= dX; 

277 
gear^.dY:= dY; 

278 
gear^.doStep:= doStepHandlers[Kind]; 

279 
gear^.CollisionIndex:= 1; 

280 
gear^.Timer:= Timer; 

281 
gear^.Z:= cUsualZ; 

282 
gear^.FlightTime:= 0; 

283 
gear^.uid:= Counter; 

2745  284 
gear^.SoundChannel:= 1; 
3094
97c8406acc85
making collision/impact sounds a gear property + adding random melon+hellish sound, feel free to hate me :D
sheepluva
parents:
3086
diff
changeset

285 
gear^.ImpactSound:= sndNone; 
3136  286 
gear^.nImpactSounds:= 0; 
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
503
diff
changeset

287 

4  288 
if CurrentTeam <> nil then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

289 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

290 
gear^.Hedgehog:= CurrentHedgehog; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

291 
gear^.IntersectGear:= CurrentHedgehog^.Gear 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

292 
end; 
802
ed5450a89b96
Start implementing 'visual gears'  gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
789
diff
changeset

293 

4  294 
case Kind of 
4168  295 
gtBomb, 
3382  296 
gtClusterBomb, 
297 
gtGasBomb: begin 

3094
97c8406acc85
making collision/impact sounds a gear property + adding random melon+hellish sound, feel free to hate me :D
sheepluva
parents:
3086
diff
changeset

298 
gear^.ImpactSound:= sndGrenadeImpact; 
3136  299 
gear^.nImpactSounds:= 1; 
3072
b18038b3a0f4
I don't know why I'm bothering. Sheepluva has a whole new approach in the works.
nemo
parents:
3065
diff
changeset

300 
gear^.AdvBounce:= 1; 
4299  301 
gear^.Radius:= 5; 
3475  302 
gear^.Elasticity:= _0_8; 
303 
gear^.Friction:= _0_8; 

2695  304 
gear^.RenderTimer:= true; 
305 
if gear^.Timer = 0 then gear^.Timer:= 3000 

4  306 
end; 
1261  307 
gtWatermelon: begin 
3094
97c8406acc85
making collision/impact sounds a gear property + adding random melon+hellish sound, feel free to hate me :D
sheepluva
parents:
3086
diff
changeset

308 
gear^.ImpactSound:= sndMelonImpact; 
3136  309 
gear^.nImpactSounds:= 1; 
3072
b18038b3a0f4
I don't know why I'm bothering. Sheepluva has a whole new approach in the works.
nemo
parents:
3065
diff
changeset

310 
gear^.AdvBounce:= 1; 
4299  311 
gear^.Radius:= 6; 
2695  312 
gear^.Elasticity:= _0_8; 
313 
gear^.Friction:= _0_995; 

314 
gear^.RenderTimer:= true; 

315 
if gear^.Timer = 0 then gear^.Timer:= 3000 

1261  316 
end; 
4  317 
gtHedgehog: begin 
3072
b18038b3a0f4
I don't know why I'm bothering. Sheepluva has a whole new approach in the works.
nemo
parents:
3065
diff
changeset

318 
gear^.AdvBounce:= 1; 
2695  319 
gear^.Radius:= cHHRadius; 
320 
gear^.Elasticity:= _0_35; 

321 
gear^.Friction:= _0_999; 

322 
gear^.Angle:= cMaxAngle div 2; 

323 
gear^.Z:= cHHZ; 

3768  324 
if (GameFlags and gfAISurvival) <> 0 then 
325 
if PHedgehog(gear^.Hedgehog)^.BotLevel > 0 then 

326 
PHedgehog(gear^.Hedgehog)^.Effects[heResurrectable] := true; 

4  327 
end; 
4168  328 
gtShell: begin 
2695  329 
gear^.Radius:= 4; 
4  330 
end; 
331 
gtGrave: begin 

3094
97c8406acc85
making collision/impact sounds a gear property + adding random melon+hellish sound, feel free to hate me :D
sheepluva
parents:
3086
diff
changeset

332 
gear^.ImpactSound:= sndGraveImpact; 
3136  333 
gear^.nImpactSounds:= 1; 
2695  334 
gear^.Radius:= 10; 
335 
gear^.Elasticity:= _0_6; 

4  336 
end; 
3080  337 
gtBee: begin 
2695  338 
gear^.Radius:= 5; 
339 
gear^.Timer:= 500; 

340 
gear^.RenderTimer:= true; 

3039  341 
gear^.Elasticity:= _0_9; 
342 
gear^.Tag:= getRandom(32); 

4  343 
end; 
344 
gtShotgunShot: begin 

2695  345 
gear^.Timer:= 900; 
346 
gear^.Radius:= 2 

4  347 
end; 
348 
gtPickHammer: begin 

2695  349 
gear^.Radius:= 10; 
350 
gear^.Timer:= 4000 

4  351 
end; 
3720  352 
gtHammerHit: begin 
353 
gear^.Radius:= 8; 

354 
gear^.Timer:= 125 

355 
end; 

4  356 
gtRope: begin 
2695  357 
gear^.Radius:= 3; 
358 
gear^.Friction:= _450; 

4  359 
RopePoints.Count:= 0; 
360 
end; 

10  361 
gtMine: begin 
2882  362 
gear^.Health:= 10; 
2695  363 
gear^.State:= gear^.State or gstMoving; 
364 
gear^.Radius:= 2; 

365 
gear^.Elasticity:= _0_55; 

366 
gear^.Friction:= _0_995; 

2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2028
diff
changeset

367 
if cMinesTime < 0 then 
4248  368 
gear^.Timer:= getrandom(51)*100 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2028
diff
changeset

369 
else 
4248  370 
gear^.Timer:= cMinesTime*1000; 
10  371 
end; 
3710  372 
gtSMine: begin 
373 
gear^.Health:= 10; 

374 
gear^.State:= gear^.State or gstMoving; 

375 
gear^.Radius:= 2; 

376 
gear^.Elasticity:= _0_55; 

377 
gear^.Friction:= _0_995; 

378 
gear^.Timer:= 500; 

379 
end; 

14
81f125629b25
 Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset

380 
gtCase: begin 
3094
97c8406acc85
making collision/impact sounds a gear property + adding random melon+hellish sound, feel free to hate me :D
sheepluva
parents:
3086
diff
changeset

381 
gear^.ImpactSound:= sndGraveImpact; 
3136  382 
gear^.nImpactSounds:= 1; 
2695  383 
gear^.Radius:= 16; 
384 
gear^.Elasticity:= _0_3 

14
81f125629b25
 Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
10
diff
changeset

385 
end; 
2911  386 
gtExplosives: begin 
3094
97c8406acc85
making collision/impact sounds a gear property + adding random melon+hellish sound, feel free to hate me :D
sheepluva
parents:
3086
diff
changeset

387 
gear^.ImpactSound:= sndGrenadeImpact; 
3136  388 
gear^.nImpactSounds:= 1; 
2911  389 
gear^.Radius:= 16; 
2933  390 
gear^.Elasticity:= _0_4; 
2938  391 
gear^.Friction:= _0_995; 
2911  392 
gear^.Health:= cBarrelHealth 
393 
end; 

37  394 
gtDEagleShot: begin 
2695  395 
gear^.Radius:= 1; 
396 
gear^.Health:= 50 

37  397 
end; 
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset

398 
gtSniperRifleShot: begin 
2695  399 
gear^.Radius:= 1; 
400 
gear^.Health:= 50 

2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset

401 
end; 
39  402 
gtDynamite: begin 
2695  403 
gear^.Radius:= 3; 
404 
gear^.Elasticity:= _0_55; 

405 
gear^.Friction:= _0_03; 

406 
gear^.Timer:= 5000; 

39  407 
end; 
2204
526f8165acce
Smaxx' idea of timers, reworked just a tad. Might need variable for offset, but seems ok for now
nemo
parents:
2186
diff
changeset

408 
gtCluster: begin 
2695  409 
gear^.Radius:= 2; 
410 
gear^.RenderTimer:= true 

2204
526f8165acce
Smaxx' idea of timers, reworked just a tad. Might need variable for offset, but seems ok for now
nemo
parents:
2186
diff
changeset

411 
end; 
2695  412 
gtShover: gear^.Radius:= 20; 
79  413 
gtFlame: begin 
2695  414 
gear^.Tag:= GetRandom(32); 
415 
gear^.Radius:= 1; 

416 
gear^.Health:= 5; 

417 
if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

418 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

419 
gear^.dY:= (getrandom  _0_8) * _0_03; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

420 
gear^.dX:= (getrandom  _0_5) * _0_4 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

421 
end 
79  422 
end; 
82  423 
gtFirePunch: begin 
2695  424 
gear^.Radius:= 15; 
425 
gear^.Tag:= Y 

82  426 
end; 
302  427 
gtAirBomb: begin 
2695  428 
gear^.Radius:= 5; 
302  429 
end; 
430 
gtBlowTorch: begin 

2695  431 
gear^.Radius:= cHHRadius + cBlowTorchC; 
432 
gear^.Timer:= 7500 

302  433 
end; 
540  434 
gtSwitcher: begin 
2695  435 
gear^.Z:= cCurrHHZ 
540  436 
end; 
593  437 
gtTarget: begin 
3271  438 
gear^.ImpactSound:= sndGrenadeImpact; 
439 
gear^.nImpactSounds:= 1; 

2695  440 
gear^.Radius:= 10; 
441 
gear^.Elasticity:= _0_3; 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

442 
gear^.Timer:= 0 
593  443 
end; 
924  444 
gtMortar: begin 
2695  445 
gear^.Radius:= 4; 
446 
gear^.Elasticity:= _0_2; 

447 
gear^.Friction:= _0_08 

924  448 
end; 
2695  449 
gtWhip: gear^.Radius:= 20; 
3717  450 
gtHammer: gear^.Radius:= 20; 
984  451 
gtKamikaze: begin 
2695  452 
gear^.Health:= 2048; 
453 
gear^.Radius:= 20 

984  454 
end; 
1089  455 
gtCake: begin 
2695  456 
gear^.Health:= 2048; 
457 
gear^.Radius:= 7; 

458 
gear^.Z:= cOnHHZ; 

459 
gear^.RenderTimer:= true; 

3508
a7ca07614a2d
correct cake sitdown animation so that it doesn't sit down in midair anymore
sheepluva
parents:
3499
diff
changeset

460 
gear^.DirAngle:= 90 * hwSign(Gear^.dX); 
2695  461 
if not dX.isNegative then gear^.Angle:= 1 else gear^.Angle:= 3 
1089  462 
end; 
1263  463 
gtHellishBomb: begin 
3136  464 
gear^.ImpactSound:= sndHellishImpact1; 
465 
gear^.nImpactSounds:= 4; 

3072
b18038b3a0f4
I don't know why I'm bothering. Sheepluva has a whole new approach in the works.
nemo
parents:
3065
diff
changeset

466 
gear^.AdvBounce:= 1; 
2695  467 
gear^.Radius:= 4; 
468 
gear^.Elasticity:= _0_5; 

469 
gear^.Friction:= _0_96; 

470 
gear^.RenderTimer:= true; 

471 
gear^.Timer:= 5000 

1263  472 
end; 
1573  473 
gtDrill: begin 
2695  474 
gear^.Timer:= 5000; 
475 
gear^.Radius:= 4 

1573  476 
end; 
1601  477 
gtBall: begin 
3094
97c8406acc85
making collision/impact sounds a gear property + adding random melon+hellish sound, feel free to hate me :D
sheepluva
parents:
3086
diff
changeset

478 
gear^.ImpactSound:= sndGrenadeImpact; 
3136  479 
gear^.nImpactSounds:= 1; 
3072
b18038b3a0f4
I don't know why I'm bothering. Sheepluva has a whole new approach in the works.
nemo
parents:
3065
diff
changeset

480 
gear^.AdvBounce:= 1; 
2695  481 
gear^.Radius:= 5; 
482 
gear^.Tag:= random(8); 

483 
gear^.Timer:= 5000; 

484 
gear^.Elasticity:= _0_7; 

485 
gear^.Friction:= _0_995; 

1601  486 
end; 
487 
gtBallgun: begin 

2695  488 
gear^.Timer:= 5001; 
1601  489 
end; 
1689  490 
gtRCPlane: begin 
2695  491 
gear^.Timer:= 15000; 
492 
gear^.Health:= 3; 

493 
gear^.Radius:= 8 

1689  494 
end; 
2177
c045698e044f
Initial attempt at jetpack. Pluses, more like lunar lander (takes fall damage). Minuses, can't seem to cancel it or use alt weapon
nemo
parents:
2168
diff
changeset

495 
gtJetpack: begin 
2695  496 
gear^.Health:= 2000; 
4260
472fd2fc1f31
Also switch saucer from updating every N ticks to updating asneeded.
nemo
parents:
4258
diff
changeset

497 
gear^.Damage:= 100 
2177
c045698e044f
Initial attempt at jetpack. Pluses, more like lunar lander (takes fall damage). Minuses, can't seem to cancel it or use alt weapon
nemo
parents:
2168
diff
changeset

498 
end; 
3697  499 
gtMolotov: begin 
2968
f59631c3c1c0
Fix iluvu flag (indexed), shrink molotov radius a bit to try and reduce fail
nemo
parents:
2964
diff
changeset

500 
gear^.Radius:= 6; 
2488  501 
end; 
2983  502 
gtBirdy: begin 
503 
gear^.Radius:= 16; // todo: check 

3149  504 
gear^.Timer:= 0; 
3115  505 
gear^.Health := 2000; 
3065  506 
gear^.FlightTime := 2; 
2983  507 
end; 
3697  508 
gtEgg: begin 
3065  509 
gear^.Radius:= 4; 
510 
gear^.Elasticity:= _0_6; 

511 
gear^.Friction:= _0_96; 

512 
if gear^.Timer = 0 then gear^.Timer:= 3000 

513 
end; 

3342
b4f01613dcd7
Some initial stubs for portal just so Tiy will quit nagging. Also let folks know what approximation of physics I plan to try, here.
nemo
parents:
3337
diff
changeset

514 
gtPortal: begin 
b4f01613dcd7
Some initial stubs for portal just so Tiy will quit nagging. Also let folks know what approximation of physics I plan to try, here.
nemo
parents:
3337
diff
changeset

515 
gear^.ImpactSound:= sndMelonImpact; 
b4f01613dcd7
Some initial stubs for portal just so Tiy will quit nagging. Also let folks know what approximation of physics I plan to try, here.
nemo
parents:
3337
diff
changeset

516 
gear^.nImpactSounds:= 1; 
b4f01613dcd7
Some initial stubs for portal just so Tiy will quit nagging. Also let folks know what approximation of physics I plan to try, here.
nemo
parents:
3337
diff
changeset

517 
gear^.AdvBounce:= 0; 
b4f01613dcd7
Some initial stubs for portal just so Tiy will quit nagging. Also let folks know what approximation of physics I plan to try, here.
nemo
parents:
3337
diff
changeset

518 
gear^.Radius:= 16; 
3388
ab9352a4ddcc
Fix portal graphic name, continuing work on portal movement
nemo
parents:
3387
diff
changeset

519 
gear^.Tag:= 0; 
3428  520 
gear^.Timer:= 15000; 
521 
gear^.RenderTimer:= false; 

522 
gear^.Health:= 100; 

3342
b4f01613dcd7
Some initial stubs for portal just so Tiy will quit nagging. Also let folks know what approximation of physics I plan to try, here.
nemo
parents:
3337
diff
changeset

523 
end; 
3350  524 
gtPiano: begin 
525 
gear^.Radius:= 32 

526 
end; 

3384  527 
gtSineGunShot: begin 
528 
gear^.Radius:= 5; 

529 
gear^.Health:= 6000; 

530 
end; 

3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

531 
gtFlamethrower: begin 
3485  532 
gear^.Tag:= 10; 
533 
gear^.Timer:= 10; 

534 
gear^.Health:= 500; 

4258  535 
gear^.Damage:= 100; 
3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

536 
end; 
3712  537 
gtPoisonCloud: begin 
538 
gear^.Timer:= 5000; 

3976  539 
gear^.dY:= int2hwfloat(4 + longint(getRandom(8))) / 1000; 
3712  540 
end; 
3963
6090d2a2472e
New Weapon: Resurrector (TODO: ammo icon + sprites)
Tobias Neumann <mail@tobiasneumann.eu>
parents:
3957
diff
changeset

541 
gtResurrector: begin 
6090d2a2472e
New Weapon: Resurrector (TODO: ammo icon + sprites)
Tobias Neumann <mail@tobiasneumann.eu>
parents:
3957
diff
changeset

542 
gear^.Radius := 100; 
4265
039b08012887
distribute health evenly amongst graves instead of randomly  avoid situation where a grave stays dead
nemo
parents:
4260
diff
changeset

543 
gear^.Tag := 0 
3963
6090d2a2472e
New Weapon: Resurrector (TODO: ammo icon + sprites)
Tobias Neumann <mail@tobiasneumann.eu>
parents:
3957
diff
changeset

544 
end; 
4153
6bd94e4c5d65
2 more variables to control water rise and health loss during sudden death.
henek
parents:
4148
diff
changeset

545 
gtWaterUp: begin 
6bd94e4c5d65
2 more variables to control water rise and health loss during sudden death.
henek
parents:
4148
diff
changeset

546 
gear^.Tag := 47; 
6bd94e4c5d65
2 more variables to control water rise and health loss during sudden death.
henek
parents:
4148
diff
changeset

547 
end; 
3963
6090d2a2472e
New Weapon: Resurrector (TODO: ammo icon + sprites)
Tobias Neumann <mail@tobiasneumann.eu>
parents:
3957
diff
changeset

548 
end; 
6090d2a2472e
New Weapon: Resurrector (TODO: ammo icon + sprites)
Tobias Neumann <mail@tobiasneumann.eu>
parents:
3957
diff
changeset

549 

2695  550 
InsertGearToList(gear); 
551 
AddGear:= gear; 

2786  552 

2792  553 
ScriptCall('onGearAdd', gear^.uid); 
4  554 
end; 
555 

1515  556 
procedure DeleteGear(Gear: PGear); 
48  557 
var team: PTeam; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

558 
t,i: Longword; 
2760
420fe0344e5f
... or. just move the king check to after the gear nil
nemo
parents:
2759
diff
changeset

559 
k: boolean; 
4  560 
begin 
2786  561 

2792  562 
ScriptCall('onGearDelete', gear^.uid); 
2786  563 

503  564 
DeleteCI(Gear); 
762  565 

566 
if Gear^.Tex <> nil then 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

567 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

568 
FreeTexture(Gear^.Tex); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

569 
Gear^.Tex:= nil 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

570 
end; 
762  571 

3422
41ae3c48faa0
* some changes/cleanups to portal, still much to do :/ * reverted nemo's temporary loop fix * notice: small loops possible again, so take care :P, bigger onces should be interrupted
sheepluva
parents:
3415
diff
changeset

572 
// make sure that portals have their link removed before deletion 
3428  573 
if (Gear^.Kind = gtPortal) then 
3432
83cef0f08a86
* get rid of some fpc hints (redundant/superfluous includes)
sheepluva
parents:
3429
diff
changeset

574 
begin 
3428  575 
if (Gear^.IntersectGear <> nil) then 
3472
b1832a3761e6
portallinkbugfix: make sure deleted portals don't reset links other than those to themselves
sheepluva
parents:
3471
diff
changeset

576 
if (Gear^.IntersectGear^.IntersectGear = Gear) then 
b1832a3761e6
portallinkbugfix: make sure deleted portals don't reset links other than those to themselves
sheepluva
parents:
3471
diff
changeset

577 
Gear^.IntersectGear^.IntersectGear:= nil; 
3432
83cef0f08a86
* get rid of some fpc hints (redundant/superfluous includes)
sheepluva
parents:
3429
diff
changeset

578 
end 
3422
41ae3c48faa0
* some changes/cleanups to portal, still much to do :/ * reverted nemo's temporary loop fix * notice: small loops possible again, so take care :P, bigger onces should be interrupted
sheepluva
parents:
3415
diff
changeset

579 
else if Gear^.Kind = gtHedgehog then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

580 
if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

581 
begin 
3894  582 
Gear^.Message:= gmDestroy; 
583 
CurAmmoGear^.Message:= gmDestroy; 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

584 
exit 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

585 
end 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

586 
else 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

587 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

588 
if (hwRound(Gear^.Y) >= cWaterLine) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

589 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

590 
t:= max(Gear^.Damage, Gear^.Health); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

591 
Gear^.Damage:= t; 
3399  592 
if (cWaterOpacity < $FF) and (hwRound(Gear^.Y) < cWaterLine + 256) then 
3461
0781275649e9
revert the restoration of nonvgt health gears. desyncs continued with it, and furthermore, occur in r3489 too
nemo
parents:
3460
diff
changeset

593 
spawnHealthTagForHH(Gear, t); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

594 
uStats.HedgehogDamaged(Gear) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

595 
end; 
2376  596 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

597 
team:= PHedgehog(Gear^.Hedgehog)^.Team; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

598 
if CurrentHedgehog^.Gear = Gear then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

599 
FreeActionsList; // to avoid ThinkThread on drawned gear 
2376  600 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

601 
PHedgehog(Gear^.Hedgehog)^.Gear:= nil; 
2726  602 
if PHedgehog(Gear^.Hedgehog)^.King then 
2758
033aa644578f
Add one king per team instead of clan, kill off clan if all kings are dead. untested.
nemo
parents:
2745
diff
changeset

603 
begin 
033aa644578f
Add one king per team instead of clan, kill off clan if all kings are dead. untested.
nemo
parents:
2745
diff
changeset

604 
// are there any other kings left? Just doing nil check. Presumably a mortally wounded king will get reaped soon enough 
2760
420fe0344e5f
... or. just move the king check to after the gear nil
nemo
parents:
2759
diff
changeset

605 
k:= false; 
2726  606 
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do 
2760
420fe0344e5f
... or. just move the king check to after the gear nil
nemo
parents:
2759
diff
changeset

607 
if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then k:= true; 
420fe0344e5f
... or. just move the king check to after the gear nil
nemo
parents:
2759
diff
changeset

608 
if not k then 
2758
033aa644578f
Add one king per team instead of clan, kill off clan if all kings are dead. untested.
nemo
parents:
2745
diff
changeset

609 
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do 
4037  610 
begin 
611 
team^.Clan^.Teams[i]^.hasGone:= true; 

2758
033aa644578f
Add one king per team instead of clan, kill off clan if all kings are dead. untested.
nemo
parents:
2745
diff
changeset

612 
TeamGoneEffect(team^.Clan^.Teams[i]^) 
4037  613 
end 
2758
033aa644578f
Add one king per team instead of clan, kill off clan if all kings are dead. untested.
nemo
parents:
2745
diff
changeset

614 
end; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

615 
inc(KilledHHs); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

616 
RecountTeamHealth(team) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

617 
end; 
1495  618 
{$IFDEF DEBUGFILE} 
3337  619 
with Gear^ do AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); 
1495  620 
{$ENDIF} 
621 

82  622 
if CurAmmoGear = Gear then CurAmmoGear:= nil; 
4  623 
if FollowGear = Gear then FollowGear:= nil; 
294  624 
RemoveGearFromList(Gear); 
1515  625 
Dispose(Gear) 
4  626 
end; 
627 

628 
function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs 

629 
var Gear: PGear; 

1849  630 
dmg: LongInt; 
4  631 
begin 
351  632 
CheckNoDamage:= true; 
4  633 
Gear:= GearsList; 
634 
while Gear <> nil do 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

635 
begin 
4120
0aba28eb8e34
more button updates, wait for hogs in infinite attack mode stop moving before clearing their damage (just used an arbitrary small interval)
nemo
parents:
4111
diff
changeset

636 
if (Gear^.Kind = gtHedgehog) and (((GameFlags and gfInfAttack) = 0) or ((Gear^.dX.QWordValue < _0_000004.QWordValue) and (Gear^.dY.QWordValue < _0_000004.QWordValue))) then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

637 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

638 
if (not isInMultiShoot) then inc(Gear^.Damage, Gear^.Karma); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

639 
if (Gear^.Damage <> 0) and 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

640 
(not Gear^.Invulnerable) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

641 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

642 
CheckNoDamage:= false; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

643 
uStats.HedgehogDamaged(Gear); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

644 
dmg:= Gear^.Damage; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

645 
if Gear^.Health < dmg then 
3453  646 
begin 
647 
Gear^.Active:= true; 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

648 
Gear^.Health:= 0 
3453  649 
end 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

650 
else 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

651 
dec(Gear^.Health, dmg); 
351  652 

2017  653 
if (PHedgehog(Gear^.Hedgehog)^.Team = CurrentTeam) and 
2135
0b7972dfad01
Push karma application to end of round  should avoid problems w/ plane and kamikaze
nemo
parents:
2134
diff
changeset

654 
(Gear^.Damage <> Gear^.Karma) and 
2824
2d25e49bc2e8
Extra incentive to attack nonking hogs. If king loses his entourage, he loses 5hp per turn
nemo
parents:
2814
diff
changeset

655 
not PHedgehog(Gear^.Hedgehog)^.King and 
3135  656 
not PHedgehog(Gear^.Hedgehog)^.Effects[hePoisoned] and 
2017  657 
not SuddenDeathDmg then 
658 
Gear^.State:= Gear^.State or gstLoser; 

659 

3461
0781275649e9
revert the restoration of nonvgt health gears. desyncs continued with it, and furthermore, occur in r3489 too
nemo
parents:
3460
diff
changeset

660 
spawnHealthTagForHH(Gear, dmg); 
867  661 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

662 
RenderHealth(PHedgehog(Gear^.Hedgehog)^); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

663 
RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team); 
1505  664 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

665 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

666 
if (not isInMultiShoot) then Gear^.Karma:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

667 
Gear^.Damage:= 0 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

668 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

669 
Gear:= Gear^.NextGear 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

670 
end; 
4  671 
end; 
672 

1054  673 
procedure HealthMachine; 
674 
var Gear: PGear; 

2824
2d25e49bc2e8
Extra incentive to attack nonking hogs. If king loses his entourage, he loses 5hp per turn
nemo
parents:
2814
diff
changeset

675 
team: PTeam; 
2d25e49bc2e8
Extra incentive to attack nonking hogs. If king loses his entourage, he loses 5hp per turn
nemo
parents:
2814
diff
changeset

676 
i: LongWord; 
2d25e49bc2e8
Extra incentive to attack nonking hogs. If king loses his entourage, he loses 5hp per turn
nemo
parents:
2814
diff
changeset

677 
flag: Boolean; 
3682  678 
tmp: LongWord; 
1054  679 
begin 
3682  680 
Gear:= GearsList; 
1054  681 

3682  682 
while Gear <> nil do 
683 
begin 

684 
if Gear^.Kind = gtHedgehog then 

685 
begin 

686 
tmp:= 0; 

3112  687 
if PHedgehog(Gear^.Hedgehog)^.Effects[hePoisoned] then 
4111  688 
begin 
3908
1429c303858d
Can't use cHealthDecrease here for these two 'cause it isn't a generic "do some damage to hog" flag, but is rather set when SD starts
nemo
parents:
3894
diff
changeset

689 
inc(tmp, ModifyDamage(5, Gear)); 
4111  690 
if (GameFlags and gfResetHealth) <> 0 then dec(PHedgehog(Gear^.Hedgehog)^.InitialHealth) // does not need a minimum check since <= 1 basically disables it 
691 
end; 

4153
6bd94e4c5d65
2 more variables to control water rise and health loss during sudden death.
henek
parents:
4148
diff
changeset

692 
if (TotalRounds > cSuddenDTurns  1) then 
6bd94e4c5d65
2 more variables to control water rise and health loss during sudden death.
henek
parents:
4148
diff
changeset

693 
begin 
6bd94e4c5d65
2 more variables to control water rise and health loss during sudden death.
henek
parents:
4148
diff
changeset

694 
inc(tmp, cHealthDecrease); 
6bd94e4c5d65
2 more variables to control water rise and health loss during sudden death.
henek
parents:
4148
diff
changeset

695 
if (GameFlags and gfResetHealth) <> 0 then dec(PHedgehog(Gear^.Hedgehog)^.InitialHealth, cHealthDecrease) 
6bd94e4c5d65
2 more variables to control water rise and health loss during sudden death.
henek
parents:
4148
diff
changeset

696 
end; 
3109
06c089cb739c
Reduce turns to 1 to allow processing health machine on first turn. Needs testing with Sudden Death set to 0
nemo
parents:
3107
diff
changeset

697 
if PHedgehog(Gear^.Hedgehog)^.King then 
06c089cb739c
Reduce turns to 1 to allow processing health machine on first turn. Needs testing with Sudden Death set to 0
nemo
parents:
3107
diff
changeset

698 
begin 
06c089cb739c
Reduce turns to 1 to allow processing health machine on first turn. Needs testing with Sudden Death set to 0
nemo
parents:
3107
diff
changeset

699 
flag:= false; 
06c089cb739c
Reduce turns to 1 to allow processing health machine on first turn. Needs testing with Sudden Death set to 0
nemo
parents:
3107
diff
changeset

700 
team:= PHedgehog(Gear^.Hedgehog)^.Team; 
06c089cb739c
Reduce turns to 1 to allow processing health machine on first turn. Needs testing with Sudden Death set to 0
nemo
parents:
3107
diff
changeset

701 
for i:= 0 to Pred(team^.HedgehogsNumber) do 
3697  702 
if (team^.Hedgehogs[i].Gear <> nil) and 
703 
(not team^.Hedgehogs[i].King) and 

704 
(team^.Hedgehogs[i].Gear^.Health > team^.Hedgehogs[i].Gear^.Damage) 

3109
06c089cb739c
Reduce turns to 1 to allow processing health machine on first turn. Needs testing with Sudden Death set to 0
nemo
parents:
3107
diff
changeset

705 
then flag:= true; 
4111  706 
if not flag then 
707 
begin 

708 
inc(tmp, 5); 

709 
if (GameFlags and gfResetHealth) <> 0 then dec(PHedgehog(Gear^.Hedgehog)^.InitialHealth, 5) 

710 
end 

3109
06c089cb739c
Reduce turns to 1 to allow processing health machine on first turn. Needs testing with Sudden Death set to 0
nemo
parents:
3107
diff
changeset

711 
end; 
3845
90034acb2e43
Untested fix of r3672  should avoid hogs dying due to multiple health machine sources, and inappropriate application of karma/vampirism to these.
nemo
parents:
3836
diff
changeset

712 
if tmp > 0 then 
90034acb2e43
Untested fix of r3672  should avoid hogs dying due to multiple health machine sources, and inappropriate application of karma/vampirism to these.
nemo
parents:
3836
diff
changeset

713 
begin 
90034acb2e43
Untested fix of r3672  should avoid hogs dying due to multiple health machine sources, and inappropriate application of karma/vampirism to these.
nemo
parents:
3836
diff
changeset

714 
inc(Gear^.Damage, min(tmp, max(0,Gear^.Health  1  Gear^.Damage))); 
90034acb2e43
Untested fix of r3672  should avoid hogs dying due to multiple health machine sources, and inappropriate application of karma/vampirism to these.
nemo
parents:
3836
diff
changeset

715 
HHHurt(Gear^.Hedgehog, dsPoison); 
90034acb2e43
Untested fix of r3672  should avoid hogs dying due to multiple health machine sources, and inappropriate application of karma/vampirism to these.
nemo
parents:
3836
diff
changeset

716 
end 
3682  717 
end; 
1054  718 

3682  719 
Gear:= Gear^.NextGear 
720 
end; 

1054  721 
end; 
722 

4  723 
procedure ProcessGears; 
614  724 
const delay: LongWord = 0; 
3949
4c4c0a2507cc
Add the standard delay (1.25 seconds) between attacks on inf attack mode, as well as checks for damage and win.
nemo
parents:
3946
diff
changeset

725 
delay2: LongWord = 0; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

726 
step: (stDelay, stChDmg, stSweep, stTurnReact, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

727 
stAfterDelay, stChWin, stWater, stChWin2, stHealth, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

728 
stSpawn, stNTurn) = stDelay; 
4  729 
var Gear, t: PGear; 
4207
31e77dcf18fe
better end of turn in infinite attack mode. NEEDS TESTING.
nemo
parents:
4198
diff
changeset

730 
i, AliveCount: LongInt; 
3331  731 
s: shortstring; 
4  732 
begin 
868  733 
PrvInactive:= AllInactive; 
4  734 
AllInactive:= true; 
1495  735 

2940  736 
if (StepSoundTimer > 0) and (StepSoundChannel < 0) then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

737 
StepSoundChannel:= LoopSound(sndSteps) 
2940  738 
else if (StepSoundTimer = 0) and (StepSoundChannel > 1) then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

739 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

740 
StopSound(StepSoundChannel); 
2993
d83edb74e92d
Remove animation on jumping/resuming walk, only leave it in on weapon switch
nemo
parents:
2991
diff
changeset

741 
StepSoundChannel:= 1 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

742 
end; 
2940  743 

744 
if StepSoundTimer > 0 then 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

745 
dec(StepSoundTimer, 1); 
2940  746 

4  747 
t:= GearsList; 
1054  748 
while t <> nil do 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

749 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

750 
Gear:= t; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

751 
t:= Gear^.NextGear; 
3123  752 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

753 
if Gear^.Active then 
2204
526f8165acce
Smaxx' idea of timers, reworked just a tad. Might need variable for offset, but seems ok for now
nemo
parents:
2186
diff
changeset

754 
begin 
526f8165acce
Smaxx' idea of timers, reworked just a tad. Might need variable for offset, but seems ok for now
nemo
parents:
2186
diff
changeset

755 
if Gear^.RenderTimer and (Gear^.Timer > 500) and ((Gear^.Timer mod 1000) = 0) then 
526f8165acce
Smaxx' idea of timers, reworked just a tad. Might need variable for offset, but seems ok for now
nemo
parents:
2186
diff
changeset

756 
begin 
2376  757 
if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); 
2619  758 
Gear^.Tex:= RenderStringTex(inttostr(Gear^.Timer div 1000), cWhiteColor, fntSmall); 
2204
526f8165acce
Smaxx' idea of timers, reworked just a tad. Might need variable for offset, but seems ok for now
nemo
parents:
2186
diff
changeset

759 
end; 
526f8165acce
Smaxx' idea of timers, reworked just a tad. Might need variable for offset, but seems ok for now
nemo
parents:
2186
diff
changeset

760 
Gear^.doStep(Gear); 
3848  761 
// might be useful later 
762 
//ScriptCall('OnGearStep', Gear^.uid); 

2204
526f8165acce
Smaxx' idea of timers, reworked just a tad. Might need variable for offset, but seems ok for now
nemo
parents:
2186
diff
changeset

763 
end 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

764 
end; 
89  765 

4  766 
if AllInactive then 
1343  767 
case step of 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

768 
stDelay: begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

769 
if delay = 0 then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

770 
delay:= cInactDelay 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

771 
else 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

772 
dec(delay); 
614  773 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

774 
if delay = 0 then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

775 
inc(step) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

776 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

777 
stChDmg: if CheckNoDamage then inc(step) else step:= stDelay; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

778 
stSweep: if SweepDirty then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

779 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

780 
SetAllToActive; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

781 
step:= stChDmg 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

782 
end else inc(step); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

783 
stTurnReact: begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

784 
if (not bBetweenTurns) and (not isInMultiShoot) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

785 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

786 
uStats.TurnReaction; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

787 
inc(step) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

788 
end else 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

789 
inc(step, 2); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

790 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

791 
stAfterDelay: begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

792 
if delay = 0 then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

793 
delay:= cInactDelay 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

794 
else 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

795 
dec(delay); 
815  796 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

797 
if delay = 0 then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

798 
inc(step) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

799 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

800 
stChWin: begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

801 
CheckForWin; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

802 
inc(step) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

803 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

804 
stWater: if (not bBetweenTurns) and (not isInMultiShoot) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

805 
begin 
3331  806 
if TotalRounds = cSuddenDTurns + 1 then bWaterRising:= true; 
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset

807 

4153
6bd94e4c5d65
2 more variables to control water rise and health loss during sudden death.
henek
parents:
4148
diff
changeset

808 
if bWaterRising and (cWaterRise > 0) then 
6bd94e4c5d65
2 more variables to control water rise and health loss during sudden death.
henek
parents:
4148
diff
changeset

809 
AddGear(0, 0, gtWaterUp, 0, _0, _0, 0)^.Tag:= cWaterRise; 
1055
9af540b23409
Water rises after 25 mins of round, health is decreased after 20 mins
unc0rr
parents:
1054
diff
changeset

810 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

811 
inc(step) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

812 
end else inc(step); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

813 
stChWin2: begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

814 
CheckForWin; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

815 
inc(step) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

816 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

817 
stHealth: begin 
4215
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

818 
if (cWaterRise <> 0) or (cHealthDecrease <> 0) then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

819 
begin 
4215
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

820 
if (TotalRounds = cSuddenDTurns) and not SuddenDeathDmg and not isInMultiShoot then 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

821 
begin 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

822 
SuddenDeathDmg:= true; 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

823 
AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState); 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

824 
playSound(sndSuddenDeath) 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

825 
end 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

826 
else if (TotalRounds < cSuddenDTurns) and not isInMultiShoot then 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

827 
begin 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

828 
i:= cSuddenDTurns  TotalRounds; 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

829 
s:= inttostr(i); 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

830 
if i = 1 then 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

831 
AddCaption(trmsg[sidRoundSD], cWhiteColor, capgrpGameState) 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

832 
else if i in [2, 5, 10, 15, 20, 25, 50, 100] then 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

833 
AddCaption(Format(trmsg[sidRoundsSD], s), cWhiteColor, capgrpGameState); 
36632d5b8492
inactivate sudden death if both health decrease and water rise is 0 and lower sudden death turns to 50 again
Henek
parents:
4210
diff
changeset

834 
end; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

835 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

836 
if bBetweenTurns 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

837 
or isInMultiShoot 
3109
06c089cb739c
Reduce turns to 1 to allow processing health machine on first turn. Needs testing with Sudden Death set to 0
nemo
parents:
3107
diff
changeset

838 
or (TotalRounds = 1) then inc(step) 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

839 
else begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

840 
bBetweenTurns:= true; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

841 
HealthMachine; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

842 
step:= stChDmg 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

843 
end 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

844 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

845 
stSpawn: begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

846 
if not isInMultiShoot then SpawnBoxOfSmth; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

847 
inc(step) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

848 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

849 
stNTurn: begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

850 
if isInMultiShoot then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

851 
isInMultiShoot:= false 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

852 
else begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

853 
// delayed till after 0.9.12 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

854 
// reset to default zoom 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

855 
//ZoomValue:= ZoomDefault; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

856 
with CurrentHedgehog^ do 
3697  857 
if (Gear <> nil) 
2611  858 
and ((Gear^.State and gstAttacked) = 0) 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

859 
and (MultiShootAttacks > 0) then OnUsedAmmo(CurrentHedgehog^); 
3697  860 

3396
e5b3e5f2818e
More portal changes. Allows for a multishoot utility. Hopefully not breaking anything.
nemo
parents:
3390
diff
changeset

861 
EndTurnCleanup; 
2376  862 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

863 
FreeActionsList; // could send left, right and similar commands, so should be called before /nextturn 
1298  864 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

865 
ParseCommand('/nextturn', true); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

866 
SwitchHedgehog; 
1298  867 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

868 
AfterSwitchHedgehog; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

869 
bBetweenTurns:= false 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

870 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

871 
step:= Low(step) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

872 
end; 
3949
4c4c0a2507cc
Add the standard delay (1.25 seconds) between attacks on inf attack mode, as well as checks for damage and win.
nemo
parents:
3946
diff
changeset

873 
end 
4c4c0a2507cc
Add the standard delay (1.25 seconds) between attacks on inf attack mode, as well as checks for damage and win.
nemo
parents:
3946
diff
changeset

874 
else if ((GameFlags and gfInfAttack) <> 0) then 
4c4c0a2507cc
Add the standard delay (1.25 seconds) between attacks on inf attack mode, as well as checks for damage and win.
nemo
parents:
3946
diff
changeset

875 
begin 
4c4c0a2507cc
Add the standard delay (1.25 seconds) between attacks on inf attack mode, as well as checks for damage and win.
nemo
parents:
3946
diff
changeset

876 
if delay2 = 0 then 
3951
c9a63db3e603
Correct another bug in slot switching, adjust width of theme list, really truly fix reset of weps (I hope) should also fix infinite teleport bug in place hogs mode. Slow update of health to 5s for inf attack mode.
nemo
parents:
3949
diff
changeset

877 
delay2:= cInactDelay * 4 
3949
4c4c0a2507cc
Add the standard delay (1.25 seconds) between attacks on inf attack mode, as well as checks for damage and win.
nemo
parents:
3946
diff
changeset

878 
else 
3957  879 
begin 
3949
4c4c0a2507cc
Add the standard delay (1.25 seconds) between attacks on inf attack mode, as well as checks for damage and win.
nemo
parents:
3946
diff
changeset

880 
dec(delay2); 
4c4c0a2507cc
Add the standard delay (1.25 seconds) between attacks on inf attack mode, as well as checks for damage and win.
nemo
parents:
3946
diff
changeset

881 

3957  882 
if ((delay2 mod cInactDelay) = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then 
883 
CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and not gstAttacked; 

884 
if delay2 = 0 then 

885 
begin 

886 
SweepDirty; 

887 
CheckNoDamage; 

4207
31e77dcf18fe
better end of turn in infinite attack mode. NEEDS TESTING.
nemo
parents:
4198
diff
changeset

888 
AliveCount:= 0; // shorter version of check for win to allow typical step activity to proceed 
31e77dcf18fe
better end of turn in infinite attack mode. NEEDS TESTING.
nemo
parents:
4198
diff
changeset

889 
for i:= 0 to Pred(ClansCount) do 
31e77dcf18fe
better end of turn in infinite attack mode. NEEDS TESTING.
nemo
parents:
4198
diff
changeset

890 
if ClansArray[i]^.ClanHealth > 0 then inc(AliveCount); 
31e77dcf18fe
better end of turn in infinite attack mode. NEEDS TESTING.
nemo
parents:
4198
diff
changeset

891 
if (AliveCount <= 1) and ((GameFlags and gfOneClanMode) = 0) then 
31e77dcf18fe
better end of turn in infinite attack mode. NEEDS TESTING.
nemo
parents:
4198
diff
changeset

892 
begin 
31e77dcf18fe
better end of turn in infinite attack mode. NEEDS TESTING.
nemo
parents:
4198
diff
changeset

893 
step:= stChDmg; 
31e77dcf18fe
better end of turn in infinite attack mode. NEEDS TESTING.
nemo
parents:
4198
diff
changeset

894 
TurnTimeLeft:= 0 
31e77dcf18fe
better end of turn in infinite attack mode. NEEDS TESTING.
nemo
parents:
4198
diff
changeset

895 
end 
3957  896 
end 
3949
4c4c0a2507cc
Add the standard delay (1.25 seconds) between attacks on inf attack mode, as well as checks for damage and win.
nemo
parents:
3946
diff
changeset

897 
end 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

898 
end; 
15  899 

4  900 
if TurnTimeLeft > 0 then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

901 
if CurrentHedgehog^.Gear <> nil then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

902 
if ((CurrentHedgehog^.Gear^.State and gstAttacking) = 0) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

903 
and not isInMultiShoot then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

904 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

905 
if (TurnTimeLeft = 5000) 
4198  906 
and (cHedgehogTurnTime >= 10000) 
2770
851313907bcb
Decrease king buff from 150% bonus to 50% bonus, disable warning sound in placement mode
nemo
parents:
2762
diff
changeset

907 
and (not PlacingHogs) 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

908 
and (CurrentHedgehog^.Gear <> nil) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

909 
and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

910 
PlaySound(sndHurry, CurrentTeam^.voicepack); 
3799  911 
if ReadyTimeLeft > 0 then 
912 
begin 

913 
if ReadyTimeLeft = 2000 then 

914 
PlaySound(sndComeonthen, CurrentTeam^.voicepack); 

915 
dec(ReadyTimeLeft) 

916 
end 

917 
else 

918 
dec(TurnTimeLeft) 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

919 
end; 
351  920 

2621
956ff066f3a5
Fix desync when playing with AI via network, occuring in certain conditions
unc0rr
parents:
2619
diff
changeset

921 
if skipFlag then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

922 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

923 
TurnTimeLeft:= 0; 
3784
75aa91bea32b
Extend statistics collection (TeamKills, TurnSkips, TeamDamage)
burp
parents:
3775
diff
changeset

924 
skipFlag:= false; 
75aa91bea32b
Extend statistics collection (TeamKills, TurnSkips, TeamDamage)
burp
parents:
3775
diff
changeset

925 
inc(CurrentHedgehog^.Team^.stats.TurnSkips); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

926 
end; 
2621
956ff066f3a5
Fix desync when playing with AI via network, occuring in certain conditions
unc0rr
parents:
2619
diff
changeset

927 

2134  928 
if ((GameTicks and $FFFF) = $FFFF) then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

929 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

930 
if (not CurrentTeam^.ExtDriven) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

931 
SendIPCTimeInc; 
2134  932 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

933 
if (not CurrentTeam^.ExtDriven) or CurrentTeam^.hasGone then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

934 
inc(hiTicks) // we do not recieve a message for this 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

935 
end; 
656
6d6d9d7b1054
Fix network game bug caused by recent protocol changes
unc0rr
parents:
651
diff
changeset

936 

515  937 
inc(GameTicks) 
4  938 
end; 
939 

3396
e5b3e5f2818e
More portal changes. Allows for a multishoot utility. Hopefully not breaking anything.
nemo
parents:
3390
diff
changeset

940 
//Purpose, to reset all transient attributes toggled by a utility and clean up various gears and effects at end of turn 
1854  941 
//If any of these are set as permanent toggles in the frontend, that needs to be checked and skipped here. 
3396
e5b3e5f2818e
More portal changes. Allows for a multishoot utility. Hopefully not breaking anything.
nemo
parents:
3390
diff
changeset

942 
procedure EndTurnCleanup; 
1865
ebc6dfca60d4
 nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1863
diff
changeset

943 
var i: LongInt; 
3480
c4c3f3512404
Prevent all portal loops the guaranteed way, at least until sheepluva's tests yield something reliable.
nemo
parents:
3476
diff
changeset

944 
t: PGear; 
1849  945 
begin 
2221  946 
SpeechText:= ''; // in case it has not been consumed 
2017  947 

1895  948 
if (GameFlags and gfLowGravity) = 0 then 
3355
dc9e61e67484
cWindSpeed recalculation assumed GetRandom returns a value between 0.01.0 while in fact is in the 0.00.5 range; Halve cMaxWindSpeed to compensate.
palewolf
parents:
3350
diff
changeset

949 
cGravity:= cMaxWindSpeed * 2; 
1895  950 

2017  951 
if (GameFlags and gfVampiric) = 0 then 
952 
cVampiric:= false; 

953 

1849  954 
cDamageModifier:= _1; 
1895  955 

956 
if (GameFlags and gfLaserSight) = 0 then 

957 
cLaserSighting:= false; 

2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset

958 

41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset

959 
if (GameFlags and gfArtillery) = 0 then 
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset

960 
cArtillery:= false; 
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset

961 
// have to sweep *all* current team hedgehogs since it is theoretically possible if you have enough invulnerabilities and switch turns to make your entire team invulnerable 
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset

962 
if (CurrentTeam <> nil) then 
4099  963 
with CurrentTeam^ do 
964 
for i:= 0 to cMaxHHIndex do 

965 
with Hedgehogs[i] do 

966 
begin 

967 
if (SpeechGear <> nil) then 

968 
begin 

969 
DeleteVisualGear(SpeechGear); // remove to restore persisting beyond end of turn. Tiy says was too much of a gameplay issue 

970 
SpeechGear:= nil 

971 
end; 

2045
b0588498bc3a
 Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset

972 

4099  973 
if (Gear <> nil) then 
974 
begin 

975 
if (GameFlags and gfInvulnerable) = 0 then 

976 
Gear^.Invulnerable:= false; 

977 
end; 

978 
end; 

3480
c4c3f3512404
Prevent all portal loops the guaranteed way, at least until sheepluva's tests yield something reliable.
nemo
parents:
3476
diff
changeset

979 
t:= GearsList; 
c4c3f3512404
Prevent all portal loops the guaranteed way, at least until sheepluva's tests yield something reliable.
nemo
parents:
3476
diff
changeset

980 
while t <> nil do 
c4c3f3512404
Prevent all portal loops the guaranteed way, at least until sheepluva's tests yield something reliable.
nemo
parents:
3476
diff
changeset

981 
begin 
c4c3f3512404
Prevent all portal loops the guaranteed way, at least until sheepluva's tests yield something reliable.
nemo
parents:
3476
diff
changeset

982 
t^.PortalCounter:= 0; 
4101
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset

983 
if ((GameFlags and gfResetHealth) <> 0) and (t^.Kind = gtHedgehog) and (t^.Health < PHedgehog(t^.Hedgehog)^.InitialHealth) then 
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset

984 
begin 
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset

985 
t^.Health:= PHedgehog(t^.Hedgehog)^.InitialHealth; 
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset

986 
RenderHealth(PHedgehog(t^.Hedgehog)^); 
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset

987 
end; 
3480
c4c3f3512404
Prevent all portal loops the guaranteed way, at least until sheepluva's tests yield something reliable.
nemo
parents:
3476
diff
changeset

988 
t:= t^.NextGear 
3946
41e06b74c991
Enable resetting of weapons after each turn  useful in combination with a limited weaponset and unlimited attacks
nemo
parents:
3908
diff
changeset

989 
end; 
41e06b74c991
Enable resetting of weapons after each turn  useful in combination with a limited weaponset and unlimited attacks
nemo
parents:
3908
diff
changeset

990 

41e06b74c991
Enable resetting of weapons after each turn  useful in combination with a limited weaponset and unlimited attacks
nemo
parents:
3908
diff
changeset

991 
if (GameFlags and gfResetWeps) <> 0 then 
4099  992 
ResetWeapons; 
4101
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset

993 

4099  994 
if (GameFlags and gfResetHealth) <> 0 then 
4101
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset

995 
for i:= 0 to Pred(TeamsCount) do 
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset

996 
RecountTeamHealth(TeamsArray[i]) 
1849  997 
end; 
2045
b0588498bc3a
 Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset

998 

3682  999 
procedure ApplyDamage(Gear: PGear; Damage: Longword; Source: TDamageSource); 
2017  1000 
var s: shortstring; 
2428  1001 
vampDmg, tmpDmg, i: Longword; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1002 
vg: PVisualGear; 
2017  1003 
begin 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1004 
if (Gear^.Kind = gtHedgehog) and (Damage>=1) then 
2017  1005 
begin 
3682  1006 
HHHurt(Gear^.Hedgehog, Source); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1007 
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color); 
2067
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1008 
tmpDmg:= min(Damage, max(0,Gear^.HealthGear^.Damage)); 
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1009 
if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (tmpDmg >= 1) then 
2017  1010 
begin 
1011 
if cVampiric then 

1012 
begin 

2067
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1013 
vampDmg:= hwRound(int2hwFloat(tmpDmg)*_0_8); 
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1014 
if vampDmg >= 1 then 
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1015 
begin 
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1016 
// was considering pulsing on attack, Tiy thinks it should be permanent while in play 
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1017 
//CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstVampiric; 
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1018 
inc(CurrentHedgehog^.Gear^.Health,vampDmg); 
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1019 
str(vampDmg, s); 
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1020 
s:= '+' + s; 
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1021 
AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); 
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1022 
RenderHealth(CurrentHedgehog^); 
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1023 
RecountTeamHealth(CurrentHedgehog^.Team); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1024 
i:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1025 
while i < vampDmg do 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1026 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1027 
vg:= AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), vgtHealth); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1028 
if vg <> nil then vg^.Frame:= 10; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1029 
inc(i, 5); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1030 
end; 
2067
7524a783bd8c
use separate variable for vamp/karma calcs, move karma damage tag from point of damage origin to originating hedgehog at unc0rr's request
nemo
parents:
2057
diff
changeset

1031 
end 
2017  1032 
end; 
2376  1033 
if ((GameFlags and gfKarma) <> 0) and 
2017  1034 
((GameFlags and gfInvulnerable) = 0) and 
1035 
not CurrentHedgehog^.Gear^.Invulnerable then 

1036 
begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid 

2135
0b7972dfad01
Push karma application to end of round  should avoid problems w/ plane and kamikaze
nemo
parents:
2134
diff
changeset

1037 
inc(CurrentHedgehog^.Gear^.Karma, tmpDmg); 
3461
0781275649e9
revert the restoration of nonvgt health gears. desyncs continued with it, and furthermore, occur in r3489 too
nemo
parents:
3460
diff
changeset

1038 
spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg); 
2017  1039 
end; 
1040 
end; 

1041 
end; 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1042 
inc(Gear^.Damage, Damage); 
3848  1043 
ScriptCall('OnGearDamage', Gear^.UID, Damage); 
2017  1044 
end; 
1849  1045 

4  1046 
procedure SetAllToActive; 
1047 
var t: PGear; 

1048 
begin 

1049 
AllInactive:= false; 

1050 
t:= GearsList; 

351  1051 
while t <> nil do 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1052 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1053 
t^.Active:= true; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1054 
t:= t^.NextGear 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1055 
end 
4  1056 
end; 
1057 

1058 
procedure SetAllHHToActive; 

1059 
var t: PGear; 

1060 
begin 

1061 
AllInactive:= false; 

1062 
t:= GearsList; 

351  1063 
while t <> nil do 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1064 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1065 
if t^.Kind = gtHedgehog then t^.Active:= true; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1066 
t:= t^.NextGear 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1067 
end 
4  1068 
end; 
1069 

2811  1070 
procedure DrawAltWeapon(Gear: PGear; sx, sy: LongInt); 
2802  1071 
begin 
1072 
with PHedgehog(Gear^.Hedgehog)^ do 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1073 
begin 
3836
833c0f32e326
Change all use of curslot/idx to CurAmmoType to try and avoid some bugs with use of last weapon.
nemo
parents:
3832
diff
changeset

1074 
if not (((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) and ((Gear^.State and gstAttacked) = 0)) then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1075 
exit; 
4159
64e677349124
REmove stupid int64 conversions, provide real fixes to compiler hints
unc0rr
parents:
4155
diff
changeset

1076 
DrawTexture(sx + 16, sy + 16, ropeIconTex); 
64e677349124
REmove stupid int64 conversions, provide real fixes to compiler hints
unc0rr
parents:
4155
diff
changeset

1077 
DrawTextureF(SpritesData[sprAMAmmos].Texture, 0.75, sx + 30, sy + 30, ord(CurAmmoType)  1, 1, 32, 32); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1078 
end; 
2802  1079 
end; 
1080 

2362  1081 
procedure DrawRopeLinesRQ(Gear: PGear); 
1082 
begin 

1083 
with RopePoints do 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1084 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1085 
rounded[Count].X:= hwRound(Gear^.X); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1086 
rounded[Count].Y:= hwRound(Gear^.Y); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1087 
rounded[Count + 1].X:= hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1088 
rounded[Count + 1].Y:= hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1089 
end; 
2362  1090 

2365  1091 
if (RopePoints.Count > 0) or (Gear^.Elasticity.QWordValue > 0) then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1092 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1093 
glDisable(GL_TEXTURE_2D); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1094 
//glEnable(GL_LINE_SMOOTH); 
2365  1095 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1096 
glPushMatrix; 
2365  1097 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1098 
glTranslatef(WorldDx, WorldDy, 0); 
2376  1099 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1100 
glLineWidth(4.0); 
2362  1101 

3390  1102 
Tint($C0, $C0, $C0, $FF); 
2362  1103 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1104 
glVertexPointer(2, GL_FLOAT, 0, @RopePoints.rounded[0]); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1105 
glDrawArrays(GL_LINE_STRIP, 0, RopePoints.Count + 2); 
3390  1106 
Tint($FF, $FF, $FF, $FF); 
2365  1107 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1108 
glPopMatrix; 
2376  1109 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1110 
glEnable(GL_TEXTURE_2D); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1111 
//glDisable(GL_LINE_SMOOTH) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1112 
end 
2362  1113 
end; 
1114 

1115 
procedure DrawRope(Gear: PGear); 

1116 
var roplen: LongInt; 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1117 
i: Longword; 
2362  1118 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1119 
procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1120 
var eX, eY, dX, dY: LongInt; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1121 
i, sX, sY, x, y, d: LongInt; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1122 
b: boolean; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1123 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1124 
if (X1 = X2) and (Y1 = Y2) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1125 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1126 
//OutError('WARNING: zero length rope line!', false); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1127 
exit 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1128 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1129 
eX:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1130 
eY:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1131 
dX:= X2  X1; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1132 
dY:= Y2  Y1; 
2362  1133 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1134 
if (dX > 0) then sX:= 1 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1135 
else 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1136 
if (dX < 0) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1137 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1138 
sX:= 1; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1139 
dX:= dX 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1140 
end else sX:= dX; 
2362  1141 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1142 
if (dY > 0) then sY:= 1 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1143 
else 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1144 
if (dY < 0) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1145 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1146 
sY:= 1; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1147 
dY:= dY 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1148 
end else sY:= dY; 
2362  1149 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1150 
if (dX > dY) then d:= dX 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1151 
else d:= dY; 
2362  1152 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1153 
x:= X1; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1154 
y:= Y1; 
2362  1155 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1156 
for i:= 0 to d do 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1157 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1158 
inc(eX, dX); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1159 
inc(eY, dY); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1160 
b:= false; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1161 
if (eX > d) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1162 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1163 
dec(eX, d); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1164 
inc(x, sX); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1165 
b:= true 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1166 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1167 
if (eY > d) then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1168 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1169 
dec(eY, d); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1170 
inc(y, sY); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1171 
b:= true 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1172 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1173 
if b then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1174 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1175 
inc(roplen); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1176 
if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x  2, y  2, 0) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1177 
end 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1178 
end 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1179 
end; 
2362  1180 
begin 
3594
aeca3d8f1b29
turn cReducedQuality into a LongInt and provide a series of quality flags (and best of all, this is still compatible with current frontend)
koda
parents:
3580
diff
changeset

1181 
if (cReducedQuality and rqSimpleRope) <> 0 then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1182 
DrawRopeLinesRQ(Gear) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1183 
else 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1184 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1185 
roplen:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1186 
if RopePoints.Count > 0 then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1187 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1188 
i:= 0; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1189 
while i < Pred(RopePoints.Count) do 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1190 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1191 
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1192 
hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1193 
inc(i) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1194 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1195 
DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1196 
hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1197 
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1198 
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1199 
end else 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1200 
if Gear^.Elasticity.QWordValue > 0 then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1201 
DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1202 
hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1203 
end; 
2362  1204 

1205 

1206 
if RopePoints.Count > 0 then 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1207 
DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1208 
else 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1209 
if Gear^.Elasticity.QWordValue > 0 then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1210 
DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); 
2362  1211 
end; 
1212 

3387
733f4001b8b9
Break out DrawHH/DrawGear to reduce scrolling in uGears.pas, add portal graphics
nemo
parents:
3384
diff
changeset

1213 
{$INCLUDE "GearDrawing.inc"} 
4  1214 

1215 
procedure FreeGearsList; 

1216 
var t, tt: PGear; 

1217 
begin 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1218 
tt:= GearsList; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1219 
GearsList:= nil; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1220 
while tt <> nil do 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1221 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1222 
t:= tt; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1223 
tt:= tt^.NextGear; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1224 
Dispose(t) 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1225 
end; 
4  1226 
end; 
1227 

10  1228 
procedure AddMiscGears; 
371  1229 
var i: LongInt; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1230 
Gear: PGear; 
4  1231 
begin 
498  1232 
AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000); 
1435
d4b32ee3caa6
Fix using freed memory (could be the cause of queue error problem and other bugs)
unc0rr
parents:
1434
diff
changeset

1233 

2428  1234 
if (TrainingFlags and tfSpawnTargets) <> 0 then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1235 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1236 
TrainingTargetGear:= AddGear(0, 0, gtTarget, 0, _0, _0, 0); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1237 
FindPlace(TrainingTargetGear, false, 0, LAND_WIDTH); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1238 
end; 
2428  1239 

4148
eaff5615f976
Decouple forts from divide/mines/explosives, since those can be set individually these days
henek
parents:
4143
diff
changeset

1240 
for i:= 0 to Pred(cLandMines) do 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1241 
begin 
4148
eaff5615f976
Decouple forts from divide/mines/explosives, since those can be set individually these days
henek
parents:
4143
diff
changeset

1242 
Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0); 
eaff5615f976
Decouple forts from divide/mines/explosives, since those can be set individually these days
henek
parents:
4143
diff
changeset

1243 
FindPlace(Gear, false, 0, LAND_WIDTH); 
eaff5615f976
Decouple forts from divide/mines/explosives, since those can be set individually these days
henek
parents:
4143
diff
changeset

1244 
end; 
eaff5615f976
Decouple forts from divide/mines/explosives, since those can be set individually these days
henek
parents:
4143
diff
changeset

1245 
for i:= 0 to Pred(cExplosives) do 
eaff5615f976
Decouple forts from divide/mines/explosives, since those can be set individually these days
henek
parents:
4143
diff
changeset

1246 
begin 
eaff5615f976
Decouple forts from divide/mines/explosives, since those can be set individually these days
henek
parents:
4143
diff
changeset

1247 
Gear:= AddGear(0, 0, gtExplosives, 0, _0, _0, 0); 
eaff5615f976
Decouple forts from divide/mines/explosives, since those can be set individually these days
henek
parents:
4143
diff
changeset

1248 
FindPlace(Gear, false, 0, LAND_WIDTH); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1249 
end; 
1895  1250 

1251 
if (GameFlags and gfLowGravity) <> 0 then 

3355
dc9e61e67484
cWindSpeed recalculation assumed GetRandom returns a value between 0.01.0 while in fact is in the 0.00.5 range; Halve cMaxWindSpeed to compensate.
palewolf
parents:
3350
diff
changeset

1252 
cGravity:= cMaxWindSpeed; 
1895  1253 

2017  1254 
if (GameFlags and gfVampiric) <> 0 then 
1255 
cVampiric:= true; 

1256 

1895  1257 
Gear:= GearsList; 
1258 
if (GameFlags and gfInvulnerable) <> 0 then 

1259 
while Gear <> nil do 

1260 
begin 

1261 
Gear^.Invulnerable:= true; // this is only checked on hogs right now, so no need for gear type check 

1262 
Gear:= Gear^.NextGear 

1263 
end; 

1264 

1265 
if (GameFlags and gfLaserSight) <> 0 then 

2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset

1266 
cLaserSighting:= true; 
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset

1267 

41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset

1268 
if (GameFlags and gfArtillery) <> 0 then 
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2020
diff
changeset

1269 
cArtillery:= true 
4  1270 
end; 
1271 

371  1272 
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); 
3475  1273 
begin 
1274 
doMakeExplosion(X, Y, Radius, Mask, $FFFFFFFF); 

1275 
end; 

1276 

1277 
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask, Tint: LongWord); 

4  1278 
var Gear: PGear; 
3097
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1279 
dmg, dmgRadius, dmgBase: LongInt; 
3322  1280 
fX, fY: hwFloat; 
3475  1281 
vg: PVisualGear; 
3689  1282 
i, cnt: LongInt; 
4  1283 
begin 
1284 
TargetPoint.X:= NoPointX; 

1434  1285 
{$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF} 
3083
8da8f2515221
Eliminate flake kick on themes with no flakes, more than 200 flakes (city) or explosions of 25 or smaller
nemo
parents:
3080
diff
changeset

1286 
if Radius > 25 then KickFlakes(Radius, X, Y); 
8da8f2515221
Eliminate flake kick on themes with no flakes, more than 200 flakes (city) or explosions of 25 or smaller
nemo
parents:
3080
diff
changeset

1287 

3032  1288 
if ((Mask and EXPLNoGfx) = 0) then 
1289 
begin 

3475  1290 
vg:= nil; 
1291 
if Radius > 50 then vg:= AddVisualGear(X, Y, vgtBigExplosion) 

1292 
else if Radius > 10 then vg:= AddVisualGear(X, Y, vgtExplosion); 

1293 
if vg <> nil then 

1294 
vg^.Tint:= Tint; 

3032  1295 
end; 
2745  1296 
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion); 
1433  1297 

1298 
if (Mask and EXPLAllDamageInRadius) = 0 then 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1299 
dmgRadius:= Radius shl 1 
1433  1300 
else 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1301 
dmgRadius:= Radius; 
3097
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1302 
dmgBase:= dmgRadius + cHHRadius div 2; 
3322  1303 
fX:= int2hwFloat(X); 
1304 
fY:= int2hwFloat(Y); 

4  1305 
Gear:= GearsList; 
1306 
while Gear <> nil do 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1307 
begin 
3097
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1308 
dmg:= 0; 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1309 
//dmg:= dmgRadius + cHHRadius div 2  hwRound(Distance(Gear^.X  int2hwFloat(X), Gear^.Y  int2hwFloat(Y))); 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1310 
//if (dmg > 1) and 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1311 
if (Gear^.State and gstNoDamage) = 0 then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1312 
begin 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1313 
case Gear^.Kind of 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1314 
gtHedgehog, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1315 
gtMine, 
3710  1316 
gtSMine, 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1317 
gtCase, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1318 
gtTarget, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1319 
gtFlame, 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1320 
gtExplosives: begin 
3097
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1321 
// Run the calcs only once we know we have a type that will need damage 
3322  1322 
if hwRound(hwAbs(Gear^.XfX)+hwAbs(Gear^.YfY)) < dmgBase then 
1323 
dmg:= dmgBase  hwRound(Distance(Gear^.X  fX, Gear^.Y  fY)); 

3097
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1324 
if dmg > 1 then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2947
diff
changeset

1325 
begin 
3097
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1326 
dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1327 
//{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1328 
if (Mask and EXPLNoDamage) = 0 then 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1329 
begin 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1330 
if not Gear^.Invulnerable then 
3682  1331 
ApplyDamage(Gear, dmg, dsExplosion) 
3097
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1332 
else 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1333 
Gear^.State:= Gear^.State or gstWinner; 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1334 
end; 
3712  1335 
if ((Mask and EXPLDoNotTouchAny) = 0) and (((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog)) then 
3097
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1336 
begin 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1337 
DeleteCI(Gear); 
3322  1338 
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X  fX); 
1339 
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y  fY); 

3097
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1340 
Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser); 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1341 
if not Gear^.Invulnerable then 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1342 
Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); 
6fa39c1c41b9
Try to reduce expensive Distance() call until sure it is needed
nemo
parents:
3094
diff
changeset

1343 
Gear^.Active:= true; 
3997  1344 
if Gear^.Kind <> gtFlame then FollowGear:= Gear 
3112 