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