author | unc0rr |
Sun, 17 Dec 2006 18:40:04 +0000 | |
changeset 303 | 1659c4aad5ab |
parent 302 | 7aca131ecd7f |
child 304 | 8096e69e839e |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
47 | 3 |
* Copyright (c) 2004, 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 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 |
|
4 | 8 |
* |
183 | 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. |
|
4 | 13 |
* |
183 | 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 |
|
4 | 17 |
*) |
18 |
||
37 | 19 |
//////////////////////////////////////////////////////////////////////////////// |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
20 |
procedure Attack(Gear: PGear); |
107 | 21 |
var xx, yy: Double; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
22 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
23 |
with Gear^, |
95 | 24 |
PHedgehog(Gear.Hedgehog)^ do |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
25 |
begin |
95 | 26 |
if ((State and gstHHDriven) <> 0)and |
27 |
// (((State and gstAttacking) <> 0) or ((Message and gm_Attack) <> 0))and |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
28 |
((State and (gstAttacked or gstMoving or gstHHChooseTarget)) = 0)and |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
29 |
(((State and gstFalling ) = 0)or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackInFall) <> 0))and |
95 | 30 |
(((State and gstHHJumping) = 0)or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackInJump) <> 0))and |
31 |
((TargetPoint.X <> NoPointX) or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_NeedTarget) = 0)) then |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
32 |
begin |
95 | 33 |
State:= State or gstAttacking; |
34 |
if Power = cMaxPower then Message:= Message and not gm_Attack |
|
35 |
else if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack |
|
36 |
else begin |
|
37 |
if Power = 0 then |
|
38 |
begin |
|
39 |
AttackBar:= CurrentTeam.AttackBar; |
|
40 |
PlaySound(sndThrowPowerUp) |
|
41 |
end; |
|
42 |
inc(Power) |
|
43 |
end; |
|
44 |
if ((Message and gm_Attack) <> 0) then exit; |
|
45 |
||
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
46 |
if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0 then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
47 |
begin |
282 | 48 |
StopSound(sndThrowPowerUp); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
49 |
PlaySound(sndThrowRelease); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
50 |
end; |
108 | 51 |
xx:= hwSign(dX)*Sin(Angle*pi/cMaxAngle); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
52 |
yy:= -Cos(Angle*pi/cMaxAngle); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
53 |
case Ammo[CurSlot, CurAmmo].AmmoType of |
78 | 54 |
amGrenade: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer); |
55 |
amClusterBomb: FollowGear:= AddGear(round(X), round(Y), gtClusterBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer); |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
56 |
amBazooka: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
57 |
amUFO: FollowGear:= AddGear(round(X), round(Y), gtUFO, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
58 |
amShotgun: begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
59 |
PlaySound(sndShotgunReload); |
75 | 60 |
CurAmmoGear:= AddGear(round(X), round(Y), gtShotgunShot, 0, xx * 0.5, yy * 0.5); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
61 |
end; |
78 | 62 |
amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHRadius, gtPickHammer, 0); |
63 |
amSkip: TurnTimeLeft:= 0; |
|
64 |
amRope: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtRope, 0, xx, yy); |
|
108 | 65 |
amMine: AddGear(round(X) + hwSign(dX) * 7, round(Y), gtMine, 0, hwSign(dX) * 0.02, 0, 3000); |
82 | 66 |
amDEagle: AddGear(round(X), round(Y), gtDEagleShot, 0, xx * 0.5, yy * 0.5); |
108 | 67 |
amDynamite: AddGear(round(X) + hwSign(dX) * 7, round(Y), gtDynamite, 0, hwSign(dX) * 0.035, 0, 5000); |
68 |
amBaseballBat: AddGear(round(X) + hwSign(dX) * 10, round(Y), gtShover, 0, xx * 0.5, yy * 0.5).Radius:= 20; |
|
69 |
amFirePunch: CurAmmoGear:= AddGear(round(X) + hwSign(dX) * 10, round(Y), gtFirePunch, 0); |
|
263 | 70 |
amParachute: CurAmmoGear:= AddGear(round(X), round(Y), gtParachute, 0); |
285 | 71 |
amAirAttack: AddGear(0, 0, gtAirAttack, 0); |
72 |
amMineStrike: AddGear(0, 0, gtAirAttack, 1); |
|
302 | 73 |
amBlowTorch: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtBlowTorch, 0, hwSign(Gear.dX) * 0.5); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
74 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
75 |
Power:= 0; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
76 |
if CurAmmoGear <> nil then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
77 |
begin |
82 | 78 |
Message:= Message or gm_Attack; |
79 |
CurAmmoGear.Message:= Message |
|
80 |
end else begin |
|
95 | 81 |
if not CurrentTeam.ExtDriven and |
82 |
((Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0) then SendIPC('a'); |
|
82 | 83 |
AfterAttack |
84 |
end |
|
95 | 85 |
end else Message:= Message and not gm_Attack |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
86 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
87 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
88 |
|
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
89 |
procedure AfterAttack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
90 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
91 |
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^, |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
92 |
CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
93 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
94 |
Inc(AttacksNum); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
95 |
State:= State and not gstAttacking; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
96 |
if Ammo[CurSlot, CurAmmo].NumPerTurn >= AttacksNum then isInMultiShoot:= true |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
97 |
else begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
98 |
TurnTimeLeft:= Ammoz[Ammo[CurSlot, CurAmmo].AmmoType].TimeAfterTurn; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
99 |
State:= State or gstAttacked; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
100 |
OnUsedAmmo(Ammo) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
101 |
end; |
95 | 102 |
AttackBar:= 0; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
103 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
104 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
105 |
|
42 | 106 |
//////////////////////////////////////////////////////////////////////////////// |
107 |
procedure PickUp(HH, Gear: PGear); |
|
295 | 108 |
var s: shortstring; |
109 |
a: TAmmoType; |
|
42 | 110 |
begin |
68 | 111 |
Gear.Message:= gm_Destroy; |
42 | 112 |
case Gear.Pos of |
295 | 113 |
posCaseAmmo: begin |
114 |
a:= TAmmoType(Gear.State); |
|
115 |
AddAmmo(PHedgehog(HH.Hedgehog), a); |
|
116 |
s:= trammo[Ammoz[a].NameId]; |
|
117 |
AddCaption(s, PHedgehog(HH.Hedgehog).Team.Color, capgrpAmmoinfo); |
|
118 |
end; |
|
42 | 119 |
posCaseHealth: begin |
120 |
inc(HH.Health, Gear.Health); |
|
295 | 121 |
str(Gear.Health, s); |
122 |
s:= '+' + s; |
|
123 |
AddCaption(s, PHedgehog(HH.Hedgehog).Team.Color, capgrpAmmoinfo); |
|
47 | 124 |
RenderHealth(PHedgehog(HH.Hedgehog)^); |
125 |
RecountTeamHealth(PHedgehog(HH.Hedgehog)^.Team) |
|
42 | 126 |
end; |
127 |
end; |
|
128 |
end; |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
129 |
|
4 | 130 |
const StepTicks: LongWord = 0; |
131 |
||
302 | 132 |
procedure HedgehogStep(Gear: PGear); |
133 |
var PrevdX: integer; |
|
134 |
begin |
|
135 |
if ((Gear.State and (gstAttacking or gstMoving or gstFalling)) = 0) then |
|
4 | 136 |
begin |
80 | 137 |
if ((Gear.Message and gm_LJump ) <> 0) then |
4 | 138 |
begin |
139 |
Gear.Message:= 0; |
|
68 | 140 |
if not TestCollisionYwithGear(Gear, -1) then |
108 | 141 |
if not TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else |
142 |
if not TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 1; |
|
143 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear.dX)) |
|
68 | 144 |
or TestCollisionYwithGear(Gear, -1)) then |
4 | 145 |
begin |
146 |
Gear.dY:= -0.15; |
|
108 | 147 |
Gear.dX:= hwSign(Gear.dX) * 0.15; |
4 | 148 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
149 |
exit |
|
150 |
end; |
|
151 |
end; |
|
80 | 152 |
if ((Gear.Message and gm_HJump ) <> 0) then |
4 | 153 |
begin |
154 |
Gear.Message:= 0; |
|
68 | 155 |
if not TestCollisionYwithGear(Gear, -1) then |
4 | 156 |
begin |
157 |
Gear.dY:= -0.20; |
|
108 | 158 |
Gear.dX:= 0.0000001 * hwSign(Gear.dX); |
159 |
Gear.X:= Gear.X - hwSign(Gear.dX)*0.00008; // shift compensation |
|
4 | 160 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
161 |
exit |
|
162 |
end; |
|
163 |
end; |
|
108 | 164 |
PrevdX:= hwSign(Gear.dX); |
300 | 165 |
if (Gear.Message and gm_Left )<>0 then Gear.dX:= -cLittle else |
166 |
if (Gear.Message and gm_Right )<>0 then Gear.dX:= cLittle else exit; |
|
74 | 167 |
StepTicks:= cHHStepTicks; |
108 | 168 |
if PrevdX <> hwSign(Gear.dX) then exit; |
4 | 169 |
PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
108 | 170 |
if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then |
4 | 171 |
begin |
108 | 172 |
if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear.dX)) |
68 | 173 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 174 |
if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear.dX)) |
68 | 175 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 176 |
if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear.dX)) |
68 | 177 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 178 |
if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear.dX)) |
68 | 179 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 180 |
if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) |
68 | 181 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 182 |
if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) |
68 | 183 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 184 |
end; |
300 | 185 |
if not TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then Gear.X:= Gear.X + hwSign(Gear.dX); |
186 |
||
62 | 187 |
SetAllHHToActive; |
37 | 188 |
|
68 | 189 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 190 |
begin |
191 |
Gear.Y:= Gear.Y + 1; |
|
68 | 192 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 193 |
begin |
194 |
Gear.Y:= Gear.Y + 1; |
|
68 | 195 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 196 |
begin |
197 |
Gear.Y:= Gear.Y + 1; |
|
68 | 198 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 199 |
begin |
200 |
Gear.Y:= Gear.Y + 1; |
|
68 | 201 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 202 |
begin |
203 |
Gear.Y:= Gear.Y + 1; |
|
68 | 204 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 205 |
begin |
206 |
Gear.Y:= Gear.Y + 1; |
|
68 | 207 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 208 |
begin |
209 |
Gear.Y:= Gear.Y - 6; |
|
210 |
Gear.dY:= 0; |
|
211 |
Gear.State:= Gear.State or gstFalling |
|
212 |
end; |
|
213 |
end |
|
214 |
end |
|
215 |
end |
|
216 |
end |
|
217 |
end |
|
62 | 218 |
end |
4 | 219 |
end |
220 |
end; |
|
221 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
222 |
procedure HedgehogChAngle(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
223 |
begin |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
224 |
if ((Gear.State and (gstMoving or gstFalling)) = 0) then |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
225 |
if (Gear.Message and gm_Up )<>0 then if Gear.Angle > 0 then dec(Gear.Angle) |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
226 |
else else |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
227 |
if (Gear.Message and gm_Down )<>0 then if Gear.Angle < cMaxAngle then inc(Gear.Angle); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
228 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
229 |
|
302 | 230 |
procedure doStepHedgehog(Gear: PGear); forward; |
231 |
//////////////////////////////////////////////////////////////////////////////// |
|
232 |
procedure doStepHedgehogDriven(Gear: PGear); |
|
233 |
var t: PGear; |
|
234 |
begin |
|
235 |
if isInMultiShoot and (Gear.Damage = 0) then |
|
236 |
begin |
|
237 |
exit |
|
238 |
end; |
|
239 |
AllInactive:= false; |
|
240 |
DeleteCI(Gear); |
|
241 |
if (TurnTimeLeft = 0) or (Gear.Damage > 0) then |
|
242 |
begin |
|
243 |
TurnTimeLeft:= 0; |
|
244 |
Gear.State:= Gear.State and not gstHHDriven; |
|
245 |
if Gear.Damage > 0 then |
|
246 |
Gear.State:= Gear.State and not gstHHJumping; |
|
247 |
exit |
|
248 |
end; |
|
249 |
if ((Gear.State and gstFalling) <> 0) or (StepTicks = cHHStepTicks) |
|
250 |
or (CurAmmoGear <> nil) then // we're moving |
|
251 |
begin |
|
252 |
// check for case with ammo |
|
253 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
254 |
if t <> nil then |
|
255 |
PickUp(Gear, t) |
|
256 |
end; |
|
257 |
||
258 |
if CurAmmoGear <> nil then |
|
259 |
begin |
|
260 |
CurAmmoGear.Message:= Gear.Message; |
|
261 |
exit |
|
262 |
end; |
|
263 |
||
264 |
if ((Gear.Message and gm_Attack) <> 0) or |
|
265 |
((Gear.State and gstAttacking) <> 0)then Attack(Gear); |
|
266 |
||
267 |
if (Gear.State and gstFalling) <> 0 then |
|
268 |
begin |
|
269 |
// it could be the source to trick: double-backspace jump -> vertical wall |
|
270 |
// collision - > (abs(Gear.dX) < 0.0000002) -> backspace -> even more high jump |
|
271 |
if ((Gear.Message and gm_HJump) <> 0) and ((Gear.State and gstHHJumping) <> 0) then |
|
272 |
if (abs(Gear.dX) < 2 * cLittle) and (Gear.dY < -0.02) then |
|
273 |
begin |
|
274 |
Gear.dY:= -0.25; |
|
275 |
Gear.dX:= hwSign(Gear.dX) * 0.02 |
|
276 |
end; |
|
277 |
Gear.Message:= Gear.Message and not (gm_LJump or gm_HJump); |
|
278 |
if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then SetLittle(Gear.dX); |
|
279 |
Gear.X:= Gear.X + Gear.dX; |
|
280 |
Gear.dY:= Gear.dY + cGravity; |
|
281 |
if (Gear.dY < 0)and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
|
282 |
Gear.Y:= Gear.Y + Gear.dY; |
|
283 |
if (Gear.dY >= 0)and TestCollisionYwithGear(Gear, 1) then |
|
284 |
begin |
|
285 |
CheckHHDamage(Gear); |
|
286 |
if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
|
287 |
and ((Gear.State and gstHHJumping) <> 0) then SetLittle(Gear.dX); |
|
288 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
|
289 |
StepTicks:= 300; |
|
290 |
Gear.dY:= 0 |
|
291 |
end; |
|
292 |
CheckGearDrowning(Gear); |
|
293 |
exit |
|
294 |
end ;//else if Gear.CollIndex = High(Longword) then AddIntersectorsCR(Gear); |
|
295 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
296 |
HedgehogChAngle(Gear); |
302 | 297 |
if StepTicks > 0 then dec(StepTicks); |
298 |
if (StepTicks = 0) then HedgehogStep(Gear) |
|
299 |
end; |
|
300 |
||
4 | 301 |
//////////////////////////////////////////////////////////////////////////////// |
302 |
procedure doStepHedgehogFree(Gear: PGear); |
|
303 |
begin |
|
62 | 304 |
//DeleteCI(Gear); |
68 | 305 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 306 |
begin |
68 | 307 |
if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
4 | 308 |
Gear.State:= Gear.State or gstFalling or gstMoving; |
309 |
Gear.dY:= Gear.dY + cGravity |
|
310 |
end else begin |
|
311 |
CheckHHDamage(Gear); |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
312 |
if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
300 | 313 |
and ((Gear.State and gstHHJumping) <> 0) then SetLittle(Gear.dX); |
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
314 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
74 | 315 |
if Gear.dY > 0 then Gear.dY:= 0; |
4 | 316 |
if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction |
317 |
end; |
|
318 |
||
53 | 319 |
if (Gear.State <> 0) then DeleteCI(Gear); |
4 | 320 |
|
321 |
if (Gear.State and gstMoving) <> 0 then |
|
108 | 322 |
if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then |
4 | 323 |
if ((Gear.State and gstFalling) = 0) then |
324 |
if abs(Gear.dX) > 0.01 then |
|
108 | 325 |
if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -1, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.96; Gear.Y:= Gear.Y - 1 end else |
326 |
if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -2, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.93; Gear.Y:= Gear.Y - 2 end else |
|
327 |
if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -3, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.90; Gear.Y:= Gear.Y - 3 end else |
|
328 |
if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -4, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.87; Gear.Y:= Gear.Y - 4 end else |
|
329 |
if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -5, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.84; Gear.Y:= Gear.Y - 5 end else |
|
149 | 330 |
if abs(Gear.dX) > 0.02 then Gear.dX:= -Gear.Elasticity * Gear.dX |
4 | 331 |
else begin |
332 |
Gear.State:= Gear.State and not gstMoving; |
|
300 | 333 |
SetLittle(Gear.dX) |
4 | 334 |
end |
149 | 335 |
else begin |
336 |
Gear.State:= Gear.State and not gstMoving; |
|
300 | 337 |
SetLittle(Gear.dX) |
149 | 338 |
end |
339 |
else Gear.dX:= -Gear.Elasticity * Gear.dX; |
|
4 | 340 |
|
341 |
if ((Gear.State and gstFalling) = 0)and |
|
342 |
(sqr(Gear.dX) + sqr(Gear.dY) < 0.0008) then |
|
343 |
begin |
|
344 |
Gear.State:= Gear.State and not gstMoving; |
|
300 | 345 |
SetLittle(Gear.dX); |
4 | 346 |
Gear.dY:= 0 |
73 | 347 |
end else Gear.State:= Gear.State or gstMoving; |
4 | 348 |
|
349 |
if (Gear.State and gstMoving) <> 0 then |
|
350 |
begin |
|
351 |
Gear.X:= Gear.X + Gear.dX; |
|
74 | 352 |
Gear.Y:= Gear.Y + Gear.dY; |
353 |
if (Gear.dY > 0) and not TestCollisionYwithGear(Gear, 1) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
354 |
begin |
|
82 | 355 |
CheckHHDamage(Gear); |
74 | 356 |
Gear.dY:= 0; |
357 |
Gear.Y:= Gear.Y + 1 |
|
358 |
end; |
|
4 | 359 |
end else |
360 |
if Gear.Health = 0 then |
|
361 |
begin |
|
362 |
if AllInactive then |
|
363 |
begin |
|
364 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound); |
|
365 |
AddGear(round(Gear.X), round(Gear.Y), gtGrave, 0).Hedgehog:= Gear.Hedgehog; |
|
366 |
DeleteGear(Gear); |
|
367 |
SetAllToActive |
|
368 |
end; |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
369 |
AllInactive:= false; |
4 | 370 |
exit |
371 |
end; |
|
372 |
||
373 |
AllInactive:= false; |
|
374 |
||
375 |
if (not CheckGearDrowning(Gear)) and |
|
376 |
((Gear.State and gstMoving) = 0) then |
|
377 |
begin |
|
378 |
Gear.State:= 0; |
|
379 |
Gear.Active:= false; |
|
53 | 380 |
AddGearCI(Gear); |
4 | 381 |
exit |
382 |
end |
|
383 |
end; |
|
384 |
||
385 |
//////////////////////////////////////////////////////////////////////////////// |
|
386 |
procedure doStepHedgehog(Gear: PGear); |
|
387 |
begin |
|
388 |
if (Gear.Message and gm_Destroy) <> 0 then |
|
389 |
begin |
|
390 |
DeleteGear(Gear); |
|
391 |
exit |
|
392 |
end; |
|
393 |
if (Gear.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
|
394 |
else doStepHedgehogDriven(Gear) |
|
395 |
end; |