author | nemo |
Fri, 27 Jul 2012 23:16:30 -0400 | |
changeset 7462 | 9cc5a2586978 |
parent 7459 | 8511a3f899d3 |
child 7503 | deaeac102355 |
child 7597 | 1ef520fea21c |
permissions | -rw-r--r-- |
6581 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
6700 | 3 |
* Copyright (c) 2004-2012 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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*) |
|
18 |
||
19 |
{$INCLUDE "options.inc"} |
|
20 |
||
21 |
unit uGearsHedgehog; |
|
22 |
interface |
|
23 |
uses uTypes; |
|
24 |
||
25 |
procedure doStepHedgehog(Gear: PGear); |
|
26 |
procedure AfterAttack; |
|
27 |
procedure HedgehogStep(Gear: PGear); |
|
28 |
procedure doStepHedgehogMoving(Gear: PGear); |
|
29 |
procedure HedgehogChAngle(HHGear: PGear); |
|
30 |
procedure PickUp(HH, Gear: PGear); |
|
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:
7375
diff
changeset
|
31 |
procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord); |
6581 | 32 |
|
33 |
implementation |
|
6992 | 34 |
uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, |
6581 | 35 |
uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript, |
36 |
uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, |
|
37 |
uGearsUtils; |
|
38 |
||
7028 | 39 |
var GHStepTicks: LongWord = 0; |
40 |
||
6581 | 41 |
// Shouldn't more of this ammo switching stuff be moved to uAmmos ? |
42 |
function ChangeAmmo(HHGear: PGear): boolean; |
|
43 |
var slot, i: Longword; |
|
44 |
ammoidx: LongInt; |
|
45 |
begin |
|
46 |
ChangeAmmo:= false; |
|
47 |
slot:= HHGear^.MsgParam; |
|
48 |
||
49 |
with HHGear^.Hedgehog^ do |
|
50 |
begin |
|
51 |
HHGear^.Message:= HHGear^.Message and (not gmSlot); |
|
52 |
ammoidx:= 0; |
|
53 |
if ((HHGear^.State and (gstAttacking or gstAttacked)) <> 0) |
|
54 |
or ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0)) |
|
55 |
or ((HHGear^.State and gstHHDriven) = 0) then |
|
56 |
exit; |
|
57 |
ChangeAmmo:= true; |
|
58 |
||
59 |
while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do |
|
60 |
inc(ammoidx); |
|
61 |
||
62 |
if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) and (MultiShootAttacks > 0) then |
|
63 |
OnUsedAmmo(HHGear^.Hedgehog^); |
|
64 |
||
65 |
MultiShootAttacks:= 0; |
|
66 |
HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump)); |
|
67 |
||
68 |
if Ammoz[CurAmmoType].Slot = slot then |
|
69 |
begin |
|
70 |
i:= 0; |
|
71 |
repeat |
|
72 |
inc(ammoidx); |
|
73 |
if (ammoidx > cMaxSlotAmmoIndex) then |
|
74 |
begin |
|
75 |
inc(i); |
|
76 |
CurAmmoType:= amNothing; |
|
77 |
ammoidx:= -1; |
|
78 |
//TryDo(i < 2, 'Engine bug: no ammo in current slot', true) |
|
79 |
end; |
|
80 |
until (i = 1) or ((Ammo^[slot, ammoidx].Count > 0) |
|
81 |
and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns)) |
|
82 |
||
83 |
end |
|
84 |
else |
|
85 |
begin |
|
86 |
i:= 0; |
|
87 |
// check whether there is ammo in slot |
|
88 |
while (i <= cMaxSlotAmmoIndex) and ((Ammo^[slot, i].Count = 0) |
|
89 |
or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns)) |
|
90 |
do inc(i); |
|
91 |
||
92 |
if i <= cMaxSlotAmmoIndex then |
|
93 |
ammoidx:= i |
|
94 |
else ammoidx:= -1 |
|
95 |
end; |
|
96 |
if ammoidx >= 0 then |
|
97 |
CurAmmoType:= Ammo^[slot, ammoidx].AmmoType; |
|
98 |
end |
|
99 |
end; |
|
100 |
||
101 |
procedure HHSetWeapon(HHGear: PGear); |
|
102 |
var t: LongInt; |
|
103 |
weap: TAmmoType; |
|
104 |
Hedgehog: PHedgehog; |
|
105 |
s: boolean; |
|
106 |
begin |
|
107 |
s:= false; |
|
108 |
||
109 |
weap:= TAmmoType(HHGear^.MsgParam); |
|
110 |
Hedgehog:= HHGear^.Hedgehog; |
|
111 |
||
112 |
if Hedgehog^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns then |
|
113 |
exit; // weapon is not activated yet |
|
114 |
||
115 |
HHGear^.MsgParam:= Ammoz[weap].Slot; |
|
116 |
||
117 |
t:= cMaxSlotAmmoIndex; |
|
118 |
||
119 |
HHGear^.Message:= HHGear^.Message and (not gmWeapon); |
|
120 |
||
121 |
with Hedgehog^ do |
|
122 |
while (CurAmmoType <> weap) and (t >= 0) do |
|
123 |
begin |
|
124 |
s:= ChangeAmmo(HHGear); |
|
125 |
dec(t) |
|
126 |
end; |
|
127 |
||
128 |
if s then |
|
129 |
ApplyAmmoChanges(HHGear^.Hedgehog^) |
|
130 |
end; |
|
131 |
||
132 |
procedure HHSetTimer(Gear: PGear); |
|
133 |
var CurWeapon: PAmmo; |
|
134 |
color: LongWord; |
|
135 |
begin |
|
136 |
Gear^.Message:= Gear^.Message and (not gmTimer); |
|
6924 | 137 |
CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^); |
6581 | 138 |
with Gear^.Hedgehog^ do |
139 |
if ((Gear^.Message and gmPrecise) <> 0) and ((CurWeapon^.Propz and ammoprop_SetBounce) <> 0) then |
|
140 |
begin |
|
141 |
color:= Gear^.Hedgehog^.Team^.Clan^.Color; |
|
142 |
case Gear^.MsgParam of |
|
143 |
1: begin |
|
7069 | 144 |
AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce1]), color, capgrpAmmostate); |
6581 | 145 |
CurWeapon^.Bounciness:= 350; |
146 |
end; |
|
147 |
2: begin |
|
7069 | 148 |
AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce2]), color, capgrpAmmostate); |
6581 | 149 |
CurWeapon^.Bounciness:= 700; |
150 |
end; |
|
151 |
3: begin |
|
7069 | 152 |
AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce3]), color, capgrpAmmostate); |
6581 | 153 |
CurWeapon^.Bounciness:= 1000; |
154 |
end; |
|
155 |
4: begin |
|
7069 | 156 |
AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce4]), color, capgrpAmmostate); |
6581 | 157 |
CurWeapon^.Bounciness:= 2000; |
158 |
end; |
|
159 |
5: begin |
|
7069 | 160 |
AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce5]), color, capgrpAmmostate); |
6581 | 161 |
CurWeapon^.Bounciness:= 4000; |
162 |
end |
|
163 |
end |
|
164 |
end |
|
165 |
else if (CurWeapon^.Propz and ammoprop_Timerable) <> 0 then |
|
166 |
begin |
|
167 |
CurWeapon^.Timer:= 1000 * Gear^.MsgParam; |
|
168 |
with CurrentTeam^ do |
|
169 |
ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); |
|
170 |
end; |
|
171 |
end; |
|
172 |
||
173 |
||
174 |
procedure Attack(Gear: PGear); |
|
175 |
var xx, yy, newDx, newDy, lx, ly: hwFloat; |
|
176 |
speech: PVisualGear; |
|
177 |
newGear: PGear; |
|
178 |
CurWeapon: PAmmo; |
|
179 |
altUse: boolean; |
|
180 |
elastic: hwFloat; |
|
181 |
begin |
|
182 |
newGear:= nil; |
|
183 |
bShowFinger:= false; |
|
6924 | 184 |
CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^); |
6581 | 185 |
with Gear^, |
186 |
Gear^.Hedgehog^ do |
|
187 |
begin |
|
188 |
if ((State and gstHHDriven) <> 0) and ((State and (gstAttacked or gstHHChooseTarget)) = 0) and (((State and gstMoving) = 0) |
|
189 |
or (Power > 0) |
|
190 |
or (CurAmmoType = amTeleport) |
|
191 |
or |
|
192 |
// Allow attacks while moving on ammo with AltAttack |
|
193 |
((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)) |
|
194 |
or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackInMove) <> 0)) |
|
195 |
and ((TargetPoint.X <> NoPointX) or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget) = 0)) then |
|
196 |
begin |
|
197 |
State:= State or gstAttacking; |
|
198 |
if Power = cMaxPower then |
|
199 |
Message:= Message and (not gmAttack) |
|
200 |
else if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) = 0 then |
|
201 |
Message:= Message and (not gmAttack) |
|
202 |
else |
|
203 |
begin |
|
204 |
if Power = 0 then |
|
205 |
begin |
|
206 |
AttackBar:= CurrentTeam^.AttackBar; |
|
207 |
PlaySound(sndThrowPowerUp) |
|
208 |
end; |
|
209 |
inc(Power) |
|
210 |
end; |
|
211 |
if ((Message and gmAttack) <> 0) then |
|
212 |
exit; |
|
213 |
||
214 |
if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0 then |
|
215 |
begin |
|
216 |
StopSound(sndThrowPowerUp); |
|
217 |
PlaySound(sndThrowRelease); |
|
218 |
end; |
|
219 |
||
220 |
xx:= SignAs(AngleSin(Angle), dX); |
|
221 |
yy:= -AngleCos(Angle); |
|
222 |
||
223 |
lx:= X + int2hwfloat(round(GetLaunchX(CurAmmoType, hwSign(dX), Angle))); |
|
224 |
ly:= Y + int2hwfloat(round(GetLaunchY(CurAmmoType, Angle))); |
|
225 |
||
226 |
if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then |
|
227 |
xx:= - xx; |
|
228 |
if Ammoz[CurAmmoType].Ammo.AttackVoice <> sndNone then |
|
229 |
AddVoice(Ammoz[CurAmmoType].Ammo.AttackVoice, CurrentTeam^.voicepack); |
|
230 |
||
231 |
// Initiating alt attack |
|
232 |
if (CurAmmoGear <> nil) |
|
233 |
and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
234 |
and ((Gear^.Message and gmLJump) <> 0) |
|
235 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then |
|
236 |
begin |
|
237 |
newDx:= dX / _2; |
|
238 |
newDy:= dY / _2; |
|
239 |
altUse:= true; |
|
240 |
end |
|
241 |
else |
|
242 |
begin |
|
243 |
newDx:= xx*Power/cPowerDivisor; |
|
244 |
newDy:= yy*Power/cPowerDivisor; |
|
245 |
altUse:= false |
|
246 |
end; |
|
247 |
||
248 |
case CurAmmoType of |
|
249 |
amGrenade: newGear:= AddGear(hwRound(lx), hwRound(ly), gtGrenade, 0, newDx, newDy, CurWeapon^.Timer); |
|
250 |
amMolotov: newGear:= AddGear(hwRound(lx), hwRound(ly), gtMolotov, 0, newDx, newDy, 0); |
|
251 |
amClusterBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtClusterBomb, 0, newDx, newDy, CurWeapon^.Timer); |
|
252 |
amGasBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtGasBomb, 0, newDx, newDy, CurWeapon^.Timer); |
|
253 |
amBazooka: newGear:= AddGear(hwRound(lx), hwRound(ly), gtShell, 0, newDx, newDy, 0); |
|
254 |
amSnowball: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSnowball, 0, newDx, newDy, 0); |
|
255 |
amBee: newGear:= AddGear(hwRound(lx), hwRound(ly), gtBee, 0, newDx, newDy, 0); |
|
256 |
amShotgun: begin |
|
257 |
PlaySound(sndShotgunReload); |
|
258 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtShotgunShot, 0, xx * _0_5, yy * _0_5, 0); |
|
259 |
end; |
|
260 |
amPickHammer: newGear:= AddGear(hwRound(lx), hwRound(ly) + cHHRadius, gtPickHammer, 0, _0, _0, 0); |
|
261 |
amSkip: ParseCommand('/skip', true); |
|
262 |
amRope: newGear:= AddGear(hwRound(lx), hwRound(ly), gtRope, 0, xx, yy, 0); |
|
263 |
amMine: if altUse then |
|
264 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, newDx, newDy, 3000) |
|
265 |
else |
|
266 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000); |
|
267 |
amSMine: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); |
|
268 |
amDEagle: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0); |
|
269 |
amSineGun: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0); |
|
270 |
amPortalGun: begin |
|
271 |
newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, |
|
272 |
// set selected color |
|
273 |
CurWeapon^.Pos); |
|
274 |
end; |
|
275 |
amSniperRifle: begin |
|
276 |
PlaySound(sndSniperReload); |
|
277 |
newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSniperRifleShot, 0, xx * _0_5, yy * _0_5, 0); |
|
278 |
end; |
|
279 |
amDynamite: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000); |
|
280 |
amFirePunch: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtFirePunch, 0, xx, _0, 0); |
|
281 |
amWhip: begin |
|
282 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtWhip, 0, SignAs(_1, dX), - _0_8, 0); |
|
283 |
PlaySound(sndWhipCrack) |
|
284 |
end; |
|
285 |
amHammer: begin |
|
286 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtHammer, 0, SignAs(_1, dX), - _0_8, 0); |
|
287 |
PlaySound(sndWhack) |
|
288 |
end; |
|
289 |
amBaseballBat: begin |
|
290 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtShover, gsttmpFlag, xx * _0_5, yy * _0_5, 0); |
|
291 |
PlaySound(sndBaseballBat) // TODO: Only play if something is hit? |
|
292 |
end; |
|
293 |
amParachute: begin |
|
294 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtParachute, 0, _0, _0, 0); |
|
295 |
PlaySound(sndParachute) |
|
296 |
end; |
|
297 |
// we save CurWeapon^.Pos (in this case: cursor direction) by using it as (otherwise irrelevant) X value of the new gear. |
|
298 |
amAirAttack: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 0, _0, _0, 0); |
|
299 |
amMineStrike: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 1, _0, _0, 0); |
|
300 |
amDrillStrike: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 3, _0, _0, CurWeapon^.Timer); |
|
301 |
amNapalm: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 2, _0, _0, 0); |
|
302 |
amBlowTorch: newGear:= AddGear(hwRound(lx), hwRound(ly), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0); |
|
303 |
amGirder: newGear:= AddGear(0, 0, gtGirder, CurWeapon^.Pos, _0, _0, 0); |
|
304 |
amTeleport: newGear:= AddGear(CurWeapon^.Pos, 0, gtTeleport, 0, _0, _0, 0); |
|
305 |
amSwitch: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSwitcher, 0, _0, _0, 0); |
|
306 |
amMortar: begin |
|
307 |
playSound(sndMortar); |
|
308 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtMortar, 0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0); |
|
309 |
end; |
|
310 |
amRCPlane: begin |
|
311 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtRCPlane, 0, xx * cMaxPower / cPowerDivisor / 4, yy * cMaxPower / cPowerDivisor / 4, 0); |
|
7053 | 312 |
newGear^.SoundChannel:= LoopSound(sndRCPlane) |
6581 | 313 |
end; |
314 |
amKamikaze: newGear:= AddGear(hwRound(lx), hwRound(ly), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0); |
|
315 |
amCake: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, xx, _0, 0); |
|
316 |
amSeduction: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSeduction, 0, _0, _0, 0); |
|
317 |
amWatermelon: newGear:= AddGear(hwRound(lx), hwRound(ly), gtWatermelon, 0, newDx, newDy, CurWeapon^.Timer); |
|
318 |
amHellishBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtHellishBomb, 0, newDx, newDy, 0); |
|
319 |
amDrill: newGear:= AddGear(hwRound(lx), hwRound(ly), gtDrill, 0, newDx, newDy, 0); |
|
320 |
amBallgun: newGear:= AddGear(hwRound(X), hwRound(Y), gtBallgun, 0, xx * _0_5, yy * _0_5, 0); |
|
321 |
amJetpack: newGear:= AddGear(hwRound(lx), hwRound(ly), gtJetpack, 0, _0, _0, 0); |
|
322 |
amBirdy: begin |
|
323 |
PlaySound(sndWhistle); |
|
324 |
newGear:= AddGear(hwRound(lx), hwRound(ly) - 32, gtBirdy, 0, _0, _0, 0); |
|
325 |
end; |
|
326 |
amLowGravity: begin |
|
327 |
PlaySound(sndLowGravity); |
|
328 |
cGravity:= cMaxWindSpeed; |
|
329 |
cGravityf:= 0.00025 |
|
330 |
end; |
|
331 |
amExtraDamage: begin |
|
332 |
PlaySound(sndHellishImpact4); |
|
333 |
cDamageModifier:= _1_5 |
|
334 |
end; |
|
335 |
amInvulnerable: Invulnerable:= true; |
|
336 |
amExtraTime: begin |
|
337 |
PlaySound(sndSwitchHog); |
|
338 |
TurnTimeLeft:= TurnTimeLeft + 30000 |
|
339 |
end; |
|
340 |
amLaserSight: cLaserSighting:= true; |
|
341 |
amVampiric: begin |
|
7053 | 342 |
PlaySoundV(sndOw1, Team^.voicepack); |
6581 | 343 |
cVampiric:= true; |
344 |
end; |
|
345 |
amPiano: begin |
|
346 |
// Tuck the hedgehog away until the piano attack is completed |
|
347 |
Unplaced:= true; |
|
348 |
X:= _0; |
|
349 |
Y:= _0; |
|
350 |
newGear:= AddGear(TargetPoint.X, 0, gtPiano, 0, _0, _0, 0); |
|
351 |
PauseMusic |
|
352 |
end; |
|
353 |
amFlamethrower: newGear:= AddGear(hwRound(X), hwRound(Y), gtFlamethrower, 0, xx * _0_5, yy * _0_5, 0); |
|
354 |
amLandGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtLandGun, 0, xx * _0_5, yy * _0_5, 0); |
|
355 |
amResurrector: begin |
|
356 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtResurrector, 0, _0, _0, 0); |
|
357 |
newGear^.SoundChannel := LoopSound(sndResurrector); |
|
358 |
end; |
|
359 |
amStructure: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtStructure, gstWait, SignAs(_0_02, dX), _0, 3000); |
|
360 |
amTardis: newGear:= AddGear(hwRound(X), hwRound(Y), gtTardis, 0, _0, _0, 5000); |
|
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6992
diff
changeset
|
361 |
amIceGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtIceGun, 0, _0, _0, 0); |
6581 | 362 |
end; |
363 |
||
364 |
case CurAmmoType of |
|
365 |
amGrenade, amMolotov, |
|
366 |
amClusterBomb, amGasBomb, |
|
367 |
amBazooka, amSnowball, |
|
368 |
amBee, amSMine, |
|
369 |
amMortar, amWatermelon, |
|
370 |
amHellishBomb, amDrill: FollowGear:= newGear; |
|
371 |
||
372 |
amShotgun, amPickHammer, |
|
373 |
amRope, amDEagle, |
|
374 |
amSineGun, amSniperRifle, |
|
375 |
amFirePunch, amWhip, |
|
376 |
amHammer, amBaseballBat, |
|
377 |
amParachute, amBlowTorch, |
|
378 |
amGirder, amTeleport, |
|
379 |
amSwitch, amRCPlane, |
|
380 |
amKamikaze, amCake, |
|
381 |
amSeduction, amBallgun, |
|
382 |
amJetpack, amBirdy, |
|
383 |
amFlamethrower, amLandGun, |
|
384 |
amResurrector, amStructure, |
|
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6992
diff
changeset
|
385 |
amTardis, amPiano, |
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6992
diff
changeset
|
386 |
amIceGun: CurAmmoGear:= newGear; |
6581 | 387 |
end; |
388 |
||
389 |
if ((CurAmmoType = amMine) or (CurAmmoType = amSMine)) and (GameFlags and gfInfAttack <> 0) then |
|
390 |
newGear^.FlightTime:= GameTicks + 1000 |
|
391 |
else if CurAmmoType = amDrill then |
|
392 |
newGear^.FlightTime:= GameTicks + 250; |
|
393 |
if Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then |
|
394 |
begin |
|
395 |
newGear^.Target.X:= TargetPoint.X; |
|
396 |
newGear^.Target.Y:= TargetPoint.Y |
|
397 |
end; |
|
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7187
diff
changeset
|
398 |
if newGear <> nil then newGear^.CollisionMask:= $FF7F; |
6581 | 399 |
|
400 |
// Clear FollowGear if using on a rope/parachute/saucer etc so focus stays with the hog's movement |
|
401 |
if altUse then |
|
402 |
FollowGear:= nil; |
|
403 |
||
404 |
if (newGear <> nil) and ((Ammoz[newGear^.AmmoType].Ammo.Propz and ammoprop_SetBounce) <> 0) then |
|
405 |
begin |
|
406 |
elastic:= int2hwfloat(CurWeapon^.Bounciness) / _1000; |
|
407 |
||
408 |
if elastic < _1 then |
|
409 |
newGear^.Elasticity:= newGear^.Elasticity * elastic |
|
410 |
else if elastic > _1 then |
|
411 |
newGear^.Elasticity:= _1 - ((_1-newGear^.Elasticity) / elastic); |
|
412 |
(* Experimented with friction modifier. Didn't seem helpful |
|
413 |
fric:= int2hwfloat(CurWeapon^.Bounciness) / _250; |
|
414 |
if fric < _1 then newGear^.Friction:= newGear^.Friction * fric |
|
415 |
else if fric > _1 then newGear^.Friction:= _1 - ((_1-newGear^.Friction) / fric)*) |
|
416 |
end; |
|
417 |
||
418 |
||
419 |
uStats.AmmoUsed(CurAmmoType); |
|
420 |
||
421 |
if not (SpeechText = '') then |
|
422 |
begin |
|
423 |
speech:= AddVisualGear(0, 0, vgtSpeechBubble); |
|
424 |
if speech <> nil then |
|
425 |
begin |
|
426 |
speech^.Text:= SpeechText; |
|
427 |
speech^.Hedgehog:= Gear^.Hedgehog; |
|
428 |
speech^.FrameTicks:= SpeechType; |
|
429 |
end; |
|
430 |
SpeechText:= '' |
|
431 |
end; |
|
432 |
||
433 |
Power:= 0; |
|
434 |
if (CurAmmoGear <> nil) |
|
435 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) = 0){check for dropping ammo from rope} then |
|
436 |
begin |
|
437 |
Message:= Message or gmAttack; |
|
438 |
CurAmmoGear^.Message:= Message |
|
439 |
end |
|
440 |
else |
|
441 |
begin |
|
442 |
if not CurrentTeam^.ExtDriven |
|
443 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0) then |
|
7067
f98ec3aecf4e
A solution to char vs string problem: mark single-letter strings with _S macro
unc0rr
parents:
7053
diff
changeset
|
444 |
SendIPC(_S'a'); |
6581 | 445 |
AfterAttack; |
446 |
end |
|
447 |
end |
|
448 |
else |
|
449 |
Message:= Message and (not gmAttack); |
|
450 |
end; |
|
451 |
TargetPoint.X := NoPointX; |
|
452 |
ScriptCall('onHogAttack'); |
|
453 |
end; |
|
454 |
||
455 |
procedure AfterAttack; |
|
456 |
var s: shortstring; |
|
457 |
a: TAmmoType; |
|
7459
8511a3f899d3
Allow AfterAttack to proceed even if the Hedgehog is dead. They could be resurrected after all.
nemo
parents:
7426
diff
changeset
|
458 |
HHGear: PGear; |
6581 | 459 |
begin |
7459
8511a3f899d3
Allow AfterAttack to proceed even if the Hedgehog is dead. They could be resurrected after all.
nemo
parents:
7426
diff
changeset
|
460 |
with CurrentHedgehog^ do |
6581 | 461 |
begin |
7459
8511a3f899d3
Allow AfterAttack to proceed even if the Hedgehog is dead. They could be resurrected after all.
nemo
parents:
7426
diff
changeset
|
462 |
HHGear:= Gear; |
6581 | 463 |
a:= CurAmmoType; |
7459
8511a3f899d3
Allow AfterAttack to proceed even if the Hedgehog is dead. They could be resurrected after all.
nemo
parents:
7426
diff
changeset
|
464 |
if HHGear <> nil then HHGear^.State:= HHGear^.State and (not gstAttacking); |
6581 | 465 |
if (Ammoz[a].Ammo.Propz and ammoprop_Effect) = 0 then |
466 |
begin |
|
467 |
Inc(MultiShootAttacks); |
|
468 |
||
469 |
if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) then |
|
470 |
begin |
|
471 |
s:= inttostr(Ammoz[a].Ammo.NumPerTurn - MultiShootAttacks + 1); |
|
472 |
AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate); |
|
473 |
end; |
|
474 |
||
475 |
if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) |
|
476 |
or ((GameFlags and gfMultiWeapon) <> 0) then |
|
477 |
begin |
|
478 |
isInMultiShoot:= true |
|
479 |
end |
|
480 |
else |
|
481 |
begin |
|
482 |
OnUsedAmmo(CurrentHedgehog^); |
|
483 |
if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (((GameFlags and gfInfAttack) = 0) or PlacingHogs) then |
|
484 |
begin |
|
485 |
if TagTurnTimeLeft = 0 then |
|
486 |
TagTurnTimeLeft:= TurnTimeLeft; |
|
487 |
TurnTimeLeft:=(Ammoz[a].TimeAfterTurn * cGetAwayTime) div 100; |
|
488 |
end; |
|
7459
8511a3f899d3
Allow AfterAttack to proceed even if the Hedgehog is dead. They could be resurrected after all.
nemo
parents:
7426
diff
changeset
|
489 |
if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (HHGear <> nil) then |
7462 | 490 |
HHGear^.State:= HHGear^.State or gstAttacked; |
6581 | 491 |
if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then |
492 |
ApplyAmmoChanges(CurrentHedgehog^) |
|
493 |
end; |
|
494 |
end |
|
495 |
else |
|
496 |
begin |
|
497 |
OnUsedAmmo(CurrentHedgehog^); |
|
498 |
ApplyAmmoChanges(CurrentHedgehog^); |
|
499 |
end; |
|
500 |
AttackBar:= 0 |
|
501 |
end |
|
502 |
end; |
|
503 |
||
504 |
//////////////////////////////////////////////////////////////////////////////// |
|
505 |
procedure doStepHedgehogDead(Gear: PGear); |
|
506 |
const frametime = 200; |
|
507 |
timertime = frametime * 6; |
|
508 |
begin |
|
509 |
if Gear^.Hedgehog^.Unplaced then |
|
510 |
exit; |
|
511 |
if Gear^.Timer > 1 then |
|
512 |
begin |
|
513 |
AllInactive:= false; |
|
514 |
dec(Gear^.Timer); |
|
515 |
if (Gear^.Timer mod frametime) = 0 then |
|
516 |
inc(Gear^.Pos) |
|
517 |
end |
|
518 |
else if Gear^.Timer = 1 then |
|
519 |
begin |
|
520 |
Gear^.State:= Gear^.State or gstNoDamage; |
|
521 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, CurrentHedgehog, EXPLAutoSound); |
|
522 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
523 |
DeleteGear(Gear); |
|
524 |
SetAllToActive |
|
525 |
end |
|
526 |
else // Gear^.Timer = 0 |
|
527 |
begin |
|
528 |
AllInactive:= false; |
|
529 |
Gear^.Z:= cCurrHHZ; |
|
530 |
RemoveGearFromList(Gear); |
|
531 |
InsertGearToList(Gear); |
|
7053 | 532 |
PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 533 |
Gear^.Pos:= 0; |
534 |
Gear^.Timer:= timertime |
|
535 |
end |
|
536 |
end; |
|
537 |
||
538 |
//////////////////////////////////////////////////////////////////////////////// |
|
539 |
procedure doStepHedgehogGone(Gear: PGear); |
|
540 |
const frametime = 65; |
|
541 |
timertime = frametime * 11; |
|
542 |
begin |
|
543 |
if Gear^.Hedgehog^.Unplaced then |
|
544 |
exit; |
|
545 |
if Gear^.Timer > 1 then |
|
546 |
begin |
|
547 |
AllInactive:= false; |
|
548 |
dec(Gear^.Timer); |
|
549 |
if (Gear^.Timer mod frametime) = 0 then |
|
550 |
inc(Gear^.Pos) |
|
551 |
end |
|
552 |
else |
|
553 |
if Gear^.Timer = 1 then |
|
554 |
begin |
|
555 |
DeleteGear(Gear); |
|
556 |
SetAllToActive |
|
557 |
end |
|
558 |
else // Gear^.Timer = 0 |
|
559 |
begin |
|
560 |
AllInactive:= false; |
|
561 |
Gear^.Z:= cCurrHHZ; |
|
562 |
RemoveGearFromList(Gear); |
|
563 |
InsertGearToList(Gear); |
|
7053 | 564 |
PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 565 |
PlaySound(sndWarp); |
566 |
Gear^.Pos:= 0; |
|
567 |
Gear^.Timer:= timertime |
|
568 |
end |
|
569 |
end; |
|
570 |
||
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:
7375
diff
changeset
|
571 |
procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord); |
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:
7375
diff
changeset
|
572 |
var s: shortstring; |
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:
7375
diff
changeset
|
573 |
vga: PVisualGear; |
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:
7375
diff
changeset
|
574 |
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:
7375
diff
changeset
|
575 |
PlaySound(sndShotgunReload); |
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:
7375
diff
changeset
|
576 |
if cnt <> 0 then AddAmmo(HH, ammo, cnt) |
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:
7375
diff
changeset
|
577 |
else AddAmmo(HH, ammo); |
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:
7375
diff
changeset
|
578 |
|
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:
7375
diff
changeset
|
579 |
if (not (HH.Team^.ExtDriven |
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:
7375
diff
changeset
|
580 |
or (HH.BotLevel > 0))) |
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:
7375
diff
changeset
|
581 |
or (HH.Team^.Clan^.ClanIndex = LocalClan) |
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:
7375
diff
changeset
|
582 |
or (GameType = gmtDemo) then |
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:
7375
diff
changeset
|
583 |
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:
7375
diff
changeset
|
584 |
if cnt <> 0 then |
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:
7375
diff
changeset
|
585 |
s:= trammo[Ammoz[ammo].NameId] + ' (+' + IntToStr(cnt) + ')' |
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:
7375
diff
changeset
|
586 |
else |
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:
7375
diff
changeset
|
587 |
s:= trammo[Ammoz[ammo].NameId] + ' (+' + IntToStr(Ammoz[ammo].NumberInCase) + ')'; |
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:
7375
diff
changeset
|
588 |
AddCaption(s, HH.Team^.Clan^.Color, capgrpAmmoinfo); |
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:
7375
diff
changeset
|
589 |
|
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:
7375
diff
changeset
|
590 |
// show ammo icon |
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:
7375
diff
changeset
|
591 |
vga:= AddVisualGear(X, Y, vgtAmmo); |
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:
7375
diff
changeset
|
592 |
if vga <> nil then |
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:
7375
diff
changeset
|
593 |
vga^.Frame:= Longword(ammo); |
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:
7375
diff
changeset
|
594 |
end; |
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:
7375
diff
changeset
|
595 |
end; |
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:
7375
diff
changeset
|
596 |
|
6581 | 597 |
//////////////////////////////////////////////////////////////////////////////// |
598 |
procedure PickUp(HH, Gear: PGear); |
|
599 |
var s: shortstring; |
|
600 |
a: TAmmoType; |
|
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
601 |
i: LongInt; |
6581 | 602 |
vga: PVisualGear; |
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
603 |
ag, gi: PGear; |
6581 | 604 |
begin |
605 |
Gear^.Message:= gmDestroy; |
|
606 |
if (Gear^.Pos and posCaseExplode) <> 0 then |
|
607 |
if (Gear^.Pos and posCasePoison) <> 0 then |
|
608 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned) |
|
609 |
else |
|
610 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound) |
|
611 |
else if (Gear^.Pos and posCasePoison) <> 0 then |
|
612 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned + EXPLNoDamage) |
|
613 |
else |
|
614 |
case Gear^.Pos of |
|
615 |
posCaseUtility, |
|
616 |
posCaseAmmo: begin |
|
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:
7375
diff
changeset
|
617 |
if Gear^.AmmoType <> amNothing then |
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:
7375
diff
changeset
|
618 |
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:
7375
diff
changeset
|
619 |
AddPickup(HH^.Hedgehog^, Gear^.AmmoType, Gear^.Power, hwRound(Gear^.X), hwRound(Gear^.Y)); |
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:
7375
diff
changeset
|
620 |
end |
6581 | 621 |
else |
622 |
begin |
|
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:
7375
diff
changeset
|
623 |
// Add spawning here... |
7409 | 624 |
AddRandomness(GameTicks); |
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
625 |
|
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
626 |
gi := GearsList; |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
627 |
while gi <> nil do |
7391
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
628 |
begin |
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
629 |
if gi^.Kind = gtGenericFaller then |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
630 |
begin |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
631 |
gi^.Active:= true; |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
632 |
gi^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
633 |
gi^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
634 |
gi^.dX:= _90-(GetRandomf*_360); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
635 |
gi^.dY:= _90-(GetRandomf*_360) |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
636 |
end; |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
637 |
gi := gi^.NextGear |
7391
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
638 |
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:
7375
diff
changeset
|
639 |
ag:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAddAmmo, gstInvisible, _0, _0, GetRandom(200)+100); |
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:
7375
diff
changeset
|
640 |
ag^.Pos:= Gear^.Pos; |
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:
7375
diff
changeset
|
641 |
ag^.Power:= Gear^.Power |
6581 | 642 |
end; |
643 |
end; |
|
644 |
posCaseHealth: begin |
|
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:
7375
diff
changeset
|
645 |
PlaySound(sndShotgunReload); |
6581 | 646 |
inc(HH^.Health, Gear^.Health); |
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6992
diff
changeset
|
647 |
HH^.Hedgehog^.Effects[hePoisoned] := 0; |
6581 | 648 |
str(Gear^.Health, s); |
649 |
s:= '+' + s; |
|
650 |
AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
|
651 |
RenderHealth(HH^.Hedgehog^); |
|
652 |
RecountTeamHealth(HH^.Hedgehog^.Team); |
|
653 |
||
654 |
i:= 0; |
|
655 |
while i < Gear^.Health do |
|
656 |
begin |
|
657 |
vga:= AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtStraightShot); |
|
658 |
if vga <> nil then |
|
659 |
with vga^ do |
|
660 |
begin |
|
661 |
Tint:= $00FF00FF; |
|
662 |
State:= ord(sprHealth) |
|
663 |
end; |
|
664 |
inc(i, 5); |
|
665 |
end; |
|
666 |
end; |
|
667 |
end |
|
668 |
end; |
|
669 |
||
670 |
procedure HedgehogStep(Gear: PGear); |
|
671 |
var PrevdX: LongInt; |
|
672 |
CurWeapon: PAmmo; |
|
673 |
begin |
|
6924 | 674 |
CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^); |
6581 | 675 |
if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then |
676 |
begin |
|
677 |
if isCursorVisible then |
|
678 |
with Gear^.Hedgehog^ do |
|
679 |
with CurWeapon^ do |
|
680 |
begin |
|
681 |
if (Gear^.Message and gmLeft ) <> 0 then |
|
682 |
Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount |
|
683 |
else |
|
684 |
if (Gear^.Message and gmRight ) <> 0 then |
|
685 |
Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount |
|
686 |
else |
|
687 |
exit; |
|
7028 | 688 |
GHStepTicks:= 200; |
6581 | 689 |
exit |
690 |
end; |
|
691 |
||
692 |
if ((Gear^.Message and gmAnimate) <> 0) then |
|
693 |
begin |
|
694 |
Gear^.Message:= 0; |
|
695 |
Gear^.State:= Gear^.State or gstAnimation; |
|
696 |
Gear^.Tag:= Gear^.MsgParam; |
|
697 |
Gear^.Timer:= 0; |
|
698 |
Gear^.Pos:= 0 |
|
699 |
end; |
|
700 |
||
701 |
if ((Gear^.Message and gmLJump ) <> 0) then |
|
702 |
begin |
|
703 |
Gear^.Message:= Gear^.Message and (not gmLJump); |
|
704 |
DeleteCI(Gear); |
|
705 |
if TestCollisionYwithGear(Gear, -1) = 0 then |
|
706 |
if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then |
|
707 |
Gear^.Y:= Gear^.Y - _2 |
|
708 |
else |
|
709 |
if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then |
|
710 |
Gear^.Y:= Gear^.Y - _1; |
|
711 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
|
712 |
or (TestCollisionYwithGear(Gear, -1) <> 0)) then |
|
713 |
begin |
|
714 |
Gear^.dY:= -_0_15; |
|
715 |
if not cArtillery then |
|
716 |
Gear^.dX:= SignAs(_0_15, Gear^.dX); |
|
717 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
|
7053 | 718 |
PlaySoundV(sndJump1, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 719 |
exit |
720 |
end; |
|
721 |
end; |
|
722 |
||
723 |
if ((Gear^.Message and gmHJump ) <> 0) then |
|
724 |
begin |
|
725 |
DeleteCI(Gear); |
|
726 |
Gear^.Message:= Gear^.Message and (not gmHJump); |
|
727 |
||
728 |
Gear^.dY:= -_0_2; |
|
729 |
SetLittle(Gear^.dX); |
|
730 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
|
7053 | 731 |
PlaySoundV(sndJump3, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 732 |
exit |
733 |
end; |
|
734 |
||
735 |
PrevdX:= hwSign(Gear^.dX); |
|
736 |
if (Gear^.Message and gmLeft )<>0 then |
|
737 |
Gear^.dX:= -cLittle else |
|
738 |
if (Gear^.Message and gmRight )<>0 then |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
739 |
Gear^.dX:= cLittle |
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
740 |
else exit; |
6581 | 741 |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
742 |
StepSoundTimer:= cHHStepTicks; |
6581 | 743 |
|
7028 | 744 |
GHStepTicks:= cHHStepTicks; |
6581 | 745 |
if PrevdX <> hwSign(Gear^.dX) then |
746 |
begin |
|
747 |
FollowGear:= Gear; |
|
748 |
exit |
|
749 |
end; |
|
750 |
DeleteCI(Gear); // must be after exit!! (see previous line) |
|
751 |
||
752 |
Gear^.Hedgehog^.visStepPos:= (Gear^.Hedgehog^.visStepPos + 1) and 7; |
|
7164
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
753 |
|
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
754 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
755 |
begin |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
756 |
Gear^.Y:= Gear^.Y - _1; |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
757 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
758 |
begin |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
759 |
Gear^.Y:= Gear^.Y - _1; |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
760 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
761 |
begin |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
762 |
Gear^.Y:= Gear^.Y - _1; |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
763 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
6581 | 764 |
begin |
7164
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
765 |
Gear^.Y:= Gear^.Y - _1; |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
766 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
767 |
begin |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
768 |
Gear^.Y:= Gear^.Y - _1; |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
769 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
770 |
begin |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
771 |
Gear^.Y:= Gear^.Y - _1; |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
772 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
773 |
Gear^.Y:= Gear^.Y + _6 |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
774 |
end else Gear^.Y:= Gear^.Y + _5 else |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
775 |
end else Gear^.Y:= Gear^.Y + _4 else |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
776 |
end else Gear^.Y:= Gear^.Y + _3 else |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
777 |
end else Gear^.Y:= Gear^.Y + _2 else |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
778 |
end else Gear^.Y:= Gear^.Y + _1 |
6581 | 779 |
end; |
780 |
||
781 |
if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then |
|
782 |
Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
|
783 |
||
784 |
SetAllHHToActive; |
|
785 |
||
786 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
787 |
begin |
|
788 |
Gear^.Y:= Gear^.Y + _1; |
|
789 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
790 |
begin |
|
791 |
Gear^.Y:= Gear^.Y + _1; |
|
792 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
793 |
begin |
|
794 |
Gear^.Y:= Gear^.Y + _1; |
|
795 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
796 |
begin |
|
797 |
Gear^.Y:= Gear^.Y + _1; |
|
798 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
799 |
begin |
|
800 |
Gear^.Y:= Gear^.Y + _1; |
|
801 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
802 |
begin |
|
803 |
Gear^.Y:= Gear^.Y + _1; |
|
804 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
805 |
begin |
|
806 |
Gear^.Y:= Gear^.Y - _6; |
|
807 |
Gear^.dY:= _0; |
|
808 |
Gear^.State:= Gear^.State or gstMoving; |
|
809 |
exit |
|
810 |
end; |
|
811 |
end |
|
812 |
end |
|
813 |
end |
|
814 |
end |
|
815 |
end |
|
816 |
end; |
|
817 |
AddGearCI(Gear) |
|
818 |
end |
|
819 |
end; |
|
820 |
||
821 |
procedure HedgehogChAngle(HHGear: PGear); |
|
822 |
var da: LongWord; |
|
823 |
begin |
|
824 |
with HHGear^.Hedgehog^ do |
|
825 |
if ((CurAmmoType = amRope) and ((HHGear^.State and (gstMoving or gstHHJumping)) = gstMoving)) |
|
826 |
or ((CurAmmoType = amPortalGun) and ((HHGear^.State and gstMoving) <> 0)) then |
|
827 |
da:= 2 |
|
828 |
else da:= 1; |
|
829 |
||
830 |
if (((HHGear^.Message and gmPrecise) = 0) or ((GameTicks mod 5) = 1)) then |
|
831 |
if ((HHGear^.Message and gmUp) <> 0) and (HHGear^.Angle >= CurMinAngle + da) then |
|
832 |
dec(HHGear^.Angle, da) |
|
833 |
else |
|
834 |
if ((HHGear^.Message and gmDown) <> 0) and (HHGear^.Angle + da <= CurMaxAngle) then |
|
835 |
inc(HHGear^.Angle, da) |
|
836 |
end; |
|
837 |
||
838 |
||
839 |
//////////////////////////////////////////////////////////////////////////////// |
|
840 |
procedure doStepHedgehogMoving(Gear: PGear); |
|
841 |
var isFalling, isUnderwater: boolean; |
|
842 |
land: Word; |
|
843 |
begin |
|
844 |
land:= 0; |
|
845 |
isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius; |
|
846 |
if Gear^.dX.QWordValue > 8160437862 then |
|
847 |
Gear^.dX.QWordValue:= 8160437862; |
|
848 |
if Gear^.dY.QWordValue > 8160437862 then |
|
849 |
Gear^.dY.QWordValue:= 8160437862; |
|
850 |
||
851 |
if Gear^.Hedgehog^.Unplaced then |
|
852 |
begin |
|
853 |
Gear^.dY:= _0; |
|
854 |
Gear^.dX:= _0; |
|
855 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
856 |
exit |
|
857 |
end; |
|
7426
55b49cc1f33a
Changes for the benefit of pas2c. Use downto in for loops to avoid repeated calls of Random/GetRandom. Wrap nots.
nemo
parents:
7409
diff
changeset
|
858 |
isFalling:= (Gear^.dY.isNegative) or (not TestCollisionYKick(Gear, 1)); |
6581 | 859 |
if isFalling then |
860 |
begin |
|
861 |
if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then |
|
862 |
Gear^.dY:= _0; |
|
863 |
Gear^.State:= Gear^.State or gstMoving; |
|
864 |
if (CurrentHedgehog^.Gear = Gear) |
|
865 |
and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then |
|
866 |
begin |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
867 |
// TODO: why so aggressive at setting FollowGear when falling? |
6581 | 868 |
FollowGear:= Gear; |
869 |
end; |
|
870 |
if isUnderwater then |
|
871 |
Gear^.dY:= Gear^.dY + cGravity / _2 |
|
872 |
else |
|
873 |
begin |
|
874 |
Gear^.dY:= Gear^.dY + cGravity; |
|
875 |
// this set of circumstances could be less complex if jumping was more clearly identified |
|
876 |
if ((GameFlags and gfMoreWind) <> 0) and (((Gear^.Damage <> 0) |
|
877 |
or ((CurAmmoGear <> nil) and ((CurAmmoGear^.AmmoType = amJetpack) or (CurAmmoGear^.AmmoType = amBirdy))) |
|
878 |
or ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue))) then |
|
879 |
Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density |
|
880 |
end |
|
881 |
end |
|
882 |
else |
|
883 |
begin |
|
884 |
land:= TestCollisionYwithGear(Gear, 1); |
|
885 |
if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0) |
|
886 |
and ((Gear^.State and gstHHJumping) <> 0) then |
|
887 |
SetLittle(Gear^.dX); |
|
888 |
||
889 |
if not Gear^.dY.isNegative then |
|
890 |
begin |
|
891 |
CheckHHDamage(Gear); |
|
892 |
||
893 |
if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) |
|
894 |
and (Gear^.dX.QWordValue < _0_02.QWordValue) then |
|
895 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; // landing after high jump |
|
896 |
Gear^.State:= Gear^.State and (not (gstHHJumping or gstHHHJump)); |
|
897 |
Gear^.dY:= _0; |
|
898 |
end |
|
899 |
else |
|
900 |
Gear^.dY:= Gear^.dY + cGravity; |
|
901 |
||
902 |
if ((Gear^.State and gstMoving) <> 0) then |
|
903 |
begin |
|
904 |
if land and lfIce <> 0 then |
|
905 |
begin |
|
906 |
Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2) |
|
907 |
end |
|
908 |
else |
|
909 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
910 |
end |
|
911 |
end; |
|
912 |
||
913 |
if (Gear^.State <> 0) then |
|
914 |
DeleteCI(Gear); |
|
915 |
||
916 |
if isUnderwater then |
|
917 |
begin |
|
918 |
Gear^.dY:= Gear^.dY * _0_999; |
|
919 |
Gear^.dX:= Gear^.dX * _0_999; |
|
920 |
end; |
|
921 |
||
922 |
if (Gear^.State and gstMoving) <> 0 then |
|
923 |
if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
|
924 |
if not isFalling then |
|
925 |
if hwAbs(Gear^.dX) > _0_01 then |
|
926 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then |
|
927 |
begin |
|
928 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
929 |
Gear^.dX:= Gear^.dX * _0_96; |
|
930 |
Gear^.Y:= Gear^.Y - _1 |
|
931 |
end |
|
932 |
else |
|
933 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) then |
|
934 |
begin |
|
935 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
936 |
Gear^.dX:= Gear^.dX * _0_93; |
|
937 |
Gear^.Y:= Gear^.Y - _2 |
|
938 |
end |
|
939 |
else |
|
940 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) then |
|
941 |
begin |
|
942 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
943 |
Gear^.dX:= Gear^.dX * _0_9 ; |
|
944 |
Gear^.Y:= Gear^.Y - _3 |
|
945 |
end |
|
946 |
else |
|
947 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then |
|
948 |
begin |
|
949 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
950 |
Gear^.dX:= Gear^.dX * _0_87; |
|
951 |
Gear^.Y:= Gear^.Y - _4 |
|
952 |
end |
|
953 |
else |
|
954 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then |
|
955 |
begin |
|
956 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
957 |
Gear^.dX:= Gear^.dX * _0_84; |
|
958 |
Gear^.Y:= Gear^.Y - _5 |
|
959 |
end |
|
960 |
else |
|
961 |
if hwAbs(Gear^.dX) > _0_02 then |
|
962 |
Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
963 |
else |
|
964 |
begin |
|
965 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
966 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
967 |
Gear^.Y:= Gear^.Y+_1; |
|
968 |
SetLittle(Gear^.dX) |
|
969 |
end |
|
970 |
else |
|
971 |
begin |
|
972 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
973 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
974 |
Gear^.Y:= Gear^.Y+_1; |
|
975 |
SetLittle(Gear^.dX) |
|
976 |
end |
|
977 |
else if (hwAbs(Gear^.dX) > cLittle) |
|
978 |
and ((Gear^.State and gstHHJumping) = 0) then |
|
979 |
Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
980 |
else |
|
981 |
SetLittle(Gear^.dX); |
|
982 |
||
983 |
if (not isFalling) |
|
7362
53bcfc714cb3
Fix rare condition when hog's gear stucks in an infinite loop which adds 1 to its Y coordinate not checking for drowning
unc0rr
parents:
7339
diff
changeset
|
984 |
and (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
6581 | 985 |
begin |
986 |
Gear^.State:= Gear^.State and (not gstWinner); |
|
987 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
7426
55b49cc1f33a
Changes for the benefit of pas2c. Use downto in for loops to avoid repeated calls of Random/GetRandom. Wrap nots.
nemo
parents:
7409
diff
changeset
|
988 |
while (TestCollisionYWithGear(Gear,1) = 0) and (not CheckGearDrowning(Gear)) do |
6581 | 989 |
Gear^.Y:= Gear^.Y+_1; |
990 |
SetLittle(Gear^.dX); |
|
991 |
Gear^.dY:= _0 |
|
992 |
end |
|
993 |
else |
|
994 |
Gear^.State:= Gear^.State or gstMoving; |
|
995 |
||
996 |
if (Gear^.State and gstMoving) <> 0 then |
|
997 |
begin |
|
998 |
Gear^.State:= Gear^.State and (not gstAnimation); |
|
999 |
// ARTILLERY but not being moved by explosions |
|
1000 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1001 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1002 |
if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1)) |
|
1003 |
and TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
1004 |
begin |
|
1005 |
CheckHHDamage(Gear); |
|
1006 |
Gear^.dY:= _0; |
|
1007 |
Gear^.Y:= Gear^.Y + _1 |
|
1008 |
end; |
|
1009 |
CheckGearDrowning(Gear); |
|
1010 |
// hide target cursor if current hog is drowning |
|
1011 |
if (Gear^.State and gstDrowning) <> 0 then |
|
1012 |
if (CurrentHedgehog^.Gear = Gear) then |
|
1013 |
isCursorVisible:= false |
|
1014 |
end; |
|
1015 |
||
1016 |
if (hwAbs(Gear^.dY) > _0) and (Gear^.FlightTime > 0) and ((GameFlags and gfLowGravity) = 0) then |
|
1017 |
begin |
|
1018 |
inc(Gear^.FlightTime); |
|
1019 |
if Gear^.FlightTime = 3000 then |
|
1020 |
begin |
|
1021 |
AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage); |
|
1022 |
PlaySound(sndHomerun) |
|
1023 |
end; |
|
1024 |
end |
|
1025 |
else |
|
1026 |
begin |
|
1027 |
uStats.hedgehogFlight(Gear, Gear^.FlightTime); |
|
1028 |
Gear^.FlightTime:= 0; |
|
1029 |
end; |
|
1030 |
||
1031 |
end; |
|
1032 |
||
1033 |
procedure doStepHedgehogDriven(HHGear: PGear); |
|
1034 |
var t: PGear; |
|
1035 |
wasJumping: boolean; |
|
1036 |
Hedgehog: PHedgehog; |
|
1037 |
begin |
|
1038 |
Hedgehog:= HHGear^.Hedgehog; |
|
1039 |
if isInMultiShoot then |
|
1040 |
HHGear^.Message:= 0; |
|
1041 |
||
1042 |
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Utility) <> 0) and isInMultiShoot then |
|
1043 |
AllInactive:= true |
|
1044 |
else if not isInMultiShoot then |
|
1045 |
AllInactive:= false; |
|
1046 |
||
1047 |
if (TurnTimeLeft = 0) or (HHGear^.Damage > 0) then |
|
1048 |
begin |
|
1049 |
if TagTurnTimeLeft = 0 then |
|
1050 |
TagTurnTimeLeft:= TurnTimeLeft; |
|
1051 |
TurnTimeLeft:= 0; |
|
1052 |
isCursorVisible:= false; |
|
1053 |
HHGear^.State:= HHGear^.State and (not (gstHHDriven or gstAnimation or gstAttacking)); |
|
1054 |
AttackBar:= 0; |
|
1055 |
if HHGear^.Damage > 0 then |
|
1056 |
HHGear^.State:= HHGear^.State and (not (gstHHJumping or gstHHHJump)); |
|
1057 |
exit |
|
1058 |
end; |
|
1059 |
||
1060 |
if (HHGear^.State and gstAnimation) <> 0 then |
|
1061 |
begin |
|
1062 |
HHGear^.Message:= 0; |
|
1063 |
if (HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].VoiceDelay) and (HHGear^.Timer = 0) then |
|
7053 | 1064 |
PlaySoundV(Wavez[TWave(HHGear^.Tag)].Voice, Hedgehog^.Team^.voicepack); |
6581 | 1065 |
inc(HHGear^.Timer); |
1066 |
if HHGear^.Timer = Wavez[TWave(HHGear^.Tag)].Interval then |
|
1067 |
begin |
|
1068 |
HHGear^.Timer:= 0; |
|
1069 |
inc(HHGear^.Pos); |
|
1070 |
if HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].FramesCount then |
|
1071 |
HHGear^.State:= HHGear^.State and (not gstAnimation) |
|
1072 |
end; |
|
1073 |
exit |
|
1074 |
end; |
|
1075 |
||
1076 |
if ((HHGear^.State and gstMoving) <> 0) |
|
7028 | 1077 |
or (GHStepTicks = cHHStepTicks) |
6581 | 1078 |
or (CurAmmoGear <> nil) then // we are moving |
1079 |
begin |
|
1080 |
with Hedgehog^ do |
|
1081 |
if (CurAmmoGear = nil) |
|
1082 |
and (HHGear^.dY > _0_39) |
|
1083 |
and (CurAmmoType = amParachute) then |
|
1084 |
HHGear^.Message:= HHGear^.Message or gmAttack; |
|
1085 |
// check for case with ammo |
|
1086 |
t:= CheckGearNear(HHGear, gtCase, 36, 36); |
|
1087 |
if t <> nil then |
|
1088 |
PickUp(HHGear, t) |
|
1089 |
end; |
|
1090 |
||
1091 |
if (CurAmmoGear = nil) then |
|
1092 |
if (((HHGear^.Message and gmAttack) <> 0) |
|
1093 |
or ((HHGear^.State and gstAttacking) <> 0)) then |
|
1094 |
Attack(HHGear) // should be before others to avoid desync with '/put' msg and changing weapon msgs |
|
1095 |
else |
|
1096 |
else |
|
1097 |
with Hedgehog^ do |
|
1098 |
if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
1099 |
and ((HHGear^.Message and gmLJump) <> 0) |
|
1100 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then |
|
1101 |
begin |
|
1102 |
Attack(HHGear); |
|
1103 |
HHGear^.Message:= HHGear^.Message and (not gmLJump) |
|
1104 |
end; |
|
1105 |
||
1106 |
if (CurAmmoGear = nil) |
|
1107 |
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
1108 |
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) then |
|
1109 |
begin |
|
1110 |
if ((HHGear^.Message and gmSlot) <> 0) then |
|
1111 |
if ChangeAmmo(HHGear) then ApplyAmmoChanges(Hedgehog^); |
|
1112 |
||
1113 |
if ((HHGear^.Message and gmWeapon) <> 0) then |
|
1114 |
HHSetWeapon(HHGear); |
|
1115 |
||
1116 |
if ((HHGear^.Message and gmTimer) <> 0) then |
|
1117 |
HHSetTimer(HHGear); |
|
1118 |
end; |
|
1119 |
||
1120 |
if CurAmmoGear <> nil then |
|
1121 |
begin |
|
1122 |
CurAmmoGear^.Message:= HHGear^.Message; |
|
1123 |
exit |
|
1124 |
end; |
|
1125 |
||
1126 |
if not isInMultiShoot then |
|
1127 |
HedgehogChAngle(HHGear); |
|
1128 |
||
1129 |
if (HHGear^.State and gstMoving) <> 0 then |
|
1130 |
begin |
|
1131 |
wasJumping:= ((HHGear^.State and gstHHJumping) <> 0); |
|
1132 |
||
1133 |
if ((HHGear^.Message and gmHJump) <> 0) and wasJumping and ((HHGear^.State and gstHHHJump) = 0) then |
|
1134 |
if (not (hwAbs(HHGear^.dX) > cLittle)) and (HHGear^.dY < -_0_02) then |
|
1135 |
begin |
|
1136 |
HHGear^.State:= HHGear^.State or gstHHHJump; |
|
1137 |
HHGear^.dY:= -_0_25; |
|
1138 |
if not cArtillery then |
|
1139 |
HHGear^.dX:= -SignAs(_0_02, HHGear^.dX); |
|
7053 | 1140 |
PlaySoundV(sndJump2, Hedgehog^.Team^.voicepack) |
6581 | 1141 |
end; |
1142 |
||
1143 |
HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump)); |
|
1144 |
||
1145 |
if (not cArtillery) and wasJumping and TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
|
1146 |
SetLittle(HHGear^.dX); |
|
1147 |
||
1148 |
if Hedgehog^.Gear <> nil then |
|
1149 |
doStepHedgehogMoving(HHGear); |
|
1150 |
||
1151 |
if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then |
|
1152 |
begin |
|
1153 |
AddGearCI(HHGear); |
|
1154 |
if wasJumping then |
|
7028 | 1155 |
GHStepTicks:= 410 |
6581 | 1156 |
else |
7028 | 1157 |
GHStepTicks:= 95 |
6581 | 1158 |
end; |
1159 |
exit |
|
1160 |
end; |
|
1161 |
||
1162 |
if not isInMultiShoot and (Hedgehog^.Gear <> nil) then |
|
1163 |
begin |
|
7028 | 1164 |
if GHStepTicks > 0 then |
1165 |
dec(GHStepTicks); |
|
1166 |
if (GHStepTicks = 0) then |
|
6581 | 1167 |
HedgehogStep(HHGear) |
1168 |
end |
|
1169 |
end; |
|
1170 |
||
1171 |
//////////////////////////////////////////////////////////////////////////////// |
|
1172 |
procedure doStepHedgehogFree(Gear: PGear); |
|
1173 |
var prevState: Longword; |
|
1174 |
begin |
|
1175 |
prevState:= Gear^.State; |
|
1176 |
||
1177 |
doStepHedgehogMoving(Gear); |
|
1178 |
||
1179 |
if (Gear^.State and (gstMoving or gstDrowning)) <> 0 then |
|
1180 |
begin |
|
1181 |
if Gear^.Damage > 0 then |
|
1182 |
CalcRotationDirAngle(Gear); |
|
1183 |
AllInactive:= false; |
|
1184 |
exit |
|
1185 |
end; |
|
1186 |
||
1187 |
if (Gear^.Health = 0) then |
|
1188 |
begin |
|
1189 |
if PrvInactive or ((GameFlags and gfInfAttack) <> 0) then |
|
1190 |
begin |
|
1191 |
Gear^.Timer:= 0; |
|
1192 |
FollowGear:= Gear; |
|
1193 |
PrvInactive:= false; |
|
1194 |
AllInactive:= false; |
|
1195 |
||
1196 |
if (Gear^.State and gstHHGone) = 0 then |
|
1197 |
begin |
|
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6992
diff
changeset
|
1198 |
Gear^.Hedgehog^.Effects[hePoisoned] := 0; |
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6992
diff
changeset
|
1199 |
if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then |
6581 | 1200 |
begin |
1201 |
ResurrectHedgehog(Gear); |
|
1202 |
end |
|
1203 |
else |
|
1204 |
begin |
|
1205 |
Gear^.State:= (Gear^.State or gstHHDeath) and (not gstAnimation); |
|
1206 |
Gear^.doStep:= @doStepHedgehogDead; |
|
1207 |
// Death message |
|
1208 |
AddCaption(Format(GetEventString(eidDied), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
1209 |
end; |
|
1210 |
end |
|
1211 |
else |
|
1212 |
begin |
|
1213 |
Gear^.State:= Gear^.State and (not gstAnimation); |
|
1214 |
Gear^.doStep:= @doStepHedgehogGone; |
|
1215 |
||
1216 |
// Gone message |
|
1217 |
AddCaption(Format(GetEventString(eidGone), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
1218 |
end |
|
1219 |
end; |
|
1220 |
exit |
|
1221 |
end; |
|
1222 |
||
1223 |
if ((Gear^.State and gstWait) = 0) and |
|
1224 |
(prevState <> Gear^.State) then |
|
1225 |
begin |
|
1226 |
Gear^.State:= Gear^.State or gstWait; |
|
1227 |
Gear^.Timer:= 150 |
|
1228 |
end |
|
1229 |
else |
|
1230 |
begin |
|
1231 |
if Gear^.Timer = 0 then |
|
1232 |
begin |
|
1233 |
Gear^.State:= Gear^.State and (not (gstWait or gstLoser or gstWinner or gstAttacked or gstNotKickable or gstHHChooseTarget)); |
|
1234 |
Gear^.Active:= false; |
|
1235 |
AddGearCI(Gear); |
|
1236 |
exit |
|
1237 |
end |
|
1238 |
else dec(Gear^.Timer) |
|
1239 |
end; |
|
1240 |
||
1241 |
AllInactive:= false |
|
1242 |
end; |
|
1243 |
||
1244 |
//////////////////////////////////////////////////////////////////////////////// |
|
1245 |
procedure doStepHedgehog(Gear: PGear); |
|
1246 |
(* |
|
1247 |
var x,y,tx,ty: LongInt; |
|
1248 |
tdX, tdY, slope: hwFloat; |
|
1249 |
land: Word; *) |
|
1250 |
var slope: hwFloat; |
|
1251 |
begin |
|
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:
7375
diff
changeset
|
1252 |
CheckSum:= CheckSum xor Gear^.Hedgehog^.BotLevel; |
6581 | 1253 |
if (Gear^.Message and gmDestroy) <> 0 then |
1254 |
begin |
|
1255 |
DeleteGear(Gear); |
|
1256 |
exit |
|
1257 |
end; |
|
1258 |
||
1259 |
if (Gear^.State and gstHHDriven) = 0 then |
|
1260 |
doStepHedgehogFree(Gear) |
|
1261 |
else |
|
1262 |
begin |
|
1263 |
with Gear^.Hedgehog^ do |
|
1264 |
if Team^.hasGone then |
|
1265 |
TeamGoneEffect(Team^) |
|
1266 |
else |
|
1267 |
doStepHedgehogDriven(Gear) |
|
1268 |
end; |
|
1269 |
if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) |
|
1270 |
and (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0) |
|
1271 |
and (not Gear^.dY.isNegative) and (GameTicks mod (100*LongWOrd(hwRound(cMaxWindSpeed*2/cGravity))) = 0) |
|
1272 |
and (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then |
|
1273 |
begin |
|
1274 |
slope:= CalcSlopeBelowGear(Gear); |
|
1275 |
Gear^.dX:=Gear^.dX+slope*_0_07; |
|
1276 |
if slope.QWordValue <> 0 then |
|
1277 |
Gear^.State:= Gear^.State or gstMoving; |
|
1278 |
(* |
|
1279 |
x:= hwRound(Gear^.X); |
|
1280 |
y:= hwRound(Gear^.Y); |
|
1281 |
AddVisualGear(x, y, vgtSmokeTrace); |
|
1282 |
AddVisualGear(x - hwRound(_5*slope), y + hwRound(_5*slope), vgtSmokeTrace); |
|
1283 |
AddVisualGear(x + hwRound(_5*slope), y - hwRound(_5*slope), vgtSmokeTrace); |
|
1284 |
AddVisualGear(x - hwRound(_20 * slope), y + hwRound(_20 * slope), vgtSmokeTrace); |
|
1285 |
AddVisualGear(x + hwRound(_20 * slope), y - hwRound(_20 * slope), vgtSmokeTrace); |
|
1286 |
AddVisualGear(x - hwRound(_30 * slope), y + hwRound(_30 * slope), vgtSmokeTrace); |
|
1287 |
AddVisualGear(x + hwRound(_30 * slope), y - hwRound(_30 * slope), vgtSmokeTrace); |
|
1288 |
AddVisualGear(x - hwRound(_40 * slope), y + hwRound(_40 * slope), vgtSmokeTrace); |
|
1289 |
AddVisualGear(x + hwRound(_40 * slope), y - hwRound(_40 * slope), vgtSmokeTrace); |
|
1290 |
AddVisualGear(x - hwRound(_50 * slope), y + hwRound(_50 * slope), vgtSmokeTrace); |
|
1291 |
AddVisualGear(x + hwRound(_50 * slope), y - hwRound(_50 * slope), vgtSmokeTrace); *) |
|
1292 |
end |
|
1293 |
end; |
|
1294 |
||
1295 |
end. |