ManaPlus
Functions
TmwAthena::SkillRecv Namespace Reference

Functions

void processSkillFailed (Net::MessageIn &msg)
 
void processPlayerSkills (Net::MessageIn &msg)
 

Function Documentation

◆ processPlayerSkills()

void TmwAthena::SkillRecv::processPlayerSkills ( Net::MessageIn msg)

Definition at line 46 of file skillrecv.cpp.

47 {
48  msg.readInt16("len");
49  const int skillCount = (msg.getLength() - 4) / 37;
50  int updateSkill = 0;
51 
52  for (int k = 0; k < skillCount; k++)
53  {
54  const int skillId = msg.readInt16("skill id");
55  const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
56  msg.readInt16("inf"));
57  msg.readInt16("skill pool flags");
58  const int level = msg.readInt16("skill level");
59  const int sp = msg.readInt16("sp");
60  const int range = msg.readInt16("range");
61  msg.skip(24, "unused");
62  const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
63  const int oldLevel = PlayerInfo::getSkillLevel(skillId);
64  if ((oldLevel != 0) && oldLevel != level)
65  updateSkill = skillId;
66  PlayerInfo::setSkillLevel(skillId, level);
67  if (skillDialog != nullptr)
68  {
69  if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
70  {
72  skillId, "", level, range, up, inf, sp);
73  }
74  }
75  }
76  if (skillDialog != nullptr)
77  {
79  if (updateSkill != 0)
80  skillDialog->playUpdateEffect(updateSkill);
81  }
82 }
#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 playUpdateEffect(const int id) const
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)
std::string update(const int id)
bool Modifiable
Definition: modifiable.h:30
bool msg(InputEvent &event)
Definition: chat.cpp:39
int getSkillLevel(const int id)
Definition: playerinfo.cpp:120
void setSkillLevel(const int id, const int value)
Definition: playerinfo.cpp:128
SkillDialog * skillDialog
Definition: skilldialog.cpp:66

References SkillDialog::addSkill(), fromBool, PlayerInfo::getSkillLevel(), Actions::msg(), SkillOwner::Player, SkillDialog::playUpdateEffect(), PlayerInfo::setSkillLevel(), skillDialog, SkillDialog::update(), and SkillDialog::updateSkill().

◆ processSkillFailed()

void TmwAthena::SkillRecv::processSkillFailed ( Net::MessageIn msg)

Definition at line 84 of file skillrecv.cpp.

85 {
86  // Action failed (ex. sit because you have not reached the
87  // right level)
88  const int skillId = msg.readInt16("skill id");
89  const int16_t bskill = msg.readInt16("bskill");
90  msg.readInt16("btype");
91  const signed char success = msg.readUInt8("success");
92  const signed char reason = msg.readUInt8("reason");
93  if (success != CAST_S32(SKILL_FAILED)
94  && bskill == CAST_S32(BSKILL_EMOTE))
95  {
96  logger->log("Action: %d/%d", bskill, success);
97  }
98 
99  std::string txt;
100  if (success == CAST_S32(SKILL_FAILED)
101  && skillId == CAST_S32(SKILL_BASIC))
102  {
103  if ((localPlayer != nullptr) &&
104  bskill == CAST_S32(BSKILL_EMOTE) &&
105  reason == CAST_S32(RFAIL_SKILLDEP))
106  {
108  }
109 
110  switch (bskill)
111  {
112  case BSKILL_TRADE:
113  // TRANSLATORS: error message
114  txt = _("Trade failed!");
115  break;
116  case BSKILL_EMOTE:
117  // TRANSLATORS: error message
118  txt = _("Emote failed!");
119  break;
120  case BSKILL_SIT:
121  // TRANSLATORS: error message
122  txt = _("Sit failed!");
123  break;
124  case BSKILL_CREATECHAT:
125  // TRANSLATORS: error message
126  txt = _("Chat creating failed!");
127  break;
128  case BSKILL_JOINPARTY:
129  // TRANSLATORS: error message
130  txt = _("Could not join party!");
131  break;
132  case BSKILL_SHOUT:
133  // TRANSLATORS: error message
134  txt = _("Cannot shout!");
135  break;
136  default:
137  UNIMPLEMENTEDPACKETFIELD(bskill);
138  break;
139  }
140 
141  txt.append(" ");
142 
143  switch (reason)
144  {
145  case RFAIL_SKILLDEP:
146  // TRANSLATORS: error message
147  txt.append(_("You have not yet reached a high enough lvl!"));
148  break;
149  case RFAIL_INSUFHP:
150  // TRANSLATORS: error message
151  txt.append(_("Insufficient HP!"));
152  break;
153  case RFAIL_INSUFSP:
154  // TRANSLATORS: error message
155  txt.append(_("Insufficient SP!"));
156  break;
157  case RFAIL_NOMEMO:
158  // TRANSLATORS: error message
159  txt.append(_("You have no memos!"));
160  break;
161  case RFAIL_SKILLDELAY:
162  // TRANSLATORS: error message
163  txt.append(_("You cannot do that right now!"));
164  break;
165  case RFAIL_ZENY:
166  // TRANSLATORS: error message
167  txt.append(_("Seems you need more money... ;-)"));
168  break;
169  case RFAIL_WEAPON:
170  // TRANSLATORS: error message
171  txt.append(_("You cannot use this skill with that "
172  "kind of weapon!"));
173  break;
174  case RFAIL_REDGEM:
175  // TRANSLATORS: error message
176  txt.append(_("You need another red gem!"));
177  break;
178  case RFAIL_BLUEGEM:
179  // TRANSLATORS: error message
180  txt.append(_("You need another blue gem!"));
181  break;
182  case RFAIL_OVERWEIGHT:
183  // TRANSLATORS: error message
184  txt.append(_("You're carrying to much to do this!"));
185  break;
186  default:
187  // TRANSLATORS: error message
188  txt.append(_("Huh? What's that?"));
189  UNIMPLEMENTEDPACKETFIELD(reason);
190  break;
191  }
192  }
193  else
194  {
195  switch (skillId)
196  {
197  case SKILL_WARP :
198  // TRANSLATORS: error message
199  txt = _("Warp failed...");
200  break;
201  case SKILL_STEAL :
202  // TRANSLATORS: error message
203  txt = _("Could not steal anything...");
204  break;
205  case SKILL_ENVENOM :
206  // TRANSLATORS: error message
207  txt = _("Poison had no effect...");
208  break;
209  default:
210  UNIMPLEMENTEDPACKETFIELD(skillId);
211  break;
212  }
213  }
214 
216 }
#define CAST_S32
Definition: cast.h:30
void stopAdvert()
void log(const char *const log_text,...)
Definition: logger.cpp:269
#define _(s)
Definition: gettext.h:35
LocalPlayer * localPlayer
Logger * logger
Definition: logger.cpp:89
#define UNIMPLEMENTEDPACKETFIELD(field)
Definition: logger.h:59
void notify(const unsigned int message)
@ SKILL_FAIL_MESSAGE
Definition: notifytypes.h:107
static const unsigned int RFAIL_BLUEGEM
Definition: skill.h:52
static const unsigned int RFAIL_OVERWEIGHT
Definition: skill.h:53
static const unsigned int BSKILL_SIT
Definition: skill.h:38
static const unsigned int SKILL_STEAL
Definition: skill.h:32
static const unsigned int RFAIL_INSUFHP
Definition: skill.h:46
static const unsigned int RFAIL_INSUFSP
Definition: skill.h:45
static const unsigned int SKILL_ENVENOM
Definition: skill.h:33
static const unsigned int RFAIL_ZENY
Definition: skill.h:49
static const unsigned int BSKILL_TRADE
Definition: skill.h:36
static const unsigned int BSKILL_SHOUT
Definition: skill.h:41
static const unsigned int BSKILL_JOINPARTY
Definition: skill.h:40
static const unsigned int SKILL_BASIC
Definition: skill.h:30
static const unsigned int RFAIL_SKILLDELAY
Definition: skill.h:48
static const unsigned int RFAIL_REDGEM
Definition: skill.h:51
static const unsigned int SKILL_WARP
Definition: skill.h:31
static const unsigned int RFAIL_SKILLDEP
Definition: skill.h:44
static const unsigned int BSKILL_EMOTE
Definition: skill.h:37
static const unsigned int BSKILL_CREATECHAT
Definition: skill.h:39
static const unsigned int RFAIL_WEAPON
Definition: skill.h:50
static const unsigned int RFAIL_NOMEMO
Definition: skill.h:47
static const unsigned int SKILL_FAILED
Definition: skill.h:56

References _, BSKILL_CREATECHAT, BSKILL_EMOTE, BSKILL_JOINPARTY, BSKILL_SHOUT, BSKILL_SIT, BSKILL_TRADE, CAST_S32, localPlayer, Logger::log(), logger, Actions::msg(), NotifyManager::notify(), RFAIL_BLUEGEM, RFAIL_INSUFHP, RFAIL_INSUFSP, RFAIL_NOMEMO, RFAIL_OVERWEIGHT, RFAIL_REDGEM, RFAIL_SKILLDELAY, RFAIL_SKILLDEP, RFAIL_WEAPON, RFAIL_ZENY, SKILL_BASIC, SKILL_ENVENOM, NotifyTypes::SKILL_FAIL_MESSAGE, SKILL_FAILED, SKILL_STEAL, SKILL_WARP, LocalPlayer::stopAdvert(), and UNIMPLEMENTEDPACKETFIELD.