ManaPlus
Functions
EAthena::MercenaryRecv Namespace Reference

Functions

void handleMercenaryMessage (const int cmd)
 
void processMercenaryUpdate (Net::MessageIn &msg)
 
void processMercenaryInfo (Net::MessageIn &msg)
 
void processMercenarySkills (Net::MessageIn &msg)
 

Function Documentation

◆ handleMercenaryMessage()

void EAthena::MercenaryRecv::handleMercenaryMessage ( const int  cmd)

Definition at line 187 of file mercenaryrecv.cpp.

188 {
189  PlayerInfo::setMercenary(nullptr);
190  if (skillDialog != nullptr)
191  {
194  }
195 
196  switch (cmd)
197  {
198  case 0:
200  break;
201  case 1:
203  break;
204  case 2:
206  break;
207  case 3:
209  break;
210  default:
212  break;
213  }
214 }
void updateModels()
void hideSkills(const SkillOwner::Type owner)
void notify(const unsigned int message)
void setMercenary(MercenaryInfo *const info)
Definition: playerinfo.cpp:520
SkillDialog * skillDialog
Definition: skilldialog.cpp:66

References SkillDialog::hideSkills(), SkillOwner::Mercenary, NotifyTypes::MERCENARY_EXPIRED, NotifyTypes::MERCENARY_FIRED, NotifyTypes::MERCENARY_KILLED, NotifyTypes::MERCENARY_RUN, NotifyTypes::MERCENARY_UNKNOWN, NotifyManager::notify(), PlayerInfo::setMercenary(), skillDialog, and SkillDialog::updateModels().

Referenced by EAthena::ChatRecv::processFormatMessage().

◆ processMercenaryInfo()

void EAthena::MercenaryRecv::processMercenaryInfo ( Net::MessageIn msg)

Definition at line 80 of file mercenaryrecv.cpp.

81 {
82  if (actorManager == nullptr)
83  return;
84  // +++ need create if need mercenary being and update stats
85  Being *const dstBeing = actorManager->findBeing(
86  msg.readBeingId("being id"));
88  msg.readInt16("atk"),
89  Notify_true);
91  msg.readInt16("matk"),
92  Notify_true);
94  msg.readInt16("hit"),
95  Notify_true);
97  msg.readInt16("crit/10"),
98  Notify_true);
100  msg.readInt16("def"),
101  Notify_true);
103  msg.readInt16("mdef"),
104  Notify_true);
106  msg.readInt16("flee"),
107  Notify_true);
109  msg.readInt16("attack speed"),
110  Notify_true);
111  const std::string name = msg.readString(24, "name");
112  const int level = msg.readInt16("level");
114  level,
115  Notify_true);
117  msg.readInt32("hp"),
118  Notify_true);
120  msg.readInt32("max hp"),
121  Notify_true);
123  msg.readInt32("sp"),
124  Notify_true);
126  msg.readInt32("max sp"),
127  Notify_true);
129  msg.readInt32("expire time"),
130  Notify_true);
132  msg.readInt16("faith"),
133  Notify_true);
135  msg.readInt32("calls"),
136  Notify_true);
138  msg.readInt32("kills"),
139  Notify_true);
140  const int range = msg.readInt16("attack range");
142  range,
143  Notify_true);
145 
146  if ((dstBeing != nullptr) && (localPlayer != nullptr))
147  {
148  MercenaryInfo *const mercenary = new MercenaryInfo;
149  mercenary->id = dstBeing->getId();
150  mercenary->name = name;
151  mercenary->level = level;
152  mercenary->range = range;
153  PlayerInfo::setMercenary(mercenary);
155  }
156 }
ActorManager * actorManager
Being * findBeing(const BeingId id) const
BeingId getId() const
Definition: actorsprite.h:64
Definition: being.h:96
LocalPlayer * localPlayer
bool msg(InputEvent &event)
Definition: chat.cpp:39
@ MERC_ATTACK_RANGE
Definition: attributes.h:96
@ MERC_ATTACK_DELAY
Definition: attributes.h:95
void setMercenaryBeing(Being *const being)
Definition: playerinfo.cpp:526
void updateAttrs()
Definition: playerinfo.cpp:420
void setStatBase(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:143
const bool Notify_true
Definition: notify.h:30
std::string name
Definition: mercenaryinfo.h:41

References actorManager, ActorManager::findBeing(), ActorSprite::getId(), MercenaryInfo::id, MercenaryInfo::level, localPlayer, Attributes::MERC_ATK, Attributes::MERC_ATTACK_DELAY, Attributes::MERC_ATTACK_RANGE, Attributes::MERC_CALLS, Attributes::MERC_CRIT, Attributes::MERC_DEF, Attributes::MERC_EXPIRE, Attributes::MERC_FAITH, Attributes::MERC_FLEE, Attributes::MERC_HIT, Attributes::MERC_HP, Attributes::MERC_KILLS, Attributes::MERC_LEVEL, Attributes::MERC_MATK, Attributes::MERC_MAX_HP, Attributes::MERC_MAX_MP, Attributes::MERC_MDEF, Attributes::MERC_MP, Actions::msg(), MercenaryInfo::name, Notify_true, MercenaryInfo::range, PlayerInfo::setMercenary(), PlayerInfo::setMercenaryBeing(), PlayerInfo::setStatBase(), and PlayerInfo::updateAttrs().

◆ processMercenarySkills()

void EAthena::MercenaryRecv::processMercenarySkills ( Net::MessageIn msg)

Definition at line 158 of file mercenaryrecv.cpp.

159 {
160  if (skillDialog != nullptr)
162  const int count = (msg.readInt16("len") - 4) / 37;
163  for (int f = 0; f < count; f ++)
164  {
165  const int skillId = msg.readInt16("skill id");
166  const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
167  msg.readInt32("inf"));
168  const int level = msg.readInt16("skill level");
169  const int sp = msg.readInt16("sp");
170  const int range = msg.readInt16("range");
171  const std::string name = msg.readString(24, "skill name");
172  const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
173  PlayerInfo::setSkillLevel(skillId, level);
174  if (skillDialog != nullptr)
175  {
176  if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
177  {
179  skillId, name, level, range, up, inf, sp);
180  }
181  }
182  }
183  if (skillDialog != nullptr)
185 }
#define fromBool(val, name)
Definition: booldefines.h:49
bool updateSkill(const int id, const int range, const Modifiable modifiable, const SkillType::SkillType type, const int sp)
void addSkill(const SkillOwner::Type owner, const int id, const std::string &name, const int level, const int range, const Modifiable modifiable, const SkillType::SkillType type, const int sp)
bool Modifiable
Definition: modifiable.h:30
void setSkillLevel(const int id, const int value)
Definition: playerinfo.cpp:128

References SkillDialog::addSkill(), fromBool, SkillDialog::hideSkills(), SkillOwner::Mercenary, Actions::msg(), PlayerInfo::setSkillLevel(), skillDialog, SkillDialog::updateModels(), and SkillDialog::updateSkill().

◆ processMercenaryUpdate()

void EAthena::MercenaryRecv::processMercenaryUpdate ( Net::MessageIn msg)

Definition at line 53 of file mercenaryrecv.cpp.

54 {
55  const int sp = msg.readInt16("type");
56  const int val = msg.readInt32("value");
57  switch (sp)
58  {
73  default:
74  reportAlways("Unknown mercenary stat %d",
75  sp)
76  break;
77  }
78 }
#define reportAlways(...)
Definition: checkutils.h:253
#define setMercStat(sp, stat)
@ MERCKILLS
Definition: sp.h:107
@ MERCFLEE
Definition: sp.h:105
@ MERCFAITH
Definition: sp.h:108
@ MAXSP
Definition: sp.h:39
@ DEF1
Definition: sp.h:76
@ MATK1
Definition: sp.h:74
@ CRITICAL
Definition: sp.h:83
@ ASPD
Definition: sp.h:84
@ MDEF1
Definition: sp.h:78
@ ATK1
Definition: sp.h:72
@ SP
Definition: sp.h:38
@ HIT
Definition: sp.h:80
@ HP
Definition: sp.h:36
@ MAXHP
Definition: sp.h:37

References Sp::ASPD, Sp::ATK1, Sp::CRITICAL, Sp::DEF1, Sp::HIT, Sp::HP, Sp::MATK1, Sp::MAXHP, Sp::MAXSP, Sp::MDEF1, Attributes::MERC_ATK, Attributes::MERC_ATTACK_DELAY, Attributes::MERC_CRIT, Attributes::MERC_DEF, Attributes::MERC_FAITH, Attributes::MERC_FLEE, Attributes::MERC_HIT, Attributes::MERC_HP, Attributes::MERC_KILLS, Attributes::MERC_MATK, Attributes::MERC_MAX_HP, Attributes::MERC_MAX_MP, Attributes::MERC_MDEF, Attributes::MERC_MP, Sp::MERCFAITH, Sp::MERCFLEE, Sp::MERCKILLS, Actions::msg(), reportAlways, setMercStat, and Sp::SP.