Exemplo n.º 1
0
 public static function giveItem(SR_Player $player, SR_Player $target, $id, $amt = 1)
 {
     if ($amt < 1) {
         $player->msg('1038');
         // 			$player->message('Please give a positive amount of items.');
         return false;
     }
     if (false === ($item = $player->getInvItem($id))) {
         $player->msg('1029');
         // 			$player->message('You don`t have that item.');
         return false;
     }
     // 		if (false === $item->isItemTradeable())
     // 		{
     // 			$player->message('You are not allowed to trade this item.');
     // 			return false;
     // 		}
     if ($item->isItemStackable()) {
         if ($amt > $item->getAmount()) {
             $player->msg('1040', array($item->getItemName()));
             // 				$player->message(sprintf('You only have %d %s.', $item->getAmount(), $item->getName()));
             return false;
         }
         $giveItem = SR_Item::createByName($item->getItemName(), $amt, true);
         $item->useAmount($player, $amt);
     } else {
         if ($amt !== 1) {
             $player->message('Currently you can only give one equipment at a time.');
             return false;
         }
         $player->removeFromInventory($item);
         $giveItem = $item;
     }
     $busymsg = $player->isFighting() ? Shadowfunc::displayBusy($player->busy(SR_Player::GIVE_TIME)) : '';
     self::rply($player, '5115', array($amt, $giveItem->displayFullName($player), $target->getName(), $busymsg));
     // 		$player->message(sprintf('You gave %d %s to %s.%s', $amt, $giveItem->getName(), $target->getName(), $busymsg));
     $target->giveItems(array($giveItem), $player->getName());
     // 		if ($target instanceof SR_TalkingNPC)
     // 		{
     // 			$target->onNPCGive($player, $items);
     // 		}
     return true;
 }
Exemplo n.º 2
0
 public function announceADV(SR_Player $player, SR_Player $target, $level, $key = '10000', $arg1 = '', $arg2 = '', $arg3 = '', $arg4 = '')
 {
     # Pick right keys. Each spell has own 4 keys for all 4 possibilities.
     $key_friend = $key;
     $key_foe = $key + 2;
     if ($this->isCastMode()) {
         $key_friend++;
         $key_foe++;
     }
     $key_friend = (string) $key_friend;
     $key_foe = (string) $key_foe;
     # 9 args
     $args = array($player->displayName(), $level, $this->getName(), $target->displayName(), $arg1, $arg2, $arg3, Shadowfunc::displayBusy($player->getBusyLeft()));
     # Announce
     $p = $player->getParty();
     $ep = $target->getParty();
     if ($ep->getID() !== $p->getID()) {
         $ep->ntice($key_foe, $args);
     }
     if ($this->isCastMode()) {
         # 10 args
         # TODO: this 12 args
         // 			$args[] = $this->getManaCost($player, $level);
         // 			$args[] = $player->getMP();
         // 			$args[] = $player->getMaxMP();
         # Old spell style 10 args
         $gain = $this->getManaCost($player, $level);
         $oldmp = $player->getMP() + $gain;
         $maxmp = $player->getMaxMP();
         $args[] = Shadowfunc::displayMPGain($oldmp, -$gain, $maxmp);
     }
     $args[] = $arg4;
     $p->ntice($key_friend, $args);
 }
Exemplo n.º 3
0
 private function forwardB(SR_Player $player, $dir, $fwbw, $busy = -1)
 {
     $by = $dir * $player->getMovePerSecond();
     $pid = $player->getID();
     $new_d = 0;
     $this->movePlayerB($pid, $by, $new_d);
     $busy = $busy > 0 ? ', ' . Shadowfunc::displayBusy($player->busy($busy)) : '.';
     $by = round($by, 1);
     $new_d = round($new_d, 1);
     $ep = $this->getEnemyParty();
     $pname = $player->getName();
     $this->ntice('5090', array($pname, abs($by), $fwbw, $new_d, $busy));
     $ep->ntice('5091', array($pname, abs($by), $fwbw, $new_d, $busy));
     // 		$message = sprintf(' moves %.01f meters %s and is now on position %.01f meters%s', abs($by), $fwbw, $new_d, $busy);
     // 		$this->message($player, $message);
     // 		$this->getEnemyParty()->message($player, $message);
     return true;
 }