Utilizador:The Nerevarine/Fast Access

A UESPWiki – Sua fonte de The Elder Scrolls desde 1995

Fast Access

Fast Access Tools and Links for my convenience

General

The Elder Scrolls Online (ESO)

Vendors

Other NPC of Interest

Named Usable Items

Sets

ESO - XML logging

Schema Definitions

Schema definitions follow the data structures gained from the pubic part of the ESO API as close as possible.

Transformations

NPC Data

Originally I planned to provide the xslt files i used earlier to transform the xml files into a wikisyntax template. I realised that there would be much confusing explanation how to fill the gaps, when to remove what part, when a certain part would be inappropriate... and so on. So i wrote a small GUI tool to support that transformation and easy filling of the data gaps.

It is still highly beta (missing some "you have forgotten to.." and "you can't do that without..." checks), but used correctly it fulfills its task smoothly. Don't forget to read the README.txt. The software comes of course without any warranty and if you decide to use it, you do it on your own risk. Ah yes, and Java 7 will be required to run it. So if you still want to give it a try: The Nerevarines Tool Set (zip file, ~430 KB).

lua data acquisition (logger)

I decided for a modular approach, so the core framework handles the general events and has methods usable for all modules, while the modules take care of the data acquisition of their respective type. I have not figured out yet how to separate and dynamically load the modules from different files with that clumsy script "language". so the first module and the core comes together in one lua script:

the xml file

<GuiXml>
    <Controls>
        <TopLevelControl name="The Nerevarine's Tool Set" hidden="true" movable="true">
            <OnUpdate>
                TNTS.onUpdate()
            </OnUpdate>
        </TopLevelControl>
    </Controls>
</GuiXml>

I admit, i have no clue if that above is really necessary or optimal for an AddOn without GUI elements, but it's what i got from the examples i looked at and it works, so... *shrug*

the txt file

## Title: The Nerevarine's Tool Set
## Author: The Nerevarine
## Version: 0.1
## APIVersion: 100004
## SavedVariables: tntsLog

TNTS.lua
TNTS.xml

the lua file

TNTS = { NPCM = {} }

TNTS.NPCM.skippedNpcNames = {
  Familiar = true,
  Cat = true,
  Rat = true,
  Lizard = true,
  Mudcrab = true,
  Horse = true,
  Snake = true,
  Scorpion = true,
  Beetle = true,
  Fox = true,
  Goat = true,
  Chicken = true,
  Dog = true,
  Rabbit = true,
  Clannfear = true,
  Frog = true,
  Deer = true,
  Spider = true,
  Torchbug = true,
  Pig = true, 
  Sheep = true,
  Cow = true,
  Butterfly = true,
  Squirrel = true,
  Centipede = true,
  Fleshflies = true,
  Monkey = true,
  Wasp = true,
  Honor = true,
  Scuttler = true,
  Scrib = true,
  ["Bantam Guar"] = true,
  ["Razak's Opus"] = true,
  ["Draft Horse"] = true,
  ["Light Horse"] = true,
  ["Restoring Twilight"] = true,
  ["Winged Twilight"] = true,
  ["Twilight Matriarch"] = true,
  ["Volatile Familiar"] = true,
  [""] = true
}

TNTS.NPCM.reactionTypeNames = {
    [UNIT_REACTION_DEFAULT]     = "default",
    [UNIT_REACTION_INTERACT]    = "interact",
    [UNIT_REACTION_DEAD]        = "dead",
    [UNIT_REACTION_HOSTILE]     = "hostile",
    [UNIT_REACTION_NEUTRAL]     = "neutral",
    [UNIT_REACTION_FRIENDLY]    = "friendly",
    [UNIT_REACTION_PLAYER_ALLY] = "pc ally",
    [UNIT_REACTION_NPC_ALLY]    = "ally"
}

TNTS.NPCM.difficultyNames = {
    [MONSTER_DIFFICULTY_NONE]   = "none",
    [MONSTER_DIFFICULTY_EASY]   = "easy",
    [MONSTER_DIFFICULTY_NORMAL] = "normal",
    [MONSTER_DIFFICULTY_HARD]   = "hard",
    [MONSTER_DIFFICULTY_DEADLY] = "deadly"
}

function TNTS.NPCM.onReticleTargetChanged(eventCode)
    if (not TNTS.loaded) then return end
    if (not IsUnitPlayer("reticleover")) then
        local name = GetUnitName("reticleover")
        if (not TNTS.NPCM.skippedNpcNames[name]) then
            local msg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            msg = msg .. "<npc xmlns=\"http://org.example.esologging/npc\"\n"
            msg = msg .. "     xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
            msg = msg .. "     xsi:schemaLocation=\"http://org.example.esologging/npc NPC.xsd\"\n"
            msg = msg .. "     name=\"" .. name .. "\"\n"
    
            msg = msg .. "     level=\"" .. GetUnitLevel("reticleover") .. "\"\n"

            local gender = GetUnitGender("reticleover")
            local genderName
            if (gender == 0) then
              genderName = "Neutrum"
            elseif (gender == 1) then
              genderName = "Female"
            elseif (gender == 2) then
              genderName = "Male"
            else
              genderName = gender
            end
            msg = msg .. "     gender=\"" .. genderName .. "\"\n"

            msg = msg .. "     difficulty=\"" .. TNTS.NPCM.difficultyNames[GetUnitDifficulty("reticleover")] .. "\"\n"

            msg = msg .. "     reaction=\"" .. TNTS.NPCM.reactionTypeNames[GetUnitReaction("reticleover")] .. "\"\n"
            
            msg = msg .. "     trader=\"" .. TNTS.toString(CanUnitTrade("reticleover")) .. "\"\n"

            msg = msg .. "     attackable=\"" .. TNTS.toString(IsUnitAttackable("reticleover")) .. "\"\n"

            msg = msg .. "     dead=\"" .. TNTS.toString(IsUnitDead("reticleover")) .. "\"\n"

            msg = msg .. "     type=\"" .. GetUnitType("reticleover") .. "\"\n"

            local curH, maxH, effH = GetUnitPower("reticleover", POWERTYPE_HEALTH)
            msg = msg .. "     health=\"" .. maxH .. "\"\n"

            local curM, maxM, effM = GetUnitPower("reticleover", POWERTYPE_MAGICKA)
            msg = msg .. "     magicka=\"" .. maxM .. "\"\n"

            local curS, maxS, effS = GetUnitPower("reticleover", POWERTYPE_STAMINA)
            msg = msg .. "     stamina=\"" .. maxS .. "\"\n"

            local follower = IsUnitFriendlyFollower("reticleover");
            msg = msg .. "     follower=\"" .. TNTS.toString(follower) .. "\">\n"

            local caption = GetUnitCaption("reticleover")
            if (caption and caption ~= "") then
                msg = msg .. "    <caption>" .. TNTS.xmlEscape(caption) .. "</caption>\n"
            end

            local rawName = GetRawUnitName("reticleover")
            if (rawName and rawName ~= "") then
                msg = msg .. "    <raw>" .. TNTS.xmlEscape(rawName) .. "</raw>\n"
            end

            local class = GetUnitClass("reticleover")
            msg = msg .. "    <class id=\"" .. GetUnitClassId("reticleover") .. "\""
            if (class and class ~= "") then
                msg = msg .. ">" .. TNTS.xmlEscape(class) .. "</class>\n"
            else
                msg = msg .. " />\n"
            end

            local zone = GetUnitZone("reticleover")
            if (zone and zone ~= "") then
                msg = msg .. "    <zone>" .. TNTS.xmlEscape(zone) .. "</zone>\n"
            end

            local location = GetPlayerLocationName()
            if (location and location ~= "") then
                msg = msg .. "    <location>" .. TNTS.xmlEscape(location) .. "</location>\n"
            end

            local drowntime = GetUnitDrownTime("reticleover")
            if (drowntime) then
                msg = msg .. "    <drowntime>" .. TNTS.xmlEscape(drowntime) .. "</drowntime>\n"
            end

            local race = GetUnitRace("reticleover")
            if (race and race ~= "") then
                msg = msg .. "    <race>" .. TNTS.xmlEscape(race) .. "</race>\n"
            end

            local title = GetUnitTitle("reticleover")
            if (title and title ~= "") then
                msg = msg .. "    <title>" .. TNTS.xmlEscape(title) .. "</title>\n"
            end
            
            msg = msg .. "</npc>\n"
            
            local save = savedVars["TNTS"]
            if (not save.NPCM) then
                save.NPCM = {}
            end
            if (not save.NPCM[name]) then
                save.NPCM[name] = msg
                savedVars["TNTS"] = save
            end
        end
    end
end

function TNTS.NPCM.onPlayerActivated ( ... )
    EVENT_MANAGER:RegisterForEvent ( "NPCModule" , EVENT_RETICLE_TARGET_CHANGED      , TNTS.NPCM.onReticleTargetChanged )
end

-- The Nerevarine's Tool Set core --

TNTS.loaded = false

function TNTS.toString(boolVal)
  local stringVal = "false"
  if (boolVal) then stringVal = "true" end
  return stringVal
end

function TNTS.xmlEscape (text)
    local result = string.gsub(text,"&","&")
    result = string.gsub(result,"<","<")
    return string.gsub(result,">",">")
end

function TNTS.onPlayerActivated ( ... )
    if (TNTS.loaded) then return end

    TNTS.NPCM.onPlayerActivated()
    TNTS.loaded = true
end

function TNTS.NPCM.onUpdate ()
    if ( not AFAisLoaded ) then return end
end

function TNTS.onAddonLoaded ( eventCode , addonName )
    if ( addonName ~= "TNTS" ) then return end
    local default = { TNTS = {}}
    savedVars = ZO_SavedVars:New("tntsLog", 1, nil, default, nil)
end

EVENT_MANAGER:RegisterForEvent     ( "TNTS" , EVENT_ADD_ON_LOADED               , TNTS.onAddonLoaded          )
EVENT_MANAGER:RegisterForEvent     ( "TNTS" , EVENT_PLAYER_ACTIVATED            , TNTS.onPlayerActivated      )