hedgewars/GSHandlers.inc
author unc0rr
Sun, 14 Jan 2007 21:51:17 +0000
changeset 337 a46abb65eb0c
parent 324 f4c109c82a0c
child 342 0a21586b3f1d
permissions -rw-r--r--
- Fix not debug build - Allow multiple debug engines running simultaneously (there were problems with debug.txt)
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
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 161
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
57c2ef19f719 Relicense to GPL
unc0rr
parents: 161
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
57c2ef19f719 Relicense to GPL
unc0rr
parents: 161
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     8
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 161
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
57c2ef19f719 Relicense to GPL
unc0rr
parents: 161
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57c2ef19f719 Relicense to GPL
unc0rr
parents: 161
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
57c2ef19f719 Relicense to GPL
unc0rr
parents: 161
diff changeset
    12
 * GNU General Public License for more details.
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    13
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 161
diff changeset
    14
 * You should have received a copy of the GNU General Public License
57c2ef19f719 Relicense to GPL
unc0rr
parents: 161
diff changeset
    15
 * along with this program; if not, write to the Free Software
57c2ef19f719 Relicense to GPL
unc0rr
parents: 161
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    17
 *)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    18
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    19
procedure doStepDrowningGear(Gear: PGear); forward;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    20
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    21
function CheckGearDrowning(Gear: PGear): boolean;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    22
begin
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
    23
Result:= Gear.Y + Gear.Radius >= cWaterLine;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    24
if Result then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    25
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    26
   Gear.State:= gstDrowning;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    27
   Gear.doStep:= doStepDrowningGear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    28
   PlaySound(sndSplash)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    29
   end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    30
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    31
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    32
procedure CheckCollision(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    33
begin
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
    34
if TestCollisionXwithGear(Gear, hwSign(Gear.X)) or TestCollisionYwithGear(Gear, hwSign(Gear.Y))
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    35
   then Gear.State:= Gear.State or      gstCollision
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    36
   else Gear.State:= Gear.State and not gstCollision
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    37
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    38
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    39
procedure CheckHHDamage(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    40
begin
71
5f56c6979496 - Changed falling damage scoring
unc0rr
parents: 70
diff changeset
    41
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
    42
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    43
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    44
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    45
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    46
procedure CalcRotationDirAngle(Gear: PGear);
107
b08ce0293a51 - Many type fixes
unc0rr
parents: 100
diff changeset
    47
var dAngle: Double;
4
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
dAngle:= (abs(Gear.dX) + abs(Gear.dY))*0.1;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    50
if Gear.dX >= 0 then Gear.DirAngle:= Gear.DirAngle + dAngle
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    51
                else Gear.DirAngle:= Gear.DirAngle - dAngle;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    52
if Gear.DirAngle < 0 then Gear.DirAngle:= Gear.DirAngle + 16
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    53
else if Gear.DirAngle >= 16 then Gear.DirAngle:= Gear.DirAngle - 16
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    54
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    55
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    56
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    57
procedure doStepDrowningGear(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    58
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    59
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    60
Gear.Y:= Gear.Y + cDrownSpeed;
75
d2b737858ff7 - New First Aid powerup
unc0rr
parents: 74
diff changeset
    61
if round(Gear.Y) > Gear.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    62
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    63
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    64
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    65
procedure doStepFallingGear(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    66
var b: boolean;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    67
begin
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
    68
if TestCollisionYwithGear(Gear, hwSign(Gear.dY)) then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    69
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    70
   Gear.dX:=   Gear.dX * Gear.Friction;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    71
   Gear.dY:= - Gear.dY * Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    72
   b:= false
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    73
   end else b:= true;
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
    74
if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    75
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    76
   Gear.dX:= - Gear.dX * Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    77
//   Gear.dY:=   Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    78
   b:= false
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    79
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    80
if b then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    81
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    82
   Gear.dY:= Gear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    83
   Gear.State:= Gear.State and not gstCollision
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    84
   end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    85
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    86
   if sqr(Gear.dX) + sqr(Gear.dY) < 0.00001 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    87
      if (Gear.Timer = 0) then Gear.Active:= false
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    88
                          else begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    89
                          Gear.dX:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    90
                          Gear.dY:= 0
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    91
                          end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    92
   Gear.State:= Gear.State or gstCollision
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    93
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    94
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    95
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    96
CheckGearDrowning(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    97
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
    98
                                         else Gear.State:= Gear.State or      gstMoving
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    99
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   100
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   101
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   102
procedure doStepCloud(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   103
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   104
Gear.X:= Gear.X + cWindSpeed * 200 + Gear.dX;
74
42257fee61ae - Unicode support for team and hedgehogs names
unc0rr
parents: 71
diff changeset
   105
if Gear.Y > -160 then Gear.dY:= Gear.dY - 0.00002
42257fee61ae - Unicode support for team and hedgehogs names
unc0rr
parents: 71
diff changeset
   106
                 else Gear.dY:= Gear.dY + 0.00002;
42257fee61ae - Unicode support for team and hedgehogs names
unc0rr
parents: 71
diff changeset
   107
Gear.Y:= Gear.Y + Gear.dY;
42257fee61ae - Unicode support for team and hedgehogs names
unc0rr
parents: 71
diff changeset
   108
if Gear.X < -cScreenWidth - 256 then Gear.X:= cScreenWidth + 2048 else
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   109
if Gear.X > cScreenWidth + 2048 then Gear.X:= -cScreenWidth - 256
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   110
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   111
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   112
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   113
procedure doStepBomb(Gear: PGear);
78
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   114
var i: integer;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   115
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   116
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   117
doStepFallingGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   118
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   119
if Gear.Timer = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   120
   begin
78
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   121
   case Gear.Kind of
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   122
        gtAmmo_Bomb: doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   123
      gtClusterBomb: begin
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   124
                     doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound);
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   125
                     for i:= 0 to 4 do
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   126
                         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
   127
                     end
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   128
        end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   129
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   130
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   131
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   132
CalcRotationDirAngle(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   133
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
   134
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   135
78
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   136
procedure doStepCluster(Gear: PGear);
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   137
begin
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   138
AllInactive:= false;
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   139
doStepFallingGear(Gear);
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   140
if (Gear.State and gstCollision) <> 0 then
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   141
   begin
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   142
   doMakeExplosion(round(Gear.X), round(Gear.Y), 20, EXPLAutoSound);
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   143
   DeleteGear(Gear);
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   144
   exit
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   145
   end;
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   146
if (GameTicks and $1F) = 0 then
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   147
   AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0)
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   148
end;
66bb79dd248d Cluster bomb
unc0rr
parents: 75
diff changeset
   149
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   150
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   151
procedure doStepGrenade(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   152
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   153
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   154
Gear.dX:= Gear.dX + cWindSpeed;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   155
doStepFallingGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   156
if (Gear.State and gstCollision) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   157
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   158
   doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   159
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   160
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   161
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   162
if (GameTicks and $3F) = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   163
   AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   164
end;
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
////////////////////////////////////////////////////////////////////////////////
95
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   167
procedure doStepHealthTagWork(Gear: PGear);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   168
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   169
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   170
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   171
Gear.Y:= Gear.Y - 0.07;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   172
if Gear.Timer = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   173
   begin
263
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   174
   PHedgehog(Gear.Hedgehog).Gear.Active:= true; // to let current hh die
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   175
   DeleteGear(Gear)
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
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   178
263
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   179
procedure doStepHealthTagWorkUnderWater(Gear: PGear);
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   180
begin
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   181
AllInactive:= false;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   182
Gear.Y:= Gear.Y - 0.07;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   183
if Gear.Y <= cWaterLine + 10 then
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   184
   DeleteGear(Gear)
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   185
end;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   186
95
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   187
procedure doStepHealthTag(Gear: PGear);
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   188
var s: shortstring;
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   189
begin
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   190
AllInactive:= false;
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   191
str(Gear.State, s);
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   192
Gear.Surf:= RenderString(s, PHedgehog(Gear.Hedgehog).Team.Color, fnt16);
263
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   193
if Gear.Y < cWaterLine then Gear.doStep:= doStepHealthTagWork
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   194
                       else Gear.doStep:= doStepHealthTagWorkUnderWater
95
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   195
end;
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   196
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   197
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   198
procedure doStepGrave(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   199
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   200
AllInactive:= false;
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 Gear.dY:= 0;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   203
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   204
if Gear.dY >=0 then
68
cbb93eb90304 Collision-related stuff
unc0rr
parents: 57
diff changeset
   205
   if TestCollisionY(Gear, 1) then
4
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.dY:= - Gear.dY * Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   208
      if Gear.dY > - 0.001 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   209
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   210
         Gear.Active:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   211
         exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   212
         end else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   213
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   214
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   215
CheckGearDrowning(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   216
Gear.dY:= Gear.dY + cGravity
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   217
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   218
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   219
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   220
procedure doStepUFOWork(Gear: PGear);
107
b08ce0293a51 - Many type fixes
unc0rr
parents: 100
diff changeset
   221
var t: Double;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   222
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   223
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   224
t:= sqrt(sqr(Gear.dX) + sqr(Gear.dY));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   225
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
   226
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
   227
t:= t / (sqrt(sqr(Gear.dX) + sqr(Gear.dY)));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   228
Gear.dX:= Gear.dX * t;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   229
Gear.dY:= Gear.dY * t;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   230
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   231
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   232
CheckCollision(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   233
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   234
if ((Gear.State and gstCollision) <> 0) or (Gear.Timer = 0) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   235
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   236
   doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   237
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   238
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   239
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   240
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   241
procedure doStepUFO(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   242
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   243
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   244
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   245
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   246
Gear.dY:= Gear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   247
CheckCollision(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   248
if (Gear.State and gstCollision) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   249
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   250
   doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   251
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   252
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   253
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   254
dec(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   255
if Gear.Timer = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   256
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   257
   Gear.Timer:= 5000;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   258
   Gear.doStep:= doStepUFOWork
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   259
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   260
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   261
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   262
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   263
procedure doStepShotgunShot(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   264
var i: LongWord;
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
AllInactive:= false;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   267
if Gear.Timer > 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   268
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   269
   dec(Gear.Timer);
95
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   270
   if Gear.Timer = 0 then PlaySound(sndShotgunFire);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   271
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   272
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   273
i:= 200;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   274
repeat
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   275
Gear.X:= Gear.X + Gear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   276
Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   277
CheckCollision(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   278
if (Gear.State and gstCollision) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   279
   begin
75
d2b737858ff7 - New First Aid powerup
unc0rr
parents: 74
diff changeset
   280
   AmmoShove(Gear, 25, 25);
42
72ffe21f027c - Fixed console behavior
unc0rr
parents: 39
diff changeset
   281
   doMakeExplosion(round(Gear.X), round(Gear.Y), 25, EXPLNoDamage or EXPLDoNotTouchHH);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   282
   DeleteGear(Gear);
75
d2b737858ff7 - New First Aid powerup
unc0rr
parents: 74
diff changeset
   283
   AfterAttack;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   284
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   285
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   286
dec(i)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   287
until i = 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   288
if (Gear.X < 0) or (Gear.Y < 0) or (Gear.X > 2048) or (Gear.Y > 1024) then
95
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   289
   begin
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   290
   DeleteGear(Gear);
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   291
   AfterAttack
1ef5e2c41115 - Fixed compilation
unc0rr
parents: 89
diff changeset
   292
   end
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   293
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   294
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   295
////////////////////////////////////////////////////////////////////////////////
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   296
procedure doStepDEagleShot(Gear: PGear);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   297
var i, x, y: LongWord;
107
b08ce0293a51 - Many type fixes
unc0rr
parents: 100
diff changeset
   298
    oX, oY: Double;
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   299
begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   300
AllInactive:= false;
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   301
i:= 80;
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   302
oX:= Gear.X;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   303
oY:= Gear.Y;
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   304
repeat
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   305
  Gear.X:= Gear.X + Gear.dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   306
  Gear.Y:= Gear.Y + Gear.dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   307
  x:= round(Gear.X);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   308
  y:= round(Gear.Y);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   309
  if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0)
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   310
     and (Land[y, x] <> 0) then inc(Gear.Damage);
75
d2b737858ff7 - New First Aid powerup
unc0rr
parents: 74
diff changeset
   311
  AmmoShove(Gear, 7, 20);
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   312
  dec(i)
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   313
until (i = 0) or (Gear.Damage > Gear.Health);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   314
if Gear.Damage > 0 then
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   315
   begin
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   316
   DrawTunnel(oX, oY, Gear.dX, Gear.dY, 82 - i, 1);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   317
   dec(Gear.Health, Gear.Damage);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   318
   Gear.Damage:= 0
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   319
   end;
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   320
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
   321
   DeleteGear(Gear)
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   322
end;
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   323
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   324
////////////////////////////////////////////////////////////////////////////////
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   325
procedure doStepActionTimer(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   326
begin
83
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   327
dec(Gear.Timer);
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   328
case Gear.Kind of
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   329
    gtATStartGame: begin
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   330
                   AllInactive:= false;
83
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   331
                   if Gear.Timer = 0 then
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   332
                      AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   333
                   end;
83
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   334
 gtATSmoothWindCh: begin
6
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   335
                   if Gear.Timer = 0 then
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   336
                      begin
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   337
                      if WindBarWidth < Gear.Tag then inc(WindBarWidth)
83
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   338
                         else if WindBarWidth > Gear.Tag then dec(WindBarWidth);
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   339
                      if WindBarWidth <> Gear.Tag then Gear.Timer:= 10;
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   340
                      end
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   341
                   end;
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   342
   gtATFinishGame: begin
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   343
                   AllInactive:= false;
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   344
                   if Gear.Timer = 0 then
113
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
   345
                      begin
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
   346
                      SendIPC('N');
324
f4c109c82a0c Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents: 306
diff changeset
   347
                      SendIPC('q');
83
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   348
                      GameState:= gsExit
113
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
   349
                      end
6
9c1f00e7b43e Smooth change wind bar
unc0rr
parents: 4
diff changeset
   350
                   end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   351
     end;
83
207c85fbef51 - First hedgehog in team has first turn in team
unc0rr
parents: 82
diff changeset
   352
if Gear.Timer = 0 then DeleteGear(Gear)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   353
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   354
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   355
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   356
procedure doStepPickHammerWork(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   357
var i, ei: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   358
    HHGear: PGear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   359
begin
70
82d93eeecebe - Many AI improvements
unc0rr
parents: 68
diff changeset
   360
AllInactive:= false;
161
d8870bbf960e - AmmoMenu
unc0rr
parents: 146
diff changeset
   361
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   362
dec(Gear.Timer);
161
d8870bbf960e - AmmoMenu
unc0rr
parents: 146
diff changeset
   363
if (Gear.Timer = 0)or((Gear.Message and gm_Destroy) <> 0)or((HHGear.State and gstHHDriven) = 0) then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   364
   begin
282
b1e3387389b6 - Pickhammer sound
unc0rr
parents: 263
diff changeset
   365
   StopSound(sndPickhammer);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   366
   DeleteGear(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   367
   AfterAttack;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   368
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   369
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   370
if (Gear.Timer and $3F) = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   371
   begin
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   372
   i:= round(Gear.X) - Gear.Radius  - GetRandom(2);
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   373
   ei:= round(Gear.X) + Gear.Radius + GetRandom(2);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   374
   while i <= ei do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   375
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   376
         doMakeExplosion(i, round(Gear.Y) + 3, 3, 0);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   377
         inc(i, 1)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   378
         end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   379
   Gear.X:= Gear.X + Gear.dX;
42
72ffe21f027c - Fixed console behavior
unc0rr
parents: 39
diff changeset
   380
   Gear.Y:= Gear.Y + 1.9;
72ffe21f027c - Fixed console behavior
unc0rr
parents: 39
diff changeset
   381
   SetAllHHToActive;
4
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
if TestCollisionYwithGear(Gear, 1) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   384
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   385
   Gear.dY:= 0;
300
be94799f33d2 Simplify hedgehogs physics code, make it better
unc0rr
parents: 285
diff changeset
   386
   SetLittle(HHGear.dX);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   387
   HHGear.dY:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   388
   end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   389
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   390
   Gear.dY:= Gear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   391
   Gear.Y:= Gear.Y + Gear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   392
   if Gear.Y > 1024 then Gear.Timer:= 1
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   393
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   394
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   395
Gear.X:= Gear.X + HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   396
HHGear.X:= Gear.X;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   397
HHGear.Y:= Gear.Y - cHHRadius;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   398
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   399
if (Gear.Message and gm_Attack) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   400
   if (Gear.State and gsttmpFlag) <> 0 then Gear.Timer:= 1 else else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   401
   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
   402
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
   403
   if ((Gear.Message and gm_Right) <> 0) then Gear.dX:= 0.3
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   404
                                         else Gear.dX:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   405
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   406
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   407
procedure doStepPickHammer(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   408
var i, y: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   409
    ar: TRangeArray;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   410
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   411
i:= 0;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   412
y:= round(Gear.Y) - cHHRadius*2;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   413
while y < round(Gear.Y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   414
   begin
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   415
   ar[i].Left := round(Gear.X) - Gear.Radius - GetRandom(2);
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   416
   ar[i].Right:= round(Gear.X) + Gear.Radius + GetRandom(2);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   417
   inc(y, 2);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   418
   inc(i)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   419
   end;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   420
DrawHLinesExplosions(@ar, 3, round(Gear.Y) - cHHRadius*2, 2, Pred(i));
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   421
Gear.dY:= PHedgehog(Gear.Hedgehog).Gear.dY;
282
b1e3387389b6 - Pickhammer sound
unc0rr
parents: 263
diff changeset
   422
PlaySound(sndPickhammer, true);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   423
doStepPickHammerWork(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   424
Gear.doStep:= doStepPickHammerWork
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   425
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   426
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   427
////////////////////////////////////////////////////////////////////////////////
305
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   428
var BTPrevAngle, BTSteps: Longword;
302
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   429
303
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   430
procedure doStepBlowTorchWork(Gear: PGear);
302
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   431
var HHGear: PGear;
305
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   432
    b: boolean;
302
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   433
begin
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   434
AllInactive:= false;
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   435
dec(Gear.Timer);
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   436
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
303
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   437
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   438
HedgehogChAngle(HHGear);
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   439
305
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   440
b:= false;
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   441
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   442
if (HHGear.Angle <> BTPrevAngle) then
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   443
   begin
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   444
   Gear.dX:= hwSign(HHGear.dX) * Sin(HHGear.Angle * pi / cMaxAngle) * 0.5;
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   445
   Gear.dY:= Cos(HHGear.Angle * pi / cMaxAngle) * (-0.5);
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   446
   BTPrevAngle:= HHGear.Angle;
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   447
   b:= true
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   448
   end;
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   449
302
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   450
if Gear.Timer mod cHHStepTicks = 0 then
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   451
   begin
305
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   452
   b:= true;
303
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   453
   if Gear.dX < 0 then HHGear.Message:= (HHGear.Message or gm_Left) and not gm_Right
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   454
                  else HHGear.Message:= (HHGear.Message or gm_Right) and not gm_Left;
302
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   455
   HedgehogStep(HHGear);
305
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   456
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   457
   inc(BTSteps);
306
7b61834edcf6 - Better blowtorch
unc0rr
parents: 305
diff changeset
   458
   if BTSteps = 11 then
305
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   459
      begin
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   460
      BTSteps:= 0;
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   461
      Gear.X:= HHGear.X + Gear.dX * cHHRadius * 2;
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   462
      Gear.Y:= HHGear.Y + Gear.dY * cHHRadius * 2;
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   463
      HHGear.State:= HHGear.State or gstNoDamage;
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   464
      AmmoShove(Gear, 3, 14);
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   465
      HHGear.State:= HHGear.State and not gstNoDamage
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   466
      end;
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   467
302
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   468
   if (HHGear.State and gstFalling) <> 0 then Gear.Timer:= 0
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   469
   end;
305
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   470
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   471
if b then
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   472
   DrawTunnel(HHGear.X - Gear.dX * cHHRadius, HHGear.Y - 4 - Gear.dY * cHHRadius + abs(Gear.dY) * 7,
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   473
              Gear.dX, Gear.dY,
306
7b61834edcf6 - Better blowtorch
unc0rr
parents: 305
diff changeset
   474
              cHHRadius * 5, cHHRadius * 2 + 6);
305
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   475
304
8096e69e839e Attack angle constraints
unc0rr
parents: 303
diff changeset
   476
if (Gear.Timer = 0) or ((HHGear.Message and gm_Attack) <> 0) then
302
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   477
   begin
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   478
   HHGear.Message:= 0;
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   479
   DeleteGear(Gear);
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   480
   AfterAttack
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   481
   end
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   482
end;
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   483
303
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   484
procedure doStepBlowTorch(Gear: PGear);
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   485
var HHGear: PGear;
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   486
begin
305
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   487
BTPrevAngle:= High(Longword);
1c1cd66ffcdc Better blowtorch
unc0rr
parents: 304
diff changeset
   488
BTSteps:= 0;
303
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   489
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   490
HHGear.State:= HHGear.State and not gstAttacking;
304
8096e69e839e Attack angle constraints
unc0rr
parents: 303
diff changeset
   491
HHGear.Message:= 0;
303
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   492
Gear.doStep:= doStepBlowTorchWork
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   493
end;
1659c4aad5ab Now blow torch angle can be changed during blowing :)
unc0rr
parents: 302
diff changeset
   494
302
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   495
////////////////////////////////////////////////////////////////////////////////
7aca131ecd7f First implementation of Blow Torch
unc0rr
parents: 300
diff changeset
   496
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   497
procedure doStepRopeWork(Gear: PGear);
70
82d93eeecebe - Many AI improvements
unc0rr
parents: 68
diff changeset
   498
const flCheck: boolean = false;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   499
var HHGear: PGear;
107
b08ce0293a51 - Many type fixes
unc0rr
parents: 100
diff changeset
   500
    len, cs, cc, tx, ty: Double;
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   501
    lx, ly: LongInt;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   502
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   503
    procedure DeleteMe;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   504
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   505
      with HHGear^ do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   506
           begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   507
           Message:= Message and not gm_Attack;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   508
           State:= State or gstFalling;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   509
           end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   510
      DeleteGear(Gear);
113
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
   511
      OnUsedAmmo(PHedgehog(HHGear.Hedgehog)^.Ammo);
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
   512
      ApplyAmmoChanges(PHedgehog(HHGear.Hedgehog)^)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   513
    end;
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
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   516
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   517
80
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 79
diff changeset
   518
if ((HHGear.State and gstHHDriven) = 0)
3c3dc6a148ca - Fixed bug with hedgehog under water using rope
unc0rr
parents: 79
diff changeset
   519
   or (CheckGearDrowning(HHGear)) then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   520
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   521
   DeleteMe;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   522
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   523
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   524
Gear.dX:= HHGear.X - Gear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   525
Gear.dY:= HHGear.Y - Gear.Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   526
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   527
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
   528
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
   529
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   530
if not TestCollisionYwithGear(HHGear, 1) then HHGear.dY:= HHGear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   531
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   532
cs:= Gear.dY + HHGear.dY;
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   533
cc:= Gear.dX + HHGear.dX;
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   534
len:= 1 / sqrt(sqr(cc)+sqr(cs));
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   535
cc:= cc * len;
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   536
cs:= cs * len;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   537
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   538
flCheck:= not flCheck;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   539
if flCheck then  // check whether rope needs dividing
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   540
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   541
   len:= Gear.Elasticity - 20;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   542
   while len > 5 do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   543
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   544
         tx:= cc*len;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   545
         ty:= cs*len;
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   546
         lx:= round(Gear.X + tx) + hwSign(HHGear.dX);
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   547
         ly:= round(Gear.Y + ty) + hwSign(HHGear.dY);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   548
         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
   549
           begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   550
           with RopePoints.ar[RopePoints.Count] do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   551
                begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   552
                X:= Gear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   553
                Y:= Gear.Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   554
                if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle32(Gear.dY, Gear.dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   555
                b:= (cc * HHGear.dY) > (cs * HHGear.dX);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   556
                dLen:= len
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   557
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   558
           Gear.X:= Gear.X + tx;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   559
           Gear.Y:= Gear.Y + ty;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   560
           inc(RopePoints.Count);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   561
           Gear.Elasticity:= Gear.Elasticity - len;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   562
           Gear.Friction:= Gear.Friction - len;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   563
           break
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   564
           end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   565
         len:= len - 3
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   566
         end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   567
   end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   568
   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
   569
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   570
      tx:= RopePoints.ar[Pred(RopePoints.Count)].X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   571
      ty:= RopePoints.ar[Pred(RopePoints.Count)].Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   572
      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
   573
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   574
         dec(RopePoints.Count);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   575
         Gear.X:=RopePoints.ar[RopePoints.Count].X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   576
         Gear.Y:=RopePoints.ar[RopePoints.Count].Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   577
         Gear.Elasticity:= Gear.Elasticity + RopePoints.ar[RopePoints.Count].dLen;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   578
         Gear.Friction:= Gear.Friction + RopePoints.ar[RopePoints.Count].dLen
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   579
         end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   580
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   581
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   582
Gear.dX:= HHGear.X - Gear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   583
Gear.dY:= HHGear.Y - Gear.Y;
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   584
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   585
cs:= Gear.dY + HHGear.dY;
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   586
cc:= Gear.dX + HHGear.dX;
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   587
len:= 1 / sqrt(sqr(cc)+sqr(cs));
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   588
cc:= cc * len;
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   589
cs:= cs * len;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   590
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   591
HHGear.dX:= HHGear.X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   592
HHGear.dY:= HHGear.Y;
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
if ((Gear.Message and gm_Down) <> 0) and (Gear.Elasticity < Gear.Friction) then
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   595
   if not (TestCollisionXwithGear(HHGear, hwSign(Gear.dX))
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   596
        or TestCollisionYwithGear(HHGear, hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity + 0.3;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   597
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   598
if ((Gear.Message and gm_Up) <> 0) and (Gear.Elasticity > 30) then
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   599
   if not (TestCollisionXwithGear(HHGear, -hwSign(Gear.dX))
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   600
        or TestCollisionYwithGear(HHGear, -hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity - 0.3;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   601
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   602
HHGear.X:= Gear.X + cc*Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   603
HHGear.Y:= Gear.Y + cs*Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   604
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   605
HHGear.dX:= HHGear.X - HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   606
HHGear.dY:= HHGear.Y - HHGear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   607
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   608
if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then
75
d2b737858ff7 - New First Aid powerup
unc0rr
parents: 74
diff changeset
   609
   HHGear.dX:= -0.6 * HHGear.dX;
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   610
if TestCollisionYwithGear(HHGear, hwSign(HHGear.dY)) then
75
d2b737858ff7 - New First Aid powerup
unc0rr
parents: 74
diff changeset
   611
   HHGear.dY:= -0.6 * HHGear.dY;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   612
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   613
if (Gear.Message and gm_Attack) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   614
   if (Gear.State and gsttmpFlag) <> 0 then DeleteMe else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   615
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
   616
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   617
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   618
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   619
procedure doStepRopeAttach(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   620
var HHGear: PGear;
107
b08ce0293a51 - Many type fixes
unc0rr
parents: 100
diff changeset
   621
    tx, ty, tt: Double;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   622
begin
113
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
   623
Gear.X:= Gear.X - Gear.dX;
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
   624
Gear.Y:= Gear.Y - Gear.dY;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   625
Gear.Elasticity:= Gear.Elasticity + 1.0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   626
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   627
if (HHGear.State and gstFalling) <> 0 then
68
cbb93eb90304 Collision-related stuff
unc0rr
parents: 57
diff changeset
   628
   if TestCollisionYwithGear(HHGear, 1) then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   629
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   630
      HHGear.dY:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   631
      CheckHHDamage(HHGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   632
      HHGear.State:= HHGear.State and not (gstFalling or gstHHJumping);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   633
      end else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   634
      begin
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   635
      if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then HHGear.dX:= 0.0000001 * hwSign(HHGear.dX);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   636
      HHGear.X:= HHGear.X + HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   637
      HHGear.Y:= HHGear.Y + HHGear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   638
      Gear.X:= Gear.X + HHGear.dX;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   639
      Gear.Y:= Gear.Y + HHGear.dY;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   640
      HHGear.dY:= HHGear.dY + cGravity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   641
      tt:= Gear.Elasticity;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   642
      tx:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   643
      ty:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   644
      while tt > 20 do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   645
            begin
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   646
            if  TestCollisionXwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dX))
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   647
             or TestCollisionYwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dY)) then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   648
                begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   649
                Gear.X:= Gear.X + tx;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   650
                Gear.Y:= Gear.Y + ty;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   651
                Gear.Elasticity:= tt;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   652
                Gear.doStep:= doStepRopeWork;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   653
                with HHGear^ do State:= State and not gstAttacking;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   654
                tt:= 0
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   655
                end;
113
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
   656
            tx:= tx + Gear.dX - Gear.dX;
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
   657
            ty:= ty + Gear.dY - Gear.dY;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   658
            tt:= tt - 2.0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   659
            end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   660
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   661
CheckCollision(Gear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   662
if (Gear.State and gstCollision) <> 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   663
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   664
   Gear.doStep:= doStepRopeWork;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   665
   with HHGear^ do State:= State and not gstAttacking;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   666
   if Gear.Elasticity < 10 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   667
      Gear.Elasticity:= 10000;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   668
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   669
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   670
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
   671
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   672
   with PHedgehog(Gear.Hedgehog).Gear^ do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   673
        begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   674
        State:= State and not gstAttacking;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   675
        Message:= Message and not gm_Attack
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   676
        end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   677
   DeleteGear(Gear)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   678
   end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   679
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   680
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   681
procedure doStepRope(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   682
begin
113
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
   683
Gear.dX:= - Gear.dX;
d975a426ebf7 - Many small fixes in engine
unc0rr
parents: 109
diff changeset
   684
Gear.dY:= - Gear.dY;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   685
Gear.doStep:= doStepRopeAttach
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   686
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   687
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   688
////////////////////////////////////////////////////////////////////////////////
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   689
procedure doStepSmokeTrace(Gear: PGear);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   690
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   691
inc(Gear.Timer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   692
if Gear.Timer > 64 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   693
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   694
   Gear.Timer:= 0;
9
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   695
   dec(Gear.State)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   696
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   697
Gear.dX:= Gear.dX + cWindSpeed;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   698
Gear.X:= Gear.X + Gear.dX;
9
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   699
if Gear.State = 0 then DeleteGear(Gear)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   700
end;
9
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   701
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   702
////////////////////////////////////////////////////////////////////////////////
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   703
procedure doStepExplosion(Gear: PGear);
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   704
begin
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   705
inc(Gear.Timer);
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   706
if Gear.Timer > 75 then
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   707
   begin
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   708
   inc(Gear.State);
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   709
   Gear.Timer:= 0;
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   710
   if Gear.State > 5 then DeleteGear(Gear)
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   711
   end;
4cbf854ad095 - Show explosion
unc0rr
parents: 6
diff changeset
   712
end;
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   713
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   714
////////////////////////////////////////////////////////////////////////////////
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   715
procedure doStepMine(Gear: PGear);
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   716
begin
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   717
if (Gear.dX <> 0) or (Gear.dY <> 0) then
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   718
   begin
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   719
   if Gear.CollIndex < High(Longword) then DeleteCI(Gear);
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   720
   doStepFallingGear(Gear);
13
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   721
   if Gear.Active = false then
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   722
      begin
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   723
      if Gear.CollIndex = High(Longword) then AddGearCI(Gear);
13
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   724
      Gear.dX:= 0;
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   725
      Gear.dY:= 0
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   726
      end;
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   727
   CalcRotationDirAngle(Gear);
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   728
   AllInactive:= false
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   729
   end;
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   730
   
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   731
if ((Gear.State and gsttmpFlag) <> 0) then
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   732
   if ((Gear.State and gstAttacking) = 0) then
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   733
      begin
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   734
      if ((GameTicks and $F) = 0) then
15
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   735
         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
   736
      end else // gstAttacking <> 0
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   737
      begin
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   738
      AllInactive:= false;
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 23
diff changeset
   739
      if (Gear.Timer and $FF) = 0 then PlaySound(sndMineTick);
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   740
      if Gear.Timer = 0 then
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   741
         begin
13
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   742
         doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   743
         DeleteGear(Gear)
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   744
         end;
13
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   745
      dec(Gear.Timer);
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   746
      end else // gsttmpFlag = 0
7a5db822fd3f - Show no crosshair when using mine
unc0rr
parents: 10
diff changeset
   747
   if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag;
10
edf56dca1587 - Mine weapon
unc0rr
parents: 9
diff changeset
   748
end;
57
e1a77ae57065 - Fixed compiling .)
unc0rr
parents: 53
diff changeset
   749
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   750
////////////////////////////////////////////////////////////////////////////////
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   751
procedure doStepDynamite(Gear: PGear);
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   752
begin
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   753
doStepFallingGear(Gear);
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   754
AllInactive:= false;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   755
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
   756
if Gear.Timer = 0 then
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   757
   begin
46
c99140d2355a - Fixed dynamit sprite
unc0rr
parents: 43
diff changeset
   758
   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
   759
   DeleteGear(Gear);
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   760
   exit
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   761
   end;
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   762
dec(Gear.Timer);
39
b78e7185ed13 - Increased FPS
unc0rr
parents: 38
diff changeset
   763
end;
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   764
15
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   765
////////////////////////////////////////////////////////////////////////////////
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   766
procedure doStepCase(Gear: PGear);
89
f9db56409a86 - Fix various bugs
unc0rr
parents: 83
diff changeset
   767
var i, x, y: integer;
14
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   768
begin
15
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   769
if (Gear.Message and gm_Destroy) > 0 then
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   770
   begin
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   771
   DeleteGear(Gear);
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   772
   exit
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   773
   end;
6200cca92480 - Minor code simplifying
unc0rr
parents: 14
diff changeset
   774
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   775
if Gear.Damage > 0 then
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   776
   begin
89
f9db56409a86 - Fix various bugs
unc0rr
parents: 83
diff changeset
   777
   x:= round(Gear.X);
f9db56409a86 - Fix various bugs
unc0rr
parents: 83
diff changeset
   778
   y:= round(Gear.Y);
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   779
   DeleteGear(Gear);
89
f9db56409a86 - Fix various bugs
unc0rr
parents: 83
diff changeset
   780
   doMakeExplosion(x, y, 25, EXPLAutoSound);
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   781
   for i:= 0 to 63 do
89
f9db56409a86 - Fix various bugs
unc0rr
parents: 83
diff changeset
   782
       AddGear(x, y, gtFlame, 0);
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   783
   exit
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   784
   end;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   785
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   786
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
   787
   begin
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   788
   AllInactive:= false;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   789
   Gear.dY:= Gear.dY + cGravity;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   790
   Gear.Y:= Gear.Y + Gear.dY;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   791
   if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0 else
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   792
   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
   793
      begin
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   794
      Gear.dY:= - Gear.dY * Gear.Elasticity;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   795
      if Gear.dY > - 0.001 then Gear.dY:= 0
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   796
         else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact);
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   797
      end;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   798
   CheckGearDrowning(Gear);
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   799
   end;
81f125629b25 - Mine checks whether a hedgehog is near less frequently
unc0rr
parents: 13
diff changeset
   800
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   801
if (Gear.CollIndex = High(Longword)) and (Gear.dY = 0) then AddGearCI(Gear)
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 49
diff changeset
   802
   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
   803
end;
49
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   804
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   805
////////////////////////////////////////////////////////////////////////////////
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   806
var thexchar: array[0..5] of record
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   807
                             oy, ny: integer;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   808
                             team: PTeam;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   809
                             end;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   810
    thexchcnt: Longword;
143
3dacbd83209b - Many fixes to AI
unc0rr
parents: 113
diff changeset
   811
    currsorter: PGear;
49
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   812
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   813
procedure doStepTeamHealthSorterWork(Gear: PGear);
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   814
var i: integer;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   815
begin
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   816
AllInactive:= false;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   817
dec(Gear.Timer);
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   818
if (Gear.Timer and 15) = 0 then
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   819
   for i:= 0 to Pred(thexchcnt) do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   820
       with thexchar[i] do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   821
            {$WARNINGS OFF}
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   822
            team.DrawHealthY:= ny + (oy - ny) * Gear.Timer div 640;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   823
            {$WARNINGS ON}
143
3dacbd83209b - Many fixes to AI
unc0rr
parents: 113
diff changeset
   824
if (Gear.Timer = 0) or (currsorter <> Gear) then
3dacbd83209b - Many fixes to AI
unc0rr
parents: 113
diff changeset
   825
   begin
3dacbd83209b - Many fixes to AI
unc0rr
parents: 113
diff changeset
   826
   if currsorter = Gear then currsorter:= nil;
49
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   827
   DeleteGear(Gear)
143
3dacbd83209b - Many fixes to AI
unc0rr
parents: 113
diff changeset
   828
   end
49
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   829
end;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   830
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   831
procedure doStepTeamHealthSorter(Gear: PGear);
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   832
var team: PTeam;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   833
    i, t: Longword;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   834
begin
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   835
AllInactive:= false;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   836
team:= TeamsList;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   837
i:= 0;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   838
while team <> nil do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   839
      begin
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   840
      thexchar[i].oy:= team.DrawHealthY;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   841
      thexchar[i].team:= team;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   842
      inc(i);
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   843
      team:= team.Next
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   844
      end;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   845
thexchcnt:= i;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   846
for i:= 1 to thexchcnt do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   847
    for t:= 0 to thexchcnt - 2 do
146
458f4f58c1b6 - Fix AI not to damage self hedgehogs
unc0rr
parents: 143
diff changeset
   848
        if thexchar[t].team.TeamHealthBarWidth > thexchar[Succ(t)].team.TeamHealthBarWidth then
49
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   849
           begin
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   850
           thexchar[5]:= thexchar[t];
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   851
           thexchar[t]:= thexchar[Succ(t)];
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   852
           thexchar[Succ(t)]:= thexchar[5]
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   853
           end;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   854
t:= cScreenHeight - 4;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   855
for i:= 0 to Pred(thexchcnt) do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   856
    with thexchar[i] do
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   857
         begin
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   858
         dec(t, team.HealthRect.h + 2);
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   859
         ny:= t
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   860
         end;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   861
Gear.Timer:= 640;
143
3dacbd83209b - Many fixes to AI
unc0rr
parents: 113
diff changeset
   862
Gear.doStep:= doStepTeamHealthSorterWork;
3dacbd83209b - Many fixes to AI
unc0rr
parents: 113
diff changeset
   863
currsorter:= Gear
49
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   864
end;
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 46
diff changeset
   865
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   866
////////////////////////////////////////////////////////////////////////////////
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   867
procedure doStepShover(Gear: PGear);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   868
var HHGear: PGear;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   869
begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   870
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   871
HHGear.State:= HHGear.State or gstNoDamage;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   872
AmmoShove(Gear, 30, 115);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   873
HHGear.State:= HHGear.State and not gstNoDamage;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   874
DeleteGear(Gear)
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   875
end;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   876
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   877
////////////////////////////////////////////////////////////////////////////////
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   878
procedure doStepFlame(Gear: PGear);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   879
begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   880
AllInactive:= false;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   881
if not TestCollisionYwithGear(Gear, 1) then
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   882
   begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   883
   Gear.dX:= Gear.dX + cWindSpeed;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   884
   Gear.dY:= Gear.dY + cGravity;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   885
   if abs(Gear.dX) > 0.12 then Gear.dX:= Gear.dX * 0.5;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   886
   if Gear.dY > 0.12 then Gear.dY:= Gear.dY * 0.995;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   887
   Gear.X:= Gear.X + Gear.dX;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   888
   Gear.Y:= Gear.Y + Gear.dY;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   889
   if Gear.Y > 1023 then
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   890
      begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   891
      DeleteGear(Gear);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   892
      exit
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   893
      end
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   894
   end else begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   895
   if Gear.Timer > 0 then dec(Gear.Timer)
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   896
      else begin
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   897
      doMakeExplosion(round(Gear.X), round(Gear.Y), 2, 0);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   898
      dec(Gear.Health);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   899
      Gear.Timer:= 1250 - Gear.Angle * 12
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   900
      end
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   901
   end;
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   902
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   903
if (((GameTicks div 8) mod 64) = Gear.Angle) then
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   904
   AmmoFlameWork(Gear);
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   905
82
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   906
if Gear.Health = 0 then
79
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   907
   DeleteGear(Gear)
29b477319854 - New test map
unc0rr
parents: 78
diff changeset
   908
end;
82
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   909
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   910
////////////////////////////////////////////////////////////////////////////////
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   911
procedure doStepFirePunchWork(Gear: PGear);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   912
var HHGear: PGear;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   913
begin
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   914
AllInactive:= false;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   915
if ((Gear.Message and gm_Destroy) <> 0) then
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   916
   begin
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   917
   DeleteGear(Gear);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   918
   AfterAttack;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   919
   exit
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   920
   end;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   921
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   922
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   923
if round(HHGear.Y) <= Gear.Tag - 2 then
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   924
   begin
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   925
   Gear.Tag:= round(HHGear.Y);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   926
   DrawTunnel(HHGear.X - cHHRadius, HHGear.Y - 1, 0.5, 0.0, cHHRadius * 4, 2);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   927
   HHGear.State:= HHGear.State or gstNoDamage;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   928
   Gear.Y:= HHGear.Y;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   929
   AmmoShove(Gear, 30, 40);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   930
   HHGear.State:= HHGear.State and not gstNoDamage
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   931
   end;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   932
   
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   933
HHGear.dY:= HHGear.dY + cGravity;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   934
if HHGear.dY >= 0 then
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   935
   begin
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   936
   HHGear.State:= HHGear.State or gstFalling;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   937
   DeleteGear(Gear);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   938
   AfterAttack;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   939
   exit
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   940
   end;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   941
HHGear.Y:= HHGear.Y + HHGear.dY
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   942
end;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   943
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   944
procedure doStepFirePunch(Gear: PGear);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   945
var HHGear: PGear;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   946
begin
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   947
AllInactive:= false;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   948
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   949
HHGear.X:= round(HHGear.X) - 0.5;
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   950
HHGear.dX:= 0.0000001 * hwSign(HHGear.dX);
82
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   951
HHGear.dY:= -0.30;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   952
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   953
Gear.X:= HHGear.X;
108
08f1fe6f21f8 Small fixes for better FPC compatibility
unc0rr
parents: 107
diff changeset
   954
Gear.dX:= hwSign(HHGear.dX)* 0.45;
82
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   955
Gear.dY:= -0.9;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   956
Gear.doStep:= doStepFirePunchWork;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   957
DrawTunnel(HHGear.X - cHHRadius, HHGear.Y + 1, 0.5, 0.0, cHHRadius * 4, 5);
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   958
end;
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   959
263
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   960
////////////////////////////////////////////////////////////////////////////////
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   961
211
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   962
procedure doStepParachute(Gear: PGear);
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   963
var HHGear: PGear;
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   964
begin
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   965
HHGear:= PHedgehog(Gear.Hedgehog).Gear;
212
c8c650b23e32 Parachute fixes
unc0rr
parents: 211
diff changeset
   966
HHGear.State:= HHGear.State and not gstAttacking;
82
2f4f3236cccc - New fort
unc0rr
parents: 81
diff changeset
   967
212
c8c650b23e32 Parachute fixes
unc0rr
parents: 211
diff changeset
   968
if TestCollisionYwithGear(HHGear, 1)
c8c650b23e32 Parachute fixes
unc0rr
parents: 211
diff changeset
   969
   or ((HHGear.State and gstHHDriven) = 0)
c8c650b23e32 Parachute fixes
unc0rr
parents: 211
diff changeset
   970
   or CheckGearDrowning(HHGear) then
211
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   971
   begin
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   972
   with HHGear^ do
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   973
        begin
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   974
        Message:= 0;
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   975
        dx:= 0.0000001 * hwSign(dX);
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   976
        dY:= 0;
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   977
        State:= State and not (gstAttacking or gstAttacked);
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   978
        State:= State or gstFalling;
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   979
        end;
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   980
   DeleteGear(Gear);
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   981
   OnUsedAmmo(PHedgehog(HHGear.Hedgehog)^.Ammo);
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   982
   ApplyAmmoChanges(PHedgehog(HHGear.Hedgehog)^);
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   983
   exit
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   984
   end;
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   985
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   986
if not TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   987
   HHGear.X:= HHGear.X + cWindSpeed * 200;
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   988
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   989
if (Gear.Message and gm_Left) <> 0 then HHGear.X:= HHGear.X - cMaxWindSpeed * 40
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   990
else if (Gear.Message and gm_Right) <> 0 then HHGear.X:= HHGear.X + cMaxWindSpeed * 40;
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   991
if (Gear.Message and gm_Up) <> 0 then HHGear.Y:= HHGear.Y - cGravity * 40
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   992
else if (Gear.Message and gm_Down) <> 0 then HHGear.Y:= HHGear.Y + cGravity * 40;
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   993
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   994
HHGear.Y:= HHGear.Y + cGravity * 100;
263
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   995
end;
211
558476056205 Parachute
unc0rr
parents: 183
diff changeset
   996
263
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   997
////////////////////////////////////////////////////////////////////////////////
285
cdab49768c83 Mine Strike weapon
unc0rr
parents: 283
diff changeset
   998
const cAirPlaneSpeed = 1.4;
263
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
   999
      cBombsDistance = 30;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1000
      cBombsSpeed = 0.1;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1001
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1002
procedure doStepAirAttackWork(Gear: PGear);
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1003
begin
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1004
AllInactive:= false;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1005
Gear.X:= Gear.X + cAirPlaneSpeed;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1006
if (Gear.Health > 0)and(Gear.X >= Gear.dX)and(Gear.X < Gear.dX + cAirPlaneSpeed) then
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1007
   begin
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1008
   dec(Gear.Health);
285
cdab49768c83 Mine Strike weapon
unc0rr
parents: 283
diff changeset
  1009
   case Gear.State of
cdab49768c83 Mine Strike weapon
unc0rr
parents: 283
diff changeset
  1010
        0: AddGear(round(Gear.X), round(Gear.Y), gtAirBomb, 0, cBombsSpeed, 0.0);
cdab49768c83 Mine Strike weapon
unc0rr
parents: 283
diff changeset
  1011
        1: AddGear(round(Gear.X), round(Gear.Y), gtMine, 0, cBombsSpeed, 0.0);
cdab49768c83 Mine Strike weapon
unc0rr
parents: 283
diff changeset
  1012
        end;
263
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1013
   Gear.dX:= Gear.dX + cBombsDistance
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1014
   end;
283
28d105f378f1 Airplane sprite
unc0rr
parents: 282
diff changeset
  1015
if Gear.X > 3072 then DeleteGear(Gear)
263
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1016
end;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1017
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1018
procedure doStepAirAttack(Gear: PGear);
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1019
begin
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1020
AllInactive:= false;
283
28d105f378f1 Airplane sprite
unc0rr
parents: 282
diff changeset
  1021
Gear.X:= -1024;
263
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1022
Gear.Y:= -128;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1023
Gear.dX:= TargetPoint.X -
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1024
          cBombsDistance * 5 / 2 - 
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1025
          cBombsSpeed * sqrt(2 * (TargetPoint.Y - Gear.Y) / cGravity);
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1026
Gear.Health:= 6;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1027
Gear.doStep:= doStepAirAttackWork
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1028
end;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1029
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1030
////////////////////////////////////////////////////////////////////////////////
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1031
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1032
procedure doStepAirBomb(Gear: PGear);
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1033
begin
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1034
AllInactive:= false;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1035
doStepFallingGear(Gear);
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1036
if (Gear.State and gstCollision) <> 0 then
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1037
   begin
285
cdab49768c83 Mine Strike weapon
unc0rr
parents: 283
diff changeset
  1038
   doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound);
263
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1039
   DeleteGear(Gear);
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1040
   exit
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1041
   end;
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1042
if (GameTicks and $3F) = 0 then
36379e6abcdd - Health tags over drowned hedgehogs
unc0rr
parents: 219
diff changeset
  1043
   AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0)
211
558476056205 Parachute
unc0rr
parents: 183
diff changeset
  1044
end;
558476056205 Parachute
unc0rr
parents: 183
diff changeset
  1045
558476056205 Parachute
unc0rr
parents: 183
diff changeset
  1046