hedgewars/uGearsHedgehog.pas
changeset 13533 0c8001e43fd3
parent 13532 ee77086fc5fa
child 13564 d8da70fdec16
equal deleted inserted replaced
13532:ee77086fc5fa 13533:0c8001e43fd3
    29 procedure HedgehogChAngle(HHGear: PGear);
    29 procedure HedgehogChAngle(HHGear: PGear);
    30 procedure PickUp(HH, Gear: PGear);
    30 procedure PickUp(HH, Gear: PGear);
    31 procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord);
    31 procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord);
    32 procedure CheckIce(Gear: PGear); inline;
    32 procedure CheckIce(Gear: PGear); inline;
    33 procedure PlayTaunt(taunt: Longword);
    33 procedure PlayTaunt(taunt: Longword);
       
    34 function HHGetTimer(Gear: PGear): LongWord;
       
    35 function HHGetTimerMsg(Gear: PGear): LongWord;
       
    36 function HHGetBounciness(Gear: PGear): LongWord;
       
    37 function HHGetBouncinessMsg(Gear: PGear): LongWord;
    34 
    38 
    35 implementation
    39 implementation
    36 uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions,
    40 uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions,
    37     uCommands, uLocale, uUtils, uStats, uIO, uScript,
    41     uCommands, uLocale, uUtils, uStats, uIO, uScript,
    38     uGearsList, uCollisions, uRandom, uStore, uTeams,
    42     uGearsList, uCollisions, uRandom, uStore, uTeams,
   211         with CurrentTeam^ do
   215         with CurrentTeam^ do
   212             ApplyAmmoChanges(Hedgehogs[CurrHedgehog]);
   216             ApplyAmmoChanges(Hedgehogs[CurrHedgehog]);
   213         end;
   217         end;
   214 end;
   218 end;
   215 
   219 
       
   220 // Return timer (in ticks) of hogs current ammo or MSGPARAM_INVALID
       
   221 // if not timerable
       
   222 function HHGetTimer(Gear: PGear): LongWord;
       
   223 var CurWeapon: PAmmo;
       
   224 begin
       
   225 CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^);
       
   226 with Gear^.Hedgehog^ do
       
   227     if ((CurWeapon^.Propz and ammoprop_Timerable) <> 0) then
       
   228         HHGetTimer:= CurWeapon^.Timer
       
   229     else
       
   230         HHGetTimer:= MSGPARAM_INVALID;
       
   231 end;
       
   232 
       
   233 // Returns timer as a corresponding msgParam for /timer command
       
   234 function HHGetTimerMsg(Gear: PGear): LongWord;
       
   235 var timer: LongInt;
       
   236 begin
       
   237 timer:= HHGetTimer(Gear);
       
   238 if timer > -1 then
       
   239     HHGetTimerMsg:= timer div 1000
       
   240 else
       
   241     HHGetTimerMsg:= MSGPARAM_INVALID
       
   242 end;
       
   243 
       
   244 // Returns the selected bounciness value for the hog gear's current ammo
       
   245 // or MSGPARAM_INVALID if current ammo has no settable bounciness
       
   246 function HHGetBounciness(Gear: PGear): LongWord;
       
   247 var CurWeapon: PAmmo;
       
   248 begin
       
   249 CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^);
       
   250 with Gear^.Hedgehog^ do
       
   251     if ((CurWeapon^.Propz and ammoprop_SetBounce) <> 0) then
       
   252         HHGetBounciness:= CurWeapon^.Bounciness
       
   253     else
       
   254         HHGetBounciness:= MSGPARAM_INVALID
       
   255 end;
       
   256 
       
   257 // Returns bounciness as a corresponding msgParam for /timer command
       
   258 function HHGetBouncinessMsg(Gear: PGear): LongWord;
       
   259 var bounciness, i: LongInt;
       
   260 begin
       
   261     bounciness:= HHGetBounciness(Gear);
       
   262     if bounciness > -1 then
       
   263         for i:=0 to High(bouncinessLevels) do
       
   264             if bounciness = bouncinessLevels[i] then
       
   265                 begin
       
   266                 HHGetBouncinessMsg:= i+1;
       
   267                 exit
       
   268                 end;
       
   269     HHGetBouncinessMsg:= MSGPARAM_INVALID
       
   270 end;
   216 
   271 
   217 procedure Attack(Gear: PGear);
   272 procedure Attack(Gear: PGear);
   218 var xx, yy, newDx, newDy, lx, ly: hwFloat;
   273 var xx, yy, newDx, newDy, lx, ly: hwFloat;
   219     speech: PVisualGear;
   274     speech: PVisualGear;
   220     newGear:  PGear;
   275     newGear:  PGear;