ManaPlus
Functions
EAthena::HomunculusRecv Namespace Reference

Functions

void processHomunculusSkills (Net::MessageIn &msg)
 
void processHomunculusData (Net::MessageIn &msg)
 
void processHomunculusInfo1 (Net::MessageIn &msg)
 
void processHomunculusInfo2 (Net::MessageIn &msg)
 
void processHomunculusInfo3 (Net::MessageIn &msg)
 
void processHomunculusSkillUp (Net::MessageIn &msg)
 
void processHomunculusFood (Net::MessageIn &msg)
 
void processHomunculusExp (Net::MessageIn &msg)
 

Function Documentation

◆ processHomunculusData()

void EAthena::HomunculusRecv::processHomunculusData ( Net::MessageIn msg)

Definition at line 79 of file homunculusrecv.cpp.

80 {
81  if (actorManager == nullptr)
82  return;
83  msg.readUInt8("unused");
84  const int cmd = msg.readUInt8("state");
85  const BeingId id = msg.readBeingId("homunculus id");
86  Being *const dstBeing = actorManager->findBeing(id);
87  const int data = msg.readInt32("data");
88  if (cmd == 0) // pre init
89  {
90  HomunculusInfo *const info = new HomunculusInfo;
91  info->id = id;
94  return;
95  }
97  if (info == nullptr)
98  return;
99  switch (cmd)
100  {
101  case 1: // intimacy
102  info->intimacy = data;
103  break;
104  case 2: // hunger
105  info->hungry = data;
106  break;
107  case 3: // accesory
108  info->equip = data;
109  break;
110  default:
111  break;
112  }
113 }
ActorManager * actorManager
int BeingId
Definition: beingid.h:30
Being * findBeing(const BeingId id) const
Definition: being.h:96
uint32_t data
bool msg(InputEvent &event)
Definition: chat.cpp:39
bool info(InputEvent &event)
Definition: commands.cpp:57
HomunculusInfo * getHomunculus()
Definition: playerinfo.cpp:603
void setHomunculusBeing(Being *const being)
Definition: playerinfo.cpp:592
void setHomunculus(HomunculusInfo *const info)
Definition: playerinfo.cpp:586

References actorManager, data, ActorManager::findBeing(), PlayerInfo::getHomunculus(), Actions::info(), Actions::msg(), PlayerInfo::setHomunculus(), and PlayerInfo::setHomunculusBeing().

◆ processHomunculusExp()

void EAthena::HomunculusRecv::processHomunculusExp ( Net::MessageIn msg)

Definition at line 387 of file homunculusrecv.cpp.

388 {
389  const int exp = msg.readInt32("exp");
390  msg.readInt32("unused");
391  if (localPlayer != nullptr)
393 }
void addHomunXpMessage(const int change)
LocalPlayer * localPlayer

References LocalPlayer::addHomunXpMessage(), localPlayer, and Actions::msg().

◆ processHomunculusFood()

void EAthena::HomunculusRecv::processHomunculusFood ( Net::MessageIn msg)

Definition at line 371 of file homunculusrecv.cpp.

372 {
373  const int flag = msg.readUInt8("fail");
374  const int itemId = msg.readItemId("food id");
375  if (flag != 0)
376  {
378  }
379  else
380  {
381  const std::string name = strprintf("[@@%d|%s@@]", itemId,
382  ItemDB::get(itemId).getName().c_str());
384  }
385 }
const std::string & getName(const int id)
Definition: groupdb.cpp:344
const ItemInfo & get(const int id)
Definition: itemdb.cpp:792
void notify(const unsigned int message)
@ HOMUNCULUS_FEED_FAIL
Definition: notifytypes.h:125
@ HOMUNCULUS_FEED_OK
Definition: notifytypes.h:124
std::string strprintf(const char *const format,...)

References ItemDB::get(), GroupDb::getName(), NotifyTypes::HOMUNCULUS_FEED_FAIL, NotifyTypes::HOMUNCULUS_FEED_OK, Actions::msg(), NotifyManager::notify(), and strprintf().

◆ processHomunculusInfo1()

void EAthena::HomunculusRecv::processHomunculusInfo1 ( Net::MessageIn msg)

Definition at line 115 of file homunculusrecv.cpp.

116 {
117  if (actorManager == nullptr)
118  return;
119  const std::string name = msg.readString(24, "name");
120  msg.readUInt8("flags"); // 0x01 - renamed, 0x02 - vaporize, 0x04 - alive
121  const int level = msg.readInt16("level");
123  level,
124  Notify_true);
125  const int hungry = msg.readInt16("hungry");
126  const int intimacy = msg.readInt16("intimacy");
127  const int equip = msg.readItemId("item id");
129  msg.readInt16("atk"),
130  Notify_true);
132  msg.readInt16("matk"),
133  Notify_true);
135  msg.readInt16("hit"),
136  Notify_true);
138  msg.readInt16("luk/3 or crit/10"),
139  Notify_true);
141  msg.readInt16("def"),
142  Notify_true);
144  msg.readInt16("mdef"),
145  Notify_true);
147  msg.readInt16("flee"),
148  Notify_true);
150  msg.readInt16("attack speed"),
151  Notify_true);
153  msg.readInt16("hp"),
154  Notify_true);
156  msg.readInt16("max hp"),
157  Notify_true);
159  msg.readInt16("sp"),
160  Notify_true);
162  msg.readInt16("max sp"),
163  Notify_true);
165  msg.readInt32("exp"),
166  Notify_true);
168  msg.readInt32("next exp"),
169  Notify_true);
171  msg.readInt16("skill points"),
172  Notify_true);
173  const int range = msg.readInt16("attack range");
175  range,
176  Notify_true);
177 
180  if (info == nullptr)
181  return;
182  Being *const dstBeing = actorManager->findBeing(info->id);
183 
184  info->name = name;
185  info->level = level;
186  info->range = range;
187  info->hungry = hungry;
188  info->intimacy = intimacy;
189  info->equip = equip;
191 }
@ HOMUN_MAX_MP
Definition: attributes.h:74
@ HOMUN_EXP_NEEDED
Definition: attributes.h:76
@ HOMUN_SKILL_POINTS
Definition: attributes.h:77
@ HOMUN_ATTACK_RANGE
Definition: attributes.h:79
@ HOMUN_MAX_HP
Definition: attributes.h:72
@ HOMUN_ATTACK_DELAY
Definition: attributes.h:78
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

References actorManager, ActorManager::findBeing(), PlayerInfo::getHomunculus(), Attributes::HOMUN_ATK, Attributes::HOMUN_ATTACK_DELAY, Attributes::HOMUN_ATTACK_RANGE, Attributes::HOMUN_CRIT, Attributes::HOMUN_DEF, Attributes::HOMUN_EXP, Attributes::HOMUN_EXP_NEEDED, Attributes::HOMUN_FLEE, Attributes::HOMUN_HIT, Attributes::HOMUN_HP, Attributes::HOMUN_LEVEL, Attributes::HOMUN_MATK, Attributes::HOMUN_MAX_HP, Attributes::HOMUN_MAX_MP, Attributes::HOMUN_MDEF, Attributes::HOMUN_MP, Attributes::HOMUN_SKILL_POINTS, Actions::info(), Actions::msg(), Notify_true, PlayerInfo::setHomunculusBeing(), PlayerInfo::setStatBase(), and PlayerInfo::updateAttrs().

◆ processHomunculusInfo2()

void EAthena::HomunculusRecv::processHomunculusInfo2 ( Net::MessageIn msg)

Definition at line 193 of file homunculusrecv.cpp.

194 {
195  if (actorManager == nullptr)
196  return;
197  const std::string name = msg.readString(24, "name");
198  msg.readUInt8("flags"); // 0x01 - renamed, 0x02 - vaporize, 0x04 - alive
199  const int level = msg.readInt16("level");
201  level,
202  Notify_true);
203  const int hungry = msg.readInt16("hungry");
204  const int intimacy = msg.readInt16("intimacy");
205  const int equip = msg.readItemId("item id");
207  msg.readInt16("atk"),
208  Notify_true);
210  msg.readInt16("matk"),
211  Notify_true);
213  msg.readInt16("hit"),
214  Notify_true);
216  msg.readInt16("luk/3 or crit/10"),
217  Notify_true);
219  msg.readInt16("def"),
220  Notify_true);
222  msg.readInt16("mdef"),
223  Notify_true);
225  msg.readInt16("flee"),
226  Notify_true);
228  msg.readInt16("attack speed"),
229  Notify_true);
231  msg.readInt32("hp"),
232  Notify_true);
234  msg.readInt32("max hp"),
235  Notify_true);
237  msg.readInt16("sp"),
238  Notify_true);
240  msg.readInt16("max sp"),
241  Notify_true);
243  msg.readInt32("exp"),
244  Notify_true);
246  msg.readInt32("next exp"),
247  Notify_true);
249  msg.readInt16("skill points"),
250  Notify_true);
251  const int range = msg.readInt16("attack range");
253  range,
254  Notify_true);
255 
258  if (info == nullptr)
259  return;
260  Being *const dstBeing = actorManager->findBeing(info->id);
261 
262  info->name = name;
263  info->level = level;
264  info->range = range;
265  info->hungry = hungry;
266  info->intimacy = intimacy;
267  info->equip = equip;
269 }

References actorManager, ActorManager::findBeing(), PlayerInfo::getHomunculus(), Attributes::HOMUN_ATK, Attributes::HOMUN_ATTACK_DELAY, Attributes::HOMUN_ATTACK_RANGE, Attributes::HOMUN_CRIT, Attributes::HOMUN_DEF, Attributes::HOMUN_EXP, Attributes::HOMUN_EXP_NEEDED, Attributes::HOMUN_FLEE, Attributes::HOMUN_HIT, Attributes::HOMUN_HP, Attributes::HOMUN_LEVEL, Attributes::HOMUN_MATK, Attributes::HOMUN_MAX_HP, Attributes::HOMUN_MAX_MP, Attributes::HOMUN_MDEF, Attributes::HOMUN_MP, Attributes::HOMUN_SKILL_POINTS, Actions::info(), Actions::msg(), Notify_true, PlayerInfo::setHomunculusBeing(), PlayerInfo::setStatBase(), and PlayerInfo::updateAttrs().

◆ processHomunculusInfo3()

void EAthena::HomunculusRecv::processHomunculusInfo3 ( Net::MessageIn msg)

Definition at line 271 of file homunculusrecv.cpp.

272 {
273  if (actorManager == nullptr)
274  return;
275  const std::string name = msg.readString(24, "name");
276  msg.readUInt8("flags"); // 0x01 - renamed, 0x02 - vaporize, 0x04 - alive
277  const int level = msg.readInt16("level");
279  level,
280  Notify_true);
281  const int hungry = msg.readInt16("hungry");
282  const int intimacy = msg.readInt16("intimacy");
284  msg.readInt16("atk"),
285  Notify_true);
287  msg.readInt16("matk"),
288  Notify_true);
290  msg.readInt16("hit"),
291  Notify_true);
293  msg.readInt16("luk/3 or crit/10"),
294  Notify_true);
296  msg.readInt16("def"),
297  Notify_true);
299  msg.readInt16("mdef"),
300  Notify_true);
302  msg.readInt16("flee"),
303  Notify_true);
305  msg.readInt16("attack speed"),
306  Notify_true);
308  msg.readInt32("hp"),
309  Notify_true);
311  msg.readInt32("max hp"),
312  Notify_true);
314  msg.readInt16("sp"),
315  Notify_true);
317  msg.readInt16("max sp"),
318  Notify_true);
320  msg.readInt32("exp"),
321  Notify_true);
323  msg.readInt32("next exp"),
324  Notify_true);
326  msg.readInt16("skill points"),
327  Notify_true);
328  const int range = msg.readInt16("attack range");
330  range,
331  Notify_true);
332 
335  if (info == nullptr)
336  return;
337  Being *const dstBeing = actorManager->findBeing(info->id);
338 
339  info->name = name;
340  info->level = level;
341  info->range = range;
342  info->hungry = hungry;
343  info->intimacy = intimacy;
344  info->equip = 0;
346 }

References actorManager, ActorManager::findBeing(), PlayerInfo::getHomunculus(), Attributes::HOMUN_ATK, Attributes::HOMUN_ATTACK_DELAY, Attributes::HOMUN_ATTACK_RANGE, Attributes::HOMUN_CRIT, Attributes::HOMUN_DEF, Attributes::HOMUN_EXP, Attributes::HOMUN_EXP_NEEDED, Attributes::HOMUN_FLEE, Attributes::HOMUN_HIT, Attributes::HOMUN_HP, Attributes::HOMUN_LEVEL, Attributes::HOMUN_MATK, Attributes::HOMUN_MAX_HP, Attributes::HOMUN_MAX_MP, Attributes::HOMUN_MDEF, Attributes::HOMUN_MP, Attributes::HOMUN_SKILL_POINTS, Actions::info(), Actions::msg(), Notify_true, PlayerInfo::setHomunculusBeing(), PlayerInfo::setStatBase(), and PlayerInfo::updateAttrs().

◆ processHomunculusSkills()

void EAthena::HomunculusRecv::processHomunculusSkills ( Net::MessageIn msg)

Definition at line 48 of file homunculusrecv.cpp.

49 {
50  if (skillDialog != nullptr)
52 
53  const int count = (msg.readInt16("len") - 4) / 37;
54  for (int f = 0; f < count; f ++)
55  {
56  const int skillId = msg.readInt16("skill id");
57  const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
58  msg.readInt16("inf"));
59  msg.readInt16("unused");
60  const int level = msg.readInt16("skill level");
61  const int sp = msg.readInt16("sp");
62  const int range = msg.readInt16("range");
63  const std::string name = msg.readString(24, "skill name");
64  const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
65  PlayerInfo::setSkillLevel(skillId, level);
66  if (skillDialog != nullptr)
67  {
68  if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
69  {
71  skillId, name, level, range, up, inf, sp);
72  }
73  }
74  }
75  if (skillDialog != nullptr)
77 }
#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 updateModels()
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)
void hideSkills(const SkillOwner::Type owner)
bool Modifiable
Definition: modifiable.h:30
void setSkillLevel(const int id, const int value)
Definition: playerinfo.cpp:128
SkillDialog * skillDialog
Definition: skilldialog.cpp:66

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

◆ processHomunculusSkillUp()

void EAthena::HomunculusRecv::processHomunculusSkillUp ( Net::MessageIn msg)

Definition at line 348 of file homunculusrecv.cpp.

349 {
350  const int skillId = msg.readInt16("skill id");
351  const int level = msg.readInt16("level");
352  const int sp = msg.readInt16("sp");
353  const int range = msg.readInt16("range");
354  const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
355 
356  if (skillDialog != nullptr && PlayerInfo::getSkillLevel(skillId) != level)
357  skillDialog->playUpdateEffect(skillId);
358  PlayerInfo::setSkillLevel(skillId, level);
359  if (skillDialog != nullptr)
360  {
361  if (!skillDialog->updateSkill(skillId, range,
362  up, SkillType::Unknown, sp))
363  {
365  skillId, "", level,
366  range, up, SkillType::Unknown, sp);
367  }
368  }
369 }
void playUpdateEffect(const int id) const
int getSkillLevel(const int id)
Definition: playerinfo.cpp:120

References SkillDialog::addSkill(), fromBool, PlayerInfo::getSkillLevel(), SkillOwner::Homunculus, Actions::msg(), SkillDialog::playUpdateEffect(), PlayerInfo::setSkillLevel(), skillDialog, SkillType::Unknown, and SkillDialog::updateSkill().