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