00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "net/ea/skillhandler.h"
00023
00024 #include "net/ea/protocol.h"
00025
00026 #include "net/messagein.h"
00027 #include "net/messageout.h"
00028
00029 #include "log.h"
00030
00031 #include "gui/skill.h"
00032
00033 #include "gui/widgets/chattab.h"
00034
00035 #include "utils/gettext.h"
00036
00038 #define SKILL_BASIC 0x0001
00039 #define SKILL_WARP 0x001b
00040 #define SKILL_STEAL 0x0032
00041 #define SKILL_ENVENOM 0x0034
00042
00044 #define BSKILL_TRADE 0x0000
00045 #define BSKILL_EMOTE 0x0001
00046 #define BSKILL_SIT 0x0002
00047 #define BSKILL_CREATECHAT 0x0003
00048 #define BSKILL_JOINPARTY 0x0004
00049 #define BSKILL_SHOUT 0x0005
00050 #define BSKILL_PK 0x0006 // ??
00051 #define BSKILL_SETALLIGN 0x0007 // ??
00052
00054 #define RFAIL_SKILLDEP 0x00
00055 #define RFAIL_INSUFHP 0x01
00056 #define RFAIL_INSUFSP 0x02
00057 #define RFAIL_NOMEMO 0x03
00058 #define RFAIL_SKILLDELAY 0x04
00059 #define RFAIL_ZENY 0x05
00060 #define RFAIL_WEAPON 0x06
00061 #define RFAIL_REDGEM 0x07
00062 #define RFAIL_BLUEGEM 0x08
00063 #define RFAIL_OVERWEIGHT 0x09
00064 #define RFAIL_GENERIC 0x0a
00065
00067 #define SKILL_FAILED 0x00
00068
00069 Net::SkillHandler *skillHandler;
00070
00071 namespace EAthena {
00072
00073 SkillHandler::SkillHandler()
00074 {
00075 static const Uint16 _messages[] = {
00076 SMSG_PLAYER_SKILLS,
00077 SMSG_SKILL_FAILED,
00078 0
00079 };
00080 handledMessages = _messages;
00081 skillHandler = this;
00082 }
00083
00084 void SkillHandler::handleMessage(MessageIn &msg)
00085 {
00086 int skillCount;
00087
00088 switch (msg.getId())
00089 {
00090 case SMSG_PLAYER_SKILLS:
00091 msg.readInt16();
00092 skillCount = (msg.getLength() - 4) / 37;
00093 skillDialog->cleanList();
00094
00095 for (int k = 0; k < skillCount; k++)
00096 {
00097 int skillId = msg.readInt16();
00098 msg.readInt16();
00099 msg.readInt16();
00100 int level = msg.readInt16();
00101 int sp = msg.readInt16();
00102 msg.readInt16();
00103 std::string skillName = msg.readString(24);
00104 int up = msg.readInt8();
00105
00106 if (level != 0 || up != 0)
00107 {
00108 if (skillDialog->hasSkill(skillId)) {
00109 skillDialog->setSkill(skillId, level, sp);
00110 }
00111 else {
00112 skillDialog->addSkill(skillId, level, sp);
00113 }
00114 }
00115 }
00116 skillDialog->update();
00117 break;
00118
00119 case SMSG_SKILL_FAILED:
00120
00121
00122 short skill = msg.readInt16();
00123 short bskill = msg.readInt16();
00124 msg.readInt16();
00125 char success = msg.readInt8();
00126 char reason = msg.readInt8();
00127 if (success != SKILL_FAILED && bskill == BSKILL_EMOTE)
00128 {
00129 logger->log("Action: %d/%d", bskill, success);
00130 }
00131
00132 std::string msg;
00133 if (success == SKILL_FAILED && skill == SKILL_BASIC)
00134 {
00135 switch (bskill)
00136 {
00137 case BSKILL_TRADE:
00138 msg = _("Trade failed!");
00139 break;
00140 case BSKILL_EMOTE:
00141 msg = _("Emote failed!");
00142 break;
00143 case BSKILL_SIT:
00144 msg = _("Sit failed!");
00145 break;
00146 case BSKILL_CREATECHAT:
00147 msg = _("Chat creating failed!");
00148 break;
00149 case BSKILL_JOINPARTY:
00150 msg = _("Could not join party!");
00151 break;
00152 case BSKILL_SHOUT:
00153 msg = _("Cannot shout!");
00154 break;
00155 }
00156
00157 msg += " ";
00158
00159 switch (reason)
00160 {
00161 case RFAIL_SKILLDEP:
00162 msg += _("You have not yet reached a high enough lvl!");
00163 break;
00164 case RFAIL_INSUFHP:
00165 msg += _("Insufficient HP!");
00166 break;
00167 case RFAIL_INSUFSP:
00168 msg += _("Insufficient SP!");
00169 break;
00170 case RFAIL_NOMEMO:
00171 msg += _("You have no memos!");
00172 break;
00173 case RFAIL_SKILLDELAY:
00174 msg += _("You cannot do that right now!");
00175 break;
00176 case RFAIL_ZENY:
00177 msg += _("Seems you need more money... ;-)");
00178 break;
00179 case RFAIL_WEAPON:
00180 msg += _("You cannot use this skill with that kind of weapon!");
00181 break;
00182 case RFAIL_REDGEM:
00183 msg += _("You need another red gem!");
00184 break;
00185 case RFAIL_BLUEGEM:
00186 msg += _("You need another blue gem!");
00187 break;
00188 case RFAIL_OVERWEIGHT:
00189 msg += _("You're carrying to much to do this!");
00190 break;
00191 default:
00192 msg += _("Huh? What's that?");
00193 break;
00194 }
00195 }
00196 else
00197 {
00198 switch (skill)
00199 {
00200 case SKILL_WARP :
00201 msg = _("Warp failed...");
00202 break;
00203 case SKILL_STEAL :
00204 msg = _("Could not steal anything...");
00205 break;
00206 case SKILL_ENVENOM :
00207 msg = _("Poison had no effect...");
00208 break;
00209 }
00210 }
00211
00212 localChatTab->chatLog(msg);
00213 break;
00214 }
00215 }
00216
00217 void SkillHandler::up(int skillId)
00218 {
00219 MessageOut outMsg(CMSG_SKILL_LEVELUP_REQUEST);
00220 outMsg.writeInt16(skillId);
00221 }
00222
00223 void SkillHandler::use(int skillId, int level, int beingId)
00224 {
00225
00226 }
00227
00228 void SkillHandler::use(int skillId, int level, int x, int y)
00229 {
00230
00231 }
00232
00233 void SkillHandler::use(int skillId, const std::string &map)
00234 {
00235
00236 }
00237
00238 }