1542 GearsNear.size:= s; |
1542 GearsNear.size:= s; |
1543 GearsNear.ar:= @GearsNearArray |
1543 GearsNear.ar:= @GearsNearArray |
1544 end; |
1544 end; |
1545 |
1545 |
1546 procedure SpawnBoxOfSmth; |
1546 procedure SpawnBoxOfSmth; |
1547 var t, aTot, uTot, a, h: LongInt; |
1547 const |
|
1548 // Max. distance between hog and crate for sndThisOneIsMine taunt |
|
1549 ThisOneIsMineDistance : LongInt = 130; |
|
1550 var t, aTot, uTot, a, h, d, minD: LongInt; |
1548 i: TAmmoType; |
1551 i: TAmmoType; |
|
1552 gi, closestHog: PGear; |
1549 begin |
1553 begin |
1550 if (PlacingHogs) or |
1554 if (PlacingHogs) or |
1551 (cCaseFactor = 0) |
1555 (cCaseFactor = 0) |
1552 or (CountGears(gtCase) >= cMaxCaseDrops) |
1556 or (CountGears(gtCase) >= cMaxCaseDrops) |
1553 or (GetRandom(cCaseFactor) <> 0) then |
1557 or (GetRandom(cCaseFactor) <> 0) then |
1619 // handles case of no ammo or utility crates - considered also placing booleans in uAmmos and altering probabilities |
1623 // handles case of no ammo or utility crates - considered also placing booleans in uAmmos and altering probabilities |
1620 if (FollowGear <> nil) then |
1624 if (FollowGear <> nil) then |
1621 begin |
1625 begin |
1622 FindPlace(FollowGear, true, 0, LAND_WIDTH); |
1626 FindPlace(FollowGear, true, 0, LAND_WIDTH); |
1623 |
1627 |
|
1628 // Taunt |
1624 if (FollowGear <> nil) then |
1629 if (FollowGear <> nil) then |
1625 if random(3) = 0 then |
1630 begin |
1626 // TODO: Play this when a crate drops close to a hog, not randomly |
1631 // Look for hog closest to the crate (on the X axis) |
1627 AddVoice(sndThisOneIsMine, CurrentTeam^.voicepack) |
1632 gi := GearsList; |
|
1633 minD := LAND_WIDTH + ThisOneIsMineDistance + 1; |
|
1634 closestHog:= nil; |
|
1635 while gi <> nil do |
|
1636 begin |
|
1637 if (gi^.Kind = gtHedgehog) then |
|
1638 begin |
|
1639 // Y axis is ignored to simplify calculations |
|
1640 d := hwRound(hwAbs(gi^.X - FollowGear^.X)); |
|
1641 if d < minD then |
|
1642 begin |
|
1643 minD := d; |
|
1644 closestHog:= gi; |
|
1645 end; |
|
1646 end; |
|
1647 gi := gi^.NextGear; |
|
1648 end; |
|
1649 |
|
1650 // Is closest hog close enough to the crate (on the X axis)? |
|
1651 if (closestHog <> nil) and (closestHog^.Hedgehog <> nil) and (minD <= ThisOneIsMineDistance) then |
|
1652 // If so, there's a chance for a special taunt |
|
1653 if random(3) > 0 then |
|
1654 AddVoice(sndThisOneIsMine, closestHog^.Hedgehog^.Team^.voicepack) |
|
1655 else |
|
1656 AddVoice(sndReinforce, CurrentTeam^.voicepack) |
1628 else |
1657 else |
|
1658 // Default crate drop taunt |
1629 AddVoice(sndReinforce, CurrentTeam^.voicepack); |
1659 AddVoice(sndReinforce, CurrentTeam^.voicepack); |
|
1660 end; |
1630 end |
1661 end |
1631 end; |
1662 end; |
1632 |
1663 |
1633 |
1664 |
1634 function GetAmmo(Hedgehog: PHedgehog): TAmmoType; |
1665 function GetAmmo(Hedgehog: PHedgehog): TAmmoType; |