hedgewars/uGearsUtils.pas
changeset 14768 185f07ec4d12
parent 14749 533ac9774279
child 14926 60340c8a6fae
equal deleted inserted replaced
14767:458a8c4e65ca 14768:185f07ec4d12
    50 
    50 
    51 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt);
    51 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt);
    52 procedure AmmoShoveCache(Ammo: PGear; Damage, Power: LongInt);
    52 procedure AmmoShoveCache(Ammo: PGear; Damage, Power: LongInt);
    53 procedure AmmoShoveLine(Ammo: PGear; Damage, Power: LongInt; oX, oY, tX, tY: hwFloat);
    53 procedure AmmoShoveLine(Ammo: PGear; Damage, Power: LongInt; oX, oY, tX, tY: hwFloat);
    54 function  GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): PGearArrayS;
    54 function  GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): PGearArrayS;
    55 procedure SpawnBoxOfSmth;
    55 function  SpawnBoxOfSmth: PGear;
       
    56 procedure PlayBoxSpawnTaunt(Gear: PGear);
    56 procedure ShotgunShot(Gear: PGear);
    57 procedure ShotgunShot(Gear: PGear);
    57 function  CanUseTardis(HHGear: PGear): boolean;
    58 function  CanUseTardis(HHGear: PGear): boolean;
    58 
    59 
    59 procedure SetAllToActive;
    60 procedure SetAllToActive;
    60 procedure SetAllHHToActive(Ice: boolean);
    61 procedure SetAllHHToActive(Ice: boolean);
  1545 
  1546 
  1546     GearsNear.size:= s;
  1547     GearsNear.size:= s;
  1547     GearsNear.ar:= @GearsNearArray
  1548     GearsNear.ar:= @GearsNearArray
  1548 end;
  1549 end;
  1549 
  1550 
  1550 procedure SpawnBoxOfSmth;
  1551 function SpawnBoxOfSmth: PGear;
  1551 const
  1552 var t, aTot, uTot, a, h: LongInt;
  1552     // Max. distance between hog and crate for sndThisOneIsMine taunt
       
  1553     ThisOneIsMineDistance : LongInt = 130;
       
  1554 var t, aTot, uTot, a, h, d, minD: LongInt;
       
  1555     i: TAmmoType;
  1553     i: TAmmoType;
  1556     gi, closestHog: PGear;
  1554 begin
  1557 begin
  1555 SpawnBoxOfSmth:= nil;
  1558 if (PlacingHogs) or
  1556 if (PlacingHogs) or
  1559     (cCaseFactor = 0)
  1557     (cCaseFactor = 0)
  1560     or (CountGears(gtCase) >= cMaxCaseDrops)
  1558     or (CountGears(gtCase) >= cMaxCaseDrops)
  1561     or (GetRandom(cCaseFactor) <> 0) then
  1559     or (GetRandom(cCaseFactor) <> 0) then
  1562        exit;
  1560        exit;
  1627 
  1625 
  1628 // handles case of no ammo or utility crates - considered also placing booleans in uAmmos and altering probabilities
  1626 // handles case of no ammo or utility crates - considered also placing booleans in uAmmos and altering probabilities
  1629 if (FollowGear <> nil) then
  1627 if (FollowGear <> nil) then
  1630     begin
  1628     begin
  1631     FindPlace(FollowGear, true, 0, LAND_WIDTH);
  1629     FindPlace(FollowGear, true, 0, LAND_WIDTH);
  1632 
  1630     PlayBoxSpawnTaunt(FollowGear);
       
  1631     SpawnBoxOfSmth:= FollowGear;
       
  1632     end
       
  1633 end;
       
  1634 
       
  1635 procedure PlayBoxSpawnTaunt(Gear: PGear);
       
  1636 const
       
  1637     // Max. distance between hog and crate for sndThisOneIsMine taunt
       
  1638     ThisOneIsMineDistance : LongInt = 130;
       
  1639 var d, minD: LongInt;
       
  1640     gi, closestHog: PGear;
       
  1641 begin
  1633     // Taunt
  1642     // Taunt
  1634     if (FollowGear <> nil) then
  1643     if (Gear <> nil) then
  1635         begin
  1644         begin
  1636         // Look for hog closest to the crate (on the X axis)
  1645         // Look for hog closest to the crate (on the X axis)
  1637         gi := GearsList;
  1646         gi := GearsList;
  1638         minD := LAND_WIDTH + ThisOneIsMineDistance + 1;
  1647         minD := LAND_WIDTH + ThisOneIsMineDistance + 1;
  1639         closestHog:= nil;
  1648         closestHog:= nil;
  1640         while gi <> nil do
  1649         while gi <> nil do
  1641             begin
  1650             begin
  1642             if (gi^.Kind = gtHedgehog) then
  1651             if (gi^.Kind = gtHedgehog) then
  1643                 begin
  1652                 begin
  1644                 // Y axis is ignored to simplify calculations
  1653                 // Y axis is ignored to simplify calculations
  1645                 d := hwRound(hwAbs(gi^.X - FollowGear^.X));
  1654                 d := hwRound(hwAbs(gi^.X - Gear^.X));
  1646                 if d < minD then
  1655                 if d < minD then
  1647                     begin
  1656                     begin
  1648                     minD := d;
  1657                     minD := d;
  1649                     closestHog:= gi;
  1658                     closestHog:= gi;
  1650                     end;
  1659                     end;
  1661                 AddVoice(sndReinforce, CurrentTeam^.voicepack)
  1670                 AddVoice(sndReinforce, CurrentTeam^.voicepack)
  1662         else
  1671         else
  1663         // Default crate drop taunt
  1672         // Default crate drop taunt
  1664             AddVoice(sndReinforce, CurrentTeam^.voicepack);
  1673             AddVoice(sndReinforce, CurrentTeam^.voicepack);
  1665         end;
  1674         end;
  1666     end
       
  1667 end;
  1675 end;
  1668 
  1676 
  1669 
  1677 
  1670 function GetAmmo(Hedgehog: PHedgehog): TAmmoType;
  1678 function GetAmmo(Hedgehog: PHedgehog): TAmmoType;
  1671 var t, aTot: LongInt;
  1679 var t, aTot: LongInt;