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