author | nemo |
Sun, 26 Aug 2012 10:15:28 -0400 | |
changeset 7609 | 7663a5c614cb |
parent 7602 | a620319d377e |
child 7615 | b39beffcf05e |
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 |
|
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
|
237 |
newDx:= dX / CurAmmoGear^.stepFreq; |
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
|
238 |
newDy:= dY / CurAmmoGear^.stepFreq; |
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); |
265 |
amDEagle: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0); |
|
266 |
amSineGun: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0); |
|
267 |
amPortalGun: begin |
|
268 |
newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, |
|
269 |
// set selected color |
|
270 |
CurWeapon^.Pos); |
|
271 |
end; |
|
272 |
amSniperRifle: begin |
|
273 |
PlaySound(sndSniperReload); |
|
274 |
newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSniperRifleShot, 0, xx * _0_5, yy * _0_5, 0); |
|
275 |
end; |
|
276 |
amDynamite: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000); |
|
277 |
amFirePunch: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtFirePunch, 0, xx, _0, 0); |
|
278 |
amWhip: begin |
|
279 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtWhip, 0, SignAs(_1, dX), - _0_8, 0); |
|
280 |
PlaySound(sndWhipCrack) |
|
281 |
end; |
|
282 |
amHammer: begin |
|
283 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtHammer, 0, SignAs(_1, dX), - _0_8, 0); |
|
284 |
PlaySound(sndWhack) |
|
285 |
end; |
|
286 |
amBaseballBat: begin |
|
287 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtShover, gsttmpFlag, xx * _0_5, yy * _0_5, 0); |
|
288 |
PlaySound(sndBaseballBat) // TODO: Only play if something is hit? |
|
289 |
end; |
|
290 |
amParachute: begin |
|
291 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtParachute, 0, _0, _0, 0); |
|
292 |
PlaySound(sndParachute) |
|
293 |
end; |
|
294 |
// we save CurWeapon^.Pos (in this case: cursor direction) by using it as (otherwise irrelevant) X value of the new gear. |
|
295 |
amAirAttack: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 0, _0, _0, 0); |
|
296 |
amMineStrike: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 1, _0, _0, 0); |
|
297 |
amDrillStrike: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 3, _0, _0, CurWeapon^.Timer); |
|
298 |
amNapalm: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 2, _0, _0, 0); |
|
299 |
amBlowTorch: newGear:= AddGear(hwRound(lx), hwRound(ly), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0); |
|
300 |
amGirder: newGear:= AddGear(0, 0, gtGirder, CurWeapon^.Pos, _0, _0, 0); |
|
301 |
amTeleport: newGear:= AddGear(CurWeapon^.Pos, 0, gtTeleport, 0, _0, _0, 0); |
|
302 |
amSwitch: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSwitcher, 0, _0, _0, 0); |
|
303 |
amMortar: begin |
|
304 |
playSound(sndMortar); |
|
305 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtMortar, 0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0); |
|
306 |
end; |
|
307 |
amRCPlane: begin |
|
308 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtRCPlane, 0, xx * cMaxPower / cPowerDivisor / 4, yy * cMaxPower / cPowerDivisor / 4, 0); |
|
7053 | 309 |
newGear^.SoundChannel:= LoopSound(sndRCPlane) |
6581 | 310 |
end; |
311 |
amKamikaze: newGear:= AddGear(hwRound(lx), hwRound(ly), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0); |
|
312 |
amCake: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, xx, _0, 0); |
|
313 |
amSeduction: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSeduction, 0, _0, _0, 0); |
|
314 |
amWatermelon: newGear:= AddGear(hwRound(lx), hwRound(ly), gtWatermelon, 0, newDx, newDy, CurWeapon^.Timer); |
|
315 |
amHellishBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtHellishBomb, 0, newDx, newDy, 0); |
|
316 |
amDrill: newGear:= AddGear(hwRound(lx), hwRound(ly), gtDrill, 0, newDx, newDy, 0); |
|
317 |
amBallgun: newGear:= AddGear(hwRound(X), hwRound(Y), gtBallgun, 0, xx * _0_5, yy * _0_5, 0); |
|
318 |
amJetpack: newGear:= AddGear(hwRound(lx), hwRound(ly), gtJetpack, 0, _0, _0, 0); |
|
319 |
amBirdy: begin |
|
320 |
PlaySound(sndWhistle); |
|
321 |
newGear:= AddGear(hwRound(lx), hwRound(ly) - 32, gtBirdy, 0, _0, _0, 0); |
|
322 |
end; |
|
323 |
amLowGravity: begin |
|
324 |
PlaySound(sndLowGravity); |
|
325 |
cGravity:= cMaxWindSpeed; |
|
326 |
cGravityf:= 0.00025 |
|
327 |
end; |
|
328 |
amExtraDamage: begin |
|
329 |
PlaySound(sndHellishImpact4); |
|
330 |
cDamageModifier:= _1_5 |
|
331 |
end; |
|
332 |
amInvulnerable: Invulnerable:= true; |
|
333 |
amExtraTime: begin |
|
334 |
PlaySound(sndSwitchHog); |
|
335 |
TurnTimeLeft:= TurnTimeLeft + 30000 |
|
336 |
end; |
|
337 |
amLaserSight: cLaserSighting:= true; |
|
338 |
amVampiric: begin |
|
7053 | 339 |
PlaySoundV(sndOw1, Team^.voicepack); |
6581 | 340 |
cVampiric:= true; |
341 |
end; |
|
342 |
amPiano: begin |
|
343 |
// Tuck the hedgehog away until the piano attack is completed |
|
344 |
Unplaced:= true; |
|
345 |
X:= _0; |
|
346 |
Y:= _0; |
|
347 |
newGear:= AddGear(TargetPoint.X, 0, gtPiano, 0, _0, _0, 0); |
|
348 |
PauseMusic |
|
349 |
end; |
|
350 |
amFlamethrower: newGear:= AddGear(hwRound(X), hwRound(Y), gtFlamethrower, 0, xx * _0_5, yy * _0_5, 0); |
|
351 |
amLandGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtLandGun, 0, xx * _0_5, yy * _0_5, 0); |
|
352 |
amResurrector: begin |
|
353 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtResurrector, 0, _0, _0, 0); |
|
354 |
newGear^.SoundChannel := LoopSound(sndResurrector); |
|
355 |
end; |
|
356 |
amStructure: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtStructure, gstWait, SignAs(_0_02, dX), _0, 3000); |
|
357 |
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
|
358 |
amIceGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtIceGun, 0, _0, _0, 0); |
6581 | 359 |
end; |
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
|
360 |
if altUse then |
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
|
361 |
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
|
362 |
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
|
363 |
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
|
364 |
end; |
6581 | 365 |
|
366 |
case CurAmmoType of |
|
367 |
amGrenade, amMolotov, |
|
368 |
amClusterBomb, amGasBomb, |
|
369 |
amBazooka, amSnowball, |
|
370 |
amBee, amSMine, |
|
371 |
amMortar, amWatermelon, |
|
372 |
amHellishBomb, amDrill: FollowGear:= newGear; |
|
373 |
||
374 |
amShotgun, amPickHammer, |
|
375 |
amRope, amDEagle, |
|
376 |
amSineGun, amSniperRifle, |
|
377 |
amFirePunch, amWhip, |
|
378 |
amHammer, amBaseballBat, |
|
379 |
amParachute, amBlowTorch, |
|
380 |
amGirder, amTeleport, |
|
381 |
amSwitch, amRCPlane, |
|
382 |
amKamikaze, amCake, |
|
383 |
amSeduction, amBallgun, |
|
384 |
amJetpack, amBirdy, |
|
385 |
amFlamethrower, amLandGun, |
|
386 |
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
|
387 |
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
|
388 |
amIceGun: CurAmmoGear:= newGear; |
6581 | 389 |
end; |
390 |
||
391 |
if ((CurAmmoType = amMine) or (CurAmmoType = amSMine)) and (GameFlags and gfInfAttack <> 0) then |
|
392 |
newGear^.FlightTime:= GameTicks + 1000 |
|
393 |
else if CurAmmoType = amDrill then |
|
394 |
newGear^.FlightTime:= GameTicks + 250; |
|
395 |
if Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then |
|
396 |
begin |
|
397 |
newGear^.Target.X:= TargetPoint.X; |
|
398 |
newGear^.Target.Y:= TargetPoint.Y |
|
399 |
end; |
|
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7187
diff
changeset
|
400 |
if newGear <> nil then newGear^.CollisionMask:= $FF7F; |
6581 | 401 |
|
402 |
// Clear FollowGear if using on a rope/parachute/saucer etc so focus stays with the hog's movement |
|
403 |
if altUse then |
|
404 |
FollowGear:= nil; |
|
405 |
||
406 |
if (newGear <> nil) and ((Ammoz[newGear^.AmmoType].Ammo.Propz and ammoprop_SetBounce) <> 0) then |
|
407 |
begin |
|
408 |
elastic:= int2hwfloat(CurWeapon^.Bounciness) / _1000; |
|
409 |
||
410 |
if elastic < _1 then |
|
411 |
newGear^.Elasticity:= newGear^.Elasticity * elastic |
|
412 |
else if elastic > _1 then |
|
413 |
newGear^.Elasticity:= _1 - ((_1-newGear^.Elasticity) / elastic); |
|
414 |
(* Experimented with friction modifier. Didn't seem helpful |
|
415 |
fric:= int2hwfloat(CurWeapon^.Bounciness) / _250; |
|
416 |
if fric < _1 then newGear^.Friction:= newGear^.Friction * fric |
|
417 |
else if fric > _1 then newGear^.Friction:= _1 - ((_1-newGear^.Friction) / fric)*) |
|
418 |
end; |
|
419 |
||
420 |
||
421 |
uStats.AmmoUsed(CurAmmoType); |
|
422 |
||
423 |
if not (SpeechText = '') then |
|
424 |
begin |
|
425 |
speech:= AddVisualGear(0, 0, vgtSpeechBubble); |
|
426 |
if speech <> nil then |
|
427 |
begin |
|
428 |
speech^.Text:= SpeechText; |
|
429 |
speech^.Hedgehog:= Gear^.Hedgehog; |
|
430 |
speech^.FrameTicks:= SpeechType; |
|
431 |
end; |
|
432 |
SpeechText:= '' |
|
433 |
end; |
|
434 |
||
435 |
Power:= 0; |
|
436 |
if (CurAmmoGear <> nil) |
|
437 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) = 0){check for dropping ammo from rope} then |
|
438 |
begin |
|
439 |
Message:= Message or gmAttack; |
|
440 |
CurAmmoGear^.Message:= Message |
|
441 |
end |
|
442 |
else |
|
443 |
begin |
|
444 |
if not CurrentTeam^.ExtDriven |
|
445 |
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
|
446 |
SendIPC(_S'a'); |
6581 | 447 |
AfterAttack; |
448 |
end |
|
449 |
end |
|
450 |
else |
|
451 |
Message:= Message and (not gmAttack); |
|
452 |
end; |
|
453 |
TargetPoint.X := NoPointX; |
|
454 |
ScriptCall('onHogAttack'); |
|
455 |
end; |
|
456 |
||
457 |
procedure AfterAttack; |
|
458 |
var s: shortstring; |
|
459 |
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
|
460 |
HHGear: PGear; |
6581 | 461 |
begin |
7459
8511a3f899d3
Allow AfterAttack to proceed even if the Hedgehog is dead. They could be resurrected after all.
nemo
parents:
7426
diff
changeset
|
462 |
with CurrentHedgehog^ do |
6581 | 463 |
begin |
7459
8511a3f899d3
Allow AfterAttack to proceed even if the Hedgehog is dead. They could be resurrected after all.
nemo
parents:
7426
diff
changeset
|
464 |
HHGear:= Gear; |
6581 | 465 |
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
|
466 |
if HHGear <> nil then HHGear^.State:= HHGear^.State and (not gstAttacking); |
6581 | 467 |
if (Ammoz[a].Ammo.Propz and ammoprop_Effect) = 0 then |
468 |
begin |
|
469 |
Inc(MultiShootAttacks); |
|
470 |
||
471 |
if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) then |
|
472 |
begin |
|
473 |
s:= inttostr(Ammoz[a].Ammo.NumPerTurn - MultiShootAttacks + 1); |
|
474 |
AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate); |
|
475 |
end; |
|
476 |
||
477 |
if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) |
|
478 |
or ((GameFlags and gfMultiWeapon) <> 0) then |
|
479 |
begin |
|
480 |
isInMultiShoot:= true |
|
481 |
end |
|
482 |
else |
|
483 |
begin |
|
484 |
OnUsedAmmo(CurrentHedgehog^); |
|
485 |
if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (((GameFlags and gfInfAttack) = 0) or PlacingHogs) then |
|
486 |
begin |
|
487 |
if TagTurnTimeLeft = 0 then |
|
488 |
TagTurnTimeLeft:= TurnTimeLeft; |
|
489 |
TurnTimeLeft:=(Ammoz[a].TimeAfterTurn * cGetAwayTime) div 100; |
|
490 |
end; |
|
7459
8511a3f899d3
Allow AfterAttack to proceed even if the Hedgehog is dead. They could be resurrected after all.
nemo
parents:
7426
diff
changeset
|
491 |
if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (HHGear <> nil) then |
7462 | 492 |
HHGear^.State:= HHGear^.State or gstAttacked; |
6581 | 493 |
if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then |
494 |
ApplyAmmoChanges(CurrentHedgehog^) |
|
495 |
end; |
|
496 |
end |
|
497 |
else |
|
498 |
begin |
|
499 |
OnUsedAmmo(CurrentHedgehog^); |
|
500 |
ApplyAmmoChanges(CurrentHedgehog^); |
|
501 |
end; |
|
502 |
AttackBar:= 0 |
|
503 |
end |
|
504 |
end; |
|
505 |
||
506 |
//////////////////////////////////////////////////////////////////////////////// |
|
507 |
procedure doStepHedgehogDead(Gear: PGear); |
|
508 |
const frametime = 200; |
|
509 |
timertime = frametime * 6; |
|
510 |
begin |
|
511 |
if Gear^.Hedgehog^.Unplaced then |
|
512 |
exit; |
|
513 |
if Gear^.Timer > 1 then |
|
514 |
begin |
|
515 |
AllInactive:= false; |
|
516 |
dec(Gear^.Timer); |
|
517 |
if (Gear^.Timer mod frametime) = 0 then |
|
518 |
inc(Gear^.Pos) |
|
519 |
end |
|
520 |
else if Gear^.Timer = 1 then |
|
521 |
begin |
|
522 |
Gear^.State:= Gear^.State or gstNoDamage; |
|
523 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, CurrentHedgehog, EXPLAutoSound); |
|
524 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
525 |
DeleteGear(Gear); |
|
526 |
SetAllToActive |
|
527 |
end |
|
528 |
else // Gear^.Timer = 0 |
|
529 |
begin |
|
530 |
AllInactive:= false; |
|
531 |
Gear^.Z:= cCurrHHZ; |
|
532 |
RemoveGearFromList(Gear); |
|
533 |
InsertGearToList(Gear); |
|
7053 | 534 |
PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 535 |
Gear^.Pos:= 0; |
536 |
Gear^.Timer:= timertime |
|
537 |
end |
|
538 |
end; |
|
539 |
||
540 |
//////////////////////////////////////////////////////////////////////////////// |
|
541 |
procedure doStepHedgehogGone(Gear: PGear); |
|
542 |
const frametime = 65; |
|
543 |
timertime = frametime * 11; |
|
544 |
begin |
|
545 |
if Gear^.Hedgehog^.Unplaced then |
|
546 |
exit; |
|
547 |
if Gear^.Timer > 1 then |
|
548 |
begin |
|
549 |
AllInactive:= false; |
|
550 |
dec(Gear^.Timer); |
|
551 |
if (Gear^.Timer mod frametime) = 0 then |
|
552 |
inc(Gear^.Pos) |
|
553 |
end |
|
554 |
else |
|
555 |
if Gear^.Timer = 1 then |
|
556 |
begin |
|
557 |
DeleteGear(Gear); |
|
558 |
SetAllToActive |
|
559 |
end |
|
560 |
else // Gear^.Timer = 0 |
|
561 |
begin |
|
562 |
AllInactive:= false; |
|
563 |
Gear^.Z:= cCurrHHZ; |
|
564 |
RemoveGearFromList(Gear); |
|
565 |
InsertGearToList(Gear); |
|
7053 | 566 |
PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 567 |
PlaySound(sndWarp); |
568 |
Gear^.Pos:= 0; |
|
569 |
Gear^.Timer:= timertime |
|
570 |
end |
|
571 |
end; |
|
572 |
||
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
|
573 |
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
|
574 |
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
|
575 |
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
|
576 |
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
|
577 |
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
|
578 |
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
|
579 |
|
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 |
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
|
581 |
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
|
582 |
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
|
583 |
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
|
584 |
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
|
585 |
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
|
586 |
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
|
587 |
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
|
588 |
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
|
589 |
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
|
590 |
|
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 |
// 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
|
592 |
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
|
593 |
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
|
594 |
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
|
595 |
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
|
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 |
|
6581 | 598 |
//////////////////////////////////////////////////////////////////////////////// |
599 |
procedure PickUp(HH, Gear: PGear); |
|
600 |
var s: shortstring; |
|
601 |
a: TAmmoType; |
|
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; |
6581 | 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 |
|
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
|
756 |
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
|
757 |
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
|
758 |
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
|
759 |
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
|
760 |
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
|
761 |
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
|
762 |
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
|
763 |
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
|
764 |
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
|
765 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
6581 | 766 |
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
|
767 |
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
|
768 |
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
|
769 |
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
|
770 |
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
|
771 |
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
|
772 |
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
|
773 |
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
|
774 |
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
|
775 |
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
|
776 |
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
|
777 |
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
|
778 |
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
|
779 |
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
|
780 |
end else Gear^.Y:= Gear^.Y + _1 |
6581 | 781 |
end; |
782 |
||
783 |
if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then |
|
784 |
Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
|
785 |
||
786 |
SetAllHHToActive; |
|
787 |
||
788 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
789 |
begin |
|
790 |
Gear^.Y:= Gear^.Y + _1; |
|
791 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
792 |
begin |
|
793 |
Gear^.Y:= Gear^.Y + _1; |
|
794 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
795 |
begin |
|
796 |
Gear^.Y:= Gear^.Y + _1; |
|
797 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
798 |
begin |
|
799 |
Gear^.Y:= Gear^.Y + _1; |
|
800 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
801 |
begin |
|
802 |
Gear^.Y:= Gear^.Y + _1; |
|
803 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
804 |
begin |
|
805 |
Gear^.Y:= Gear^.Y + _1; |
|
806 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
807 |
begin |
|
808 |
Gear^.Y:= Gear^.Y - _6; |
|
809 |
Gear^.dY:= _0; |
|
810 |
Gear^.State:= Gear^.State or gstMoving; |
|
811 |
exit |
|
812 |
end; |
|
813 |
end |
|
814 |
end |
|
815 |
end |
|
816 |
end |
|
817 |
end |
|
818 |
end; |
|
819 |
AddGearCI(Gear) |
|
820 |
end |
|
821 |
end; |
|
822 |
||
823 |
procedure HedgehogChAngle(HHGear: PGear); |
|
824 |
var da: LongWord; |
|
825 |
begin |
|
826 |
with HHGear^.Hedgehog^ do |
|
827 |
if ((CurAmmoType = amRope) and ((HHGear^.State and (gstMoving or gstHHJumping)) = gstMoving)) |
|
828 |
or ((CurAmmoType = amPortalGun) and ((HHGear^.State and gstMoving) <> 0)) then |
|
829 |
da:= 2 |
|
830 |
else da:= 1; |
|
831 |
||
832 |
if (((HHGear^.Message and gmPrecise) = 0) or ((GameTicks mod 5) = 1)) then |
|
833 |
if ((HHGear^.Message and gmUp) <> 0) and (HHGear^.Angle >= CurMinAngle + da) then |
|
834 |
dec(HHGear^.Angle, da) |
|
835 |
else |
|
836 |
if ((HHGear^.Message and gmDown) <> 0) and (HHGear^.Angle + da <= CurMaxAngle) then |
|
837 |
inc(HHGear^.Angle, da) |
|
838 |
end; |
|
839 |
||
840 |
||
841 |
//////////////////////////////////////////////////////////////////////////////// |
|
842 |
procedure doStepHedgehogMoving(Gear: PGear); |
|
843 |
var isFalling, isUnderwater: boolean; |
|
844 |
land: Word; |
|
845 |
begin |
|
846 |
land:= 0; |
|
847 |
isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius; |
|
848 |
if Gear^.dX.QWordValue > 8160437862 then |
|
849 |
Gear^.dX.QWordValue:= 8160437862; |
|
850 |
if Gear^.dY.QWordValue > 8160437862 then |
|
851 |
Gear^.dY.QWordValue:= 8160437862; |
|
852 |
||
853 |
if Gear^.Hedgehog^.Unplaced then |
|
854 |
begin |
|
855 |
Gear^.dY:= _0; |
|
856 |
Gear^.dX:= _0; |
|
857 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
858 |
exit |
|
859 |
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
|
860 |
isFalling:= (Gear^.dY.isNegative) or (not TestCollisionYKick(Gear, 1)); |
6581 | 861 |
if isFalling then |
862 |
begin |
|
863 |
if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then |
|
864 |
Gear^.dY:= _0; |
|
865 |
Gear^.State:= Gear^.State or gstMoving; |
|
866 |
if (CurrentHedgehog^.Gear = Gear) |
|
867 |
and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then |
|
868 |
begin |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
869 |
// TODO: why so aggressive at setting FollowGear when falling? |
6581 | 870 |
FollowGear:= Gear; |
871 |
end; |
|
872 |
if isUnderwater then |
|
873 |
Gear^.dY:= Gear^.dY + cGravity / _2 |
|
874 |
else |
|
875 |
begin |
|
876 |
Gear^.dY:= Gear^.dY + cGravity; |
|
877 |
// this set of circumstances could be less complex if jumping was more clearly identified |
|
878 |
if ((GameFlags and gfMoreWind) <> 0) and (((Gear^.Damage <> 0) |
|
879 |
or ((CurAmmoGear <> nil) and ((CurAmmoGear^.AmmoType = amJetpack) or (CurAmmoGear^.AmmoType = amBirdy))) |
|
880 |
or ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue))) then |
|
881 |
Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density |
|
882 |
end |
|
883 |
end |
|
884 |
else |
|
885 |
begin |
|
886 |
land:= TestCollisionYwithGear(Gear, 1); |
|
887 |
if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0) |
|
888 |
and ((Gear^.State and gstHHJumping) <> 0) then |
|
889 |
SetLittle(Gear^.dX); |
|
890 |
||
891 |
if not Gear^.dY.isNegative then |
|
892 |
begin |
|
893 |
CheckHHDamage(Gear); |
|
894 |
||
895 |
if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) |
|
896 |
and (Gear^.dX.QWordValue < _0_02.QWordValue) then |
|
897 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; // landing after high jump |
|
898 |
Gear^.State:= Gear^.State and (not (gstHHJumping or gstHHHJump)); |
|
899 |
Gear^.dY:= _0; |
|
900 |
end |
|
901 |
else |
|
902 |
Gear^.dY:= Gear^.dY + cGravity; |
|
903 |
||
904 |
if ((Gear^.State and gstMoving) <> 0) then |
|
905 |
begin |
|
906 |
if land and lfIce <> 0 then |
|
907 |
begin |
|
908 |
Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2) |
|
909 |
end |
|
910 |
else |
|
911 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
912 |
end |
|
913 |
end; |
|
914 |
||
915 |
if (Gear^.State <> 0) then |
|
916 |
DeleteCI(Gear); |
|
917 |
||
918 |
if isUnderwater then |
|
919 |
begin |
|
920 |
Gear^.dY:= Gear^.dY * _0_999; |
|
921 |
Gear^.dX:= Gear^.dX * _0_999; |
|
922 |
end; |
|
923 |
||
924 |
if (Gear^.State and gstMoving) <> 0 then |
|
925 |
if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
|
926 |
if not isFalling then |
|
927 |
if hwAbs(Gear^.dX) > _0_01 then |
|
928 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then |
|
929 |
begin |
|
930 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
931 |
Gear^.dX:= Gear^.dX * _0_96; |
|
932 |
Gear^.Y:= Gear^.Y - _1 |
|
933 |
end |
|
934 |
else |
|
935 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) then |
|
936 |
begin |
|
937 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
938 |
Gear^.dX:= Gear^.dX * _0_93; |
|
939 |
Gear^.Y:= Gear^.Y - _2 |
|
940 |
end |
|
941 |
else |
|
942 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) then |
|
943 |
begin |
|
944 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
945 |
Gear^.dX:= Gear^.dX * _0_9 ; |
|
946 |
Gear^.Y:= Gear^.Y - _3 |
|
947 |
end |
|
948 |
else |
|
949 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then |
|
950 |
begin |
|
951 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
952 |
Gear^.dX:= Gear^.dX * _0_87; |
|
953 |
Gear^.Y:= Gear^.Y - _4 |
|
954 |
end |
|
955 |
else |
|
956 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then |
|
957 |
begin |
|
958 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
959 |
Gear^.dX:= Gear^.dX * _0_84; |
|
960 |
Gear^.Y:= Gear^.Y - _5 |
|
961 |
end |
|
962 |
else |
|
963 |
if hwAbs(Gear^.dX) > _0_02 then |
|
964 |
Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
965 |
else |
|
966 |
begin |
|
967 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
968 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
969 |
Gear^.Y:= Gear^.Y+_1; |
|
970 |
SetLittle(Gear^.dX) |
|
971 |
end |
|
972 |
else |
|
973 |
begin |
|
974 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
975 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
976 |
Gear^.Y:= Gear^.Y+_1; |
|
977 |
SetLittle(Gear^.dX) |
|
978 |
end |
|
979 |
else if (hwAbs(Gear^.dX) > cLittle) |
|
980 |
and ((Gear^.State and gstHHJumping) = 0) then |
|
981 |
Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
982 |
else |
|
983 |
SetLittle(Gear^.dX); |
|
984 |
||
985 |
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
|
986 |
and (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
6581 | 987 |
begin |
988 |
Gear^.State:= Gear^.State and (not gstWinner); |
|
989 |
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
|
990 |
while (TestCollisionYWithGear(Gear,1) = 0) and (not CheckGearDrowning(Gear)) do |
6581 | 991 |
Gear^.Y:= Gear^.Y+_1; |
992 |
SetLittle(Gear^.dX); |
|
993 |
Gear^.dY:= _0 |
|
994 |
end |
|
995 |
else |
|
996 |
Gear^.State:= Gear^.State or gstMoving; |
|
997 |
||
998 |
if (Gear^.State and gstMoving) <> 0 then |
|
999 |
begin |
|
1000 |
Gear^.State:= Gear^.State and (not gstAnimation); |
|
1001 |
// ARTILLERY but not being moved by explosions |
|
1002 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1003 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1004 |
if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1)) |
|
1005 |
and TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
1006 |
begin |
|
1007 |
CheckHHDamage(Gear); |
|
1008 |
Gear^.dY:= _0; |
|
1009 |
Gear^.Y:= Gear^.Y + _1 |
|
1010 |
end; |
|
1011 |
CheckGearDrowning(Gear); |
|
1012 |
// hide target cursor if current hog is drowning |
|
1013 |
if (Gear^.State and gstDrowning) <> 0 then |
|
1014 |
if (CurrentHedgehog^.Gear = Gear) then |
|
1015 |
isCursorVisible:= false |
|
1016 |
end; |
|
1017 |
||
1018 |
if (hwAbs(Gear^.dY) > _0) and (Gear^.FlightTime > 0) and ((GameFlags and gfLowGravity) = 0) then |
|
1019 |
begin |
|
1020 |
inc(Gear^.FlightTime); |
|
1021 |
if Gear^.FlightTime = 3000 then |
|
1022 |
begin |
|
1023 |
AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage); |
|
1024 |
PlaySound(sndHomerun) |
|
1025 |
end; |
|
1026 |
end |
|
1027 |
else |
|
1028 |
begin |
|
1029 |
uStats.hedgehogFlight(Gear, Gear^.FlightTime); |
|
1030 |
Gear^.FlightTime:= 0; |
|
1031 |
end; |
|
1032 |
||
1033 |
end; |
|
1034 |
||
1035 |
procedure doStepHedgehogDriven(HHGear: PGear); |
|
1036 |
var t: PGear; |
|
1037 |
wasJumping: boolean; |
|
1038 |
Hedgehog: PHedgehog; |
|
1039 |
begin |
|
1040 |
Hedgehog:= HHGear^.Hedgehog; |
|
1041 |
if isInMultiShoot then |
|
1042 |
HHGear^.Message:= 0; |
|
1043 |
||
1044 |
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Utility) <> 0) and isInMultiShoot then |
|
1045 |
AllInactive:= true |
|
1046 |
else if not isInMultiShoot then |
|
1047 |
AllInactive:= false; |
|
1048 |
||
1049 |
if (TurnTimeLeft = 0) or (HHGear^.Damage > 0) then |
|
1050 |
begin |
|
1051 |
if TagTurnTimeLeft = 0 then |
|
1052 |
TagTurnTimeLeft:= TurnTimeLeft; |
|
1053 |
TurnTimeLeft:= 0; |
|
1054 |
isCursorVisible:= false; |
|
1055 |
HHGear^.State:= HHGear^.State and (not (gstHHDriven or gstAnimation or gstAttacking)); |
|
1056 |
AttackBar:= 0; |
|
1057 |
if HHGear^.Damage > 0 then |
|
1058 |
HHGear^.State:= HHGear^.State and (not (gstHHJumping or gstHHHJump)); |
|
1059 |
exit |
|
1060 |
end; |
|
1061 |
||
1062 |
if (HHGear^.State and gstAnimation) <> 0 then |
|
1063 |
begin |
|
1064 |
HHGear^.Message:= 0; |
|
1065 |
if (HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].VoiceDelay) and (HHGear^.Timer = 0) then |
|
7053 | 1066 |
PlaySoundV(Wavez[TWave(HHGear^.Tag)].Voice, Hedgehog^.Team^.voicepack); |
6581 | 1067 |
inc(HHGear^.Timer); |
1068 |
if HHGear^.Timer = Wavez[TWave(HHGear^.Tag)].Interval then |
|
1069 |
begin |
|
1070 |
HHGear^.Timer:= 0; |
|
1071 |
inc(HHGear^.Pos); |
|
1072 |
if HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].FramesCount then |
|
1073 |
HHGear^.State:= HHGear^.State and (not gstAnimation) |
|
1074 |
end; |
|
1075 |
exit |
|
1076 |
end; |
|
1077 |
||
1078 |
if ((HHGear^.State and gstMoving) <> 0) |
|
7028 | 1079 |
or (GHStepTicks = cHHStepTicks) |
6581 | 1080 |
or (CurAmmoGear <> nil) then // we are moving |
1081 |
begin |
|
1082 |
with Hedgehog^ do |
|
1083 |
if (CurAmmoGear = nil) |
|
1084 |
and (HHGear^.dY > _0_39) |
|
1085 |
and (CurAmmoType = amParachute) then |
|
1086 |
HHGear^.Message:= HHGear^.Message or gmAttack; |
|
1087 |
// check for case with ammo |
|
1088 |
t:= CheckGearNear(HHGear, gtCase, 36, 36); |
|
1089 |
if t <> nil then |
|
1090 |
PickUp(HHGear, t) |
|
1091 |
end; |
|
1092 |
||
1093 |
if (CurAmmoGear = nil) then |
|
1094 |
if (((HHGear^.Message and gmAttack) <> 0) |
|
1095 |
or ((HHGear^.State and gstAttacking) <> 0)) then |
|
1096 |
Attack(HHGear) // should be before others to avoid desync with '/put' msg and changing weapon msgs |
|
1097 |
else |
|
1098 |
else |
|
1099 |
with Hedgehog^ do |
|
1100 |
if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
1101 |
and ((HHGear^.Message and gmLJump) <> 0) |
|
1102 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then |
|
1103 |
begin |
|
1104 |
Attack(HHGear); |
|
1105 |
HHGear^.Message:= HHGear^.Message and (not gmLJump) |
|
1106 |
end; |
|
1107 |
||
1108 |
if (CurAmmoGear = nil) |
|
1109 |
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
1110 |
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) then |
|
1111 |
begin |
|
1112 |
if ((HHGear^.Message and gmSlot) <> 0) then |
|
1113 |
if ChangeAmmo(HHGear) then ApplyAmmoChanges(Hedgehog^); |
|
1114 |
||
1115 |
if ((HHGear^.Message and gmWeapon) <> 0) then |
|
1116 |
HHSetWeapon(HHGear); |
|
1117 |
||
1118 |
if ((HHGear^.Message and gmTimer) <> 0) then |
|
1119 |
HHSetTimer(HHGear); |
|
1120 |
end; |
|
1121 |
||
1122 |
if CurAmmoGear <> nil then |
|
1123 |
begin |
|
1124 |
CurAmmoGear^.Message:= HHGear^.Message; |
|
1125 |
exit |
|
1126 |
end; |
|
1127 |
||
1128 |
if not isInMultiShoot then |
|
1129 |
HedgehogChAngle(HHGear); |
|
1130 |
||
1131 |
if (HHGear^.State and gstMoving) <> 0 then |
|
1132 |
begin |
|
1133 |
wasJumping:= ((HHGear^.State and gstHHJumping) <> 0); |
|
1134 |
||
1135 |
if ((HHGear^.Message and gmHJump) <> 0) and wasJumping and ((HHGear^.State and gstHHHJump) = 0) then |
|
1136 |
if (not (hwAbs(HHGear^.dX) > cLittle)) and (HHGear^.dY < -_0_02) then |
|
1137 |
begin |
|
1138 |
HHGear^.State:= HHGear^.State or gstHHHJump; |
|
1139 |
HHGear^.dY:= -_0_25; |
|
1140 |
if not cArtillery then |
|
1141 |
HHGear^.dX:= -SignAs(_0_02, HHGear^.dX); |
|
7053 | 1142 |
PlaySoundV(sndJump2, Hedgehog^.Team^.voicepack) |
6581 | 1143 |
end; |
1144 |
||
1145 |
HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump)); |
|
1146 |
||
1147 |
if (not cArtillery) and wasJumping and TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
|
1148 |
SetLittle(HHGear^.dX); |
|
1149 |
||
1150 |
if Hedgehog^.Gear <> nil then |
|
1151 |
doStepHedgehogMoving(HHGear); |
|
1152 |
||
1153 |
if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then |
|
1154 |
begin |
|
1155 |
AddGearCI(HHGear); |
|
1156 |
if wasJumping then |
|
7028 | 1157 |
GHStepTicks:= 410 |
6581 | 1158 |
else |
7028 | 1159 |
GHStepTicks:= 95 |
6581 | 1160 |
end; |
1161 |
exit |
|
1162 |
end; |
|
1163 |
||
1164 |
if not isInMultiShoot and (Hedgehog^.Gear <> nil) then |
|
1165 |
begin |
|
7028 | 1166 |
if GHStepTicks > 0 then |
1167 |
dec(GHStepTicks); |
|
1168 |
if (GHStepTicks = 0) then |
|
6581 | 1169 |
HedgehogStep(HHGear) |
1170 |
end |
|
1171 |
end; |
|
1172 |
||
1173 |
//////////////////////////////////////////////////////////////////////////////// |
|
1174 |
procedure doStepHedgehogFree(Gear: PGear); |
|
1175 |
var prevState: Longword; |
|
1176 |
begin |
|
1177 |
prevState:= Gear^.State; |
|
1178 |
||
1179 |
doStepHedgehogMoving(Gear); |
|
1180 |
||
1181 |
if (Gear^.State and (gstMoving or gstDrowning)) <> 0 then |
|
1182 |
begin |
|
1183 |
if Gear^.Damage > 0 then |
|
1184 |
CalcRotationDirAngle(Gear); |
|
1185 |
AllInactive:= false; |
|
1186 |
exit |
|
1187 |
end; |
|
1188 |
||
1189 |
if (Gear^.Health = 0) then |
|
1190 |
begin |
|
1191 |
if PrvInactive or ((GameFlags and gfInfAttack) <> 0) then |
|
1192 |
begin |
|
1193 |
Gear^.Timer:= 0; |
|
1194 |
FollowGear:= Gear; |
|
1195 |
PrvInactive:= false; |
|
1196 |
AllInactive:= false; |
|
1197 |
||
1198 |
if (Gear^.State and gstHHGone) = 0 then |
|
1199 |
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
|
1200 |
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
|
1201 |
if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then |
6581 | 1202 |
begin |
1203 |
ResurrectHedgehog(Gear); |
|
1204 |
end |
|
1205 |
else |
|
1206 |
begin |
|
1207 |
Gear^.State:= (Gear^.State or gstHHDeath) and (not gstAnimation); |
|
1208 |
Gear^.doStep:= @doStepHedgehogDead; |
|
1209 |
// Death message |
|
1210 |
AddCaption(Format(GetEventString(eidDied), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
1211 |
end; |
|
1212 |
end |
|
1213 |
else |
|
1214 |
begin |
|
1215 |
Gear^.State:= Gear^.State and (not gstAnimation); |
|
1216 |
Gear^.doStep:= @doStepHedgehogGone; |
|
1217 |
||
1218 |
// Gone message |
|
1219 |
AddCaption(Format(GetEventString(eidGone), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
1220 |
end |
|
1221 |
end; |
|
1222 |
exit |
|
1223 |
end; |
|
1224 |
||
1225 |
if ((Gear^.State and gstWait) = 0) and |
|
1226 |
(prevState <> Gear^.State) then |
|
1227 |
begin |
|
1228 |
Gear^.State:= Gear^.State or gstWait; |
|
1229 |
Gear^.Timer:= 150 |
|
1230 |
end |
|
1231 |
else |
|
1232 |
begin |
|
1233 |
if Gear^.Timer = 0 then |
|
1234 |
begin |
|
1235 |
Gear^.State:= Gear^.State and (not (gstWait or gstLoser or gstWinner or gstAttacked or gstNotKickable or gstHHChooseTarget)); |
|
1236 |
Gear^.Active:= false; |
|
1237 |
AddGearCI(Gear); |
|
1238 |
exit |
|
1239 |
end |
|
1240 |
else dec(Gear^.Timer) |
|
1241 |
end; |
|
1242 |
||
1243 |
AllInactive:= false |
|
1244 |
end; |
|
1245 |
||
1246 |
//////////////////////////////////////////////////////////////////////////////// |
|
1247 |
procedure doStepHedgehog(Gear: PGear); |
|
1248 |
(* |
|
1249 |
var x,y,tx,ty: LongInt; |
|
1250 |
tdX, tdY, slope: hwFloat; |
|
1251 |
land: Word; *) |
|
1252 |
var slope: hwFloat; |
|
1253 |
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
|
1254 |
CheckSum:= CheckSum xor Gear^.Hedgehog^.BotLevel; |
6581 | 1255 |
if (Gear^.Message and gmDestroy) <> 0 then |
1256 |
begin |
|
1257 |
DeleteGear(Gear); |
|
1258 |
exit |
|
1259 |
end; |
|
1260 |
||
1261 |
if (Gear^.State and gstHHDriven) = 0 then |
|
1262 |
doStepHedgehogFree(Gear) |
|
1263 |
else |
|
1264 |
begin |
|
1265 |
with Gear^.Hedgehog^ do |
|
1266 |
if Team^.hasGone then |
|
1267 |
TeamGoneEffect(Team^) |
|
1268 |
else |
|
1269 |
doStepHedgehogDriven(Gear) |
|
1270 |
end; |
|
1271 |
if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) |
|
1272 |
and (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0) |
|
1273 |
and (not Gear^.dY.isNegative) and (GameTicks mod (100*LongWOrd(hwRound(cMaxWindSpeed*2/cGravity))) = 0) |
|
1274 |
and (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then |
|
1275 |
begin |
|
1276 |
slope:= CalcSlopeBelowGear(Gear); |
|
1277 |
Gear^.dX:=Gear^.dX+slope*_0_07; |
|
1278 |
if slope.QWordValue <> 0 then |
|
1279 |
Gear^.State:= Gear^.State or gstMoving; |
|
1280 |
(* |
|
1281 |
x:= hwRound(Gear^.X); |
|
1282 |
y:= hwRound(Gear^.Y); |
|
1283 |
AddVisualGear(x, y, vgtSmokeTrace); |
|
1284 |
AddVisualGear(x - hwRound(_5*slope), y + hwRound(_5*slope), vgtSmokeTrace); |
|
1285 |
AddVisualGear(x + hwRound(_5*slope), y - hwRound(_5*slope), vgtSmokeTrace); |
|
1286 |
AddVisualGear(x - hwRound(_20 * slope), y + hwRound(_20 * slope), vgtSmokeTrace); |
|
1287 |
AddVisualGear(x + hwRound(_20 * slope), y - hwRound(_20 * slope), vgtSmokeTrace); |
|
1288 |
AddVisualGear(x - hwRound(_30 * slope), y + hwRound(_30 * slope), vgtSmokeTrace); |
|
1289 |
AddVisualGear(x + hwRound(_30 * slope), y - hwRound(_30 * slope), vgtSmokeTrace); |
|
1290 |
AddVisualGear(x - hwRound(_40 * slope), y + hwRound(_40 * slope), vgtSmokeTrace); |
|
1291 |
AddVisualGear(x + hwRound(_40 * slope), y - hwRound(_40 * slope), vgtSmokeTrace); |
|
1292 |
AddVisualGear(x - hwRound(_50 * slope), y + hwRound(_50 * slope), vgtSmokeTrace); |
|
1293 |
AddVisualGear(x + hwRound(_50 * slope), y - hwRound(_50 * slope), vgtSmokeTrace); *) |
|
1294 |
end |
|
1295 |
end; |
|
1296 |
||
1297 |
end. |