hedgewars/uGearsHedgehog.pas
changeset 7754 e81dc9bef8b8
parent 7738 abcc7012de0b
child 7763 6ab7307fcec3
equal deleted inserted replaced
7753:dda33caa609d 7754:e81dc9bef8b8
    40 
    40 
    41 // Shouldn't more of this ammo switching stuff be moved to uAmmos ?
    41 // Shouldn't more of this ammo switching stuff be moved to uAmmos ?
    42 function ChangeAmmo(HHGear: PGear): boolean;
    42 function ChangeAmmo(HHGear: PGear): boolean;
    43 var slot, i: Longword;
    43 var slot, i: Longword;
    44     ammoidx: LongInt;
    44     ammoidx: LongInt;
       
    45     prevAmmo: TAmmoType;
    45 begin
    46 begin
    46 ChangeAmmo:= false;
    47 ChangeAmmo:= false;
    47 slot:= HHGear^.MsgParam;
    48 slot:= HHGear^.MsgParam;
    48 
    49 
    49 with HHGear^.Hedgehog^ do
    50 with HHGear^.Hedgehog^ do
    50     begin
    51     begin
    51     HHGear^.Message:= HHGear^.Message and (not gmSlot);
    52     HHGear^.Message:= HHGear^.Message and (not gmSlot);
       
    53     prevAmmo:= CurAmmoType;
    52     ammoidx:= 0;
    54     ammoidx:= 0;
    53     if ((HHGear^.State and (gstAttacking or gstAttacked)) <> 0)
    55     if ((HHGear^.State and (gstAttacking or gstAttacked)) <> 0)
    54     or ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0))
    56     or ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0))
    55     or ((HHGear^.State and gstHHDriven) = 0) then
    57     or ((HHGear^.State and gstHHDriven) = 0) then
    56         exit;
    58         exit;
    93             ammoidx:= i
    95             ammoidx:= i
    94         else ammoidx:= -1
    96         else ammoidx:= -1
    95         end;
    97         end;
    96         if ammoidx >= 0 then
    98         if ammoidx >= 0 then
    97             CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
    99             CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
       
   100     if (prevAmmo <> CurAmmoType) then
       
   101         begin
       
   102         if CurAmmoType = amKnife then
       
   103             LoadHedgehogHat(HHGear^.Hedgehog^, 'Reserved/chef')
       
   104         else if prevAmmo = amKnife then
       
   105             LoadHedgehogHat(HHGear^.Hedgehog^, Hat);
       
   106         end
    98     end
   107     end
    99 end;
   108 end;
   100 
   109 
   101 procedure HHSetWeapon(HHGear: PGear);
   110 procedure HHSetWeapon(HHGear: PGear);
   102 var t: LongInt;
   111 var t: LongInt;
   260                    amPickHammer: newGear:= AddGear(hwRound(lx), hwRound(ly) + cHHRadius, gtPickHammer, 0, _0, _0, 0);
   269                    amPickHammer: newGear:= AddGear(hwRound(lx), hwRound(ly) + cHHRadius, gtPickHammer, 0, _0, _0, 0);
   261                          amSkip: ParseCommand('/skip', true);
   270                          amSkip: ParseCommand('/skip', true);
   262                          amRope: newGear:= AddGear(hwRound(lx), hwRound(ly), gtRope, 0, xx, yy, 0);
   271                          amRope: newGear:= AddGear(hwRound(lx), hwRound(ly), gtRope, 0, xx, yy, 0);
   263                          amMine: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000);
   272                          amMine: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000);
   264                         amSMine: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   273                         amSMine: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   265                         amKnife: newGear:= AddGear(hwRound(lx), hwRound(ly), gtKnife,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   274                         amKnife: begin 
       
   275                                  newGear:= AddGear(hwRound(lx), hwRound(ly), gtKnife,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
       
   276                                  newGear^.State:= newGear^.State or gstMoving; 
       
   277                                  newGear^.Radius:= 6 // temporarily shrink so it doesn't instantly embed in the ground
       
   278                                  end;
   266                        amDEagle: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
   279                        amDEagle: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
   267                       amSineGun: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0);
   280                       amSineGun: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0);
   268                     amPortalGun: begin
   281                     amPortalGun: begin
   269                                  newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, 
   282                                  newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, 
   270                                  // set selected color
   283                                  // set selected color