ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Wish List (https://www.esoui.com/forums/forumdisplay.php?f=177)
-   -   [open] New API functions IsVampire() / GetVampireStage() (https://www.esoui.com/forums/showthread.php?t=9116)

Baertram 04/28/20 12:46 PM

[open] New API functions IsVampire() / GetVampireStage()
 
Could we please get 2 new API functions. The Wererwolf functions already exist some years but for vampirism we got nothing.

Code:

IsVampire() -> Return boolean true/false
GetVampireStage() -> Return number:nilable vamprirism stage (or nil if not a vampire)

Many thanks!

Toirealach 05/08/24 04:30 PM

This is from VampRemind.lua which is one of the files in my Reminderz addon:

Code:

-- VampireStageType
NOT_A_VAMPIRE = 0
VAMPIRE_STAGE_1 = 135397
VAMPIRE_STAGE_2 = 135399
VAMPIRE_STAGE_3 = 135400
VAMPIRE_STAGE_4 = 135402

-- * IsVampire()
-- ** *bool* _isVampire_
function IsVampire()
        return (GetVampireStage() ~= NOT_A_VAMPIRE)
end

-- * GetVampireStage()
-- ** _Returns:_ *VampireStageType* _vampireStage_, *number:nilable* _timeEnding_, *string:nilable* _vampireStageName_, *string:nilable* _iconFileName_
function GetVampireStage()

        for n = 0, GetNumBuffs("player") do
                local buffName, timeStarted, timeEnding, _, _, iconFilename, _, _, abilityType, _, abilityId, _, _ = GetUnitBuffInfo("player", n)
                if (abilityId == VAMPIRE_STAGE_1) or (abilityId == VAMPIRE_STAGE_2) or (abilityId == VAMPIRE_STAGE_3) or (abilityId == VAMPIRE_STAGE_4) then
                        return abilityId, timeEnding, buffName, iconFilename
                end
        end

        return NOT_A_VAMPIRE, nil, nil, nil, nil
end


Baertram 05/08/24 05:04 PM

Thanks, have something similar in LibVampire I think, but have not updated it for a long while now ;)

Hint
You can easeand speed-up such ifs
Code:

if (abilityId == VAMPIRE_STAGE_1) or (abilityId == VAMPIRE_STAGE_2) or (abilityId == VAMPIRE_STAGE_3) or (abilityId == VAMPIRE_STAGE_4) then
by the help of a simple table with key = abilityId and value = boolean true:

Lua Code:
  1. local vampireStages = {
  2.  [VAMPIRE_STAGE_1] = true,
  3.  [VAMPIRE_STAGE_2] = true,
  4.  [VAMPIRE_STAGE_3] = true,
  5.  [VAMPIRE_STAGE_4] = true,
  6. }
  7. if vampireStages[abilityId] then


All times are GMT -6. The time now is 01:20 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI