Anonymous

Module:CombatAreas: Difference between revisions

From Melvor Idle
Update for v1.3
(_getAreaRequirements: Resolve cases where requirement text returned could contain empty lines)
(Update for v1.3)
Line 11: Line 11:
["combat"] = 'combatAreas',
["combat"] = 'combatAreas',
["dungeon"] = 'dungeons',
["dungeon"] = 'dungeons',
["slayer"] = 'slayerAreas'
["slayer"] = 'slayerAreas',
["depth"] = 'abyssDepths'
}
}


Line 24: Line 25:
end
end


function p.getAreaByID(id, type)
function p.getAreaByID(id, areaType)
local areaType = areaMap[type]
for aType, areaKey in pairs(areaMap) do
if areaType ~= nil then
if areaType == nil or areaType == aType then
return GameData.getEntityByID(areaType, id)
local area = GameData.getEntityByID(areaKey, id)
if area ~= nil then
return area
end
end
end
end
end
end
Line 138: Line 143:
end
end


function p.getMonsterAreas(monsterID)
function p._isMonsterInArea(monster, area)
return (
Shared.contains(area.monsterIDs, monster.id)
-- Check for Lair of the Spider Queen random spiders
or (
Shared.contains(area.monsterIDs, 'melvorTotH:RandomSpiderLair')
and Shared.contains(GameData.rawData.spiderLairMonsters, monster.id)
)
)
end
 
function p._getMonsterAreas(monster)
-- Special handling for Lair of the Spider Queen, which has a random list of enemies
-- Special handling for Lair of the Spider Queen, which has a random list of enemies
local randomSpiderCheck = Shared.contains(GameData.rawData.spiderLairMonsters, monsterID)
local randomSpiderCheck = Shared.contains(GameData.rawData.spiderLairMonsters, monster.id)
return p.getAreas(
return p.getAreas(
function(area)
function(area)
return Shared.contains(area.monsterIDs, monsterID) or
return p._isMonsterInArea(monster, area)
(randomSpiderCheck and Shared.contains(area.monsterIDs, 'melvorTotH:RandomSpiderLair'))
end)
end)
end
end