mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-15 23:50:38 +00:00
totem: add GetTotemDuration(slot)
Returns the slot's active totem total duration in seconds (0 when none) — the totem's full lifetime from cast, same value as GetTotemInfo's 4th return, companion to GetTotemTimeLeft. Reads the tracker's durationMs. Verified in-game (constant 45 while time-left counts down).
This commit is contained in:
@@ -63,7 +63,7 @@ Full per-function reference: **[docs/API.md](docs/API.md)**.
|
||||
| [Talent](docs/API.md#talent) | `GetTalentIDByIndex`, `GetTalentSpellID` |
|
||||
| [TaxiMap](docs/API.md#taximap) | `C_TaxiMap.GetTaxiNodesForMap`, `C_TaxiMap.GetAllTaxiNodes` |
|
||||
| [Time](docs/API.md#time) | `C_DateAndTime.AdjustTimeByDays`, `C_DateAndTime.AdjustTimeByMinutes`, `C_DateAndTime.CompareCalendarTime`, `C_DateAndTime.GetCalendarTimeFromEpoch`, `C_DateAndTime.GetCurrentCalendarTime`, `C_DateAndTime.GetSecondsUntilDailyReset`, `C_DateAndTime.GetServerTimeLocal`, `C_Timer.After`, `C_Timer.NewTicker`, `C_Timer.NewTimer`, `GetServerTime` |
|
||||
| [Totem](docs/API.md#totem) | `GetTotemInfo`, `GetTotemTimeLeft`, `TargetTotem` |
|
||||
| [Totem](docs/API.md#totem) | `GetTotemInfo`, `GetTotemTimeLeft`, `GetTotemDuration`, `TargetTotem` |
|
||||
| [TradeSkillUI](docs/API.md#tradeskillui) | `C_TradeSkillUI.GetTradeSkillListLink`, `C_TradeSkillUI.GetCraftListLink`, `C_TradeSkillUI.GetTradeSkillListRecipes` |
|
||||
| [UIColor](docs/API.md#uicolor) | `C_UIColor.GetColors` |
|
||||
| [Unit](docs/API.md#unit) | `ClosestUnitPosition`, `GetUnitSpeed`, `UnitClassBase`, `UnitCreatureFamilyID`, `UnitCreatureTypeID`, `UnitDistanceSquared`, `UnitGUID`, `UnitInLineOfSight`, `UnitInRange`, `UnitIsAFK`, `UnitIsDND`, `UnitIsFeignDeath`, `UnitIsInMyGuild`, `UnitIsMinion`, `UnitIsOtherPlayersPet`, `UnitIsPet`, `UnitIsPossessed`, `UnitOwnerGUID`, `UnitPower`, `UnitPowerMax`, `UnitPowerType`, `UnitRaceBase`, `UnitStandState`, `UnitSubName`, `UnitTokenFromGUID` |
|
||||
|
||||
+13
@@ -465,6 +465,7 @@ build instructions.
|
||||
- [Totem](#totem)
|
||||
- [`GetTotemInfo(slot)`](#gettoteminfoslot)
|
||||
- [`GetTotemTimeLeft(slot)`](#gettotemtimeleftslot)
|
||||
- [`GetTotemDuration(slot)`](#gettotemdurationslot)
|
||||
- [`TargetTotem(slot)`](#targettotemslot)
|
||||
|
||||
- [TradeSkillUI](#tradeskillui)
|
||||
@@ -11292,6 +11293,18 @@ notably it reflects the totem's *full* duration from cast, unaffected by
|
||||
any server-side early expiry the client isn't told about (the WorldTick
|
||||
scan still clears the slot when the totem creature actually disappears).
|
||||
|
||||
### `GetTotemDuration(slot)`
|
||||
|
||||
Returns the slot's active totem's **total** duration in seconds (its full
|
||||
lifetime from cast), or `0` when no totem is active. The companion to
|
||||
[`GetTotemTimeLeft`](#gettotemtimeleftslot) (remaining time) — same value
|
||||
as `GetTotemInfo`'s 4th return.
|
||||
|
||||
```lua
|
||||
local total = GetTotemDuration(1) -- e.g. 60
|
||||
local frac = GetTotemTimeLeft(1) / GetTotemDuration(1) -- bar fill
|
||||
```
|
||||
|
||||
### `TargetTotem(slot)`
|
||||
|
||||
Targets the player's totem in the given slot (`1` Fire, `2` Earth, `3`
|
||||
|
||||
@@ -454,6 +454,26 @@ int __fastcall Script_GetTotemTimeLeft(void *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// `GetTotemDuration(slot)` → the total duration (seconds) of the slot's
|
||||
// active totem, or `0` when none. This is the totem's full lifetime from
|
||||
// cast (the 4th value of GetTotemInfo); see GetTotemTimeLeft for the
|
||||
// remaining time.
|
||||
int __fastcall Script_GetTotemDuration(void *L) {
|
||||
if (!Game::Lua::IsNumber(L, 1)) {
|
||||
Game::Lua::Error(L, "Usage: GetTotemDuration(slot)");
|
||||
return 0;
|
||||
}
|
||||
const int slot = static_cast<int>(Game::Lua::ToNumber(L, 1));
|
||||
double seconds = 0.0;
|
||||
if (slot >= 1 && slot <= kSlots) {
|
||||
const Slot &t = g_slots[slot - 1];
|
||||
if (t.active)
|
||||
seconds = static_cast<double>(t.durationMs) / 1000.0;
|
||||
}
|
||||
Game::Lua::PushNumber(L, seconds);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// `TargetTotem(slot)` — target the player's totem in the given slot
|
||||
// (1 Fire, 2 Earth, 3 Water, 4 Air). No-op when the slot has no active
|
||||
// totem or the totem creature isn't currently visible. Finds the totem
|
||||
@@ -483,6 +503,8 @@ void RegisterLuaFunctions() {
|
||||
Game::Lua::RegisterGlobalFunction("GetTotemInfo", &Script_GetTotemInfo);
|
||||
Game::Lua::RegisterGlobalFunction("GetTotemTimeLeft",
|
||||
&Script_GetTotemTimeLeft);
|
||||
Game::Lua::RegisterGlobalFunction("GetTotemDuration",
|
||||
&Script_GetTotemDuration);
|
||||
Game::Lua::RegisterGlobalFunction("TargetTotem", &Script_TargetTotem);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user