示例#1
0
 public function onUpgradeB(SR_Player $player, array $args, $safe)
 {
     $pid = $player->getID();
     $safebit = $safe ? 'X' : 'Y';
     $old_msg = isset(self::$UPGRADE_CONFIRM[$pid . $safebit]) ? self::$UPGRADE_CONFIRM[$pid . $safebit] : '';
     unset(self::$UPGRADE_CONFIRM[$pid . $safebit]);
     $bot = Shadowrap::instance($player);
     if (count($args) !== 2) {
         $bot->reply(Shadowhelp::getHelp($player, $safe ? 'safeupgrade' : 'upgrade'));
         return false;
     }
     if (false === ($item = $player->getItem($args[0]))) {
         $bot->rply('1029');
         // 			$bot->reply('You don`t have that item.');
         return false;
     }
     if ($item instanceof SR_Mount) {
         /* thx noother */
     } elseif (!$item instanceof SR_Equipment || !$item->isItemStattable()) {
         $bot->rply('1158');
         // 			$bot->reply('The first item is not an equipment.');
         return false;
     }
     if (false === ($rune = $player->getInvItem($args[1]))) {
         $bot->rply('1029');
         // 			$bot->reply('You don`t have that rune.');
         return false;
     }
     if (!$rune instanceof SR_Rune) {
         $bot->rply('1160');
         // 			$bot->reply('The second item is not a rune.');
         return false;
     }
     $modsRune = $rune->getModifiers();
     if ($modsRune === NULL || count($modsRune) === 0) {
         $bot->reply('The rune has no modifiers. Somethings wrong! (BUG)');
         return false;
     }
     if (!$this->checkCombination($player, $item, $rune)) {
         // 			$bot->rply('1161');
         // 			$bot->reply('This item can not get this rune applied to it.');
         return false;
     }
     # Check if equipped mount is loaded with items. (thx tehron)
     if ($item instanceof SR_Mount) {
         if ($item->isEquipped($player)) {
             if (count($player->getMountInvSorted()) !== 0) {
                 $bot->rply('1164');
                 // 					$bot->reply("Please '#mount clean' before you '#upgrade' it.");
                 return false;
             }
         }
     }
     if (false === SR_Item::canMergeModifiersLength($item, $rune)) {
         $bot->rply('1165');
         // 			$bot->reply('The item string would get too long with another modifier.');
         return false;
     }
     $mods = SR_Item::mergeModifiers($item->getItemModifiersB(), $rune->getItemModifiersB());
     $luck = $player->get('luck');
     $luck = Common::clamp($luck, 0, 30);
     $luckmod = 0.35;
     $luckmod -= $luck * 0.005;
     $fail = SR_Rune::calcFailChance($mods) * $luckmod * $this->getUpgradeFailModifier();
     $break = SR_Rune::calcBreakChance($mods) * $luckmod * $this->getUpgradeBreakModifier();
     $price_u = $this->calcUpgradePrice($player, $rune->getItemPriceStatted());
     $dpu = Shadowfunc::displayNuyen($price_u);
     $fail = round(Common::clamp($fail, 5, 85), 2);
     $break = round(Common::clamp($break, 1, 50), 2);
     if ($safe) {
         $fail -= 5;
         $break = 0;
     }
     ## Confirm
     $msg = implode(' ', $args);
     if ($msg !== $old_msg) {
         self::$UPGRADE_CONFIRM[$pid . $safebit] = $msg;
         return $player->msg('5211', array(Shadowfunc::displayNuyen($price_u), $item->displayFullName($player), $rune->displayFullName($player), $fail, $break));
         // 			return $player->message(sprintf(
         // 				'The smith examines your items ... "It would cost you %s to upgrade your %s with %s. The fail chance is %.02f%% and the break chance is %.02f%%. Please retype to confirm.',
         // 				Shadowfunc::displayNuyen($price_u), $item->getItemName(), $rune->getItemName(), $fail, $break
         // 			));
     }
     if (!$player->hasNuyen($price_u)) {
         $bot->rply('1063', array($dpu, $player->displayNuyen()));
         // 			$bot->reply(sprintf('The smith says: "I am sorry chummer, the upgrade would cost you %s."', $dpu));
         return false;
     }
     # Safe mode
     if ($safe) {
         $break = 0;
         if (false === ($oil = $player->getInvItemByName('MagicOil'))) {
             $bot->rply('1187', array(Shadowlang::displayItemNameS('MagicOil')));
             return false;
         }
         if (!$oil->useAmount($player, 1)) {
             $bot->reply('DB Error 19');
             return false;
         }
     }
     $player->msg('5212');
     // 		$player->message('The smith takes your items and goes to work...');
     $player->removeItem($rune);
     $rune->delete();
     if (Shadowfunc::dicePercent($fail)) {
         if (Shadowfunc::dicePercent($break)) {
             $player->removeItem($item);
             $item->delete();
             $bot->rply('5213', array($item->displayFullName($player), $rune->displayFullName($player)));
             // 				$bot->reply(sprintf('The upgrade horrible failed and the item and the rune is lost. The smith is very sorry and you don`t need to pay any money.'));
         } else {
             $price_f = $this->calcUpgradePrice($player, 0);
             $player->pay($price_f);
             $dpf = Shadowfunc::displayNuyen($price_f);
             $bot->rply('5214', array($dpf, $rune->displayFullName($player)));
             // 				$bot->reply(sprintf('The upgrade failed and the rune is lost. You only need to pay %s for the work.', $dpf));
         }
     } else {
         $player->pay($price_u);
         $old_name = $item->displayFullName($player);
         $item->addModifiers($rune->getItemModifiersB(), true);
         $item->addModifiers($rune->getItemModifiersA($player), true);
         $bot->rply('5215', array($dpu, $item->displayFullName($player), $old_name, $rune->displayFullName($player)));
         // 			$bot->reply(sprintf('The upgrade succeeded. You pay %s and the smith presents you a fine %s.', $dpu, $item->getItemName()));
     }
     $player->modify();
     return true;
 }
示例#2
0
 public function getQuestDescription()
 {
     return $this->lang('descr', array(Shadowlang::displayItemNameS(Forest_Clearing::THESWORD)));
 }