hedgewars/uGearsHedgehog.pas
author unc0rr
Sun, 17 Jun 2012 00:08:20 +0400
changeset 7252 74a92f39703b
parent 7187 aff30d80bd7b
child 7194 d8e68cbca7ee
child 7272 71df899c4163
permissions -rw-r--r--
Catch all types of exceptions in recv thread. Should probably help with ghosts problem, though I have no idea which else kind of exception could arise there.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     1
(*
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6700
e04da46ee43c the most important commit of the year
koda
parents: 6581
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     4
 *
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     8
 *
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    12
 * GNU General Public License for more details.
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    13
 *
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    14
 * You should have received a copy of the GNU General Public License
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    15
 * along with this program; if not, write to the Free Software
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    17
 *)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    18
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    19
{$INCLUDE "options.inc"}
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    20
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    21
unit uGearsHedgehog;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    22
interface
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    23
uses uTypes;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    24
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    25
procedure doStepHedgehog(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    26
procedure AfterAttack; 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    27
procedure HedgehogStep(Gear: PGear); 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    28
procedure doStepHedgehogMoving(Gear: PGear); 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    29
procedure HedgehogChAngle(HHGear: PGear); 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    30
procedure PickUp(HH, Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    31
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    32
implementation
6992
b8f3d8991e92 marked a couple of functions as inline
koda
parents: 6982
diff changeset
    33
uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, 
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    34
    uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    35
    uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    36
    uGearsUtils;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    37
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 7010
diff changeset
    38
var GHStepTicks: LongWord = 0;
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 7010
diff changeset
    39
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    40
// Shouldn't more of this ammo switching stuff be moved to uAmmos ?
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    41
function ChangeAmmo(HHGear: PGear): boolean;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    42
var slot, i: Longword;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    43
    ammoidx: LongInt;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    44
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    45
ChangeAmmo:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    46
slot:= HHGear^.MsgParam;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    47
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    48
with HHGear^.Hedgehog^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    49
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    50
    HHGear^.Message:= HHGear^.Message and (not gmSlot);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    51
    ammoidx:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    52
    if ((HHGear^.State and (gstAttacking or gstAttacked)) <> 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    53
    or ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0))
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    54
    or ((HHGear^.State and gstHHDriven) = 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    55
        exit;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    56
    ChangeAmmo:= true;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    57
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    58
    while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    59
        inc(ammoidx);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    60
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    61
    if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) and (MultiShootAttacks > 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    62
        OnUsedAmmo(HHGear^.Hedgehog^);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    63
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    64
    MultiShootAttacks:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    65
    HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump));
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    66
    
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    67
    if Ammoz[CurAmmoType].Slot = slot then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    68
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    69
        i:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    70
        repeat
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    71
        inc(ammoidx);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    72
        if (ammoidx > cMaxSlotAmmoIndex) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    73
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    74
            inc(i);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    75
            CurAmmoType:= amNothing;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    76
            ammoidx:= -1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    77
            //TryDo(i < 2, 'Engine bug: no ammo in current slot', true)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    78
            end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    79
        until (i = 1) or ((Ammo^[slot, ammoidx].Count > 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    80
        and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns))
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    81
        
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    82
        end 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    83
    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    84
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    85
        i:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    86
        // check whether there is ammo in slot
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    87
        while (i <= cMaxSlotAmmoIndex) and ((Ammo^[slot, i].Count = 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    88
        or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns))
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    89
            do inc(i);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    90
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    91
        if i <= cMaxSlotAmmoIndex then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    92
            ammoidx:= i
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    93
        else ammoidx:= -1
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    94
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    95
        if ammoidx >= 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    96
            CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    97
    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    98
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    99
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   100
procedure HHSetWeapon(HHGear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   101
var t: LongInt;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   102
    weap: TAmmoType;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   103
    Hedgehog: PHedgehog;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   104
    s: boolean;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   105
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   106
s:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   107
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   108
weap:= TAmmoType(HHGear^.MsgParam);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   109
Hedgehog:= HHGear^.Hedgehog;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   110
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   111
if Hedgehog^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   112
    exit; // weapon is not activated yet
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   113
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   114
HHGear^.MsgParam:= Ammoz[weap].Slot;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   115
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   116
t:= cMaxSlotAmmoIndex;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   117
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   118
HHGear^.Message:= HHGear^.Message and (not gmWeapon);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   119
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   120
with Hedgehog^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   121
    while (CurAmmoType <> weap) and (t >= 0) do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   122
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   123
        s:= ChangeAmmo(HHGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   124
        dec(t)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   125
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   126
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   127
if s then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   128
    ApplyAmmoChanges(HHGear^.Hedgehog^)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   129
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   130
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   131
procedure HHSetTimer(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   132
var CurWeapon: PAmmo;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   133
    color: LongWord;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   134
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   135
Gear^.Message:= Gear^.Message and (not gmTimer);
6924
57b66ee3bff3 Get rid of overloaded functions in uAmmo
unc0rr
parents: 6700
diff changeset
   136
CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   137
with Gear^.Hedgehog^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   138
    if ((Gear^.Message and gmPrecise) <> 0) and ((CurWeapon^.Propz and ammoprop_SetBounce) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   139
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   140
        color:= Gear^.Hedgehog^.Team^.Clan^.Color;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   141
        case Gear^.MsgParam of
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   142
            1: begin
7069
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7067
diff changeset
   143
               AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce1]), color, capgrpAmmostate);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   144
               CurWeapon^.Bounciness:= 350;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   145
               end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   146
            2: begin
7069
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7067
diff changeset
   147
               AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce2]), color, capgrpAmmostate);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   148
               CurWeapon^.Bounciness:= 700;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   149
               end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   150
            3: begin
7069
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7067
diff changeset
   151
               AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce3]), color, capgrpAmmostate);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   152
               CurWeapon^.Bounciness:= 1000;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   153
               end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   154
            4: begin
7069
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7067
diff changeset
   155
               AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce4]), color, capgrpAmmostate);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   156
               CurWeapon^.Bounciness:= 2000;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   157
               end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   158
            5: begin
7069
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7067
diff changeset
   159
               AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce5]), color, capgrpAmmostate);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   160
               CurWeapon^.Bounciness:= 4000;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   161
               end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   162
            end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   163
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   164
    else if (CurWeapon^.Propz and ammoprop_Timerable) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   165
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   166
        CurWeapon^.Timer:= 1000 * Gear^.MsgParam;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   167
        with CurrentTeam^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   168
            ApplyAmmoChanges(Hedgehogs[CurrHedgehog]);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   169
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   170
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   171
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   172
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   173
procedure Attack(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   174
var xx, yy, newDx, newDy, lx, ly: hwFloat;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   175
    speech: PVisualGear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   176
    newGear:  PGear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   177
    CurWeapon: PAmmo;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   178
    altUse: boolean;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   179
    elastic: hwFloat;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   180
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   181
newGear:= nil;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   182
bShowFinger:= false;
6924
57b66ee3bff3 Get rid of overloaded functions in uAmmo
unc0rr
parents: 6700
diff changeset
   183
CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   184
with Gear^,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   185
    Gear^.Hedgehog^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   186
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   187
        if ((State and gstHHDriven) <> 0) and ((State and (gstAttacked or gstHHChooseTarget)) = 0) and (((State and gstMoving) = 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   188
        or (Power > 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   189
        or (CurAmmoType = amTeleport)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   190
        or 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   191
        // Allow attacks while moving on ammo with AltAttack
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   192
        ((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0))
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   193
        or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackInMove) <> 0))
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   194
        and ((TargetPoint.X <> NoPointX) or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget) = 0)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   195
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   196
            State:= State or gstAttacking;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   197
            if Power = cMaxPower then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   198
                Message:= Message and (not gmAttack)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   199
            else if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   200
                Message:= Message and (not gmAttack)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   201
            else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   202
                begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   203
                if Power = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   204
                    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   205
                    AttackBar:= CurrentTeam^.AttackBar;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   206
                    PlaySound(sndThrowPowerUp)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   207
                    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   208
                inc(Power)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   209
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   210
        if ((Message and gmAttack) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   211
            exit;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   212
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   213
        if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   214
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   215
            StopSound(sndThrowPowerUp);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   216
            PlaySound(sndThrowRelease);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   217
            end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   218
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   219
        xx:= SignAs(AngleSin(Angle), dX);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   220
        yy:= -AngleCos(Angle);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   221
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   222
        lx:= X + int2hwfloat(round(GetLaunchX(CurAmmoType, hwSign(dX), Angle)));
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   223
        ly:= Y + int2hwfloat(round(GetLaunchY(CurAmmoType, Angle)));
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   224
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   225
        if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   226
            xx:= - xx;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   227
        if Ammoz[CurAmmoType].Ammo.AttackVoice <> sndNone then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   228
            AddVoice(Ammoz[CurAmmoType].Ammo.AttackVoice, CurrentTeam^.voicepack);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   229
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   230
// Initiating alt attack
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   231
        if  (CurAmmoGear <> nil)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   232
        and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   233
        and ((Gear^.Message and gmLJump) <> 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   234
        and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   235
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   236
            newDx:= dX / _2; 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   237
            newDy:= dY / _2;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   238
            altUse:= true;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   239
            end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   240
        else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   241
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   242
            newDx:= xx*Power/cPowerDivisor;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   243
            newDy:= yy*Power/cPowerDivisor;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   244
            altUse:= false
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   245
            end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   246
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   247
             case CurAmmoType of
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   248
                      amGrenade: newGear:= AddGear(hwRound(lx), hwRound(ly), gtGrenade,         0, newDx, newDy, CurWeapon^.Timer);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   249
                      amMolotov: newGear:= AddGear(hwRound(lx), hwRound(ly), gtMolotov,      0, newDx, newDy, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   250
                  amClusterBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtClusterBomb,  0, newDx, newDy, CurWeapon^.Timer);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   251
                      amGasBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtGasBomb,      0, newDx, newDy, CurWeapon^.Timer);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   252
                      amBazooka: newGear:= AddGear(hwRound(lx), hwRound(ly), gtShell,        0, newDx, newDy, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   253
                     amSnowball: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSnowball,     0, newDx, newDy, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   254
                          amBee: newGear:= AddGear(hwRound(lx), hwRound(ly), gtBee,          0, newDx, newDy, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   255
                      amShotgun: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   256
                                 PlaySound(sndShotgunReload);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   257
                                 newGear:= AddGear(hwRound(lx), hwRound(ly), gtShotgunShot,  0, xx * _0_5, yy * _0_5, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   258
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   259
                   amPickHammer: newGear:= AddGear(hwRound(lx), hwRound(ly) + cHHRadius, gtPickHammer, 0, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   260
                         amSkip: ParseCommand('/skip', true);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   261
                         amRope: newGear:= AddGear(hwRound(lx), hwRound(ly), gtRope, 0, xx, yy, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   262
                         amMine: if altUse then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   263
                                     newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, newDx, newDy, 3000)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   264
                                 else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   265
                                     newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   266
                        amSMine: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   267
                       amDEagle: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   268
                      amSineGun: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   269
                    amPortalGun: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   270
                                 newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   271
                                 // set selected color
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   272
                                 CurWeapon^.Pos);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   273
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   274
                  amSniperRifle: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   275
                                 PlaySound(sndSniperReload);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   276
                                 newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSniperRifleShot, 0, xx * _0_5, yy * _0_5, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   277
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   278
                     amDynamite: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   279
                    amFirePunch: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtFirePunch, 0, xx, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   280
                         amWhip: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   281
                                 newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtWhip, 0, SignAs(_1, dX), - _0_8, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   282
                                 PlaySound(sndWhipCrack)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   283
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   284
                       amHammer: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   285
                                 newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtHammer, 0, SignAs(_1, dX), - _0_8, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   286
                                 PlaySound(sndWhack)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   287
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   288
                  amBaseballBat: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   289
                                 newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtShover, gsttmpFlag, xx * _0_5, yy * _0_5, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   290
                                 PlaySound(sndBaseballBat) // TODO: Only play if something is hit?
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   291
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   292
                    amParachute: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   293
                                 newGear:= AddGear(hwRound(lx), hwRound(ly), gtParachute, 0, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   294
                                 PlaySound(sndParachute)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   295
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   296
                    // we save CurWeapon^.Pos (in this case: cursor direction) by using it as (otherwise irrelevant) X value of the new gear.
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   297
                    amAirAttack: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 0, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   298
                   amMineStrike: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 1, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   299
                  amDrillStrike: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 3, _0, _0, CurWeapon^.Timer);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   300
                       amNapalm: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 2, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   301
                    amBlowTorch: newGear:= AddGear(hwRound(lx), hwRound(ly), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   302
                       amGirder: newGear:= AddGear(0, 0, gtGirder, CurWeapon^.Pos, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   303
                     amTeleport: newGear:= AddGear(CurWeapon^.Pos, 0, gtTeleport, 0, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   304
                       amSwitch: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSwitcher, 0, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   305
                       amMortar: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   306
                                 playSound(sndMortar);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   307
                                 newGear:= AddGear(hwRound(lx), hwRound(ly), gtMortar,  0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   308
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   309
                      amRCPlane: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   310
                                 newGear:= AddGear(hwRound(lx), hwRound(ly), gtRCPlane,  0, xx * cMaxPower / cPowerDivisor / 4, yy * cMaxPower / cPowerDivisor / 4, 0);
7053
8c9dcaedc7a8 Make pas2c happier with uSound
unc0rr
parents: 7028
diff changeset
   311
                                 newGear^.SoundChannel:= LoopSound(sndRCPlane)
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   312
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   313
                     amKamikaze: newGear:= AddGear(hwRound(lx), hwRound(ly), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   314
                         amCake: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, xx, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   315
                    amSeduction: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSeduction, 0, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   316
                   amWatermelon: newGear:= AddGear(hwRound(lx), hwRound(ly), gtWatermelon,  0, newDx, newDy, CurWeapon^.Timer);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   317
                  amHellishBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtHellishBomb,    0, newDx, newDy, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   318
                        amDrill: newGear:= AddGear(hwRound(lx), hwRound(ly), gtDrill, 0, newDx, newDy, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   319
                      amBallgun: newGear:= AddGear(hwRound(X), hwRound(Y), gtBallgun,  0, xx * _0_5, yy * _0_5, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   320
                      amJetpack: newGear:= AddGear(hwRound(lx), hwRound(ly), gtJetpack, 0, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   321
                        amBirdy: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   322
                             PlaySound(sndWhistle);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   323
                             newGear:= AddGear(hwRound(lx), hwRound(ly) - 32, gtBirdy, 0, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   324
                             end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   325
                   amLowGravity: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   326
                                 PlaySound(sndLowGravity);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   327
                                 cGravity:= cMaxWindSpeed;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   328
                                 cGravityf:= 0.00025
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   329
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   330
                  amExtraDamage: begin 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   331
                                 PlaySound(sndHellishImpact4);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   332
                                 cDamageModifier:= _1_5
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   333
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   334
                 amInvulnerable: Invulnerable:= true;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   335
                    amExtraTime: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   336
                                 PlaySound(sndSwitchHog);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   337
                                 TurnTimeLeft:= TurnTimeLeft + 30000
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   338
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   339
                   amLaserSight: cLaserSighting:= true;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   340
                     amVampiric: begin
7053
8c9dcaedc7a8 Make pas2c happier with uSound
unc0rr
parents: 7028
diff changeset
   341
                                 PlaySoundV(sndOw1, Team^.voicepack);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   342
                                 cVampiric:= true;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   343
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   344
                        amPiano: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   345
                                 // Tuck the hedgehog away until the piano attack is completed
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   346
                                 Unplaced:= true;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   347
                                 X:= _0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   348
                                 Y:= _0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   349
                                 newGear:= AddGear(TargetPoint.X, 0, gtPiano, 0, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   350
                                 PauseMusic
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   351
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   352
                 amFlamethrower: newGear:= AddGear(hwRound(X), hwRound(Y), gtFlamethrower,  0, xx * _0_5, yy * _0_5, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   353
                      amLandGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtLandGun,  0, xx * _0_5, yy * _0_5, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   354
                  amResurrector: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   355
                                 newGear:= AddGear(hwRound(lx), hwRound(ly), gtResurrector, 0, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   356
                                 newGear^.SoundChannel := LoopSound(sndResurrector);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   357
                                 end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   358
                                 //amMelonStrike: AddGear(CurWeapon^.Pos, 0, gtAirAttack, 4, _0, _0, 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   359
                    amStructure: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtStructure, gstWait, SignAs(_0_02, dX), _0, 3000);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   360
                       amTardis: newGear:= AddGear(hwRound(X), hwRound(Y), gtTardis, 0, _0, _0, 5000);
7010
10a0a31804f3 Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents: 6992
diff changeset
   361
                       amIceGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtIceGun, 0, _0, _0, 0);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   362
             end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   363
             
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   364
             case CurAmmoType of
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   365
                      amGrenade, amMolotov, 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   366
                  amClusterBomb, amGasBomb, 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   367
                      amBazooka, amSnowball, 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   368
                          amBee, amSMine,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   369
                       amMortar, amWatermelon,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   370
                  amHellishBomb, amDrill: FollowGear:= newGear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   371
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   372
                      amShotgun, amPickHammer,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   373
                         amRope, amDEagle,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   374
                      amSineGun, amSniperRifle,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   375
                    amFirePunch, amWhip,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   376
                       amHammer, amBaseballBat,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   377
                    amParachute, amBlowTorch,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   378
                       amGirder, amTeleport,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   379
                       amSwitch, amRCPlane,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   380
                     amKamikaze, amCake,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   381
                    amSeduction, amBallgun,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   382
                      amJetpack, amBirdy,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   383
                 amFlamethrower, amLandGun,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   384
                  amResurrector, amStructure,
7010
10a0a31804f3 Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents: 6992
diff changeset
   385
                       amTardis, amPiano,
10a0a31804f3 Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents: 6992
diff changeset
   386
                       amIceGun: CurAmmoGear:= newGear;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   387
             end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   388
             
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   389
            if ((CurAmmoType = amMine) or (CurAmmoType = amSMine)) and (GameFlags and gfInfAttack <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   390
                newGear^.FlightTime:= GameTicks + 1000
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   391
            else if CurAmmoType = amDrill then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   392
                newGear^.FlightTime:= GameTicks + 250;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   393
        if Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   394
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   395
            newGear^.Target.X:= TargetPoint.X;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   396
            newGear^.Target.Y:= TargetPoint.Y
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   397
            end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   398
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   399
        // Clear FollowGear if using on a rope/parachute/saucer etc so focus stays with the hog's movement
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   400
        if altUse then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   401
            FollowGear:= nil;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   402
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   403
        if (newGear <> nil) and ((Ammoz[newGear^.AmmoType].Ammo.Propz and ammoprop_SetBounce) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   404
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   405
            elastic:=  int2hwfloat(CurWeapon^.Bounciness) / _1000;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   406
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   407
            if elastic < _1 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   408
                newGear^.Elasticity:= newGear^.Elasticity * elastic
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   409
            else if elastic > _1 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   410
                newGear^.Elasticity:= _1 - ((_1-newGear^.Elasticity) / elastic);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   411
(* Experimented with friction modifier. Didn't seem helpful 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   412
            fric:= int2hwfloat(CurWeapon^.Bounciness) / _250;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   413
            if fric < _1 then newGear^.Friction:= newGear^.Friction * fric
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   414
            else if fric > _1 then newGear^.Friction:= _1 - ((_1-newGear^.Friction) / fric)*)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   415
            end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   416
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   417
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   418
        uStats.AmmoUsed(CurAmmoType);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   419
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   420
        if not (SpeechText = '') then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   421
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   422
            speech:= AddVisualGear(0, 0, vgtSpeechBubble);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   423
            if speech <> nil then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   424
                begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   425
                speech^.Text:= SpeechText;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   426
                speech^.Hedgehog:= Gear^.Hedgehog;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   427
                speech^.FrameTicks:= SpeechType;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   428
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   429
            SpeechText:= ''
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   430
            end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   431
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   432
        Power:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   433
        if (CurAmmoGear <> nil)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   434
            and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) = 0){check for dropping ammo from rope} then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   435
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   436
            Message:= Message or gmAttack;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   437
            CurAmmoGear^.Message:= Message
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   438
            end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   439
        else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   440
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   441
            if not CurrentTeam^.ExtDriven
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   442
            and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0) then
7067
f98ec3aecf4e A solution to char vs string problem: mark single-letter strings with _S macro
unc0rr
parents: 7053
diff changeset
   443
                SendIPC(_S'a');
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   444
            AfterAttack;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   445
            end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   446
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   447
    else 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   448
        Message:= Message and (not gmAttack);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   449
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   450
    TargetPoint.X := NoPointX;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   451
    ScriptCall('onHogAttack');
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   452
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   453
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   454
procedure AfterAttack;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   455
var s: shortstring;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   456
    a: TAmmoType;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   457
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   458
with CurrentHedgehog^.Gear^, CurrentHedgehog^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   459
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   460
    a:= CurAmmoType;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   461
    State:= State and (not gstAttacking);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   462
    if (Ammoz[a].Ammo.Propz and ammoprop_Effect) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   463
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   464
        Inc(MultiShootAttacks);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   465
        
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   466
        if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   467
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   468
            s:= inttostr(Ammoz[a].Ammo.NumPerTurn - MultiShootAttacks + 1);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   469
            AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   470
            end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   471
        
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   472
        if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   473
        or ((GameFlags and gfMultiWeapon) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   474
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   475
            isInMultiShoot:= true
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   476
            end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   477
        else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   478
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   479
            OnUsedAmmo(CurrentHedgehog^);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   480
            if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (((GameFlags and gfInfAttack) = 0) or PlacingHogs) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   481
                begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   482
                if TagTurnTimeLeft = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   483
                    TagTurnTimeLeft:= TurnTimeLeft;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   484
                TurnTimeLeft:=(Ammoz[a].TimeAfterTurn * cGetAwayTime) div 100;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   485
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   486
            if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   487
                State:= State or gstAttacked;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   488
            if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   489
                ApplyAmmoChanges(CurrentHedgehog^)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   490
            end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   491
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   492
    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   493
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   494
        OnUsedAmmo(CurrentHedgehog^);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   495
        ApplyAmmoChanges(CurrentHedgehog^);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   496
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   497
    AttackBar:= 0
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   498
    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   499
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   500
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   501
////////////////////////////////////////////////////////////////////////////////
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   502
procedure doStepHedgehogDead(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   503
const frametime = 200;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   504
      timertime = frametime * 6;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   505
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   506
if Gear^.Hedgehog^.Unplaced then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   507
    exit;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   508
if Gear^.Timer > 1 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   509
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   510
    AllInactive:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   511
    dec(Gear^.Timer);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   512
    if (Gear^.Timer mod frametime) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   513
        inc(Gear^.Pos)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   514
    end 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   515
else if Gear^.Timer = 1 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   516
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   517
    Gear^.State:= Gear^.State or gstNoDamage;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   518
    doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, CurrentHedgehog, EXPLAutoSound);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   519
    AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   520
    DeleteGear(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   521
    SetAllToActive
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   522
    end 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   523
else // Gear^.Timer = 0
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   524
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   525
    AllInactive:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   526
    Gear^.Z:= cCurrHHZ;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   527
    RemoveGearFromList(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   528
    InsertGearToList(Gear);
7053
8c9dcaedc7a8 Make pas2c happier with uSound
unc0rr
parents: 7028
diff changeset
   529
    PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   530
    Gear^.Pos:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   531
    Gear^.Timer:= timertime
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   532
    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   533
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   534
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   535
////////////////////////////////////////////////////////////////////////////////
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   536
procedure doStepHedgehogGone(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   537
const frametime = 65;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   538
      timertime = frametime * 11;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   539
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   540
if Gear^.Hedgehog^.Unplaced then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   541
    exit;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   542
if Gear^.Timer > 1 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   543
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   544
    AllInactive:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   545
    dec(Gear^.Timer);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   546
    if (Gear^.Timer mod frametime) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   547
        inc(Gear^.Pos)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   548
    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   549
else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   550
if Gear^.Timer = 1 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   551
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   552
    DeleteGear(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   553
    SetAllToActive
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   554
    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   555
else // Gear^.Timer = 0
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   556
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   557
    AllInactive:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   558
    Gear^.Z:= cCurrHHZ;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   559
    RemoveGearFromList(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   560
    InsertGearToList(Gear);
7053
8c9dcaedc7a8 Make pas2c happier with uSound
unc0rr
parents: 7028
diff changeset
   561
    PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   562
    PlaySound(sndWarp);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   563
    Gear^.Pos:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   564
    Gear^.Timer:= timertime
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   565
    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   566
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   567
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   568
////////////////////////////////////////////////////////////////////////////////
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   569
procedure PickUp(HH, Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   570
var s: shortstring;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   571
    a: TAmmoType;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   572
    i: LongInt;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   573
    vga: PVisualGear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   574
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   575
Gear^.Message:= gmDestroy;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   576
PlaySound(sndShotgunReload);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   577
if (Gear^.Pos and posCaseExplode) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   578
    if (Gear^.Pos and posCasePoison) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   579
        doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   580
    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   581
        doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   582
else if (Gear^.Pos and posCasePoison) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   583
    doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned + EXPLNoDamage)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   584
else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   585
case Gear^.Pos of
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   586
       posCaseUtility,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   587
       posCaseAmmo: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   588
                    if Gear^.AmmoType <> amNothing then a:= Gear^.AmmoType 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   589
                    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   590
                        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   591
                        for i:= 0 to GameTicks and $7F do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   592
                            GetRandom(2); // Burn some random numbers
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   593
                        if Gear^.Pos = posCaseUtility then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   594
                            a:= GetUtility(HH^.Hedgehog)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   595
                        else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   596
                            a:= GetAmmo(HH^.Hedgehog)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   597
                        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   598
                    AddAmmo(HH^.Hedgehog^, a);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   599
// Possibly needs to check shared clan ammo game flag once added.
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   600
// On the other hand, no obvious reason that clan members shouldn't know what ammo another clan member picked up
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   601
                    if (not (HH^.Hedgehog^.Team^.ExtDriven 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   602
                    or (HH^.Hedgehog^.BotLevel > 0)))
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   603
                    or (HH^.Hedgehog^.Team^.Clan^.ClanIndex = LocalClan)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   604
                    or (GameType = gmtDemo)  then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   605
                        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   606
                        s:= trammo[Ammoz[a].NameId] + ' (+' + IntToStr(Ammoz[a].NumberInCase) + ')';
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   607
                        AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   608
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   609
                        // show ammo icon
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   610
                        vga:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtAmmo);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   611
                        if vga <> nil then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   612
                            vga^.Frame:= Longword(a);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   613
                        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   614
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   615
                    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   616
     posCaseHealth: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   617
                    inc(HH^.Health, Gear^.Health);
7010
10a0a31804f3 Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents: 6992
diff changeset
   618
                    HH^.Hedgehog^.Effects[hePoisoned] := 0;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   619
                    str(Gear^.Health, s);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   620
                    s:= '+' + s;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   621
                    AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   622
                    RenderHealth(HH^.Hedgehog^);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   623
                    RecountTeamHealth(HH^.Hedgehog^.Team);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   624
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   625
                    i:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   626
                    while i < Gear^.Health do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   627
                        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   628
                        vga:= AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtStraightShot);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   629
                        if vga <> nil then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   630
                            with vga^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   631
                                begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   632
                                Tint:= $00FF00FF;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   633
                                State:= ord(sprHealth)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   634
                                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   635
                        inc(i, 5);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   636
                        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   637
                    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   638
     end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   639
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   640
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   641
procedure HedgehogStep(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   642
var PrevdX: LongInt;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   643
    CurWeapon: PAmmo;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   644
begin
6924
57b66ee3bff3 Get rid of overloaded functions in uAmmo
unc0rr
parents: 6700
diff changeset
   645
CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   646
if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   647
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   648
    if isCursorVisible then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   649
        with Gear^.Hedgehog^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   650
            with CurWeapon^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   651
                begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   652
                if (Gear^.Message and gmLeft  ) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   653
                    Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   654
                else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   655
                    if (Gear^.Message and gmRight ) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   656
                        Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   657
    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   658
        exit;
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 7010
diff changeset
   659
    GHStepTicks:= 200;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   660
    exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   661
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   662
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   663
    if ((Gear^.Message and gmAnimate) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   664
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   665
        Gear^.Message:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   666
        Gear^.State:= Gear^.State or gstAnimation;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   667
        Gear^.Tag:= Gear^.MsgParam;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   668
        Gear^.Timer:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   669
        Gear^.Pos:= 0
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   670
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   671
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   672
    if ((Gear^.Message and gmLJump ) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   673
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   674
        Gear^.Message:= Gear^.Message and (not gmLJump);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   675
        DeleteCI(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   676
        if TestCollisionYwithGear(Gear, -1) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   677
            if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   678
                Gear^.Y:= Gear^.Y - _2
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   679
            else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   680
                if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   681
                    Gear^.Y:= Gear^.Y - _1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   682
            if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX))
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   683
            or   (TestCollisionYwithGear(Gear, -1) <> 0)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   684
                begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   685
                Gear^.dY:= -_0_15;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   686
                if not cArtillery then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   687
                    Gear^.dX:= SignAs(_0_15, Gear^.dX);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   688
                Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
7053
8c9dcaedc7a8 Make pas2c happier with uSound
unc0rr
parents: 7028
diff changeset
   689
                PlaySoundV(sndJump1, Gear^.Hedgehog^.Team^.voicepack);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   690
        exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   691
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   692
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   693
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   694
    if ((Gear^.Message and gmHJump ) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   695
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   696
        DeleteCI(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   697
        Gear^.Message:= Gear^.Message and (not gmHJump);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   698
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   699
        Gear^.dY:= -_0_2;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   700
        SetLittle(Gear^.dX);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   701
        Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
7053
8c9dcaedc7a8 Make pas2c happier with uSound
unc0rr
parents: 7028
diff changeset
   702
        PlaySoundV(sndJump3, Gear^.Hedgehog^.Team^.voicepack);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   703
        exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   704
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   705
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   706
    PrevdX:= hwSign(Gear^.dX);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   707
    if (Gear^.Message and gmLeft  )<>0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   708
        Gear^.dX:= -cLittle else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   709
    if (Gear^.Message and gmRight )<>0 then
7187
aff30d80bd7b - Allow camera movement while current hedgehog is falling
unc0rr
parents: 7164
diff changeset
   710
        Gear^.dX:=  cLittle 
aff30d80bd7b - Allow camera movement while current hedgehog is falling
unc0rr
parents: 7164
diff changeset
   711
        else exit;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   712
7187
aff30d80bd7b - Allow camera movement while current hedgehog is falling
unc0rr
parents: 7164
diff changeset
   713
    StepSoundTimer:= cHHStepTicks;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   714
   
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 7010
diff changeset
   715
    GHStepTicks:= cHHStepTicks;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   716
    if PrevdX <> hwSign(Gear^.dX) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   717
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   718
        FollowGear:= Gear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   719
        exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   720
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   721
    DeleteCI(Gear); // must be after exit!! (see previous line)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   722
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   723
    Gear^.Hedgehog^.visStepPos:= (Gear^.Hedgehog^.visStepPos + 1) and 7;
7164
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   724
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   725
    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   726
        begin
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   727
        Gear^.Y:= Gear^.Y - _1;
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   728
    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   729
        begin
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   730
        Gear^.Y:= Gear^.Y - _1;
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   731
    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   732
        begin
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   733
        Gear^.Y:= Gear^.Y - _1;
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   734
    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   735
        begin
7164
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   736
        Gear^.Y:= Gear^.Y - _1;
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   737
    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   738
        begin
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   739
        Gear^.Y:= Gear^.Y - _1;
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   740
    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   741
        begin
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   742
        Gear^.Y:= Gear^.Y - _1;
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   743
        if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   744
            Gear^.Y:= Gear^.Y + _6
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   745
        end else Gear^.Y:= Gear^.Y + _5 else
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   746
        end else Gear^.Y:= Gear^.Y + _4 else
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   747
        end else Gear^.Y:= Gear^.Y + _3 else
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   748
        end else Gear^.Y:= Gear^.Y + _2 else
fad64b97947e Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents: 7069
diff changeset
   749
        end else Gear^.Y:= Gear^.Y + _1
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   750
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   751
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   752
    if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   753
        Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   754
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   755
   SetAllHHToActive;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   756
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   757
    if TestCollisionYwithGear(Gear, 1) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   758
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   759
        Gear^.Y:= Gear^.Y + _1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   760
    if TestCollisionYwithGear(Gear, 1) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   761
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   762
        Gear^.Y:= Gear^.Y + _1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   763
    if TestCollisionYwithGear(Gear, 1) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   764
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   765
        Gear^.Y:= Gear^.Y + _1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   766
    if TestCollisionYwithGear(Gear, 1) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   767
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   768
        Gear^.Y:= Gear^.Y + _1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   769
    if TestCollisionYwithGear(Gear, 1) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   770
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   771
        Gear^.Y:= Gear^.Y + _1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   772
    if TestCollisionYwithGear(Gear, 1) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   773
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   774
        Gear^.Y:= Gear^.Y + _1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   775
    if TestCollisionYwithGear(Gear, 1) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   776
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   777
        Gear^.Y:= Gear^.Y - _6;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   778
        Gear^.dY:= _0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   779
        Gear^.State:= Gear^.State or gstMoving;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   780
        exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   781
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   782
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   783
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   784
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   785
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   786
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   787
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   788
    AddGearCI(Gear)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   789
    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   790
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   791
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   792
procedure HedgehogChAngle(HHGear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   793
var da: LongWord;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   794
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   795
with HHGear^.Hedgehog^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   796
    if ((CurAmmoType = amRope) and ((HHGear^.State and (gstMoving or gstHHJumping)) = gstMoving))
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   797
    or ((CurAmmoType = amPortalGun) and ((HHGear^.State and gstMoving) <> 0)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   798
        da:= 2
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   799
    else da:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   800
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   801
if (((HHGear^.Message and gmPrecise) = 0) or ((GameTicks mod 5) = 1)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   802
    if ((HHGear^.Message and gmUp) <> 0) and (HHGear^.Angle >= CurMinAngle + da) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   803
        dec(HHGear^.Angle, da)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   804
    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   805
        if ((HHGear^.Message and gmDown) <> 0) and (HHGear^.Angle + da <= CurMaxAngle) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   806
            inc(HHGear^.Angle, da)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   807
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   808
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   809
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   810
////////////////////////////////////////////////////////////////////////////////
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   811
procedure doStepHedgehogMoving(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   812
var isFalling, isUnderwater: boolean;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   813
    land: Word;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   814
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   815
land:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   816
isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   817
if Gear^.dX.QWordValue > 8160437862 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   818
    Gear^.dX.QWordValue:= 8160437862;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   819
if Gear^.dY.QWordValue > 8160437862 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   820
    Gear^.dY.QWordValue:= 8160437862;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   821
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   822
if Gear^.Hedgehog^.Unplaced then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   823
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   824
    Gear^.dY:= _0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   825
    Gear^.dX:= _0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   826
    Gear^.State:= Gear^.State and (not gstMoving);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   827
    exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   828
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   829
isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   830
if isFalling then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   831
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   832
    if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   833
        Gear^.dY:= _0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   834
    Gear^.State:= Gear^.State or gstMoving;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   835
    if (CurrentHedgehog^.Gear = Gear)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   836
        and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   837
        begin
7187
aff30d80bd7b - Allow camera movement while current hedgehog is falling
unc0rr
parents: 7164
diff changeset
   838
        // TODO: why so aggressive at setting FollowGear when falling?
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   839
        FollowGear:= Gear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   840
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   841
    if isUnderwater then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   842
       Gear^.dY:= Gear^.dY + cGravity / _2
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   843
    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   844
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   845
        Gear^.dY:= Gear^.dY + cGravity;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   846
// this set of circumstances could be less complex if jumping was more clearly identified
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   847
        if ((GameFlags and gfMoreWind) <> 0) and (((Gear^.Damage <> 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   848
        or ((CurAmmoGear <> nil) and ((CurAmmoGear^.AmmoType = amJetpack) or (CurAmmoGear^.AmmoType = amBirdy)))
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   849
        or ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue))) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   850
            Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   851
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   852
    end 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   853
else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   854
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   855
    land:= TestCollisionYwithGear(Gear, 1);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   856
    if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   857
    and ((Gear^.State and gstHHJumping) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   858
        SetLittle(Gear^.dX);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   859
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   860
    if not Gear^.dY.isNegative then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   861
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   862
        CheckHHDamage(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   863
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   864
        if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   865
        and (Gear^.dX.QWordValue < _0_02.QWordValue) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   866
            Gear^.dX.isNegative:= not Gear^.dX.isNegative; // landing after high jump
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   867
        Gear^.State:= Gear^.State and (not (gstHHJumping or gstHHHJump));
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   868
        Gear^.dY:= _0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   869
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   870
    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   871
        Gear^.dY:= Gear^.dY + cGravity;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   872
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   873
    if ((Gear^.State and gstMoving) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   874
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   875
        if land and lfIce <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   876
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   877
            Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   878
            end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   879
        else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   880
            Gear^.dX:= Gear^.dX * Gear^.Friction;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   881
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   882
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   883
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   884
if (Gear^.State <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   885
    DeleteCI(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   886
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   887
if isUnderwater then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   888
   begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   889
   Gear^.dY:= Gear^.dY * _0_999;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   890
   Gear^.dX:= Gear^.dX * _0_999;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   891
   end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   892
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   893
if (Gear^.State and gstMoving) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   894
    if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   895
        if not isFalling then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   896
            if hwAbs(Gear^.dX) > _0_01 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   897
                if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   898
                    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   899
                    Gear^.X:= Gear^.X + Gear^.dX;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   900
                    Gear^.dX:= Gear^.dX * _0_96;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   901
                    Gear^.Y:= Gear^.Y - _1
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   902
                    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   903
                else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   904
                    if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   905
                        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   906
                        Gear^.X:= Gear^.X + Gear^.dX;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   907
                        Gear^.dX:= Gear^.dX * _0_93;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   908
                        Gear^.Y:= Gear^.Y - _2
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   909
                        end 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   910
                    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   911
                        if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   912
                        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   913
                        Gear^.X:= Gear^.X + Gear^.dX;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   914
                        Gear^.dX:= Gear^.dX * _0_9 ;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   915
                        Gear^.Y:= Gear^.Y - _3
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   916
                        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   917
                    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   918
                        if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   919
                            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   920
                            Gear^.X:= Gear^.X + Gear^.dX;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   921
                            Gear^.dX:= Gear^.dX * _0_87;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   922
                            Gear^.Y:= Gear^.Y - _4
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   923
                            end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   924
                    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   925
                        if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   926
                            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   927
                            Gear^.X:= Gear^.X + Gear^.dX;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   928
                            Gear^.dX:= Gear^.dX * _0_84;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   929
                            Gear^.Y:= Gear^.Y - _5
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   930
                            end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   931
                    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   932
                        if hwAbs(Gear^.dX) > _0_02 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   933
                            Gear^.dX:= -Gear^.Elasticity * Gear^.dX
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   934
                        else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   935
                            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   936
                            Gear^.State:= Gear^.State and (not gstMoving);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   937
                            while TestCollisionYWithGear(Gear,1) = 0 do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   938
                                Gear^.Y:= Gear^.Y+_1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   939
                            SetLittle(Gear^.dX)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   940
                            end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   941
            else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   942
                begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   943
                Gear^.State:= Gear^.State and (not gstMoving);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   944
                while TestCollisionYWithGear(Gear,1) = 0 do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   945
                    Gear^.Y:= Gear^.Y+_1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   946
                SetLittle(Gear^.dX)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   947
                end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   948
        else if (hwAbs(Gear^.dX) > cLittle)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   949
        and ((Gear^.State and gstHHJumping) = 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   950
            Gear^.dX:= -Gear^.Elasticity * Gear^.dX
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   951
        else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   952
            SetLittle(Gear^.dX);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   953
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   954
if (not isFalling)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   955
and (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   956
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   957
    Gear^.State:= Gear^.State and (not gstWinner);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   958
    Gear^.State:= Gear^.State and (not gstMoving);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   959
    while TestCollisionYWithGear(Gear,1) = 0 do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   960
        Gear^.Y:= Gear^.Y+_1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   961
    SetLittle(Gear^.dX);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   962
    Gear^.dY:= _0
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   963
    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   964
else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   965
    Gear^.State:= Gear^.State or gstMoving;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   966
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   967
if (Gear^.State and gstMoving) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   968
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   969
    Gear^.State:= Gear^.State and (not gstAnimation);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   970
// ARTILLERY but not being moved by explosions
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   971
    Gear^.X:= Gear^.X + Gear^.dX;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   972
    Gear^.Y:= Gear^.Y + Gear^.dY;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   973
    if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1)) 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   974
    and TestCollisionYwithXYShift(Gear, 0, 1, 1) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   975
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   976
        CheckHHDamage(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   977
        Gear^.dY:= _0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   978
        Gear^.Y:= Gear^.Y + _1
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   979
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   980
    CheckGearDrowning(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   981
    // hide target cursor if current hog is drowning
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   982
    if (Gear^.State and gstDrowning) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   983
        if (CurrentHedgehog^.Gear = Gear) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   984
            isCursorVisible:= false
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   985
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   986
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   987
if (hwAbs(Gear^.dY) > _0) and (Gear^.FlightTime > 0) and ((GameFlags and gfLowGravity) = 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   988
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   989
    inc(Gear^.FlightTime);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   990
    if Gear^.FlightTime = 3000 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   991
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   992
        AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   993
        PlaySound(sndHomerun)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   994
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   995
    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   996
else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   997
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   998
    uStats.hedgehogFlight(Gear, Gear^.FlightTime);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   999
    Gear^.FlightTime:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1000
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1001
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1002
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1003
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1004
procedure doStepHedgehogDriven(HHGear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1005
var t: PGear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1006
    wasJumping: boolean;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1007
    Hedgehog: PHedgehog;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1008
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1009
Hedgehog:= HHGear^.Hedgehog;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1010
if isInMultiShoot then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1011
    HHGear^.Message:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1012
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1013
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Utility) <> 0) and isInMultiShoot then 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1014
    AllInactive:= true
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1015
else if not isInMultiShoot then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1016
    AllInactive:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1017
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1018
if (TurnTimeLeft = 0) or (HHGear^.Damage > 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1019
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1020
    if TagTurnTimeLeft = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1021
        TagTurnTimeLeft:= TurnTimeLeft;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1022
    TurnTimeLeft:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1023
    isCursorVisible:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1024
    HHGear^.State:= HHGear^.State and (not (gstHHDriven or gstAnimation or gstAttacking));
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1025
    AttackBar:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1026
    if HHGear^.Damage > 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1027
        HHGear^.State:= HHGear^.State and (not (gstHHJumping or gstHHHJump));
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1028
    exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1029
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1030
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1031
if (HHGear^.State and gstAnimation) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1032
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1033
    HHGear^.Message:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1034
    if (HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].VoiceDelay) and (HHGear^.Timer = 0) then
7053
8c9dcaedc7a8 Make pas2c happier with uSound
unc0rr
parents: 7028
diff changeset
  1035
        PlaySoundV(Wavez[TWave(HHGear^.Tag)].Voice, Hedgehog^.Team^.voicepack);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1036
    inc(HHGear^.Timer);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1037
    if HHGear^.Timer = Wavez[TWave(HHGear^.Tag)].Interval then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1038
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1039
        HHGear^.Timer:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1040
        inc(HHGear^.Pos);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1041
        if HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].FramesCount then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1042
            HHGear^.State:= HHGear^.State and (not gstAnimation)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1043
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1044
    exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1045
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1046
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1047
if ((HHGear^.State and gstMoving) <> 0)
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 7010
diff changeset
  1048
or (GHStepTicks = cHHStepTicks)
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1049
or (CurAmmoGear <> nil) then // we are moving
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1050
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1051
    with Hedgehog^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1052
        if (CurAmmoGear = nil)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1053
        and (HHGear^.dY > _0_39)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1054
        and (CurAmmoType = amParachute) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1055
            HHGear^.Message:= HHGear^.Message or gmAttack;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1056
    // check for case with ammo
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1057
    t:= CheckGearNear(HHGear, gtCase, 36, 36);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1058
    if t <> nil then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1059
        PickUp(HHGear, t)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1060
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1061
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1062
if (CurAmmoGear = nil) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1063
    if (((HHGear^.Message and gmAttack) <> 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1064
    or ((HHGear^.State and gstAttacking) <> 0)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1065
        Attack(HHGear) // should be before others to avoid desync with '/put' msg and changing weapon msgs
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1066
    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1067
else 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1068
    with Hedgehog^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1069
        if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1070
        and ((HHGear^.Message and gmLJump) <> 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1071
        and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1072
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1073
            Attack(HHGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1074
            HHGear^.Message:= HHGear^.Message and (not gmLJump)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1075
            end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1076
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1077
if (CurAmmoGear = nil)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1078
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1079
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1080
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1081
    if ((HHGear^.Message and gmSlot) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1082
        if ChangeAmmo(HHGear) then ApplyAmmoChanges(Hedgehog^);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1083
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1084
    if ((HHGear^.Message and gmWeapon) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1085
        HHSetWeapon(HHGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1086
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1087
    if ((HHGear^.Message and gmTimer) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1088
        HHSetTimer(HHGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1089
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1090
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1091
if CurAmmoGear <> nil then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1092
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1093
    CurAmmoGear^.Message:= HHGear^.Message;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1094
    exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1095
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1096
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1097
if not isInMultiShoot then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1098
    HedgehogChAngle(HHGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1099
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1100
if (HHGear^.State and gstMoving) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1101
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1102
    wasJumping:= ((HHGear^.State and gstHHJumping) <> 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1103
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1104
    if ((HHGear^.Message and gmHJump) <> 0) and wasJumping and ((HHGear^.State and gstHHHJump) = 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1105
        if (not (hwAbs(HHGear^.dX) > cLittle)) and (HHGear^.dY < -_0_02) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1106
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1107
            HHGear^.State:= HHGear^.State or gstHHHJump;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1108
            HHGear^.dY:= -_0_25;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1109
            if not cArtillery then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1110
                HHGear^.dX:= -SignAs(_0_02, HHGear^.dX);
7053
8c9dcaedc7a8 Make pas2c happier with uSound
unc0rr
parents: 7028
diff changeset
  1111
            PlaySoundV(sndJump2, Hedgehog^.Team^.voicepack)
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1112
            end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1113
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1114
    HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump));
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1115
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1116
    if (not cArtillery) and wasJumping and TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1117
        SetLittle(HHGear^.dX);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1118
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1119
    if Hedgehog^.Gear <> nil then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1120
        doStepHedgehogMoving(HHGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1121
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1122
    if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1123
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1124
        AddGearCI(HHGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1125
        if wasJumping then
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 7010
diff changeset
  1126
            GHStepTicks:= 410
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1127
        else
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 7010
diff changeset
  1128
            GHStepTicks:= 95
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1129
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1130
    exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1131
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1132
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1133
    if not isInMultiShoot and (Hedgehog^.Gear <> nil) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1134
        begin
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 7010
diff changeset
  1135
        if GHStepTicks > 0 then
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 7010
diff changeset
  1136
            dec(GHStepTicks);
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 7010
diff changeset
  1137
        if (GHStepTicks = 0) then
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1138
            HedgehogStep(HHGear)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1139
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1140
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1141
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1142
////////////////////////////////////////////////////////////////////////////////
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1143
procedure doStepHedgehogFree(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1144
var prevState: Longword;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1145
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1146
prevState:= Gear^.State;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1147
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1148
doStepHedgehogMoving(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1149
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1150
if (Gear^.State and (gstMoving or gstDrowning)) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1151
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1152
    if Gear^.Damage > 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1153
        CalcRotationDirAngle(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1154
    AllInactive:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1155
    exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1156
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1157
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1158
if (Gear^.Health = 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1159
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1160
    if PrvInactive or ((GameFlags and gfInfAttack) <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1161
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1162
        Gear^.Timer:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1163
        FollowGear:= Gear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1164
        PrvInactive:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1165
        AllInactive:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1166
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1167
        if (Gear^.State and gstHHGone) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1168
            begin
7010
10a0a31804f3 Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents: 6992
diff changeset
  1169
            Gear^.Hedgehog^.Effects[hePoisoned] := 0;
10a0a31804f3 Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents: 6992
diff changeset
  1170
            if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1171
                begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1172
                ResurrectHedgehog(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1173
                end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1174
            else 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1175
                begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1176
                Gear^.State:= (Gear^.State or gstHHDeath) and (not gstAnimation);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1177
                Gear^.doStep:= @doStepHedgehogDead;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1178
                // Death message
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1179
                AddCaption(Format(GetEventString(eidDied), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1180
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1181
            end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1182
        else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1183
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1184
            Gear^.State:= Gear^.State and (not gstAnimation);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1185
            Gear^.doStep:= @doStepHedgehogGone;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1186
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1187
            // Gone message
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1188
            AddCaption(Format(GetEventString(eidGone), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1189
            end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1190
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1191
    exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1192
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1193
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1194
if ((Gear^.State and gstWait) = 0) and
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1195
    (prevState <> Gear^.State) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1196
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1197
    Gear^.State:= Gear^.State or gstWait;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1198
    Gear^.Timer:= 150
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1199
    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1200
else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1201
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1202
    if Gear^.Timer = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1203
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1204
        Gear^.State:= Gear^.State and (not (gstWait or gstLoser or gstWinner or gstAttacked or gstNotKickable or gstHHChooseTarget));
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1205
        Gear^.Active:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1206
        AddGearCI(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1207
        exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1208
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1209
    else dec(Gear^.Timer)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1210
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1211
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1212
AllInactive:= false
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1213
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1214
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1215
////////////////////////////////////////////////////////////////////////////////
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1216
procedure doStepHedgehog(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1217
(*
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1218
var x,y,tx,ty: LongInt;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1219
    tdX, tdY, slope: hwFloat; 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1220
    land: Word; *)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1221
var slope: hwFloat; 
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1222
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1223
if (Gear^.Message and gmDestroy) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1224
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1225
    DeleteGear(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1226
    exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1227
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1228
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1229
if (Gear^.State and gstHHDriven) = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1230
    doStepHedgehogFree(Gear)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1231
else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1232
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1233
    with Gear^.Hedgehog^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1234
        if Team^.hasGone then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1235
            TeamGoneEffect(Team^)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1236
        else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1237
            doStepHedgehogDriven(Gear)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1238
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1239
if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1240
and (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1241
and (not Gear^.dY.isNegative) and (GameTicks mod (100*LongWOrd(hwRound(cMaxWindSpeed*2/cGravity))) = 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1242
and (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1243
    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1244
    slope:= CalcSlopeBelowGear(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1245
    Gear^.dX:=Gear^.dX+slope*_0_07;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1246
    if slope.QWordValue <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1247
        Gear^.State:= Gear^.State or gstMoving;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1248
(*
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1249
    x:= hwRound(Gear^.X);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1250
    y:= hwRound(Gear^.Y);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1251
    AddVisualGear(x, y, vgtSmokeTrace);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1252
    AddVisualGear(x - hwRound(_5*slope), y + hwRound(_5*slope), vgtSmokeTrace);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1253
    AddVisualGear(x + hwRound(_5*slope), y - hwRound(_5*slope), vgtSmokeTrace);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1254
    AddVisualGear(x - hwRound(_20 * slope), y + hwRound(_20 * slope), vgtSmokeTrace);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1255
    AddVisualGear(x + hwRound(_20 * slope), y - hwRound(_20 * slope), vgtSmokeTrace);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1256
    AddVisualGear(x - hwRound(_30 * slope), y + hwRound(_30 * slope), vgtSmokeTrace);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1257
    AddVisualGear(x + hwRound(_30 * slope), y - hwRound(_30 * slope), vgtSmokeTrace);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1258
    AddVisualGear(x - hwRound(_40 * slope), y + hwRound(_40 * slope), vgtSmokeTrace);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1259
    AddVisualGear(x + hwRound(_40 * slope), y - hwRound(_40 * slope), vgtSmokeTrace);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1260
    AddVisualGear(x - hwRound(_50 * slope), y + hwRound(_50 * slope), vgtSmokeTrace);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1261
    AddVisualGear(x + hwRound(_50 * slope), y - hwRound(_50 * slope), vgtSmokeTrace); *)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1262
    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1263
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1264
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
  1265
end.