// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder #include "atcommand.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "achievement.hpp" #include "battle.hpp" #include "buyingstore.hpp" #include "channel.hpp" #include "chat.hpp" #include "chrif.hpp" #include "clan.hpp" #include "clif.hpp" #include "duel.hpp" #include "elemental.hpp" #include "guild.hpp" #include "homunculus.hpp" #include "instance.hpp" #include "intif.hpp" #include "itemdb.hpp" // MAX_ITEMGROUP #include "log.hpp" #include "mail.hpp" #include "map.hpp" #include "mapreg.hpp" #include "mercenary.hpp" #include "mob.hpp" #include "npc.hpp" #include "party.hpp" #include "pc.hpp" #include "pc_groups.hpp" #include "pet.hpp" #include "quest.hpp" #include "script.hpp" #include "storage.hpp" #include "trade.hpp" #include "vending.hpp" using namespace rathena; #define ATCOMMAND_LENGTH 50 #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, map_session_data* sd, const char* command, const char* message) typedef struct AtCommandInfo AtCommandInfo; int atcmd_binding_count = 0; /// Atcommand restriction usage enum e_atcmd_restict { ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2) ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3) ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0); }; struct AtCommandInfo { char command[ATCOMMAND_LENGTH]; AtCommandFunc func; char* at_groups; /// Quick @commands "can-use" lookup char* char_groups; /// Quick @charcommands "can-use" lookup uint8 restriction; /// Restrictions see enum e_restict }; struct s_atcommand_alias_info{ AtCommandInfo *command; std::set aliases; std::string help; }; char atcommand_symbol = '@'; // first char of the commands char charcommand_symbol = '#'; static DBMap* atcommand_db = NULL; //name -> AtCommandInfo static AtCommandInfo* get_atcommandinfo_byname( const char* name ); class AtcommandAliasDatabase : public TypesafeYamlDatabase{ private: std::unordered_map aliases; public: AtcommandAliasDatabase() : TypesafeYamlDatabase( "ATCOMMAND_DB", 1 ){ } void clear() override; const std::string getDefaultLocation() override; uint64 parseBodyNode( const ryml::NodeRef& node ) override; // Additional const char* checkAlias( const char* alias ); }; void AtcommandAliasDatabase::clear(){ TypesafeYamlDatabase::clear(); this->aliases.clear(); } const std::string AtcommandAliasDatabase::getDefaultLocation(){ return std::string(conf_path) + "/atcommands.yml"; } uint64 AtcommandAliasDatabase::parseBodyNode( const ryml::NodeRef& node ){ std::string command; if( !this->asString( node, "Command", command ) ){ return 0; } AtCommandInfo* commandinfo = get_atcommandinfo_byname( command.c_str() ); if( commandinfo == nullptr ){ this->invalidWarning( node["Command"], "Command %s does not exist.\n", command.c_str() ); return 0; } std::shared_ptr info = this->find( command ); bool exists = info != nullptr; if( !exists ){ info = std::make_shared(); info->command = commandinfo; } if( this->nodeExists( node, "Help" ) ){ std::string help; if( !this->asString( node, "Help", help ) ){ return 0; } info->help = help; } if( this->nodeExists( node, "Aliases" ) ){ const auto& aliasesNode = node["Aliases"]; if( !aliasesNode.is_seq() ){ this->invalidWarning( aliasesNode, "Aliases should be a sequence.\n" ); return 0; } for( const auto& subNode : aliasesNode ){ std::string alias; subNode >> alias; info->aliases.insert( alias ); this->aliases[alias] = command; } } if( !exists ){ this->put( command, info ); } return 1; } const char* AtcommandAliasDatabase::checkAlias( const char* alias ){ std::string alias_str( alias ); std::string* command = util::umap_find( this->aliases, alias_str ); if( command == nullptr ){ return alias; }else{ return command->c_str(); } } AtcommandAliasDatabase atcommand_alias_db; static char atcmd_output[CHAT_SIZE_MAX]; static char atcmd_player_name[NAME_LENGTH]; const char *parent_cmd; struct atcmd_binding_data** atcmd_binding; static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help static void atcommand_get_suggestions(map_session_data* sd, const char *name, bool atcommand); // @help static void warp_get_suggestions(map_session_data* sd, const char *name); // @rura, @warp, @mapmove // @commands (script-based) struct atcmd_binding_data* get_atcommandbind_byname(const char* name) { int i = 0; if( *name == atcommand_symbol || *name == charcommand_symbol ) name++; // for backwards compatibility ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 ); return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL; } /** * retrieves the help string associated with a given command. * * @param name the name of the command to retrieve help information for * @return the string associated with the command, or NULL */ static const char* atcommand_help_string( const char* command ){ // remove the prefix symbol for the raw name of the command if( *command == atcommand_symbol || *command == charcommand_symbol ){ command++; } // convert alias to the real command name command = atcommand_alias_db.checkAlias( command ); // attempt to find the first default help command std::shared_ptr info = atcommand_alias_db.find( command ); // failed to find the help property in the configuration file if( info == nullptr ){ return nullptr; } // push the result from the method return info->help.c_str(); } /*========================================== * @send (used for testing packet sends from the client) *------------------------------------------*/ ACMD_FUNC(send) { int len=0,type; // read message type as hex number (without the 0x) if(!message || !*message || !((sscanf(message, "len %8x", &type)==1 && (len=1)) || sscanf(message, "%8x", &type)==1) ) { int i; for (i = 900; i <= 903; ++i) clif_displaymessage(fd, msg_txt(sd,i)); return -1; } #define PARSE_ERROR(error,p) \ {\ clif_displaymessage(fd, (error));\ sprintf(atcmd_output, ">%s", (p));\ clif_displaymessage(fd, atcmd_output);\ } //define PARSE_ERROR #define CHECK_EOS(p) \ if(*(p) == 0){\ clif_displaymessage(fd, "Unexpected end of string");\ return -1;\ } //define CHECK_EOS #define SKIP_VALUE(p) \ {\ while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\ while(*(p) && ISSPACE(*(p))) ++(p); /* space */\ } //define SKIP_VALUE #define GET_VALUE(p,num) \ {\ if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\ PARSE_ERROR("Invalid number in:",(p));\ return -1;\ }\ } //define GET_VALUE if (type > 0 && type < MAX_PACKET_DB) { int off,end; long num; if(len) {// show packet length sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[type].len); // Packet 0x%x length: %d clif_displaymessage(fd, atcmd_output); return 0; } len=packet_db[type].len; off=2; if(len == 0) {// unknown packet - ERROR sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x clif_displaymessage(fd, atcmd_output); return -1; } else if(len == -1) {// dynamic packet len=SHRT_MAX-4; // maximum length off=4; } WFIFOHEAD(fd, len); WFIFOW(fd,0)=TOW(type); // parse packet contents SKIP_VALUE(message); while(*message != 0 && off < len){ if(ISDIGIT(*message) || *message == '-' || *message == '+') {// default (byte) GET_VALUE(message,num); WFIFOB(fd,off)=TOB(num); ++off; } else if(TOUPPER(*message) == 'B') {// byte ++message; GET_VALUE(message,num); WFIFOB(fd,off)=TOB(num); ++off; } else if(TOUPPER(*message) == 'W') {// word (2 bytes) ++message; GET_VALUE(message,num); WFIFOW(fd,off)=TOW(num); off+=2; } else if(TOUPPER(*message) == 'L') {// long word (4 bytes) ++message; GET_VALUE(message,num); WFIFOL(fd,off)=TOL(num); off+=4; } else if(TOUPPER(*message) == 'S') {// string - escapes are valid // get string length - num <= 0 means not fixed length (default) ++message; if(*message == '"'){ num=0; } else { GET_VALUE(message,num); while(*message != '"') {// find start of string if(*message == 0 || ISSPACE(*message)){ PARSE_ERROR(msg_txt(sd,906),message); // Not a string: return -1; } ++message; } } // parse string ++message; CHECK_EOS(message); end=(num<=0? 0: min(off+((int)num),len)); for(; *message != '"' && (off < end || end == 0); ++off){ if(*message == '\\'){ ++message; CHECK_EOS(message); switch(*message){ case 'a': num=0x07; break; // Bell case 'b': num=0x08; break; // Backspace case 't': num=0x09; break; // Horizontal tab case 'n': num=0x0A; break; // Line feed case 'v': num=0x0B; break; // Vertical tab case 'f': num=0x0C; break; // Form feed case 'r': num=0x0D; break; // Carriage return case 'e': num=0x1B; break; // Escape default: num=*message; break; case 'x': // Hexadecimal { ++message; CHECK_EOS(message); if(!ISXDIGIT(*message)){ PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit: return -1; } num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10); if(ISXDIGIT(*message)){ ++message; CHECK_EOS(message); num<<=8; num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10); } WFIFOB(fd,off)=TOB(num); ++message; CHECK_EOS(message); continue; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': // Octal { num=*message-'0'; // 1st octal digit ++message; CHECK_EOS(message); if(ISDIGIT(*message) && *message < '8'){ num<<=3; num+=*message-'0'; // 2nd octal digit ++message; CHECK_EOS(message); if(ISDIGIT(*message) && *message < '8'){ num<<=3; num+=*message-'0'; // 3rd octal digit ++message; CHECK_EOS(message); } } WFIFOB(fd,off)=TOB(num); continue; } } } else num=*message; WFIFOB(fd,off)=TOB(num); ++message; CHECK_EOS(message); }//for while(*message != '"') {// ignore extra characters ++message; CHECK_EOS(message); } // terminate the string if(off < end) {// fill the rest with 0's memset(WFIFOP(fd,off),0,end-off); off=end; } } else {// unknown PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in: return -1; } SKIP_VALUE(message); } if(packet_db[type].len == -1) {// send dynamic packet WFIFOW(fd,2)=TOW(off); WFIFOSET(fd,off); } else {// send static packet if(off < len) memset(WFIFOP(fd,off),0,len-off); WFIFOSET(fd,len); } } else { clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet return -1; } sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d) clif_displaymessage(fd, atcmd_output); return 0; #undef PARSE_ERROR #undef CHECK_EOS #undef SKIP_VALUE #undef GET_VALUE } /** * Retrieves map name suggestions for a given string. * This will first check if any map names contain the given string, and will * print out MAX_SUGGESTIONS results if any maps are found. * Otherwise, suggestions will be calculated through Levenshtein distance, * and up to 5 of the closest matches will be printed. * * @author Euphy */ static void warp_get_suggestions(map_session_data* sd, const char *name) { // Minimum length for suggestions is 2 characters if( strlen( name ) < 2 ){ return; } std::vector suggestions; suggestions.reserve( MAX_SUGGESTIONS ); // check for maps that contain string for (int i = 0; i < map_num; i++) { struct map_data *mapdata = map_getmapdata(i); // Prevent suggestion of instance mapnames if( mapdata->instance_id != 0 ){ continue; } if( strstr( mapdata->name, name ) != nullptr ){ suggestions.push_back( mapdata->name ); if( suggestions.size() == MAX_SUGGESTIONS ){ break; } } } // if no maps found, search by edit distance if( suggestions.empty() ){ // Levenshtein > 4 is bad const int LEVENSHTEIN_MAX = 4; std::unordered_map> maps; for (int i = 0; i < map_num; i++) { struct map_data *mapdata = map_getmapdata(i); // Prevent suggestion of instance mapnames if(mapdata->instance_id != 0 ){ continue; } // Calculate the levenshtein distance of the two strings int distance = levenshtein(mapdata->name, name); // Check if it is above the maximum defined distance if( distance > LEVENSHTEIN_MAX ){ continue; } std::vector& vector = maps[distance]; // Do not add more entries than required if( vector.size() == MAX_SUGGESTIONS ){ continue; } vector.push_back(mapdata->name); } for( int distance = 0; distance <= LEVENSHTEIN_MAX; distance++ ){ std::vector& vector = maps[distance]; for( const char* found_map : vector ){ suggestions.push_back( found_map ); if( suggestions.size() == MAX_SUGGESTIONS ){ break; } } if( suggestions.size() == MAX_SUGGESTIONS ){ break; } } } // If no suggestion could be made, do not output anything at all if( suggestions.empty() ){ return; } char buffer[CHAT_SIZE_MAX]; // build the suggestion string strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant: strcat(buffer, "\n"); for( const char* suggestion : suggestions ){ strcat(buffer, suggestion); strcat(buffer, " "); } clif_displaymessage(sd->fd, buffer); } /*========================================== * @rura, @warp, @mapmove *------------------------------------------*/ ACMD_FUNC(mapmove) { char map_name[MAP_NAME_LENGTH_EXT]; unsigned short mapindex; short x = 0, y = 0; int16 m = -1; nullpo_retr(-1, sd); memset(map_name, '\0', sizeof(map_name)); if (!message || !*message || (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 && sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) { clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove ). return -1; } mapindex = mapindex_name2idx(map_name, nullptr); if (mapindex) m = map_mapindex2mapid(mapindex); if (m < 0) { // m < 0 means on different server! [Kevin] clif_displaymessage(fd, msg_txt(sd,1)); // Map not found. if (battle_config.warp_suggestions_enabled) warp_get_suggestions(sd, map_name); return -1; } if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS)) { //This is to prevent the pc_setpos call from printing an error. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1)) x = y = 0; //Invalid cell, use random spot. } if ((map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) || !pc_job_can_entermap((enum e_job)sd->status.class_, m, pc_get_group_level(sd))) { clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map. return -1; } if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map. return -1; } if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) { clif_displaymessage(fd, msg_txt(sd,1)); // Map not found. return -1; } clif_displaymessage(fd, msg_txt(sd,0)); // Warped. return 0; } /*========================================== * Displays where a character is. Corrected version by Silent. [Skotlex] *------------------------------------------*/ ACMD_FUNC(where) { map_session_data* pl_sd; nullpo_retr(-1, sd); memset(atcmd_player_name, '\0', sizeof atcmd_player_name); if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where ). return -1; } pl_sd = map_nick2sd(atcmd_player_name,true); if (pl_sd == NULL || strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 || (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) ) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; } snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); clif_displaymessage(fd, atcmd_output); return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(jumpto) { map_session_data* pl_sd = nullptr;; nullpo_retr(-1, sd); memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto ). return -1; } if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; } if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map. return -1; } if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map. return -1; } if( pc_isdead(sd) ) { clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead. return -1; } pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT); sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s clif_displaymessage(fd, atcmd_output); return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(jump) { short x = 0, y = 0; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); sscanf(message, "%6hd %6hd", &x, &y); if (map_getmapflag(sd->bl.m, MF_NOTELEPORT) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map. return -1; } if( pc_isdead(sd) ) { clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead. return -1; } if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS)) { //This is to prevent the pc_setpos call from printing an error. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1)) x = y = 0; //Invalid cell, use random spot. } pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT); sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d clif_displaymessage(fd, atcmd_output); return 0; } /*========================================== * Display list of online characters with * various info. *------------------------------------------*/ ACMD_FUNC(who) { map_session_data* pl_sd = nullptr;; struct s_mapiterator *iter = NULL; char player_name[NAME_LENGTH] = ""; int count = 0; int level = 0; StringBuf buf; /** * 1 = @who : Player name, [Title], [Party name], [Guild name] * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y */ int display_type = 1; int map_id = -1; nullpo_retr(-1, sd); if (strstr(command, "map") != NULL) { char map_name[MAP_NAME_LENGTH_EXT] = ""; if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0) map_id = sd->bl.m; } else { sscanf(message, "%23s", player_name); } if (strstr(command, "2") != NULL) display_type = 2; else if (strstr(command, "3") != NULL) display_type = 3; level = pc_get_group_level(sd); StringBuf_Init(&buf); iter = mapit_getallusers(); for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) { if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || pc_isinvisible(pl_sd)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive || (map_id >= 0 && pl_sd->bl.m != map_id)) continue; switch (display_type) { case 2: { StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists StringBuf_Printf(&buf, msg_txt(sd,344),pl_sd->group->name.c_str()); // "(%s) " StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s" break; } case 3: { if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) " StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) " StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d" break; } default: { struct party_data *p = party_search(pl_sd->status.party_id); auto &g = pl_sd->guild; StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) " if (p != NULL) StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'" if (g != NULL) StringBuf_Printf(&buf, msg_txt(sd,346), g->guild.name); // " | Guild: '%s'" break; } } clif_displaymessage(fd, StringBuf_Value(&buf)); StringBuf_Clear(&buf); count++; } } mapit_free(iter); if (map_id < 0) { if (count == 0) StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found. else if (count == 1) StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found. else StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found. } else { struct map_data *mapdata = map_getmapdata(map_id); if (count == 0) StringBuf_Printf(&buf, msg_txt(sd,54), mapdata->name); // No player found in map '%s'. else if (count == 1) StringBuf_Printf(&buf, msg_txt(sd,55), mapdata->name); // 1 player found in map '%s'. else StringBuf_Printf(&buf, msg_txt(sd,56), count, mapdata->name); // %d players found in map '%s'. } clif_displaymessage(fd, StringBuf_Value(&buf)); StringBuf_Destroy(&buf); return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(whogm) { map_session_data* pl_sd; struct s_mapiterator* iter; int j, count; int level; char match_text[CHAT_SIZE_MAX]; char player_name[NAME_LENGTH]; struct party_data *p; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); memset(match_text, '\0', sizeof(match_text)); memset(player_name, '\0', sizeof(player_name)); if (sscanf(message, "%255[^\n]", match_text) < 1) strcpy(match_text, ""); for (j = 0; match_text[j]; j++) match_text[j] = TOLOWER(match_text[j]); count = 0; level = pc_get_group_level(sd); iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) { int pl_level = pc_get_group_level(pl_sd); if (!pl_level) continue; if (match_text[0]) { memcpy(player_name, pl_sd->status.name, NAME_LENGTH); for (j = 0; player_name[j]; j++) player_name[j] = TOLOWER(player_name[j]); // search with no case sensitive if (strstr(player_name, match_text) == NULL) continue; } if (pl_level > level) { if (pc_isinvisible(pl_sd)) continue; sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM) clif_displaymessage(fd, atcmd_output); count++; continue; } sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d pl_sd->status.name, pl_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d) pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level); clif_displaymessage(fd, atcmd_output); p = party_search(pl_sd->status.party_id); auto &g = pl_sd->guild; sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s' p?p->party.name:msg_txt(sd,917), g?g->guild.name:msg_txt(sd,917)); // None. clif_displaymessage(fd, atcmd_output); count++; } mapit_free(iter); if (count == 0) clif_displaymessage(fd, msg_txt(sd,150)); // No GM found. else if (count == 1) clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found. else { sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found. clif_displaymessage(fd, atcmd_output); } return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(save) { nullpo_retr(-1, sd); if( map_getmapdata(sd->bl.m)->instance_id ) { clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance. return 1; } pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y); if (sd->status.pet_id > 0 && sd->pd) intif_save_petdata(sd->status.account_id, &sd->pd->pet); chrif_save(sd, CSAVE_NORMAL); clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(load){ nullpo_retr(-1, sd); uint16 mapindex = mapindex_name2id( sd->status.save_point.map ); int16 m = map_mapindex2mapid( mapindex ); if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map. return -1; } if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map. return -1; } pc_setpos( sd, mapindex, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT ); clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point.. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(speed) { short speed; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) { sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>). clif_displaymessage(fd, atcmd_output); return -1; } sd->state.permanent_speed = 0; // Remove lock when set back to default speed. if (speed < 0) sd->base_status.speed = DEFAULT_WALK_SPEED; else sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED); if (sd->base_status.speed != DEFAULT_WALK_SPEED) { sd->state.permanent_speed = 1; // Set lock when set to non-default speed. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed. } else clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal. status_calc_bl(&sd->bl, { SCB_SPEED }); return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(storage) { nullpo_retr(-1, sd); if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag) return -1; if (storage_storageopen(sd) == 1) { //Already open. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first. return -1; } clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(guildstorage) { nullpo_retr(-1, sd); if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading) return -1; switch (storage_guild_storageopen(sd)) { case GSTORAGE_OPEN: clif_displaymessage(fd, msg_txt(sd, 920)); // Guild storage opened. break; case GSTORAGE_STORAGE_ALREADY_OPEN: clif_displaymessage(fd, msg_txt(sd, 250)); // You have already opened your storage. Close it first. return -1; case GSTORAGE_ALREADY_OPEN: clif_displaymessage(fd, msg_txt(sd, 251)); // You have already opened your guild storage. Close it first. return -1; case GSTORAGE_NO_GUILD: clif_displaymessage(fd, msg_txt(sd, 252)); // You are not in a guild. return -1; case GSTORAGE_NO_STORAGE: clif_displaymessage(fd, msg_txt(sd, 786)); // The guild does not have a guild storage. return -1; case GSTORAGE_NO_PERMISSION: clif_displaymessage(fd, msg_txt(sd, 787)); // You do not have permission to use the guild storage. return -1; } return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(option) { int param1 = 0, param2 = 0, param3 = 0; nullpo_retr(-1, sd); if (!message || !*message || sscanf(message, "%11d %11d %11d", ¶m1, ¶m2, ¶m3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {// failed to match the parameters so inform the user of the options const char* text; // attempt to find the setting information for this command text = atcommand_help_string( command ); // notify the user of the requirement to enter an option clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option. if( text ) {// send the help text associated with this command clif_displaymessage( fd, text ); } return -1; } sd->sc.opt1 = param1; sd->sc.opt2 = param2; pc_setoption(sd, param3); clif_displaymessage(fd, msg_txt(sd,9)); // Options changed. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(hide) { nullpo_retr(-1, sd); if (pc_isinvisible(sd)) { sd->sc.option &= ~OPTION_INVISIBLE; if (sd->disguise) status_set_viewdata(&sd->bl, sd->disguise); else status_set_viewdata(&sd->bl, sd->status.class_); clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off // increment the number of pvp players on the map map_getmapdata(sd->bl.m)->users_pvp++; if( !battle_config.pk_mode && map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) ) {// register the player for ranking calculations sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 ); } //bugreport:2266 map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl); } else { sd->sc.option |= OPTION_INVISIBLE; sd->vd.class_ = JT_INVISIBLE; clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On // decrement the number of pvp players on the map map_getmapdata(sd->bl.m)->users_pvp--; if( map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking delete_timer( sd->pvp_timer, pc_calc_pvprank_timer ); sd->pvp_timer = INVALID_TIMER; } } clif_changeoption(&sd->bl); return 0; } /*========================================== * Changes a character's class *------------------------------------------*/ ACMD_FUNC(jobchange) { int job = 0, upper = 0; const char* text; nullpo_retr(-1, sd); if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) { int i; bool found = false; upper = 0; // Normal Jobs for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) { if (strncmpi(message, job_name(i), 16) == 0) { job = i; found = true; } } // High Jobs, Babys, Third, and Fourth for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) { if (strncmpi(message, job_name(i), 16) == 0) { job = i; found = true; } } if (!found) { text = atcommand_help_string(command); if (text) clif_displaymessage(fd, text); return -1; } } if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2 || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE_KNIGHT2 && job <= JOB_BABY_MECHANIC2) || job == JOB_BABY_STAR_GLADIATOR2 || job == JOB_STAR_EMPEROR2 || job == JOB_BABY_STAR_EMPEROR2 || job == JOB_SUMMER2 || (job >= JOB_WINDHAWK2 && job <= JOB_IMPERIAL_GUARD2) || job == JOB_SKY_EMPEROR2) { // Deny direct transformation into dummy jobs clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command." return 0; } if (pcdb_checkid(job)) { if (pc_jobchange(sd, job, upper)) clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed. else { clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job. return -1; } } else { text = atcommand_help_string(command); if (text) clif_displaymessage(fd, text); return -1; } return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(kill) { nullpo_retr(-1, sd); status_kill(&sd->bl); clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died. if (fd != sd->fd) clif_displaymessage(fd, msg_txt(sd,14)); // Character killed. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(alive) { nullpo_retr(-1, sd); if (!status_revive(&sd->bl, 100, 100)) { clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead. return -1; } clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1); clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle! return 0; } /*========================================== * +kamic [LuzZza] *------------------------------------------*/ ACMD_FUNC(kami) { unsigned long color=0; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); if(*(command + 5) != 'c' && *(command + 5) != 'C') { if (!message || !*message) { clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami ). return -1; } sscanf(message, "%255[^\n]", atcmd_output); if (strstr(command, "l") != NULL) clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP); else intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT); } else { if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) { clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic ). return -1; } if(color > 0xFFFFFF) { clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color. return -1; } intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0); } return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(heal) { int hp = 0, sp = 0; // [Valaris] thanks to fov nullpo_retr(-1, sd); sscanf(message, "%11d %11d", &hp, &sp); // some overflow checks if( hp == INT_MIN ) hp++; if( sp == INT_MIN ) sp++; if ( hp == 0 && sp == 0 ) { if (!status_percent_heal(&sd->bl, 100, 100)) clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered. else clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered. return 0; } if ( hp > 0 && sp >= 0 ) { if(!status_heal(&sd->bl, hp, sp, 0)) clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value. else clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered. return 0; } if ( hp < 0 && sp <= 0 ) { status_damage(NULL, &sd->bl, -hp, -sp, 0, 0, 0); clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false); clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified. return 0; } //Opposing signs. if ( hp ) { if (hp > 0) status_heal(&sd->bl, hp, 0, 0); else { status_damage(NULL, &sd->bl, -hp, 0, 0, 0, 0); clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false); } } if ( sp ) { if (sp > 0) status_heal(&sd->bl, 0, sp, 0); else status_damage(NULL, &sd->bl, 0, -sp, 0, 0, 0); } clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified. return 0; } /*========================================== * Recover's AP and allows exact adjustments. [Rytech] *------------------------------------------*/ ACMD_FUNC(healap) { int ap = 0; nullpo_retr(-1, sd); sscanf(message, "%11d", &ap); // Overflow check. if (ap == INT_MIN) ap++; if (ap == 0) { if (!status_percent_heal(&sd->bl, 0, 0, 100)) clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered. else clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered. return 0; }else if (ap > 0) { if (!status_heal(&sd->bl, 0, 0, ap, 0)) clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered. else clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered. return 0; }else{ status_damage(NULL, &sd->bl, 0, 0, -ap, 0, 0, 0); clif_displaymessage(fd, msg_txt(sd, 822));// AP modified. return 0; } } /*========================================== * @item command (usage: @item ) (modified by [Yor] for pet_egg) * @itembound command (usage: @itembound ) *------------------------------------------*/ ACMD_FUNC(item) { char item_name[100]; int number = 0, bound = BOUND_NONE; char flag = 0; char *itemlist; nullpo_retr(-1, sd); memset(item_name, '\0', sizeof(item_name)); parent_cmd = atcommand_alias_db.checkAlias(command+1); if (!strcmpi(parent_cmd,"itembound")) { if (!message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 && sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3)) { clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item ). clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type return -1; } if( bound <= BOUND_NONE || bound >= BOUND_MAX ) { clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type return -1; } } else if (!message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 && sscanf(message, "%99s %11d", item_name, &number) < 1 )) { clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item ). return -1; } std::vector> items; itemlist = strtok(item_name, ":"); while( itemlist != nullptr ){ std::shared_ptr item = item_db.searchname( itemlist ); if( item == nullptr ){ item = item_db.find( strtoul( itemlist, nullptr, 10 ) ); } if( item == nullptr ){ clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name. return -1; } items.push_back( item ); itemlist = strtok(NULL, ":"); //next itemline } if (number <= 0) number = 1; int get_count = number; // Produce items in list for( const auto& item : items ){ t_itemid item_id = item->nameid; //Check if it's stackable. if( !itemdb_isstackable2( item.get() ) ){ get_count = 1; } for( int i = 0; i < number; i += get_count ){ // if not pet egg if (!pet_create_egg(sd, item_id)) { struct item item_tmp = {}; item_tmp.nameid = item_id; item_tmp.identify = 1; item_tmp.bound = bound; if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND))) clif_additem(sd, 0, 0, flag); } } } if (flag == 0) clif_displaymessage(fd, msg_txt(sd,18)); // Item created. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(item2) { char item_name[100]; int number = 0, bound = BOUND_NONE; int identify = 0, refine = 0, attr = 0; int c1 = 0, c2 = 0, c3 = 0, c4 = 0; nullpo_retr(-1, sd); memset(item_name, '\0', sizeof(item_name)); parent_cmd = atcommand_alias_db.checkAlias(command+1); if (!strcmpi(parent_cmd+1,"itembound2")) { if (!message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 && sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 )) { clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 clif_displaymessage(fd, msg_txt(sd,297)); // ). clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type return -1; } if( bound <= BOUND_NONE || bound >= BOUND_MAX ) { clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type return -1; } } else if ( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 && sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 )) { clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 clif_displaymessage(fd, msg_txt(sd,985)); // ). return -1; } if (number <= 0) number = 1; std::shared_ptr item_data = item_db.searchname( item_name ); if( item_data == nullptr ){ item_data = item_db.find( strtoul( item_name, nullptr, 10 ) ); } if( item_data != nullptr ){ int loop, get_count, i; char flag = 0; //Check if it's stackable. if( !itemdb_isstackable2( item_data.get() ) ){ loop = number; get_count = 1; }else{ loop = 1; get_count = number; } if( itemdb_isequip2( item_data.get() ) ){ refine = cap_value( refine, 0, MAX_REFINE ); }else{ // All other items cannot be refined and are always identified identify = 1; refine = attr = 0; } for (i = 0; i < loop; i++) { // if not pet egg if (!pet_create_egg(sd, item_data->nameid)) { struct item item_tmp = {}; item_tmp.nameid = item_data->nameid; item_tmp.identify = identify; item_tmp.refine = refine; item_tmp.attribute = attr; item_tmp.card[0] = c1; item_tmp.card[1] = c2; item_tmp.card[2] = c3; item_tmp.card[3] = c4; item_tmp.bound = bound; if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND))) clif_additem(sd, 0, 0, flag); } } if (flag == 0) clif_displaymessage(fd, msg_txt(sd,18)); // Item created. } else { clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name. return -1; } return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(itemreset) { int i; nullpo_retr(-1, sd); for (i = 0; i < MAX_INVENTORY; i++) { if (sd->inventory.u.items_inventory[i].amount && sd->inventory.u.items_inventory[i].equip == 0 && !itemdb_ishatched_egg(&sd->inventory.u.items_inventory[i])) { pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND); } } clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed. return 0; } /*========================================== * Atcommand @lvlup *------------------------------------------*/ ACMD_FUNC(baselevelup) { int level=0, i=0, status_point=0, trait_point=0; nullpo_retr(-1, sd); level = atoi(message); if (!message || !*message || !level) { clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup ). return -1; } if (level > 0) { if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher. return -1; } // End Addition if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow level = pc_maxbaselv(sd) - sd->status.base_level; for (i = 0; i < level; i++) { status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i); trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i); } sd->status.status_point += status_point; sd->status.trait_point += trait_point; sd->status.base_level += (unsigned int)level; status_calc_pc(sd, SCO_FORCE); status_percent_heal(&sd->bl, 100, 100); clif_misceffect(&sd->bl, 0); for (uint32 j = sd->status.base_level - level; j <= sd->status.base_level; j++) { achievement_update_objective(sd, AG_GOAL_LEVEL, 1, j); achievement_update_objective(sd, AG_GOAL_STATUS, 2, j, sd->status.class_); } clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised. } else { if (sd->status.base_level == 1) { clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower. return -1; } level*=-1; if ((unsigned int)level >= sd->status.base_level) level = sd->status.base_level-1; for (i = 0; i > -level; i--) { status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i - 1); trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i - 1); } if (sd->status.status_point < status_point || sd->status.trait_point < trait_point) pc_resetstate(sd); if (sd->status.status_point < status_point) sd->status.status_point = 0; else sd->status.status_point -= status_point; if (sd->status.trait_point < trait_point) sd->status.trait_point = 0; else sd->status.trait_point -= trait_point; sd->status.base_level -= (unsigned int)level; clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered. status_calc_pc(sd, SCO_FORCE); level*=-1; } sd->status.base_exp = 0; clif_updatestatus(sd, SP_STATUSPOINT); clif_updatestatus(sd, SP_TRAITPOINT); clif_updatestatus(sd, SP_BASELEVEL); clif_updatestatus(sd, SP_BASEEXP); clif_updatestatus(sd, SP_NEXTBASEEXP); pc_baselevelchanged(sd); if(sd->status.party_id) party_send_levelup(sd); if( level > 0 && battle_config.atcommand_levelup_events ) npc_script_event(sd,NPCE_BASELVUP); return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(joblevelup) { int level=0; nullpo_retr(-1, sd); level = atoi(message); if (!message || !*message || !level) { clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup ). return -1; } if (level > 0) { if (sd->status.job_level >= pc_maxjoblv(sd)) { clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher. return -1; } if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow level = pc_maxjoblv(sd) - sd->status.job_level; sd->status.job_level += (unsigned int)level; sd->status.skill_point += level; clif_misceffect(&sd->bl, 1); for (uint32 i = sd->status.job_level - level; i <= sd->status.job_level; i++) achievement_update_objective(sd, AG_GOAL_LEVEL, 1, i); clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised. } else { if (sd->status.job_level == 1) { clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower. return -1; } level *=-1; if ((unsigned int)level >= sd->status.job_level) // fix negative overflow level = sd->status.job_level-1; sd->status.job_level -= (unsigned int)level; if (sd->status.skill_point < level) pc_resetskill(sd,0); //Reset skills since we need to subtract more points. if (sd->status.skill_point < level) sd->status.skill_point = 0; else sd->status.skill_point -= level; clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered. level *=-1; } sd->status.job_exp = 0; clif_updatestatus(sd, SP_JOBLEVEL); clif_updatestatus(sd, SP_JOBEXP); clif_updatestatus(sd, SP_NEXTJOBEXP); clif_updatestatus(sd, SP_SKILLPOINT); status_calc_pc(sd, SCO_FORCE); if( level > 0 && battle_config.atcommand_levelup_events ) npc_script_event(sd,NPCE_JOBLVUP); return 0; } /*========================================== * @help *------------------------------------------*/ ACMD_FUNC(help){ const char *command_name = nullptr; nullpo_retr(-1, sd); if (!message || !*message) { command_name = "help"; // If no command_name specified, display help for @help. } else { if (*message == atcommand_symbol || *message == charcommand_symbol) ++message; command_name = atcommand_alias_db.checkAlias(message); } if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) { sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command" clif_displaymessage(fd, atcmd_output); atcommand_get_suggestions(sd, command_name, true); return -1; } // attempt to find the first default help command std::shared_ptr info = atcommand_alias_db.find( command_name ); const char* text = info != nullptr ? info->help.c_str() : nullptr; if( text == nullptr ){ sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s. clif_displaymessage(fd, atcmd_output); atcommand_get_suggestions(sd, command_name, true); return -1; } sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s: clif_displaymessage(fd, atcmd_output); { // Display aliases StringBuf buf; bool has_aliases = false; StringBuf_Init(&buf); StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases: for( const std::string& alias : info->aliases ){ StringBuf_Printf( &buf, " %s", alias.c_str() ); has_aliases = true; } if (has_aliases) clif_displaymessage(fd, StringBuf_Value(&buf)); StringBuf_Destroy(&buf); } // Display help contents clif_displaymessage(fd, text); return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(pvpoff) { nullpo_retr(-1, sd); if (!map_getmapflag(sd->bl.m, MF_PVP)) { clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off. return -1; } map_setmapflag(sd->bl.m, MF_PVP, false); clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(pvpon) { nullpo_retr(-1, sd); if (map_getmapflag(sd->bl.m, MF_PVP)) { clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On. return -1; } map_setmapflag(sd->bl.m, MF_PVP, true); clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(gvgoff) { nullpo_retr(-1, sd); if (!map_getmapflag(sd->bl.m, MF_GVG)) { clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off. return -1; } map_setmapflag(sd->bl.m, MF_GVG, false); clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(gvgon) { nullpo_retr(-1, sd); if (map_getmapflag(sd->bl.m, MF_GVG)) { clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On. return -1; } map_setmapflag(sd->bl.m, MF_GVG, true); clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(model) { int hair_style = 0, hair_color = 0, cloth_color = 0; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) { sprintf(atcmd_output, msg_txt(sd,991), // Please enter at least one value (usage: @model ). MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); clif_displaymessage(fd, atcmd_output); return -1; } if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE && hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR && cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) { pc_changelook(sd, LOOK_HAIR, hair_style); pc_changelook(sd, LOOK_HAIR_COLOR, hair_color); pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color); clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed. } else { clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified. return -1; } return 0; } /*========================================== * @bodystyle [Rytech] *------------------------------------------*/ ACMD_FUNC(bodystyle) { int body_style = 0; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); if ( (sd->class_ & JOBL_FOURTH) || !(sd->class_ & JOBL_THIRD) || (sd->class_ & MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E || (sd->class_ & MAPID_THIRDMASK) == MAPID_STAR_EMPEROR || (sd->class_ & MAPID_THIRDMASK) == MAPID_SOUL_REAPER) { clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles. return -1; } if (!message || !*message || sscanf(message, "%d", &body_style) < 1) { sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle ). clif_displaymessage(fd, atcmd_output); return -1; } if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) { pc_changelook(sd, LOOK_BODY2, body_style); clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed. } else { clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified. return -1; } return 0; } /*========================================== * @dye && @ccolor *------------------------------------------*/ ACMD_FUNC(dye) { int cloth_color = 0; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) { sprintf(atcmd_output, msg_txt(sd,992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor ). clif_displaymessage(fd, atcmd_output); return -1; } if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) { pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color); clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed. } else { clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified. return -1; } return 0; } /*========================================== * @hairstyle && @hstyle *------------------------------------------*/ ACMD_FUNC(hair_style) { int hair_style = 0; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) { sprintf(atcmd_output, msg_txt(sd,993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle ). clif_displaymessage(fd, atcmd_output); return -1; } if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) { pc_changelook(sd, LOOK_HAIR, hair_style); clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed. } else { clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified. return -1; } return 0; } /*========================================== * @haircolor && @hcolor *------------------------------------------*/ ACMD_FUNC(hair_color) { int hair_color = 0; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) { sprintf(atcmd_output, msg_txt(sd,994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor ). clif_displaymessage(fd, atcmd_output); return -1; } if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) { pc_changelook(sd, LOOK_HAIR_COLOR, hair_color); clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed. } else { clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified. return -1; } return 0; } /*========================================== * @go [city_number or city_name] - Updated by Harbin *------------------------------------------*/ ACMD_FUNC(go) { int i; int town; char map_name[MAP_NAME_LENGTH]; const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = { { MAP_PRONTERA, 156, 191 }, // 0=Prontera { MAP_MORROC, 156, 93 }, // 1=Morroc { MAP_GEFFEN, 119, 59 }, // 2=Geffen { MAP_PAYON, 162, 233 }, // 3=Payon { MAP_ALBERTA, 192, 147 }, // 4=Alberta #ifdef RENEWAL { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal) #else { MAP_IZLUDE, 128, 114 }, // 5=Izlude #endif { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran { MAP_LUTIE, 147, 134 }, // 7=Lutie { MAP_COMODO, 209, 143 }, // 8=Comodo { MAP_YUNO, 157, 51 }, // 9=Yuno { MAP_AMATSU, 198, 84 }, // 10=Amatsu { MAP_GONRYUN, 160, 120 }, // 11=Gonryun { MAP_UMBALA, 89, 157 }, // 12=Umbala { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim { MAP_LOUYANG, 217, 40 }, // 14=Louyang #ifdef RENEWAL { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal) #else { MAP_NOVICE, 53, 111 }, // 15=Training Grounds #endif { MAP_JAIL, 23, 61 }, // 16=Prison { MAP_JAWAII, 249, 127 }, // 17=Jawaii { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya { MAP_EINBROCH, 64, 200 }, // 19=Einbroch { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen { MAP_EINBECH, 70, 95 }, // 21=Einbech { MAP_HUGEL, 96, 145 }, // 22=Hugel { MAP_RACHEL, 130, 110 }, // 23=Rachel { MAP_VEINS, 216, 123 }, // 24=Veins { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp { MAP_MANUK, 282, 138 }, // 27=Manuk { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide { MAP_BRASILIS, 182, 239 }, // 29=Brasilis { MAP_DICASTES, 198, 187 }, // 30=El Dicastes { MAP_MORA, 44, 151 }, // 31=Mora { MAP_DEWATA, 200, 180 }, // 32=Dewata { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island { MAP_MALAYA, 242, 211 }, // 34=Malaya Port { MAP_ECLAGE, 110, 39 }, // 35=Eclage { MAP_LASAGNA, 193, 182 }, // 36=Lasagna }; nullpo_retr(-1, sd); if( map_getmapflag(sd->bl.m, MF_NOGO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map. return 0; } memset(map_name, '\0', sizeof(map_name)); memset(atcmd_output, '\0', sizeof(atcmd_output)); // get the number town = atoi(message); if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {// no value matched so send the list of locations const char* text; // attempt to find the text help string text = atcommand_help_string( command ); clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name. if( text ) {// send the text to the client clif_displaymessage( fd, text ); } return -1; } // get possible name of the city map_name[MAP_NAME_LENGTH-1] = '\0'; for (i = 0; map_name[i]; i++) map_name[i] = TOLOWER(map_name[i]); // try to identify the map name if (strncmp(map_name, "prontera", 3) == 0) { town = 0; } else if (strncmp(map_name, "morocc", 4) == 0 || strncmp(map_name, "morroc", 4) == 0) { town = 1; } else if (strncmp(map_name, "geffen", 3) == 0) { town = 2; } else if (strncmp(map_name, "payon", 3) == 0) { town = 3; } else if (strncmp(map_name, "alberta", 3) == 0) { town = 4; } else if (strncmp(map_name, "izlude", 3) == 0) { town = 5; } else if (strncmp(map_name, "aldebaran", 3) == 0) { town = 6; } else if (strncmp(map_name, "lutie", 3) == 0 || strcmp(map_name, "christmas") == 0 || strncmp(map_name, "xmas", 3) == 0 || strncmp(map_name, "x-mas", 3) == 0) { town = 7; } else if (strncmp(map_name, "comodo", 3) == 0) { town = 8; } else if (strncmp(map_name, "juno", 3) == 0 || strncmp(map_name, "yuno", 3) == 0) { town = 9; } else if (strncmp(map_name, "amatsu", 3) == 0) { town = 10; } else if (strncmp(map_name, "kunlun", 3) == 0 || strncmp(map_name, "gonryun", 3) == 0) { town = 11; } else if (strncmp(map_name, "umbala", 3) == 0) { town = 12; } else if (strncmp(map_name, "niflheim", 3) == 0) { town = 13; } else if (strncmp(map_name, "louyang", 3) == 0) { town = 14; } else if (strncmp(map_name, "new_1-1", 3) == 0 || strncmp(map_name, "startpoint", 3) == 0 || strncmp(map_name, "beginning", 3) == 0) { town = 15; } else if (strncmp(map_name, "sec_pri", 3) == 0 || strncmp(map_name, "prison", 3) == 0 || strncmp(map_name, "jail", 3) == 0) { town = 16; } else if (strncmp(map_name, "jawaii", 3) == 0) { town = 17; } else if (strncmp(map_name, "ayothaya", 3) == 0) { town = 18; } else if (strncmp(map_name, "einbroch", 5) == 0) { town = 19; } else if (strncmp(map_name, "lighthalzen", 3) == 0) { town = 20; } else if (strncmp(map_name, "einbech", 5) == 0) { town = 21; } else if (strncmp(map_name, "hugel", 3) == 0) { town = 22; } else if (strncmp(map_name, "rachel", 3) == 0) { town = 23; } else if (strncmp(map_name, "veins", 3) == 0) { town = 24; } else if (strncmp(map_name, "moscovia", 3) == 0) { town = 25; } else if (strncmp(map_name, "mid_camp", 3) == 0) { town = 26; } else if (strncmp(map_name, "manuk", 3) == 0) { town = 27; } else if (strncmp(map_name, "splendide", 3) == 0) { town = 28; } else if (strncmp(map_name, "brasilis", 3) == 0) { town = 29; } else if (strncmp(map_name, "dicastes01", 3) == 0) { town = 30; } else if (strcmp(map_name, "mora") == 0) { town = 31; } else if (strncmp(map_name, "dewata", 3) == 0) { town = 32; } else if (strncmp(map_name, "malangdo", 5) == 0) { town = 33; } else if (strncmp(map_name, "malaya", 5) == 0) { town = 34; } else if (strncmp(map_name, "eclage", 3) == 0) { town = 35; } else if (strncmp(map_name, "lasagna", 2) == 0) { town = 36; } if (town >= 0 && town < ARRAYLENGTH(data)) { int16 m = map_mapname2mapid(data[town].map); if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map. return -1; } if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map. return -1; } if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) { clif_displaymessage(fd, msg_txt(sd,0)); // Warped. } else { clif_displaymessage(fd, msg_txt(sd,1)); // Map not found. return -1; } } else { // if you arrive here, you have an error in town variable when reading of names clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name. return -1; } return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(monster) { char name[NAME_LENGTH]; char monster[NAME_LENGTH]; char eventname[EVENT_NAME_LENGTH] = ""; int mob_id; int number = 0; int count; int i, range; short mx, my; unsigned int size; nullpo_retr(-1, sd); memset(name, '\0', sizeof(name)); memset(monster, '\0', sizeof(monster)); memset(atcmd_output, '\0', sizeof(atcmd_output)); if (!message || !*message) { clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please. return -1; } if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 || sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) { //All data can be left as it is. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) { //Here, it is possible name was not given and we are using monster for it. if (count < 3) //Blank mob's name. name[0] = '\0'; } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) { //All data can be left as it is. } else if (sscanf(message, "%23s", monster) > 0) { //As before, name may be already filled. name[0] = '\0'; } else { clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please. return -1; } if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number) mob_id = mobdb_checkid(atoi(monster)); if (mob_id == 0) { clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name. return -1; } if (mob_id == MOBID_EMPERIUM) { clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned. return -1; } if (number <= 0) number = 1; if( !name[0] ) strcpy(name, "--ja--"); // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit) number = battle_config.atc_spawn_quantity_limit; parent_cmd = atcommand_alias_db.checkAlias(command+1); if (strcmp(parent_cmd, "monstersmall") == 0) size = SZ_MEDIUM; // This is just gorgeous [mkbu95] else if (strcmp(parent_cmd, "monsterbig") == 0) size = SZ_BIG; else size = SZ_SMALL; if (battle_config.etc_log) ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y); count = 0; range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { int k; map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0); k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE); if(k) { //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed count ++; } } if (count != 0) if (number == count) clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned! else { sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned! clif_displaymessage(fd, atcmd_output); } else { clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name. return -1; } return 0; } /*========================================== * *------------------------------------------*/ static int atkillmonster_sub(struct block_list *bl, va_list ap) { struct mob_data *md; int flag; nullpo_ret(md=(struct mob_data *)bl); flag = va_arg(ap, int); if (md->guardian_data) return 0; //Do not touch WoE mobs! if (flag) status_zap(bl,md->status.hp, 0); else status_kill(bl); return 1; } ACMD_FUNC(killmonster) { int map_id, drop_flag; char map_name[MAP_NAME_LENGTH_EXT]; nullpo_retr(-1, sd); memset(map_name, '\0', sizeof(map_name)); if (!message || !*message || sscanf(message, "%15s", map_name) < 1) map_id = sd->bl.m; else { if ((map_id = map_mapname2mapid(map_name)) < 0) map_id = sd->bl.m; } parent_cmd = atcommand_alias_db.checkAlias(command+1); drop_flag = strcmpi(parent_cmd, "killmonster2"); map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag); clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed! return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(refine) { int j, position = 0, refine = 0, current_position, final_refine; int count; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) { clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <+/- amount>). sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1521), EQP_SHADOW_ARMOR); // %d: Shadow Armor clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1522), EQP_SHADOW_WEAPON); // %d: Shadow Weapon clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1523), EQP_SHADOW_SHIELD); // %d: Shadow Shield clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1524), EQP_SHADOW_SHOES); // %d: Shadow Shoes clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1525), EQP_SHADOW_ACC_R); // %d: Shadow Right Accessory clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1526), EQP_SHADOW_ACC_L); // %d: Shadow Left Accessory clif_displaymessage(fd, atcmd_output); return -1; } refine = cap_value(refine, -MAX_REFINE, MAX_REFINE); count = 0; for (j = 0; j < EQI_MAX; j++) { int i; if ((i = sd->equip_index[j]) < 0) continue; if(j == EQI_AMMO) continue; if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i)) continue; if(position && !(sd->inventory.u.items_inventory[i].equip & position)) continue; final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE); if (sd->inventory.u.items_inventory[i].refine != final_refine) { sd->inventory.u.items_inventory[i].refine = final_refine; current_position = sd->inventory.u.items_inventory[i].equip; pc_unequipitem(sd, i, 3); clif_refine(fd, 0, i, sd->inventory.u.items_inventory[i].refine); clif_delitem(sd, i, 1, 3); clif_additem(sd, i, 1, 0); pc_equipitem(sd, i, current_position); clif_misceffect(&sd->bl, 3); if( sd->inventory_data[i]->type == IT_WEAPON ){ achievement_update_objective(sd, AG_ENCHANT_SUCCESS, 2, sd->inventory_data[i]->weapon_level, sd->inventory.u.items_inventory[i].refine); } count++; } } if (count == 0) clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined. else if (count == 1) clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined. else { sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined. clif_displaymessage(fd, atcmd_output); } return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(grade) { int j, position = 0, grade = 0, current_position, final_grade; int count; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); if (!message || !*message || sscanf(message, "%11d %11d", &position, &grade) < 2) { clif_displaymessage(fd, msg_txt(sd,1519)); // Please enter a position and an amount (usage: @grade <+/- amount>). sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear clif_displaymessage(fd, atcmd_output); sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear clif_displaymessage(fd, atcmd_output); return -1; } grade = cap_value(grade, -MAX_ENCHANTGRADE, MAX_ENCHANTGRADE); count = 0; for (j = 0; j < EQI_MAX; j++) { int i; if ((i = sd->equip_index[j]) < 0) continue; if(j == EQI_AMMO) continue; if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i)) continue; if(position && !(sd->inventory.u.items_inventory[i].equip & position)) continue; final_grade = cap_value(sd->inventory.u.items_inventory[i].enchantgrade + grade, 0, MAX_ENCHANTGRADE); if (sd->inventory.u.items_inventory[i].enchantgrade != final_grade) { sd->inventory.u.items_inventory[i].enchantgrade = final_grade; current_position = sd->inventory.u.items_inventory[i].equip; pc_unequipitem(sd, i, 3); clif_delitem(sd, i, 1, 3); clif_additem(sd, i, 1, 0); pc_equipitem(sd, i, current_position); clif_misceffect(&sd->bl, 3); count++; } } sprintf(atcmd_output, msg_txt(sd,1520), count); // %d items have been graded. clif_displaymessage(fd, atcmd_output); return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(produce) { char item_name[100]; t_itemid item_id; int attribute = 0, star = 0; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); memset(item_name, '\0', sizeof(item_name)); if (!message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 && sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1 )) { clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <# of very's>). return -1; } std::shared_ptr item_data = item_db.searchname( item_name ); if( item_data == nullptr ){ item_data = item_db.find( strtoul( item_name, nullptr, 10 ) ); } if( item_data == nullptr ){ clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment. return -1; } item_id = item_data->nameid; if( itemdb_isequip2( item_data.get() ) ){ char flag = 0; if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE) attribute = ATTRIBUTE_NORMAL; if (star < MIN_STAR || star > MAX_STAR) star = 0; struct item tmp_item = {}; tmp_item.nameid = item_id; tmp_item.amount = 1; tmp_item.identify = 1; tmp_item.card[0] = CARD0_FORGE; tmp_item.card[1] = item_data->type==IT_WEAPON? ((star*5) << 8) + attribute:0; tmp_item.card[2] = GetWord(sd->status.char_id, 0); tmp_item.card[3] = GetWord(sd->status.char_id, 1); clif_produceeffect(sd, 0, item_id); clif_misceffect(&sd->bl, 3); if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND))) clif_additem(sd, 0, 0, flag); } else { sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name.c_str()); // The item (%u: '%s') is not equipable. clif_displaymessage(fd, atcmd_output); return -1; } return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(memo) { int position = 0; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); if( !message || !*message || sscanf(message, "%11d", &position) < 1 ) { int i; clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are: for( i = 0; i < MAX_MEMOPOINTS; i++ ) { if( strcmp( "", sd->status.memo_point[i].map ) != 0 ) sprintf( atcmd_output, "%d - %s (%d,%d)", i, sd->status.memo_point[i].map, sd->status.memo_point[i].x, sd->status.memo_point[i].y ); else sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void clif_displaymessage(sd->fd, atcmd_output); } return 0; } if( position < 0 || position >= MAX_MEMOPOINTS ) { sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo ). clif_displaymessage(fd, atcmd_output); return -1; } return !pc_memo( sd, position ); } /*========================================== * *------------------------------------------*/ ACMD_FUNC(gat) { int y; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); for (y = 2; y >= -2; y--) { sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X", map_getmapdata(sd->bl.m)->name, sd->bl.x - 2, sd->bl.y + y, map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE), map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE), map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE), map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE), map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE)); clif_displaymessage(fd, atcmd_output); } return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(displaystatus) { int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0; nullpo_retr(-1, sd); if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) { clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus { { {}}}). return -1; } if (i < 2) flag = 1; if (i < 3) tick = 0; clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3); return 0; } /*========================================== * @stpoint (Rewritten by [Yor]) *------------------------------------------*/ ACMD_FUNC(statuspoint) { int point; unsigned int new_status_point; if (!message || !*message || (point = atoi(message)) == 0) { clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint ). return -1; } if(point < 0) { if(sd->status.status_point < (unsigned int)(-point)) { new_status_point = 0; } else { new_status_point = sd->status.status_point + point; } } else if(UINT_MAX - sd->status.status_point < (unsigned int)point) { new_status_point = UINT_MAX; } else { new_status_point = sd->status.status_point + point; } if (new_status_point != sd->status.status_point) { sd->status.status_point = new_status_point; clif_updatestatus(sd, SP_STATUSPOINT); clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed. } else { if (point < 0) clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value. return -1; } return 0; } /*========================================== * @trpoint *------------------------------------------*/ ACMD_FUNC(traitpoint) { int point; unsigned int new_trait_point; if (!message || !*message || (point = atoi(message)) == 0) { clif_displaymessage(fd, msg_txt(sd, 820)); // Please enter a number (usage: @trpoint ). return -1; } if (point < 0) { if (sd->status.trait_point < (unsigned int)(-point)) { new_trait_point = 0; } else { new_trait_point = sd->status.trait_point + point; } } else if (UINT_MAX - sd->status.trait_point < (unsigned int)point) { new_trait_point = UINT_MAX; } else { new_trait_point = sd->status.trait_point + point; } if (new_trait_point != sd->status.trait_point) { sd->status.trait_point = new_trait_point; clif_updatestatus(sd, SP_TRAITPOINT); clif_displaymessage(fd, msg_txt(sd, 174)); // Number of status points changed. } else { if (point < 0) clif_displaymessage(fd, msg_txt(sd, 41)); // Unable to decrease the number/value. else clif_displaymessage(fd, msg_txt(sd, 149)); // Unable to increase the number/value. return -1; } return 0; } /*========================================== * @skpoint (Rewritten by [Yor]) *------------------------------------------*/ ACMD_FUNC(skillpoint) { int point; unsigned int new_skill_point; nullpo_retr(-1, sd); if (!message || !*message || (point = atoi(message)) == 0) { clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint ). return -1; } if(point < 0) { if(sd->status.skill_point < (unsigned int)(-point)) { new_skill_point = 0; } else { new_skill_point = sd->status.skill_point + point; } } else if(UINT_MAX - sd->status.skill_point < (unsigned int)point) { new_skill_point = UINT_MAX; } else { new_skill_point = sd->status.skill_point + point; } if (new_skill_point != sd->status.skill_point) { sd->status.skill_point = new_skill_point; clif_updatestatus(sd, SP_SKILLPOINT); clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed. } else { if (point < 0) clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value. return -1; } return 0; } /*========================================== * @zeny *------------------------------------------*/ ACMD_FUNC(zeny) { int zeny=0, ret=-1; nullpo_retr(-1, sd); if (!message || !*message || (zeny = atoi(message)) == 0) { clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny ). return -1; } if(zeny > 0){ if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND)) == 1) clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value. } else { if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny; if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND)) == 1) clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value. } if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(param) { nullpo_retr(-1, sd); uint8 stat; int value = 0; uint16 new_value, status, max_status; memset(atcmd_output, '\0', sizeof(atcmd_output)); if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) { clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>). return -1; } ARR_FIND( 0, ARRAYLENGTH(parameter_names), stat, strcmpi(command + 1, parameter_names[stat]) == 0 ); if( stat == ARRAYLENGTH(parameter_names)) { // normally impossible... clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>). return -1; } if( stat < PARAM_POW ){ status = pc_getstat( sd, SP_STR + stat - PARAM_STR ); }else{ if( !( sd->class_ & JOBL_FOURTH ) ){ clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class. return -1; } status = pc_getstat( sd, SP_POW + stat - PARAM_POW ); } if( pc_has_permission( sd, PC_PERM_BYPASS_MAX_STAT ) ){ max_status = SHRT_MAX; }else{ max_status = pc_maxparameter( sd, static_cast( stat ) ); } if( value > 0 && status + value >= max_status ){ new_value = max_status; }else if( value < 0 && abs( value ) >= status ){ if( stat < PARAM_POW ){ new_value = 1; }else{ new_value = 0; } }else{ new_value = status + value; } if( new_value != status ){ if (stat < PARAM_POW) { pc_setstat( sd, SP_STR + stat - PARAM_STR, new_value ); clif_updatestatus(sd, SP_STR + stat); clif_updatestatus(sd, SP_USTR + stat); } else { pc_setstat( sd, SP_POW + stat - PARAM_POW, new_value ); clif_updatestatus(sd, SP_POW + stat - PARAM_POW); clif_updatestatus(sd, SP_UPOW + stat - PARAM_POW); } status_calc_pc(sd, SCO_FORCE); clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed. achievement_update_objective(sd, AG_GOAL_STATUS, 0); } else { if (value < 0) clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value. return -1; } return 0; } /*========================================== * Stat all by fritz (rewritten by [Yor]) *------------------------------------------*/ ACMD_FUNC(stat_all) { nullpo_retr(-1, sd); int value = 0; uint8 count, i; uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {}; for (i = PARAM_STR; i < PARAM_POW; i++) status[i] = pc_getstat(sd, SP_STR + i); if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) { for (i = PARAM_STR; i < PARAM_POW; i++) max_status[i] = pc_maxparameter(sd, static_cast(i)); value = SHRT_MAX; } else { if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) { for (i = PARAM_STR; i < PARAM_POW; i++) max_status[i] = SHRT_MAX; } else { for (i = PARAM_STR; i < PARAM_POW; i++) max_status[i] = pc_maxparameter(sd, static_cast(i)); } } count = 0; for (i = PARAM_STR; i < PARAM_POW; i++) { short new_value; if (value > 0 && status[i] + value >= max_status[i]) new_value = max_status[i]; else if (value < 0 && abs(value) >= status[i]) new_value = 1; else new_value = status[i] + value; if (new_value != status[i]) { pc_setstat( sd, SP_STR + i, new_value ); clif_updatestatus(sd, SP_STR + i); clif_updatestatus(sd, SP_USTR + i); count++; } } if (count > 0) { // if at least 1 stat modified status_calc_pc(sd, SCO_FORCE); clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed! achievement_update_objective(sd, AG_GOAL_STATUS, 0); } else { if (value < 0) clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore. else clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore. return -1; } return 0; } /*========================================== * Traits *------------------------------------------*/ ACMD_FUNC(trait_all) { nullpo_retr(-1, sd); #ifndef RENEWAL sprintf(atcmd_output, msg_txt(sd, 154), command); // %s failed. clif_displaymessage(fd, atcmd_output); return -1; #endif if( !( sd->class_ & JOBL_FOURTH ) ){ clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class. return -1; } int value = 0; uint8 i; uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {}; for (i = PARAM_POW; i < PARAM_MAX; i++) status[i] = pc_getstat(sd, SP_POW + i - PARAM_POW); if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) { for (i = PARAM_POW; i < PARAM_MAX; i++) max_status[i] = pc_maxparameter(sd, static_cast(i)); value = SHRT_MAX; } else { if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) { for (i = PARAM_POW; i < PARAM_MAX; i++) max_status[i] = SHRT_MAX; } else { for (i = PARAM_POW; i < PARAM_MAX; i++) max_status[i] = pc_maxparameter(sd, static_cast(i)); } } uint8 count = 0; for (i = PARAM_POW; i < PARAM_MAX; i++) { short new_value; if (value > 0 && status[i] + value >= max_status[i]) new_value = max_status[i]; else if (value < 0 && abs(value) >= status[i]) new_value = 0; else new_value = status[i] + value; if (new_value != status[i]) { pc_setstat( sd, SP_POW + i - PARAM_POW, new_value ); clif_updatestatus(sd, SP_POW + i - PARAM_POW); clif_updatestatus(sd, SP_UPOW + i - PARAM_POW); count++; } } if (count > 0) { // if at least 1 stat modified status_calc_pc(sd, SCO_FORCE); clif_displaymessage(fd, msg_txt(sd, 84)); // All stats changed! achievement_update_objective(sd, AG_GOAL_STATUS, 0); } else { if (value < 0) clif_displaymessage(fd, msg_txt(sd, 177)); // You cannot decrease that stat anymore. else clif_displaymessage(fd, msg_txt(sd, 178)); // You cannot increase that stat anymore. return -1; } return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(guildlevelup) { int level = 0; short added_level; nullpo_retr(-1, sd); if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) { clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>). return -1; } auto &guild_info = sd->guild; if (sd->status.guild_id <= 0 || guild_info == nullptr) { clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild. return -1; } //if (strcmp(sd->status.name, guild_info->master) != 0) { // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild. // return -1; //} added_level = (short)level; if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild.guild_lv))) // fix positive overflow added_level = (short)MAX_GUILDLEVEL - guild_info->guild.guild_lv; else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild.guild_lv))) // fix negative overflow added_level = 1 - guild_info->guild.guild_lv; if (added_level != 0) { intif_guild_change_basicinfo(guild_info->guild.guild_id, GBI_GUILDLV, &added_level, sizeof(added_level)); clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed. } else { clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed. return -1; } return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(makeegg) { int id; nullpo_retr(-1, sd); if (!message || !*message) { clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg ). return -1; } // for monster name if ((id = mobdb_searchname(message)) != 0) ; else id = atoi(message); std::shared_ptr pet = pet_db.find(id); if( pet == nullptr ){ t_itemid nameid; // for egg name std::shared_ptr item_data = item_db.searchname( message ); if( item_data != nullptr ){ nameid = item_data->nameid; }else{ nameid = strtoul( message, nullptr, 10 ); } pet = pet_db_search( nameid, PET_EGG ); } int res(-1); if (pet != nullptr) { std::shared_ptr mdb = mob_db.find(pet->class_); if(mdb){ sd->catch_target_class = pet->class_; if(intif_create_pet(sd->status.account_id, sd->status.char_id, pet->class_, mdb->lv, pet->EggID, 0, pet->intimate, 100, 0, 1, mdb->jname.c_str())){ res = 0; } else { res = -2; //char server down } } } switch(res){ case -1: clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist. break; case -2: clif_displaymessage(fd, msg_txt(sd,407)); //charserver link broken break; } return res; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(hatch) { nullpo_retr(-1, sd); if (sd->status.pet_id <= 0) clif_sendegg(sd); else { clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet. return -1; } return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(petfriendly) { int friendly; struct pet_data *pd; nullpo_retr(-1, sd); if (!message || !*message || (friendly = atoi(message)) < 0) { clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>). return -1; } pd = sd->pd; if (!pd) { clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet. return -1; } if (friendly < 0 || friendly > 1000) { clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified. return -1; } if (friendly == pd->pet.intimate) { clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum. return -1; } pet_set_intimate(pd, friendly); clif_send_petstatus(sd); clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(pethungry) { int hungry; struct pet_data *pd; nullpo_retr(-1, sd); if (!message || !*message || (hungry = atoi(message)) < 0) { clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>). return -1; } pd = sd->pd; if (!sd->status.pet_id || !pd) { clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet. return -1; } if (hungry < 0 || hungry > 100) { clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified. return -1; } if (hungry == pd->pet.hungry) { clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum. return -1; } pd->pet.hungry = hungry; clif_send_petstatus(sd); clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(petrename) { struct pet_data *pd; nullpo_retr(-1, sd); if (!sd->status.pet_id || !sd->pd) { clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet. return -1; } pd = sd->pd; if (!pd->pet.rename_flag) { clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet. return -1; } pd->pet.rename_flag = 0; intif_save_petdata(sd->status.account_id, &pd->pet); clif_send_petstatus(sd); clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet. return 0; } /*========================================== * *------------------------------------------*/ ACMD_FUNC(recall) { map_session_data* pl_sd = nullptr;; nullpo_retr(-1, sd); memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall ). return -1; } if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL) { clif_displaymessage(fd, msg_txt(sd,3)); // Character not found. return -1; } if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to perform this action on the specified player. return -1; } if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map. return -1; } if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map. return -1; } if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) { return -1; } if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){ clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled. return -1; } sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled! clif_displaymessage(fd, atcmd_output); return 0; } /*========================================== * charblock command (usage: charblock ) * This command do a definitiv ban on a player *------------------------------------------*/ ACMD_FUNC(char_block) { nullpo_retr(-1, sd); memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s ). clif_displaymessage(fd, atcmd_output); return -1; } chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0); sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server... clif_displaymessage(fd, atcmd_output); return 0; } /*========================================== * accountban command (usage: ban <%time> ) * charban command (usage: charban <%time> ) * %time see common/timer.cpp::solve_time() *------------------------------------------*/ ACMD_FUNC(char_ban) { char *modif_p, output[CHAT_SIZE_MAX]; int32 timediff = 0; //don't set this as uint as we may want to decrease banned time enum chrif_req_op bantype; nullpo_retr(-1, sd); memset(atcmd_output, '\0', sizeof(atcmd_output)); memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); parent_cmd = atcommand_alias_db.checkAlias(command+1); if (strcmpi(parent_cmd,"charban") == 0) bantype = CHRIF_OP_BAN; else if (strcmpi(parent_cmd,"ban") == 0) bantype = CHRIF_OP_LOGIN_BAN; else return -1; if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) { sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s