author | unc0rr |
Mon, 03 Jul 2006 17:46:58 +0000 | |
changeset 73 | fe1c62875a19 |
parent 70 | 82d93eeecebe |
child 74 | 42257fee61ae |
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; |
4 | 128 |
begin |
70 | 129 |
if isInMultiShoot and (Gear.Damage = 0) then |
39 | 130 |
begin |
131 |
exit |
|
132 |
end; |
|
4 | 133 |
AllInactive:= false; |
53 | 134 |
DeleteCI(Gear); |
4 | 135 |
if (TurnTimeLeft = 0) or (Gear.Damage > 0) then |
136 |
begin |
|
137 |
if ((Gear.State and (gstMoving or gstFalling)) = 0) |
|
138 |
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
|
139 |
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
|
140 |
if Gear.Damage > 0 then |
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
141 |
Gear.State:= Gear.State and not gstHHJumping; |
4 | 142 |
exit |
143 |
end; |
|
70 | 144 |
if ((Gear.State and gstFalling) <> 0) or (StepTicks = cHHStepTicks) |
42 | 145 |
or (CurAmmoGear <> nil) then // we're moving |
15 | 146 |
begin |
42 | 147 |
// check for case with ammo |
148 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
149 |
if t <> nil then |
|
150 |
PickUp(Gear, t) |
|
15 | 151 |
end; |
4 | 152 |
|
153 |
if CurAmmoGear <> nil then |
|
154 |
begin |
|
155 |
CurAmmoGear.Message:= Gear.Message; |
|
156 |
exit |
|
157 |
end; |
|
158 |
||
159 |
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
|
160 |
if (Gear.State and (gstAttacked or gstHHChooseTarget) = 0) then |
4 | 161 |
with PHedgehog(Gear.Hedgehog)^ do |
162 |
begin |
|
163 |
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
|
164 |
if Gear.Power = cMaxPower then Gear.Message:= Gear.Message and not gm_Attack |
37 | 165 |
else |
38 | 166 |
if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then |
167 |
Gear.Message:= Gear.Message and not gm_Attack |
|
4 | 168 |
else begin |
169 |
if Gear.Power = 0 then |
|
170 |
begin |
|
171 |
AttackBar:= CurrentTeam.AttackBar; |
|
172 |
PlaySound(sndThrowPowerUp) |
|
173 |
end; |
|
174 |
inc(Gear.Power) |
|
175 |
end |
|
37 | 176 |
end |
177 |
else Gear.Message:= Gear.Message and not gm_Attack; |
|
4 | 178 |
|
37 | 179 |
if ((Gear.State and gstAttacking) <> 0) and ((Gear.Message and gm_Attack) = 0) then |
180 |
begin |
|
181 |
Attack(Gear); |
|
38 | 182 |
StepTicks:= 40 |
37 | 183 |
end; |
4 | 184 |
|
185 |
if (Gear.State and gstFalling) <> 0 then |
|
186 |
begin |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
187 |
// 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
|
188 |
// collision - > (abs(Gear.dX) < 0.0000002) -> backspace -> even more high jump |
4 | 189 |
if ((Gear.Message and gm_HJump) <> 0) and ((Gear.State and gstHHJumping) <> 0) then |
190 |
if (abs(Gear.dX) < 0.0000002) and (Gear.dY < -0.02) then |
|
191 |
begin |
|
192 |
Gear.dY:= -0.25; |
|
193 |
Gear.dX:= Sign(Gear.dX) * 0.02 |
|
194 |
end; |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
195 |
Gear.Message:= Gear.Message and not (gm_LJump or gm_HJump); |
4 | 196 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
197 |
Gear.X:= Gear.X + Gear.dX; |
|
198 |
Gear.dY:= Gear.dY + cGravity; |
|
199 |
if (Gear.dY < 0)and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
|
200 |
Gear.Y:= Gear.Y + Gear.dY; |
|
68 | 201 |
if (Gear.dY >= 0)and TestCollisionYwithGear(Gear, 1) then |
4 | 202 |
begin |
203 |
CheckHHDamage(Gear); |
|
204 |
if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
|
205 |
and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
206 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
|
39 | 207 |
StepTicks:= 300; |
4 | 208 |
Gear.dY:= 0 |
209 |
end; |
|
210 |
CheckGearDrowning(Gear); |
|
211 |
exit |
|
53 | 212 |
end ;//else if Gear.CollIndex = High(Longword) then AddIntersectorsCR(Gear); |
4 | 213 |
|
214 |
if StepTicks > 0 then dec(StepTicks); |
|
215 |
||
216 |
if ((Gear.State and (gstMoving or gstFalling)) = 0) then |
|
217 |
if (Gear.Message and gm_Up )<>0 then if Gear.Angle > 0 then dec(Gear.Angle) |
|
218 |
else else |
|
219 |
if (Gear.Message and gm_Down )<>0 then if Gear.Angle < cMaxAngle then inc(Gear.Angle); |
|
220 |
||
221 |
if ((Gear.State and (gstAttacking or gstMoving or gstFalling)) = 0)and(StepTicks = 0) then |
|
222 |
begin |
|
223 |
if ((Gear.Message and gm_LJump )<>0) then |
|
224 |
begin |
|
225 |
Gear.Message:= 0; |
|
68 | 226 |
if not TestCollisionYwithGear(Gear, -1) then |
4 | 227 |
if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else |
228 |
if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 1; |
|
229 |
if not (TestCollisionXwithGear(Gear, Sign(Gear.dX)) |
|
68 | 230 |
or TestCollisionYwithGear(Gear, -1)) then |
4 | 231 |
begin |
232 |
Gear.dY:= -0.15; |
|
233 |
Gear.dX:= Sign(Gear.dX) * 0.15; |
|
234 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
|
235 |
exit |
|
236 |
end; |
|
237 |
end; |
|
238 |
if ((Gear.Message and gm_HJump )<>0) then |
|
239 |
begin |
|
240 |
Gear.Message:= 0; |
|
68 | 241 |
if not TestCollisionYwithGear(Gear, -1) then |
4 | 242 |
begin |
243 |
Gear.dY:= -0.20; |
|
244 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
245 |
Gear.X:= Gear.X - Sign(Gear.dX)*0.00008; // êîìïåíñàöèÿ ñäâèãà %) |
|
246 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
|
247 |
exit |
|
248 |
end; |
|
249 |
end; |
|
250 |
if (Gear.Message and gm_Left )<>0 then Gear.dX:= -1.0 else |
|
251 |
if (Gear.Message and gm_Right )<>0 then Gear.dX:= 1.0 else exit; |
|
252 |
PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
|
70 | 253 |
StepTicks:= cHHStepTicks; |
4 | 254 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
255 |
begin |
|
256 |
if not (TestCollisionXwithXYShift(Gear, 0, -6, Sign(Gear.dX)) |
|
68 | 257 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 258 |
if not (TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) |
68 | 259 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 260 |
if not (TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX)) |
68 | 261 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 262 |
if not (TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX)) |
68 | 263 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 264 |
if not (TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) |
68 | 265 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 266 |
if not (TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) |
68 | 267 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 268 |
end; |
269 |
if not TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.X:= Gear.X + Gear.dX; |
|
62 | 270 |
SetAllHHToActive; |
37 | 271 |
|
68 | 272 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 273 |
begin |
274 |
Gear.Y:= Gear.Y + 1; |
|
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 - 6; |
|
293 |
Gear.dY:= 0; |
|
294 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
295 |
Gear.State:= Gear.State or gstFalling |
|
296 |
end; |
|
297 |
end |
|
298 |
end |
|
299 |
end |
|
300 |
end |
|
301 |
end |
|
62 | 302 |
end |
4 | 303 |
end |
304 |
end; |
|
305 |
||
306 |
//////////////////////////////////////////////////////////////////////////////// |
|
307 |
procedure doStepHedgehogFree(Gear: PGear); |
|
308 |
begin |
|
62 | 309 |
//DeleteCI(Gear); |
68 | 310 |
if not TestCollisionYwithGear(Gear, 1) then |
73 | 311 |
if TestCollisionYwithXYShift(Gear, 0, 1, 1) then Gear.Y:= Gear.Y + 1 else |
4 | 312 |
begin |
68 | 313 |
if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
4 | 314 |
Gear.State:= Gear.State or gstFalling or gstMoving; |
315 |
Gear.dY:= Gear.dY + cGravity |
|
316 |
end else begin |
|
317 |
CheckHHDamage(Gear); |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
318 |
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
|
319 |
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
|
320 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
4 | 321 |
if Gear.dY > 0 then Gear.dY:= 0; |
322 |
if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction |
|
323 |
end; |
|
324 |
||
53 | 325 |
if (Gear.State <> 0) then DeleteCI(Gear); |
4 | 326 |
|
327 |
if (Gear.State and gstMoving) <> 0 then |
|
328 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
|
329 |
if ((Gear.State and gstFalling) = 0) then |
|
330 |
if abs(Gear.dX) > 0.01 then |
|
73 | 331 |
if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.99; Gear.Y:= Gear.Y - 1 end else |
332 |
if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.98; Gear.Y:= Gear.Y - 2 end else |
|
333 |
if not TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.97; Gear.Y:= Gear.Y - 3 end else |
|
334 |
if not TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.96; Gear.Y:= Gear.Y - 4 end else |
|
335 |
if not TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.95; Gear.Y:= Gear.Y - 5 end else |
|
336 |
if abs(Gear.dX) > 0.02 then Gear.dX:= -0.3 * Gear.dX |
|
4 | 337 |
else begin |
338 |
Gear.State:= Gear.State and not gstMoving; |
|
339 |
Gear.dX:= 0.0000001 * Sign(Gear.dX) |
|
340 |
end |
|
341 |
else begin |
|
342 |
Gear.State:= Gear.State and not gstMoving; |
|
343 |
Gear.dX:= 0.0000001 * Sign(Gear.dX) |
|
344 |
end |
|
345 |
else Gear.dX:= -0.8 * Gear.dX; |
|
346 |
||
347 |
if ((Gear.State and gstFalling) = 0)and |
|
348 |
(sqr(Gear.dX) + sqr(Gear.dY) < 0.0008) then |
|
349 |
begin |
|
350 |
Gear.State:= Gear.State and not gstMoving; |
|
351 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
352 |
Gear.dY:= 0 |
|
73 | 353 |
end else Gear.State:= Gear.State or gstMoving; |
4 | 354 |
|
355 |
if (Gear.State and gstMoving) <> 0 then |
|
356 |
begin |
|
357 |
Gear.X:= Gear.X + Gear.dX; |
|
358 |
Gear.Y:= Gear.Y + Gear.dY |
|
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; |