author | Stepan777 <stepik-777@mail.ru> |
Sat, 07 Jul 2012 17:26:20 +0400 | |
changeset 7359 | 8bb4da06b065 |
parent 7347 | 88685fbb2679 |
child 7373 | d5ec4e4eb2d5 |
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) |
|
7180 | 606 |
or (GameType in [gmtDemo, gmtRecord]) then |
6581 | 607 |
begin |
7339 | 608 |
if Gear^.Power <> 0 then |
609 |
s:= trammo[Ammoz[a].NameId] + ' (+' + IntToStr(Gear^.Power) + ')' |
|
610 |
else |
|
611 |
s:= trammo[Ammoz[a].NameId] + ' (+' + IntToStr(Ammoz[a].NumberInCase) + ')'; |
|
6581 | 612 |
AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
613 |
||
614 |
// show ammo icon |
|
615 |
vga:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtAmmo); |
|
616 |
if vga <> nil then |
|
617 |
vga^.Frame:= Longword(a); |
|
618 |
end; |
|
619 |
||
620 |
end; |
|
621 |
posCaseHealth: begin |
|
622 |
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
|
623 |
HH^.Hedgehog^.Effects[hePoisoned] := 0; |
6581 | 624 |
str(Gear^.Health, s); |
625 |
s:= '+' + s; |
|
626 |
AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
|
627 |
RenderHealth(HH^.Hedgehog^); |
|
628 |
RecountTeamHealth(HH^.Hedgehog^.Team); |
|
629 |
||
630 |
i:= 0; |
|
631 |
while i < Gear^.Health do |
|
632 |
begin |
|
633 |
vga:= AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtStraightShot); |
|
634 |
if vga <> nil then |
|
635 |
with vga^ do |
|
636 |
begin |
|
637 |
Tint:= $00FF00FF; |
|
638 |
State:= ord(sprHealth) |
|
639 |
end; |
|
640 |
inc(i, 5); |
|
641 |
end; |
|
642 |
end; |
|
643 |
end |
|
644 |
end; |
|
645 |
||
646 |
procedure HedgehogStep(Gear: PGear); |
|
647 |
var PrevdX: LongInt; |
|
648 |
CurWeapon: PAmmo; |
|
649 |
begin |
|
6924 | 650 |
CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^); |
6581 | 651 |
if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then |
652 |
begin |
|
653 |
if isCursorVisible then |
|
654 |
with Gear^.Hedgehog^ do |
|
655 |
with CurWeapon^ do |
|
656 |
begin |
|
657 |
if (Gear^.Message and gmLeft ) <> 0 then |
|
658 |
Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount |
|
659 |
else |
|
660 |
if (Gear^.Message and gmRight ) <> 0 then |
|
661 |
Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount |
|
662 |
else |
|
663 |
exit; |
|
7028 | 664 |
GHStepTicks:= 200; |
6581 | 665 |
exit |
666 |
end; |
|
667 |
||
668 |
if ((Gear^.Message and gmAnimate) <> 0) then |
|
669 |
begin |
|
670 |
Gear^.Message:= 0; |
|
671 |
Gear^.State:= Gear^.State or gstAnimation; |
|
672 |
Gear^.Tag:= Gear^.MsgParam; |
|
673 |
Gear^.Timer:= 0; |
|
674 |
Gear^.Pos:= 0 |
|
675 |
end; |
|
676 |
||
677 |
if ((Gear^.Message and gmLJump ) <> 0) then |
|
678 |
begin |
|
679 |
Gear^.Message:= Gear^.Message and (not gmLJump); |
|
680 |
DeleteCI(Gear); |
|
681 |
if TestCollisionYwithGear(Gear, -1) = 0 then |
|
682 |
if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then |
|
683 |
Gear^.Y:= Gear^.Y - _2 |
|
684 |
else |
|
685 |
if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then |
|
686 |
Gear^.Y:= Gear^.Y - _1; |
|
687 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
|
688 |
or (TestCollisionYwithGear(Gear, -1) <> 0)) then |
|
689 |
begin |
|
690 |
Gear^.dY:= -_0_15; |
|
691 |
if not cArtillery then |
|
692 |
Gear^.dX:= SignAs(_0_15, Gear^.dX); |
|
693 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
|
7053 | 694 |
PlaySoundV(sndJump1, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 695 |
exit |
696 |
end; |
|
697 |
end; |
|
698 |
||
699 |
if ((Gear^.Message and gmHJump ) <> 0) then |
|
700 |
begin |
|
701 |
DeleteCI(Gear); |
|
702 |
Gear^.Message:= Gear^.Message and (not gmHJump); |
|
703 |
||
704 |
Gear^.dY:= -_0_2; |
|
705 |
SetLittle(Gear^.dX); |
|
706 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
|
7053 | 707 |
PlaySoundV(sndJump3, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 708 |
exit |
709 |
end; |
|
710 |
||
711 |
PrevdX:= hwSign(Gear^.dX); |
|
712 |
if (Gear^.Message and gmLeft )<>0 then |
|
713 |
Gear^.dX:= -cLittle else |
|
714 |
if (Gear^.Message and gmRight )<>0 then |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
715 |
Gear^.dX:= cLittle |
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
716 |
else exit; |
6581 | 717 |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
718 |
StepSoundTimer:= cHHStepTicks; |
6581 | 719 |
|
7028 | 720 |
GHStepTicks:= cHHStepTicks; |
6581 | 721 |
if PrevdX <> hwSign(Gear^.dX) then |
722 |
begin |
|
723 |
FollowGear:= Gear; |
|
724 |
exit |
|
725 |
end; |
|
726 |
DeleteCI(Gear); // must be after exit!! (see previous line) |
|
727 |
||
728 |
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
|
729 |
|
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 |
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 |
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
|
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 |
6581 | 740 |
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
|
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 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
|
746 |
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
|
747 |
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
|
748 |
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
|
749 |
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
|
750 |
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
|
751 |
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
|
752 |
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
|
753 |
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
|
754 |
end else Gear^.Y:= Gear^.Y + _1 |
6581 | 755 |
end; |
756 |
||
757 |
if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then |
|
758 |
Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
|
759 |
||
760 |
SetAllHHToActive; |
|
761 |
||
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 + _1; |
|
780 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
781 |
begin |
|
782 |
Gear^.Y:= Gear^.Y - _6; |
|
783 |
Gear^.dY:= _0; |
|
784 |
Gear^.State:= Gear^.State or gstMoving; |
|
785 |
exit |
|
786 |
end; |
|
787 |
end |
|
788 |
end |
|
789 |
end |
|
790 |
end |
|
791 |
end |
|
792 |
end; |
|
793 |
AddGearCI(Gear) |
|
794 |
end |
|
795 |
end; |
|
796 |
||
797 |
procedure HedgehogChAngle(HHGear: PGear); |
|
798 |
var da: LongWord; |
|
799 |
begin |
|
800 |
with HHGear^.Hedgehog^ do |
|
801 |
if ((CurAmmoType = amRope) and ((HHGear^.State and (gstMoving or gstHHJumping)) = gstMoving)) |
|
802 |
or ((CurAmmoType = amPortalGun) and ((HHGear^.State and gstMoving) <> 0)) then |
|
803 |
da:= 2 |
|
804 |
else da:= 1; |
|
805 |
||
806 |
if (((HHGear^.Message and gmPrecise) = 0) or ((GameTicks mod 5) = 1)) then |
|
807 |
if ((HHGear^.Message and gmUp) <> 0) and (HHGear^.Angle >= CurMinAngle + da) then |
|
808 |
dec(HHGear^.Angle, da) |
|
809 |
else |
|
810 |
if ((HHGear^.Message and gmDown) <> 0) and (HHGear^.Angle + da <= CurMaxAngle) then |
|
811 |
inc(HHGear^.Angle, da) |
|
812 |
end; |
|
813 |
||
814 |
||
815 |
//////////////////////////////////////////////////////////////////////////////// |
|
816 |
procedure doStepHedgehogMoving(Gear: PGear); |
|
817 |
var isFalling, isUnderwater: boolean; |
|
818 |
land: Word; |
|
819 |
begin |
|
820 |
land:= 0; |
|
821 |
isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius; |
|
822 |
if Gear^.dX.QWordValue > 8160437862 then |
|
823 |
Gear^.dX.QWordValue:= 8160437862; |
|
824 |
if Gear^.dY.QWordValue > 8160437862 then |
|
825 |
Gear^.dY.QWordValue:= 8160437862; |
|
826 |
||
827 |
if Gear^.Hedgehog^.Unplaced then |
|
828 |
begin |
|
829 |
Gear^.dY:= _0; |
|
830 |
Gear^.dX:= _0; |
|
831 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
832 |
exit |
|
833 |
end; |
|
834 |
isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1); |
|
835 |
if isFalling then |
|
836 |
begin |
|
837 |
if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then |
|
838 |
Gear^.dY:= _0; |
|
839 |
Gear^.State:= Gear^.State or gstMoving; |
|
840 |
if (CurrentHedgehog^.Gear = Gear) |
|
841 |
and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then |
|
842 |
begin |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
843 |
// TODO: why so aggressive at setting FollowGear when falling? |
6581 | 844 |
FollowGear:= Gear; |
845 |
end; |
|
846 |
if isUnderwater then |
|
847 |
Gear^.dY:= Gear^.dY + cGravity / _2 |
|
848 |
else |
|
849 |
begin |
|
850 |
Gear^.dY:= Gear^.dY + cGravity; |
|
851 |
// this set of circumstances could be less complex if jumping was more clearly identified |
|
852 |
if ((GameFlags and gfMoreWind) <> 0) and (((Gear^.Damage <> 0) |
|
853 |
or ((CurAmmoGear <> nil) and ((CurAmmoGear^.AmmoType = amJetpack) or (CurAmmoGear^.AmmoType = amBirdy))) |
|
854 |
or ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue))) then |
|
855 |
Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density |
|
856 |
end |
|
857 |
end |
|
858 |
else |
|
859 |
begin |
|
860 |
land:= TestCollisionYwithGear(Gear, 1); |
|
861 |
if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0) |
|
862 |
and ((Gear^.State and gstHHJumping) <> 0) then |
|
863 |
SetLittle(Gear^.dX); |
|
864 |
||
865 |
if not Gear^.dY.isNegative then |
|
866 |
begin |
|
867 |
CheckHHDamage(Gear); |
|
868 |
||
869 |
if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) |
|
870 |
and (Gear^.dX.QWordValue < _0_02.QWordValue) then |
|
871 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; // landing after high jump |
|
872 |
Gear^.State:= Gear^.State and (not (gstHHJumping or gstHHHJump)); |
|
873 |
Gear^.dY:= _0; |
|
874 |
end |
|
875 |
else |
|
876 |
Gear^.dY:= Gear^.dY + cGravity; |
|
877 |
||
878 |
if ((Gear^.State and gstMoving) <> 0) then |
|
879 |
begin |
|
880 |
if land and lfIce <> 0 then |
|
881 |
begin |
|
882 |
Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2) |
|
883 |
end |
|
884 |
else |
|
885 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
886 |
end |
|
887 |
end; |
|
888 |
||
889 |
if (Gear^.State <> 0) then |
|
890 |
DeleteCI(Gear); |
|
891 |
||
892 |
if isUnderwater then |
|
893 |
begin |
|
894 |
Gear^.dY:= Gear^.dY * _0_999; |
|
895 |
Gear^.dX:= Gear^.dX * _0_999; |
|
896 |
end; |
|
897 |
||
898 |
if (Gear^.State and gstMoving) <> 0 then |
|
899 |
if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
|
900 |
if not isFalling then |
|
901 |
if hwAbs(Gear^.dX) > _0_01 then |
|
902 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then |
|
903 |
begin |
|
904 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
905 |
Gear^.dX:= Gear^.dX * _0_96; |
|
906 |
Gear^.Y:= Gear^.Y - _1 |
|
907 |
end |
|
908 |
else |
|
909 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) then |
|
910 |
begin |
|
911 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
912 |
Gear^.dX:= Gear^.dX * _0_93; |
|
913 |
Gear^.Y:= Gear^.Y - _2 |
|
914 |
end |
|
915 |
else |
|
916 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) then |
|
917 |
begin |
|
918 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
919 |
Gear^.dX:= Gear^.dX * _0_9 ; |
|
920 |
Gear^.Y:= Gear^.Y - _3 |
|
921 |
end |
|
922 |
else |
|
923 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then |
|
924 |
begin |
|
925 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
926 |
Gear^.dX:= Gear^.dX * _0_87; |
|
927 |
Gear^.Y:= Gear^.Y - _4 |
|
928 |
end |
|
929 |
else |
|
930 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then |
|
931 |
begin |
|
932 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
933 |
Gear^.dX:= Gear^.dX * _0_84; |
|
934 |
Gear^.Y:= Gear^.Y - _5 |
|
935 |
end |
|
936 |
else |
|
937 |
if hwAbs(Gear^.dX) > _0_02 then |
|
938 |
Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
939 |
else |
|
940 |
begin |
|
941 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
942 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
943 |
Gear^.Y:= Gear^.Y+_1; |
|
944 |
SetLittle(Gear^.dX) |
|
945 |
end |
|
946 |
else |
|
947 |
begin |
|
948 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
949 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
950 |
Gear^.Y:= Gear^.Y+_1; |
|
951 |
SetLittle(Gear^.dX) |
|
952 |
end |
|
953 |
else if (hwAbs(Gear^.dX) > cLittle) |
|
954 |
and ((Gear^.State and gstHHJumping) = 0) then |
|
955 |
Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
956 |
else |
|
957 |
SetLittle(Gear^.dX); |
|
958 |
||
959 |
if (not isFalling) |
|
960 |
and (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
|
961 |
begin |
|
962 |
Gear^.State:= Gear^.State and (not gstWinner); |
|
963 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
964 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
965 |
Gear^.Y:= Gear^.Y+_1; |
|
966 |
SetLittle(Gear^.dX); |
|
967 |
Gear^.dY:= _0 |
|
968 |
end |
|
969 |
else |
|
970 |
Gear^.State:= Gear^.State or gstMoving; |
|
971 |
||
972 |
if (Gear^.State and gstMoving) <> 0 then |
|
973 |
begin |
|
974 |
Gear^.State:= Gear^.State and (not gstAnimation); |
|
975 |
// ARTILLERY but not being moved by explosions |
|
976 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
977 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
978 |
if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1)) |
|
979 |
and TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
980 |
begin |
|
981 |
CheckHHDamage(Gear); |
|
982 |
Gear^.dY:= _0; |
|
983 |
Gear^.Y:= Gear^.Y + _1 |
|
984 |
end; |
|
985 |
CheckGearDrowning(Gear); |
|
986 |
// hide target cursor if current hog is drowning |
|
987 |
if (Gear^.State and gstDrowning) <> 0 then |
|
988 |
if (CurrentHedgehog^.Gear = Gear) then |
|
989 |
isCursorVisible:= false |
|
990 |
end; |
|
991 |
||
992 |
if (hwAbs(Gear^.dY) > _0) and (Gear^.FlightTime > 0) and ((GameFlags and gfLowGravity) = 0) then |
|
993 |
begin |
|
994 |
inc(Gear^.FlightTime); |
|
995 |
if Gear^.FlightTime = 3000 then |
|
996 |
begin |
|
997 |
AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage); |
|
998 |
PlaySound(sndHomerun) |
|
999 |
end; |
|
1000 |
end |
|
1001 |
else |
|
1002 |
begin |
|
1003 |
uStats.hedgehogFlight(Gear, Gear^.FlightTime); |
|
1004 |
Gear^.FlightTime:= 0; |
|
1005 |
end; |
|
1006 |
||
1007 |
end; |
|
1008 |
||
1009 |
procedure doStepHedgehogDriven(HHGear: PGear); |
|
1010 |
var t: PGear; |
|
1011 |
wasJumping: boolean; |
|
1012 |
Hedgehog: PHedgehog; |
|
1013 |
begin |
|
1014 |
Hedgehog:= HHGear^.Hedgehog; |
|
1015 |
if isInMultiShoot then |
|
1016 |
HHGear^.Message:= 0; |
|
1017 |
||
1018 |
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Utility) <> 0) and isInMultiShoot then |
|
1019 |
AllInactive:= true |
|
1020 |
else if not isInMultiShoot then |
|
1021 |
AllInactive:= false; |
|
1022 |
||
1023 |
if (TurnTimeLeft = 0) or (HHGear^.Damage > 0) then |
|
1024 |
begin |
|
1025 |
if TagTurnTimeLeft = 0 then |
|
1026 |
TagTurnTimeLeft:= TurnTimeLeft; |
|
1027 |
TurnTimeLeft:= 0; |
|
1028 |
isCursorVisible:= false; |
|
1029 |
HHGear^.State:= HHGear^.State and (not (gstHHDriven or gstAnimation or gstAttacking)); |
|
1030 |
AttackBar:= 0; |
|
1031 |
if HHGear^.Damage > 0 then |
|
1032 |
HHGear^.State:= HHGear^.State and (not (gstHHJumping or gstHHHJump)); |
|
1033 |
exit |
|
1034 |
end; |
|
1035 |
||
1036 |
if (HHGear^.State and gstAnimation) <> 0 then |
|
1037 |
begin |
|
1038 |
HHGear^.Message:= 0; |
|
1039 |
if (HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].VoiceDelay) and (HHGear^.Timer = 0) then |
|
7053 | 1040 |
PlaySoundV(Wavez[TWave(HHGear^.Tag)].Voice, Hedgehog^.Team^.voicepack); |
6581 | 1041 |
inc(HHGear^.Timer); |
1042 |
if HHGear^.Timer = Wavez[TWave(HHGear^.Tag)].Interval then |
|
1043 |
begin |
|
1044 |
HHGear^.Timer:= 0; |
|
1045 |
inc(HHGear^.Pos); |
|
1046 |
if HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].FramesCount then |
|
1047 |
HHGear^.State:= HHGear^.State and (not gstAnimation) |
|
1048 |
end; |
|
1049 |
exit |
|
1050 |
end; |
|
1051 |
||
1052 |
if ((HHGear^.State and gstMoving) <> 0) |
|
7028 | 1053 |
or (GHStepTicks = cHHStepTicks) |
6581 | 1054 |
or (CurAmmoGear <> nil) then // we are moving |
1055 |
begin |
|
1056 |
with Hedgehog^ do |
|
1057 |
if (CurAmmoGear = nil) |
|
1058 |
and (HHGear^.dY > _0_39) |
|
1059 |
and (CurAmmoType = amParachute) then |
|
1060 |
HHGear^.Message:= HHGear^.Message or gmAttack; |
|
1061 |
// check for case with ammo |
|
1062 |
t:= CheckGearNear(HHGear, gtCase, 36, 36); |
|
1063 |
if t <> nil then |
|
1064 |
PickUp(HHGear, t) |
|
1065 |
end; |
|
1066 |
||
1067 |
if (CurAmmoGear = nil) then |
|
1068 |
if (((HHGear^.Message and gmAttack) <> 0) |
|
1069 |
or ((HHGear^.State and gstAttacking) <> 0)) then |
|
1070 |
Attack(HHGear) // should be before others to avoid desync with '/put' msg and changing weapon msgs |
|
1071 |
else |
|
1072 |
else |
|
1073 |
with Hedgehog^ do |
|
1074 |
if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
1075 |
and ((HHGear^.Message and gmLJump) <> 0) |
|
1076 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then |
|
1077 |
begin |
|
1078 |
Attack(HHGear); |
|
1079 |
HHGear^.Message:= HHGear^.Message and (not gmLJump) |
|
1080 |
end; |
|
1081 |
||
1082 |
if (CurAmmoGear = nil) |
|
1083 |
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
1084 |
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) then |
|
1085 |
begin |
|
1086 |
if ((HHGear^.Message and gmSlot) <> 0) then |
|
1087 |
if ChangeAmmo(HHGear) then ApplyAmmoChanges(Hedgehog^); |
|
1088 |
||
1089 |
if ((HHGear^.Message and gmWeapon) <> 0) then |
|
1090 |
HHSetWeapon(HHGear); |
|
1091 |
||
1092 |
if ((HHGear^.Message and gmTimer) <> 0) then |
|
1093 |
HHSetTimer(HHGear); |
|
1094 |
end; |
|
1095 |
||
1096 |
if CurAmmoGear <> nil then |
|
1097 |
begin |
|
1098 |
CurAmmoGear^.Message:= HHGear^.Message; |
|
1099 |
exit |
|
1100 |
end; |
|
1101 |
||
1102 |
if not isInMultiShoot then |
|
1103 |
HedgehogChAngle(HHGear); |
|
1104 |
||
1105 |
if (HHGear^.State and gstMoving) <> 0 then |
|
1106 |
begin |
|
1107 |
wasJumping:= ((HHGear^.State and gstHHJumping) <> 0); |
|
1108 |
||
1109 |
if ((HHGear^.Message and gmHJump) <> 0) and wasJumping and ((HHGear^.State and gstHHHJump) = 0) then |
|
1110 |
if (not (hwAbs(HHGear^.dX) > cLittle)) and (HHGear^.dY < -_0_02) then |
|
1111 |
begin |
|
1112 |
HHGear^.State:= HHGear^.State or gstHHHJump; |
|
1113 |
HHGear^.dY:= -_0_25; |
|
1114 |
if not cArtillery then |
|
1115 |
HHGear^.dX:= -SignAs(_0_02, HHGear^.dX); |
|
7053 | 1116 |
PlaySoundV(sndJump2, Hedgehog^.Team^.voicepack) |
6581 | 1117 |
end; |
1118 |
||
1119 |
HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump)); |
|
1120 |
||
1121 |
if (not cArtillery) and wasJumping and TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
|
1122 |
SetLittle(HHGear^.dX); |
|
1123 |
||
1124 |
if Hedgehog^.Gear <> nil then |
|
1125 |
doStepHedgehogMoving(HHGear); |
|
1126 |
||
1127 |
if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then |
|
1128 |
begin |
|
1129 |
AddGearCI(HHGear); |
|
1130 |
if wasJumping then |
|
7028 | 1131 |
GHStepTicks:= 410 |
6581 | 1132 |
else |
7028 | 1133 |
GHStepTicks:= 95 |
6581 | 1134 |
end; |
1135 |
exit |
|
1136 |
end; |
|
1137 |
||
1138 |
if not isInMultiShoot and (Hedgehog^.Gear <> nil) then |
|
1139 |
begin |
|
7028 | 1140 |
if GHStepTicks > 0 then |
1141 |
dec(GHStepTicks); |
|
1142 |
if (GHStepTicks = 0) then |
|
6581 | 1143 |
HedgehogStep(HHGear) |
1144 |
end |
|
1145 |
end; |
|
1146 |
||
1147 |
//////////////////////////////////////////////////////////////////////////////// |
|
1148 |
procedure doStepHedgehogFree(Gear: PGear); |
|
1149 |
var prevState: Longword; |
|
1150 |
begin |
|
1151 |
prevState:= Gear^.State; |
|
1152 |
||
1153 |
doStepHedgehogMoving(Gear); |
|
1154 |
||
1155 |
if (Gear^.State and (gstMoving or gstDrowning)) <> 0 then |
|
1156 |
begin |
|
1157 |
if Gear^.Damage > 0 then |
|
1158 |
CalcRotationDirAngle(Gear); |
|
1159 |
AllInactive:= false; |
|
1160 |
exit |
|
1161 |
end; |
|
1162 |
||
1163 |
if (Gear^.Health = 0) then |
|
1164 |
begin |
|
1165 |
if PrvInactive or ((GameFlags and gfInfAttack) <> 0) then |
|
1166 |
begin |
|
1167 |
Gear^.Timer:= 0; |
|
1168 |
FollowGear:= Gear; |
|
1169 |
PrvInactive:= false; |
|
1170 |
AllInactive:= false; |
|
1171 |
||
1172 |
if (Gear^.State and gstHHGone) = 0 then |
|
1173 |
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
|
1174 |
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
|
1175 |
if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then |
6581 | 1176 |
begin |
1177 |
ResurrectHedgehog(Gear); |
|
1178 |
end |
|
1179 |
else |
|
1180 |
begin |
|
1181 |
Gear^.State:= (Gear^.State or gstHHDeath) and (not gstAnimation); |
|
1182 |
Gear^.doStep:= @doStepHedgehogDead; |
|
1183 |
// Death message |
|
1184 |
AddCaption(Format(GetEventString(eidDied), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
1185 |
end; |
|
1186 |
end |
|
1187 |
else |
|
1188 |
begin |
|
1189 |
Gear^.State:= Gear^.State and (not gstAnimation); |
|
1190 |
Gear^.doStep:= @doStepHedgehogGone; |
|
1191 |
||
1192 |
// Gone message |
|
1193 |
AddCaption(Format(GetEventString(eidGone), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
1194 |
end |
|
1195 |
end; |
|
1196 |
exit |
|
1197 |
end; |
|
1198 |
||
1199 |
if ((Gear^.State and gstWait) = 0) and |
|
1200 |
(prevState <> Gear^.State) then |
|
1201 |
begin |
|
1202 |
Gear^.State:= Gear^.State or gstWait; |
|
1203 |
Gear^.Timer:= 150 |
|
1204 |
end |
|
1205 |
else |
|
1206 |
begin |
|
1207 |
if Gear^.Timer = 0 then |
|
1208 |
begin |
|
1209 |
Gear^.State:= Gear^.State and (not (gstWait or gstLoser or gstWinner or gstAttacked or gstNotKickable or gstHHChooseTarget)); |
|
1210 |
Gear^.Active:= false; |
|
1211 |
AddGearCI(Gear); |
|
1212 |
exit |
|
1213 |
end |
|
1214 |
else dec(Gear^.Timer) |
|
1215 |
end; |
|
1216 |
||
1217 |
AllInactive:= false |
|
1218 |
end; |
|
1219 |
||
1220 |
//////////////////////////////////////////////////////////////////////////////// |
|
1221 |
procedure doStepHedgehog(Gear: PGear); |
|
1222 |
(* |
|
1223 |
var x,y,tx,ty: LongInt; |
|
1224 |
tdX, tdY, slope: hwFloat; |
|
1225 |
land: Word; *) |
|
1226 |
var slope: hwFloat; |
|
1227 |
begin |
|
1228 |
if (Gear^.Message and gmDestroy) <> 0 then |
|
1229 |
begin |
|
1230 |
DeleteGear(Gear); |
|
1231 |
exit |
|
1232 |
end; |
|
1233 |
||
1234 |
if (Gear^.State and gstHHDriven) = 0 then |
|
1235 |
doStepHedgehogFree(Gear) |
|
1236 |
else |
|
1237 |
begin |
|
1238 |
with Gear^.Hedgehog^ do |
|
1239 |
if Team^.hasGone then |
|
1240 |
TeamGoneEffect(Team^) |
|
1241 |
else |
|
1242 |
doStepHedgehogDriven(Gear) |
|
1243 |
end; |
|
1244 |
if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) |
|
1245 |
and (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0) |
|
1246 |
and (not Gear^.dY.isNegative) and (GameTicks mod (100*LongWOrd(hwRound(cMaxWindSpeed*2/cGravity))) = 0) |
|
1247 |
and (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then |
|
1248 |
begin |
|
1249 |
slope:= CalcSlopeBelowGear(Gear); |
|
1250 |
Gear^.dX:=Gear^.dX+slope*_0_07; |
|
1251 |
if slope.QWordValue <> 0 then |
|
1252 |
Gear^.State:= Gear^.State or gstMoving; |
|
1253 |
(* |
|
1254 |
x:= hwRound(Gear^.X); |
|
1255 |
y:= hwRound(Gear^.Y); |
|
1256 |
AddVisualGear(x, y, vgtSmokeTrace); |
|
1257 |
AddVisualGear(x - hwRound(_5*slope), y + hwRound(_5*slope), vgtSmokeTrace); |
|
1258 |
AddVisualGear(x + hwRound(_5*slope), y - hwRound(_5*slope), vgtSmokeTrace); |
|
1259 |
AddVisualGear(x - hwRound(_20 * slope), y + hwRound(_20 * slope), vgtSmokeTrace); |
|
1260 |
AddVisualGear(x + hwRound(_20 * slope), y - hwRound(_20 * slope), vgtSmokeTrace); |
|
1261 |
AddVisualGear(x - hwRound(_30 * slope), y + hwRound(_30 * slope), vgtSmokeTrace); |
|
1262 |
AddVisualGear(x + hwRound(_30 * slope), y - hwRound(_30 * slope), vgtSmokeTrace); |
|
1263 |
AddVisualGear(x - hwRound(_40 * slope), y + hwRound(_40 * slope), vgtSmokeTrace); |
|
1264 |
AddVisualGear(x + hwRound(_40 * slope), y - hwRound(_40 * slope), vgtSmokeTrace); |
|
1265 |
AddVisualGear(x - hwRound(_50 * slope), y + hwRound(_50 * slope), vgtSmokeTrace); |
|
1266 |
AddVisualGear(x + hwRound(_50 * slope), y - hwRound(_50 * slope), vgtSmokeTrace); *) |
|
1267 |
end |
|
1268 |
end; |
|
1269 |
||
1270 |
end. |