Add Tier 7 commands: combat and trade

Combat Commands:
- /duel - Challenge target to a duel (CMSG_DUEL_PROPOSED 0x166)
- /trade - Open trade window with target (CMSG_INITIATE_TRADE 0x116)
- /startattack - Begin auto-attacking target
- /stopattack - Stop auto-attacking
- /stopcasting - Cancel current spell cast

New opcodes:
- CMSG_DUEL_PROPOSED (0x166) for initiating duels
- CMSG_INITIATE_TRADE (0x116) for starting trades

Packet builders:
- DuelProposedPacket - sends duel challenge to target GUID
- InitiateTradePacket - sends trade request to target GUID
- AttackSwingPacket, AttackStopPacket, CancelCastPacket reused from existing

Game handler methods:
- proposeDuel(targetGuid) - challenge target to duel
- initiateTrade(targetGuid) - open trade with target
- stopCasting() - cancel current spell cast (uses existing casting state)

All commands include validation for target selection and world state.
Removed duplicate packet class definitions from previous phases.
This commit is contained in:
kelsi davis 2026-02-07 13:36:50 -08:00
parent d5b734a591
commit bca3f64af6
6 changed files with 201 additions and 38 deletions

View file

@ -1452,6 +1452,45 @@ network::Packet RequestRaidInfoPacket::build() {
return packet;
}
// ============================================================
// Combat and Trade
// ============================================================
network::Packet DuelProposedPacket::build(uint64_t targetGuid) {
network::Packet packet(static_cast<uint16_t>(Opcode::CMSG_DUEL_PROPOSED));
packet.writeUInt64(targetGuid);
LOG_DEBUG("Built CMSG_DUEL_PROPOSED for target: 0x", std::hex, targetGuid, std::dec);
return packet;
}
network::Packet InitiateTradePacket::build(uint64_t targetGuid) {
network::Packet packet(static_cast<uint16_t>(Opcode::CMSG_INITIATE_TRADE));
packet.writeUInt64(targetGuid);
LOG_DEBUG("Built CMSG_INITIATE_TRADE for target: 0x", std::hex, targetGuid, std::dec);
return packet;
}
network::Packet AttackSwingPacket::build(uint64_t targetGuid) {
network::Packet packet(static_cast<uint16_t>(Opcode::CMSG_ATTACKSWING));
packet.writeUInt64(targetGuid);
LOG_DEBUG("Built CMSG_ATTACKSWING for target: 0x", std::hex, targetGuid, std::dec);
return packet;
}
network::Packet AttackStopPacket::build() {
network::Packet packet(static_cast<uint16_t>(Opcode::CMSG_ATTACKSTOP));
LOG_DEBUG("Built CMSG_ATTACKSTOP");
return packet;
}
network::Packet CancelCastPacket::build(uint32_t spellId) {
network::Packet packet(static_cast<uint16_t>(Opcode::CMSG_CANCEL_CAST));
packet.writeUInt32(0); // cast count/sequence
packet.writeUInt32(spellId);
LOG_DEBUG("Built CMSG_CANCEL_CAST for spell: ", spellId);
return packet;
}
// ============================================================
// Random Roll
// ============================================================
@ -1777,19 +1816,6 @@ bool MonsterMoveParser::parse(network::Packet& packet, MonsterMoveData& data) {
// Phase 2: Combat Core
// ============================================================
network::Packet AttackSwingPacket::build(uint64_t targetGuid) {
network::Packet packet(static_cast<uint16_t>(Opcode::CMSG_ATTACKSWING));
packet.writeUInt64(targetGuid);
LOG_DEBUG("Built CMSG_ATTACKSWING: target=0x", std::hex, targetGuid, std::dec);
return packet;
}
network::Packet AttackStopPacket::build() {
network::Packet packet(static_cast<uint16_t>(Opcode::CMSG_ATTACKSTOP));
LOG_DEBUG("Built CMSG_ATTACKSTOP");
return packet;
}
bool AttackStartParser::parse(network::Packet& packet, AttackStartData& data) {
if (packet.getSize() < 16) return false;
data.attackerGuid = packet.readUInt64();
@ -1971,13 +1997,6 @@ network::Packet CastSpellPacket::build(uint32_t spellId, uint64_t targetGuid, ui
return packet;
}
network::Packet CancelCastPacket::build(uint32_t spellId) {
network::Packet packet(static_cast<uint16_t>(Opcode::CMSG_CANCEL_CAST));
packet.writeUInt32(0); // sequence
packet.writeUInt32(spellId);
return packet;
}
network::Packet CancelAuraPacket::build(uint32_t spellId) {
network::Packet packet(static_cast<uint16_t>(Opcode::CMSG_CANCEL_AURA));
packet.writeUInt32(spellId);