Ejemplo n.º 1
0
 public function ai_respond($chatcmd, $key, $args = null)
 {
     if (Shadowlang::hasLangRealNPC($this, $key)) {
         $message = Shadowlang::langNPC($this, $this->getChatPartner(), $key, $args);
     } else {
         $message = $key;
     }
     return $this->ai_act($chatcmd . ' ' . $message);
 }
Ejemplo n.º 2
0
 public static function onLoadLanguage()
 {
     $dir = Shadowrun4::getShadowDir();
     self::$LANG_NPC = array();
     # flush caches too.
     self::$LANG_QUEST = array();
     self::$LANG_LOCATION = array();
     self::$LANG_HELP = new GWF_LangTrans("{$dir}lang/help/shadowhelp");
     self::$LANG_ITEM = new GWF_LangTrans("{$dir}lang/item/shadowitems");
     self::$LANG_ITEM_UUID = new GWF_LangTrans("{$dir}data/itemuuid/itemuuid");
     self::$LANG_STAT_UUID = new GWF_LangTrans("{$dir}data/statuuid/statuuid");
     self::$LANG_EQ = new GWF_LangTrans("{$dir}lang/eq/eq");
     self::$LANG_VARS = new GWF_LangTrans("{$dir}lang/vars/vars");
     self::$LANG_VARIABLES = new GWF_LangTrans("{$dir}lang/variables/variables");
 }
Ejemplo n.º 3
0
 public static function init()
 {
     Dog_Log::debug(__METHOD__);
     static $inited = false;
     if ($inited === false) {
         $inited = true;
         Shadowlang::onLoadLanguage();
         Shadowrap::init();
         self::$sr_timestamp = GWF_CachedCounter::getCount('SR4_TIME');
         $path = self::getShadowDir();
         self::initCore($path);
         self::initCmds($path);
         Shadowcmd::init();
         self::initItems($path);
         // 			self::initQuests($path);
         self::initCityBases($path);
         self::initSpells($path);
         self::initCityQuests($path);
         self::initCityNPCs($path);
         self::initCityLocations($path);
         // 			self::initCities($path);
         self::initCityAfter();
         SR_Player::init();
         // 			require_once DOG_PATH.'Lamb_IRCFrom.php';
         // 			require_once DOG_PATH.'Lamb_IRCTo.php';
         if (defined('SL4_REALS')) {
             self::initRealNPCs();
         }
         Shadowcleanup::cleanup();
     }
 }
Ejemplo n.º 4
0
 /**
  * Turn a var into translated shortcut.
  * @param SR_Player $player
  * @param string $var
  * @return string
  */
 public static function translateVar(SR_Player $player, $var)
 {
     return self::shortcut($var, Shadowlang::getVarFile()->getTrans($player->getLangISO()));
 }
Ejemplo n.º 5
0
 public function getQuestDescription()
 {
     return $this->lang('descr', array(Shadowlang::displayItemnameS('BlackOrchid'), Shadowlang::displayItemnameS('WhiteOrchid')));
 }
Ejemplo n.º 6
0
 public final function getItemUUID()
 {
     return Shadowlang::getItemUUID($this);
 }
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
0
 public function partyRply($key, $args = NULL)
 {
     $player = $this->chat_partner;
     $p = $player->getParty();
     foreach ($p->getMembers() as $member) {
         $message = $member->lang('5085', array($this->getName(), Shadowlang::langNPC($this, $member, $key, $args)));
         $member->message($message);
     }
 }
Ejemplo n.º 9
0
 private static function createItemLangFile()
 {
     // 		printf("%s\n", __METHOD__);
     $langfile = Shadowlang::getItemfile();
     $items = SR_Item::getAllItems();
     usort($items, array('SR_Item', 'sort_type_asc'));
     $old_type = '';
     // 		printf("%s: sorted items...\n", __METHOD__);
     foreach (Dog_Lang::getISOCodes() as $iso) {
         $path = sprintf('%slang/item/shadowitems_%s.php', Shadowrun4::getShadowDir(), $iso);
         if (false === Common::isFile($path)) {
             continue;
         }
         $out = '<?php' . PHP_EOL;
         $out .= '$lang = array(' . PHP_EOL;
         foreach ($items as $item) {
             $item instanceof SR_Item;
             $type = $item->getItemType();
             if ($old_type !== $type) {
                 // 					printf("%s: New subsection %s\n", __METHOD__, $type);
                 $old_type = $type;
                 $out .= PHP_EOL;
                 $out .= '# ' . $type . PHP_EOL;
             }
             $key = $item->getName();
             if ($key === ($trans = $langfile->langISO($iso, $key))) {
                 // 					printf("%s: Unknown Key %s\n", __METHOD__, $key);
                 $out .= sprintf("'%s' => '%s',", $key, str_replace("'", '\\\'', $trans));
             } else {
                 // 					printf("%s: Old Key %s\n", __METHOD__, $key);
                 $out .= sprintf("'%s' => '%s',", $key, str_replace("'", '\\\'', $trans));
             }
             $out .= PHP_EOL;
             $key .= '__desc__';
             if ($key === ($trans = $langfile->langISO($iso, $key))) {
                 $out .= sprintf("'%s' => '%s',", $key, str_replace("'", '\\\'', $item->getItemDescription()));
             } else {
                 $out .= sprintf("'%s' => '%s',", $key, str_replace("'", '\\\'', $trans));
             }
             $out .= PHP_EOL;
         }
         $out .= ');' . PHP_EOL;
         $out .= '?>' . PHP_EOL;
         GWF_File::writeFile($path, $out);
     }
     return true;
 }
Ejemplo n.º 10
0
 public function getQuestDescription()
 {
     return $this->lang('descr', array(Shadowlang::displayItemNameS(Forest_Clearing::THESWORD)));
 }
Ejemplo n.º 11
0
 public function lang(SR_Player $player, $key, $args = NULL)
 {
     return Shadowlang::langLocation($this, $player, $key, $args);
 }