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