Загрузить файлы в «/»
This commit is contained in:
+46
-5
@@ -94,6 +94,18 @@ local function ResizeToText()
|
||||
frame:SetHeight(height)
|
||||
end
|
||||
|
||||
-- While the player is flagged AFK, the addon makes no pet queries at all.
|
||||
-- On some servers (seen on OctoWoW) pet API calls count as player activity,
|
||||
-- which clears the AFK flag and makes it flicker on/off while standing still.
|
||||
-- Checks simply resume on the first tick after the AFK flag is gone.
|
||||
local chatAFK = false -- fallback if the client has no UnitIsAFK
|
||||
local function IsPlayerAFK()
|
||||
if UnitIsAFK then
|
||||
return UnitIsAFK("player") and true or false
|
||||
end
|
||||
return chatAFK
|
||||
end
|
||||
|
||||
-- Reads the pet's happiness. 1 = unhappy, 2 = content, 3 = happy.
|
||||
-- Anything below "happy" is treated as hungry.
|
||||
local function UpdateHunger()
|
||||
@@ -241,13 +253,23 @@ driver:SetScript("OnUpdate", function()
|
||||
loyaltyElapsed = loyaltyElapsed + arg1
|
||||
hungerElapsed = hungerElapsed + arg1
|
||||
|
||||
-- Work at most once per second.
|
||||
if loyaltyElapsed < LOYALTY_INTERVAL then
|
||||
return
|
||||
end
|
||||
loyaltyElapsed = 0
|
||||
|
||||
-- AFK: touch nothing. hungerElapsed keeps growing, so the first tick after
|
||||
-- the AFK flag is gone runs a full hunger check right away.
|
||||
if IsPlayerAFK() then
|
||||
return
|
||||
end
|
||||
|
||||
if hungerElapsed >= GetHungryInterval() then
|
||||
hungerElapsed = 0
|
||||
loyaltyElapsed = 0
|
||||
CheckFeeding()
|
||||
CheckHunger()
|
||||
elseif loyaltyElapsed >= LOYALTY_INTERVAL then
|
||||
loyaltyElapsed = 0
|
||||
else
|
||||
CheckFeeding()
|
||||
UpdateDisplay()
|
||||
end
|
||||
@@ -257,10 +279,22 @@ driver:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
driver:RegisterEvent("UNIT_PET")
|
||||
driver:RegisterEvent("UNIT_AURA")
|
||||
driver:RegisterEvent("PLAYER_REGEN_ENABLED") -- left combat
|
||||
driver:RegisterEvent("CHAT_MSG_SYSTEM") -- only used for the AFK fallback
|
||||
|
||||
driver:SetScript("OnEvent", function()
|
||||
if event == "CHAT_MSG_SYSTEM" then
|
||||
if arg1 then
|
||||
if string.find(arg1, "now AFK", 1, true) then
|
||||
chatAFK = true
|
||||
elseif string.find(arg1, "no longer AFK", 1, true) then
|
||||
chatAFK = false
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if event == "UNIT_AURA" then
|
||||
if isHunter and arg1 == "pet" then
|
||||
if isHunter and arg1 == "pet" and not IsPlayerAFK() then
|
||||
CheckFeeding()
|
||||
end
|
||||
return
|
||||
@@ -289,6 +323,13 @@ driver:SetScript("OnEvent", function()
|
||||
return
|
||||
end
|
||||
|
||||
-- While AFK, don't query the pet: just make sure the next non-AFK tick
|
||||
-- runs a hunger check.
|
||||
if IsPlayerAFK() then
|
||||
hungerElapsed = GetHungryInterval()
|
||||
return
|
||||
end
|
||||
|
||||
-- Entering world, pet change, or leaving combat: check hunger right away.
|
||||
hungerElapsed = 0
|
||||
CheckHunger()
|
||||
@@ -335,7 +376,7 @@ SlashCmdList["ADEPET"] = function(msg)
|
||||
DEFAULT_CHAT_FRAME:AddMessage("AdePet debug: GetPetHappiness = " .. tostring(happiness) .. " (" .. type(happiness) .. "), " .. tostring(damage) .. ", " .. tostring(rate))
|
||||
local loyalty = GetPetLoyalty()
|
||||
DEFAULT_CHAT_FRAME:AddMessage("AdePet debug: GetPetLoyalty = " .. tostring(loyalty) .. " (" .. type(loyalty) .. "), parsed level = " .. tostring(ParseLoyalty(loyalty)))
|
||||
DEFAULT_CHAT_FRAME:AddMessage("AdePet debug: hungry = " .. tostring(isHungry) .. ", feeding = " .. tostring(PetIsFeeding()) .. ", interval = " .. GetHungryInterval() .. "s, window shown = " .. tostring(frame:IsShown()))
|
||||
DEFAULT_CHAT_FRAME:AddMessage("AdePet debug: hungry = " .. tostring(isHungry) .. ", feeding = " .. tostring(PetIsFeeding()) .. ", interval = " .. GetHungryInterval() .. "s, window shown = " .. tostring(frame:IsShown()) .. ", AFK = " .. tostring(IsPlayerAFK()) .. " (UnitIsAFK " .. (UnitIsAFK and "available" or "missing") .. ")")
|
||||
else
|
||||
DEFAULT_CHAT_FRAME:AddMessage("AdePet commands: /adepet lock, unlock, reset, debug | /hungry X")
|
||||
end
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
## Interface: 11200
|
||||
## Title: AdePet
|
||||
## Notes: Hunter pet loyalty window with hunger warning
|
||||
## Author: Claude
|
||||
## Version: 1.2
|
||||
## Version: 1.0.2
|
||||
## SavedVariablesPerCharacter: AdePetDB
|
||||
|
||||
AdePet.lua
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to AdePet are documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [1.0.2] - 2026-10-26
|
||||
|
||||
### Fixed
|
||||
- Standing still with a summoned pet made the AFK flag flicker ("You are no
|
||||
longer AFK" immediately followed by "You are now AFK", can cosidered as boting).
|
||||
The addon now makes no pet queries at all while the player is AFK and resumes
|
||||
on the first check after the flag is cleared.
|
||||
|
||||
### Changed
|
||||
- Timer work now runs in one-second ticks, so the hunger check interval is
|
||||
accurate to about a second.
|
||||
- `/adepet debug` also shows the current AFK state.
|
||||
|
||||
## [1.0.1] - 2026-10-10
|
||||
|
||||
### Fixed
|
||||
- The "Pet is hungry" warning never appeared at maximum loyalty (Level 6). The
|
||||
hunger timer stopped running while the window was hidden; it now runs
|
||||
independently of the window.
|
||||
|
||||
### Added
|
||||
- `/adepet debug` prints the raw pet happiness and loyalty values returned by
|
||||
the client, for troubleshooting.
|
||||
|
||||
## [1.0] - 2026-10-08
|
||||
|
||||
First release.
|
||||
|
||||
### Added
|
||||
- Small movable window showing `Pet_Name: Loyalty_Level (Loyalty_Name)`.
|
||||
- Window width adjusts automatically to the text length.
|
||||
- Hunter-only: the addon stays inactive for every other class.
|
||||
- Hunger warning: a "Pet is hungry" line under the pet name when happiness is
|
||||
below Happy (yellow for Content, red for Unhappy).
|
||||
- Hunger check every 15 seconds, after leaving combat, on pet change, and
|
||||
right after feeding ends (detected via the "Feed Pet Effect" buff).
|
||||
- `/hungry X` command to change the hunger check interval (seconds, minimum 1);
|
||||
saved per character.
|
||||
- `/adepet lock`, `/adepet unlock` and `/adepet reset` (alias `/ap`) to lock,
|
||||
unlock and reset the window position; position is saved per character.
|
||||
- At maximum loyalty (Level 6, Best Friend) the window is hidden and shown only
|
||||
while the pet is hungry.
|
||||
- Compatibility with OctoWoW, whose `GetPetLoyalty()` returns text instead of a
|
||||
plain number.
|
||||
@@ -12,10 +12,11 @@ Lightweight hunter pet addon for OctoWoW.
|
||||
change and when feeding ends
|
||||
- At max loyalty (Level 6) the window is hidden unless the pet is hungry
|
||||
- Hunters only
|
||||
- Makes no pet queries while you are AFK (keeps the AFK flag from flickering)
|
||||
|
||||
## Installation
|
||||
|
||||
1. Download the latest `AdePet-v1.0.zip` from the Releases page.
|
||||
1. Download the latest `AdePet-v1.0.2.zip` from the Releases page.
|
||||
2. Extract it so the folder `AdePet` sits directly in
|
||||
`<WoW folder>\Interface\AddOns\` (the path must be
|
||||
`Interface\AddOns\AdePet\AdePet.toc`), remove -main from folder name.
|
||||
@@ -32,6 +33,7 @@ Lightweight hunter pet addon for OctoWoW.
|
||||
| `/adepet unlock` | Unlock the window so it can be dragged |
|
||||
| `/adepet reset` | Reset the window position |
|
||||
|
||||
`/adepet debug` prints the raw pet happiness and loyalty values (useful for bug reports).
|
||||
`/ap` works as a short alias for `/adepet`. Drag the window with the left mouse
|
||||
button; the position and interval are saved per character.
|
||||
|
||||
@@ -41,5 +43,8 @@ button; the position and interval are saved per character.
|
||||
The 1.12 API does not expose a numeric satiety value, so there is no bar.
|
||||
- Feeding is detected through the "Feed Pet Effect" buff. The check matches the
|
||||
English buff name (this check will not work if using any other language).
|
||||
- Not checking pet state while player have "afk" status.
|
||||
|
||||
## Changelog
|
||||
|
||||
See [CHANGELOG.md](CHANGELOG.md).
|
||||
|
||||
Reference in New Issue
Block a user