示例#1
0
 public function onReload(SR_Player $player)
 {
     if (false === ($ammo = $player->getItemByName($this->getAmmoName()))) {
         $player->msg('5205');
         // 			$player->message('You are out of ammo!');
         $player->unequip($this);
         $player->modify();
         return true;
     }
     $p = $player->getParty();
     $now = $this->getAmmo();
     $max = $this->getBulletsMax();
     $avail = $ammo->getAmount();
     $put = Common::clamp($max - $now, 0, $avail);
     if ($put == 0) {
         $player->msg('1156');
         // 			$player->message('Your weapon is already loaded.');
         return false;
     }
     //		Dog_Log::debug(sprintf('%s reloads his %s: Nee'))
     $ammo->useAmount($player, $put);
     $this->increase('sr4it_ammo', $put);
     if ($p->isFighting()) {
         $ep = $p->getEnemyParty();
         $busy = $player->busy(round($this->getReloadTime() + rand(0, 10)));
         $p->ntice('5206', array($player->getName(), $put, $this->getName(), $busy));
         $ep->ntice('5206', array($player->getName(), $put, $this->getName(), $busy));
         // 			$message = sprintf(' load(s) %d bullet(s) into his %s. %s', $put, $this->getItemName(), Shadowfunc::displayBusy($busy));
         //			$message = sprintf(' load(s) %d bullet(s) into his %s. %s busy.', $put, $this->getItemName(), $player->busy(round($this->getReloadTime()+rand(0, 10))));
         // 			$p->message($player, $message);
         // 			$p->getEnemyParty()->message($player, $message);
     } else {
         // 			$message = sprintf('You load %d bullet(s) into your %s.', $put, $this->getItemName());
         // 			$bot = Shadowrap::instance($player);
         // 			$bot->rply('5207', array($put, $this->getName()));
         $player->msg('5207', array($put, $this->getName()));
         // 			$bot->reply($message);
     }
     return true;
 }
示例#2
0
 public function onItemUnequip(SR_Player $player)
 {
     return $player->unequip($this, true);
 }