author | unc0rr |
Sun, 17 Jun 2012 21:45:49 +0400 | |
changeset 7258 | 722e8a0d89dc |
parent 7187 | aff30d80bd7b |
child 7194 | d8e68cbca7ee |
child 7272 | 71df899c4163 |
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; |
|
398 |
||
399 |
// Clear FollowGear if using on a rope/parachute/saucer etc so focus stays with the hog's movement |
|
400 |
if altUse then |
|
401 |
FollowGear:= nil; |
|
402 |
||
403 |
if (newGear <> nil) and ((Ammoz[newGear^.AmmoType].Ammo.Propz and ammoprop_SetBounce) <> 0) then |
|
404 |
begin |
|
405 |
elastic:= int2hwfloat(CurWeapon^.Bounciness) / _1000; |
|
406 |
||
407 |
if elastic < _1 then |
|
408 |
newGear^.Elasticity:= newGear^.Elasticity * elastic |
|
409 |
else if elastic > _1 then |
|
410 |
newGear^.Elasticity:= _1 - ((_1-newGear^.Elasticity) / elastic); |
|
411 |
(* Experimented with friction modifier. Didn't seem helpful |
|
412 |
fric:= int2hwfloat(CurWeapon^.Bounciness) / _250; |
|
413 |
if fric < _1 then newGear^.Friction:= newGear^.Friction * fric |
|
414 |
else if fric > _1 then newGear^.Friction:= _1 - ((_1-newGear^.Friction) / fric)*) |
|
415 |
end; |
|
416 |
||
417 |
||
418 |
uStats.AmmoUsed(CurAmmoType); |
|
419 |
||
420 |
if not (SpeechText = '') then |
|
421 |
begin |
|
422 |
speech:= AddVisualGear(0, 0, vgtSpeechBubble); |
|
423 |
if speech <> nil then |
|
424 |
begin |
|
425 |
speech^.Text:= SpeechText; |
|
426 |
speech^.Hedgehog:= Gear^.Hedgehog; |
|
427 |
speech^.FrameTicks:= SpeechType; |
|
428 |
end; |
|
429 |
SpeechText:= '' |
|
430 |
end; |
|
431 |
||
432 |
Power:= 0; |
|
433 |
if (CurAmmoGear <> nil) |
|
434 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) = 0){check for dropping ammo from rope} then |
|
435 |
begin |
|
436 |
Message:= Message or gmAttack; |
|
437 |
CurAmmoGear^.Message:= Message |
|
438 |
end |
|
439 |
else |
|
440 |
begin |
|
441 |
if not CurrentTeam^.ExtDriven |
|
442 |
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
|
443 |
SendIPC(_S'a'); |
6581 | 444 |
AfterAttack; |
445 |
end |
|
446 |
end |
|
447 |
else |
|
448 |
Message:= Message and (not gmAttack); |
|
449 |
end; |
|
450 |
TargetPoint.X := NoPointX; |
|
451 |
ScriptCall('onHogAttack'); |
|
452 |
end; |
|
453 |
||
454 |
procedure AfterAttack; |
|
455 |
var s: shortstring; |
|
456 |
a: TAmmoType; |
|
457 |
begin |
|
458 |
with CurrentHedgehog^.Gear^, CurrentHedgehog^ do |
|
459 |
begin |
|
460 |
a:= CurAmmoType; |
|
461 |
State:= State and (not gstAttacking); |
|
462 |
if (Ammoz[a].Ammo.Propz and ammoprop_Effect) = 0 then |
|
463 |
begin |
|
464 |
Inc(MultiShootAttacks); |
|
465 |
||
466 |
if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) then |
|
467 |
begin |
|
468 |
s:= inttostr(Ammoz[a].Ammo.NumPerTurn - MultiShootAttacks + 1); |
|
469 |
AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate); |
|
470 |
end; |
|
471 |
||
472 |
if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) |
|
473 |
or ((GameFlags and gfMultiWeapon) <> 0) then |
|
474 |
begin |
|
475 |
isInMultiShoot:= true |
|
476 |
end |
|
477 |
else |
|
478 |
begin |
|
479 |
OnUsedAmmo(CurrentHedgehog^); |
|
480 |
if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (((GameFlags and gfInfAttack) = 0) or PlacingHogs) then |
|
481 |
begin |
|
482 |
if TagTurnTimeLeft = 0 then |
|
483 |
TagTurnTimeLeft:= TurnTimeLeft; |
|
484 |
TurnTimeLeft:=(Ammoz[a].TimeAfterTurn * cGetAwayTime) div 100; |
|
485 |
end; |
|
486 |
if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) then |
|
487 |
State:= State or gstAttacked; |
|
488 |
if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then |
|
489 |
ApplyAmmoChanges(CurrentHedgehog^) |
|
490 |
end; |
|
491 |
end |
|
492 |
else |
|
493 |
begin |
|
494 |
OnUsedAmmo(CurrentHedgehog^); |
|
495 |
ApplyAmmoChanges(CurrentHedgehog^); |
|
496 |
end; |
|
497 |
AttackBar:= 0 |
|
498 |
end |
|
499 |
end; |
|
500 |
||
501 |
//////////////////////////////////////////////////////////////////////////////// |
|
502 |
procedure doStepHedgehogDead(Gear: PGear); |
|
503 |
const frametime = 200; |
|
504 |
timertime = frametime * 6; |
|
505 |
begin |
|
506 |
if Gear^.Hedgehog^.Unplaced then |
|
507 |
exit; |
|
508 |
if Gear^.Timer > 1 then |
|
509 |
begin |
|
510 |
AllInactive:= false; |
|
511 |
dec(Gear^.Timer); |
|
512 |
if (Gear^.Timer mod frametime) = 0 then |
|
513 |
inc(Gear^.Pos) |
|
514 |
end |
|
515 |
else if Gear^.Timer = 1 then |
|
516 |
begin |
|
517 |
Gear^.State:= Gear^.State or gstNoDamage; |
|
518 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, CurrentHedgehog, EXPLAutoSound); |
|
519 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
520 |
DeleteGear(Gear); |
|
521 |
SetAllToActive |
|
522 |
end |
|
523 |
else // Gear^.Timer = 0 |
|
524 |
begin |
|
525 |
AllInactive:= false; |
|
526 |
Gear^.Z:= cCurrHHZ; |
|
527 |
RemoveGearFromList(Gear); |
|
528 |
InsertGearToList(Gear); |
|
7053 | 529 |
PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 530 |
Gear^.Pos:= 0; |
531 |
Gear^.Timer:= timertime |
|
532 |
end |
|
533 |
end; |
|
534 |
||
535 |
//////////////////////////////////////////////////////////////////////////////// |
|
536 |
procedure doStepHedgehogGone(Gear: PGear); |
|
537 |
const frametime = 65; |
|
538 |
timertime = frametime * 11; |
|
539 |
begin |
|
540 |
if Gear^.Hedgehog^.Unplaced then |
|
541 |
exit; |
|
542 |
if Gear^.Timer > 1 then |
|
543 |
begin |
|
544 |
AllInactive:= false; |
|
545 |
dec(Gear^.Timer); |
|
546 |
if (Gear^.Timer mod frametime) = 0 then |
|
547 |
inc(Gear^.Pos) |
|
548 |
end |
|
549 |
else |
|
550 |
if Gear^.Timer = 1 then |
|
551 |
begin |
|
552 |
DeleteGear(Gear); |
|
553 |
SetAllToActive |
|
554 |
end |
|
555 |
else // Gear^.Timer = 0 |
|
556 |
begin |
|
557 |
AllInactive:= false; |
|
558 |
Gear^.Z:= cCurrHHZ; |
|
559 |
RemoveGearFromList(Gear); |
|
560 |
InsertGearToList(Gear); |
|
7053 | 561 |
PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 562 |
PlaySound(sndWarp); |
563 |
Gear^.Pos:= 0; |
|
564 |
Gear^.Timer:= timertime |
|
565 |
end |
|
566 |
end; |
|
567 |
||
568 |
//////////////////////////////////////////////////////////////////////////////// |
|
569 |
procedure PickUp(HH, Gear: PGear); |
|
570 |
var s: shortstring; |
|
571 |
a: TAmmoType; |
|
572 |
i: LongInt; |
|
573 |
vga: PVisualGear; |
|
574 |
begin |
|
575 |
Gear^.Message:= gmDestroy; |
|
576 |
PlaySound(sndShotgunReload); |
|
577 |
if (Gear^.Pos and posCaseExplode) <> 0 then |
|
578 |
if (Gear^.Pos and posCasePoison) <> 0 then |
|
579 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned) |
|
580 |
else |
|
581 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound) |
|
582 |
else if (Gear^.Pos and posCasePoison) <> 0 then |
|
583 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned + EXPLNoDamage) |
|
584 |
else |
|
585 |
case Gear^.Pos of |
|
586 |
posCaseUtility, |
|
587 |
posCaseAmmo: begin |
|
588 |
if Gear^.AmmoType <> amNothing then a:= Gear^.AmmoType |
|
589 |
else |
|
590 |
begin |
|
591 |
for i:= 0 to GameTicks and $7F do |
|
592 |
GetRandom(2); // Burn some random numbers |
|
593 |
if Gear^.Pos = posCaseUtility then |
|
594 |
a:= GetUtility(HH^.Hedgehog) |
|
595 |
else |
|
596 |
a:= GetAmmo(HH^.Hedgehog) |
|
597 |
end; |
|
598 |
AddAmmo(HH^.Hedgehog^, a); |
|
599 |
// Possibly needs to check shared clan ammo game flag once added. |
|
600 |
// On the other hand, no obvious reason that clan members shouldn't know what ammo another clan member picked up |
|
601 |
if (not (HH^.Hedgehog^.Team^.ExtDriven |
|
602 |
or (HH^.Hedgehog^.BotLevel > 0))) |
|
603 |
or (HH^.Hedgehog^.Team^.Clan^.ClanIndex = LocalClan) |
|
604 |
or (GameType = gmtDemo) then |
|
605 |
begin |
|
606 |
s:= trammo[Ammoz[a].NameId] + ' (+' + IntToStr(Ammoz[a].NumberInCase) + ')'; |
|
607 |
AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
|
608 |
||
609 |
// show ammo icon |
|
610 |
vga:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtAmmo); |
|
611 |
if vga <> nil then |
|
612 |
vga^.Frame:= Longword(a); |
|
613 |
end; |
|
614 |
||
615 |
end; |
|
616 |
posCaseHealth: begin |
|
617 |
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
|
618 |
HH^.Hedgehog^.Effects[hePoisoned] := 0; |
6581 | 619 |
str(Gear^.Health, s); |
620 |
s:= '+' + s; |
|
621 |
AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
|
622 |
RenderHealth(HH^.Hedgehog^); |
|
623 |
RecountTeamHealth(HH^.Hedgehog^.Team); |
|
624 |
||
625 |
i:= 0; |
|
626 |
while i < Gear^.Health do |
|
627 |
begin |
|
628 |
vga:= AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtStraightShot); |
|
629 |
if vga <> nil then |
|
630 |
with vga^ do |
|
631 |
begin |
|
632 |
Tint:= $00FF00FF; |
|
633 |
State:= ord(sprHealth) |
|
634 |
end; |
|
635 |
inc(i, 5); |
|
636 |
end; |
|
637 |
end; |
|
638 |
end |
|
639 |
end; |
|
640 |
||
641 |
procedure HedgehogStep(Gear: PGear); |
|
642 |
var PrevdX: LongInt; |
|
643 |
CurWeapon: PAmmo; |
|
644 |
begin |
|
6924 | 645 |
CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^); |
6581 | 646 |
if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then |
647 |
begin |
|
648 |
if isCursorVisible then |
|
649 |
with Gear^.Hedgehog^ do |
|
650 |
with CurWeapon^ do |
|
651 |
begin |
|
652 |
if (Gear^.Message and gmLeft ) <> 0 then |
|
653 |
Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount |
|
654 |
else |
|
655 |
if (Gear^.Message and gmRight ) <> 0 then |
|
656 |
Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount |
|
657 |
else |
|
658 |
exit; |
|
7028 | 659 |
GHStepTicks:= 200; |
6581 | 660 |
exit |
661 |
end; |
|
662 |
||
663 |
if ((Gear^.Message and gmAnimate) <> 0) then |
|
664 |
begin |
|
665 |
Gear^.Message:= 0; |
|
666 |
Gear^.State:= Gear^.State or gstAnimation; |
|
667 |
Gear^.Tag:= Gear^.MsgParam; |
|
668 |
Gear^.Timer:= 0; |
|
669 |
Gear^.Pos:= 0 |
|
670 |
end; |
|
671 |
||
672 |
if ((Gear^.Message and gmLJump ) <> 0) then |
|
673 |
begin |
|
674 |
Gear^.Message:= Gear^.Message and (not gmLJump); |
|
675 |
DeleteCI(Gear); |
|
676 |
if TestCollisionYwithGear(Gear, -1) = 0 then |
|
677 |
if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then |
|
678 |
Gear^.Y:= Gear^.Y - _2 |
|
679 |
else |
|
680 |
if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then |
|
681 |
Gear^.Y:= Gear^.Y - _1; |
|
682 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
|
683 |
or (TestCollisionYwithGear(Gear, -1) <> 0)) then |
|
684 |
begin |
|
685 |
Gear^.dY:= -_0_15; |
|
686 |
if not cArtillery then |
|
687 |
Gear^.dX:= SignAs(_0_15, Gear^.dX); |
|
688 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
|
7053 | 689 |
PlaySoundV(sndJump1, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 690 |
exit |
691 |
end; |
|
692 |
end; |
|
693 |
||
694 |
if ((Gear^.Message and gmHJump ) <> 0) then |
|
695 |
begin |
|
696 |
DeleteCI(Gear); |
|
697 |
Gear^.Message:= Gear^.Message and (not gmHJump); |
|
698 |
||
699 |
Gear^.dY:= -_0_2; |
|
700 |
SetLittle(Gear^.dX); |
|
701 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
|
7053 | 702 |
PlaySoundV(sndJump3, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 703 |
exit |
704 |
end; |
|
705 |
||
706 |
PrevdX:= hwSign(Gear^.dX); |
|
707 |
if (Gear^.Message and gmLeft )<>0 then |
|
708 |
Gear^.dX:= -cLittle else |
|
709 |
if (Gear^.Message and gmRight )<>0 then |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
710 |
Gear^.dX:= cLittle |
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
711 |
else exit; |
6581 | 712 |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
713 |
StepSoundTimer:= cHHStepTicks; |
6581 | 714 |
|
7028 | 715 |
GHStepTicks:= cHHStepTicks; |
6581 | 716 |
if PrevdX <> hwSign(Gear^.dX) then |
717 |
begin |
|
718 |
FollowGear:= Gear; |
|
719 |
exit |
|
720 |
end; |
|
721 |
DeleteCI(Gear); // must be after exit!! (see previous line) |
|
722 |
||
723 |
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
|
724 |
|
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
|
725 |
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
|
726 |
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
|
727 |
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
|
728 |
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
|
729 |
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
|
730 |
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
|
731 |
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
|
732 |
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
|
733 |
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
|
734 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
6581 | 735 |
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
|
736 |
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
|
737 |
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
|
738 |
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
|
739 |
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
|
740 |
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
|
741 |
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
|
742 |
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
|
743 |
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
|
744 |
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
|
745 |
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
|
746 |
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
|
747 |
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
|
748 |
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
|
749 |
end else Gear^.Y:= Gear^.Y + _1 |
6581 | 750 |
end; |
751 |
||
752 |
if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then |
|
753 |
Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
|
754 |
||
755 |
SetAllHHToActive; |
|
756 |
||
757 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
758 |
begin |
|
759 |
Gear^.Y:= Gear^.Y + _1; |
|
760 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
761 |
begin |
|
762 |
Gear^.Y:= Gear^.Y + _1; |
|
763 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
764 |
begin |
|
765 |
Gear^.Y:= Gear^.Y + _1; |
|
766 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
767 |
begin |
|
768 |
Gear^.Y:= Gear^.Y + _1; |
|
769 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
770 |
begin |
|
771 |
Gear^.Y:= Gear^.Y + _1; |
|
772 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
773 |
begin |
|
774 |
Gear^.Y:= Gear^.Y + _1; |
|
775 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
776 |
begin |
|
777 |
Gear^.Y:= Gear^.Y - _6; |
|
778 |
Gear^.dY:= _0; |
|
779 |
Gear^.State:= Gear^.State or gstMoving; |
|
780 |
exit |
|
781 |
end; |
|
782 |
end |
|
783 |
end |
|
784 |
end |
|
785 |
end |
|
786 |
end |
|
787 |
end; |
|
788 |
AddGearCI(Gear) |
|
789 |
end |
|
790 |
end; |
|
791 |
||
792 |
procedure HedgehogChAngle(HHGear: PGear); |
|
793 |
var da: LongWord; |
|
794 |
begin |
|
795 |
with HHGear^.Hedgehog^ do |
|
796 |
if ((CurAmmoType = amRope) and ((HHGear^.State and (gstMoving or gstHHJumping)) = gstMoving)) |
|
797 |
or ((CurAmmoType = amPortalGun) and ((HHGear^.State and gstMoving) <> 0)) then |
|
798 |
da:= 2 |
|
799 |
else da:= 1; |
|
800 |
||
801 |
if (((HHGear^.Message and gmPrecise) = 0) or ((GameTicks mod 5) = 1)) then |
|
802 |
if ((HHGear^.Message and gmUp) <> 0) and (HHGear^.Angle >= CurMinAngle + da) then |
|
803 |
dec(HHGear^.Angle, da) |
|
804 |
else |
|
805 |
if ((HHGear^.Message and gmDown) <> 0) and (HHGear^.Angle + da <= CurMaxAngle) then |
|
806 |
inc(HHGear^.Angle, da) |
|
807 |
end; |
|
808 |
||
809 |
||
810 |
//////////////////////////////////////////////////////////////////////////////// |
|
811 |
procedure doStepHedgehogMoving(Gear: PGear); |
|
812 |
var isFalling, isUnderwater: boolean; |
|
813 |
land: Word; |
|
814 |
begin |
|
815 |
land:= 0; |
|
816 |
isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius; |
|
817 |
if Gear^.dX.QWordValue > 8160437862 then |
|
818 |
Gear^.dX.QWordValue:= 8160437862; |
|
819 |
if Gear^.dY.QWordValue > 8160437862 then |
|
820 |
Gear^.dY.QWordValue:= 8160437862; |
|
821 |
||
822 |
if Gear^.Hedgehog^.Unplaced then |
|
823 |
begin |
|
824 |
Gear^.dY:= _0; |
|
825 |
Gear^.dX:= _0; |
|
826 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
827 |
exit |
|
828 |
end; |
|
829 |
isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1); |
|
830 |
if isFalling then |
|
831 |
begin |
|
832 |
if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then |
|
833 |
Gear^.dY:= _0; |
|
834 |
Gear^.State:= Gear^.State or gstMoving; |
|
835 |
if (CurrentHedgehog^.Gear = Gear) |
|
836 |
and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then |
|
837 |
begin |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
838 |
// TODO: why so aggressive at setting FollowGear when falling? |
6581 | 839 |
FollowGear:= Gear; |
840 |
end; |
|
841 |
if isUnderwater then |
|
842 |
Gear^.dY:= Gear^.dY + cGravity / _2 |
|
843 |
else |
|
844 |
begin |
|
845 |
Gear^.dY:= Gear^.dY + cGravity; |
|
846 |
// this set of circumstances could be less complex if jumping was more clearly identified |
|
847 |
if ((GameFlags and gfMoreWind) <> 0) and (((Gear^.Damage <> 0) |
|
848 |
or ((CurAmmoGear <> nil) and ((CurAmmoGear^.AmmoType = amJetpack) or (CurAmmoGear^.AmmoType = amBirdy))) |
|
849 |
or ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue))) then |
|
850 |
Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density |
|
851 |
end |
|
852 |
end |
|
853 |
else |
|
854 |
begin |
|
855 |
land:= TestCollisionYwithGear(Gear, 1); |
|
856 |
if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0) |
|
857 |
and ((Gear^.State and gstHHJumping) <> 0) then |
|
858 |
SetLittle(Gear^.dX); |
|
859 |
||
860 |
if not Gear^.dY.isNegative then |
|
861 |
begin |
|
862 |
CheckHHDamage(Gear); |
|
863 |
||
864 |
if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) |
|
865 |
and (Gear^.dX.QWordValue < _0_02.QWordValue) then |
|
866 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; // landing after high jump |
|
867 |
Gear^.State:= Gear^.State and (not (gstHHJumping or gstHHHJump)); |
|
868 |
Gear^.dY:= _0; |
|
869 |
end |
|
870 |
else |
|
871 |
Gear^.dY:= Gear^.dY + cGravity; |
|
872 |
||
873 |
if ((Gear^.State and gstMoving) <> 0) then |
|
874 |
begin |
|
875 |
if land and lfIce <> 0 then |
|
876 |
begin |
|
877 |
Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2) |
|
878 |
end |
|
879 |
else |
|
880 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
881 |
end |
|
882 |
end; |
|
883 |
||
884 |
if (Gear^.State <> 0) then |
|
885 |
DeleteCI(Gear); |
|
886 |
||
887 |
if isUnderwater then |
|
888 |
begin |
|
889 |
Gear^.dY:= Gear^.dY * _0_999; |
|
890 |
Gear^.dX:= Gear^.dX * _0_999; |
|
891 |
end; |
|
892 |
||
893 |
if (Gear^.State and gstMoving) <> 0 then |
|
894 |
if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
|
895 |
if not isFalling then |
|
896 |
if hwAbs(Gear^.dX) > _0_01 then |
|
897 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then |
|
898 |
begin |
|
899 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
900 |
Gear^.dX:= Gear^.dX * _0_96; |
|
901 |
Gear^.Y:= Gear^.Y - _1 |
|
902 |
end |
|
903 |
else |
|
904 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) then |
|
905 |
begin |
|
906 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
907 |
Gear^.dX:= Gear^.dX * _0_93; |
|
908 |
Gear^.Y:= Gear^.Y - _2 |
|
909 |
end |
|
910 |
else |
|
911 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) then |
|
912 |
begin |
|
913 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
914 |
Gear^.dX:= Gear^.dX * _0_9 ; |
|
915 |
Gear^.Y:= Gear^.Y - _3 |
|
916 |
end |
|
917 |
else |
|
918 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then |
|
919 |
begin |
|
920 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
921 |
Gear^.dX:= Gear^.dX * _0_87; |
|
922 |
Gear^.Y:= Gear^.Y - _4 |
|
923 |
end |
|
924 |
else |
|
925 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then |
|
926 |
begin |
|
927 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
928 |
Gear^.dX:= Gear^.dX * _0_84; |
|
929 |
Gear^.Y:= Gear^.Y - _5 |
|
930 |
end |
|
931 |
else |
|
932 |
if hwAbs(Gear^.dX) > _0_02 then |
|
933 |
Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
934 |
else |
|
935 |
begin |
|
936 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
937 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
938 |
Gear^.Y:= Gear^.Y+_1; |
|
939 |
SetLittle(Gear^.dX) |
|
940 |
end |
|
941 |
else |
|
942 |
begin |
|
943 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
944 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
945 |
Gear^.Y:= Gear^.Y+_1; |
|
946 |
SetLittle(Gear^.dX) |
|
947 |
end |
|
948 |
else if (hwAbs(Gear^.dX) > cLittle) |
|
949 |
and ((Gear^.State and gstHHJumping) = 0) then |
|
950 |
Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
951 |
else |
|
952 |
SetLittle(Gear^.dX); |
|
953 |
||
954 |
if (not isFalling) |
|
955 |
and (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
|
956 |
begin |
|
957 |
Gear^.State:= Gear^.State and (not gstWinner); |
|
958 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
959 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
960 |
Gear^.Y:= Gear^.Y+_1; |
|
961 |
SetLittle(Gear^.dX); |
|
962 |
Gear^.dY:= _0 |
|
963 |
end |
|
964 |
else |
|
965 |
Gear^.State:= Gear^.State or gstMoving; |
|
966 |
||
967 |
if (Gear^.State and gstMoving) <> 0 then |
|
968 |
begin |
|
969 |
Gear^.State:= Gear^.State and (not gstAnimation); |
|
970 |
// ARTILLERY but not being moved by explosions |
|
971 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
972 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
973 |
if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1)) |
|
974 |
and TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
975 |
begin |
|
976 |
CheckHHDamage(Gear); |
|
977 |
Gear^.dY:= _0; |
|
978 |
Gear^.Y:= Gear^.Y + _1 |
|
979 |
end; |
|
980 |
CheckGearDrowning(Gear); |
|
981 |
// hide target cursor if current hog is drowning |
|
982 |
if (Gear^.State and gstDrowning) <> 0 then |
|
983 |
if (CurrentHedgehog^.Gear = Gear) then |
|
984 |
isCursorVisible:= false |
|
985 |
end; |
|
986 |
||
987 |
if (hwAbs(Gear^.dY) > _0) and (Gear^.FlightTime > 0) and ((GameFlags and gfLowGravity) = 0) then |
|
988 |
begin |
|
989 |
inc(Gear^.FlightTime); |
|
990 |
if Gear^.FlightTime = 3000 then |
|
991 |
begin |
|
992 |
AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage); |
|
993 |
PlaySound(sndHomerun) |
|
994 |
end; |
|
995 |
end |
|
996 |
else |
|
997 |
begin |
|
998 |
uStats.hedgehogFlight(Gear, Gear^.FlightTime); |
|
999 |
Gear^.FlightTime:= 0; |
|
1000 |
end; |
|
1001 |
||
1002 |
end; |
|
1003 |
||
1004 |
procedure doStepHedgehogDriven(HHGear: PGear); |
|
1005 |
var t: PGear; |
|
1006 |
wasJumping: boolean; |
|
1007 |
Hedgehog: PHedgehog; |
|
1008 |
begin |
|
1009 |
Hedgehog:= HHGear^.Hedgehog; |
|
1010 |
if isInMultiShoot then |
|
1011 |
HHGear^.Message:= 0; |
|
1012 |
||
1013 |
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Utility) <> 0) and isInMultiShoot then |
|
1014 |
AllInactive:= true |
|
1015 |
else if not isInMultiShoot then |
|
1016 |
AllInactive:= false; |
|
1017 |
||
1018 |
if (TurnTimeLeft = 0) or (HHGear^.Damage > 0) then |
|
1019 |
begin |
|
1020 |
if TagTurnTimeLeft = 0 then |
|
1021 |
TagTurnTimeLeft:= TurnTimeLeft; |
|
1022 |
TurnTimeLeft:= 0; |
|
1023 |
isCursorVisible:= false; |
|
1024 |
HHGear^.State:= HHGear^.State and (not (gstHHDriven or gstAnimation or gstAttacking)); |
|
1025 |
AttackBar:= 0; |
|
1026 |
if HHGear^.Damage > 0 then |
|
1027 |
HHGear^.State:= HHGear^.State and (not (gstHHJumping or gstHHHJump)); |
|
1028 |
exit |
|
1029 |
end; |
|
1030 |
||
1031 |
if (HHGear^.State and gstAnimation) <> 0 then |
|
1032 |
begin |
|
1033 |
HHGear^.Message:= 0; |
|
1034 |
if (HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].VoiceDelay) and (HHGear^.Timer = 0) then |
|
7053 | 1035 |
PlaySoundV(Wavez[TWave(HHGear^.Tag)].Voice, Hedgehog^.Team^.voicepack); |
6581 | 1036 |
inc(HHGear^.Timer); |
1037 |
if HHGear^.Timer = Wavez[TWave(HHGear^.Tag)].Interval then |
|
1038 |
begin |
|
1039 |
HHGear^.Timer:= 0; |
|
1040 |
inc(HHGear^.Pos); |
|
1041 |
if HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].FramesCount then |
|
1042 |
HHGear^.State:= HHGear^.State and (not gstAnimation) |
|
1043 |
end; |
|
1044 |
exit |
|
1045 |
end; |
|
1046 |
||
1047 |
if ((HHGear^.State and gstMoving) <> 0) |
|
7028 | 1048 |
or (GHStepTicks = cHHStepTicks) |
6581 | 1049 |
or (CurAmmoGear <> nil) then // we are moving |
1050 |
begin |
|
1051 |
with Hedgehog^ do |
|
1052 |
if (CurAmmoGear = nil) |
|
1053 |
and (HHGear^.dY > _0_39) |
|
1054 |
and (CurAmmoType = amParachute) then |
|
1055 |
HHGear^.Message:= HHGear^.Message or gmAttack; |
|
1056 |
// check for case with ammo |
|
1057 |
t:= CheckGearNear(HHGear, gtCase, 36, 36); |
|
1058 |
if t <> nil then |
|
1059 |
PickUp(HHGear, t) |
|
1060 |
end; |
|
1061 |
||
1062 |
if (CurAmmoGear = nil) then |
|
1063 |
if (((HHGear^.Message and gmAttack) <> 0) |
|
1064 |
or ((HHGear^.State and gstAttacking) <> 0)) then |
|
1065 |
Attack(HHGear) // should be before others to avoid desync with '/put' msg and changing weapon msgs |
|
1066 |
else |
|
1067 |
else |
|
1068 |
with Hedgehog^ do |
|
1069 |
if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
1070 |
and ((HHGear^.Message and gmLJump) <> 0) |
|
1071 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then |
|
1072 |
begin |
|
1073 |
Attack(HHGear); |
|
1074 |
HHGear^.Message:= HHGear^.Message and (not gmLJump) |
|
1075 |
end; |
|
1076 |
||
1077 |
if (CurAmmoGear = nil) |
|
1078 |
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
1079 |
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) then |
|
1080 |
begin |
|
1081 |
if ((HHGear^.Message and gmSlot) <> 0) then |
|
1082 |
if ChangeAmmo(HHGear) then ApplyAmmoChanges(Hedgehog^); |
|
1083 |
||
1084 |
if ((HHGear^.Message and gmWeapon) <> 0) then |
|
1085 |
HHSetWeapon(HHGear); |
|
1086 |
||
1087 |
if ((HHGear^.Message and gmTimer) <> 0) then |
|
1088 |
HHSetTimer(HHGear); |
|
1089 |
end; |
|
1090 |
||
1091 |
if CurAmmoGear <> nil then |
|
1092 |
begin |
|
1093 |
CurAmmoGear^.Message:= HHGear^.Message; |
|
1094 |
exit |
|
1095 |
end; |
|
1096 |
||
1097 |
if not isInMultiShoot then |
|
1098 |
HedgehogChAngle(HHGear); |
|
1099 |
||
1100 |
if (HHGear^.State and gstMoving) <> 0 then |
|
1101 |
begin |
|
1102 |
wasJumping:= ((HHGear^.State and gstHHJumping) <> 0); |
|
1103 |
||
1104 |
if ((HHGear^.Message and gmHJump) <> 0) and wasJumping and ((HHGear^.State and gstHHHJump) = 0) then |
|
1105 |
if (not (hwAbs(HHGear^.dX) > cLittle)) and (HHGear^.dY < -_0_02) then |
|
1106 |
begin |
|
1107 |
HHGear^.State:= HHGear^.State or gstHHHJump; |
|
1108 |
HHGear^.dY:= -_0_25; |
|
1109 |
if not cArtillery then |
|
1110 |
HHGear^.dX:= -SignAs(_0_02, HHGear^.dX); |
|
7053 | 1111 |
PlaySoundV(sndJump2, Hedgehog^.Team^.voicepack) |
6581 | 1112 |
end; |
1113 |
||
1114 |
HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump)); |
|
1115 |
||
1116 |
if (not cArtillery) and wasJumping and TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
|
1117 |
SetLittle(HHGear^.dX); |
|
1118 |
||
1119 |
if Hedgehog^.Gear <> nil then |
|
1120 |
doStepHedgehogMoving(HHGear); |
|
1121 |
||
1122 |
if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then |
|
1123 |
begin |
|
1124 |
AddGearCI(HHGear); |
|
1125 |
if wasJumping then |
|
7028 | 1126 |
GHStepTicks:= 410 |
6581 | 1127 |
else |
7028 | 1128 |
GHStepTicks:= 95 |
6581 | 1129 |
end; |
1130 |
exit |
|
1131 |
end; |
|
1132 |
||
1133 |
if not isInMultiShoot and (Hedgehog^.Gear <> nil) then |
|
1134 |
begin |
|
7028 | 1135 |
if GHStepTicks > 0 then |
1136 |
dec(GHStepTicks); |
|
1137 |
if (GHStepTicks = 0) then |
|
6581 | 1138 |
HedgehogStep(HHGear) |
1139 |
end |
|
1140 |
end; |
|
1141 |
||
1142 |
//////////////////////////////////////////////////////////////////////////////// |
|
1143 |
procedure doStepHedgehogFree(Gear: PGear); |
|
1144 |
var prevState: Longword; |
|
1145 |
begin |
|
1146 |
prevState:= Gear^.State; |
|
1147 |
||
1148 |
doStepHedgehogMoving(Gear); |
|
1149 |
||
1150 |
if (Gear^.State and (gstMoving or gstDrowning)) <> 0 then |
|
1151 |
begin |
|
1152 |
if Gear^.Damage > 0 then |
|
1153 |
CalcRotationDirAngle(Gear); |
|
1154 |
AllInactive:= false; |
|
1155 |
exit |
|
1156 |
end; |
|
1157 |
||
1158 |
if (Gear^.Health = 0) then |
|
1159 |
begin |
|
1160 |
if PrvInactive or ((GameFlags and gfInfAttack) <> 0) then |
|
1161 |
begin |
|
1162 |
Gear^.Timer:= 0; |
|
1163 |
FollowGear:= Gear; |
|
1164 |
PrvInactive:= false; |
|
1165 |
AllInactive:= false; |
|
1166 |
||
1167 |
if (Gear^.State and gstHHGone) = 0 then |
|
1168 |
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
|
1169 |
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
|
1170 |
if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then |
6581 | 1171 |
begin |
1172 |
ResurrectHedgehog(Gear); |
|
1173 |
end |
|
1174 |
else |
|
1175 |
begin |
|
1176 |
Gear^.State:= (Gear^.State or gstHHDeath) and (not gstAnimation); |
|
1177 |
Gear^.doStep:= @doStepHedgehogDead; |
|
1178 |
// Death message |
|
1179 |
AddCaption(Format(GetEventString(eidDied), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
1180 |
end; |
|
1181 |
end |
|
1182 |
else |
|
1183 |
begin |
|
1184 |
Gear^.State:= Gear^.State and (not gstAnimation); |
|
1185 |
Gear^.doStep:= @doStepHedgehogGone; |
|
1186 |
||
1187 |
// Gone message |
|
1188 |
AddCaption(Format(GetEventString(eidGone), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
1189 |
end |
|
1190 |
end; |
|
1191 |
exit |
|
1192 |
end; |
|
1193 |
||
1194 |
if ((Gear^.State and gstWait) = 0) and |
|
1195 |
(prevState <> Gear^.State) then |
|
1196 |
begin |
|
1197 |
Gear^.State:= Gear^.State or gstWait; |
|
1198 |
Gear^.Timer:= 150 |
|
1199 |
end |
|
1200 |
else |
|
1201 |
begin |
|
1202 |
if Gear^.Timer = 0 then |
|
1203 |
begin |
|
1204 |
Gear^.State:= Gear^.State and (not (gstWait or gstLoser or gstWinner or gstAttacked or gstNotKickable or gstHHChooseTarget)); |
|
1205 |
Gear^.Active:= false; |
|
1206 |
AddGearCI(Gear); |
|
1207 |
exit |
|
1208 |
end |
|
1209 |
else dec(Gear^.Timer) |
|
1210 |
end; |
|
1211 |
||
1212 |
AllInactive:= false |
|
1213 |
end; |
|
1214 |
||
1215 |
//////////////////////////////////////////////////////////////////////////////// |
|
1216 |
procedure doStepHedgehog(Gear: PGear); |
|
1217 |
(* |
|
1218 |
var x,y,tx,ty: LongInt; |
|
1219 |
tdX, tdY, slope: hwFloat; |
|
1220 |
land: Word; *) |
|
1221 |
var slope: hwFloat; |
|
1222 |
begin |
|
1223 |
if (Gear^.Message and gmDestroy) <> 0 then |
|
1224 |
begin |
|
1225 |
DeleteGear(Gear); |
|
1226 |
exit |
|
1227 |
end; |
|
1228 |
||
1229 |
if (Gear^.State and gstHHDriven) = 0 then |
|
1230 |
doStepHedgehogFree(Gear) |
|
1231 |
else |
|
1232 |
begin |
|
1233 |
with Gear^.Hedgehog^ do |
|
1234 |
if Team^.hasGone then |
|
1235 |
TeamGoneEffect(Team^) |
|
1236 |
else |
|
1237 |
doStepHedgehogDriven(Gear) |
|
1238 |
end; |
|
1239 |
if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) |
|
1240 |
and (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0) |
|
1241 |
and (not Gear^.dY.isNegative) and (GameTicks mod (100*LongWOrd(hwRound(cMaxWindSpeed*2/cGravity))) = 0) |
|
1242 |
and (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then |
|
1243 |
begin |
|
1244 |
slope:= CalcSlopeBelowGear(Gear); |
|
1245 |
Gear^.dX:=Gear^.dX+slope*_0_07; |
|
1246 |
if slope.QWordValue <> 0 then |
|
1247 |
Gear^.State:= Gear^.State or gstMoving; |
|
1248 |
(* |
|
1249 |
x:= hwRound(Gear^.X); |
|
1250 |
y:= hwRound(Gear^.Y); |
|
1251 |
AddVisualGear(x, y, vgtSmokeTrace); |
|
1252 |
AddVisualGear(x - hwRound(_5*slope), y + hwRound(_5*slope), vgtSmokeTrace); |
|
1253 |
AddVisualGear(x + hwRound(_5*slope), y - hwRound(_5*slope), vgtSmokeTrace); |
|
1254 |
AddVisualGear(x - hwRound(_20 * slope), y + hwRound(_20 * slope), vgtSmokeTrace); |
|
1255 |
AddVisualGear(x + hwRound(_20 * slope), y - hwRound(_20 * slope), vgtSmokeTrace); |
|
1256 |
AddVisualGear(x - hwRound(_30 * slope), y + hwRound(_30 * slope), vgtSmokeTrace); |
|
1257 |
AddVisualGear(x + hwRound(_30 * slope), y - hwRound(_30 * slope), vgtSmokeTrace); |
|
1258 |
AddVisualGear(x - hwRound(_40 * slope), y + hwRound(_40 * slope), vgtSmokeTrace); |
|
1259 |
AddVisualGear(x + hwRound(_40 * slope), y - hwRound(_40 * slope), vgtSmokeTrace); |
|
1260 |
AddVisualGear(x - hwRound(_50 * slope), y + hwRound(_50 * slope), vgtSmokeTrace); |
|
1261 |
AddVisualGear(x + hwRound(_50 * slope), y - hwRound(_50 * slope), vgtSmokeTrace); *) |
|
1262 |
end |
|
1263 |
end; |
|
1264 |
||
1265 |
end. |