private function getMapDist($xVal, $yVal) { $midPoint = floor(ProcGen::GetMapSize() / 2); $xDistFromStart = abs($xVal - $midPoint); $yDistFromStart = abs($yVal - $midPoint); $dist = max($xDistFromStart, $yDistFromStart); return $dist; }
function checkBounds($x, $y) { $max = ProcGen::GetMapSize() - 1; $inBounds = true; if ($x < 0 || $x > $max) { $inBounds = false; } if ($y < 0 || $y > $max) { $inBounds = false; } return $inBounds; }
private function InitRandomEquipment($playerLevel, $distance) { // e.g. 0 at 0 distance, 10 at max distance $mapHalfSize = floor(ProcGen::GetMapSize() / 2); // 50 $boundary = floor($mapHalfSize / 10); // 10 $distanceFactor = floor($distance / $boundary); // NB: Can spawn both armour AND weapon. // Weapon $oneInHundred = rand(1, 100); if (true || $oneInHundred > 50) { $weaponName = NameGenerator::Weapon($playerLevel); $randomFactor = rand(-2, 2); $weaponLvl = rand($playerLevel, $playerLevel + $distanceFactor + $randomFactor); $weaponLvl = max(1, $weaponLvl); $this->addEquipment($weaponName, $weaponLvl, ShopEquipment::Weapon); } // Armour $oneInHundred = rand(1, 100); if ($oneInHundred > 50) { $armourName = NameGenerator::Armour($playerLevel); $randomFactor = rand(-2, 2); $armourLvl = rand($playerLevel, $playerLevel + $distanceFactor + $randomFactor); $armourLvl = max(1, $armourLvl); $this->addEquipment($armourName, $armourLvl, ShopEquipment::Armour); } }
function initMapSaveData($nick) { DEBUG_echo("initMapSave"); global $procGen; $initialSaveData = new MapSaveData(); $mapHalfSize = floor(ProcGen::GetMapSize() / 2); $x = $y = $mapHalfSize; $initialSaveData->playerX = $initialSaveData->playerY = $x; $map = new Map(); // Definitely do not spawn a monster in the first room. $procGen->GenerateRoomForMap($map, $x, $y, 1, true); $initialSaveData->map = $map; return $initialSaveData; }