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