Esempio n. 1
0
 /**
  * Check if the party sum levels match nicely.
  * @param SR_Party $attackers
  * @param SR_Party $defenders
  * @param boolean $verbose
  * @return true|false
  */
 public static function isKillProtectedPartyLevel(SR_Party $attackers, SR_Party $defenders, SR_Player $player, $verbose = true)
 {
     # NPC
     if (!$defenders->isHuman()) {
         return false;
     }
     # A member has bounty or bad karma
     foreach ($defenders->getMembers() as $defender) {
         $defender instanceof SR_Player;
         if ($defender->getBase('bounty') > 0) {
             return false;
         }
         if ($defender->getBase('bad_karma')) {
             return false;
         }
     }
     # Check party sums for effective level.
     $al = $attackers->getSum('level', false);
     $dl = $defenders->getSum('level', false);
     # Clamp to the level where game gets hard.
     $clamp = self::MAX_LEVEL_DIFF + self::DISABLE_LEVEL_DIFF;
     $al = Common::clamp($al, 0, $clamp);
     $dl = Common::clamp($dl, 0, $clamp);
     $dif = $al - $dl;
     if ($dif > self::MAX_LEVEL_DIFF) {
         if ($verbose) {
             $player->msg('1015', array($al, $dl, self::MAX_LEVEL_DIFF));
             // 				$player->message(sprintf('Your party (level sum %d) cannot attack a party with level sum %d because the level difference is larger than %d.', $al, $dl, self::MAX_LEVEL_DIFF));
         }
         # Protected by level
         return true;
     }
     # No protection
     return false;
 }
Esempio n. 2
0
 private function maxEnemies(SR_Party $party)
 {
     $mc = $party->getMemberCount();
     return Common::clamp(round($party->getSum('level', true) / 14) + 1, $mc, 9);
 }
Esempio n. 3
0
 public function getNPCMeetPercent(SR_Party $party)
 {
     $bad_karma = $party->getSum('bad_karma', true);
     $perc = $bad_karma / 50 * 100;
     return Common::clamp($perc, 0.0, 100.0);
 }