author  nemo 
Fri, 03 Apr 2015 16:46:14 0400  
changeset 10891  a4c454ef80a6 
parent 10889  f7200e614295 
child 11002  01c8e95d2265 
permissions  rwrr 
6581  1 
(* 
2 
* Hedgewars, a free turn based strategy game 

9998  3 
* Copyright (c) 20042014 Andrey Korotaev <unC0Rr@gmail.com> 
6581  4 
* 
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 

8 
* 

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. 

13 
* 

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 

10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright  but I ain't gonna touch their copyright headers
sheepluva
parents:
10040
diff
changeset

16 
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 021101301 USA 
6581  17 
*) 
18 

19 
{$INCLUDE "options.inc"} 

20 
unit uGearsList; 

21 

22 
interface 

10032
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

23 
uses uFloat, uTypes, SDLh; 
6581  24 

25 
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; 

10646
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

26 
procedure DeleteGear(Gear: PGear); 
6581  27 
procedure InsertGearToList(Gear: PGear); 
28 
procedure RemoveGearFromList(Gear: PGear); 

29 

7395  30 
var curHandledGear: PGear; 
31 

6581  32 
implementation 
33 

34 
uses uRandom, uUtils, uConsts, uVariables, uAmmos, uTeams, uStats, 

35 
uTextures, uScript, uRenderUtils, uAI, uCollisions, 

7395  36 
uGearsRender, uGearsUtils, uDebug; 
6581  37 

8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

38 
const 
8795
b5b79a8f9354
merge correction, also what's with all those trailing whitespaces?
koda
parents:
8774
diff
changeset

39 
GearKindAmmoTypeMap : array [TGearType] of TAmmoType = ( 
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

40 
(* gtFlame *) amNothing 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

41 
(* gtHedgehog *) , amNothing 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

42 
(* gtMine *) , amMine 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

43 
(* gtCase *) , amNothing 
10829  44 
(* gtAirMine *) , amAirMine 
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

45 
(* gtExplosives *) , amNothing 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

46 
(* gtGrenade *) , amGrenade 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

47 
(* gtShell *) , amBazooka 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

48 
(* gtGrave *) , amNothing 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

49 
(* gtBee *) , amBee 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

50 
(* gtShotgunShot *) , amShotgun 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

51 
(* gtPickHammer *) , amPickHammer 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

52 
(* gtRope *) , amRope 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

53 
(* gtDEagleShot *) , amDEagle 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

54 
(* gtDynamite *) , amDynamite 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

55 
(* gtClusterBomb *) , amClusterBomb 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

56 
(* gtCluster *) , amClusterBomb 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

57 
(* gtShover *) , amBaseballBat // Shover is only used for baseball bat right now 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

58 
(* gtFirePunch *) , amFirePunch 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

59 
(* gtATStartGame *) , amNothing 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

60 
(* gtATFinishGame *) , amNothing 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

61 
(* gtParachute *) , amParachute 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

62 
(* gtAirAttack *) , amAirAttack 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

63 
(* gtAirBomb *) , amAirAttack 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

64 
(* gtBlowTorch *) , amBlowTorch 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

65 
(* gtGirder *) , amGirder 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

66 
(* gtTeleport *) , amTeleport 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

67 
(* gtSwitcher *) , amSwitch 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

68 
(* gtTarget *) , amNothing 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

69 
(* gtMortar *) , amMortar 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

70 
(* gtWhip *) , amWhip 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

71 
(* gtKamikaze *) , amKamikaze 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

72 
(* gtCake *) , amCake 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

73 
(* gtSeduction *) , amSeduction 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

74 
(* gtWatermelon *) , amWatermelon 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

75 
(* gtMelonPiece *) , amWatermelon 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

76 
(* gtHellishBomb *) , amHellishBomb 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

77 
(* gtWaterUp *) , amNothing 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

78 
(* gtDrill *) , amDrill 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

79 
(* gtBallGun *) , amBallgun 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

80 
(* gtBall *) , amBallgun 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

81 
(* gtRCPlane *) , amRCPlane 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

82 
(*gtSniperRifleShot *) , amSniperRifle 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

83 
(* gtJetpack *) , amJetpack 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

84 
(* gtMolotov *) , amMolotov 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

85 
(* gtBirdy *) , amBirdy 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

86 
(* gtEgg *) , amBirdy 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

87 
(* gtPortal *) , amPortalGun 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

88 
(* gtPiano *) , amPiano 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

89 
(* gtGasBomb *) , amGasBomb 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

90 
(* gtSineGunShot *) , amSineGun 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

91 
(* gtFlamethrower *) , amFlamethrower 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

92 
(* gtSMine *) , amSMine 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

93 
(* gtPoisonCloud *) , amNothing 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

94 
(* gtHammer *) , amHammer 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

95 
(* gtHammerHit *) , amHammer 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

96 
(* gtResurrector *) , amResurrector 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

97 
(* gtPoisonCloud *) , amNothing 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

98 
(* gtSnowball *) , amSnowball 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

99 
(* gtFlake *) , amNothing 
8161  100 
//(* gtStructure *) , amStructure // TODO  This will undoubtedly change once there is more than one structure 
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

101 
(* gtLandGun *) , amLandGun 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

102 
(* gtTardis *) , amTardis 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

103 
(* gtIceGun *) , amIceGun 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

104 
(* gtAddAmmo *) , amNothing 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

105 
(* gtGenericFaller *) , amNothing 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

106 
(* gtKnife *) , amKnife 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

107 
); 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

108 

6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

109 

7093  110 
var GCounter: LongWord = 0; // this does not get reinitialized, but should be harmless 
7028  111 

8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

112 
const 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

113 
cUsualZ = 500; 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

114 
cOnHHZ = 2000; 
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
7754
diff
changeset

115 

6581  116 
procedure InsertGearToList(Gear: PGear); 
117 
var tmp, ptmp: PGear; 

118 
begin 

119 
tmp:= GearsList; 

120 
ptmp:= GearsList; 

7366
e5a0856708dc
Insert at front of same Z, not end. Saves a little time on insertion and lua lookup of recent adds.
nemo
parents:
7364
diff
changeset

121 
while (tmp <> nil) and (tmp^.Z < Gear^.Z) do 
6581  122 
begin 
123 
ptmp:= tmp; 

124 
tmp:= tmp^.NextGear 

125 
end; 

126 

127 
if ptmp <> tmp then 

128 
begin 

129 
Gear^.NextGear:= ptmp^.NextGear; 

130 
Gear^.PrevGear:= ptmp; 

131 
if ptmp^.NextGear <> nil then 

132 
ptmp^.NextGear^.PrevGear:= Gear; 

133 
ptmp^.NextGear:= Gear 

134 
end 

135 
else 

136 
begin 

137 
Gear^.NextGear:= GearsList; 

138 
if Gear^.NextGear <> nil then 

139 
Gear^.NextGear^.PrevGear:= Gear; 

140 
GearsList:= Gear; 

141 
end; 

142 
end; 

143 

7395  144 

6581  145 
procedure RemoveGearFromList(Gear: PGear); 
146 
begin 

10634
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset

147 
if (Gear <> GearsList) and (Gear <> nil) and (Gear^.NextGear = nil) and (Gear^.PrevGear = nil) then 
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset

148 
begin 
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset

149 
AddFileLog('Attempted to remove Gear #'+inttostr(Gear^.uid)+' from the list twice.'); 
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset

150 
exit 
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset

151 
end; 
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset

152 
TryDo((Gear = nil) or (curHandledGear = nil) or (Gear = curHandledGear), 'You''re doing it wrong', true); 
7395  153 

6581  154 
if Gear^.NextGear <> nil then 
155 
Gear^.NextGear^.PrevGear:= Gear^.PrevGear; 

156 
if Gear^.PrevGear <> nil then 

157 
Gear^.PrevGear^.NextGear:= Gear^.NextGear 

10634
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset

158 
else 
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset

159 
GearsList:= Gear^.NextGear; 
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset

160 

35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset

161 
Gear^.NextGear:= nil; 
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset

162 
Gear^.PrevGear:= nil 
6581  163 
end; 
7395  164 

165 

6581  166 
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; 
167 
var gear: PGear; 

10518
dbbe2f6c0a96
make gear ability to speak somewhat less ironic
sheepluva
parents:
10495
diff
changeset

168 
//c: byte; 
10874
059a6492176e
allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents:
10848
diff
changeset

169 
cakeData: PCakeData; 
6581  170 
begin 
7028  171 
inc(GCounter); 
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
7754
diff
changeset

172 

7028  173 
AddFileLog('AddGear: #' + inttostr(GCounter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); 
6581  174 

8330  175 

6581  176 
New(gear); 
177 
FillChar(gear^, sizeof(TGear), 0); 

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

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

180 
gear^.Target.X:= NoPointX; 

181 
gear^.Kind := Kind; 

182 
gear^.State:= State; 

183 
gear^.Active:= true; 

184 
gear^.dX:= dX; 

185 
gear^.dY:= dY; 

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

187 
gear^.CollisionIndex:= 1; 

188 
gear^.Timer:= Timer; 

7028  189 
gear^.uid:= GCounter; 
6581  190 
gear^.SoundChannel:= 1; 
191 
gear^.ImpactSound:= sndNone; 

192 
gear^.Density:= _1; 

193 
// Define ammo association, if any. 

194 
gear^.AmmoType:= GearKindAmmoTypeMap[Kind]; 

7730
2013733f9ca9
A bit more on the knife. Also add missing files to CMakeLists
nemo
parents:
7726
diff
changeset

195 
gear^.CollisionMask:= $FFFF; 
10032
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

196 
gear^.Tint:= $FFFFFFFF; 
10874
059a6492176e
allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents:
10848
diff
changeset

197 
gear^.Data:= nil; 
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset

198 

8795
b5b79a8f9354
merge correction, also what's with all those trailing whitespaces?
koda
parents:
8774
diff
changeset

199 
if CurrentHedgehog <> nil then 
7726
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset

200 
begin 
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset

201 
gear^.Hedgehog:= CurrentHedgehog; 
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset

202 
if (CurrentHedgehog^.Gear <> nil) and (hwRound(CurrentHedgehog^.Gear^.X) = X) and (hwRound(CurrentHedgehog^.Gear^.Y) = Y) then 
8751
4609823efc94
More flagging of Land values. Also use less than for tests of nonterrain, instead of "and $FF00 = 0". Saves a couple of ops, which actually matters a small amount in a few places.
nemo
parents:
8744
diff
changeset

203 
gear^.CollisionMask:= lfNotCurrentMask 
7730
2013733f9ca9
A bit more on the knife. Also add missing files to CMakeLists
nemo
parents:
7726
diff
changeset

204 
end; 
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset

205 

7364  206 
if (Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then 
6581  207 
gear^.Z:= cHHZ+1 
208 
else gear^.Z:= cUsualZ; 

209 

8795
b5b79a8f9354
merge correction, also what's with all those trailing whitespaces?
koda
parents:
8774
diff
changeset

210 

6581  211 
case Kind of 
212 
gtGrenade, 

213 
gtClusterBomb, 

214 
gtGasBomb: begin 

215 
gear^.ImpactSound:= sndGrenadeImpact; 

216 
gear^.nImpactSounds:= 1; 

217 
gear^.AdvBounce:= 1; 

218 
gear^.Radius:= 5; 

219 
gear^.Elasticity:= _0_8; 

220 
gear^.Friction:= _0_8; 

221 
gear^.Density:= _1_5; 

222 
gear^.RenderTimer:= true; 

223 
if gear^.Timer = 0 then 

224 
gear^.Timer:= 3000 

225 
end; 

226 
gtWatermelon: begin 

227 
gear^.ImpactSound:= sndMelonImpact; 

228 
gear^.nImpactSounds:= 1; 

229 
gear^.AdvBounce:= 1; 

230 
gear^.Radius:= 6; 

231 
gear^.Elasticity:= _0_8; 

232 
gear^.Friction:= _0_995; 

233 
gear^.Density:= _2; 

234 
gear^.RenderTimer:= true; 

235 
if gear^.Timer = 0 then 

236 
gear^.Timer:= 3000 

237 
end; 

238 
gtMelonPiece: begin 

9825  239 
gear^.AdvBounce:= 1; 
10889
f7200e614295
give melon pieces a radius. is why they weren't bouncing.
nemo
parents:
10875
diff
changeset

240 
gear^.Density:= _2; 
f7200e614295
give melon pieces a radius. is why they weren't bouncing.
nemo
parents:
10875
diff
changeset

241 
gear^.Radius:= 4 
6581  242 
end; 
243 
gtHedgehog: begin 

244 
gear^.AdvBounce:= 1; 

245 
gear^.Radius:= cHHRadius; 

246 
gear^.Elasticity:= _0_35; 

247 
gear^.Friction:= _0_999; 

248 
gear^.Angle:= cMaxAngle div 2; 

249 
gear^.Density:= _3; 

250 
gear^.Z:= cHHZ; 

251 
if (GameFlags and gfAISurvival) <> 0 then 

252 
if gear^.Hedgehog^.BotLevel > 0 then 

7077  253 
gear^.Hedgehog^.Effects[heResurrectable] := 1; 
10032
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

254 
// this would presumably be set in the frontend 
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

255 
// if we weren't going to do that yet, would need to reinit GetRandom 
10040  256 
// oh, and, randomising slightly R and B might be nice too. 
10032
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

257 
//gear^.Tint:= $fa00efff or ((random(80)+128) shl 16) 
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

258 
//gear^.Tint:= $faa4efff 
10040  259 
//gear^.Tint:= (($e0+random(32)) shl 24) or 
10032
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

260 
// ((random(80)+128) shl 16) or 
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

261 
// (($d5+random(32)) shl 8) or $ff 
10495
6d61b44a5652
 Comment out getrandom in addgear for hedgehog, causes previewgame desync
unc0rr
parents:
10494
diff
changeset

262 
{c:= GetRandom(32); 
10040  263 
gear^.Tint:= (($e0+c) shl 24) or 
10494  264 
((GetRandom(90)+128) shl 16) or 
10495
6d61b44a5652
 Comment out getrandom in addgear for hedgehog, causes previewgame desync
unc0rr
parents:
10494
diff
changeset

265 
(($d5+c) shl 8) or $ff} 
6581  266 
end; 
267 
gtShell: begin 

9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

268 
gear^.Elasticity:= _0_8; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

269 
gear^.Friction:= _0_8; 
6581  270 
gear^.Radius:= 4; 
271 
gear^.Density:= _1; 

9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

272 
gear^.AdvBounce:= 1; 
6581  273 
end; 
274 
gtSnowball: begin 

275 
gear^.ImpactSound:= sndMudballImpact; 

276 
gear^.nImpactSounds:= 1; 

277 
gear^.Radius:= 4; 

278 
gear^.Density:= _0_5; 

9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

279 
gear^.AdvBounce:= 1; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

280 
gear^.Elasticity:= _0_8; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

281 
gear^.Friction:= _0_8; 
6581  282 
end; 
283 

284 
gtFlake: begin 

285 
with Gear^ do 

286 
begin 

287 
Pos:= 0; 

288 
Radius:= 1; 

7069  289 
DirAngle:= random(360); 
6581  290 
if State and gstTmpFlag = 0 then 
291 
begin 

292 
dx.isNegative:= GetRandom(2) = 0; 

9809  293 
dx.QWordValue:= QWord($40DA) * GetRandom(10000) * 8; 
6581  294 
dy.isNegative:= false; 
9809  295 
dy.QWordValue:= QWord($3AD3) * GetRandom(7000) * 8; 
6581  296 
if GetRandom(2) = 0 then 
10645
b8c73bacb31e
Fix inflight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents:
10643
diff
changeset

297 
dx := dx; 
b8c73bacb31e
Fix inflight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents:
10643
diff
changeset

298 
Tint:= $FFFFFFFF 
b8c73bacb31e
Fix inflight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents:
10643
diff
changeset

299 
end 
b8c73bacb31e
Fix inflight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents:
10643
diff
changeset

300 
else 
b8c73bacb31e
Fix inflight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents:
10643
diff
changeset

301 
Tint:= (ExplosionBorderColor shr RShift and $FF shl 24) or 
b8c73bacb31e
Fix inflight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents:
10643
diff
changeset

302 
(ExplosionBorderColor shr GShift and $FF shl 16) or 
b8c73bacb31e
Fix inflight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents:
10643
diff
changeset

303 
(ExplosionBorderColor shr BShift and $FF shl 8) or $FF; 
6581  304 
State:= State or gstInvisible; 
10625
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10589
diff
changeset

305 
// use health field to store current frameticks 
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10589
diff
changeset

306 
if vobFrameTicks > 0 then 
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10589
diff
changeset

307 
Health:= random(vobFrameTicks) 
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10589
diff
changeset

308 
else 
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10589
diff
changeset

309 
Health:= 0; 
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10589
diff
changeset

310 
// use timer to store currently displayed frame index 
9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

311 
if gear^.Timer = 0 then Timer:= random(vobFramesCount); 
10645
b8c73bacb31e
Fix inflight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents:
10643
diff
changeset

312 
Damage:= (random(2) * 2  1) * (vobVelocity + random(vobVelocity)) * 8 
6581  313 
end 
314 
end; 

315 
gtGrave: begin 

316 
gear^.ImpactSound:= sndGraveImpact; 

317 
gear^.nImpactSounds:= 1; 

318 
gear^.Radius:= 10; 

319 
gear^.Elasticity:= _0_6; 

320 
end; 

321 
gtBee: begin 

322 
gear^.Radius:= 5; 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

323 
if gear^.Timer = 0 then gear^.Timer:= 500; 
6581  324 
gear^.RenderTimer:= true; 
325 
gear^.Elasticity:= _0_9; 

326 
gear^.Tag:= 0; 

9479
167dea42d7d7
move border back a bit from left/right bounds, bee tweak
nemo
parents:
9195
diff
changeset

327 
gear^.State:= Gear^.State or gstSubmersible 
6581  328 
end; 
329 
gtSeduction: begin 

330 
gear^.Radius:= 250; 

331 
end; 

332 
gtShotgunShot: begin 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

333 
if gear^.Timer = 0 then gear^.Timer:= 900; 
6581  334 
gear^.Radius:= 2 
335 
end; 

336 
gtPickHammer: begin 

337 
gear^.Radius:= 10; 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

338 
if gear^.Timer = 0 then gear^.Timer:= 4000 
6581  339 
end; 
340 
gtHammerHit: begin 

341 
gear^.Radius:= 8; 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

342 
if gear^.Timer = 0 then gear^.Timer:= 125 
6581  343 
end; 
344 
gtRope: begin 

345 
gear^.Radius:= 3; 

346 
gear^.Friction:= _450 * _0_01 * cRopePercent; 

347 
RopePoints.Count:= 0; 

10848  348 
gear^.Tint:= $D8D8D8FF; 
349 
gear^.Tag:= 0; // normal rope render 

6581  350 
end; 
351 
gtMine: begin 

352 
gear^.ImpactSound:= sndMineImpact; 

353 
gear^.nImpactSounds:= 1; 

354 
gear^.Health:= 10; 

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

356 
gear^.Radius:= 2; 

357 
gear^.Elasticity:= _0_55; 

358 
gear^.Friction:= _0_995; 

7602
a620319d377e
Fix throwing things off rope, also make throwing things a bit more generic and gear density dependent (so you can throw mines further, and also throw dynamite a little).
nemo
parents:
7395
diff
changeset

359 
gear^.Density:= _1; 
9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

360 
if gear^.Timer = 0 then 
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

361 
begin 
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

362 
if cMinesTime < 0 then 
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

363 
gear^.Timer:= getrandom(51)*100 
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

364 
else 
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

365 
gear^.Timer:= cMinesTime 
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

366 
end 
6581  367 
end; 
10789
acbf69e2e5cf
experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents:
10663
diff
changeset

368 
gtAirMine: begin 
acbf69e2e5cf
experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents:
10663
diff
changeset

369 
gear^.ImpactSound:= sndDenied; 
acbf69e2e5cf
experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents:
10663
diff
changeset

370 
gear^.nImpactSounds:= 1; 
acbf69e2e5cf
experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents:
10663
diff
changeset

371 
gear^.Health:= 30; 
10827  372 
gear^.State:= gear^.State or gstMoving or gstNoGravity or gstSubmersible; 
10802
089e43d01f74
Use the larger scaled airmine sprite originally intended, add some antidickery measures.
nemo
parents:
10800
diff
changeset

373 
gear^.Radius:= 8; 
10789
acbf69e2e5cf
experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents:
10663
diff
changeset

374 
gear^.Elasticity:= _0_55; 
acbf69e2e5cf
experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents:
10663
diff
changeset

375 
gear^.Friction:= _0_995; 
acbf69e2e5cf
experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents:
10663
diff
changeset

376 
gear^.Density:= _1; 
10791
0311c9fa7498
tweak a few params. still something wtf going on when on rope
nemo
parents:
10789
diff
changeset

377 
gear^.Angle:= 175; // Radius at which air bombs will start "seeking". $FFFFFFFF = unlimited. check is skipped. 
10800  378 
gear^.Power:= cMaxWindSpeed.QWordValue div 2; // hwFloat converted. 1/2 g default. defines the "seek" speed when a gear is in range. 
10828
9867dd60a66a
bit more friction. remove gstSubmersible clearing. was for the old "sea" thing that is totally gone now. As a general attribute, better to let other stuff clear it as needed.
nemo
parents:
10827
diff
changeset

379 
gear^.Pos:= cMaxWindSpeed.QWordValue * 3 div 2; // air friction. slows it down when not hitting stuff 
10789
acbf69e2e5cf
experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents:
10663
diff
changeset

380 
gear^.Karma:= 30; // damage 
10805  381 
if gear^.Timer = 0 then 
382 
begin 

383 
if cMinesTime < 0 then 

384 
gear^.Timer:= getrandom(13)*100 

385 
else 

386 
gear^.Timer:= cMinesTime div 4 

387 
end; 

388 
gear^.WDTimer:= gear^.Timer 

10789
acbf69e2e5cf
experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents:
10663
diff
changeset

389 
end; 
6581  390 
gtSMine: begin 
391 
gear^.Health:= 10; 

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

393 
gear^.Radius:= 2; 

394 
gear^.Elasticity:= _0_55; 

395 
gear^.Friction:= _0_995; 

7602
a620319d377e
Fix throwing things off rope, also make throwing things a bit more generic and gear density dependent (so you can throw mines further, and also throw dynamite a little).
nemo
parents:
7395
diff
changeset

396 
gear^.Density:= _1_6; 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

397 
gear^.AdvBounce:= 1; 
9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

398 
if gear^.Timer = 0 then gear^.Timer:= 500; 
6581  399 
end; 
7733  400 
gtKnife: begin 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

401 
gear^.AdvBounce:= 1; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

402 
gear^.Elasticity:= _0_8; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

403 
gear^.Friction:= _0_8; 
7754  404 
gear^.Density:= _4; 
8494
53b91a602955
Cleaver tweaks based on feedback. Nerf damage, shrink radius. This means cleaver will embed into ground quite a bit further.
nemo
parents:
8161
diff
changeset

405 
gear^.Radius:= 7 
7733  406 
end; 
6581  407 
gtCase: begin 
408 
gear^.ImpactSound:= sndGraveImpact; 

409 
gear^.nImpactSounds:= 1; 

410 
gear^.Radius:= 16; 

7168
8defaabce92e
warp sound when AI survival hog respawns. attempt at a bit of a crate spawn animation (moar sparkles and a quick fadein)
nemo
parents:
7093
diff
changeset

411 
gear^.Elasticity:= _0_3; 
9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

412 
if gear^.Timer = 0 then gear^.Timer:= 500 
6581  413 
end; 
414 
gtExplosives: begin 

9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

415 
gear^.AdvBounce:= 1; 
6581  416 
gear^.ImpactSound:= sndGrenadeImpact; 
417 
gear^.nImpactSounds:= 1; 

418 
gear^.Radius:= 16; 

419 
gear^.Elasticity:= _0_4; 

420 
gear^.Friction:= _0_995; 

421 
gear^.Density:= _6; 

422 
gear^.Health:= cBarrelHealth; 

423 
gear^.Z:= cHHZ1 

424 
end; 

425 
gtDEagleShot: begin 

426 
gear^.Radius:= 1; 

427 
gear^.Health:= 50 

428 
end; 

429 
gtSniperRifleShot: begin 

430 
gear^.Radius:= 1; 

431 
gear^.Health:= 50 

432 
end; 

433 
gtDynamite: begin 

434 
gear^.Radius:= 3; 

435 
gear^.Elasticity:= _0_55; 

436 
gear^.Friction:= _0_03; 

437 
gear^.Density:= _2; 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

438 
if gear^.Timer = 0 then gear^.Timer:= 5000; 
6581  439 
end; 
440 
gtCluster: begin 

9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

441 
gear^.AdvBounce:= 1; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

442 
gear^.Elasticity:= _0_8; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

443 
gear^.Friction:= _0_8; 
6581  444 
gear^.Radius:= 2; 
445 
gear^.Density:= _1_5; 

446 
gear^.RenderTimer:= true 

447 
end; 

448 
gtShover: gear^.Radius:= 20; 

449 
gtFlame: begin 

450 
gear^.Tag:= GetRandom(32); 

451 
gear^.Radius:= 1; 

452 
gear^.Health:= 5; 

453 
gear^.Density:= _1; 

10589
98ea597e5cd9
expose FlightTime to lua, disable inair flame harming moving hogs â˜¹ aaaand override that in ClimbHome â˜º
nemo
parents:
10518
diff
changeset

454 
gear^.FlightTime:= 9999999; // determines whether inair flames do damage. disabled by default 
6581  455 
if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then 
456 
begin 

7001  457 
gear^.dY:= (getrandomf  _0_8) * _0_03; 
458 
gear^.dX:= (getrandomf  _0_5) * _0_4 

6581  459 
end 
460 
end; 

461 
gtFirePunch: begin 

9824  462 
if gear^.Timer = 0 then gear^.Timer:= 3000; 
6581  463 
gear^.Radius:= 15; 
464 
gear^.Tag:= Y 

465 
end; 

10032
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

466 
gtAirAttack: begin 
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

467 
gear^.Z:= cHHZ+2; 
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

468 
gear^.Tint:= gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF 
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

469 
end; 
6581  470 
gtAirBomb: begin 
10891
a4c454ef80a6
enable bounce on rubber for air bombs. give them the missing elasticity they needed for the code there to work properly.
nemo
parents:
10889
diff
changeset

471 
gear^.AdvBounce:= 1; 
6581  472 
gear^.Radius:= 5; 
473 
gear^.Density:= _2; 

10891
a4c454ef80a6
enable bounce on rubber for air bombs. give them the missing elasticity they needed for the code there to work properly.
nemo
parents:
10889
diff
changeset

474 
gear^.Elasticity:= _0_55; 
a4c454ef80a6
enable bounce on rubber for air bombs. give them the missing elasticity they needed for the code there to work properly.
nemo
parents:
10889
diff
changeset

475 
gear^.Friction:= _0_995 
6581  476 
end; 
477 
gtBlowTorch: begin 

478 
gear^.Radius:= cHHRadius + cBlowTorchC; 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

479 
if gear^.Timer = 0 then gear^.Timer:= 7500 
6581  480 
end; 
481 
gtSwitcher: begin 

482 
gear^.Z:= cCurrHHZ 

483 
end; 

484 
gtTarget: begin 

485 
gear^.ImpactSound:= sndGrenadeImpact; 

486 
gear^.nImpactSounds:= 1; 

487 
gear^.Radius:= 10; 

488 
gear^.Elasticity:= _0_3; 

489 
end; 

490 
gtTardis: begin 

491 
gear^.Pos:= 1; 

492 
gear^.Z:= cCurrHHZ+1; 

493 
end; 

494 
gtMortar: begin 

9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

495 
gear^.AdvBounce:= 1; 
6581  496 
gear^.Radius:= 4; 
497 
gear^.Elasticity:= _0_2; 

498 
gear^.Friction:= _0_08; 

499 
gear^.Density:= _1; 

500 
end; 

501 
gtWhip: gear^.Radius:= 20; 

502 
gtHammer: gear^.Radius:= 20; 

503 
gtKamikaze: begin 

504 
gear^.Health:= 2048; 

505 
gear^.Radius:= 20 

506 
end; 

507 
gtCake: begin 

508 
gear^.Health:= 2048; 

509 
gear^.Radius:= 7; 

510 
gear^.Z:= cOnHHZ; 

10875  511 
gear^.RenderTimer:= false; 
6581  512 
gear^.DirAngle:= 90 * hwSign(Gear^.dX); 
513 
if not dX.isNegative then 

514 
gear^.Angle:= 1 

515 
else 

10874
059a6492176e
allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents:
10848
diff
changeset

516 
gear^.Angle:= 3; 
059a6492176e
allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents:
10848
diff
changeset

517 
New(cakeData); 
059a6492176e
allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents:
10848
diff
changeset

518 
gear^.Data:= Pointer(cakeData); 
6581  519 
end; 
520 
gtHellishBomb: begin 

521 
gear^.ImpactSound:= sndHellishImpact1; 

522 
gear^.nImpactSounds:= 4; 

523 
gear^.AdvBounce:= 1; 

524 
gear^.Radius:= 4; 

525 
gear^.Elasticity:= _0_5; 

526 
gear^.Friction:= _0_96; 

527 
gear^.Density:= _1_5; 

528 
gear^.RenderTimer:= true; 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

529 
if gear^.Timer = 0 then gear^.Timer:= 5000 
6581  530 
end; 
531 
gtDrill: begin 

9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

532 
gear^.AdvBounce:= 1; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

533 
gear^.Elasticity:= _0_8; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

534 
gear^.Friction:= _0_8; 
6581  535 
if gear^.Timer = 0 then 
536 
gear^.Timer:= 5000; 

537 
// Tag for drill strike. if 1 then first impact occured already 

538 
gear^.Tag := 0; 

539 
gear^.Radius:= 4; 

540 
gear^.Density:= _1; 

541 
end; 

542 
gtBall: begin 

543 
gear^.ImpactSound:= sndGrenadeImpact; 

544 
gear^.nImpactSounds:= 1; 

545 
gear^.AdvBounce:= 1; 

546 
gear^.Radius:= 5; 

547 
gear^.Tag:= random(8); 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

548 
if gear^.Timer = 0 then gear^.Timer:= 5000; 
6581  549 
gear^.Elasticity:= _0_7; 
550 
gear^.Friction:= _0_995; 

551 
gear^.Density:= _1_5; 

552 
end; 

553 
gtBallgun: begin 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

554 
if gear^.Timer = 0 then gear^.Timer:= 5001; 
6581  555 
end; 
556 
gtRCPlane: begin 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

557 
if gear^.Timer = 0 then gear^.Timer:= 15000; 
6581  558 
gear^.Health:= 3; 
10032
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

559 
gear^.Radius:= 8; 
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

560 
gear^.Tint:= gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF 
6581  561 
end; 
562 
gtJetpack: begin 

563 
gear^.Health:= 2000; 

8987
47cf32305d99
some saucer thing for firing weps underwater and aiming and such. bit drunk and sleepy so testing I guess
nemo
parents:
8795
diff
changeset

564 
gear^.Damage:= 100; 
9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

565 
gear^.State:= Gear^.State or gstSubmersible 
6581  566 
end; 
567 
gtMolotov: begin 

9825  568 
gear^.AdvBounce:= 1; 
6581  569 
gear^.Radius:= 6; 
9825  570 
gear^.Density:= _2 
6581  571 
end; 
572 
gtBirdy: begin 

573 
gear^.Radius:= 16; // todo: check 

574 
gear^.Health := 2000; 

9825  575 
gear^.FlightTime := 2 
6581  576 
end; 
577 
gtEgg: begin 

9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

578 
gear^.AdvBounce:= 1; 
6581  579 
gear^.Radius:= 4; 
580 
gear^.Elasticity:= _0_6; 

581 
gear^.Friction:= _0_96; 

582 
gear^.Density:= _1; 

583 
if gear^.Timer = 0 then 

584 
gear^.Timer:= 3000 

585 
end; 

586 
gtPortal: begin 

587 
gear^.ImpactSound:= sndMelonImpact; 

588 
gear^.nImpactSounds:= 1; 

589 
gear^.Radius:= 17; 

590 
// set color 

591 
gear^.Tag:= 2 * gear^.Timer; 

592 
gear^.Timer:= 15000; 

593 
gear^.RenderTimer:= false; 

594 
gear^.Health:= 100; 

595 
end; 

596 
gtPiano: begin 

597 
gear^.Radius:= 32; 

598 
gear^.Density:= _50; 

599 
end; 

600 
gtSineGunShot: begin 

601 
gear^.Radius:= 5; 

602 
gear^.Health:= 6000; 

603 
end; 

604 
gtFlamethrower: begin 

605 
gear^.Tag:= 10; 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

606 
if gear^.Timer = 0 then gear^.Timer:= 10; 
6581  607 
gear^.Health:= 500; 
608 
gear^.Damage:= 100; 

609 
end; 

610 
gtLandGun: begin 

611 
gear^.Tag:= 10; 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

612 
if gear^.Timer = 0 then gear^.Timer:= 10; 
6581  613 
gear^.Health:= 1000; 
614 
gear^.Damage:= 100; 

615 
end; 

616 
gtPoisonCloud: begin 

9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

617 
if gear^.Timer = 0 then gear^.Timer:= 5000; 
6581  618 
gear^.dY:= int2hwfloat(4 + longint(getRandom(8))) / 1000; 
10032
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

619 
gear^.Tint:= $C0C000C0 
6581  620 
end; 
621 
gtResurrector: begin 

622 
gear^.Radius := 100; 

10032
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

623 
gear^.Tag := 0; 
db65298717da
This adds idle hog tinting. Active hog tinting still needed.
nemo
parents:
9998
diff
changeset

624 
gear^.Tint:= $F5DB35FF 
6581  625 
end; 
626 
gtWaterUp: begin 

627 
gear^.Tag := 47; 

628 
end; 

629 
gtNapalmBomb: begin 

9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

630 
gear^.Elasticity:= _0_8; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9479
diff
changeset

631 
gear^.Friction:= _0_8; 
9195
e653e96b0ec3
Many of the gears treat non0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents:
9080
diff
changeset

632 
if gear^.Timer = 0 then gear^.Timer:= 1000; 
6581  633 
gear^.Radius:= 5; 
634 
gear^.Density:= _1_5; 

635 
end; 

8161  636 
{ 
6581  637 
gtStructure: begin 
638 
gear^.Elasticity:= _0_55; 

639 
gear^.Friction:= _0_995; 

640 
gear^.Density:= _0_9; 

641 
gear^.Radius:= 13; 

642 
gear^.Health:= 200; 

643 
gear^.Timer:= 0; 

644 
gear^.Tag:= TotalRounds + 3; 

645 
gear^.Pos:= 1; 

646 
end; 

8161  647 
} 
8774
39754516eee6
Try to document TGear a bit, so people know what is commonly overridden, and what stuff is used for. Remove gtIceGunspecific values from TGear and abuse a couple of commonly abused members instead.
nemo
parents:
8751
diff
changeset

648 
gtIceGun: begin 
39754516eee6
Try to document TGear a bit, so people know what is commonly overridden, and what stuff is used for. Remove gtIceGunspecific values from TGear and abuse a couple of commonly abused members instead.
nemo
parents:
8751
diff
changeset

649 
gear^.Health:= 1000; 
39754516eee6
Try to document TGear a bit, so people know what is commonly overridden, and what stuff is used for. Remove gtIceGunspecific values from TGear and abuse a couple of commonly abused members instead.
nemo
parents:
8751
diff
changeset

650 
gear^.Radius:= 8; 
39754516eee6
Try to document TGear a bit, so people know what is commonly overridden, and what stuff is used for. Remove gtIceGunspecific values from TGear and abuse a couple of commonly abused members instead.
nemo
parents:
8751
diff
changeset

651 
end; 
7389
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7366
diff
changeset

652 
gtGenericFaller:begin 
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7366
diff
changeset

653 
gear^.AdvBounce:= 1; 
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7366
diff
changeset

654 
gear^.Radius:= 1; 
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7366
diff
changeset

655 
gear^.Elasticity:= _0_9; 
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7366
diff
changeset

656 
gear^.Friction:= _0_995; 
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7366
diff
changeset

657 
gear^.Density:= _1; 
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7366
diff
changeset

658 
end; 
6581  659 
end; 
660 

661 
InsertGearToList(gear); 

662 
AddGear:= gear; 

663 

664 
ScriptCall('onGearAdd', gear^.uid); 

665 
end; 

666 

10646
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

667 
procedure DeleteGear(Gear: PGear); 
6581  668 
var team: PTeam; 
669 
t,i: Longword; 

670 
k: boolean; 

10874
059a6492176e
allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents:
10848
diff
changeset

671 
cakeData: PCakeData; 
6581  672 
begin 
673 

674 
ScriptCall('onGearDelete', gear^.uid); 

675 

676 
DeleteCI(Gear); 

677 

10634
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset

678 
FreeAndNilTexture(Gear^.Tex); 
6581  679 

680 
// make sure that portals have their link removed before deletion 

681 
if (Gear^.Kind = gtPortal) then 

682 
begin 

7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset

683 
if (Gear^.LinkedGear <> nil) then 
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset

684 
if (Gear^.LinkedGear^.LinkedGear = Gear) then 
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset

685 
Gear^.LinkedGear^.LinkedGear:= nil; 
6581  686 
end 
10874
059a6492176e
allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents:
10848
diff
changeset

687 
else if Gear^.Kind = gtCake then 
059a6492176e
allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents:
10848
diff
changeset

688 
begin 
059a6492176e
allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents:
10848
diff
changeset

689 
cakeData:= PCakeData(Gear^.Data); 
059a6492176e
allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents:
10848
diff
changeset

690 
Dispose(cakeData); 
059a6492176e
allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents:
10848
diff
changeset

691 
cakeData:= nil; 
059a6492176e
allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents:
10848
diff
changeset

692 
end 
6581  693 
else if Gear^.Kind = gtHedgehog then 
694 
(* 

695 
This behaviour dates back to revision 4, and I accidentally encountered it with TARDIS. I don't think it must apply to any modern weapon, since if it was actually hit, the best the gear could do would be to destroy itself immediately, and you'd still end up with two graves. I believe it should be removed 

696 
if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then 

697 
begin 

698 
AttackBar:= 0; 

699 
Gear^.Message:= gmDestroy; 

700 
CurAmmoGear^.Message:= gmDestroy; 

701 
exit 

702 
end 

703 
else*) 

704 
begin 

10646
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

705 
if ((CurrentHedgehog = nil) or (Gear <> CurrentHedgehog^.Gear)) or (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtKamikaze) then 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

706 
Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; 
10663
9bbb29d2bd68
remove a not that somehow magically appeared in a prior commit.
nemo
parents:
10646
diff
changeset

707 
if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then 
6581  708 
begin 
10646
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

709 
t:= max(Gear^.Damage, Gear^.Health); 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

710 
Gear^.Damage:= t; 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

711 
if (((not SuddenDeathDmg) and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF))) then 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

712 
spawnHealthTagForHH(Gear, t); 
6581  713 
end; 
714 

10646
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

715 
team:= Gear^.Hedgehog^.Team; 
10636
aba9ae27ead0
meh. will persevere. DeleteGear can't call that much stuff...
nemo
parents:
10634
diff
changeset

716 
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear = Gear) then 
6581  717 
begin 
718 
AttackBar:= 0; 

719 
FreeActionsList; // to avoid ThinkThread on drawned gear 

720 
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) 

721 
and (CurrentHedgehog^.MultiShootAttacks > 0) then 

722 
OnUsedAmmo(CurrentHedgehog^); 

723 
end; 

724 

725 
Gear^.Hedgehog^.Gear:= nil; 

10646
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

726 

6581  727 
if Gear^.Hedgehog^.King then 
728 
begin 

729 
// are there any other kings left? Just doing nil check. Presumably a mortally wounded king will get reaped soon enough 

730 
k:= false; 

731 
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do 

732 
if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then 

733 
k:= true; 

734 
if not k then 

735 
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do 

736 
begin 

737 
team^.Clan^.Teams[i]^.hasGone:= true; 

738 
TeamGoneEffect(team^.Clan^.Teams[i]^) 

739 
end 

740 
end; 

10646
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

741 

0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

742 
// should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

743 
// same stand for CheckHHDamage 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

744 
if (Gear^.LastDamage <> nil) and (CurrentHedgehog <> nil) then 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

745 
uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true) 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

746 
else if CurrentHedgehog <> nil then 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

747 
uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

748 

0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

749 
inc(KilledHHs); 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

750 
RecountTeamHealth(team); 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

751 
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0) and 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

752 
//(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

753 
(Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

754 
with CurrentHedgehog^ do 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

755 
begin 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

756 
inc(Team^.stats.AIKills); 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

757 
FreeAndNilTexture(Team^.AIKillsTex); 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

758 
Team^.AIKillsTex := RenderStringTex(ansistring(inttostr(Team^.stats.AIKills)), Team^.Clan^.Color, fnt16); 
0be6442946b1
put back the old uteams cleanup, leaks and all, to worry about postrelease since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents:
10645
diff
changeset

759 
end 
6581  760 
end; 
761 
with Gear^ do 

7389
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7366
diff
changeset

762 
begin 
6581  763 
AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); 
7389
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7366
diff
changeset

764 
AddRandomness(X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac) 
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7366
diff
changeset

765 
end; 
6581  766 
if CurAmmoGear = Gear then 
767 
CurAmmoGear:= nil; 

768 
if FollowGear = Gear then 

769 
FollowGear:= nil; 

770 
if lastGearByUID = Gear then 

771 
lastGearByUID := nil; 

10638  772 
if (Gear^.Hedgehog = nil) or (Gear^.Hedgehog^.GearHidden <> Gear) then // hidden hedgehogs shouldn't be in the list 
10639  773 
RemoveGearFromList(Gear) 
774 
else Gear^.Hedgehog^.GearHidden:= nil; 

10638  775 

6581  776 
Dispose(Gear) 
777 
end; 

778 

779 
end. 