function giveWeapon($monster, &$charData) { //--------------------------------------- // Barbarian trait: :D // global $traitMap; $isBarbarian = $traitMap->ClassHasTrait($charData, TraitName::DualWield); //--------------------------------------- $textOutput = ""; $monsterLevel = $monster->level; $weaponName = NameGenerator::Weapon($monsterLevel); $weaponLvl = lootLevel($monsterLevel); $currentWpnVal = $charData->weaponVal; // Only equip weapons that are better. if ($weaponLvl > $currentWpnVal) { $article = NameGenerator::GetArticle($weaponName); $textOutput = "You find {$article} {$weaponName} and equip it immediately"; if ($isBarbarian && $charData->weaponVal > $charData->weapon2Val) { $textOutput .= ", moving your {$charData->weapon} to your off-hand"; $charData->weapon2 = $charData->weapon; $charData->weapon2Val = $charData->weaponVal; } $textOutput .= "! "; $charData->weapon = $weaponName; $charData->weaponVal = $weaponLvl; } else { if ($isBarbarian && $weaponLvl > $charData->weapon2Val) { $article = NameGenerator::GetArticle($weaponName); $textOutput = "You find {$article} {$weaponName} and equip it immediately in your off-hand! "; $charData->weapon2 = $weaponName; $charData->weapon2Val = $weaponLvl; } else { $textOutput = giveGold($monster, $charData); } } return $textOutput; }
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); } }