hedgewars/GSHandlers.inc
author unc0rr
Mon, 09 Jan 2006 20:33:12 +0000
changeset 42 72ffe21f027c
parent 39 b78e7185ed13
child 43 e297fea1a2f3
permissions -rw-r--r--
- Fixed console behavior - Fixed pickhammer - Fixed bots using of shotgun and desert eagle - Fixed shotgun and desert eagle - Added health cases
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     1
(*
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     2
 * Hedgewars, a worms-like game
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     3
 * Copyright (c) 2004, 2005 Andrey Korotaev <unC0Rr@gmail.com>
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     4
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     5
 * Distributed under the terms of the BSD-modified licence:
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     6
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     8
 * of this software and associated documentation files (the "Software"), to deal
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     9
 * with the Software without restriction, including without limitation the
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    10
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    11
 * sell copies of the Software, and to permit persons to whom the Software is
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    12
 * furnished to do so, subject to the following conditions:
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    13
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    14
 * 1. Redistributions of source code must retain the above copyright notice,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    15
 *    this list of conditions and the following disclaimer.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    16
 * 2. Redistributions in binary form must reproduce the above copyright notice,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    17
 *    this list of conditions and the following disclaimer in the documentation
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    18
 *    and/or other materials provided with the distribution.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    19
 * 3. The name of the author may not be used to endorse or promote products
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    20
 *    derived from this software without specific prior written permission.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    21
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    22
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    23
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    24
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    25
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    26
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    27
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    28
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    29
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    30
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    31
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    32
 *)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    33
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    34
procedure doStepDrowningGear(Gear: PGear); forward;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    35
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    36
function CheckGearDrowning(Gear: PGear): boolean;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    37
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    38
Result:= Gear.Y + Gear.HalfHeight >= cWaterLine;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    39
if Result then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    40
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    41
   Gear.State:= gstDrowning;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    42
   Gear.doStep:= doStepDrowningGear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    43
   PlaySound(sndSplash)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    44
   end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    45
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    46
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    47
procedure CheckCollision(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    48
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    49
if TestCollisionXwithGear(Gear, Sign(Gear.X)) or TestCollisionYwithGear(Gear, Sign(Gear.Y))
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    50
   then Gear.State:= Gear.State or      gstCollision
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    51
   else Gear.State:= Gear.State and not gstCollision
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    52
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    53
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    54
procedure CheckHHDamage(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    55
begin
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
    56
if Gear.dY > 0.35 then Gear.Damage:= Gear.Damage + round(75 * (abs(Gear.dY) - 0.35));
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    57
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    58
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    59
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    60
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    61
procedure CalcRotationDirAngle(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    62
var dAngle: real;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    63
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    64
dAngle:= (abs(Gear.dX) + abs(Gear.dY))*0.1;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    65
if Gear.dX >= 0 then Gear.DirAngle:= Gear.DirAngle + dAngle
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    66
                else Gear.DirAngle:= Gear.DirAngle - dAngle;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    67
if Gear.DirAngle < 0 then Gear.DirAngle:= Gear.DirAngle + 16
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    68
else if Gear.DirAngle >= 16 then Gear.DirAngle:= Gear.DirAngle - 16
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    69
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    70
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    71
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    72
procedure doStepDrowningGear(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    73
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    74
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    75
Gear.Y:= Gear.Y + cDrownSpeed;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    76
if round(Gear.Y) > Gear.HalfHeight + cWaterLine + 48 + cVisibleWater then DeleteGear(Gear)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    77
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    78
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    79
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    80
procedure doStepFallingGear(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    81
var b: boolean;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    82
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    83
if TestCollisionYwithGear(Gear, Sign(Gear.dY)) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    84
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    85
   Gear.dX:=   Gear.dX * Gear.Friction;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    86
   Gear.dY:= - Gear.dY * Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    87
   b:= false
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    88
   end else b:= true;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    89
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    90
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    91
   Gear.dX:= - Gear.dX * Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    92
//   Gear.dY:=   Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    93
   b:= false
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    94
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    95
if b then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    96
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    97
   Gear.dY:= Gear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    98
   Gear.State:= Gear.State and not gstCollision
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    99
   end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   100
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   101
   if sqr(Gear.dX) + sqr(Gear.dY) < 0.00001 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   102
      if (Gear.Timer = 0) then Gear.Active:= false
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   103
                          else begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   104
                          Gear.dX:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   105
                          Gear.dY:= 0
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   106
                          end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   107
   Gear.State:= Gear.State or gstCollision
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   108
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   109
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   110
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   111
CheckGearDrowning(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   112
if (sqr(Gear.dX) + sqr(Gear.dY) < 0.003) then Gear.State:= Gear.State and not gstMoving
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   113
                                         else Gear.State:= Gear.State or      gstMoving
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   114
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   115
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   116
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   117
procedure doStepCloud(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   118
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   119
Gear.X:= Gear.X + cWindSpeed * 200 + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   120
if Gear.X < -cScreenWidth-256 then Gear.X:= cScreenWidth + 2048 else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   121
if Gear.X > cScreenWidth + 2048 then Gear.X:= -cScreenWidth - 256
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   122
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   123
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   124
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   125
procedure doStepBomb(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   126
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   127
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   128
doStepFallingGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   129
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   130
if Gear.Timer = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   131
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   132
   doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   133
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   134
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   135
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   136
CalcRotationDirAngle(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   137
if (Gear.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then PlaySound(sndGrenadeImpact)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   138
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   139
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   140
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   141
procedure doStepGrenade(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   142
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   143
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   144
Gear.dX:= Gear.dX + cWindSpeed;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   145
doStepFallingGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   146
if (Gear.State and gstCollision) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   147
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   148
   doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   149
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   150
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   151
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   152
if (GameTicks and $3F) = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   153
   AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   154
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   155
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   156
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   157
procedure doStepHealthTag(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   158
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   159
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   160
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   161
Gear.Y:= Gear.Y - 0.07;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   162
if Gear.Timer = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   163
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   164
   PHedgehog(Gear.Hedgehog).Gear.Active:= true;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   165
   DeleteGear(Gear)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   166
   end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   167
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   168
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   169
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   170
procedure doStepGrave(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   171
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   172
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   173
if Gear.dY < 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   174
   if TestCollisionY(Gear, -1) then Gear.dY:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   175
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   176
if Gear.dY >=0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   177
   if TestCollisionY(Gear, 1) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   178
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   179
      Gear.dY:= - Gear.dY * Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   180
      if Gear.dY > - 0.001 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   181
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   182
         Gear.Active:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   183
         exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   184
         end else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   185
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   186
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   187
CheckGearDrowning(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   188
Gear.dY:= Gear.dY + cGravity
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   189
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   190
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   191
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   192
procedure doStepUFOWork(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   193
var t: real;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   194
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   195
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   196
t:= sqrt(sqr(Gear.dX) + sqr(Gear.dY));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   197
Gear.dX:= Gear.Elasticity * (Gear.dX + 0.000004 * (TargetPoint.X - trunc(Gear.X)));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   198
Gear.dY:= Gear.Elasticity * (Gear.dY + 0.000004 * (TargetPoint.Y - trunc(Gear.Y)));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   199
t:= t / (sqrt(sqr(Gear.dX) + sqr(Gear.dY)));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   200
Gear.dX:= Gear.dX * t;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   201
Gear.dY:= Gear.dY * t;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   202
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   203
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   204
CheckCollision(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   205
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   206
if ((Gear.State and gstCollision) <> 0) or (Gear.Timer = 0) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   207
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   208
   doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   209
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   210
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   211
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   212
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   213
procedure doStepUFO(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   214
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   215
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   216
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   217
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   218
Gear.dY:= Gear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   219
CheckCollision(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   220
if (Gear.State and gstCollision) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   221
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   222
   doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   223
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   224
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   225
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   226
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   227
if Gear.Timer = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   228
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   229
   Gear.Timer:= 5000;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   230
   Gear.doStep:= doStepUFOWork
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   231
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   232
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   233
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   234
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   235
procedure doStepShotgunShot(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   236
var i: LongWord;
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   237
    t: PGear;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   238
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   239
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   240
if Gear.Timer > 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   241
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   242
   dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   243
   if Gear.Timer = 1 then PlaySound(sndShotgunFire);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   244
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   245
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   246
i:= 200;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   247
repeat
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   248
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   249
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   250
CheckCollision(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   251
if (Gear.State and gstCollision) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   252
   begin
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   253
   t:= CheckGearsCollision(Gear, Sign(Gear.dX), true);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   254
   if t = nil then t:= CheckGearsCollision(Gear, Sign(Gear.dY), false);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   255
   if t <> nil then
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   256
      AmmoShove(Gear, t, 25);
42
72ffe21f027c - Fixed console behavior
unc0rr
parents: 39
diff changeset
   257
   doMakeExplosion(round(Gear.X), round(Gear.Y), 25, EXPLNoDamage or EXPLDoNotTouchHH);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   258
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   259
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   260
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   261
dec(i)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   262
until i = 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   263
if (Gear.X < 0) or (Gear.Y < 0) or (Gear.X > 2048) or (Gear.Y > 1024) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   264
   DeleteGear(Gear)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   265
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   266
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   267
////////////////////////////////////////////////////////////////////////////////
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   268
procedure doStepDEagleShot(Gear: PGear);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   269
var i, x, y: LongWord;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   270
    oX, oY: real;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   271
    t: PGear;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   272
begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   273
AllInactive:= false;
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   274
i:= 80;
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   275
oX:= Gear.X;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   276
oY:= Gear.Y;
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   277
repeat
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   278
  Gear.X:= Gear.X + Gear.dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   279
  Gear.Y:= Gear.Y + Gear.dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   280
  x:= round(Gear.X);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   281
  y:= round(Gear.Y);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   282
  if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0)
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   283
     and (Land[y, x] <> 0) then inc(Gear.Damage);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   284
  t:= CheckGearsCollision(Gear, Sign(Gear.dX), true);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   285
  if t = nil then t:= CheckGearsCollision(Gear, Sign(Gear.dY), false);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   286
  if t <> nil then
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   287
     begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   288
     AmmoShove(Gear, t, 12);
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   289
     inc(Gear.Damage, 10);
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   290
     if t.CollIndex < High(Longword) then DeleteCR(t)
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   291
     end;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   292
  dec(i)
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   293
until (i = 0) or (Gear.Damage > Gear.Health);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   294
if Gear.Damage > 0 then
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   295
   begin
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   296
   DrawTunnel(oX, oY, Gear.dX, Gear.dY, 82 - i, 1);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   297
   dec(Gear.Health, Gear.Damage);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   298
   Gear.Damage:= 0
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   299
   end;
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   300
if (Gear.Health <= 0) or (Gear.X < 0) or (Gear.Y < 0) or (Gear.X > 2048) or (Gear.Y > 1024) then
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   301
   DeleteGear(Gear)
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   302
end;
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   303
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   304
////////////////////////////////////////////////////////////////////////////////
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   305
procedure doStepActionTimer(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   306
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   307
case Gear.State of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   308
     gtsStartGame: begin
6
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   309
                   dec(Gear.Timer);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   310
                   AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   311
                   if Gear.Timer > 0 then exit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   312
                   AddCaption('Let''s fight!', $FFFFFF, capgrpStartGame);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   313
                   DeleteGear(Gear)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   314
                   end;
6
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   315
  gtsSmoothWindCh: begin
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   316
                   if Gear.Timer = 0 then
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   317
                      begin
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   318
                      Gear.Timer:= 10;
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   319
                      if WindBarWidth < Gear.Tag then inc(WindBarWidth)
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   320
                         else if WindBarWidth > Gear.Tag then dec(WindBarWidth)
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   321
                         else DeleteGear(Gear)
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   322
                      end else dec(Gear.Timer)
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   323
                   end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   324
     end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   325
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   326
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   327
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   328
procedure doStepPickHammerWork(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   329
var i, ei: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   330
    HHGear: PGear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   331
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   332
Allinactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   333
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   334
if (Gear.Timer = 0)or((Gear.Message and gm_Destroy) <> 0) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   335
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   336
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   337
   AfterAttack;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   338
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   339
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   340
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   341
if (Gear.Timer and $3F) = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   342
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   343
   i:= round(Gear.X) - Gear.HalfWidth  - GetRandom(2);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   344
   ei:= round(Gear.X) + Gear.HalfWidth + GetRandom(2);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   345
   while i <= ei do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   346
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   347
         doMakeExplosion(i, round(Gear.Y) + 3, 3, 0);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   348
         inc(i, 1)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   349
         end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   350
   Gear.X:= Gear.X + Gear.dX;
42
72ffe21f027c - Fixed console behavior
unc0rr
parents: 39
diff changeset
   351
   Gear.Y:= Gear.Y + 1.9;
72ffe21f027c - Fixed console behavior
unc0rr
parents: 39
diff changeset
   352
   SetAllHHToActive;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   353
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   354
if TestCollisionYwithGear(Gear, 1) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   355
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   356
   Gear.dY:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   357
   HHGear.dX:= 0.0000001 * Sign(PGear(Gear.Hedgehog).dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   358
   HHGear.dY:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   359
   end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   360
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   361
   Gear.dY:= Gear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   362
   Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   363
   if Gear.Y > 1024 then Gear.Timer:= 1
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   364
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   365
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   366
Gear.X:= Gear.X + HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   367
HHGear.X:= Gear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   368
HHGear.Y:= Gear.Y - cHHHalfHeight;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   369
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   370
if (Gear.Message and gm_Attack) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   371
   if (Gear.State and gsttmpFlag) <> 0 then Gear.Timer:= 1 else else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   372
   if (Gear.State and gsttmpFlag) = 0 then Gear.State:= Gear.State or gsttmpFlag;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   373
if ((Gear.Message and gm_Left) <> 0) then Gear.dX:= -0.3 else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   374
   if ((Gear.Message and gm_Right) <> 0) then Gear.dX:= 0.3
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   375
                                         else Gear.dX:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   376
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   377
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   378
procedure doStepPickHammer(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   379
var i, y: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   380
    ar: TRangeArray;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   381
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   382
i:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   383
y:= round(Gear.Y) - cHHHalfHeight*2;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   384
while y < round(Gear.Y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   385
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   386
   ar[i].Left := round(Gear.X) - Gear.HalfWidth - GetRandom(2);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   387
   ar[i].Right:= round(Gear.X) + Gear.HalfWidth + GetRandom(2);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   388
   inc(y, 2);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   389
   inc(i)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   390
   end;
42
72ffe21f027c - Fixed console behavior
unc0rr
parents: 39
diff changeset
   391
DrawHLinesExplosions(@ar, 3, round(Gear.Y) - cHHHalfHeight*2, 2, Pred(i));
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   392
Gear.dY:= PHedgehog(Gear.Hedgehog).Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   393
doStepPickHammerWork(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   394
Gear.doStep:= doStepPickHammerWork
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   395
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   396
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   397
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   398
procedure doStepRopeWork(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   399
const pidiv2: real = pi/2;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   400
      flCheck: boolean = false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   401
var HHGear: PGear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   402
    len, cs, cc, tx, ty: real;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   403
    lx, ly: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   404
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   405
    procedure DeleteMe;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   406
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   407
      with HHGear^ do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   408
           begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   409
           Message:= Message and not gm_Attack;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   410
           State:= State or gstFalling;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   411
           end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   412
      DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   413
      OnUsedAmmo(PHedgehog(Gear.Hedgehog)^.Ammo);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   414
      ApplyAmmoChanges(PHedgehog(Gear.Hedgehog))
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   415
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   416
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   417
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   418
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   419
if (HHGear.State and gstHHDriven) = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   420
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   421
   DeleteMe;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   422
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   423
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   424
Gear.dX:= HHGear.X - Gear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   425
Gear.dY:= HHGear.Y - Gear.Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   426
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   427
if (Gear.Message and gm_Left  <> 0) then HHGear.dX:= HHGear.dX - 0.0002 else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   428
if (Gear.Message and gm_Right <> 0) then HHGear.dX:= HHGear.dX + 0.0002;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   429
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   430
if not TestCollisionYwithGear(HHGear, 1) then HHGear.dY:= HHGear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   431
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   432
HHGear.DirAngle:= arctan(Gear.dY + HHGear.dY, Gear.dX + HHGear.dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   433
cs:= sin(HHGear.DirAngle);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   434
cc:= cos(HHGear.DirAngle);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   435
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   436
flCheck:= not flCheck;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   437
if flCheck then  // check whether rope needs dividing
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   438
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   439
   len:= Gear.Elasticity - 20;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   440
   while len > 5 do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   441
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   442
         tx:= cc*len;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   443
         ty:= cs*len;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   444
         lx:= round(Gear.X + tx) + sign(HHGear.dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   445
         ly:= round(Gear.Y + ty) + sign(HHGear.dY);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   446
         if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0)and (Land[ly, lx] <> 0) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   447
           begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   448
           with RopePoints.ar[RopePoints.Count] do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   449
                begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   450
                X:= Gear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   451
                Y:= Gear.Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   452
                if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle32(Gear.dY, Gear.dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   453
                b:= (cc * HHGear.dY) > (cs * HHGear.dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   454
                dLen:= len
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   455
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   456
           Gear.X:= Gear.X + tx;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   457
           Gear.Y:= Gear.Y + ty;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   458
           inc(RopePoints.Count);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   459
           Gear.Elasticity:= Gear.Elasticity - len;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   460
           Gear.Friction:= Gear.Friction - len;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   461
           break
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   462
           end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   463
         len:= len - 3
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   464
         end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   465
   end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   466
   if RopePoints.Count > 0 then // check whether the last dividing point could be removed
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   467
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   468
      tx:= RopePoints.ar[Pred(RopePoints.Count)].X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   469
      ty:= RopePoints.ar[Pred(RopePoints.Count)].Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   470
      if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear.X) * (ty - HHGear.Y) > (tx - HHGear.X) * (ty - Gear.Y)) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   471
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   472
         dec(RopePoints.Count);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   473
         Gear.X:=RopePoints.ar[RopePoints.Count].X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   474
         Gear.Y:=RopePoints.ar[RopePoints.Count].Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   475
         Gear.Elasticity:= Gear.Elasticity + RopePoints.ar[RopePoints.Count].dLen;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   476
         Gear.Friction:= Gear.Friction + RopePoints.ar[RopePoints.Count].dLen
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   477
         end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   478
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   479
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   480
Gear.dX:= HHGear.X - Gear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   481
Gear.dY:= HHGear.Y - Gear.Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   482
HHGear.DirAngle:= arctan(Gear.dY + HHGear.dY, Gear.dX + HHGear.dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   483
cs:= sin(HHGear.DirAngle);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   484
cc:= cos(HHGear.DirAngle);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   485
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   486
HHGear.dX:= HHGear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   487
HHGear.dY:= HHGear.Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   488
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   489
if ((Gear.Message and gm_Down) <> 0) and (Gear.Elasticity < Gear.Friction) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   490
   if not (TestCollisionXwithGear(HHGear, Sign(Gear.dX))
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   491
        or TestCollisionYwithGear(HHGear, Sign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity + 0.3;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   492
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   493
if ((Gear.Message and gm_Up) <> 0) and (Gear.Elasticity > 30) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   494
   if not (TestCollisionXwithGear(HHGear, -Sign(Gear.dX))
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   495
        or TestCollisionYwithGear(HHGear, -Sign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity - 0.3;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   496
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   497
HHGear.X:= Gear.X + cc*Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   498
HHGear.Y:= Gear.Y + cs*Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   499
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   500
HHGear.dX:= HHGear.X - HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   501
HHGear.dY:= HHGear.Y - HHGear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   502
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   503
if TestCollisionXwithGear(HHGear, Sign(HHGear.dX)) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   504
   HHGear.dX:= -0.9 * HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   505
if TestCollisionYwithGear(HHGear, Sign(HHGear.dY)) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   506
   HHGear.dY:= -0.9 * HHGear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   507
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   508
if (Gear.Message and gm_Attack) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   509
   if (Gear.State and gsttmpFlag) <> 0 then DeleteMe else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   510
else if (Gear.State and gsttmpFlag) = 0 then Gear.State:= Gear.State or gsttmpFlag;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   511
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   512
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   513
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   514
procedure doStepRopeAttach(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   515
var HHGear: PGear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   516
    tx, ty, tt: real;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   517
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   518
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   519
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   520
Gear.Elasticity:= Gear.Elasticity + 1.0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   521
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   522
if (HHGear.State and gstFalling) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   523
   if HHTestCollisionYwithGear(HHGear, 1) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   524
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   525
      HHGear.dY:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   526
      CheckHHDamage(HHGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   527
      HHGear.State:= HHGear.State and not (gstFalling or gstHHJumping);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   528
      end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   529
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   530
      if TestCollisionXwithGear(HHGear, Sign(HHGear.dX)) then HHGear.dX:= 0.0000001 * Sign(HHGear.dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   531
      HHGear.X:= HHGear.X + HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   532
      HHGear.Y:= HHGear.Y + HHGear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   533
      Gear.X:= Gear.X + HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   534
      Gear.Y:= Gear.Y + HHGear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   535
      HHGear.dY:= HHGear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   536
      tt:= Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   537
      tx:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   538
      ty:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   539
      while tt > 20 do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   540
            begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   541
            if  TestCollisionXwithXYShift(Gear, round(tx), round(ty), Sign(Gear.dX))
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   542
             or TestCollisionYwithXYShift(Gear, round(tx), round(ty), Sign(Gear.dY)) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   543
                begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   544
                Gear.X:= Gear.X + tx;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   545
                Gear.Y:= Gear.Y + ty;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   546
                Gear.Elasticity:= tt;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   547
                Gear.doStep:= doStepRopeWork;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   548
                with HHGear^ do State:= State and not gstAttacking;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   549
                tt:= 0
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   550
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   551
            tx:= tx - Gear.dX - Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   552
            ty:= ty - Gear.dY - Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   553
            tt:= tt - 2.0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   554
            end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   555
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   556
CheckCollision(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   557
if (Gear.State and gstCollision) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   558
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   559
   Gear.doStep:= doStepRopeWork;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   560
   with HHGear^ do State:= State and not gstAttacking;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   561
   if Gear.Elasticity < 10 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   562
      Gear.Elasticity:= 10000;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   563
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   564
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   565
if (Gear.Elasticity >= Gear.Friction) or ((Gear.Message and gm_Attack) = 0) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   566
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   567
   with PHedgehog(Gear.Hedgehog).Gear^ do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   568
        begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   569
        State:= State and not gstAttacking;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   570
        Message:= Message and not gm_Attack
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   571
        end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   572
   DeleteGear(Gear)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   573
   end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   574
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   575
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   576
procedure doStepRope(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   577
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   578
Gear.doStep:= doStepRopeAttach
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   579
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   580
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   581
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   582
procedure doStepSmokeTrace(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   583
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   584
inc(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   585
if Gear.Timer > 64 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   586
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   587
   Gear.Timer:= 0;
9
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   588
   dec(Gear.State)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   589
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   590
Gear.dX:= Gear.dX + cWindSpeed;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   591
Gear.X:= Gear.X + Gear.dX;
9
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   592
if Gear.State = 0 then DeleteGear(Gear)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   593
end;
9
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   594
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   595
////////////////////////////////////////////////////////////////////////////////
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   596
procedure doStepExplosion(Gear: PGear);
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   597
begin
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   598
inc(Gear.Timer);
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   599
if Gear.Timer > 75 then
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   600
   begin
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   601
   inc(Gear.State);
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   602
   Gear.Timer:= 0;
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   603
   if Gear.State > 5 then DeleteGear(Gear)
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   604
   end;
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   605
end;
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   606
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   607
////////////////////////////////////////////////////////////////////////////////
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   608
procedure doStepMine(Gear: PGear);
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   609
begin
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   610
if (Gear.dX <> 0) or (Gear.dY <> 0) then
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   611
   begin
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   612
   if Gear.CollIndex < High(Longword) then DeleteCR(Gear);
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   613
   doStepFallingGear(Gear);
13
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   614
   if Gear.Active = false then
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   615
      begin
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   616
      if Gear.CollIndex = High(Longword) then AddGearCR(Gear);
13
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   617
      Gear.dX:= 0;
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   618
      Gear.dY:= 0
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   619
      end;
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   620
   CalcRotationDirAngle(Gear);
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   621
   AllInactive:= false
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   622
   end;
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   623
   
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   624
if ((Gear.State and gsttmpFlag) <> 0) then
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   625
   if ((Gear.State and gstAttacking) = 0) then
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   626
      begin
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   627
      if ((GameTicks and $F) = 0) then
15
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   628
         if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear.State:= Gear.State or gstAttacking
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   629
      end else // gstAttacking <> 0
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   630
      begin
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   631
      AllInactive:= false;
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   632
      if (Gear.Timer and $FF) = 0 then PlaySound(sndMineTick);
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   633
      if Gear.Timer = 0 then
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   634
         begin
13
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   635
         doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   636
         DeleteGear(Gear)
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   637
         end;
13
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   638
      dec(Gear.Timer);
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   639
      end else // gsttmpFlag = 0
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   640
   if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag;
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   641
end;
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   642
////////////////////////////////////////////////////////////////////////////////
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   643
procedure doStepDynamite(Gear: PGear);
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   644
begin
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   645
if (Gear.dX <> 0) or (Gear.dY <> 0) {or not TestCollisionY(Gear, 1)} then
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   646
   begin
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   647
   doStepFallingGear(Gear);
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   648
   if Gear.Active = false then
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   649
      begin
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   650
      Gear.dX:= 0;
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   651
      Gear.dY:= 0
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   652
      end;
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   653
//   CalcRotationDirAngle(Gear);
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   654
   AllInactive:= false
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   655
   end;
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   656
//if ((Gear.State and gsttmpFlag) <> 0) then
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   657
//   if ((Gear.State  and gstAttacking) = 0) then
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   658
      begin
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   659
  //    AllInactive:= true;
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   660
      if (Gear.Timer and $FF) = 0 then PlaySound(sndMineTick);
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   661
      if Gear.Timer = 0 then
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   662
         begin
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   663
         doMakeExplosion(round(Gear.X), round(Gear.Y), 85, EXPLAutoSound);
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   664
         DeleteGear(Gear)
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   665
         end;
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   666
      dec(Gear.Timer);
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   667
      end;{ else // gsttmpFlag = 0
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   668
   if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag;}
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   669
end;
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   670
15
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   671
////////////////////////////////////////////////////////////////////////////////
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   672
procedure doStepCase(Gear: PGear);
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   673
begin
15
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   674
if (Gear.Message and gm_Destroy) > 0 then
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   675
   begin
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   676
   DeleteGear(Gear);
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   677
   exit
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   678
   end;
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   679
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   680
if (Gear.dY <> 0) or (not TestCollisionY(Gear, 1)) then
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   681
   begin
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   682
   AllInactive:= false;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   683
   Gear.dY:= Gear.dY + cGravity;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   684
   Gear.Y:= Gear.Y + Gear.dY;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   685
   if (Gear.dY < 0) and TestCollisionY(Gear, -1) then Gear.dY:= 0 else
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   686
   if (Gear.dY >= 0) and TestCollisionY(Gear, 1) then
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   687
      begin
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   688
      Gear.dY:= - Gear.dY * Gear.Elasticity;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   689
      if Gear.dY > - 0.001 then Gear.dY:= 0
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   690
         else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact);
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   691
      end;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   692
   CheckGearDrowning(Gear);
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   693
   end;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   694
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   695
if (Gear.CollIndex = High(Longword)) and (Gear.dY = 0) then AddGearCR(Gear)
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   696
   else if (Gear.CollIndex < High(Longword)) and (Gear.dY <> 0) then DeleteCR(Gear);
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   697
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   698
if Gear.Damage > 0 then
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   699
   begin
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   700
   DeleteGear(Gear);
16
b6f4b413dd41 - Various fixes for ammo cases
unc0rr
parents: 15
diff changeset
   701
   doMakeExplosion(round(Gear.X), round(Gear.Y), 20, EXPLAutoSound)
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   702
   end
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   703
end;