Thread Tools Display Modes
04/28/20, 12:46 PM   #1
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,000
[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!
  Reply With Quote
Today, 04:30 PM   #2
Toirealach
AddOn Author - Click to view addons
Join Date: Sep 2020
Posts: 30
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
  Reply With Quote
Today, 05:04 PM   #3
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,000
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
  Reply With Quote

ESOUI » Developer Discussions » Wish List » [open] New API functions IsVampire() / GetVampireStage()


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off