private function checkNPCLang(SR_NPC $npc) { if ($npc instanceof SR_TalkingNPC) { $npc->setChatPartner(Shadowrun4::getDummyPlayer()); $npc->langNPC('default'); } }
public function onCast(SR_Player $player, array $args, $wanted_level = true) { if ($this instanceof SR_CombatSpell) { if ($this->mode === self::MODE_BREW) { } elseif (!$player->isFighting()) { $player->msg('1052', array($this->getName())); // $player->message(sprintf('The spell %s works in combat only.', $this->getName())); return false; } elseif (count($args) === 0) { $members = $player->getEnemyParty()->getMembers(); if (count($members) === 0) { $player->msg('1052', array($this->getName())); return false; } $member = $members[array_rand($members)]; $args[] = $member->getEnum(); // $args[] = rand(1, $player->getEnemyParty()->getMemberCount()); } } else { if (count($args) === 0) { $args[] = $player->getName(); } } if ($this->mode === self::MODE_BREW) { # Dummy player $target = Shadowrun4::getDummyPlayer(); } elseif (false === ($target = $this->getTarget($player, $args))) { return false; } $level = $this->getLevel($this->getCaster()); if ($this->mode === self::MODE_BREW) { $level = $wanted_level; } elseif ($wanted_level !== true) { $wanted_level = (int) $wanted_level; if ($wanted_level < 0) { $player->msg('1053'); // $player->message('You cannot cast a spell with a level smaller than 0.'); return false; } elseif ($wanted_level > $level) { $player->msg('1054', array($this->getName(), $wanted_level, $level)); // $player->message(sprintf('You cannot cast %s level %s because your spell level is only %s.', $this->getName(), $wanted_level, $level)); return false; } else { $level = $wanted_level; } } $mp_faktor = $this->mode === self::MODE_BREW ? 1.5 : 1.0; $need = round($this->getManaCost($player, $level) * $mp_faktor, 1); $need = Common::clamp($need, 1, 1000000); $have = $player->getMP(); if ($need > $have && false === $this->isPotionMode()) { $player->msg('1055', array($need, $this->getName(), $level, $have)); // $player->message(sprintf('You need %s MP to cast %s, but you only have %s.', $need, $this->getName(), $have)); return false; } $hits = $this->dice($this->getCaster(), $target, $level); echo "!!! CASTED {$hits} hits !!!\n"; $busy = ''; if ($player->isFighting()) { $busy = Shadowfunc::displayBusy($player->busy($this->getCastTime($level))); } // if ($hits < $target->get('essence')) // { // $waste = round($need/2, 1); // $player->healMP(-$waste); // $player->msg('1056', array($this->getName(), $waste, $busy)); // // $player->message(sprintf('You failed to cast %s. %s MP wasted.%s', $this->getName(), $waste, $busy)); // return false; // } if (false === $this->isPotionMode()) { $player->healMP(-$need); } if ($this->mode === self::MODE_BREW) { return true; } return $this->cast($player, $target, $level, $hits, $player); }
private static function createItemDataFile() { $out = '<?php' . "\n\$lang = array(\n"; $player = Shadowrun4::getDummyPlayer(); $data = array(); foreach (SR_Item::getAllItems() as $item) { $item instanceof SR_Item; $data[(int) $item->getItemUUID()] = $player->lang($item->displayPacked($player)); } ksort($data); foreach ($data as $uuid => $type) { $out .= sprintf("'%d'=>'%s',\n", $uuid, $type); } $out .= ");\n?>\n"; $outfile = Shadowrun4::getShadowDir() . 'data/itemdata/itemdata_en.php'; @mkdir(dirname($outfile), 0700, true); file_put_contents($outfile, $out); return true; }
public function checkLocation() { foreach ($this->getSubwayTargets(Shadowrun4::getDummyPlayer()) as $data) { $target = $data[0]; if (false === ($location = Shadowrun4::getLocationByTarget($target))) { die(sprintf('The subway %s has an invalid target: %s.', $this->getName(), $target)); } } }
public function checkLocation() { $player = Shadowrun4::getDummyPlayer(); $items = $this->getStoreItems($player); foreach ($items as $data) { $iname = $data[0]; if (false === SR_Item::createByName($iname, 1, false)) { die(sprintf('%s has an invalid item: %s.', $this->getName(), $iname)); } } return parent::checkLocation(); }
/** * Validate if all NPC exist. */ private function checkLocationNPCs() { # Dummy player $player = Shadowrun4::getDummyPlayer(); # Validate talking NPCs foreach ($this->getNPCS($player) as $tt => $classname) { if (false === ($npc = Shadowrun4::getNPC($classname))) { die(sprintf('Location %s is missing talking NPC %s.', $this->getName(), $classname)); return false; } } return true; }