hedgewars/GSHandlers.inc
author unc0rr
Mon, 24 Jul 2006 14:03:51 +0000
changeset 83 207c85fbef51
parent 82 2f4f3236cccc
child 89 f9db56409a86
permissions -rw-r--r--
- First hedgehog in team has first turn in team - AI fix: let bots go to the right and... Show whether round finished with draw or team won... get rid of error message
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
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
     3
 * Copyright (c) 2004, 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com>
4
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
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
    38
Result:= Gear.Y + Gear.Radius >= cWaterLine;
4
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
71
5f56c6979496 - Changed falling damage scoring
unc0rr
parents: 70
diff changeset
    56
if Gear.dY > 0.40 then Gear.Damage:= Gear.Damage + 1 + round(70 * (abs(Gear.dY) - 0.40));
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;
75
d2b737858ff7 - New First Aid powerup
unc0rr
parents: 74
diff changeset
    76
if round(Gear.Y) > Gear.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear)
4
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;
74
42257fee61ae - Unicode support for team and hedgehogs names
unc0rr
parents: 71
diff changeset
   120
if Gear.Y > -160 then Gear.dY:= Gear.dY - 0.00002
42257fee61ae - Unicode support for team and hedgehogs names
unc0rr
parents: 71
diff changeset
   121
                 else Gear.dY:= Gear.dY + 0.00002;
42257fee61ae - Unicode support for team and hedgehogs names
unc0rr
parents: 71
diff changeset
   122
Gear.Y:= Gear.Y + Gear.dY;
42257fee61ae - Unicode support for team and hedgehogs names
unc0rr
parents: 71
diff changeset
   123
if Gear.X < -cScreenWidth - 256 then Gear.X:= cScreenWidth + 2048 else
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   124
if Gear.X > cScreenWidth + 2048 then Gear.X:= -cScreenWidth - 256
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   125
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   126
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   127
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   128
procedure doStepBomb(Gear: PGear);
78
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   129
var i: integer;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   130
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   131
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   132
doStepFallingGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   133
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   134
if Gear.Timer = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   135
   begin
78
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   136
   case Gear.Kind of
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   137
        gtAmmo_Bomb: doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   138
      gtClusterBomb: begin
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   139
                     doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound);
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   140
                     for i:= 0 to 4 do
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   141
                         AddGear(round(Gear.X), round(Gear.Y), gtCluster, 0, (getrandom - 0.5)*0.2, (getrandom - 3) * 0.08);
78
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   142
                     end
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   143
        end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   144
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   145
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   146
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   147
CalcRotationDirAngle(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   148
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
   149
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   150
78
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   151
procedure doStepCluster(Gear: PGear);
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   152
begin
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   153
AllInactive:= false;
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   154
doStepFallingGear(Gear);
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   155
if (Gear.State and gstCollision) <> 0 then
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   156
   begin
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   157
   doMakeExplosion(round(Gear.X), round(Gear.Y), 20, EXPLAutoSound);
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   158
   DeleteGear(Gear);
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   159
   exit
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   160
   end;
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   161
if (GameTicks and $1F) = 0 then
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   162
   AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0)
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   163
end;
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   164
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   165
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   166
procedure doStepGrenade(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   167
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   168
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   169
Gear.dX:= Gear.dX + cWindSpeed;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   170
doStepFallingGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   171
if (Gear.State and gstCollision) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   172
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   173
   doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   174
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   175
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   176
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   177
if (GameTicks and $3F) = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   178
   AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   179
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   180
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   181
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   182
procedure doStepHealthTag(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   183
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   184
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   185
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   186
Gear.Y:= Gear.Y - 0.07;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   187
if Gear.Timer = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   188
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   189
   PHedgehog(Gear.Hedgehog).Gear.Active:= true;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   190
   DeleteGear(Gear)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   191
   end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   192
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   193
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   194
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   195
procedure doStepGrave(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   196
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   197
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   198
if Gear.dY < 0 then
68
cbb93eb90304 Collision-related stuff
unc0rr
parents: 57
diff changeset
   199
   if TestCollisionY(Gear, -1) then Gear.dY:= 0;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   200
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   201
if Gear.dY >=0 then
68
cbb93eb90304 Collision-related stuff
unc0rr
parents: 57
diff changeset
   202
   if TestCollisionY(Gear, 1) then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   203
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   204
      Gear.dY:= - Gear.dY * Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   205
      if Gear.dY > - 0.001 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   206
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   207
         Gear.Active:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   208
         exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   209
         end else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact)
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
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   212
CheckGearDrowning(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   213
Gear.dY:= Gear.dY + cGravity
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   214
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   215
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   216
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   217
procedure doStepUFOWork(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   218
var t: real;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   219
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   220
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   221
t:= sqrt(sqr(Gear.dX) + sqr(Gear.dY));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   222
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
   223
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
   224
t:= t / (sqrt(sqr(Gear.dX) + sqr(Gear.dY)));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   225
Gear.dX:= Gear.dX * t;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   226
Gear.dY:= Gear.dY * t;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   227
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   228
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   229
CheckCollision(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   230
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   231
if ((Gear.State and gstCollision) <> 0) or (Gear.Timer = 0) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   232
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   233
   doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   234
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   235
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   236
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   237
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   238
procedure doStepUFO(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   239
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   240
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   241
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   242
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   243
Gear.dY:= Gear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   244
CheckCollision(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   245
if (Gear.State and gstCollision) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   246
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   247
   doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   248
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   249
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   250
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   251
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   252
if Gear.Timer = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   253
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   254
   Gear.Timer:= 5000;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   255
   Gear.doStep:= doStepUFOWork
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   256
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   257
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   258
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   259
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   260
procedure doStepShotgunShot(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   261
var i: LongWord;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   262
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   263
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   264
if Gear.Timer > 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   265
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   266
   dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   267
   if Gear.Timer = 1 then PlaySound(sndShotgunFire);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   268
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   269
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   270
i:= 200;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   271
repeat
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   272
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   273
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   274
CheckCollision(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   275
if (Gear.State and gstCollision) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   276
   begin
75
d2b737858ff7 - New First Aid powerup
unc0rr
parents: 74
diff changeset
   277
   AmmoShove(Gear, 25, 25);
42
72ffe21f027c - Fixed console behavior
unc0rr
parents: 39
diff changeset
   278
   doMakeExplosion(round(Gear.X), round(Gear.Y), 25, EXPLNoDamage or EXPLDoNotTouchHH);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   279
   DeleteGear(Gear);
75
d2b737858ff7 - New First Aid powerup
unc0rr
parents: 74
diff changeset
   280
   AfterAttack;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   281
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   282
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   283
dec(i)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   284
until i = 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   285
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
   286
   DeleteGear(Gear)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   287
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   288
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   289
////////////////////////////////////////////////////////////////////////////////
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   290
procedure doStepDEagleShot(Gear: PGear);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   291
var i, x, y: LongWord;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   292
    oX, oY: real;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   293
begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   294
AllInactive:= false;
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   295
i:= 80;
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   296
oX:= Gear.X;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   297
oY:= Gear.Y;
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   298
repeat
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   299
  Gear.X:= Gear.X + Gear.dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   300
  Gear.Y:= Gear.Y + Gear.dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   301
  x:= round(Gear.X);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   302
  y:= round(Gear.Y);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   303
  if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0)
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   304
     and (Land[y, x] <> 0) then inc(Gear.Damage);
75
d2b737858ff7 - New First Aid powerup
unc0rr
parents: 74
diff changeset
   305
  AmmoShove(Gear, 7, 20);
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   306
  dec(i)
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   307
until (i = 0) or (Gear.Damage > Gear.Health);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   308
if Gear.Damage > 0 then
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   309
   begin
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   310
   DrawTunnel(oX, oY, Gear.dX, Gear.dY, 82 - i, 1);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   311
   dec(Gear.Health, Gear.Damage);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   312
   Gear.Damage:= 0
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   313
   end;
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   314
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
   315
   DeleteGear(Gear)
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   316
end;
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   317
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   318
////////////////////////////////////////////////////////////////////////////////
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   319
procedure doStepActionTimer(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   320
begin
83
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   321
dec(Gear.Timer);
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   322
case Gear.Kind of
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   323
    gtATStartGame: begin
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   324
                   AllInactive:= false;
83
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   325
                   if Gear.Timer = 0 then
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   326
                      AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   327
                   end;
83
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   328
 gtATSmoothWindCh: begin
6
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   329
                   if Gear.Timer = 0 then
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   330
                      begin
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   331
                      if WindBarWidth < Gear.Tag then inc(WindBarWidth)
83
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   332
                         else if WindBarWidth > Gear.Tag then dec(WindBarWidth);
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   333
                      if WindBarWidth <> Gear.Tag then Gear.Timer:= 10;
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   334
                      end
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   335
                   end;
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   336
   gtATFinishGame: begin
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   337
                   AllInactive:= false;
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   338
                   if Gear.Timer = 0 then
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   339
                      GameState:= gsExit
6
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   340
                   end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   341
     end;
83
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   342
if Gear.Timer = 0 then DeleteGear(Gear)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   343
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   344
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   345
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   346
procedure doStepPickHammerWork(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   347
var i, ei: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   348
    HHGear: PGear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   349
begin
70
82d93eeecebe - Many AI improvements
unc0rr
parents: 68
diff changeset
   350
AllInactive:= false;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   351
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   352
if (Gear.Timer = 0)or((Gear.Message and gm_Destroy) <> 0) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   353
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   354
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   355
   AfterAttack;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   356
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   357
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   358
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   359
if (Gear.Timer and $3F) = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   360
   begin
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   361
   i:= round(Gear.X) - Gear.Radius  - GetRandom(2);
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   362
   ei:= round(Gear.X) + Gear.Radius + GetRandom(2);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   363
   while i <= ei do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   364
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   365
         doMakeExplosion(i, round(Gear.Y) + 3, 3, 0);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   366
         inc(i, 1)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   367
         end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   368
   Gear.X:= Gear.X + Gear.dX;
42
72ffe21f027c - Fixed console behavior
unc0rr
parents: 39
diff changeset
   369
   Gear.Y:= Gear.Y + 1.9;
72ffe21f027c - Fixed console behavior
unc0rr
parents: 39
diff changeset
   370
   SetAllHHToActive;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   371
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   372
if TestCollisionYwithGear(Gear, 1) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   373
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   374
   Gear.dY:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   375
   HHGear.dX:= 0.0000001 * Sign(PGear(Gear.Hedgehog).dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   376
   HHGear.dY:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   377
   end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   378
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   379
   Gear.dY:= Gear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   380
   Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   381
   if Gear.Y > 1024 then Gear.Timer:= 1
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   382
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   383
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   384
Gear.X:= Gear.X + HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   385
HHGear.X:= Gear.X;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   386
HHGear.Y:= Gear.Y - cHHRadius;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   387
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   388
if (Gear.Message and gm_Attack) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   389
   if (Gear.State and gsttmpFlag) <> 0 then Gear.Timer:= 1 else else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   390
   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
   391
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
   392
   if ((Gear.Message and gm_Right) <> 0) then Gear.dX:= 0.3
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   393
                                         else Gear.dX:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   394
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   395
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   396
procedure doStepPickHammer(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   397
var i, y: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   398
    ar: TRangeArray;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   399
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   400
i:= 0;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   401
y:= round(Gear.Y) - cHHRadius*2;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   402
while y < round(Gear.Y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   403
   begin
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   404
   ar[i].Left := round(Gear.X) - Gear.Radius - GetRandom(2);
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   405
   ar[i].Right:= round(Gear.X) + Gear.Radius + GetRandom(2);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   406
   inc(y, 2);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   407
   inc(i)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   408
   end;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   409
DrawHLinesExplosions(@ar, 3, round(Gear.Y) - cHHRadius*2, 2, Pred(i));
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   410
Gear.dY:= PHedgehog(Gear.Hedgehog).Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   411
doStepPickHammerWork(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   412
Gear.doStep:= doStepPickHammerWork
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   413
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   414
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   415
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   416
procedure doStepRopeWork(Gear: PGear);
70
82d93eeecebe - Many AI improvements
unc0rr
parents: 68
diff changeset
   417
const flCheck: boolean = false;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   418
var HHGear: PGear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   419
    len, cs, cc, tx, ty: real;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   420
    lx, ly: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   421
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   422
    procedure DeleteMe;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   423
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   424
      with HHGear^ do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   425
           begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   426
           Message:= Message and not gm_Attack;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   427
           State:= State or gstFalling;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   428
           end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   429
      DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   430
      OnUsedAmmo(PHedgehog(Gear.Hedgehog)^.Ammo);
70
82d93eeecebe - Many AI improvements
unc0rr
parents: 68
diff changeset
   431
      ApplyAmmoChanges(PHedgehog(Gear.Hedgehog)^)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   432
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   433
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   434
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   435
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
80
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 79
diff changeset
   436
if ((HHGear.State and gstHHDriven) = 0)
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 79
diff changeset
   437
   or (CheckGearDrowning(HHGear)) then
4
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
   DeleteMe;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   440
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   441
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   442
Gear.dX:= HHGear.X - Gear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   443
Gear.dY:= HHGear.Y - Gear.Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   444
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   445
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
   446
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
   447
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   448
if not TestCollisionYwithGear(HHGear, 1) then HHGear.dY:= HHGear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   449
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   450
HHGear.DirAngle:= arctan(Gear.dY + HHGear.dY, Gear.dX + HHGear.dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   451
cs:= sin(HHGear.DirAngle);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   452
cc:= cos(HHGear.DirAngle);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   453
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   454
flCheck:= not flCheck;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   455
if flCheck then  // check whether rope needs dividing
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   456
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   457
   len:= Gear.Elasticity - 20;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   458
   while len > 5 do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   459
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   460
         tx:= cc*len;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   461
         ty:= cs*len;
70
82d93eeecebe - Many AI improvements
unc0rr
parents: 68
diff changeset
   462
         lx:= round(Gear.X + tx) + Sign(HHGear.dX);
82d93eeecebe - Many AI improvements
unc0rr
parents: 68
diff changeset
   463
         ly:= round(Gear.Y + ty) + Sign(HHGear.dY);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   464
         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
   465
           begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   466
           with RopePoints.ar[RopePoints.Count] do
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
                X:= Gear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   469
                Y:= Gear.Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   470
                if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle32(Gear.dY, Gear.dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   471
                b:= (cc * HHGear.dY) > (cs * HHGear.dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   472
                dLen:= len
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   473
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   474
           Gear.X:= Gear.X + tx;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   475
           Gear.Y:= Gear.Y + ty;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   476
           inc(RopePoints.Count);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   477
           Gear.Elasticity:= Gear.Elasticity - len;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   478
           Gear.Friction:= Gear.Friction - len;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   479
           break
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   480
           end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   481
         len:= len - 3
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   482
         end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   483
   end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   484
   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
   485
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   486
      tx:= RopePoints.ar[Pred(RopePoints.Count)].X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   487
      ty:= RopePoints.ar[Pred(RopePoints.Count)].Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   488
      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
   489
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   490
         dec(RopePoints.Count);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   491
         Gear.X:=RopePoints.ar[RopePoints.Count].X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   492
         Gear.Y:=RopePoints.ar[RopePoints.Count].Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   493
         Gear.Elasticity:= Gear.Elasticity + RopePoints.ar[RopePoints.Count].dLen;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   494
         Gear.Friction:= Gear.Friction + RopePoints.ar[RopePoints.Count].dLen
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   495
         end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   496
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   497
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   498
Gear.dX:= HHGear.X - Gear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   499
Gear.dY:= HHGear.Y - Gear.Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   500
HHGear.DirAngle:= arctan(Gear.dY + HHGear.dY, Gear.dX + HHGear.dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   501
cs:= sin(HHGear.DirAngle);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   502
cc:= cos(HHGear.DirAngle);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   503
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   504
HHGear.dX:= HHGear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   505
HHGear.dY:= HHGear.Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   506
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   507
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
   508
   if not (TestCollisionXwithGear(HHGear, Sign(Gear.dX))
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   509
        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
   510
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   511
if ((Gear.Message and gm_Up) <> 0) and (Gear.Elasticity > 30) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   512
   if not (TestCollisionXwithGear(HHGear, -Sign(Gear.dX))
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   513
        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
   514
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   515
HHGear.X:= Gear.X + cc*Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   516
HHGear.Y:= Gear.Y + cs*Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   517
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   518
HHGear.dX:= HHGear.X - HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   519
HHGear.dY:= HHGear.Y - HHGear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   520
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   521
if TestCollisionXwithGear(HHGear, Sign(HHGear.dX)) then
75
d2b737858ff7 - New First Aid powerup
unc0rr
parents: 74
diff changeset
   522
   HHGear.dX:= -0.6 * HHGear.dX;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   523
if TestCollisionYwithGear(HHGear, Sign(HHGear.dY)) then
75
d2b737858ff7 - New First Aid powerup
unc0rr
parents: 74
diff changeset
   524
   HHGear.dY:= -0.6 * HHGear.dY;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   525
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   526
if (Gear.Message and gm_Attack) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   527
   if (Gear.State and gsttmpFlag) <> 0 then DeleteMe else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   528
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
   529
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   530
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   531
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   532
procedure doStepRopeAttach(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   533
var HHGear: PGear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   534
    tx, ty, tt: real;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   535
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   536
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   537
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   538
Gear.Elasticity:= Gear.Elasticity + 1.0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   539
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   540
if (HHGear.State and gstFalling) <> 0 then
68
cbb93eb90304 Collision-related stuff
unc0rr
parents: 57
diff changeset
   541
   if TestCollisionYwithGear(HHGear, 1) then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   542
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   543
      HHGear.dY:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   544
      CheckHHDamage(HHGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   545
      HHGear.State:= HHGear.State and not (gstFalling or gstHHJumping);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   546
      end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   547
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   548
      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
   549
      HHGear.X:= HHGear.X + HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   550
      HHGear.Y:= HHGear.Y + HHGear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   551
      Gear.X:= Gear.X + HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   552
      Gear.Y:= Gear.Y + HHGear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   553
      HHGear.dY:= HHGear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   554
      tt:= Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   555
      tx:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   556
      ty:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   557
      while tt > 20 do
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
            if  TestCollisionXwithXYShift(Gear, round(tx), round(ty), Sign(Gear.dX))
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   560
             or TestCollisionYwithXYShift(Gear, round(tx), round(ty), Sign(Gear.dY)) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   561
                begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   562
                Gear.X:= Gear.X + tx;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   563
                Gear.Y:= Gear.Y + ty;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   564
                Gear.Elasticity:= tt;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   565
                Gear.doStep:= doStepRopeWork;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   566
                with HHGear^ do State:= State and not gstAttacking;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   567
                tt:= 0
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   568
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   569
            tx:= tx - Gear.dX - Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   570
            ty:= ty - Gear.dY - Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   571
            tt:= tt - 2.0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   572
            end;
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
CheckCollision(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   575
if (Gear.State and gstCollision) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   576
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   577
   Gear.doStep:= doStepRopeWork;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   578
   with HHGear^ do State:= State and not gstAttacking;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   579
   if Gear.Elasticity < 10 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   580
      Gear.Elasticity:= 10000;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   581
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   582
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   583
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
   584
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   585
   with PHedgehog(Gear.Hedgehog).Gear^ do
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
        State:= State and not gstAttacking;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   588
        Message:= Message and not gm_Attack
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
   DeleteGear(Gear)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   591
   end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   592
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   593
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   594
procedure doStepRope(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   595
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   596
Gear.doStep:= doStepRopeAttach
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   597
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   598
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   599
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   600
procedure doStepSmokeTrace(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   601
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   602
inc(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   603
if Gear.Timer > 64 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   604
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   605
   Gear.Timer:= 0;
9
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   606
   dec(Gear.State)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   607
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   608
Gear.dX:= Gear.dX + cWindSpeed;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   609
Gear.X:= Gear.X + Gear.dX;
9
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   610
if Gear.State = 0 then DeleteGear(Gear)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   611
end;
9
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   612
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   613
////////////////////////////////////////////////////////////////////////////////
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   614
procedure doStepExplosion(Gear: PGear);
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   615
begin
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   616
inc(Gear.Timer);
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   617
if Gear.Timer > 75 then
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   618
   begin
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   619
   inc(Gear.State);
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   620
   Gear.Timer:= 0;
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   621
   if Gear.State > 5 then DeleteGear(Gear)
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   622
   end;
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   623
end;
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   624
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   625
////////////////////////////////////////////////////////////////////////////////
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   626
procedure doStepMine(Gear: PGear);
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   627
begin
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   628
if (Gear.dX <> 0) or (Gear.dY <> 0) then
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   629
   begin
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   630
   if Gear.CollIndex < High(Longword) then DeleteCI(Gear);
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   631
   doStepFallingGear(Gear);
13
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   632
   if Gear.Active = false then
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   633
      begin
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   634
      if Gear.CollIndex = High(Longword) then AddGearCI(Gear);
13
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   635
      Gear.dX:= 0;
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   636
      Gear.dY:= 0
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   637
      end;
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   638
   CalcRotationDirAngle(Gear);
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   639
   AllInactive:= false
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   640
   end;
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   641
   
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   642
if ((Gear.State and gsttmpFlag) <> 0) then
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   643
   if ((Gear.State and gstAttacking) = 0) then
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   644
      begin
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   645
      if ((GameTicks and $F) = 0) then
15
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   646
         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
   647
      end else // gstAttacking <> 0
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   648
      begin
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   649
      AllInactive:= false;
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   650
      if (Gear.Timer and $FF) = 0 then PlaySound(sndMineTick);
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   651
      if Gear.Timer = 0 then
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   652
         begin
13
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   653
         doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   654
         DeleteGear(Gear)
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   655
         end;
13
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   656
      dec(Gear.Timer);
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   657
      end else // gsttmpFlag = 0
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   658
   if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag;
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   659
end;
57
e1a77ae57065 - Fixed compiling .)
unc0rr
parents: 53
diff changeset
   660
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   661
////////////////////////////////////////////////////////////////////////////////
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   662
procedure doStepDynamite(Gear: PGear);
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   663
begin
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   664
doStepFallingGear(Gear);
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   665
AllInactive:= false;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   666
if Gear.Timer mod 166 = 0 then inc(Gear.Tag);
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   667
if Gear.Timer = 0 then
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   668
   begin
46
c99140d2355a - Fixed dynamit sprite
unc0rr
parents: 43
diff changeset
   669
   doMakeExplosion(round(Gear.X), round(Gear.Y), 75, EXPLAutoSound);
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   670
   DeleteGear(Gear);
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   671
   exit
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   672
   end;
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   673
dec(Gear.Timer);
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   674
end;
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   675
15
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   676
////////////////////////////////////////////////////////////////////////////////
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   677
procedure doStepCase(Gear: PGear);
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   678
var i: integer;
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   679
begin
15
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   680
if (Gear.Message and gm_Destroy) > 0 then
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   681
   begin
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   682
   DeleteGear(Gear);
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   683
   exit
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   684
   end;
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   685
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   686
if Gear.Damage > 0 then
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   687
   begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   688
   DeleteGear(Gear);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   689
   doMakeExplosion(round(Gear.X), round(Gear.Y), 25, EXPLAutoSound);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   690
   for i:= 0 to 63 do
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   691
       AddGear(round(Gear.X), round(Gear.Y), gtFlame, 0);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   692
   exit
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   693
   end;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   694
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   695
if (Gear.dY <> 0) or (not TestCollisionYwithGear(Gear, 1)) then
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   696
   begin
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   697
   AllInactive:= false;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   698
   Gear.dY:= Gear.dY + cGravity;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   699
   Gear.Y:= Gear.Y + Gear.dY;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   700
   if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0 else
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   701
   if (Gear.dY >= 0) and TestCollisionYwithGear(Gear, 1) then
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   702
      begin
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   703
      Gear.dY:= - Gear.dY * Gear.Elasticity;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   704
      if Gear.dY > - 0.001 then Gear.dY:= 0
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   705
         else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact);
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   706
      end;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   707
   CheckGearDrowning(Gear);
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   708
   end;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   709
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   710
if (Gear.CollIndex = High(Longword)) and (Gear.dY = 0) then AddGearCI(Gear)
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   711
   else if (Gear.CollIndex < High(Longword)) and (Gear.dY <> 0) then DeleteCI(Gear);
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   712
end;
49
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   713
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   714
////////////////////////////////////////////////////////////////////////////////
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   715
var thexchar: array[0..5] of record
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   716
                             oy, ny: integer;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   717
                             team: PTeam;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   718
                             end;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   719
    thexchcnt: Longword;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   720
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   721
procedure doStepTeamHealthSorterWork(Gear: PGear);
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   722
var i: integer;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   723
begin
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   724
AllInactive:= false;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   725
dec(Gear.Timer);
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   726
if (Gear.Timer and 15) = 0 then
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   727
   for i:= 0 to Pred(thexchcnt) do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   728
       with thexchar[i] do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   729
            {$WARNINGS OFF}
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   730
            team.DrawHealthY:= ny + (oy - ny) * Gear.Timer div 640;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   731
            {$WARNINGS ON}
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   732
if Gear.Timer = 0 then
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   733
   DeleteGear(Gear)
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   734
end;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   735
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   736
procedure doStepTeamHealthSorter(Gear: PGear);
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   737
var team: PTeam;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   738
    i, t: Longword;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   739
begin
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   740
AllInactive:= false;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   741
team:= TeamsList;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   742
i:= 0;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   743
while team <> nil do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   744
      begin
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   745
      thexchar[i].oy:= team.DrawHealthY;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   746
      thexchar[i].team:= team;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   747
      inc(i);
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   748
      team:= team.Next
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   749
      end;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   750
thexchcnt:= i;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   751
for i:= 1 to thexchcnt do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   752
    for t:= 0 to thexchcnt - 2 do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   753
        if thexchar[t].team.TeamHealth > thexchar[Succ(t)].team.TeamHealth then
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   754
           begin
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   755
           thexchar[5]:= thexchar[t];
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   756
           thexchar[t]:= thexchar[Succ(t)];
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   757
           thexchar[Succ(t)]:= thexchar[5]
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   758
           end;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   759
t:= cScreenHeight - 4;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   760
for i:= 0 to Pred(thexchcnt) do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   761
    with thexchar[i] do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   762
         begin
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   763
         dec(t, team.HealthRect.h + 2);
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   764
         ny:= t
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   765
         end;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   766
Gear.Timer:= 640;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   767
Gear.doStep:= doStepTeamHealthSorterWork
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   768
end;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   769
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   770
////////////////////////////////////////////////////////////////////////////////
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   771
procedure doStepShover(Gear: PGear);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   772
var HHGear: PGear;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   773
begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   774
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   775
HHGear.State:= HHGear.State or gstNoDamage;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   776
AmmoShove(Gear, 30, 115);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   777
HHGear.State:= HHGear.State and not gstNoDamage;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   778
DeleteGear(Gear)
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   779
end;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   780
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   781
////////////////////////////////////////////////////////////////////////////////
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   782
procedure doStepFlame(Gear: PGear);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   783
begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   784
AllInactive:= false;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   785
if not TestCollisionYwithGear(Gear, 1) then
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   786
   begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   787
   Gear.dX:= Gear.dX + cWindSpeed;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   788
   Gear.dY:= Gear.dY + cGravity;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   789
   if abs(Gear.dX) > 0.12 then Gear.dX:= Gear.dX * 0.5;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   790
   if Gear.dY > 0.12 then Gear.dY:= Gear.dY * 0.995;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   791
   Gear.X:= Gear.X + Gear.dX;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   792
   Gear.Y:= Gear.Y + Gear.dY;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   793
   if Gear.Y > 1023 then
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   794
      begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   795
      DeleteGear(Gear);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   796
      exit
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   797
      end
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   798
   end else begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   799
   if Gear.Timer > 0 then dec(Gear.Timer)
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   800
      else begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   801
      doMakeExplosion(round(Gear.X), round(Gear.Y), 2, 0);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   802
      dec(Gear.Health);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   803
      Gear.Timer:= 1250 - Gear.Angle * 12
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   804
      end
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   805
   end;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   806
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   807
if (((GameTicks div 8) mod 64) = Gear.Angle) then
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   808
   AmmoFlameWork(Gear);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   809
82
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   810
if Gear.Health = 0 then
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   811
   DeleteGear(Gear)
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   812
end;
82
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   813
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   814
////////////////////////////////////////////////////////////////////////////////
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   815
procedure doStepFirePunchWork(Gear: PGear);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   816
var HHGear: PGear;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   817
begin
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   818
AllInactive:= false;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   819
if ((Gear.Message and gm_Destroy) <> 0) then
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   820
   begin
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   821
   DeleteGear(Gear);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   822
   AfterAttack;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   823
   exit
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   824
   end;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   825
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   826
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   827
if round(HHGear.Y) <= Gear.Tag - 2 then
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   828
   begin
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   829
   Gear.Tag:= round(HHGear.Y);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   830
   DrawTunnel(HHGear.X - cHHRadius, HHGear.Y - 1, 0.5, 0.0, cHHRadius * 4, 2);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   831
   HHGear.State:= HHGear.State or gstNoDamage;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   832
   Gear.Y:= HHGear.Y;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   833
   AmmoShove(Gear, 30, 40);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   834
   HHGear.State:= HHGear.State and not gstNoDamage
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   835
   end;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   836
   
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   837
HHGear.dY:= HHGear.dY + cGravity;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   838
if HHGear.dY >= 0 then
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   839
   begin
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   840
   HHGear.State:= HHGear.State or gstFalling;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   841
   DeleteGear(Gear);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   842
   AfterAttack;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   843
   exit
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   844
   end;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   845
HHGear.Y:= HHGear.Y + HHGear.dY
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   846
end;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   847
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   848
procedure doStepFirePunch(Gear: PGear);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   849
var HHGear: PGear;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   850
begin
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   851
AllInactive:= false;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   852
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   853
HHGear.X:= round(HHGear.X) - 0.5;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   854
HHGear.dX:= 0.0000001 * Sign(HHGear.dX);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   855
HHGear.dY:= -0.30;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   856
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   857
Gear.X:= HHGear.X;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   858
Gear.dX:= Sign(HHGear.dX)* 0.45;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   859
Gear.dY:= -0.9;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   860
Gear.doStep:= doStepFirePunchWork;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   861
DrawTunnel(HHGear.X - cHHRadius, HHGear.Y + 1, 0.5, 0.0, cHHRadius * 4, 5);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   862
end;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   863
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   864