コード例 #1
0
ファイル: SR_City.php プロジェクト: sinfocol/gwf3
 private function enemyContact(SR_Party $party, $friendly = false)
 {
     $dice = $friendly ? 18 : 8;
     if (rand(1, $dice) !== 1) {
         return false;
     }
     $mc = $party->getMemberCount();
     $level = $party->getMax('level', true);
     $possible = array();
     $total = 0;
     foreach ($this->npcs as $npc) {
         $npc instanceof SR_NPC;
         if ($npc->getNPCLevel() <= $level && $npc->isNPCFriendly($party) === $friendly && $npc->canNPCMeet($party)) {
             $multi = $friendly === true ? 1 : 1;
             $percent = round($npc->getNPCMeetPercent($party) * $multi * 100);
             $total += $percent;
             $possible[] = array($npc->getNPCClassName(), $percent);
         }
     }
     $npcs = array();
     $x = 200;
     // 200% chance nothing
     do {
         $contact = false;
         if (false !== ($npc = Shadowfunc::randomData($possible, $total, $x * 100))) {
             $contact = true;
             $npcs[] = $npc;
             $x += 120 - Common::clamp($mc * 10, 0, 50);
         }
         if (count($npcs) >= $this->maxEnemies($party)) {
             break;
         }
     } while ($contact === true);
     if (count($npcs) === 0) {
         return false;
     }
     $ep = SR_NPC::createEnemyParty($npcs);
     if ($friendly === true) {
         $party->talk($ep, true);
     } else {
         $party->fight($ep, true);
     }
     return true;
 }