mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Add gameobject interaction and taxi activation
This commit is contained in:
parent
a71902a571
commit
e5c48dc9b7
8 changed files with 361 additions and 58 deletions
|
|
@ -85,6 +85,10 @@ private:
|
|||
void despawnOnlineCreature(uint64_t guid);
|
||||
void buildCreatureDisplayLookups();
|
||||
std::string getModelPathForDisplayId(uint32_t displayId) const;
|
||||
void spawnOnlineGameObject(uint64_t guid, uint32_t displayId, float x, float y, float z, float orientation);
|
||||
void despawnOnlineGameObject(uint64_t guid);
|
||||
void buildGameObjectDisplayLookups();
|
||||
std::string getGameObjectModelPathForDisplayId(uint32_t displayId) const;
|
||||
|
||||
static Application* instance;
|
||||
|
||||
|
|
@ -151,6 +155,20 @@ private:
|
|||
std::unordered_map<uint32_t, uint32_t> displayIdModelCache_; // displayId → modelId (model caching)
|
||||
uint32_t nextCreatureModelId_ = 5000; // Model IDs for online creatures
|
||||
|
||||
// Online gameobject model spawning
|
||||
struct GameObjectInstanceInfo {
|
||||
uint32_t modelId = 0;
|
||||
uint32_t instanceId = 0;
|
||||
bool isWmo = false;
|
||||
};
|
||||
std::unordered_map<uint32_t, std::string> gameObjectDisplayIdToPath_;
|
||||
std::unordered_map<uint32_t, uint32_t> gameObjectDisplayIdModelCache_; // displayId → M2 modelId
|
||||
std::unordered_map<uint32_t, uint32_t> gameObjectDisplayIdWmoCache_; // displayId → WMO modelId
|
||||
std::unordered_map<uint64_t, GameObjectInstanceInfo> gameObjectInstances_; // guid → instance info
|
||||
uint32_t nextGameObjectModelId_ = 20000;
|
||||
uint32_t nextGameObjectWmoModelId_ = 40000;
|
||||
bool gameObjectLookupsBuilt_ = false;
|
||||
|
||||
// Mount model tracking
|
||||
uint32_t mountInstanceId_ = 0;
|
||||
uint32_t mountModelId_ = 0;
|
||||
|
|
@ -167,6 +185,14 @@ private:
|
|||
std::vector<PendingCreatureSpawn> pendingCreatureSpawns_;
|
||||
static constexpr int MAX_SPAWNS_PER_FRAME = 2;
|
||||
void processCreatureSpawnQueue();
|
||||
|
||||
struct PendingGameObjectSpawn {
|
||||
uint64_t guid;
|
||||
uint32_t displayId;
|
||||
float x, y, z, orientation;
|
||||
};
|
||||
std::vector<PendingGameObjectSpawn> pendingGameObjectSpawns_;
|
||||
void processGameObjectSpawnQueue();
|
||||
};
|
||||
|
||||
} // namespace core
|
||||
|
|
|
|||
|
|
@ -378,6 +378,15 @@ public:
|
|||
using CreatureDespawnCallback = std::function<void(uint64_t guid)>;
|
||||
void setCreatureDespawnCallback(CreatureDespawnCallback cb) { creatureDespawnCallback_ = std::move(cb); }
|
||||
|
||||
// GameObject spawn callback (online mode - triggered when gameobject enters view)
|
||||
// Parameters: guid, displayId, x, y, z (canonical), orientation
|
||||
using GameObjectSpawnCallback = std::function<void(uint64_t guid, uint32_t displayId, float x, float y, float z, float orientation)>;
|
||||
void setGameObjectSpawnCallback(GameObjectSpawnCallback cb) { gameObjectSpawnCallback_ = std::move(cb); }
|
||||
|
||||
// GameObject despawn callback (online mode - triggered when gameobject leaves view)
|
||||
using GameObjectDespawnCallback = std::function<void(uint64_t guid)>;
|
||||
void setGameObjectDespawnCallback(GameObjectDespawnCallback cb) { gameObjectDespawnCallback_ = std::move(cb); }
|
||||
|
||||
// Faction hostility map (populated from FactionTemplate.dbc by Application)
|
||||
void setFactionHostileMap(std::unordered_map<uint32_t, bool> map) { factionHostileMap_ = std::move(map); }
|
||||
|
||||
|
|
@ -417,6 +426,7 @@ public:
|
|||
|
||||
// NPC Gossip
|
||||
void interactWithNpc(uint64_t guid);
|
||||
void interactWithGameObject(uint64_t guid);
|
||||
void selectGossipOption(uint32_t optionId);
|
||||
void selectGossipQuest(uint32_t questId);
|
||||
void acceptQuest();
|
||||
|
|
@ -792,6 +802,8 @@ private:
|
|||
CreatureSpawnCallback creatureSpawnCallback_;
|
||||
CreatureDespawnCallback creatureDespawnCallback_;
|
||||
CreatureMoveCallback creatureMoveCallback_;
|
||||
GameObjectSpawnCallback gameObjectSpawnCallback_;
|
||||
GameObjectDespawnCallback gameObjectDespawnCallback_;
|
||||
std::vector<uint32_t> knownSpells;
|
||||
std::unordered_map<uint32_t, float> spellCooldowns; // spellId -> remaining seconds
|
||||
uint8_t castCount = 0;
|
||||
|
|
|
|||
|
|
@ -193,6 +193,9 @@ enum class Opcode : uint16_t {
|
|||
SMSG_LOOT_MONEY_NOTIFY = 0x163,
|
||||
SMSG_LOOT_CLEAR_MONEY = 0x165,
|
||||
|
||||
// ---- Phase 5: Taxi / Flight Paths ----
|
||||
CMSG_ACTIVATETAXI = 0x19D,
|
||||
|
||||
// ---- Phase 5: NPC Gossip ----
|
||||
CMSG_GOSSIP_HELLO = 0x17B,
|
||||
CMSG_GOSSIP_SELECT_OPTION = 0x17C,
|
||||
|
|
@ -200,6 +203,9 @@ enum class Opcode : uint16_t {
|
|||
SMSG_GOSSIP_COMPLETE = 0x17E,
|
||||
SMSG_NPC_TEXT_UPDATE = 0x180,
|
||||
|
||||
// ---- Phase 5: GameObject ----
|
||||
CMSG_GAMEOBJECT_USE = 0x01B,
|
||||
|
||||
// ---- Phase 5: Quests ----
|
||||
CMSG_QUESTGIVER_STATUS_QUERY = 0x182,
|
||||
SMSG_QUESTGIVER_STATUS = 0x183,
|
||||
|
|
|
|||
|
|
@ -1665,8 +1665,10 @@ struct ShowTaxiNodesData {
|
|||
uint32_t nearestNode = 0; // Taxi node player is at
|
||||
uint32_t nodeMask[TLK_TAXI_MASK_SIZE] = {};
|
||||
bool isNodeKnown(uint32_t nodeId) const {
|
||||
uint32_t idx = nodeId / 32;
|
||||
uint32_t bit = nodeId % 32;
|
||||
if (nodeId == 0) return false;
|
||||
uint32_t bitIndex = nodeId - 1;
|
||||
uint32_t idx = bitIndex / 32;
|
||||
uint32_t bit = bitIndex % 32;
|
||||
return idx < TLK_TAXI_MASK_SIZE && (nodeMask[idx] & (1u << bit));
|
||||
}
|
||||
};
|
||||
|
|
@ -1694,6 +1696,18 @@ public:
|
|||
static network::Packet build(uint64_t npcGuid, const std::vector<uint32_t>& pathNodes);
|
||||
};
|
||||
|
||||
/** CMSG_ACTIVATETAXI packet builder */
|
||||
class ActivateTaxiPacket {
|
||||
public:
|
||||
static network::Packet build(uint64_t npcGuid, uint32_t srcNode, uint32_t destNode);
|
||||
};
|
||||
|
||||
/** CMSG_GAMEOBJECT_USE packet builder */
|
||||
class GameObjectUsePacket {
|
||||
public:
|
||||
static network::Packet build(uint64_t guid);
|
||||
};
|
||||
|
||||
/** CMSG_REPOP_REQUEST packet builder */
|
||||
class RepopRequestPacket {
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue