#include "atcommand.hpp" #include #include #include #include "../common/core.hpp" #include "../common/cxxstdio.hpp" #include "../common/mmo.hpp" #include "../common/random.hpp" #include "../common/nullpo.hpp" #include "../common/socket.hpp" #include "../common/timer.hpp" #include "../common/utils2.hpp" #include "battle.hpp" #include "chrif.hpp" #include "clif.hpp" #include "intif.hpp" #include "itemdb.hpp" #include "map.hpp" #include "mob.hpp" #include "npc.hpp" #include "party.hpp" #include "pc.hpp" #include "script.hpp" #include "skill.hpp" #include "storage.hpp" #include "tmw.hpp" #include "trade.hpp" #include "../poison.hpp" #define ATCOMMAND_FUNC(x) static \ int atcommand_##x(const int fd, struct map_session_data* sd, const char* command, const char* message) ATCOMMAND_FUNC(setup); ATCOMMAND_FUNC(broadcast); ATCOMMAND_FUNC(localbroadcast); ATCOMMAND_FUNC(charwarp); ATCOMMAND_FUNC(warp); ATCOMMAND_FUNC(where); ATCOMMAND_FUNC(goto); ATCOMMAND_FUNC(jump); ATCOMMAND_FUNC(who); ATCOMMAND_FUNC(whogroup); ATCOMMAND_FUNC(whomap); ATCOMMAND_FUNC(whomapgroup); ATCOMMAND_FUNC(whogm); // by Yor ATCOMMAND_FUNC(save); ATCOMMAND_FUNC(load); ATCOMMAND_FUNC(speed); ATCOMMAND_FUNC(storage); ATCOMMAND_FUNC(option); ATCOMMAND_FUNC(hide); ATCOMMAND_FUNC(die); ATCOMMAND_FUNC(kill); ATCOMMAND_FUNC(alive); ATCOMMAND_FUNC(kami); ATCOMMAND_FUNC(heal); ATCOMMAND_FUNC(item); ATCOMMAND_FUNC(itemreset); ATCOMMAND_FUNC(itemcheck); ATCOMMAND_FUNC(baselevelup); ATCOMMAND_FUNC(joblevelup); ATCOMMAND_FUNC(help); ATCOMMAND_FUNC(gm); ATCOMMAND_FUNC(pvpoff); ATCOMMAND_FUNC(pvpon); ATCOMMAND_FUNC(model); ATCOMMAND_FUNC(spawn); ATCOMMAND_FUNC(killmonster); ATCOMMAND_FUNC(killmonster2); ATCOMMAND_FUNC(gat); ATCOMMAND_FUNC(packet); ATCOMMAND_FUNC(statuspoint); ATCOMMAND_FUNC(skillpoint); ATCOMMAND_FUNC(zeny); template ATCOMMAND_FUNC(param); ATCOMMAND_FUNC(recall); ATCOMMAND_FUNC(recallall); ATCOMMAND_FUNC(revive); ATCOMMAND_FUNC(character_stats); ATCOMMAND_FUNC(character_stats_all); ATCOMMAND_FUNC(character_option); ATCOMMAND_FUNC(character_save); ATCOMMAND_FUNC(doom); ATCOMMAND_FUNC(doommap); ATCOMMAND_FUNC(raise); ATCOMMAND_FUNC(raisemap); ATCOMMAND_FUNC(character_baselevel); ATCOMMAND_FUNC(character_joblevel); ATCOMMAND_FUNC(kick); ATCOMMAND_FUNC(kickall); ATCOMMAND_FUNC(questskill); ATCOMMAND_FUNC(charquestskill); ATCOMMAND_FUNC(lostskill); ATCOMMAND_FUNC(charlostskill); ATCOMMAND_FUNC(party); ATCOMMAND_FUNC(charskreset); ATCOMMAND_FUNC(charstreset); ATCOMMAND_FUNC(charreset); ATCOMMAND_FUNC(charstpoint); ATCOMMAND_FUNC(charmodel); ATCOMMAND_FUNC(charskpoint); ATCOMMAND_FUNC(charzeny); ATCOMMAND_FUNC(reloaditemdb); ATCOMMAND_FUNC(reloadmobdb); ATCOMMAND_FUNC(reloadskilldb); ATCOMMAND_FUNC(reloadscript); ATCOMMAND_FUNC(reloadgmdb); // by Yor ATCOMMAND_FUNC(mapexit); ATCOMMAND_FUNC(idsearch); ATCOMMAND_FUNC(mapinfo); ATCOMMAND_FUNC(dye); //** by fritz ATCOMMAND_FUNC(hair_style); //** by fritz ATCOMMAND_FUNC(hair_color); //** by fritz ATCOMMAND_FUNC(all_stats); //** by fritz ATCOMMAND_FUNC(char_change_sex); // by Yor ATCOMMAND_FUNC(char_block); // by Yor ATCOMMAND_FUNC(char_ban); // by Yor ATCOMMAND_FUNC(char_unblock); // by Yor ATCOMMAND_FUNC(char_unban); // by Yor ATCOMMAND_FUNC(partyspy); // [Syrus22] ATCOMMAND_FUNC(partyrecall); // by Yor ATCOMMAND_FUNC(enablenpc); ATCOMMAND_FUNC(disablenpc); ATCOMMAND_FUNC(servertime); // by Yor ATCOMMAND_FUNC(chardelitem); // by Yor ATCOMMAND_FUNC(ignorelist); // by Yor ATCOMMAND_FUNC(charignorelist); // by Yor ATCOMMAND_FUNC(inall); // by Yor ATCOMMAND_FUNC(exall); // by Yor ATCOMMAND_FUNC(email); // by Yor ATCOMMAND_FUNC(effect); //by Apple ATCOMMAND_FUNC(character_item_list); // by Yor ATCOMMAND_FUNC(character_storage_list); // by Yor ATCOMMAND_FUNC(character_cart_list); // by Yor ATCOMMAND_FUNC(addwarp); // by MouseJstr ATCOMMAND_FUNC(killer); // by MouseJstr ATCOMMAND_FUNC(npcmove); // by MouseJstr ATCOMMAND_FUNC(killable); // by MouseJstr ATCOMMAND_FUNC(charkillable); // by MouseJstr ATCOMMAND_FUNC(chareffect); // by MouseJstr ATCOMMAND_FUNC(dropall); // by MouseJstr ATCOMMAND_FUNC(chardropall); // by MouseJstr ATCOMMAND_FUNC(storeall); // by MouseJstr ATCOMMAND_FUNC(charstoreall); // by MouseJstr ATCOMMAND_FUNC(summon); ATCOMMAND_FUNC(rain); ATCOMMAND_FUNC(snow); ATCOMMAND_FUNC(sakura); ATCOMMAND_FUNC(fog); ATCOMMAND_FUNC(leaves); ATCOMMAND_FUNC(adjgmlvl); // by MouseJstr ATCOMMAND_FUNC(adjcmdlvl); // by MouseJstr ATCOMMAND_FUNC(trade); // by MouseJstr ATCOMMAND_FUNC(char_wipe); // [Fate] ATCOMMAND_FUNC(set_magic); // [Fate] ATCOMMAND_FUNC(magic_info); // [Fate] ATCOMMAND_FUNC(log); // [Fate] ATCOMMAND_FUNC(tee); // [Fate] ATCOMMAND_FUNC(invisible); // [Fate] ATCOMMAND_FUNC(visible); // [Fate] ATCOMMAND_FUNC(list_nearby); // [Fate] ATCOMMAND_FUNC(iterate_forward_over_players); // [Fate] ATCOMMAND_FUNC(iterate_backwards_over_players); // [Fate] ATCOMMAND_FUNC(skillpool_info); // [Fate] ATCOMMAND_FUNC(skillpool_focus); // [Fate] ATCOMMAND_FUNC(skillpool_unfocus); // [Fate] ATCOMMAND_FUNC(skill_learn); // [Fate] ATCOMMAND_FUNC(wgm); ATCOMMAND_FUNC(ipcheck); ATCOMMAND_FUNC(doomspot); /*========================================== *AtCommandInfo atcommand_info[]構造体の定義 *------------------------------------------ */ // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value. // to set default level, read atcommand_athena.conf first please. static AtCommandInfo atcommand_info[] = { {AtCommand_Setup, "@setup", 40, atcommand_setup}, {AtCommand_CharWarp, "@charwarp", 60, atcommand_charwarp}, {AtCommand_Warp, "@warp", 40, atcommand_warp}, {AtCommand_Where, "@where", 1, atcommand_where}, {AtCommand_Goto, "@goto", 20, atcommand_goto}, {AtCommand_Jump, "@jump", 40, atcommand_jump}, {AtCommand_Who, "@who", 20, atcommand_who}, {AtCommand_WhoGroup, "@whogroup", 20, atcommand_whogroup}, {AtCommand_WhoMap, "@whomap", 20, atcommand_whomap}, {AtCommand_WhoMapGroup, "@whomapgroup", 20, atcommand_whomapgroup}, {AtCommand_WhoGM, "@whogm", 20, atcommand_whogm}, // by Yor {AtCommand_Save, "@save", 40, atcommand_save}, {AtCommand_Load, "@return", 40, atcommand_load}, {AtCommand_Load, "@load", 40, atcommand_load}, {AtCommand_Speed, "@speed", 40, atcommand_speed}, {AtCommand_Storage, "@storage", 1, atcommand_storage}, {AtCommand_Option, "@option", 40, atcommand_option}, {AtCommand_Hide, "@hide", 40, atcommand_hide}, // + /hide {AtCommand_Die, "@die", 1, atcommand_die}, {AtCommand_Kill, "@kill", 60, atcommand_kill}, {AtCommand_Alive, "@alive", 60, atcommand_alive}, {AtCommand_Kami, "@kami", 40, atcommand_kami}, {AtCommand_Heal, "@heal", 40, atcommand_heal}, {AtCommand_Item, "@item", 60, atcommand_item}, {AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset}, {AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck}, {AtCommand_BaseLevelUp, "@blvl", 60, atcommand_baselevelup}, {AtCommand_JobLevelUp, "@jlvl", 60, atcommand_joblevelup}, {AtCommand_Help, "@help", 20, atcommand_help}, {AtCommand_GM, "@gm", 100, atcommand_gm}, {AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff}, {AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon}, {AtCommand_Model, "@model", 20, atcommand_model}, {AtCommand_Spawn, "@spawn", 50, atcommand_spawn}, {AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster}, {AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2}, {AtCommand_GAT, "@gat", 99, atcommand_gat}, // debug function {AtCommand_Packet, "@packet", 99, atcommand_packet}, // debug function {AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint}, {AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint}, {AtCommand_Zeny, "@zeny", 60, atcommand_zeny}, {AtCommand_Strength, "@str", 60, atcommand_param}, {AtCommand_Agility, "@agi", 60, atcommand_param}, {AtCommand_Vitality, "@vit", 60, atcommand_param}, {AtCommand_Intelligence, "@int", 60, atcommand_param}, {AtCommand_Dexterity, "@dex", 60, atcommand_param}, {AtCommand_Luck, "@luk", 60, atcommand_param}, {AtCommand_Recall, "@recall", 60, atcommand_recall}, // + /recall {AtCommand_Revive, "@revive", 60, atcommand_revive}, {AtCommand_CharacterStats, "@charstats", 40, atcommand_character_stats}, {AtCommand_CharacterStatsAll, "@charstatsall", 40, atcommand_character_stats_all}, {AtCommand_CharacterOption, "@charoption", 60, atcommand_character_option}, {AtCommand_CharacterSave, "@charsave", 60, atcommand_character_save}, {AtCommand_Doom, "@doom", 80, atcommand_doom}, {AtCommand_DoomMap, "@doommap", 80, atcommand_doommap}, {AtCommand_Raise, "@raise", 80, atcommand_raise}, {AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap}, {AtCommand_CharacterBaseLevel, "@charbaselvl", 60, atcommand_character_baselevel}, {AtCommand_CharacterJobLevel, "@charjlvl", 60, atcommand_character_joblevel}, {AtCommand_Kick, "@kick", 20, atcommand_kick}, // + right click menu for GM "(name) force to quit" {AtCommand_KickAll, "@kickall", 99, atcommand_kickall}, {AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill}, {AtCommand_CharQuestSkill, "@charquestskill", 60, atcommand_charquestskill}, {AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill}, {AtCommand_CharLostSkill, "@charlostskill", 60, atcommand_charlostskill}, {AtCommand_Party, "@party", 1, atcommand_party}, {AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit}, {AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch}, {AtCommand_MapMove, "@mapmove", 40, atcommand_warp}, // /mm command {AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast}, // /b and /nb command {AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast}, // /lb and /nlb command {AtCommand_RecallAll, "@recallall", 80, atcommand_recallall}, {AtCommand_CharSkReset, "@charskreset", 60, atcommand_charskreset}, {AtCommand_CharStReset, "@charstreset", 60, atcommand_charstreset}, {AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb}, // admin command {AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb}, // admin command {AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb}, // admin command {AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript}, // admin command {AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb}, // admin command {AtCommand_CharReset, "@charreset", 60, atcommand_charreset}, {AtCommand_CharModel, "@charmodel", 50, atcommand_charmodel}, {AtCommand_CharSKPoint, "@charskpoint", 60, atcommand_charskpoint}, {AtCommand_CharSTPoint, "@charstpoint", 60, atcommand_charstpoint}, {AtCommand_CharZeny, "@charzeny", 60, atcommand_charzeny}, {AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo}, {AtCommand_Dye, "@dye", 40, atcommand_dye}, // by fritz {AtCommand_Dye, "@ccolor", 40, atcommand_dye}, // by fritz {AtCommand_HairStyle, "@hairstyle", 40, atcommand_hair_style}, // by fritz {AtCommand_HairColor, "@haircolor", 40, atcommand_hair_color}, // by fritz {AtCommand_AllStats, "@allstats", 60, atcommand_all_stats}, // by fritz {AtCommand_CharChangeSex, "@charchangesex", 60, atcommand_char_change_sex}, // by Yor {AtCommand_CharBlock, "@block", 60, atcommand_char_block}, // by Yor {AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock}, // by Yor {AtCommand_CharBan, "@ban", 60, atcommand_char_ban}, // by Yor {AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban}, // by Yor {AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy}, // [Syrus22] {AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall}, // by Yor {AtCommand_Enablenpc, "@enablenpc", 80, atcommand_enablenpc}, // [] {AtCommand_Disablenpc, "@disablenpc", 80, atcommand_disablenpc}, // [] {AtCommand_ServerTime, "@servertime", 0, atcommand_servertime}, // by Yor {AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem}, // by Yor {AtCommand_ListNearby, "@listnearby", 40, atcommand_list_nearby}, // by Yor {AtCommand_IgnoreList, "@ignorelist", 0, atcommand_ignorelist}, // by Yor {AtCommand_CharIgnoreList, "@charignorelist", 20, atcommand_charignorelist}, // by Yor {AtCommand_IgnoreList, "@inall", 20, atcommand_inall}, // by Yor {AtCommand_ExAll, "@exall", 20, atcommand_exall}, // by Yor {AtCommand_EMail, "@email", 0, atcommand_email}, // by Yor {AtCommand_Effect, "@effect", 40, atcommand_effect}, // by Apple {AtCommand_Char_Item_List, "@charitemlist", 40, atcommand_character_item_list}, // by Yor {AtCommand_Char_Storage_List, "@charstoragelist", 40, atcommand_character_storage_list}, // by Yor {AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list}, // by Yor {AtCommand_AddWarp, "@addwarp", 20, atcommand_addwarp}, // by MouseJstr {AtCommand_Killer, "@killer", 60, atcommand_killer}, // by MouseJstr {AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove}, // by MouseJstr {AtCommand_Killable, "@killable", 40, atcommand_killable}, // by MouseJstr {AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable}, // by MouseJstr {AtCommand_Chareffect, "@chareffect", 40, atcommand_chareffect}, // MouseJstr {AtCommand_Dropall, "@dropall", 40, atcommand_dropall}, // MouseJstr {AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall}, // MouseJstr {AtCommand_Storeall, "@storeall", 40, atcommand_storeall}, // MouseJstr {AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall}, // MouseJstr {AtCommand_Rain, "@rain", 99, atcommand_rain}, {AtCommand_Snow, "@snow", 99, atcommand_snow}, {AtCommand_Sakura, "@sakura", 99, atcommand_sakura}, {AtCommand_Fog, "@fog", 99, atcommand_fog}, {AtCommand_Leaves, "@leaves", 99, atcommand_leaves}, //{ AtCommand_Shuffle, "@shuffle", 99, atcommand_shuffle }, //{ AtCommand_Maintenance, "@maintenance", 99, atcommand_maintenance }, //{ AtCommand_Misceffect, "@misceffect", 60, atcommand_misceffect }, {AtCommand_Summon, "@summon", 60, atcommand_summon}, {AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl}, {AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl}, {AtCommand_Trade, "@trade", 60, atcommand_trade}, {AtCommand_UnMute, "@charwipe", 60, atcommand_char_wipe}, // [Fate] {AtCommand_SetMagic, "@setmagic", 99, atcommand_set_magic}, // [Fate] {AtCommand_MagicInfo, "@magicinfo", 60, atcommand_magic_info}, // [Fate] {AtCommand_Log, "@log", 60, atcommand_log}, // [Fate] {AtCommand_Log, "@l", 60, atcommand_log}, // [Fate] {AtCommand_Tee, "@tee", 60, atcommand_tee}, // [Fate] {AtCommand_Tee, "@t", 60, atcommand_tee}, // [Fate] {AtCommand_Invisible, "@invisible", 60, atcommand_invisible}, // [Fate] {AtCommand_Visible, "@visible", 60, atcommand_visible}, // [Fate] {AtCommand_IterateForward, "@hugo", 60, atcommand_iterate_forward_over_players}, // [Fate] {AtCommand_IterateBackward, "@linus", 60, atcommand_iterate_backwards_over_players}, // [Fate] {AtCommand_IterateBackward, "@sp-info", 40, atcommand_skillpool_info}, // [Fate] {AtCommand_IterateBackward, "@sp-focus", 80, atcommand_skillpool_focus}, // [Fate] {AtCommand_IterateBackward, "@sp-unfocus", 80, atcommand_skillpool_unfocus}, // [Fate] {AtCommand_IterateBackward, "@skill-learn", 80, atcommand_skill_learn}, // [Fate] {AtCommand_Wgm, "@wgm", 0, atcommand_wgm}, {AtCommand_IpCheck, "@ipcheck", 60, atcommand_ipcheck}, {AtCommand_DoomSpot, "@doomspot", 60, atcommand_doomspot}, // add new commands before this line {AtCommand_Unknown, NULL, 1, NULL} }; /*========================================== * get_atcommand_level @コマンドの必要レベルを取得 *------------------------------------------ */ int get_atcommand_level(const AtCommandType type) { int i; for (i = 0; atcommand_info[i].type != AtCommand_None; i++) if (atcommand_info[i].type == type) return atcommand_info[i].level; return 100; // 100: command can not be used } static FILE *get_gm_log(); /*======================================== * At-command logging */ void log_atcommand(struct map_session_data *sd, const_string cmd) { FILE *fp = get_gm_log(); if (!fp) return; timestamp_seconds_buffer tmpstr; stamp_time(tmpstr); fprintf(fp, "[%s] %s(%d,%d) %s(%d) : ", tmpstr, map[sd->bl.m].name, sd->bl.x, sd->bl.y, sd->status.name, sd->status.account_id); fwrite(cmd.data(), 1, cmd.size(), fp); } char *gm_logfile_name = NULL; /*========================================== * Log a timestamped line to GM log file *------------------------------------------ */ FILE *get_gm_log() { if (!gm_logfile_name) return NULL; time_t ts = time(NULL); struct tm ctime = *gmtime(&ts); int year = ctime.tm_year + 1900; int month = ctime.tm_mon + 1; int logfile_nr = (year * 12) + month; static FILE *gm_logfile = NULL; static int last_logfile_nr = 0; if (logfile_nr == last_logfile_nr) return gm_logfile; last_logfile_nr = logfile_nr; std::string fullname = STRPRINTF("%s.%04d-%02d", gm_logfile_name, year, month); if (gm_logfile) fclose_(gm_logfile); gm_logfile = fopen_(fullname.c_str(), "a"); if (!gm_logfile) { perror("GM log file"); gm_logfile_name = NULL; } return gm_logfile; } static AtCommandType atcommand(const int level, const char *message, struct AtCommandInfo * info); /*========================================== *is_atcommand @コマンドに存在するかどうか確認する *------------------------------------------ */ bool is_atcommand(const int fd, struct map_session_data *sd, const char *message, int gmlvl) { AtCommandInfo info; AtCommandType type; nullpo_retr(false, sd); if (!message || !*message) return false; memset(&info, 0, sizeof(info)); type = atcommand(gmlvl > 0 ? gmlvl : pc_isGM(sd), message, &info); if (type != AtCommand_None) { char command[100]; const char *str = message; const char *p = message; memset(command, '\0', sizeof(command)); while (*p && !isspace(*p)) p++; if (p - str >= sizeof(command)) // too long return true; strncpy(command, str, p - str); while (isspace(*p)) p++; if (type == AtCommand_Unknown || info.proc == NULL) { std::string output = STRPRINTF("%s is Unknown Command.", command); clif_displaymessage(fd, output); } else { if (info.proc(fd, sd, command, p) != 0) { // Command can not be executed std::string output = STRPRINTF("%s failed.", command); clif_displaymessage(fd, output); } else { if (get_atcommand_level(type) != 0) // Don't log level 0 commands log_atcommand(sd, message); } } return true; } return false; } /*========================================== * *------------------------------------------ */ AtCommandType atcommand(const int level, const char *message, struct AtCommandInfo * info) { const char *p = message; if (!info) return AtCommand_None; if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd) return AtCommand_None; if (!p || !*p) { FPRINTF(stderr, "at command message is empty\n"); return AtCommand_None; } if (*p == '@') { // check first char. char command[101]; int i = 0; memset(info, 0, sizeof(AtCommandInfo)); sscanf(p, "%100s", command); command[sizeof(command) - 1] = '\0'; while (atcommand_info[i].type != AtCommand_Unknown) { if (strcasecmp(command, atcommand_info[i].command) == 0 && level >= atcommand_info[i].level) { break; } i++; } if (atcommand_info[i].type == AtCommand_Unknown) { // doesn't return Unknown if player is normal player (display the text, not display: unknown command) if (level == 0) return AtCommand_None; else return AtCommand_Unknown; } memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]); } else { return AtCommand_None; } return info->type; } /*========================================== * *------------------------------------------ */ static void atkillmonster_sub(struct block_list *bl, int flag) { nullpo_retv(bl); if (flag) mob_damage(NULL, (struct mob_data *) bl, ((struct mob_data *) bl)->hp, 2); else mob_delete((struct mob_data *) bl); } /*========================================== * *------------------------------------------ */ static AtCommandInfo *get_atcommandinfo_byname(const char *name) { int i; for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++) if (strcasecmp(atcommand_info[i].command + 1, name) == 0) return &atcommand_info[i]; return NULL; } /*========================================== * *------------------------------------------ */ int atcommand_config_read(const char *cfgName) { char line[1024], w1[1024], w2[1024]; AtCommandInfo *p; FILE *fp; if ((fp = fopen_(cfgName, "r")) == NULL) { PRINTF("At commands configuration file not found: %s\n", cfgName); return 1; } while (fgets(line, sizeof(line) - 1, fp)) { if (line[0] == '/' && line[1] == '/') continue; if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2) continue; p = get_atcommandinfo_byname(w1); if (p != NULL) { p->level = atoi(w2); if (p->level > 100) p->level = 100; else if (p->level < 0) p->level = 0; } if (strcasecmp(w1, "import") == 0) atcommand_config_read(w2); } fclose_(fp); return 0; } /*========================================== // @ command processing functions *------------------------------------------ */ /*========================================== * @setup - Safely set a chars levels and warp them to a special place * TAW Specific *------------------------------------------ */ int atcommand_setup(const int fd, struct map_session_data *sd, const char *, const char *message) { char character[100]; int level = 1; memset(character, '\0', sizeof(character)); if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2) { clif_displaymessage(fd, "Usage: @setup "); return -1; } level--; std::string buf; buf = STRPRINTF("-255 %s", character); atcommand_character_baselevel(fd, sd, "@charbaselvl", buf.c_str()); buf = STRPRINTF("%d %s", level, character); atcommand_character_baselevel(fd, sd, "@charbaselvl", buf.c_str()); // Emote skill buf = STRPRINTF("1 1 %s", character); atcommand_skill_learn(fd, sd, "@skill-learn", buf.c_str()); // Trade skill buf = STRPRINTF("2 1 %s", character); atcommand_skill_learn(fd, sd, "@skill-learn", buf.c_str()); // Party skill STRPRINTF("2 2 %s", character); atcommand_skill_learn(fd, sd, "@skill-learn", buf.c_str()); STRPRINTF("018-1.gat 24 98 %s", character); atcommand_charwarp(fd, sd, "@charwarp", buf.c_str()); return (0); } /*========================================== * @rura+ *------------------------------------------ */ int atcommand_charwarp(const int fd, struct map_session_data *sd, const char *, const char *message) { char map_name[100]; char character[100]; int x = 0, y = 0; struct map_session_data *pl_sd; int m; memset(map_name, '\0', sizeof(map_name)); memset(character, '\0', sizeof(character)); if (!message || !*message || sscanf(message, "%99s %d %d %99[^\n]", map_name, &x, &y, character) < 4) { clif_displaymessage(fd, "Usage: @charwarp/@rura+ "); return -1; } if (x <= 0) x = random_::in(1, 399); if (y <= 0) y = random_::in(1, 399); if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat) strcat(map_name, ".gat"); if ((pl_sd = map_nick2sd(character)) != NULL) { if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can rura+ only lower or same GM level if (x > 0 && x < 800 && y > 0 && y < 800) { m = map_mapname2mapid(map_name); if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp someone to this map."); return -1; } if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp this player from its actual map."); return -1; } if (pc_setpos(pl_sd, map_name, x, y, BeingRemoveWhy::WARPED) == 0) { clif_displaymessage(pl_sd->fd, "Warped."); clif_displaymessage(fd, "Player warped (message sends to player too)."); } else { clif_displaymessage(fd, "Map not found."); return -1; } } else { clif_displaymessage(fd, "Coordinates out of range."); return -1; } } else { clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { clif_displaymessage(fd, "Character not found."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_warp(const int fd, struct map_session_data *sd, const char *, const char *message) { char map_name[100]; int x = 0, y = 0; int m; memset(map_name, '\0', sizeof(map_name)); if (!message || !*message || sscanf(message, "%99s %d %d", map_name, &x, &y) < 1) { clif_displaymessage(fd, "Please, enter a map (usage: @warp )."); return -1; } if (x <= 0) x = random_::in(1, 399); if (y <= 0) y = random_::in(1, 399); if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat) strcat(map_name, ".gat"); if (x > 0 && x < 800 && y > 0 && y < 800) { m = map_mapname2mapid(map_name); if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you to this map."); return -1; } if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you from your actual map."); return -1; } if (pc_setpos(sd, map_name, x, y, BeingRemoveWhy::WARPED) == 0) clif_displaymessage(fd, "Warped."); else { clif_displaymessage(fd, "Map not found."); return -1; } } else { clif_displaymessage(fd, "Coordinates out of range."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_where(const int fd, struct map_session_data *sd, const char *, const char *message) { char character[100]; struct map_session_data *pl_sd; memset(character, '\0', sizeof(character)); if (sscanf(message, "%99[^\n]", character) < 1) strcpy(character, sd->status.name); if ((pl_sd = map_nick2sd(character)) != NULL && !((battle_config.hide_GM_session || bool(pl_sd->status.option & Option::HIDE)) && (pc_isGM(pl_sd) > pc_isGM(sd)))) { // you can look only lower or same level std::string output = STRPRINTF("%s: %s (%d,%d)", pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y); clif_displaymessage(fd, output); } else { clif_displaymessage(fd, "Character not found."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_goto(const int fd, struct map_session_data *sd, const char *, const char *message) { char character[100]; struct map_session_data *pl_sd; memset(character, '\0', sizeof(character)); if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) { clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto )."); return -1; } if ((pl_sd = map_nick2sd(character)) != NULL) { if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you to the map of this player."); return -1; } if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you from your actual map."); return -1; } pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, BeingRemoveWhy::WARPED); std::string output = STRPRINTF("Jump to %s", character); clif_displaymessage(fd, output); } else { clif_displaymessage(fd, "Character not found."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_jump(const int fd, struct map_session_data *sd, const char *, const char *message) { int x = 0, y = 0; sscanf(message, "%d %d", &x, &y); if (x <= 0) x = random_::in(1, 399); if (y <= 0) y = random_::in(1, 399); if (x > 0 && x < 800 && y > 0 && y < 800) { if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you to your actual map."); return -1; } if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you from your actual map."); return -1; } pc_setpos(sd, sd->mapname, x, y, BeingRemoveWhy::WARPED); std::string output = STRPRINTF("Jump to %d %d", x, y); clif_displaymessage(fd, output); } else { clif_displaymessage(fd, "Coordinates out of range."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_who(const int fd, struct map_session_data *sd, const char *, const char *message) { struct map_session_data *pl_sd; int i, j, count; int pl_GM_level, GM_level; char match_text[100]; char player_name[24]; memset(match_text, '\0', sizeof(match_text)); memset(player_name, '\0', sizeof(player_name)); if (sscanf(message, "%99[^\n]", match_text) < 1) strcpy(match_text, ""); for (j = 0; match_text[j]; j++) match_text[j] = tolower(match_text[j]); count = 0; GM_level = pc_isGM(sd); for (i = 0; i < fd_max; i++) { if (session[i] && (pl_sd = (struct map_session_data *)session[i]->session_data) && pl_sd->state.auth) { pl_GM_level = pc_isGM(pl_sd); if (! ((battle_config.hide_GM_session || bool(pl_sd->status.option & Option::HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level memcpy(player_name, pl_sd->status.name, 24); for (j = 0; player_name[j]; j++) player_name[j] = tolower(player_name[j]); if (strstr(player_name, match_text) != NULL) { // search with no case sensitive std::string output; if (pl_GM_level > 0) output = STRPRINTF( "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y); else output = STRPRINTF( "Name: %s | Location: %s %d %d", pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y); clif_displaymessage(fd, output); count++; } } } } if (count == 0) clif_displaymessage(fd, "No player found."); else if (count == 1) clif_displaymessage(fd, "1 player found."); else { std::string output = STRPRINTF("%d players found.", count); clif_displaymessage(fd, output); } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_whogroup(const int fd, struct map_session_data *sd, const char *, const char *message) { struct map_session_data *pl_sd; int i, j, count; int pl_GM_level, GM_level; char match_text[100]; char player_name[24]; struct party *p; memset(match_text, '\0', sizeof(match_text)); memset(player_name, '\0', sizeof(player_name)); if (sscanf(message, "%99[^\n]", match_text) < 1) strcpy(match_text, ""); for (j = 0; match_text[j]; j++) match_text[j] = tolower(match_text[j]); count = 0; GM_level = pc_isGM(sd); for (i = 0; i < fd_max; i++) { if (session[i] && (pl_sd = (struct map_session_data *)session[i]->session_data) && pl_sd->state.auth) { pl_GM_level = pc_isGM(pl_sd); if (! ((battle_config.hide_GM_session || bool(pl_sd->status.option & Option::HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level memcpy(player_name, pl_sd->status.name, 24); for (j = 0; player_name[j]; j++) player_name[j] = tolower(player_name[j]); if (strstr(player_name, match_text) != NULL) { // search with no case sensitive p = party_search(pl_sd->status.party_id); const char *temp0 = p ? p->name : "None"; std::string output; if (pl_GM_level > 0) output = STRPRINTF( "Name: %s (GM:%d) | Party: '%s'", pl_sd->status.name, pl_GM_level, temp0); clif_displaymessage(fd, output); count++; } } } } if (count == 0) clif_displaymessage(fd, "No player found."); else if (count == 1) clif_displaymessage(fd, "1 player found."); else { std::string output = STRPRINTF("%d players found.", count); clif_displaymessage(fd, output); } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_whomap(const int fd, struct map_session_data *sd, const char *, const char *message) { struct map_session_data *pl_sd; int i, count; int pl_GM_level, GM_level; int map_id; char map_name[100]; memset(map_name, '\0', sizeof(map_name)); if (!message || !*message) map_id = sd->bl.m; else { sscanf(message, "%99s", map_name); if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat) strcat(map_name, ".gat"); if ((map_id = map_mapname2mapid(map_name)) < 0) map_id = sd->bl.m; } count = 0; GM_level = pc_isGM(sd); for (i = 0; i < fd_max; i++) { if (session[i] && (pl_sd = (struct map_session_data *)session[i]->session_data) && pl_sd->state.auth) { pl_GM_level = pc_isGM(pl_sd); if (! ((battle_config.hide_GM_session || bool(pl_sd->status.option & Option::HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level if (pl_sd->bl.m == map_id) { std::string output; if (pl_GM_level > 0) output = STRPRINTF( "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y); else output = STRPRINTF( "Name: %s | Location: %s %d %d", pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y); clif_displaymessage(fd, output); count++; } } } } std::string output = STRPRINTF("%d players found in map '%s'.", count, map[map_id].name); clif_displaymessage(fd, output); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_whomapgroup(const int fd, struct map_session_data *sd, const char *, const char *message) { struct map_session_data *pl_sd; int i, count; int pl_GM_level, GM_level; int map_id = 0; char map_name[100]; struct party *p; memset(map_name, '\0', sizeof(map_name)); if (!message || !*message) map_id = sd->bl.m; else { sscanf(message, "%99s", map_name); if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat) strcat(map_name, ".gat"); if ((map_id = map_mapname2mapid(map_name)) < 0) map_id = sd->bl.m; } count = 0; GM_level = pc_isGM(sd); for (i = 0; i < fd_max; i++) { if (session[i] && (pl_sd = (struct map_session_data *)session[i]->session_data) && pl_sd->state.auth) { pl_GM_level = pc_isGM(pl_sd); if (! ((battle_config.hide_GM_session || bool(pl_sd->status.option & Option::HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level if (pl_sd->bl.m == map_id) { p = party_search(pl_sd->status.party_id); const char *temp0 = p ? p->name : "None"; std::string output; if (pl_GM_level > 0) output = STRPRINTF("Name: %s (GM:%d) | Party: '%s'", pl_sd->status.name, pl_GM_level, temp0); else output = STRPRINTF("Name: %s | Party: '%s'", pl_sd->status.name, temp0); clif_displaymessage(fd, output); count++; } } } } std::string output; if (count == 0) output = STRPRINTF("No player found in map '%s'.", map[map_id].name); else if (count == 1) output = STRPRINTF("1 player found in map '%s'.", map[map_id].name); else { output = STRPRINTF("%d players found in map '%s'.", count, map[map_id].name); } clif_displaymessage(fd, output); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_whogm(const int fd, struct map_session_data *sd, const char *, const char *message) { struct map_session_data *pl_sd; int i, j, count; int pl_GM_level, GM_level; char match_text[100]; char player_name[24]; struct party *p; memset(match_text, '\0', sizeof(match_text)); memset(player_name, '\0', sizeof(player_name)); if (sscanf(message, "%99[^\n]", match_text) < 1) strcpy(match_text, ""); for (j = 0; match_text[j]; j++) match_text[j] = tolower(match_text[j]); count = 0; GM_level = pc_isGM(sd); for (i = 0; i < fd_max; i++) { if (session[i] && (pl_sd = (struct map_session_data *)session[i]->session_data) && pl_sd->state.auth) { pl_GM_level = pc_isGM(pl_sd); if (pl_GM_level > 0) { if (! ((battle_config.hide_GM_session || bool(pl_sd->status.option & Option::HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level memcpy(player_name, pl_sd->status.name, 24); for (j = 0; player_name[j]; j++) player_name[j] = tolower(player_name[j]); if (strstr(player_name, match_text) != NULL) { // search with no case sensitive std::string output; output = STRPRINTF( "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y); clif_displaymessage(fd, output); output = STRPRINTF( " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, "Novice/Human", pl_sd->status.job_level); clif_displaymessage(fd, output); p = party_search(pl_sd->status.party_id); const char *temp0 = p ? p->name : "None"; output = STRPRINTF( " Party: '%s'", temp0); clif_displaymessage(fd, output); count++; } } } } } if (count == 0) clif_displaymessage(fd, "No GM found."); else if (count == 1) clif_displaymessage(fd, "1 GM found."); else { std::string output = STRPRINTF("%d GMs found.", count); clif_displaymessage(fd, output); } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_save(const int fd, struct map_session_data *sd, const char *, const char *) { nullpo_retr(-1, sd); pc_setsavepoint(sd, sd->mapname, sd->bl.x, sd->bl.y); pc_makesavestatus(sd); chrif_save(sd); clif_displaymessage(fd, "Character data respawn point saved."); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_load(const int fd, struct map_session_data *sd, const char *, const char *) { int m; m = map_mapname2mapid(sd->status.save_point.map); if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you to your save map."); return -1; } if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp you from your actual map."); return -1; } pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, BeingRemoveWhy::GONE); clif_displaymessage(fd, "Warping to respawn point."); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_speed(const int fd, struct map_session_data *sd, const char *, const char *message) { if (!message || !*message) { std::string output = STRPRINTF( "Please, enter a speed value (usage: @speed <%d-%d>).", static_cast(MIN_WALK_SPEED.count()), static_cast(MAX_WALK_SPEED.count())); clif_displaymessage(fd, output); return -1; } interval_t speed = static_cast(atoi(message)); if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) { sd->speed = speed; //sd->walktimer = x; //この文を追加 by れ clif_updatestatus(sd, SP::SPEED); clif_displaymessage(fd, "Speed changed."); } else { std::string output = STRPRINTF( "Please, enter a valid speed value (usage: @speed <%d-%d>).", static_cast(MIN_WALK_SPEED.count()), static_cast(MAX_WALK_SPEED.count())); clif_displaymessage(fd, output); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_storage(const int fd, struct map_session_data *sd, const char *, const char *) { struct storage *stor; //changes from Freya/Yor nullpo_retr(-1, sd); if (sd->state.storage_open) { clif_displaymessage(fd, "msg_table[250]"); return -1; } if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) { clif_displaymessage(fd, "msg_table[250]"); return -1; } storage_storageopen(sd); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_option(const int fd, struct map_session_data *sd, const char *, const char *message) { int param1_ = 0, param2_ = 0, param3_ = 0; nullpo_retr(-1, sd); if (!message || !*message || sscanf(message, "%d %d %d", ¶m1_, ¶m2_, ¶m3_) < 1 || param1_ < 0 || param2_ < 0 || param3_ < 0) { clif_displaymessage(fd, "Please, enter at least a option (usage: @option )."); return -1; } Opt1 param1 = Opt1(param1_); Opt2 param2 = Opt2(param2_); Option param3 = Option(param3_); sd->opt1 = param1; sd->opt2 = param2; sd->status.option = param3; clif_changeoption(&sd->bl); pc_calcstatus(sd, 0); clif_displaymessage(fd, "Options changed."); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_hide(const int fd, struct map_session_data *sd, const char *, const char *) { if (bool(sd->status.option & Option::HIDE)) { sd->status.option &= ~Option::HIDE; clif_displaymessage(fd, "Invisible: Off."); // Invisible: Off } else { sd->status.option |= Option::HIDE; clif_displaymessage(fd, "Invisible: On."); // Invisible: On } clif_changeoption(&sd->bl); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_die(const int fd, struct map_session_data *sd, const char *, const char *) { pc_damage(NULL, sd, sd->status.hp + 1); clif_displaymessage(fd, "A pity! You've died."); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_kill(const int fd, struct map_session_data *sd, const char *, const char *message) { char character[100]; struct map_session_data *pl_sd; memset(character, '\0', sizeof(character)); if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) { clif_displaymessage(fd, "Please, enter a player name (usage: @kill )."); return -1; } if ((pl_sd = map_nick2sd(character)) != NULL) { if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level pc_damage(NULL, pl_sd, pl_sd->status.hp + 1); clif_displaymessage(fd, "Character killed."); } else { clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { clif_displaymessage(fd, "Character not found."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_alive(const int fd, struct map_session_data *sd, const char *, const char *) { sd->status.hp = sd->status.max_hp; sd->status.sp = sd->status.max_sp; pc_setstand(sd); if (static_cast(battle_config.pc_invincible_time) > interval_t::zero()) pc_setinvincibletimer(sd, static_cast(battle_config.pc_invincible_time)); clif_updatestatus(sd, SP::HP); clif_updatestatus(sd, SP::SP); clif_resurrection(&sd->bl, 1); clif_displaymessage(fd, "You've been revived! It's a miracle!"); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_kami(const int fd, struct map_session_data *, const char *, const char *message) { if (!message || !*message) { clif_displaymessage(fd, "Please, enter a message (usage: @kami )."); return -1; } intif_GMmessage(message, 0); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_heal(const int fd, struct map_session_data *sd, const char *, const char *message) { int hp = 0, sp = 0; // [Valaris] thanks to fov sscanf(message, "%d %d", &hp, &sp); if (hp == 0 && sp == 0) { hp = sd->status.max_hp - sd->status.hp; sp = sd->status.max_sp - sd->status.sp; } else { if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow hp = sd->status.max_hp - sd->status.hp; else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow hp = 1 - sd->status.hp; if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow sp = sd->status.max_sp - sd->status.sp; else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow sp = 1 - sd->status.sp; } if (hp < 0) // display like damage clif_damage(&sd->bl, &sd->bl, gettick(), interval_t::zero(), interval_t::zero(), -hp, 0, DamageType::RETURNED, 0); if (hp != 0 || sp != 0) { pc_heal(sd, hp, sp); if (hp >= 0 && sp >= 0) clif_displaymessage(fd, "HP, SP recovered."); else clif_displaymessage(fd, "HP or/and SP modified."); } else { clif_displaymessage(fd, "HP and SP are already with the good value."); return -1; } return 0; } /*========================================== * @item command (usage: @item ) *------------------------------------------ */ int atcommand_item(const int fd, struct map_session_data *sd, const char *, const char *message) { char item_name[100]; int number = 0, item_id; struct item item_tmp; struct item_data *item_data; int get_count, i; memset(item_name, '\0', sizeof(item_name)); if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) { clif_displaymessage(fd, "Please, enter an item name/id (usage: @item [quantity])."); return -1; } if (number <= 0) number = 1; item_id = 0; if ((item_data = itemdb_searchname(item_name)) != NULL || (item_data = itemdb_exists(atoi(item_name))) != NULL) item_id = item_data->nameid; if (item_id >= 500) { get_count = number; if (item_data->type == ItemType::WEAPON || item_data->type == ItemType::ARMOR || item_data->type == ItemType::_7 || item_data->type == ItemType::_8) { get_count = 1; } for (i = 0; i < number; i += get_count) { memset(&item_tmp, 0, sizeof(item_tmp)); item_tmp.nameid = item_id; item_tmp.identify = 1; PickupFail flag; if ((flag = pc_additem(sd, &item_tmp, get_count)) != PickupFail::OKAY) clif_additem(sd, 0, 0, flag); } clif_displaymessage(fd, "Item created."); } else { clif_displaymessage(fd, "Invalid item ID or name."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_itemreset(const int fd, struct map_session_data *sd, const char *, const char *) { int i; for (i = 0; i < MAX_INVENTORY; i++) { if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == EPOS::ZERO) pc_delitem(sd, i, sd->status.inventory[i].amount, 0); } clif_displaymessage(fd, "All of your items have been removed."); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_itemcheck(const int, struct map_session_data *sd, const char *, const char *) { pc_checkitem(sd); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_baselevelup(const int fd, struct map_session_data *sd, const char *, const char *message) { int level, i; if (!message || !*message || (level = atoi(message)) == 0) { clif_displaymessage(fd, "Please, enter a level adjustement (usage: @blvl )."); return -1; } if (level > 0) { if (sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris clif_displaymessage(fd, "Base level can't go any higher."); return -1; } // End Addition if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow level = battle_config.maximum_level - sd->status.base_level; for (i = 1; i <= level; i++) sd->status.status_point += (sd->status.base_level + i + 14) / 4; sd->status.base_level += level; clif_updatestatus(sd, SP::BASELEVEL); clif_updatestatus(sd, SP::NEXTBASEEXP); clif_updatestatus(sd, SP::STATUSPOINT); pc_calcstatus(sd, 0); pc_heal(sd, sd->status.max_hp, sd->status.max_sp); clif_misceffect(&sd->bl, 0); clif_displaymessage(fd, "Base level raised."); } else { if (sd->status.base_level == 1) { clif_displaymessage(fd, "Base level can't go any lower."); return -1; } if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level)) // fix negativ overflow level = 1 - sd->status.base_level; if (sd->status.status_point > 0) { for (i = 0; i > level; i--) sd->status.status_point -= (sd->status.base_level + i + 14) / 4; if (sd->status.status_point < 0) sd->status.status_point = 0; clif_updatestatus(sd, SP::STATUSPOINT); } // to add: remove status points from stats sd->status.base_level += level; clif_updatestatus(sd, SP::BASELEVEL); clif_updatestatus(sd, SP::NEXTBASEEXP); pc_calcstatus(sd, 0); clif_displaymessage(fd, "Base level lowered."); } return 0; } /*========================================== * *------------------------------------------ */ // TODO: merge this with pc_setparam(SP::JOBLEVEL) // then fix the funny 50 and/or 10 limitation. int atcommand_joblevelup(const int fd, struct map_session_data *sd, const char *, const char *message) { int up_level = 50, level; if (!message || !*message || (level = atoi(message)) == 0) { clif_displaymessage(fd, "Please, enter a level adjustement (usage: @jlvl )."); return -1; } up_level -= 40; if (level > 0) { if (sd->status.job_level == up_level) { clif_displaymessage(fd, "Job level can't go any higher."); return -1; } if (level > up_level || level > (up_level - sd->status.job_level)) // fix positiv overflow level = up_level - sd->status.job_level; sd->status.job_level += level; clif_updatestatus(sd, SP::JOBLEVEL); clif_updatestatus(sd, SP::NEXTJOBEXP); sd->status.skill_point += level; clif_updatestatus(sd, SP::SKILLPOINT); pc_calcstatus(sd, 0); clif_misceffect(&sd->bl, 1); clif_displaymessage(fd, "Job level raised."); } else { if (sd->status.job_level == 1) { clif_displaymessage(fd, "Job level can't go any lower."); return -1; } if (level < -up_level || level < (1 - sd->status.job_level)) // fix negativ overflow level = 1 - sd->status.job_level; sd->status.job_level += level; clif_updatestatus(sd, SP::JOBLEVEL); clif_updatestatus(sd, SP::NEXTJOBEXP); if (sd->status.skill_point > 0) { sd->status.skill_point += level; if (sd->status.skill_point < 0) sd->status.skill_point = 0; clif_updatestatus(sd, SP::SKILLPOINT); } // to add: remove status points from skills pc_calcstatus(sd, 0); clif_displaymessage(fd, "Job level lowered."); } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_help(const int fd, struct map_session_data *sd, const char *, const char *) { char buf[2048], w1[2048], w2[2048]; int i, gm_level; FILE *fp; memset(buf, '\0', sizeof(buf)); if ((fp = fopen_(help_txt, "r")) != NULL) { clif_displaymessage(fd, "Help commands:"); gm_level = pc_isGM(sd); while (fgets(buf, sizeof(buf) - 1, fp) != NULL) { if (buf[0] == '/' && buf[1] == '/') continue; for (i = 0; buf[i] != '\0'; i++) { if (buf[i] == '\r' || buf[i] == '\n') { buf[i] = '\0'; break; } } if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2) clif_displaymessage(fd, buf); else if (gm_level >= atoi(w1)) clif_displaymessage(fd, w2); } fclose_(fp); } else { clif_displaymessage(fd, "File help.txt not found."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_gm(const int fd, struct map_session_data *sd, const char *, const char *message) { char password[100]; memset(password, '\0', sizeof(password)); if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) { clif_displaymessage(fd, "Please, enter a password (usage: @gm )."); return -1; } if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!) clif_displaymessage(fd, "You already have some GM powers."); return -1; } else chrif_changegm(sd->status.account_id, password, strlen(password) + 1); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_pvpoff(const int fd, struct map_session_data *sd, const char *, const char *) { struct map_session_data *pl_sd; int i; if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris] clif_displaymessage(fd, "This option cannot be used in PK Mode."); return -1; } if (map[sd->bl.m].flag.pvp) { map[sd->bl.m].flag.pvp = 0; for (i = 0; i < fd_max; i++) { //人数分ループ if (session[i] && (pl_sd = (struct map_session_data *)session[i]->session_data) && pl_sd->state.auth) { if (sd->bl.m == pl_sd->bl.m) { if (pl_sd->pvp_timer) { delete_timer(pl_sd->pvp_timer); pl_sd->pvp_timer = nullptr; } } } } clif_displaymessage(fd, "PvP: Off."); } else { clif_displaymessage(fd, "PvP is already Off."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_pvpon(const int fd, struct map_session_data *sd, const char *, const char *) { struct map_session_data *pl_sd; int i; if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris] clif_displaymessage(fd, "This option cannot be used in PK Mode."); return -1; } if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) { map[sd->bl.m].flag.pvp = 1; for (i = 0; i < fd_max; i++) { if (session[i] && (pl_sd = (struct map_session_data *)session[i]->session_data) && pl_sd->state.auth) { if (sd->bl.m == pl_sd->bl.m && !pl_sd->pvp_timer) { pl_sd->pvp_timer = add_timer(gettick() + std::chrono::milliseconds(200), std::bind(pc_calc_pvprank_timer, ph::_1, ph::_2, pl_sd->bl.id)); pl_sd->pvp_rank = 0; pl_sd->pvp_lastusers = 0; pl_sd->pvp_point = 5; } } } clif_displaymessage(fd, "PvP: On."); } else { clif_displaymessage(fd, "PvP is already On."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_model(const int fd, struct map_session_data *sd, const char *, const char *message) { int hair_style = 0, hair_color = 0, cloth_color = 0; if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) { std::string output = STRPRINTF( "Please, enter at least a value (usage: @model ).", MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); clif_displaymessage(fd, 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, "Appearence changed."); } } else { clif_displaymessage(fd, "An invalid number was specified."); return -1; } return 0; } /*========================================== * @dye && @ccolor *------------------------------------------ */ int atcommand_dye(const int fd, struct map_session_data *sd, const char *, const char *message) { int cloth_color = 0; if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) { std::string output = STRPRINTF( "Please, enter a clothes color (usage: @dye/@ccolor ).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); clif_displaymessage(fd, 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, "Appearence changed."); } } else { clif_displaymessage(fd, "An invalid number was specified."); return -1; } return 0; } /*========================================== * @hairstyle && @hstyle *------------------------------------------ */ int atcommand_hair_style(const int fd, struct map_session_data *sd, const char *, const char *message) { int hair_style = 0; if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) { std::string output = STRPRINTF( "Please, enter a hair style (usage: @hairstyle/@hstyle ).", MIN_HAIR_STYLE, MAX_HAIR_STYLE); clif_displaymessage(fd, output); return -1; } if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) { { pc_changelook(sd, LOOK::HAIR, hair_style); clif_displaymessage(fd, "Appearence changed."); } } else { clif_displaymessage(fd, "An invalid number was specified."); return -1; } return 0; } /*========================================== * @haircolor && @hcolor *------------------------------------------ */ int atcommand_hair_color(const int fd, struct map_session_data *sd, const char *, const char *message) { int hair_color = 0; if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) { std::string output = STRPRINTF( "Please, enter a hair color (usage: @haircolor/@hcolor ).", MIN_HAIR_COLOR, MAX_HAIR_COLOR); clif_displaymessage(fd, 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, "Appearence changed."); } } else { clif_displaymessage(fd, "An invalid number was specified."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_spawn(const int fd, struct map_session_data *sd, const char *command, const char *message) { char monster[100]; int mob_id; int number = 0; int x = 0, y = 0; int count; int i, j, k; int mx, my, range; memset(monster, '\0', sizeof(monster)); if (!message || !*message || sscanf(message, "%99s %d %d %d", monster, &number, &x, &y) < 1) { clif_displaymessage(fd, "Give a monster name/id please."); return -1; } // If monster identifier/name argument is a name 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, "Invalid monster ID or name."); return -1; } if (mob_id == 1288) { clif_displaymessage(fd, "Cannot spawn emperium."); return -1; } if (number <= 0) number = 1; // 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 >= 1 && number > battle_config.atc_spawn_quantity_limit) number = battle_config.atc_spawn_quantity_limit; if (battle_config.etc_log) PRINTF("%s monster='%s' id=%d count=%d (%d,%d)\n", command, monster, mob_id, number, x, y); count = 0; range = sqrt(number) / 2; range = range * 2 + 5; // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { j = 0; k = 0; while (j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area) if (x <= 0) mx = sd->bl.x + random_::in(-range / 2, range / 2 ); else mx = x; if (y <= 0) my = sd->bl.y + random_::in(-range / 2, range / 2); else my = y; k = mob_once_spawn(sd, "this", mx, my, "", mob_id, 1, ""); } count += (k != 0) ? 1 : 0; } if (count != 0) if (number == count) clif_displaymessage(fd, "All monster summoned!"); else { std::string output = STRPRINTF("%d monster(s) summoned!", count); clif_displaymessage(fd, output); } else { clif_displaymessage(fd, "Invalid monster ID or name."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ static void atcommand_killmonster_sub(const int fd, struct map_session_data *sd, const char *message, const int drop) { int map_id; char map_name[100]; memset(map_name, '\0', sizeof(map_name)); if (!message || !*message || sscanf(message, "%99s", map_name) < 1) map_id = sd->bl.m; else { if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat) strcat(map_name, ".gat"); if ((map_id = map_mapname2mapid(map_name)) < 0) map_id = sd->bl.m; } map_foreachinarea(std::bind(atkillmonster_sub, ph::_1, drop), map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL::MOB); clif_displaymessage(fd, "All monsters killed!"); return; } /*========================================== * *------------------------------------------ */ int atcommand_killmonster(const int fd, struct map_session_data *sd, const char *, const char *message) { atcommand_killmonster_sub(fd, sd, message, 1); return 0; } /*========================================== * *------------------------------------------ */ static void atlist_nearby_sub(struct block_list *bl, int fd) { nullpo_retv(bl); std::string buf = STRPRINTF(" - \"%s\"", ((struct map_session_data *) bl)->status.name); clif_displaymessage(fd, buf); } /*========================================== * *------------------------------------------ */ int atcommand_list_nearby(const int fd, struct map_session_data *sd, const char *, const char *) { clif_displaymessage(fd, "Nearby players:"); map_foreachinarea(std::bind(atlist_nearby_sub, ph::_1, fd), sd->bl.m, sd->bl.x - 1, sd->bl.y - 1, sd->bl.x + 1, sd->bl.x + 1, BL::PC); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_killmonster2(const int fd, struct map_session_data *sd, const char *, const char *message) { atcommand_killmonster_sub(fd, sd, message, 0); return 0; } /*========================================== * *------------------------------------------ */ int atcommand_gat(const int fd, struct map_session_data *sd, const char *, const char *) { int y; for (y = 2; y >= -2; y--) { std::string output = STRPRINTF( "%s (x= %d, y= %d) %02X %02X %02X %02X %02X", map[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), map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y), map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y), map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y), map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y)); clif_displaymessage(fd, output); } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_packet(const int fd, struct map_session_data *sd, const char *, const char *message) { int type = 0, flag = 0; if (!message || !*message || sscanf(message, "%d %d", &type, &flag) < 2) { clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet )."); return -1; } clif_status_change(&sd->bl, StatusChange(type), flag); return 0; } /*========================================== * @stpoint (Rewritten by [Yor]) *------------------------------------------ */ int atcommand_statuspoint(const int fd, struct map_session_data *sd, const char *, const char *message) { int point, new_status_point; if (!message || !*message || (point = atoi(message)) == 0) { clif_displaymessage(fd, "Please, enter a number (usage: @stpoint )."); return -1; } new_status_point = (int) sd->status.status_point + point; if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow new_status_point = 0x7FFF; else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow new_status_point = 0; if (new_status_point != (int) sd->status.status_point) { sd->status.status_point = (short) new_status_point; clif_updatestatus(sd, SP::STATUSPOINT); clif_displaymessage(fd, "Number of status points changed!"); } else { if (point < 0) clif_displaymessage(fd, "Impossible to decrease the number/value."); else clif_displaymessage(fd, "Impossible to increase the number/value."); return -1; } return 0; } /*========================================== * @skpoint (Rewritten by [Yor]) *------------------------------------------ */ int atcommand_skillpoint(const int fd, struct map_session_data *sd, const char *, const char *message) { int point, new_skill_point; if (!message || !*message || (point = atoi(message)) == 0) { clif_displaymessage(fd, "Please, enter a number (usage: @skpoint )."); return -1; } new_skill_point = (int) sd->status.skill_point + point; if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow new_skill_point = 0x7FFF; else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow new_skill_point = 0; if (new_skill_point != (int) sd->status.skill_point) { sd->status.skill_point = (short) new_skill_point; clif_updatestatus(sd, SP::SKILLPOINT); clif_displaymessage(fd, "Number of skill points changed!"); } else { if (point < 0) clif_displaymessage(fd, "Impossible to decrease the number/value."); else clif_displaymessage(fd, "Impossible to increase the number/value."); return -1; } return 0; } /*========================================== * @zeny (Rewritten by [Yor]) *------------------------------------------ */ int atcommand_zeny(const int fd, struct map_session_data *sd, const char *, const char *message) { int zeny, new_zeny; if (!message || !*message || (zeny = atoi(message)) == 0) { clif_displaymessage(fd, "Please, enter an amount (usage: @zeny )."); return -1; } new_zeny = sd->status.zeny + zeny; if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow new_zeny = MAX_ZENY; else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow new_zeny = 0; if (new_zeny != sd->status.zeny) { sd->status.zeny = new_zeny; clif_updatestatus(sd, SP::ZENY); clif_displaymessage(fd, "Number of zenys changed!"); } else { if (zeny < 0) clif_displaymessage(fd, "Impossible to decrease the number/value."); else clif_displaymessage(fd, "Impossible to increase the number/value."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ template int atcommand_param(const int fd, struct map_session_data *sd, const char *, const char *message) { int value = 0, new_value; if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) { // there was a clang bug here // fortunately, STRPRINTF was not actually needed clif_displaymessage(fd, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>)."); return -1; } new_value = (int) sd->status.attrs[attr] + value; if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow new_value = battle_config.max_parameter; else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow new_value = 1; if (new_value != sd->status.attrs[attr]) { sd->status.attrs[attr] = new_value; clif_updatestatus(sd, attr_to_sp(attr)); clif_updatestatus(sd, attr_to_usp(attr)); pc_calcstatus(sd, 0); clif_displaymessage(fd, "Stat changed."); } else { if (value < 0) clif_displaymessage(fd, "Impossible to decrease the number/value."); else clif_displaymessage(fd, "Impossible to increase the number/value."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ //** Stat all by fritz (rewritten by [Yor]) int atcommand_all_stats(const int fd, struct map_session_data *sd, const char *, const char *message) { int count, value = 0, new_value; if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) value = battle_config.max_parameter; count = 0; for (ATTR attr : ATTRs) { new_value = sd->status.attrs[attr] + value; if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow new_value = battle_config.max_parameter; else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow new_value = 1; if (new_value != sd->status.attrs[attr]) { sd->status.attrs[attr] = new_value; clif_updatestatus(sd, attr_to_sp(attr)); clif_updatestatus(sd, attr_to_usp(attr)); pc_calcstatus(sd, 0); count++; } } if (count > 0) // if at least 1 stat modified clif_displaymessage(fd, "All stats changed!"); else { if (value < 0) clif_displaymessage(fd, "Impossible to decrease a stat."); else clif_displaymessage(fd, "Impossible to increase a stat."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_recall(const int fd, struct map_session_data *sd, const char *, const char *message) { char character[100]; struct map_session_data *pl_sd; memset(character, '\0', sizeof(character)); if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) { clif_displaymessage(fd, "Please, enter a player name (usage: @recall )."); return -1; } if ((pl_sd = map_nick2sd(character)) != NULL) { if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map."); return -1; } if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, "You are not authorised to warp this player from its actual map."); return -1; } pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, BeingRemoveWhy::QUIT); std::string output = STRPRINTF("%s recalled!", character); clif_displaymessage(fd, output); } else { clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { clif_displaymessage(fd, "Character not found."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_revive(const int fd, struct map_session_data *sd, const char *, const char *message) { char character[100]; struct map_session_data *pl_sd; memset(character, '\0', sizeof(character)); if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) { clif_displaymessage(fd, "Please, enter a player name (usage: @revive )."); return -1; } if ((pl_sd = map_nick2sd(character)) != NULL) { pl_sd->status.hp = pl_sd->status.max_hp; pc_setstand(pl_sd); if (static_cast(battle_config.pc_invincible_time) > interval_t::zero()) pc_setinvincibletimer(sd, static_cast(battle_config.pc_invincible_time)); clif_updatestatus(pl_sd, SP::HP); clif_updatestatus(pl_sd, SP::SP); clif_resurrection(&pl_sd->bl, 1); clif_displaymessage(fd, "Character revived."); } else { clif_displaymessage(fd, "Character not found."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_character_stats(const int fd, struct map_session_data *, const char *, const char *message) { char character[100]; struct map_session_data *pl_sd; memset(character, '\0', sizeof(character)); if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) { clif_displaymessage(fd, "Please, enter a player name (usage: @charstats )."); return -1; } if ((pl_sd = map_nick2sd(character)) != NULL) { std::string output; output = STRPRINTF("'%s' stats:", pl_sd->status.name); clif_displaymessage(fd, output); output = STRPRINTF("Base Level - %d", pl_sd->status.base_level), clif_displaymessage(fd, output); output = STRPRINTF("Job - Novice/Human (level %d)", pl_sd->status.job_level); clif_displaymessage(fd, output); output = STRPRINTF("Hp - %d", pl_sd->status.hp); clif_displaymessage(fd, output); output = STRPRINTF("MaxHp - %d", pl_sd->status.max_hp); clif_displaymessage(fd, output); output = STRPRINTF("Sp - %d", pl_sd->status.sp); clif_displaymessage(fd, output); output = STRPRINTF("MaxSp - %d", pl_sd->status.max_sp); clif_displaymessage(fd, output); output = STRPRINTF("Str - %3d", pl_sd->status.attrs[ATTR::STR]); clif_displaymessage(fd, output); output = STRPRINTF("Agi - %3d", pl_sd->status.attrs[ATTR::AGI]); clif_displaymessage(fd, output); output = STRPRINTF("Vit - %3d", pl_sd->status.attrs[ATTR::VIT]); clif_displaymessage(fd, output); output = STRPRINTF("Int - %3d", pl_sd->status.attrs[ATTR::INT]); clif_displaymessage(fd, output); output = STRPRINTF("Dex - %3d", pl_sd->status.attrs[ATTR::DEX]); clif_displaymessage(fd, output); output = STRPRINTF("Luk - %3d", pl_sd->status.attrs[ATTR::LUK]); clif_displaymessage(fd, output); output = STRPRINTF("Zeny - %d", pl_sd->status.zeny); clif_displaymessage(fd, output); } else { clif_displaymessage(fd, "Character not found."); return -1; } return 0; } /*========================================== * *------------------------------------------ */ //** Character Stats All by fritz int atcommand_character_stats_all(const int fd, struct map_session_data *, const char *, const char *) { int i; int count; struct map_session_data *pl_sd; count = 0; for (i = 0; i < fd_max; i++) { if (session[i] && (pl_sd = (struct map_session_data *)session[i]->session_data) && pl_sd->state.auth) { std::string gmlevel; if (pc_isGM(pl_sd) > 0) gmlevel = STRPRINTF("| GM Lvl: %d", pc_isGM(pl_sd)); else gmlevel = " "; std::string output; output = STRPRINTF( "Name: %s | BLvl: %d | Job: Novice/Human (Lvl: %d) | HP: %d/%d | SP: %d/%d", pl_sd->status.name, pl_sd->status.base_level, pl_sd->status.job_level, pl_sd->status.hp, pl_sd->status.max_hp, pl_sd->status.sp, pl_sd->status.max_sp); clif_displaymessage(fd, output); output = STRPRINTF("STR: %d | AGI: %d | VIT: %d | INT: %d | DEX: %d | LUK: %d | Zeny: %d %s", pl_sd->status.attrs[ATTR::STR], pl_sd->status.attrs[ATTR::AGI], pl_sd->status.attrs[ATTR::VIT], pl_sd->status.attrs[ATTR::INT], pl_sd->status.attrs[ATTR::DEX], pl_sd->status.attrs[ATTR::LUK], pl_sd->status.zeny, gmlevel); clif_displaymessage(fd, output); clif_displaymessage(fd, "--------"); count++; } } if (count == 0) clif_displaymessage(fd, "No player found."); else if (count == 1) clif_displaymessage(fd, "1 player found."); else { std::string output = STRPRINTF("%d players found.", count); clif_displaymessage(fd, output); } return 0; } /*========================================== * *------------------------------------------ */ int atcommand_character_option(const int fd, struct map_session_data *sd, const char *, const char *message) { char character[100]; int opt1_ = 0, opt2_ = 0, opt3_ = 0; struct map_session_data *pl_sd; memset(character, '\0', sizeof(character)); if (!message || !*message || sscanf(message, "%d %d %d %99[^\n]", &opt1_, &opt2_, &opt3_, character) < 4 || opt1_ < 0 || opt2_ < 0 || opt3_ < 0) { clif_displaymessage(fd, "Please, enter valid options and a player name (usage: @charoption )."); return -1; } Opt1 opt1 = Opt1(opt1_); Opt2 opt2 = Opt2(opt2_); Option opt3 = Option(opt3_); if ((pl_sd = map_nick2sd(character)) != NULL) { if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change option only to lower or same level pl_sd->opt1 = opt1; pl_sd->opt2 = opt2; pl_sd->status.option = opt3; clif_changeoption(&pl_sd->bl); pc_calcstatus(pl_sd, 0); clif_displaymessage(fd, "Character's options changed."); } else { clif_displaymessage(fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { clif_displaymessage(fd, "Character not found."); return -1; } return 0; } /*========================================== * charchangesex command (usage: charchangesex ) *------------------------------------------ */ int atcommand_char_change_sex(const int fd, struct map_session_data *sd, const char *, const char *message) { char character[100]; memset(character, '\0', sizeof(character)); if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) { clif_displaymessage(fd, "Please, enter a player name (usage: @charchangesex )."); return -1; } // check player name if (strlen(character) < 4) { clif_displaymessage(fd, "Sorry, but a player name have at least 4 characters."); return -1; } else if (strlen(character) > 23) { clif_displaymessage(fd, "Sorry, but a player name have 23 characters maximum."); return -1; } else { chrif_char_ask_name(sd->status.account_id, character, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex clif_displaymessage(fd, "Character name sends to char-server to ask it."); } return 0; } /*========================================== * charblock command (usage: charblock ) * This command do a definitiv ban on a player *------------------------------------------ */ int atcommand_char_block(const int fd, struct map_session_data *sd, const char *, const char *message) { char character[100]; memset(character, '\0', sizeof(character)); if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) { clif_displaymessage(fd, "Please, enter a player name (usage: @block )."); return -1; } // check player name if (strlen(character) < 4) { clif_displaymessage(fd, "Sorry, but a player name have at least 4 characters."); return -1; } else if (strlen(character) > 23) { clif_displaymessage(fd, "Sorry, but a player name have 23 characters maximum."); return -1; } else { chrif_char_ask_name(sd->status.account_id, character, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block clif_displaymessage(fd, "Character name sends to char-server to ask it."); } return 0; } /*========================================== * charban command (usage: charban