<?php if (!$player->getSector()->hasLocation($var['LocationID'])) { create_error('That location does not exist in this sector'); } $weapon =& SmrWeapon::getWeapon($player->getGameID(), $var['WeaponTypeID']); // Are we buying? if (!isset($var['OrderID'])) { $location =& SmrLocation::getLocation($var['LocationID']); if (!$location->isWeaponSold($var['WeaponTypeID'])) { create_error('We do not sell that weapon here!'); } if ($weapon->getRaceID() != RACE_NEUTRAL && $player->getRelation($weapon->getRaceID()) < 300) { create_error('We are at WAR!!! Do you really think I\'m gonna sell you that weapon?'); } // do we have enough cash? if ($player->getCredits() < $weapon->getCost()) { create_error('You do not have enough cash to purchase this weapon!'); } // can we load such a weapon (power_level) if (!$ship->checkPowerLevel($weapon->getPowerLevel())) { create_error('Your ship doesn\'t have enough power to support that weapon!'); } if ($ship->getOpenWeaponSlots() < 1) { create_error('You can\'t buy any more weapons!'); } if ($weapon->getBuyerRestriction() == 2 && $player->getAlignment() > -100) { create_error('You can\'t buy evil weapons!'); } else { if ($weapon->getBuyerRestriction() == 1 && $player->getAlignment() < 100) { create_error('You can\'t buy good weapons!');
</option><?php } unset($Weapon); break; case 'Locations': ?> <option value="Bank">Any Bank</option> <option value="Bar">Any Bar</option> <option value="SafeFed">Any Safe Fed</option> <option value="Fed">Any Fed</option> <option value="HQ">Any Headquarters</option> <option value="UG">Any Underground</option> <option value="Hardware">Any Hardware Shop</option> <option value="Ship">Any Ship Shop</option> <option value="Weapon">Any Weapon Shop</option><?php $Locations =& SmrLocation::getAllLocations(); Sorter::sortByNumMethod($Locations, 'getName'); foreach ($Locations as &$Location) { ?> <option value="<?php echo $Location->getTypeID(); ?> "><?php echo $Location->getName(); ?> </option><?php } unset($Location); break; case 'Goods': $Goods =& Globals::getGoods();
<?php $template->assign('PageTopic', 'Weapon Dealer'); $template->assignByRef('ThisLocation', SmrLocation::getLocation($var['LocationID']));
function plotToFed(&$player, $plotToHQ = false) { debug('Plotting To Fed', $plotToHQ); if ($plotToHQ === false && $player->getSector()->offersFederalProtection()) { if (!$player->hasNewbieTurns() && !$player->hasFederalProtection() && $player->getShip()->hasIllegalGoods()) { //We have illegals and no newbie turns, dump the illegals to get fed protection. debug('Dumping illegals'); processContainer(dumpCargo($player)); } debug('Plotted to fed whilst in fed, switch NPC and wait for turns'); changeNPCLogin(); return true; } if ($plotToHQ === true) { return plotToNearest($player, SmrLocation::getLocation($player->getRaceID() + LOCATION_GROUP_RACIAL_HQS)); } return plotToNearest($player, SmrLocation::getLocation($player->getRaceID() + LOCATION_GROUP_RACIAL_BEACONS)); // return plotToNearest($player,$plotToHQ===true?'HQ':'Fed'); }
$location->removeShipSold($shipTypeID); } } if (isset($_REQUEST['remove_weapons']) && is_array($_REQUEST['remove_weapons'])) { foreach ($_REQUEST['remove_weapons'] as $weaponTypeID) { $location->removeWeaponSold($weaponTypeID); } } if (isset($_REQUEST['remove_hardware']) && is_array($_REQUEST['remove_hardware'])) { foreach ($_REQUEST['remove_hardware'] as $hardwareTypeID) { $location->removeHardwareSold($hardwareTypeID); } } $location->setFed(isset($_REQUEST['fed'])); $location->setBar(isset($_REQUEST['bar'])); $location->setBank(isset($_REQUEST['bank'])); $location->setHQ(isset($_REQUEST['hq'])); $location->setUG(isset($_REQUEST['ug'])); } $template->assignByRef('Location', $location); $template->assignByRef('Ships', AbstractSmrShip::getAllBaseShips($var['game_type_id'])); $template->assignByRef('Weapons', SmrWeapon::getAllWeapons($var['game_type_id'])); $db->query('SELECT * FROM hardware_type'); $hardware = array(); while ($db->nextRecord()) { $hardware[$db->getField('hardware_type_id')] = array('ID' => $db->getField('hardware_type_id'), 'Name' => $db->getField('hardware_name')); } $template->assignByRef('AllHardware', $hardware); } else { $template->assignByRef('Locations', SmrLocation::getAllLocations()); }
function addLocationToSector(SmrLocation &$location, SmrSector &$sector) { $fedBeacon =& SmrLocation::getLocation(LOCATION_TYPE_FEDERAL_BEACON); // if ($loc_id > 1 && $loc_id < 10) { // //get max loc #s for each type // $max = array(0,0,0,0,0,0,0,0,0,0); // foreach ($LOCATIONS as $id => $array) { // //skip fed beacon and "Random Bank Location" and such // if ($id >= 100) $type = floor($id / 100); // else continue; // //determine a range of this type of location (ie banks are 501-504) // if ($id > $max[$type]) $max[$type] = $id; // } // // //we need to insert random banks,ship shops, etc // $min = $loc_id * 100 + 1; //smallest ID // $max_s = $max[$loc_id]; //largest ID // $loc_id = mt_rand($min, $max_s); //get rand id // while (in_array($loc_id,$SPECIAL) || in_array($loc_id, $updateLoc[$sector])) $loc_id = mt_rand($min, $max_s); //check if this is an allowed id // } if ($sector->hasLocation($location->getTypeID())) { return false; } $sector->addLocation($location); //insert the location if ($location->isHQ()) { //only playable races have extra locations to add //Racial/Fed $linkedLocations =& $location->getLinkedLocations(); foreach ($linkedLocations as &$linkedLocation) { $sector->addLocation($linkedLocation); if ($linkedLocation->isFed()) { $fedBeacon =& $linkedLocation; } } unset($linkedLocation); //add Beacons to all surrounding areas (up to 2 sectors out) if (!$sector->offersFederalProtection()) { $sector->addLocation($fedBeacon); } //add beacon to this sector $visitedSectors = array(); $links = array('Up', 'Right', 'Down', 'Left'); $fedSectors = array(&$sector); $tempFedSectors = array(); for ($i = 0; $i < DEFAULT_FED_RADIUS; $i++) { foreach ($fedSectors as &$fedSector) { foreach ($links as $link) { if ($fedSector->hasLink($link) && !isset($visitedSectors[$fedSector->getLink($link)])) { $linkSector =& $sector->getLinkSector($link); if (!$linkSector->offersFederalProtection()) { $linkSector->addLocation($fedBeacon); } //add beacon to this sector $tempFedSectors[] =& $linkSector; $visitedSectors[$fedSector->getLink($link)] = true; } } } $fedSectors =& $tempFedSectors; $tempFedSectors = array(); } } return true; }