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