Release 1.5.2: low ammo box looks only at the equipped ammo, hunters get a plain bow on the range icon

The low ammo box now shows when the equipped stack is down to 100 shots (/ctk ammo <shots> changes it) and no longer counts the bags. The range icon is a plain bow for hunters so it looks the same every time, instead of borrowing the watched spell's picture.
This commit is contained in:
notforever-ship-it
2026-10-07 21:30:48 +01:00
parent 1f676c6b6b
commit 88787c5369
7 changed files with 39 additions and 42 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
## Title: Class Toolkit
## Notes: Swing timer, range icon, buff and reagent reminders, spell ready icons for every class; aggro meter and feed helpers for hunters. /ctk
## Author: stealthzi
## Version: 1.5.1
## Version: 1.5.2
## SavedVariables: ClassToolkitDB
## SavedVariablesPerCharacter: ClassToolkitCharDB
+6 -7
View File
@@ -7,7 +7,7 @@
ClassToolkit = {}
local CTK = ClassToolkit
CTK.VERSION = "1.5.1"
CTK.VERSION = "1.5.2"
CTK.movingIcons = false
CTK.modules = {} -- each module registers { update = function() } so settings changes reach it
@@ -102,7 +102,7 @@ local function ClassDefaults(class)
aggroGrowl = false, -- false: Growl's threat by its rank; a number: what you set with /ctk aggro growl
aggroScale = 1, -- how much more (or less) the pet's threat is worth than counted, learned from fights
ammoBox = hunter,
ammoBoxStacks = 2,
ammoBoxShots = 100,
feedWhen = "content",
feedSound = true,
debug = false,
@@ -242,7 +242,7 @@ local function ChatHelp()
CTK.Print("/ctk ready all | one - an icon for every watched spell, or one for the next one ready")
CTK.Print("/ctk aggro growl <threat> | auto - what one Growl is worth; /ctk aggro reset - forget what it learned")
CTK.Print("/ctk feed content | unhappy | sound - when the feed reminder shows, and its sound")
CTK.Print("/ctk ammo <stacks> - hunters: show the low ammo box at this many stacks left (2 to start)")
CTK.Print("/ctk ammo <shots> - hunters: show the low ammo box when your equipped ammo is down to this many shots (100 to start)")
CTK.Print("/ctk buffs reset - bring back buff reminders you right-clicked away")
CTK.Print("/ctk counts - list your reagents and ammo")
CTK.Print("/ctk version - show which version you have")
@@ -264,11 +264,10 @@ local function SlashHandler(msg)
ChatHelp()
return
elseif cmd == "ammo" and tonumber(rest) then
local stacks = math.max(1, math.floor(tonumber(rest)))
CTK.char.ammoBoxStacks = stacks
local shots = math.max(1, math.floor(tonumber(rest)))
CTK.char.ammoBoxShots = shots
CTK.char.ammoBox = true
CTK.Print("the low ammo box shows when you're down to " .. stacks .. (stacks == 1 and " stack" or " stacks") ..
" of ammo.")
CTK.Print("the low ammo box shows when the ammo you have equipped is down to " .. shots .. " shots.")
CTK.UpdateAll()
return
elseif cmd == "ready" and (rest == "one" or rest == "all") then
+2 -2
View File
@@ -40,8 +40,8 @@ local HELP_TEXT = table.concat({
" ",
GOLD .. "Reagents and ammo" .. END,
"- A chat warning when a reagent you carry runs low. " .. WHITE .. "/ctk counts" .. END .. " lists what you have.",
"- Hunters: warnings at 200 and 50 shots, and a " .. RED .. "Low ammo" .. END .. " box on screen when you're down " ..
"to your last 2 stacks (" .. WHITE .. "/ctk ammo 3" .. END .. " to change).",
"- Hunters: warnings at 200 and 50 shots, and a " .. RED .. "Low ammo" .. END .. " box on screen when the ammo you " ..
"have equipped is down to 100 shots (" .. WHITE .. "/ctk ammo 50" .. END .. " to change). It only looks at the equipped stack, not your bags.",
" ",
GOLD .. "Range icon" .. END,
"- Watches one spell, your class's main attack to start (Fireball, Shadow Bolt, Heroic Strike, Auto Shot...). " ..
+12 -27
View File
@@ -96,9 +96,6 @@ end
local ammoBox
local ammoQueued = false
-- The box also shows whenever you are down to this many shots in all, whatever the stacks look like: it is
-- the same level as the first chat warning (Reagents.lua).
local LOW_SHOTS = 200
local NEEDS_AMMO = { ["Bows"] = true, ["Guns"] = true, ["Crossbows"] = true }
-- Is a bow, gun or crossbow in the ranged slot? (Thrown weapons and wands need no ammo.)
@@ -112,30 +109,19 @@ local function HasAmmoWeapon()
return okInfo and subType and NEEDS_AMMO[subType] or false
end
-- How many spare stacks of your equipped ammo are in your bags, all your shots (the equipped stack plus the
-- bags), and its icon. With no ammo equipped but a bow, gun or crossbow in your hand that is 0 stacks and 0
-- shots; nil when no ammo is wanted (a thrown weapon, a wand, or nothing).
local function AmmoStacks()
-- The shots left in the ammo you have equipped (the stack in the ammo slot, not what is in your bags), and its
-- icon. With no ammo equipped but a bow, gun or crossbow in your hand that is 0; nil when no ammo is wanted
-- (a thrown weapon, a wand, or nothing).
local function EquippedAmmo()
local ok, slot = pcall(GetInventorySlotInfo, "AmmoSlot")
if not ok or not slot then return nil end
local link = GetInventoryItemLink("player", slot)
local _, _, name = string.find(link or "", "%[(.-)%]")
if not name then
if HasAmmoWeapon() then return 0, 0, nil end
if HasAmmoWeapon() then return 0, nil end
return nil
end
local stacks, shots = 0, GetInventoryItemCount("player", slot) or 0
for bag = 0, 4 do
for s = 1, (GetContainerNumSlots(bag) or 0) do
local itemLink = GetContainerItemLink(bag, s)
if itemLink and string.find(itemLink, "[" .. name .. "]", 1, true) then
local _, count = GetContainerItemInfo(bag, s)
stacks = stacks + 1
shots = shots + (count or 0)
end
end
end
return stacks, shots, GetInventoryItemTexture("player", slot)
return GetInventoryItemCount("player", slot) or 0, GetInventoryItemTexture("player", slot)
end
local function UpdateAmmoBox()
@@ -146,24 +132,23 @@ local function UpdateAmmoBox()
ammoBox:Hide()
return
end
local stacks, shots, texture = AmmoStacks()
if not stacks or (stacks > (c.ammoBoxStacks or 2) and shots > LOW_SHOTS) then
local shots, texture = EquippedAmmo()
if not shots or shots > (c.ammoBoxShots or 100) then
ammoBox:Hide()
return
end
ammoBox.icon:SetTexture(texture or "Interface\\Icons\\INV_Ammo_Arrow_02")
if shots == 0 then
ammoBox.title:SetText("OUT OF AMMO")
ammoBox.detail:SetText("Buy more before you pull")
ammoBox.detail:SetText("Equip more before you pull")
else
ammoBox.title:SetText("Low ammo")
local spare = stacks == 0 and "" or (", " .. stacks .. (stacks == 1 and " spare stack" or " spare stacks"))
ammoBox.detail:SetText(shots .. " shots left" .. spare)
ammoBox.detail:SetText(shots .. " shots left")
end
ammoBox:Show()
end
-- Bags change many times a second while looting and shooting, so wait for them to settle.
-- Bags and the ammo slot change many times a second while looting and shooting, so wait for them to settle.
local function QueueAmmoBox()
if ammoQueued then return end
ammoQueued = true
@@ -224,7 +209,7 @@ local function Update()
if c.ammoBox and hunter then
ammoBox.icon:SetTexture("Interface\\Icons\\INV_Ammo_Arrow_02")
ammoBox.title:SetText("Low ammo box (drag)")
ammoBox.detail:SetText("2 stacks, 312 shots left")
ammoBox.detail:SetText("73 shots left")
ammoBox:Show()
else
ammoBox:Hide()
+1 -1
View File
@@ -43,7 +43,7 @@ local TIPS = {
"and what to do: Shoot, Ease off, Hold, or Feign Death. Threat is estimated from the combat log and " ..
"corrected by what the mob attacks, so it learns your server's numbers as you fight.",
feed = "A happiness face when your pet stops being happy. Click it to feed.",
ammoBox = "A red box on screen when you're down to your last stacks of ammo (2 to start; /ctk ammo 3 to change).",
ammoBox = "A red box on screen when the ammo you have equipped is low (100 shots to start; /ctk ammo 50 to change), or when a bow or gun has no ammo equipped.",
}
-- One line per watched spell, made as they're added, so you can watch as many as you like.
+7 -2
View File
@@ -6,7 +6,7 @@ Small, useful helpers for every class on Ravencraft (and other 1.12.1 servers).
- **Buff reminder.** An icon appears when a buff your class keeps up is missing or about to run out: an aspect, an armor, a blessing or aura, Fortitude, Mark of the Wild and so on. Click it to cast, right-click to stop that reminder. Hunters also get a warning when Aspect of the Cheetah or the Pack is still on in a fight.
- **Spell ready icons.** Watch as many spells as you like. Each gets an icon that greys out with a countdown on cooldown, turns blue without the mana (or rage, or energy), red when the target is out of range, and says **READY** when you can cast it. Or keep **one** icon that shows whichever watched spell is ready first. Hunters start with Arcane Shot.
- **Reagent and ammo warnings.** A chat and mid-screen warning when you run low on a reagent you carry (Soul Shards, Ankhs, runes, candles, symbols, seeds, Flash Powder), and hunters' ammo at 200 and 50 shots.
- **Low ammo box** for hunters: a red box on screen when you're down to your last 2 spare stacks of arrows or bullets, or to 200 shots or fewer in all (the equipped stack counts), or when a bow, gun or crossbow is in your hand with no ammo equipped.
- **Low ammo box** for hunters: a red box on screen when you're down to your last 2 spare stacks of arrows or bullets, when the ammo you have equipped is down to 100 shots (`/ctk ammo <shots>` to change), or when a bow, gun or crossbow is in your hand with no ammo equipped. It looks only at the equipped stack, not your bags.
- **Hunters:** a **range icon** (In range, Dead zone, Melee, Out of range) and a **pet feed reminder** that you click to feed.
These started out in [PokeHuntLog](https://github.com/notforever-ship-it/PokeHuntLog), the hunter pet collection log, and moved here so every class can use them.
@@ -62,7 +62,7 @@ A reminder only appears once you know the spell. Buffs from other players count
| `/ctk swing`, `/ctk ranged` | Melee timer, Auto Shot / wand timer on or off |
| `/ctk ready`, `/ctk buffs`, `/ctk reagents` | Spell ready icons, buff reminder, reagent warnings on or off |
| `/ctk range`, `/ctk feed`, `/ctk ammo` | Hunters: range icon, feed reminder, low ammo box on or off |
| `/ctk ammo <stacks>` | Hunters: show the low ammo box at this many stacks left (2 to start) |
| `/ctk ammo <shots>` | Hunters: show the low ammo box when your equipped ammo is down to this many shots (100 to start) |
| `/ctk watch <spell>` / `/ctk unwatch <spell>` | Add or remove a spell ready icon |
| `/ctk ready all` / `/ctk ready one` | An icon for every watched spell, or one for the next one ready |
| `/ctk feed content` / `/ctk feed unhappy` / `/ctk feed sound` | When the feed reminder shows, and its sound |
@@ -99,6 +99,11 @@ MIT, see [LICENSE](LICENSE).
## Changelog
### 1.5.2
- **The low ammo box only looks at the ammo you have equipped**, not your bags: it shows when that stack is down to 100 shots (`/ctk ammo <shots>` to change; it used to count spare stacks), and shows "OUT OF AMMO" when a bow, gun or crossbow is in your hand with no ammo equipped.
- **The range icon is a plain bow for hunters**, so it looks the same every time. Before, it borrowed the watched spell's picture, which came and went depending on where the spell sat on your action bars. Other classes still get the watched spell's picture.
### 1.5.1
- **The low ammo box is easier to see.** It now counts the equipped stack as well as the stacks in your bags, shows whenever you are down to 200 shots or fewer in all (the same level as the first chat warning), and shows "OUT OF AMMO" when a bow, gun or crossbow is in your hand and no ammo is equipped. Before, it only counted spare stacks in your bags and showed nothing with an empty quiver slot.
+10 -2
View File
@@ -10,6 +10,14 @@
local CTK = ClassToolkit
local QUESTION = "Interface\\Icons\\INV_Misc_QuestionMark"
local BOW = "Interface\\Icons\\INV_Weapon_Bow_05"
-- The picture on the icon. Hunters always get a plain bow, so it shows the same every time; the spell's own
-- picture came and went with where the spell sat on the action bars. Other classes get the watched spell's.
local function RangeTexture(spell)
if CTK.IsClass("HUNTER") then return BOW end
return (spell and CTK.SpellTexture(spell)) or QUESTION
end
-- The spell each class starts with, and others to fall back on if it isn't known yet.
local DEFAULTS = {
@@ -156,7 +164,7 @@ local function OnUpdate()
local text = state.text
if key == "range" and yards and yards > 0 then text = text .. " (" .. yards .. " yd)" end
CTK.SetIconState(frame, state.r, state.g, state.b, text)
frame.icon:SetTexture((spell and CTK.SpellTexture(spell)) or QUESTION)
frame.icon:SetTexture(RangeTexture(spell))
if key == "range" or key == "meleeGood" then
frame.icon:SetVertexColor(1, 1, 1)
else
@@ -172,7 +180,7 @@ local function Update()
if CTK.movingIcons then
if c.range then
local spell = CTK.RangeSpell()
frame.icon:SetTexture((spell and CTK.SpellTexture(spell)) or QUESTION)
frame.icon:SetTexture(RangeTexture(spell))
frame.icon:SetVertexColor(1, 1, 1)
CTK.SetIconState(frame, 0.25, 1, 0.25, "Range icon (drag)")
frame:Show()