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