commit d8d93faab91a97cedacad8afde30940629b84325 Author: anonymous Date: Thu Aug 3 09:10:41 2023 +0200 up diff --git a/Dare.lua b/Dare.lua new file mode 100644 index 0000000..04e2013 --- /dev/null +++ b/Dare.lua @@ -0,0 +1,9 @@ +-- slash command /dare as addon entrypoint +SLASH_DARE1 = "/dare" +SlashCmdList["DARE"] = function(msg) + UIErrorsFrame:AddMessage(spirits.distances(player)) +end + + + + diff --git a/Dare.toc b/Dare.toc new file mode 100644 index 0000000..5fb510a --- /dev/null +++ b/Dare.toc @@ -0,0 +1,11 @@ +## Interface: 20400 +## Title: Dare +## Notes: Shows distance from nearest Spirit Healer +## Author: L +## Version: 0.0.2 + +Dare.lua + +Locations.lua +Player.lua +Spirits.lua \ No newline at end of file diff --git a/Locations.lua b/Locations.lua new file mode 100644 index 0000000..e6b3312 --- /dev/null +++ b/Locations.lua @@ -0,0 +1,57 @@ + +-- spirit healer location database +-- not 100% correct, got it from a WoTLK website +locations = { + "Blasted Lands", {{51.1,12.1},{51.3,55.6}}, + "Duskwood", {{75.1,59},{20,49.2},{48.8,62.3}}, + "Swamp of Sorrows", {{50.3,62.4},{82.8,45.7},{15.7,47.2}}, + "Westfall", {{51.7,49.7},{37.5,78},{36,24.7}}, + "Redridge Mountains", {{20.8,56.6},{66.2,62.2},{34,42.5}}, + "Burning Steppes", {{64.1,24.1},{37.1,45.5},{71.8,49}}, + "Badlands", {{8.4,55.3},{56.7,23.7},{56.7,73.3}}, + "Loch Modan", {{32.6,47},{64.7,45.6}}, + "Wetlands", {{11,43.8},{49.3,41.8},{33,29.2},{59.4,66.6},{73.3,43.4}}, + "Arathi Highlands", {{48.8,55.6},{32.8,50.5},{64.4,49.2}}, + "Hillsbrad Foothills", {{51.8,52.5},{64.5,19.7},{79.6,60.9},{29.7,45.6}}, + "The Hinterlands", {{73.1,68.2},{16.9,44.5},{58.5,34.6},{38.1,64.9}}, + "Western Plaguelands", {{45,86},{65.8,74.2},{59.7,53.2},{49.8,24.7}}, + "Tirisfal Glades", {{82,69.6},{30.8,64.9},{56.2,49.4},{79,41},{50.1,68.5}}, + "Un'Goro Crater", {{80.3,50.3},{50,56},{45.3,7.6},{50.6,6}}, + "Tanaris", {{53.9,28.8},{63.6,49.4},{69,40.7},{49.4,59},{36.3,69},{40.5,40.7}}, + "Thousand Needles", {{68.7,53.3},{30.6,23},{43.9,47.6},{77.7,73.3}}, + "Feralas", {{31.8,48.2},{54.8,48.1},{73,44.5},{57.4,68.3},{83.8,42.6},{45.5,20.8}}, + "Mulgore", {{42.6,78.1},{46.5,55.5},{61.6,71.6},{62,26.2}}, + "The Barrens", {{45.3,61},{60.2,39.7},{50.7,32.6},{45.8,82.7},{42.7,21.5},{51,12},{56.1,51.9},{47,45.8},{58.6,19.8}}, + "Desolace", {{50.4,62.9},{30.6,74.4},{55.7,80.8},{72.3,67},{66.9,31},{38.2,30.2}}, + "Thunder Bluff", {{56.7,19.1}}, + "Durotar", {{57.2,73.3},{44.2,69.4},{53.5,44.5},{47.4,17.9}}, + "Stonetalon Mountains", {{57.5,61.3},{40.3,5.6},{36.4,75.2},{72.6,50},{45,37.5}}, + "Ashenvale", {{80.7,58.4},{40.5,52.8},{22.9,45.3},{59.5,61.8}}, + "Azshara", {{14,78.6},{54.3,71.5},{70.4,16.1},{45.2,30.2},{32.8,63.2}}, + "Felwood", {{56.8,87},{49.5,31.1}}, + "Darkshore", {{43.6,92.4},{41.8,36.6}}, + "Winterspring", {{61.5,35.4},{29,43},{62.7,61.3},{53.3,16.3},{45.5,40.5},{55.9,86.1}}, + "Moonglade", {{62.2,70.1}}, + "Deadwind Pass", {{40,74.2}}, + "Undercity", {{68.2,9.1}}, + "Wintergrasp", {{64.5,70.7},{72.3,29},{28.9,31.1},{36.8,69.8},{48.2,9},{68.2,31.2},{20.8,34.5},{50,13.7}}, + "Sholazar Basin", {{24.9,57.3},{57.9,35},{33.5,84.9},{76.7,60.9},{40.4,35.8},{47.7,60.2},{29.5,32},{55.8,77.7}}, + "Zul'Drak", {{20.2,63.4},{37.4,59},{84.1,31.6},{70.1,64.7},{53.8,56.4},{47.2,81.9},{30.7,73}}, + "Elwynn Forest", {{39.5,60.5},{49.7,42.5},{83.6,69.8},{61.6,70.1}}, + "Ghostlands", {{43.9,25.7},{61.5,57},{80.4,70.1}}, + "Teldrassil", {{56.2,63.3},{58.7,42.3},{56,92}}, + "Darnassus", {{77.7,25.9}}, + "Eversong Woods", {{48,49.5},{38.2,17.6},{60,64},{44.3,71.2}}, + "Azuremyst Isle", {{77.7,48.8},{47.2,55.7},{39.2,19.7},{28.3,25.5}}, + "Bloodmyst Isle", {{58.1,57.7},{30.1,45.9}}, + "Dustwallow Marsh", {{63.6,42.4},{39.5,31.4},{41.2,74.4},{46.6,57.1},{50,72.1}}, + "Alterac Mountains", {{42.9,38}}, + "Isle of Quel'Danas", {{46.6,32.7}}, + "Borean Tundra", {{45.1,53.8},{47.7,34.9},{30.6,33.3},{56.1,17.6},{50.5,10},{82,48.3},{77.8,34.4},{33.2,53.5},{56.9,62.9},{73.8,48.3}}, + "Howling Fjord", {{69.5,32.7},{73.9,59.4},{59.1,50},{58.4,60.7},{55.8,43.6},{37.8,28.8},{26.3,59.2},{38.1,74.6},{45,47.8},{53.8,21.7},{75.9,29.6},{75.2,72.1},{53.8,75.9},{72.9,13.2}}, + "Plaguelands: The Scarlet Enclave", {{54.5,34.3},{54.9,57},{39.2,46.1}}, + "Grizzly Hills", {{16.6,69},{33.7,56.6},{59.8,33.3},{23,44.3},{32.9,73.8},{47.6,34.1},{16.6,31.5},{70.6,40.3}}, + "Crystalsong Forest", {{76.6,80.1},{28.8,34.2},{74.7,50.2}}, + "Icecrown", {{85.3,80.3},{41.1,29.5},{52.3,52.6},{75.2,36.8},{27.9,54.4},{79.8,23},{53.9,71.3}}, + "The Storm Peaks", {{27.8,65.8},{42.5,24.7},{60.5,48.1},{39.9,44.4},{72.7,57.7},{54.3,49.9},{29,38.3},{33.7,68.6},{42.6,79.4},{46,65.6}} +} diff --git a/Player.lua b/Player.lua new file mode 100644 index 0000000..1e31c21 --- /dev/null +++ b/Player.lua @@ -0,0 +1,25 @@ + +-- player module +player = {} + +-- get player's current zone +function player.zone() + return GetZoneText() +end + +-- get player name +function player.name() + return UnitName("player") +end + +-- get player's X position +function player.x() + local x, y = GetPlayerMapPosition("player") + return tonumber(string.format("%.2f", (100 * x))) +end + +-- get player's Y position +function player.y() + local x, y = GetPlayerMapPosition("player") + return tonumber(string.format("%.2f", (100 * y))) +end diff --git a/Spirits.lua b/Spirits.lua new file mode 100644 index 0000000..df609e0 --- /dev/null +++ b/Spirits.lua @@ -0,0 +1,49 @@ + +-- spirits module +spirits = {} + +-- finds all spirit healers by given zone +function spirits.find(zone) + for i, v in pairs(locations) do + if i % 2 ~= 0 then + if v == zone then + return locations[i+1] + end + end + end + + return nil +end + +-- determine given player's distance to spirit healers in resolved zone +function spirits.distances(player) + + local zone = player.zone() + local locs = spirits.find(zone) + + if nil == locs then + return string.format("No spirits found for zone: %s", zone) + end + + local msg = "" + for j, coords in pairs(locs) do + x, y = unpack(coords) + dx = math.abs(player.x() - x) + dy = math.abs(player.y() - y) + + dist = math.max(dx, dy) + color = "cffFF0000" + + if dist < 3 then + color = "cff00FF00" + elseif dist < 10 then + color = "cffFFFF00" + else + color = "cffFF0000" + end + + msg = msg .. string.format("|%s%.2f|r away from %d", color, dist, j) .. ";" + end + + return msg +end