ManaPlus
Public Member Functions
EAthena::HomunculusHandler Class Reference

#include <homunculushandler.h>

Inheritance diagram for EAthena::HomunculusHandler:
Net::HomunculusHandler

Public Member Functions

 HomunculusHandler ()
 
 ~HomunculusHandler ()
 
void setName (const std::string &name) const
 
void moveToMaster () const
 
void move (const int x, const int y) const
 
void attack (const BeingId targetId, const Keep keep) const
 
void feed () const
 
void fire () 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::HomunculusHandler
 HomunculusHandler ()
 

Detailed Description

Definition at line 29 of file homunculushandler.h.

Constructor & Destructor Documentation

◆ HomunculusHandler()

EAthena::HomunculusHandler::HomunculusHandler ( )

Definition at line 38 of file homunculushandler.cpp.

39 {
40  homunculusHandler = this;
41 }
Net::HomunculusHandler * homunculusHandler
Definition: net.cpp:112

References homunculusHandler.

◆ ~HomunculusHandler()

EAthena::HomunculusHandler::~HomunculusHandler ( )
virtual

Reimplemented from Net::HomunculusHandler.

Definition at line 43 of file homunculushandler.cpp.

44 {
45  homunculusHandler = nullptr;
46 }

References homunculusHandler.

Member Function Documentation

◆ attack()

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

Implements Net::HomunculusHandler.

Definition at line 75 of file homunculushandler.cpp.

77 {
79  if (id == BeingId_zero)
80  return;
81  createOutPacket(CMSG_HOMMERC_ATTACK);
82  outMsg.writeBeingId(id, "homunculus id");
83  outMsg.writeBeingId(targetId, "target id");
84  outMsg.writeInt8(CAST_S8(keep == Keep_true ? 1 : 0), "keep");
85 }
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 getHomunculusId()
Definition: playerinfo.cpp:608

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

◆ emote()

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

Implements Net::HomunculusHandler.

Definition at line 122 of file homunculushandler.cpp.

123 {
124  if (!serverFeatures->haveMovePet())
125  return;
126  createOutPacket(CMSG_HOMMERC_EMOTE);
127  outMsg.writeInt8(emoteId, "emote id");
128 }
virtual bool haveMovePet() const =0
Net::ServerFeatures * serverFeatures
Definition: net.cpp:101

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

◆ feed()

void EAthena::HomunculusHandler::feed ( ) const
virtual

Implements Net::HomunculusHandler.

Definition at line 87 of file homunculushandler.cpp.

88 {
89  if (packetVersion < 20050425)
90  return;
91  createOutPacket(CMSG_HOMUNCULUS_MENU);
92  outMsg.writeInt16(0, "type");
93  outMsg.writeInt8(1, "command"); // feed
94 }
int packetVersion
Definition: client.cpp:125

References createOutPacket, and packetVersion.

◆ fire()

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

Implements Net::HomunculusHandler.

Definition at line 96 of file homunculushandler.cpp.

97 {
98  if (packetVersion < 20050425)
99  return;
100  createOutPacket(CMSG_HOMUNCULUS_MENU);
101  outMsg.writeInt16(0, "type");
102  outMsg.writeInt8(2, "command"); // delete
103 }

References createOutPacket, and packetVersion.

◆ move()

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

Implements Net::HomunculusHandler.

Definition at line 63 of file homunculushandler.cpp.

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

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

◆ moveToMaster()

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

Implements Net::HomunculusHandler.

Definition at line 54 of file homunculushandler.cpp.

55 {
57  if (id == BeingId_zero)
58  return;
59  createOutPacket(CMSG_HOMMERC_MOVE_TO_MASTER);
60  outMsg.writeBeingId(id, "homunculus id");
61 }

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

◆ setDirection()

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

Implements Net::HomunculusHandler.

Definition at line 130 of file homunculushandler.cpp.

131 {
132  if (!serverFeatures->haveMovePet())
133  return;
134  createOutPacket(CMSG_HOMMERC_DIRECTION);
135  outMsg.writeInt32(0, "pet id");
136  outMsg.writeInt8(0, "head direction");
137  outMsg.writeInt8(0, "unused");
138  outMsg.writeInt8(MessageOut::toServerDirection(type),
139  "pet direction");
140 }
static unsigned char toServerDirection(unsigned char direction) A_CONST
Definition: messageout.cpp:253

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

◆ setName()

void EAthena::HomunculusHandler::setName ( const std::string &  name) const
virtual

Implements Net::HomunculusHandler.

Definition at line 48 of file homunculushandler.cpp.

49 {
50  createOutPacket(CMSG_HOMUNCULUS_SET_NAME);
51  outMsg.writeString(name, 24, "name");
52 }

References createOutPacket.

◆ talk()

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

Implements Net::HomunculusHandler.

Definition at line 105 of file homunculushandler.cpp.

106 {
107  if (!serverFeatures->haveMovePet())
108  return;
109  if (text.empty())
110  return;
111  std::string msg = text;
112  if (msg.size() > 500)
113  msg = msg.substr(0, 500);
114  const size_t sz = msg.size();
115 
116  createOutPacket(CMSG_HOMMERC_TALK);
117  outMsg.writeInt16(CAST_S16(sz + 4 + 1), "len");
118  outMsg.writeString(msg, CAST_S32(sz), "message");
119  outMsg.writeInt8(0, "zero byte");
120 }
#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: