mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
feat(gossip): fire DYNAMIC_GOSSIP_POI_UPDATED and document the POI API
Diff the gossip marker's x, y and expiry once per frame: each set rewrites them and both clears (10 yards, 480 s) zero them. The map rebuild that every change runs also runs on each map view change, so it is not a usable trigger on its own. Add the two POI functions and the event to README.md and docs/API.md.
This commit is contained in:
@@ -103,7 +103,7 @@ In the Frame rows, a name that starts with `:` is a method of the widget that th
|
||||
| [GameObject](docs/API.md#gameobject) | `C_GameObjectInfo.GetGameObjectInfoByID`, `C_GameObjectInfo.RequestLoadGameObjectByID`, `ClosestGameObjectPosition` |
|
||||
| [Glue](docs/API.md#glue) | `C_Glue.IsOnGlueScreen` |
|
||||
| [GameTooltip](docs/API.md#gametooltip) | `GameTooltip:AddSpellByID`, `GameTooltip:AddTexture`, `GameTooltip:GetGameObject`, `GameTooltip:GetItem`, `GameTooltip:GetMinimumWidth`, `GameTooltip:GetOwner`, `GameTooltip:GetPadding`, `GameTooltip:GetSpell`, `GameTooltip:GetUnit`, `GameTooltip:GetUnitGUID`, `GameTooltip:HasGameObject`, `GameTooltip:HasItem`, `GameTooltip:HasSpell`, `GameTooltip:HasUnit`, `GameTooltip:IsEquippedItem`, `GameTooltip:IsUnit`, `GameTooltip:SetAnchorType`, `GameTooltip:SetEquipmentSet`, `GameTooltip:SetFrameStack`, `GameTooltip:SetHyperlink` (full links, `spell:`, `quest:`), `GameTooltip:SetHyperlinkCompareItem`, `GameTooltip:SetInventoryItemByID`, `GameTooltip:SetItemByGUID`, `GameTooltip:SetItemByID`, `GameTooltip:SetSpellByID`, `GameTooltip:SetTalentByID`, `GameTooltip:SetTotem`, `GameTooltip:SetUnitAura`, `OnTooltipSetItem`, `OnTooltipSetSpell`, `OnTooltipSetUnit`, `OnTooltipSetGameObject`, `OnTooltipSetFrameStack` (scripts) |
|
||||
| [Gossip](docs/API.md#gossip) | `C_GossipInfo.CloseGossip`, `C_GossipInfo.GetActiveQuests`, `C_GossipInfo.GetAvailableQuests`, `C_GossipInfo.GetNumActiveQuests`, `C_GossipInfo.GetNumAvailableQuests`, `C_GossipInfo.GetNumOptions`, `C_GossipInfo.GetOptions`, `C_GossipInfo.GetText`, `C_GossipInfo.SelectActiveQuest`, `C_GossipInfo.SelectAvailableQuest`, `C_GossipInfo.SelectOption`, `C_GossipInfo.SelectOptionByIndex`, `GetNumGossipActiveQuests`, `GetNumGossipAvailableQuests` |
|
||||
| [Gossip](docs/API.md#gossip) | `C_GossipInfo.CloseGossip`, `C_GossipInfo.GetActiveQuests`, `C_GossipInfo.GetAvailableQuests`, `C_GossipInfo.GetNumActiveQuests`, `C_GossipInfo.GetNumAvailableQuests`, `C_GossipInfo.GetNumOptions`, `C_GossipInfo.GetOptions`, `C_GossipInfo.GetPoiForUiMapID`, `C_GossipInfo.GetPoiInfo`, `C_GossipInfo.GetText`, `C_GossipInfo.SelectActiveQuest`, `C_GossipInfo.SelectAvailableQuest`, `C_GossipInfo.SelectOption`, `C_GossipInfo.SelectOptionByIndex`, `GetNumGossipActiveQuests`, `GetNumGossipAvailableQuests` |
|
||||
| [Hooks](docs/API.md#hooks) | `hooksecurefunc` |
|
||||
| [Input](docs/API.md#input) | `GetMouseButtonClicked`, `IsLeftAltKeyDown`, `IsLeftControlKeyDown`, `IsLeftShiftKeyDown`, `IsModifierKeyDown`, `IsMouseButtonDown`, `IsRightAltKeyDown`, `IsRightControlKeyDown`, `IsRightShiftKeyDown` |
|
||||
| [Instance](docs/API.md#instance) | `GetInstanceInfo`, `IsActiveBattlefieldArena` |
|
||||
@@ -275,6 +275,7 @@ when launching with `-console`), not as Lua functions. See the
|
||||
| `COMBAT_LOG_EVENT` | `timestamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...` ([details](docs/API.md#combat_log_event_unfiltered--combat_log_event-events)) |
|
||||
| `COMBAT_LOG_EVENT_UNFILTERED` | same as `COMBAT_LOG_EVENT` |
|
||||
| `CURSOR_CHANGED` | `isDefault, newCursorType, oldCursorType, oldCursorVirtualID` |
|
||||
| `DYNAMIC_GOSSIP_POI_UPDATED` | *(none)* |
|
||||
| `EQUIPMENT_SETS_CHANGED` | *(none)* |
|
||||
| `EQUIPMENT_SWAP_PENDING` | `setID` |
|
||||
| `EQUIPMENT_SWAP_FINISHED` | `success, setID` |
|
||||
|
||||
+43
@@ -198,6 +198,7 @@ build instructions.
|
||||
- [`UPDATE_INVENTORY_DURABILITY` event](#update_inventory_durability-event)
|
||||
- [`PLAYER_AVG_ITEM_LEVEL_READY` event](#player_avg_item_level_ready-event)
|
||||
- [`HEARTHSTONE_BOUND` event](#hearthstone_bound-event)
|
||||
- [`DYNAMIC_GOSSIP_POI_UPDATED` event](#dynamic_gossip_poi_updated-event)
|
||||
- [Player input-state events (`PLAYER_STARTED_MOVING` / `LOOKING` / `TURNING` + `STOPPED_*`)](#player-input-state-events)
|
||||
- [`GLOBAL_MOUSE_DOWN` / `GLOBAL_MOUSE_UP` events](#global_mouse_down--global_mouse_up-events)
|
||||
- [`AUCTION_MULTISELL_START` / `AUCTION_MULTISELL_UPDATE` / `AUCTION_MULTISELL_FAILURE` events](#c_auctionhousepostitemitemlocation-duration-quantity-numstacks-bid-buyout)
|
||||
@@ -429,6 +430,8 @@ build instructions.
|
||||
- [`C_GossipInfo.SelectAvailableQuest(questID)`](#c_gossipinfoselectavailablequestquestid)
|
||||
- [`C_GossipInfo.SelectActiveQuest(questID)`](#c_gossipinfoselectactivequestquestid)
|
||||
- [`C_GossipInfo.CloseGossip()`](#c_gossipinfoclosegossip)
|
||||
- [`C_GossipInfo.GetPoiForUiMapID(uiMapID)`](#c_gossipinfogetpoiforuimapiduimapid)
|
||||
- [`C_GossipInfo.GetPoiInfo(uiMapID, gossipPoiID)`](#c_gossipinfogetpoiinfouimapid-gossippoiid)
|
||||
- [`GetNumGossipAvailableQuests()` / `GetNumGossipActiveQuests()`](#getnumgossipavailablequests--getnumgossipactivequests)
|
||||
|
||||
- [Hooks](#hooks)
|
||||
@@ -4518,6 +4521,12 @@ Character switch is handled automatically: the character-entry init
|
||||
re-zeroes the flag, so each new character's first update is also
|
||||
treated as sync and suppressed.
|
||||
|
||||
### `DYNAMIC_GOSSIP_POI_UPDATED` event
|
||||
|
||||
Fires (with no payload) when a gossip point of interest is added to the map or
|
||||
removed from it. When it fires, read the marker again with
|
||||
[`C_GossipInfo.GetPoiForUiMapID`](#c_gossipinfogetpoiforuimapiduimapid).
|
||||
|
||||
### Player input-state events
|
||||
|
||||
Three pairs of zero-payload events fired from a single per-frame
|
||||
@@ -9779,6 +9788,40 @@ Picks an in-progress quest by `questID`. Same shape as
|
||||
Closes the gossip window. Direct passthrough to the engine's
|
||||
`CloseGossip`. Returns nothing.
|
||||
|
||||
### `C_GossipInfo.GetPoiForUiMapID(uiMapID)`
|
||||
|
||||
Returns the ID of the gossip point of interest on the map `uiMapID`, or nil.
|
||||
Some gossip options add this marker to the map, for example the directions
|
||||
that a city guard gives. There is only one marker at a time, and its ID is
|
||||
always `1`.
|
||||
|
||||
The function returns nil when there is no marker, or when the marker is not
|
||||
inside the map. The marker goes away when the player comes within 10 yards of
|
||||
it, or 8 minutes after it was added.
|
||||
|
||||
### `C_GossipInfo.GetPoiInfo(uiMapID, gossipPoiID)`
|
||||
|
||||
Returns a table that describes the gossip point of interest on the map
|
||||
`uiMapID`, or nil. It returns nil in the same conditions as
|
||||
`GetPoiForUiMapID`, and when `gossipPoiID` is not the ID that
|
||||
`GetPoiForUiMapID` returns.
|
||||
|
||||
| Field | Type | Description |
|
||||
|----------------|---------|-------------|
|
||||
| `name` | string | The name of the location, for example `"Stormwind Bank"`. |
|
||||
| `textureIndex` | number | The icon index. It is the same index that `GetMapLandmarkInfo` returns for this marker. |
|
||||
| `position` | vector2 | The position on the map, from 0 to 1 on each axis. |
|
||||
| `inBattleMap` | boolean | Always `false`. |
|
||||
|
||||
```lua
|
||||
local mapID = C_Map.GetBestMapForUnit("player")
|
||||
local poiID = C_GossipInfo.GetPoiForUiMapID(mapID)
|
||||
if poiID then
|
||||
local info = C_GossipInfo.GetPoiInfo(mapID, poiID)
|
||||
print(info.name, info.position:GetXY())
|
||||
end
|
||||
```
|
||||
|
||||
### `GetNumGossipAvailableQuests()` / `GetNumGossipActiveQuests()`
|
||||
|
||||
Returns the number of quests that `GetGossipAvailableQuests()` /
|
||||
|
||||
@@ -10410,6 +10410,9 @@ enum Offsets {
|
||||
// via the 0x006DAC10 / 0x004A67A0 / 0x004A7360 decompiles.
|
||||
VAR_GOSSIP_POI_BLIP = 0x00CEA7D4,
|
||||
VAR_GOSSIP_POI_NAME = 0x00CEA6E0, // char[0x40], slot 1 of the names at 0x00CEA6A0
|
||||
// u32, wall-clock seconds (0x00429580) + 480 at each set; both clears
|
||||
// zero it with x/y (0x006D93FB, 0x006D9A3A). 0 = no marker.
|
||||
VAR_GOSSIP_POI_EXPIRY = 0x00CEAAA4,
|
||||
OFF_STATIC_BLIP_ICON = 0x08, // u32, POI icon index (the packet's icon)
|
||||
OFF_STATIC_BLIP_X = 0x10, // float, world X (north)
|
||||
OFF_STATIC_BLIP_Y = 0x14, // float, world Y (west)
|
||||
|
||||
@@ -25,11 +25,20 @@
|
||||
//
|
||||
// The packet carries no POI id, and there is only ever one marker, so its
|
||||
// `gossipPoiID` is the engine's slot number, 1.
|
||||
//
|
||||
// `DYNAMIC_GOSSIP_POI_UPDATED` fires when the marker is set or cleared. Every
|
||||
// change runs the world map rebuild 0x004A67A0 (the setter after a packet, the
|
||||
// 480 s expiry and the 10-yard clear in 0x006D93A0), but that rebuild also
|
||||
// runs for every map view change, so the event comes from a once-per-frame
|
||||
// diff of the record instead: x, y and the expiry, which each set rewrites
|
||||
// and each clear zeroes.
|
||||
|
||||
#include "Game.h"
|
||||
#include "Offsets.h"
|
||||
#include "event/Custom.h"
|
||||
#include "map/Area.h"
|
||||
#include "map/Vector2.h"
|
||||
#include "tick/WorldTick.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -43,6 +52,32 @@ template <typename T> T BlipField(uintptr_t off) {
|
||||
return *reinterpret_cast<const T *>(Offsets::VAR_GOSSIP_POI_BLIP + off);
|
||||
}
|
||||
|
||||
const Game::Doc::Event kPoiUpdatedDoc{
|
||||
"GossipInfo", "Fires when a gossip point of interest is added to or removed from the map.",
|
||||
{}};
|
||||
const Event::Custom::AutoReserve _evtPoiUpdated{"DYNAMIC_GOSSIP_POI_UPDATED",
|
||||
&kPoiUpdatedDoc};
|
||||
|
||||
struct Snapshot {
|
||||
uint32_t x, y, expiry;
|
||||
};
|
||||
|
||||
// The record as of the last fire. DLL-lived like the record itself, so a
|
||||
// /reload with a marker up does not fire a phantom change.
|
||||
Snapshot g_last{};
|
||||
|
||||
void OnTick() {
|
||||
const Snapshot now{BlipField<uint32_t>(Offsets::OFF_STATIC_BLIP_X),
|
||||
BlipField<uint32_t>(Offsets::OFF_STATIC_BLIP_Y),
|
||||
*reinterpret_cast<const uint32_t *>(Offsets::VAR_GOSSIP_POI_EXPIRY)};
|
||||
if (now.x == g_last.x && now.y == g_last.y && now.expiry == g_last.expiry)
|
||||
return;
|
||||
g_last = now;
|
||||
Event::Custom::Fire(_evtPoiUpdated.Slot(), "");
|
||||
}
|
||||
|
||||
const Tick::WorldTick::AutoSubscribe _tick{&OnTick};
|
||||
|
||||
// Projects the live marker onto `uiMapID`. False when there is no marker or
|
||||
// it isn't on that map.
|
||||
bool ProjectOnMap(int uiMapID, double *outPx, double *outPy) {
|
||||
|
||||
Reference in New Issue
Block a user