コード例 #1
0
ファイル: SR_AICMD.php プロジェクト: sinfocol/gwf3
 public static function combatTimer(SR_Player $player)
 {
     $ai = $player->getVar('sr4pl_combat_ai');
     if ($ai === NULL) {
         if ($player->isHuman()) {
             return;
         } else {
             $ai = self::DEFAULT_COMBAT_AI;
         }
     }
     //		$data = array();
     //		$total = 0;
     $decisions = array();
     $ai = explode(';', $ai);
     foreach ($ai as $func) {
         $func = trim($func);
         if (preg_match('/([a-z_]+)(\\([^\\)]+\\))?([-+*\\/]\\d+)?/i', $func, $matches)) {
             $funcname = $matches[1];
             $classname = 'ShadowAI_' . $funcname;
             if (class_exists($classname)) {
                 $args = isset($matches[1]) ? explode(',', $matches[1]) : NULL;
                 $multi = isset($matches[2]) ? $matches[2] : '*1';
                 $decision = call_user_func(array($classname, 'decideCombat'), $player, $args);
                 if ($decision !== NULL) {
                     $command = $decision[0];
                     $prefer = $decision[1];
                     $prefer = eval("{$prefer}{$multi};");
                     //						$chance = (int)($prefer*100);
                     //						$total += $chance;
                     //						$data[] = array($command, $chance);
                     $decisions[$command] = $prefer;
                 }
             } else {
                 Dog_Log::debug(sprintf('%s has an invalid AI method: %s.', $player->getName(), $funcname));
             }
         } else {
             Dog_Log::debug(sprintf('PREG MATCH FAILED: %s.', $func));
         }
     }
     # Best
     if (count($decisions) > 0) {
         arsort($decisions);
         $command = key($decisions);
         $player->combatPush($command);
     }
     # Rand
     //		if (false !== ($command = Shadowfunc::randomData($data, $total)))
     //		{
     //			$player->combatPush($command);
     //		}
 }
コード例 #2
0
ファイル: SR_PlayerStats.php プロジェクト: sinfocol/gwf3
 public static function onKill(SR_Player $killer, SR_Player $victim)
 {
     if (!$killer->isHuman()) {
         return true;
     }
     if ($victim instanceof SR_HireNPC) {
         $column = 'npc';
     } elseif ($victim instanceof SR_NPC) {
         $column = 'mob';
     } else {
         if ($victim->isRunner()) {
             $column = 'runner';
         } else {
             $column = 'human';
         }
     }
     if (false === ($stats = self::getOrCreateStats($killer))) {
         return false;
     }
     return $stats->increase('sr4ps_kill_' . $column, 1);
 }
コード例 #3
0
ファイル: SR_Player.php プロジェクト: sinfocol/gwf3
 private function announceKilled(SR_Player $killer)
 {
     $famous = $this->isRunner() ? 'famous' : 'newbie';
     $famous2 = $killer->isRunner() ? 'famous' : 'newbie';
     $npchuman = $killer->isHuman() ? 'runner' : 'NPC';
     $message = sprintf('[Shadowlamb] - The %s runner %s got killed by the %s %s %s', $famous, $this->getName(), $famous2, $npchuman, $killer->getName());
     Shadowshout::sendGlobalMessage($message);
 }
コード例 #4
0
ファイル: Shadowfunc.php プロジェクト: sinfocol/gwf3
 public static function diceHits($mindmg, $arm, $atk, $def, SR_Player $player, SR_Player $target)
 {
     $ep = $target->getParty();
     if ($player->isHuman()) {
         if ($target->isHuman()) {
             // 				$oops = rand(80, 250) / 10;
             $oops = self::diceFloat(6.0, 9.0, 1);
         } else {
             // 				$oops = rand(80, 190) / 10;
             $oops = $player->getBase('level') * 0.1;
             $oops = self::diceFloat(6.0 + $oops, 9.0 + $oops, 1);
         }
     } else {
         if ($target->isHuman()) {
             // 				$rand = rand(12, 20) / 10;
             // 				$oops = $rand + $ep->getMemberCount()*0.3; # + $ep->getMax('level', true)*0.01;
             $oops = 0.2 + $target->getBase('level') * 0.05;
             $oops *= Common::pow(1.28, $ep->getMemberCount());
         } else {
             // 				$oops = rand(80, 250) / 10;
             $oops = self::diceFloat(0.8, 2.5, 1);
         }
     }
     // 		$chances = (($atk*10 + $mindmg*5) / ($def*5 + $arm*2)) * $oops * 0.65;
     $chances = ($atk * 20 + $mindmg * 50) / ($def * 5 + $arm * 2) * $oops * 0.7;
     // 		echo "OOOOOOOPS: $oops\n";
     // 		return Shadowfunc::dicePool(round($chances), round($def)+1, round(sqrt($def)));
     return Shadowfunc::dicePoolB($chances, $def);
 }