ManaPlus
Public Member Functions
EAthena::MercenaryHandler Class Reference

#include <mercenaryhandler.h>

Inheritance diagram for EAthena::MercenaryHandler:
Net::MercenaryHandler

Public Member Functions

 MercenaryHandler ()
 
 ~MercenaryHandler ()
 
void fire () const
 
void moveToMaster () const
 
void move (const int x, const int y) const
 
void attack (const BeingId targetId, const Keep keep) const
 
void talk (const std::string &text) const
 
void emote (const uint8_t emoteId) const
 
void setDirection (const unsigned char type) const
 
- Public Member Functions inherited from Net::MercenaryHandler
 MercenaryHandler ()
 

Detailed Description

Definition at line 29 of file mercenaryhandler.h.

Constructor & Destructor Documentation

◆ MercenaryHandler()

EAthena::MercenaryHandler::MercenaryHandler ( )

Definition at line 36 of file mercenaryhandler.cpp.

37 {
38  mercenaryHandler = this;
39 }
Net::MercenaryHandler * mercenaryHandler
Definition: net.cpp:118

References mercenaryHandler.

◆ ~MercenaryHandler()

EAthena::MercenaryHandler::~MercenaryHandler ( )
virtual

Reimplemented from Net::MercenaryHandler.

Definition at line 41 of file mercenaryhandler.cpp.

42 {
43  mercenaryHandler = nullptr;
44 }

References mercenaryHandler.

Member Function Documentation

◆ attack()

void EAthena::MercenaryHandler::attack ( const BeingId  targetId,
const Keep  keep 
) const
virtual

Implements Net::MercenaryHandler.

Definition at line 73 of file mercenaryhandler.cpp.

75 {
77  if (id == BeingId_zero)
78  return;
79  createOutPacket(CMSG_HOMMERC_ATTACK);
80  outMsg.writeBeingId(id, "mercenary id");
81  outMsg.writeBeingId(targetId, "target id");
82  outMsg.writeInt8(CAST_S8(keep == Keep_true ? 1 : 0), "keep");
83 }
int BeingId
Definition: beingid.h:30
const BeingId BeingId_zero
Definition: beingid.h:30
#define CAST_S8
Definition: cast.h:26
const bool Keep_true
Definition: keep.h:30
#define createOutPacket(name)
Definition: messageout.h:37
BeingId getMercenaryId()
Definition: playerinfo.cpp:613

References BeingId_zero, CAST_S8, createOutPacket, PlayerInfo::getMercenaryId(), and Keep_true.

◆ emote()

void EAthena::MercenaryHandler::emote ( const uint8_t  emoteId) const
virtual

Implements Net::MercenaryHandler.

Definition at line 102 of file mercenaryhandler.cpp.

103 {
104  if (!serverFeatures->haveMovePet())
105  return;
106  createOutPacket(CMSG_HOMMERC_EMOTE);
107  outMsg.writeInt8(emoteId, "emote id");
108 }
virtual bool haveMovePet() const =0
Net::ServerFeatures * serverFeatures
Definition: net.cpp:101

References createOutPacket, Net::ServerFeatures::haveMovePet(), and serverFeatures.

◆ fire()

void EAthena::MercenaryHandler::fire ( ) const
virtual

Implements Net::MercenaryHandler.

Definition at line 46 of file mercenaryhandler.cpp.

47 {
48  createOutPacket(CMSG_MERCENARY_ACTION);
49  outMsg.writeInt8(2, "action"); // delete
50 }

References createOutPacket.

◆ move()

void EAthena::MercenaryHandler::move ( const int  x,
const int  y 
) const
virtual

Implements Net::MercenaryHandler.

Definition at line 61 of file mercenaryhandler.cpp.

62 {
64  if (id == BeingId_zero)
65  return;
66  createOutPacket(CMSG_HOMMERC_MOVE_TO);
67  outMsg.writeBeingId(id, "mercenary id");
68  outMsg.writeCoordinates(CAST_U16(x),
69  CAST_U16(y),
70  1U, "position");
71 }
#define CAST_U16
Definition: cast.h:29

References BeingId_zero, CAST_U16, createOutPacket, PlayerInfo::getMercenaryId(), x, and y.

◆ moveToMaster()

void EAthena::MercenaryHandler::moveToMaster ( ) const
virtual

Implements Net::MercenaryHandler.

Definition at line 52 of file mercenaryhandler.cpp.

53 {
55  if (id == BeingId_zero)
56  return;
57  createOutPacket(CMSG_HOMMERC_MOVE_TO_MASTER);
58  outMsg.writeBeingId(id, "mercenary id");
59 }

References BeingId_zero, createOutPacket, and PlayerInfo::getMercenaryId().

◆ setDirection()

void EAthena::MercenaryHandler::setDirection ( const unsigned char  type) const
virtual

Implements Net::MercenaryHandler.

Definition at line 110 of file mercenaryhandler.cpp.

111 {
112  if (!serverFeatures->haveMovePet())
113  return;
114  createOutPacket(CMSG_HOMMERC_DIRECTION);
115  outMsg.writeInt32(0, "pet id");
116  outMsg.writeInt8(0, "head direction");
117  outMsg.writeInt8(0, "unused");
118  outMsg.writeInt8(MessageOut::toServerDirection(type),
119  "pet direction");
120 }
static unsigned char toServerDirection(unsigned char direction) A_CONST
Definition: messageout.cpp:253

References createOutPacket, Net::ServerFeatures::haveMovePet(), serverFeatures, and Net::MessageOut::toServerDirection().

◆ talk()

void EAthena::MercenaryHandler::talk ( const std::string &  text) const
virtual

Implements Net::MercenaryHandler.

Definition at line 85 of file mercenaryhandler.cpp.

86 {
88  return;
89  if (text.empty())
90  return;
91  std::string msg = text;
92  if (msg.size() > 500)
93  msg = msg.substr(0, 500);
94  const size_t sz = msg.size();
95 
96  createOutPacket(CMSG_HOMMERC_TALK);
97  outMsg.writeInt16(CAST_S16(sz + 4 + 1), "len");
98  outMsg.writeString(msg, CAST_S32(sz), "message");
99  outMsg.writeInt8(0, "zero byte");
100 }
#define CAST_S16
Definition: cast.h:28
#define CAST_S32
Definition: cast.h:30
bool msg(InputEvent &event)
Definition: chat.cpp:39

References CAST_S16, CAST_S32, createOutPacket, Net::ServerFeatures::haveMovePet(), Actions::msg(), and serverFeatures.


The documentation for this class was generated from the following files: