Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
CombatHandler.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#include "
Common.h
"
7
#include "
CreatureAI.h
"
8
#include "
Log.h
"
9
#include "
ObjectAccessor.h
"
10
#include "
ObjectDefines.h
"
11
#include "
Opcodes.h
"
12
#include "
Player.h
"
13
#include "
Vehicle.h
"
14
#include "
VehicleDefines.h
"
15
#include "
WorldPacket.h
"
16
#include "
WorldSession.h
"
17
18
void
WorldSession::HandleAttackSwingOpcode
(
WorldPacket
& recvData)
19
{
20
ObjectGuid
guid;
21
22
recvData.
ReadGuidMask
(guid, 6, 5, 7, 0, 3, 1, 4, 2);
23
recvData.
ReadGuidBytes
(guid, 6, 7, 1, 3, 2, 0, 4, 5);
24
25
SF_LOG_DEBUG
(
"network"
,
"WORLD: Recvd CMSG_ATTACKSWING Message guidlow:%u guidhigh:%u"
,
GUID_LOPART
(guid),
GUID_HIPART
(guid));
26
27
Unit
* pEnemy =
ObjectAccessor::GetUnit
(*
_player
, guid);
28
29
if
(!pEnemy)
30
{
31
// stop attack state at client
32
SendAttackStop
(NULL);
33
return
;
34
}
35
36
if
(!
_player
->IsValidAttackTarget(pEnemy))
37
{
38
// stop attack state at client
39
SendAttackStop
(pEnemy);
40
return
;
41
}
42
46
if
(
Vehicle
* vehicle =
_player
->GetVehicle())
47
{
48
VehicleSeatEntry
const
* seat = vehicle->GetSeatForPassenger(
_player
);
49
ASSERT
(seat);
50
if
(!(seat->
m_flags
&
VEHICLE_SEAT_FLAG_CAN_ATTACK
))
51
{
52
SendAttackStop
(pEnemy);
53
return
;
54
}
55
}
56
57
_player
->Attack(pEnemy,
true
);
58
}
59
60
void
WorldSession::HandleAttackStopOpcode
(
WorldPacket
&
/*recvData*/
)
61
{
62
GetPlayer
()->
AttackStop
();
63
}
64
65
void
WorldSession::HandleSetSheathedOpcode
(
WorldPacket
& recvData)
66
{
67
uint32
sheathed;
68
bool
hasData =
false
;
69
70
recvData >> sheathed;
71
hasData = recvData.
ReadBit
();
72
73
//SF_LOG_DEBUG("network", "WORLD: Recvd CMSG_SETSHEATHED Message guidlow:%u value1:%u", GetPlayer()->GetGUIDLow(), sheathed);
74
75
if
(hasData)
76
{
77
if
(sheathed >=
MAX_SHEATH_STATE
)
78
{
79
SF_LOG_ERROR
(
"network"
,
"Unknown sheath state %u ??"
, sheathed);
80
return
;
81
}
82
83
GetPlayer
()->
SetSheath
(
SheathState
(sheathed));
84
}
85
}
86
87
void
WorldSession::SendAttackStop
(
Unit
const
* enemy)
88
{
89
WorldPacket
data(
SMSG_ATTACKSTOP
, (8 + 8 + 4));
// we guess size
90
data.
append
(
GetPlayer
()->GetPackGUID());
91
data.
append
(enemy ? enemy->
GetPackGUID
() : 0);
// must be packed guid
92
data <<
uint32
(0);
// unk, can be 1 also
93
SendPacket
(&data);
94
}
Common.h
CreatureAI.h
VEHICLE_SEAT_FLAG_CAN_ATTACK
@ VEHICLE_SEAT_FLAG_CAN_ATTACK
Definition
DBCEnums.h:532
uint32
std::uint32_t uint32
Definition
Define.h:77
ASSERT
#define ASSERT
Definition
Errors.h:29
Log.h
SF_LOG_DEBUG
#define SF_LOG_DEBUG(filterType__,...)
Definition
Log.h:134
SF_LOG_ERROR
#define SF_LOG_ERROR(filterType__,...)
Definition
Log.h:143
ObjectAccessor.h
ObjectDefines.h
GUID_LOPART
uint32 GUID_LOPART(uint64 x)
Definition
ObjectDefines.h:208
GUID_HIPART
uint32 GUID_HIPART(uint64 guid)
Definition
ObjectDefines.h:195
Opcodes.h
Player.h
SheathState
SheathState
Definition
Unit.h:244
MAX_SHEATH_STATE
#define MAX_SHEATH_STATE
Definition
Unit.h:250
Vehicle.h
VehicleDefines.h
WorldPacket.h
WorldSession.h
ByteBuffer::ReadGuidBytes
void ReadGuidBytes(ObjectGuid &guid, Offsets... offsets)
Definition
ByteBuffer.h:256
ByteBuffer::append
void append(T value)
Definition
ByteBuffer.h:147
ByteBuffer::ReadGuidMask
void ReadGuidMask(ObjectGuid &guid, Offsets... offsets)
Definition
ByteBuffer.h:240
ByteBuffer::ReadBit
bool ReadBit()
Definition
ByteBuffer.h:180
ObjectAccessor::GetUnit
static Unit * GetUnit(WorldObject const &, uint64 guid)
Definition
ObjectAccessor.cpp:204
Object::GetPackGUID
const ByteBuffer & GetPackGUID() const
Definition
Object.h:124
Player::SetSheath
void SetSheath(SheathState sheathed) override
Definition
Player.cpp:10471
Unit
Definition
Unit.h:1367
Unit::AttackStop
bool AttackStop()
Definition
UnitCombatState.cpp:183
Vehicle
Definition
Vehicle.h:22
WorldPacket
Definition
WorldPacket.h:16
WorldSession::GetPlayer
Player * GetPlayer() const
Definition
WorldSession.h:295
WorldSession::SendPacket
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition
WorldSession.cpp:196
WorldSession::_player
Player * _player
Definition
WorldSession.h:1188
WorldSession::HandleAttackSwingOpcode
void HandleAttackSwingOpcode(WorldPacket &recvPacket)
Definition
CombatHandler.cpp:18
WorldSession::SendAttackStop
void SendAttackStop(Unit const *enemy)
Definition
CombatHandler.cpp:87
WorldSession::HandleSetSheathedOpcode
void HandleSetSheathedOpcode(WorldPacket &recvPacket)
Definition
CombatHandler.cpp:65
WorldSession::HandleAttackStopOpcode
void HandleAttackStopOpcode(WorldPacket &recvPacket)
Definition
CombatHandler.cpp:60
SMSG_ATTACKSTOP
@ SMSG_ATTACKSTOP
Definition
Opcodes.h:520
ObjectGuid
Definition
ByteBuffer.h:66
VehicleSeatEntry
Definition
DBCStructure.h:2862
VehicleSeatEntry::m_flags
uint32 m_flags
Definition
DBCStructure.h:2864
src
server
game
Handlers
CombatHandler.cpp
Generated on
for Project SkyFire Core by
1.17.0