<?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!');
Beispiel #2
0
<?php

$template->assign('PageTopic', 'Weapon Dealer');
$template->assignByRef('ThisLocation', SmrLocation::getLocation($var['LocationID']));
Beispiel #3
0
<?php

$template->assign('ViewAllLocationsLink', SmrSession::getNewHREF(create_container('skeleton.php', 'location_edit.php')));
require_once get_file_loc('SmrLocation.class.inc');
if (isset($var['location_type_id'])) {
    $location =& SmrLocation::getLocation($var['location_type_id']);
    if (isset($_REQUEST['save'])) {
        if ($_REQUEST['add_ship_id'] != 0) {
            $location->addShipSold($_REQUEST['add_ship_id']);
        }
        if ($_REQUEST['add_weapon_id'] != 0) {
            $location->addWeaponSold($_REQUEST['add_weapon_id']);
        }
        if ($_REQUEST['add_hardware_id'] != 0) {
            $location->addHardwareSold($_REQUEST['add_hardware_id']);
        }
        if (isset($_REQUEST['remove_ships']) && is_array($_REQUEST['remove_ships'])) {
            foreach ($_REQUEST['remove_ships'] as $shipTypeID) {
                $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);
            }
        }
Beispiel #4
0
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');
}
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;
}