author | unc0rr |
Sat, 08 Jul 2006 21:40:03 +0000 | |
changeset 74 | 42257fee61ae |
parent 73 | fe1c62875a19 |
child 75 | d2b737858ff7 |
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 |
* |
5 |
* Distributed under the terms of the BSD-modified licence: |
|
6 |
* |
|
7 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8 |
* of this software and associated documentation files (the "Software"), to deal |
|
9 |
* with the Software without restriction, including without limitation the |
|
10 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
|
11 |
* sell copies of the Software, and to permit persons to whom the Software is |
|
12 |
* furnished to do so, subject to the following conditions: |
|
13 |
* |
|
14 |
* 1. Redistributions of source code must retain the above copyright notice, |
|
15 |
* this list of conditions and the following disclaimer. |
|
16 |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
|
17 |
* this list of conditions and the following disclaimer in the documentation |
|
18 |
* and/or other materials provided with the distribution. |
|
19 |
* 3. The name of the author may not be used to endorse or promote products |
|
20 |
* derived from this software without specific prior written permission. |
|
21 |
* |
|
22 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
|
23 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
24 |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
|
25 |
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
26 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
27 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
|
28 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|
29 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|
30 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
31 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
32 |
*) |
|
33 |
||
37 | 34 |
//////////////////////////////////////////////////////////////////////////////// |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
35 |
procedure Attack(Gear: PGear); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
36 |
var xx, yy: real; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
37 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
38 |
with Gear^, |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
39 |
CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
40 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
41 |
{$IFDEF DEBUGFILE}AddFileLog('Attack: Gear.State = '+inttostr(State)+' CurAmmoGear = '+inttostr(longword(CurAmmoGear)));{$ENDIF} |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
42 |
if CurAmmoGear <> nil then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
43 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
44 |
Message:= Message and not gm_Attack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
45 |
if not CurrentTeam.ExtDriven then SendIPC('a') |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
46 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
47 |
if (((State and (gstHHDriven or gstAttacking)) = (gstHHDriven or gstAttacking))and |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
48 |
((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
|
49 |
(((State and gstFalling ) = 0)or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackInFall) <> 0))and |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
50 |
(((State and gstHHJumping) = 0)or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackInJump) <> 0)))and |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
51 |
(CurAmmoGear = nil) then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
52 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
53 |
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
|
54 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
55 |
StopTPUSound; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
56 |
PlaySound(sndThrowRelease); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
57 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
58 |
xx:= Sign(dX)*Sin(Angle*pi/cMaxAngle); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
59 |
yy:= -Cos(Angle*pi/cMaxAngle); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
60 |
case Ammo[CurSlot, CurAmmo].AmmoType of |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
61 |
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
|
62 |
amGrenade: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
63 |
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
|
64 |
amShotgun: begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
65 |
PlaySound(sndShotgunReload); |
38 | 66 |
FollowGear:= 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
|
67 |
end; |
37 | 68 |
amDEagle: begin |
38 | 69 |
FollowGear:= AddGear(round(X), round(Y), gtDEagleShot, 0, xx * 0.5, yy * 0.5); |
37 | 70 |
end; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
71 |
amSkip: TurnTimeLeft:= 0; |
53 | 72 |
amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHRadius, gtPickHammer, 0); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
73 |
amRope: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtRope, 0, xx, yy); |
56 | 74 |
amMine: AddGear(round(X) + Sign(dX) * 7, round(Y), gtMine, 0, Sign(dX) * 0.02, 0, 3000); |
75 |
amDynamite: AddGear(round(X) + Sign(dX) * 7, round(Y), gtDynamite, 0, Sign(dX) * 0.035, 0, 5000); |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
76 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
77 |
Power:= 0; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
78 |
if CurAmmoGear <> nil then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
79 |
begin |
39 | 80 |
Gear.Message:= Gear.Message or gm_Attack; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
81 |
CurAmmoGear.Message:= Gear.Message; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
82 |
exit |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
83 |
end else |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
84 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
85 |
Message:= Message and not gm_Attack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
86 |
if not CurrentTeam.ExtDriven then SendIPC('a') |
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 |
AfterAttack |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
89 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
90 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
91 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
92 |
|
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
93 |
procedure AfterAttack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
94 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
95 |
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^, |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
96 |
CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
97 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
98 |
Inc(AttacksNum); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
99 |
State:= State and not gstAttacking; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
100 |
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
|
101 |
else begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
102 |
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
|
103 |
State:= State or gstAttacked; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
104 |
OnUsedAmmo(Ammo) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
105 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
106 |
AttackBar:= 0 |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
107 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
108 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
109 |
|
42 | 110 |
//////////////////////////////////////////////////////////////////////////////// |
111 |
procedure PickUp(HH, Gear: PGear); |
|
112 |
begin |
|
68 | 113 |
Gear.Message:= gm_Destroy; |
42 | 114 |
case Gear.Pos of |
115 |
posCaseHealth: begin |
|
116 |
inc(HH.Health, Gear.Health); |
|
47 | 117 |
RenderHealth(PHedgehog(HH.Hedgehog)^); |
118 |
RecountTeamHealth(PHedgehog(HH.Hedgehog)^.Team) |
|
42 | 119 |
end; |
120 |
end; |
|
121 |
end; |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
122 |
|
4 | 123 |
procedure doStepHedgehog(Gear: PGear); forward; |
124 |
//////////////////////////////////////////////////////////////////////////////// |
|
125 |
procedure doStepHedgehogDriven(Gear: PGear); |
|
126 |
const StepTicks: LongWord = 0; |
|
15 | 127 |
var t: PGear; |
74 | 128 |
PrevdX: integer; |
4 | 129 |
begin |
70 | 130 |
if isInMultiShoot and (Gear.Damage = 0) then |
39 | 131 |
begin |
132 |
exit |
|
133 |
end; |
|
4 | 134 |
AllInactive:= false; |
53 | 135 |
DeleteCI(Gear); |
4 | 136 |
if (TurnTimeLeft = 0) or (Gear.Damage > 0) then |
137 |
begin |
|
138 |
if ((Gear.State and (gstMoving or gstFalling)) = 0) |
|
139 |
and (CurAmmoGear = nil) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
140 |
Gear.State:= Gear.State and not gstHHDriven; |
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
141 |
if Gear.Damage > 0 then |
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
142 |
Gear.State:= Gear.State and not gstHHJumping; |
4 | 143 |
exit |
144 |
end; |
|
70 | 145 |
if ((Gear.State and gstFalling) <> 0) or (StepTicks = cHHStepTicks) |
42 | 146 |
or (CurAmmoGear <> nil) then // we're moving |
15 | 147 |
begin |
42 | 148 |
// check for case with ammo |
149 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
150 |
if t <> nil then |
|
151 |
PickUp(Gear, t) |
|
15 | 152 |
end; |
4 | 153 |
|
154 |
if CurAmmoGear <> nil then |
|
155 |
begin |
|
156 |
CurAmmoGear.Message:= Gear.Message; |
|
157 |
exit |
|
158 |
end; |
|
159 |
||
160 |
if (Gear.Message and gm_Attack)<>0 then |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
161 |
if (Gear.State and (gstAttacked or gstHHChooseTarget) = 0) then |
4 | 162 |
with PHedgehog(Gear.Hedgehog)^ do |
163 |
begin |
|
164 |
Gear.State:= Gear.State or gstAttacking; |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
165 |
if Gear.Power = cMaxPower then Gear.Message:= Gear.Message and not gm_Attack |
37 | 166 |
else |
38 | 167 |
if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then |
168 |
Gear.Message:= Gear.Message and not gm_Attack |
|
4 | 169 |
else begin |
170 |
if Gear.Power = 0 then |
|
171 |
begin |
|
172 |
AttackBar:= CurrentTeam.AttackBar; |
|
173 |
PlaySound(sndThrowPowerUp) |
|
174 |
end; |
|
175 |
inc(Gear.Power) |
|
176 |
end |
|
37 | 177 |
end |
178 |
else Gear.Message:= Gear.Message and not gm_Attack; |
|
4 | 179 |
|
37 | 180 |
if ((Gear.State and gstAttacking) <> 0) and ((Gear.Message and gm_Attack) = 0) then |
181 |
begin |
|
182 |
Attack(Gear); |
|
38 | 183 |
StepTicks:= 40 |
37 | 184 |
end; |
4 | 185 |
|
186 |
if (Gear.State and gstFalling) <> 0 then |
|
187 |
begin |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
188 |
// it could be the source to trick: double-backspace jump -> vertical wall |
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
189 |
// collision - > (abs(Gear.dX) < 0.0000002) -> backspace -> even more high jump |
4 | 190 |
if ((Gear.Message and gm_HJump) <> 0) and ((Gear.State and gstHHJumping) <> 0) then |
191 |
if (abs(Gear.dX) < 0.0000002) and (Gear.dY < -0.02) then |
|
192 |
begin |
|
193 |
Gear.dY:= -0.25; |
|
194 |
Gear.dX:= Sign(Gear.dX) * 0.02 |
|
195 |
end; |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
196 |
Gear.Message:= Gear.Message and not (gm_LJump or gm_HJump); |
4 | 197 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
198 |
Gear.X:= Gear.X + Gear.dX; |
|
199 |
Gear.dY:= Gear.dY + cGravity; |
|
200 |
if (Gear.dY < 0)and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
|
201 |
Gear.Y:= Gear.Y + Gear.dY; |
|
68 | 202 |
if (Gear.dY >= 0)and TestCollisionYwithGear(Gear, 1) then |
4 | 203 |
begin |
204 |
CheckHHDamage(Gear); |
|
205 |
if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
|
206 |
and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
207 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
|
39 | 208 |
StepTicks:= 300; |
4 | 209 |
Gear.dY:= 0 |
210 |
end; |
|
211 |
CheckGearDrowning(Gear); |
|
212 |
exit |
|
53 | 213 |
end ;//else if Gear.CollIndex = High(Longword) then AddIntersectorsCR(Gear); |
4 | 214 |
|
215 |
if StepTicks > 0 then dec(StepTicks); |
|
216 |
||
217 |
if ((Gear.State and (gstMoving or gstFalling)) = 0) then |
|
218 |
if (Gear.Message and gm_Up )<>0 then if Gear.Angle > 0 then dec(Gear.Angle) |
|
219 |
else else |
|
220 |
if (Gear.Message and gm_Down )<>0 then if Gear.Angle < cMaxAngle then inc(Gear.Angle); |
|
221 |
||
222 |
if ((Gear.State and (gstAttacking or gstMoving or gstFalling)) = 0)and(StepTicks = 0) then |
|
223 |
begin |
|
224 |
if ((Gear.Message and gm_LJump )<>0) then |
|
225 |
begin |
|
226 |
Gear.Message:= 0; |
|
68 | 227 |
if not TestCollisionYwithGear(Gear, -1) then |
4 | 228 |
if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else |
229 |
if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 1; |
|
230 |
if not (TestCollisionXwithGear(Gear, Sign(Gear.dX)) |
|
68 | 231 |
or TestCollisionYwithGear(Gear, -1)) then |
4 | 232 |
begin |
233 |
Gear.dY:= -0.15; |
|
234 |
Gear.dX:= Sign(Gear.dX) * 0.15; |
|
235 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
|
236 |
exit |
|
237 |
end; |
|
238 |
end; |
|
239 |
if ((Gear.Message and gm_HJump )<>0) then |
|
240 |
begin |
|
241 |
Gear.Message:= 0; |
|
68 | 242 |
if not TestCollisionYwithGear(Gear, -1) then |
4 | 243 |
begin |
244 |
Gear.dY:= -0.20; |
|
245 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
246 |
Gear.X:= Gear.X - Sign(Gear.dX)*0.00008; // êîìïåíñàöèÿ ñäâèãà %) |
|
247 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
|
248 |
exit |
|
249 |
end; |
|
250 |
end; |
|
74 | 251 |
PrevdX:= Sign(Gear.dX); |
4 | 252 |
if (Gear.Message and gm_Left )<>0 then Gear.dX:= -1.0 else |
253 |
if (Gear.Message and gm_Right )<>0 then Gear.dX:= 1.0 else exit; |
|
74 | 254 |
StepTicks:= cHHStepTicks; |
255 |
if PrevdX <> Sign(Gear.dX) then exit; |
|
4 | 256 |
PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
257 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
|
258 |
begin |
|
259 |
if not (TestCollisionXwithXYShift(Gear, 0, -6, Sign(Gear.dX)) |
|
68 | 260 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 261 |
if not (TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) |
68 | 262 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 263 |
if not (TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX)) |
68 | 264 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 265 |
if not (TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX)) |
68 | 266 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 267 |
if not (TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) |
68 | 268 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 269 |
if not (TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) |
68 | 270 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 271 |
end; |
272 |
if not TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.X:= Gear.X + Gear.dX; |
|
62 | 273 |
SetAllHHToActive; |
37 | 274 |
|
68 | 275 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 276 |
begin |
277 |
Gear.Y:= Gear.Y + 1; |
|
68 | 278 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 279 |
begin |
280 |
Gear.Y:= Gear.Y + 1; |
|
68 | 281 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 282 |
begin |
283 |
Gear.Y:= Gear.Y + 1; |
|
68 | 284 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 285 |
begin |
286 |
Gear.Y:= Gear.Y + 1; |
|
68 | 287 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 288 |
begin |
289 |
Gear.Y:= Gear.Y + 1; |
|
68 | 290 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 291 |
begin |
292 |
Gear.Y:= Gear.Y + 1; |
|
68 | 293 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 294 |
begin |
295 |
Gear.Y:= Gear.Y - 6; |
|
296 |
Gear.dY:= 0; |
|
297 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
298 |
Gear.State:= Gear.State or gstFalling |
|
299 |
end; |
|
300 |
end |
|
301 |
end |
|
302 |
end |
|
303 |
end |
|
304 |
end |
|
62 | 305 |
end |
4 | 306 |
end |
307 |
end; |
|
308 |
||
309 |
//////////////////////////////////////////////////////////////////////////////// |
|
310 |
procedure doStepHedgehogFree(Gear: PGear); |
|
311 |
begin |
|
62 | 312 |
//DeleteCI(Gear); |
68 | 313 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 314 |
begin |
68 | 315 |
if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
4 | 316 |
Gear.State:= Gear.State or gstFalling or gstMoving; |
317 |
Gear.dY:= Gear.dY + cGravity |
|
318 |
end else begin |
|
319 |
CheckHHDamage(Gear); |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
320 |
if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
321 |
and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
322 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
74 | 323 |
if Gear.dY > 0 then Gear.dY:= 0; |
4 | 324 |
if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction |
325 |
end; |
|
326 |
||
53 | 327 |
if (Gear.State <> 0) then DeleteCI(Gear); |
4 | 328 |
|
329 |
if (Gear.State and gstMoving) <> 0 then |
|
330 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
|
331 |
if ((Gear.State and gstFalling) = 0) then |
|
332 |
if abs(Gear.dX) > 0.01 then |
|
74 | 333 |
if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -1, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.96; Gear.Y:= Gear.Y - 1 end else |
334 |
if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -2, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.93; Gear.Y:= Gear.Y - 2 end else |
|
335 |
if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -3, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.90; Gear.Y:= Gear.Y - 3 end else |
|
336 |
if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -4, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.87; Gear.Y:= Gear.Y - 4 end else |
|
337 |
if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -5, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.84; Gear.Y:= Gear.Y - 5 end else |
|
338 |
if abs(Gear.dX) > 0.02 then Gear.dX:= -0.5 * Gear.dX |
|
4 | 339 |
else begin |
340 |
Gear.State:= Gear.State and not gstMoving; |
|
341 |
Gear.dX:= 0.0000001 * Sign(Gear.dX) |
|
342 |
end |
|
343 |
else begin |
|
344 |
Gear.State:= Gear.State and not gstMoving; |
|
345 |
Gear.dX:= 0.0000001 * Sign(Gear.dX) |
|
346 |
end |
|
74 | 347 |
else Gear.dX:= -Gear.dX; |
4 | 348 |
|
349 |
if ((Gear.State and gstFalling) = 0)and |
|
350 |
(sqr(Gear.dX) + sqr(Gear.dY) < 0.0008) then |
|
351 |
begin |
|
352 |
Gear.State:= Gear.State and not gstMoving; |
|
353 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
354 |
Gear.dY:= 0 |
|
73 | 355 |
end else Gear.State:= Gear.State or gstMoving; |
4 | 356 |
|
357 |
if (Gear.State and gstMoving) <> 0 then |
|
358 |
begin |
|
359 |
Gear.X:= Gear.X + Gear.dX; |
|
74 | 360 |
Gear.Y:= Gear.Y + Gear.dY; |
361 |
if (Gear.dY > 0) and not TestCollisionYwithGear(Gear, 1) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
362 |
begin |
|
363 |
Gear.dY:= 0; |
|
364 |
Gear.Y:= Gear.Y + 1 |
|
365 |
end; |
|
4 | 366 |
end else |
367 |
if Gear.Health = 0 then |
|
368 |
begin |
|
369 |
if AllInactive then |
|
370 |
begin |
|
371 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound); |
|
372 |
AddGear(round(Gear.X), round(Gear.Y), gtGrave, 0).Hedgehog:= Gear.Hedgehog; |
|
373 |
DeleteGear(Gear); |
|
374 |
SetAllToActive |
|
375 |
end; |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
376 |
AllInactive:= false; |
4 | 377 |
exit |
378 |
end; |
|
379 |
||
380 |
AllInactive:= false; |
|
381 |
||
382 |
if (not CheckGearDrowning(Gear)) and |
|
383 |
((Gear.State and gstMoving) = 0) then |
|
384 |
begin |
|
385 |
Gear.State:= 0; |
|
386 |
Gear.Active:= false; |
|
53 | 387 |
AddGearCI(Gear); |
4 | 388 |
exit |
389 |
end |
|
390 |
end; |
|
391 |
||
392 |
//////////////////////////////////////////////////////////////////////////////// |
|
393 |
procedure doStepHedgehog(Gear: PGear); |
|
394 |
begin |
|
395 |
if (Gear.Message and gm_Destroy) <> 0 then |
|
396 |
begin |
|
397 |
DeleteGear(Gear); |
|
398 |
exit |
|
399 |
end; |
|
400 |
if (Gear.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
|
401 |
else doStepHedgehogDriven(Gear) |
|
402 |
end; |