PageRenderTime 59ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 2ms

/src/map/atcommand.c

https://gitlab.com/evol/hercules
C | 10340 lines | 8018 code | 1401 blank | 921 comment | 2647 complexity | 60a1d92ffe0296710d30b4bd5c365bc9 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.0
  1. /**
  2. * This file is part of Hercules.
  3. * http://herc.ws - http://github.com/HerculesWS/Hercules
  4. *
  5. * Copyright (C) 2012-2016 Hercules Dev Team
  6. * Copyright (C) Athena Dev Teams
  7. *
  8. * Hercules is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #define HERCULES_CORE
  22. #include "config/core.h" // AUTOLOOTITEM_SIZE, AUTOTRADE_PERSISTENCY, MAX_SUGGESTIONS, MOB_FLEE(), MOB_HIT(), RENEWAL, RENEWAL_DROP, RENEWAL_EXP
  23. #include "atcommand.h"
  24. #include "map/HPMmap.h"
  25. #include "map/battle.h"
  26. #include "map/channel.h"
  27. #include "map/chat.h"
  28. #include "map/chrif.h"
  29. #include "map/clif.h"
  30. #include "map/duel.h"
  31. #include "map/elemental.h"
  32. #include "map/guild.h"
  33. #include "map/homunculus.h"
  34. #include "map/intif.h"
  35. #include "map/itemdb.h"
  36. #include "map/log.h"
  37. #include "map/mail.h"
  38. #include "map/map.h"
  39. #include "map/mapreg.h"
  40. #include "map/mercenary.h"
  41. #include "map/mob.h"
  42. #include "map/npc.h"
  43. #include "map/party.h"
  44. #include "map/pc.h"
  45. #include "map/pc_groups.h" // groupid2name
  46. #include "map/pet.h"
  47. #include "map/quest.h"
  48. #include "map/script.h"
  49. #include "map/searchstore.h"
  50. #include "map/skill.h"
  51. #include "map/status.h"
  52. #include "map/storage.h"
  53. #include "map/trade.h"
  54. #include "map/unit.h"
  55. #include "common/cbasetypes.h"
  56. #include "common/conf.h"
  57. #include "common/core.h"
  58. #include "common/memmgr.h"
  59. #include "common/mmo.h" // MAX_CARTS
  60. #include "common/nullpo.h"
  61. #include "common/random.h"
  62. #include "common/showmsg.h"
  63. #include "common/socket.h"
  64. #include "common/strlib.h"
  65. #include "common/sysinfo.h"
  66. #include "common/timer.h"
  67. #include "common/utils.h"
  68. #include <math.h>
  69. #include <stdio.h>
  70. #include <stdlib.h>
  71. #include <string.h>
  72. struct atcommand_interface atcommand_s;
  73. struct atcommand_interface *atcommand;
  74. static char atcmd_output[CHAT_SIZE_MAX];
  75. static char atcmd_player_name[NAME_LENGTH];
  76. // @commands (script-based)
  77. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  78. int i = 0;
  79. nullpo_retr(NULL, name);
  80. if( *name == atcommand->at_symbol || *name == atcommand->char_symbol )
  81. name++; // for backwards compatibility
  82. ARR_FIND( 0, atcommand->binding_count, i, strcmpi(atcommand->binding[i]->command, name) == 0 );
  83. return ( i < atcommand->binding_count ) ? atcommand->binding[i] : NULL;
  84. }
  85. const char* atcommand_msgsd(struct map_session_data *sd, int msg_number) {
  86. Assert_retr("??", msg_number >= 0 && msg_number < MAX_MSG && atcommand->msg_table[0][msg_number] != NULL);
  87. if (!sd || sd->lang_id >= atcommand->max_message_table || !atcommand->msg_table[sd->lang_id][msg_number])
  88. return atcommand->msg_table[0][msg_number];
  89. return atcommand->msg_table[sd->lang_id][msg_number];
  90. }
  91. const char* atcommand_msgfd(int fd, int msg_number) {
  92. struct map_session_data *sd = sockt->session_is_valid(fd) ? sockt->session[fd]->session_data : NULL;
  93. Assert_retr("??", msg_number >= 0 && msg_number < MAX_MSG && atcommand->msg_table[0][msg_number] != NULL);
  94. if (!sd || sd->lang_id >= atcommand->max_message_table || !atcommand->msg_table[sd->lang_id][msg_number])
  95. return atcommand->msg_table[0][msg_number];
  96. return atcommand->msg_table[sd->lang_id][msg_number];
  97. }
  98. //-----------------------------------------------------------
  99. // Return the message string of the specified number by [Yor]
  100. //-----------------------------------------------------------
  101. const char* atcommand_msg(int msg_number) {
  102. Assert_retr("??", msg_number >= 0 && msg_number < MAX_MSG);
  103. if (atcommand->msg_table[map->default_lang_id][msg_number] != NULL && atcommand->msg_table[map->default_lang_id][msg_number][0] != '\0')
  104. return atcommand->msg_table[map->default_lang_id][msg_number];
  105. if(atcommand->msg_table[0][msg_number] != NULL && atcommand->msg_table[0][msg_number][0] != '\0')
  106. return atcommand->msg_table[0][msg_number];
  107. return "??";
  108. }
  109. /**
  110. * Reads Message Data
  111. *
  112. * @param[in] cfg_name configuration filename to read.
  113. * @param[in] allow_override whether to allow duplicate message IDs to override the original value.
  114. * @return success state.
  115. */
  116. bool msg_config_read(const char *cfg_name, bool allow_override) {
  117. int msg_number;
  118. char line[1024], w1[1024], w2[1024];
  119. FILE *fp;
  120. static int called = 1;
  121. nullpo_retr(false, cfg_name);
  122. if ((fp = fopen(cfg_name, "r")) == NULL) {
  123. ShowError("Messages file not found: %s\n", cfg_name);
  124. return false;
  125. }
  126. if( !atcommand->max_message_table )
  127. atcommand->expand_message_table();
  128. while(fgets(line, sizeof(line), fp)) {
  129. if (line[0] == '/' && line[1] == '/')
  130. continue;
  131. if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) != 2)
  132. continue;
  133. if (strcmpi(w1, "import") == 0) {
  134. atcommand->msg_read(w2, true);
  135. } else {
  136. msg_number = atoi(w1);
  137. if (msg_number >= 0 && msg_number < MAX_MSG) {
  138. if (atcommand->msg_table[0][msg_number] != NULL) {
  139. if (!allow_override) {
  140. ShowError("Duplicate message: ID '%d' was already used for '%s'. Message '%s' will be ignored.\n",
  141. msg_number, w2, atcommand->msg_table[0][msg_number]);
  142. continue;
  143. }
  144. aFree(atcommand->msg_table[0][msg_number]);
  145. }
  146. /* this could easily become consecutive memory like get_str() and save the malloc overhead for over 1k calls [Ind] */
  147. atcommand->msg_table[0][msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  148. strcpy(atcommand->msg_table[0][msg_number],w2);
  149. }
  150. }
  151. }
  152. fclose(fp);
  153. if( ++called == 1 ) { //Original
  154. if( script->lang_export_fp ) {
  155. int i;
  156. for(i = 0; i < MAX_MSG;i++) {
  157. if( atcommand->msg_table[0][i] != NULL ) {
  158. fprintf(script->lang_export_fp, "msgctxt \"messages.conf\"\n"
  159. "msgid \"%s\"\n"
  160. "msgstr \"\"\n",
  161. atcommand->msg_table[0][i]
  162. );
  163. }
  164. }
  165. }
  166. }
  167. return true;
  168. }
  169. /*==========================================
  170. * Cleanup Message Data
  171. *------------------------------------------*/
  172. void do_final_msg(void) {
  173. int i, j;
  174. for(i = 0; i < atcommand->max_message_table; i++) {
  175. for (j = 0; j < MAX_MSG; j++) {
  176. if( atcommand->msg_table[i][j] )
  177. aFree(atcommand->msg_table[i][j]);
  178. }
  179. aFree(atcommand->msg_table[i]);
  180. }
  181. if( atcommand->msg_table )
  182. aFree(atcommand->msg_table);
  183. }
  184. /**
  185. * retrieves the help string associated with a given command.
  186. */
  187. static inline const char* atcommand_help_string(AtCommandInfo *info) {
  188. return info->help;
  189. }
  190. /*==========================================
  191. * @send (used for testing packet sends from the client)
  192. *------------------------------------------*/
  193. ACMD(send)
  194. {
  195. int len=0,type;
  196. long num;
  197. // read message type as hex number (without the 0x)
  198. if (!*message
  199. || !((sscanf(message, "len %x", &type)==1 && (len=1, true))
  200. || sscanf(message, "%x", &type)==1)
  201. ) {
  202. clif->message(fd, msg_fd(fd,900)); // Usage:
  203. clif->message(fd, msg_fd(fd,901)); // @send len <packet hex number>
  204. clif->message(fd, msg_fd(fd,902)); // @send <packet hex number> {<value>}*
  205. clif->message(fd, msg_fd(fd,903)); // Value: <type=B(default),W,L><number> or S<length>"<string>"
  206. return false;
  207. }
  208. #define PARSE_ERROR(error,p) do {\
  209. clif->message(fd, (error));\
  210. safesnprintf(atcmd_output, sizeof(atcmd_output), ">%s", (p));\
  211. clif->message(fd, atcmd_output);\
  212. } while(0) //define PARSE_ERROR
  213. #define CHECK_EOS(p) do { \
  214. if(*(p) == 0){ \
  215. clif->message(fd, "Unexpected end of string");\
  216. return false;\
  217. } \
  218. } while(0) //define CHECK_EOS
  219. #define SKIP_VALUE(p) do { \
  220. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  221. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  222. } while(0) //define SKIP_VALUE
  223. #define GET_VALUE(p,num) do { \
  224. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  225. PARSE_ERROR("Invalid number in:",(p));\
  226. return false;\
  227. }\
  228. } while(0) //define GET_VALUE
  229. if (type >= MIN_PACKET_DB && type <= MAX_PACKET_DB) {
  230. int off = 2;
  231. if (len) {
  232. // show packet length
  233. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, clif->packet(type)->len); // Packet 0x%x length: %d
  234. clif->message(fd, atcmd_output);
  235. return true;
  236. }
  237. len = clif->packet(type)->len;
  238. if (len == 0) {
  239. // unknown packet - ERROR
  240. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,905), type); // Unknown packet: 0x%x
  241. clif->message(fd, atcmd_output);
  242. return false;
  243. } else if (len == -1) {
  244. // dynamic packet
  245. len = SHRT_MAX-4; // maximum length
  246. off = 4;
  247. }
  248. WFIFOHEAD(sd->fd, len);
  249. WFIFOW(sd->fd,0)=TOW(type);
  250. // parse packet contents
  251. SKIP_VALUE(message);
  252. while(*message != 0 && off < len){
  253. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  254. {// default (byte)
  255. GET_VALUE(message,num);
  256. WFIFOB(sd->fd,off)=TOB(num);
  257. ++off;
  258. } else if(TOUPPER(*message) == 'B')
  259. {// byte
  260. ++message;
  261. GET_VALUE(message,num);
  262. WFIFOB(sd->fd,off)=TOB(num);
  263. ++off;
  264. } else if(TOUPPER(*message) == 'W')
  265. {// word (2 bytes)
  266. ++message;
  267. GET_VALUE(message,num);
  268. WFIFOW(sd->fd,off)=TOW(num);
  269. off+=2;
  270. } else if(TOUPPER(*message) == 'L')
  271. {// long word (4 bytes)
  272. ++message;
  273. GET_VALUE(message,num);
  274. WFIFOL(sd->fd,off)=TOL(num);
  275. off+=4;
  276. } else if(TOUPPER(*message) == 'S')
  277. {// string - escapes are valid
  278. // get string length - num <= 0 means not fixed length (default)
  279. int end;
  280. ++message;
  281. if(*message == '"'){
  282. num=0;
  283. } else {
  284. GET_VALUE(message,num);
  285. while(*message != '"')
  286. {// find start of string
  287. if(*message == 0 || ISSPACE(*message)){
  288. PARSE_ERROR(msg_fd(fd,906),message); // Not a string:
  289. return false;
  290. }
  291. ++message;
  292. }
  293. }
  294. // parse string
  295. ++message;
  296. CHECK_EOS(message);
  297. end=(num<=0? 0: min(off+((int)num),len));
  298. for(; *message != '"' && (off < end || end == 0); ++off){
  299. if(*message == '\\'){
  300. ++message;
  301. CHECK_EOS(message);
  302. switch(*message){
  303. case 'a': num=0x07; break; // Bell
  304. case 'b': num=0x08; break; // Backspace
  305. case 't': num=0x09; break; // Horizontal tab
  306. case 'n': num=0x0A; break; // Line feed
  307. case 'v': num=0x0B; break; // Vertical tab
  308. case 'f': num=0x0C; break; // Form feed
  309. case 'r': num=0x0D; break; // Carriage return
  310. case 'e': num=0x1B; break; // Escape
  311. default: num=*message; break;
  312. case 'x': // Hexadecimal
  313. {
  314. ++message;
  315. CHECK_EOS(message);
  316. if(!ISXDIGIT(*message)){
  317. PARSE_ERROR(msg_fd(fd,907),message); // Not a hexadecimal digit:
  318. return false;
  319. }
  320. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  321. if(ISXDIGIT(*message)){
  322. ++message;
  323. CHECK_EOS(message);
  324. num<<=8;
  325. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  326. }
  327. WFIFOB(sd->fd,off)=TOB(num);
  328. ++message;
  329. CHECK_EOS(message);
  330. continue;
  331. }
  332. case '0':
  333. case '1':
  334. case '2':
  335. case '3':
  336. case '4':
  337. case '5':
  338. case '6':
  339. case '7': // Octal
  340. {
  341. num=*message-'0'; // 1st octal digit
  342. ++message;
  343. CHECK_EOS(message);
  344. if(ISDIGIT(*message) && *message < '8'){
  345. num<<=3;
  346. num+=*message-'0'; // 2nd octal digit
  347. ++message;
  348. CHECK_EOS(message);
  349. if(ISDIGIT(*message) && *message < '8'){
  350. num<<=3;
  351. num+=*message-'0'; // 3rd octal digit
  352. ++message;
  353. CHECK_EOS(message);
  354. }
  355. }
  356. WFIFOB(sd->fd,off)=TOB(num);
  357. continue;
  358. }
  359. }
  360. } else
  361. num=*message;
  362. WFIFOB(sd->fd,off)=TOB(num);
  363. ++message;
  364. CHECK_EOS(message);
  365. }//for
  366. while(*message != '"')
  367. {// ignore extra characters
  368. ++message;
  369. CHECK_EOS(message);
  370. }
  371. // terminate the string
  372. if(off < end)
  373. {// fill the rest with 0's
  374. memset(WFIFOP(sd->fd,off),0,end-off);
  375. off=end;
  376. }
  377. } else
  378. {// unknown
  379. PARSE_ERROR(msg_fd(fd,908),message); // Unknown type of value in:
  380. return false;
  381. }
  382. SKIP_VALUE(message);
  383. }
  384. if (clif->packet(type)->len == -1) { // send dynamic packet
  385. WFIFOW(sd->fd,2)=TOW(off);
  386. WFIFOSET(sd->fd,off);
  387. } else {// send static packet
  388. if(off < len)
  389. memset(WFIFOP(sd->fd,off),0,len-off);
  390. WFIFOSET(sd->fd,len);
  391. }
  392. } else {
  393. clif->message(fd, msg_fd(fd,259)); // Invalid packet
  394. return false;
  395. }
  396. sprintf (atcmd_output, msg_fd(fd,258), type, type); // Sent packet 0x%x (%d)
  397. clif->message(fd, atcmd_output);
  398. return true;
  399. #undef PARSE_ERROR
  400. #undef CHECK_EOS
  401. #undef SKIP_VALUE
  402. #undef GET_VALUE
  403. }
  404. /*==========================================
  405. * @rura, @warp, @mapmove
  406. *------------------------------------------*/
  407. ACMD(mapmove) {
  408. char map_name[MAP_NAME_LENGTH_EXT];
  409. unsigned short map_index;
  410. short x = 0, y = 0;
  411. int16 m = -1;
  412. memset(map_name, '\0', sizeof(map_name));
  413. if (!*message ||
  414. (sscanf(message, "%15s %5hd %5hd", map_name, &x, &y) < 3 &&
  415. sscanf(message, "%15[^,],%5hd,%5hd", map_name, &x, &y) < 1)) {
  416. clif->message(fd, msg_fd(fd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  417. return false;
  418. }
  419. map_index = mapindex->name2id(map_name);
  420. if (map_index)
  421. m = map->mapindex2mapid(map_index);
  422. if (!map_index || m < 0) { // m < 0 means on different server or that map is disabled! [Kevin]
  423. clif->message(fd, msg_fd(fd,1)); // Map not found.
  424. return false;
  425. }
  426. if( sd->bl.m == m && sd->bl.x == x && sd->bl.y == y ) {
  427. clif->message(fd, msg_fd(fd,253)); // You already are at your destination!
  428. return false;
  429. }
  430. if ((x || y) && map->getcell(m, &sd->bl, x, y, CELL_CHKNOPASS) && pc_get_group_level(sd) < battle_config.gm_ignore_warpable_area) {
  431. //This is to prevent the pc->setpos call from printing an error.
  432. clif->message(fd, msg_fd(fd,2));
  433. if (!map->search_freecell(NULL, m, &x, &y, 10, 10, 1))
  434. x = y = 0; //Invalid cell, use random spot.
  435. }
  436. if (map->list[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  437. clif->message(fd, msg_fd(fd,247));
  438. return false;
  439. }
  440. if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  441. clif->message(fd, msg_fd(fd,248));
  442. return false;
  443. }
  444. if (pc->setpos(sd, map_index, x, y, CLR_TELEPORT) != 0) {
  445. clif->message(fd, msg_fd(fd,1)); // Map not found.
  446. return false;
  447. }
  448. clif->message(fd, msg_fd(fd,0)); // Warped.
  449. return true;
  450. }
  451. /*==========================================
  452. * Displays where a character is. Corrected version by Silent. [Skotlex]
  453. *------------------------------------------*/
  454. ACMD(where) {
  455. struct map_session_data* pl_sd;
  456. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  457. if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  458. clif->message(fd, msg_fd(fd,910)); // Please enter a player name (usage: @where <char name>).
  459. return false;
  460. }
  461. pl_sd = map->nick2sd(atcmd_player_name);
  462. if (pl_sd == NULL ||
  463. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  464. (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))
  465. ) {
  466. clif->message(fd, msg_fd(fd,3)); // Character not found.
  467. return false;
  468. }
  469. 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);
  470. clif->message(fd, atcmd_output);
  471. return true;
  472. }
  473. /*==========================================
  474. *
  475. *------------------------------------------*/
  476. ACMD(jumpto) {
  477. struct map_session_data *pl_sd = NULL;
  478. if (!*message) {
  479. clif->message(fd, msg_fd(fd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  480. return false;
  481. }
  482. if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  483. clif->message(fd, msg_fd(fd,248)); // You are not authorized to warp from your current map.
  484. return false;
  485. }
  486. if( pc_isdead(sd) ) {
  487. clif->message(fd, msg_fd(fd,864)); // "You cannot use this command when dead."
  488. return false;
  489. }
  490. if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
  491. clif->message(fd, msg_fd(fd,3)); // Character not found.
  492. return false;
  493. }
  494. if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  495. clif->message(fd, msg_fd(fd,247)); // You are not authorized to warp to this map.
  496. return false;
  497. }
  498. if( pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y ) {
  499. clif->message(fd, msg_fd(fd,253)); // You already are at your destination!
  500. return false;
  501. }
  502. pc->setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  503. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,4), pl_sd->status.name); // Jumped to %s
  504. clif->message(fd, atcmd_output);
  505. return true;
  506. }
  507. /*==========================================
  508. *
  509. *------------------------------------------*/
  510. ACMD(jump)
  511. {
  512. short x = 0, y = 0;
  513. memset(atcmd_output, '\0', sizeof(atcmd_output));
  514. sscanf(message, "%5hd %5hd", &x, &y);
  515. if (map->list[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  516. clif->message(fd, msg_fd(fd,248)); // You are not authorized to warp from your current map.
  517. return false;
  518. }
  519. if( pc_isdead(sd) ) {
  520. clif->message(fd, msg_fd(fd,864)); // "You cannot use this command when dead."
  521. return false;
  522. }
  523. if ((x || y) && map->getcell(sd->bl.m, &sd->bl, x, y, CELL_CHKNOPASS)) {
  524. //This is to prevent the pc->setpos call from printing an error.
  525. clif->message(fd, msg_fd(fd,2));
  526. if (!map->search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  527. x = y = 0; //Invalid cell, use random spot.
  528. }
  529. if (x && y && sd->bl.x == x && sd->bl.y == y) {
  530. clif->message(fd, msg_fd(fd,253)); // You already are at your destination!
  531. return false;
  532. }
  533. pc->setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  534. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  535. clif->message(fd, atcmd_output);
  536. return true;
  537. }
  538. /*==========================================
  539. * Display list of online characters with
  540. * various info.
  541. *------------------------------------------*/
  542. ACMD(who) {
  543. const struct map_session_data *pl_sd = NULL;
  544. struct s_mapiterator *iter = NULL;
  545. char player_name[NAME_LENGTH] = "";
  546. int count = 0;
  547. int level = 0;
  548. StringBuf buf;
  549. /**
  550. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  551. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  552. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  553. */
  554. int display_type = 1;
  555. int map_id = -1;
  556. if (stristr(info->command, "map") != NULL) {
  557. char map_name[MAP_NAME_LENGTH_EXT] = "";
  558. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map->mapname2mapid(map_name)) < 0)
  559. map_id = sd->bl.m;
  560. } else {
  561. sscanf(message, "%23s", player_name);
  562. }
  563. if (stristr(info->command, "2") != NULL)
  564. display_type = 2;
  565. else if (stristr(info->command, "3") != NULL)
  566. display_type = 3;
  567. level = pc_get_group_level(sd);
  568. StrBuf->Init(&buf);
  569. iter = mapit_getallusers();
  570. for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_PC, mapit->next(iter))) {
  571. 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
  572. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  573. || (map_id >= 0 && pl_sd->bl.m != map_id))
  574. continue;
  575. switch (display_type) {
  576. case 2: {
  577. StrBuf->Printf(&buf, msg_fd(fd,343), pl_sd->status.name); // "Name: %s "
  578. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  579. StrBuf->Printf(&buf, msg_fd(fd,344), pcg->get_name(pl_sd->group)); // "(%s) "
  580. StrBuf->Printf(&buf, msg_fd(fd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  581. pc->job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  582. break;
  583. }
  584. case 3: {
  585. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  586. StrBuf->Printf(&buf, msg_fd(fd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  587. StrBuf->Printf(&buf, msg_fd(fd,343), pl_sd->status.name); // "Name: %s "
  588. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  589. StrBuf->Printf(&buf, msg_fd(fd,344), pcg->get_name(pl_sd->group)); // "(%s) "
  590. StrBuf->Printf(&buf, msg_fd(fd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  591. break;
  592. }
  593. default: {
  594. struct party_data *p = party->search(pl_sd->status.party_id);
  595. struct guild *g = pl_sd->guild;
  596. StrBuf->Printf(&buf, msg_fd(fd,343), pl_sd->status.name); // "Name: %s "
  597. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  598. StrBuf->Printf(&buf, msg_fd(fd,344), pcg->get_name(pl_sd->group)); // "(%s) "
  599. if (p != NULL)
  600. StrBuf->Printf(&buf, msg_fd(fd,345), p->party.name); // " | Party: '%s'"
  601. if (g != NULL)
  602. StrBuf->Printf(&buf, msg_fd(fd,346), g->name); // " | Guild: '%s'"
  603. break;
  604. }
  605. }
  606. clif->messagecolor_self(fd, COLOR_DEFAULT, StrBuf->Value(&buf));/** for whatever reason clif->message crashes with some patterns, see bugreport:8186 **/
  607. StrBuf->Clear(&buf);
  608. count++;
  609. }
  610. }
  611. mapit->free(iter);
  612. if (map_id < 0) {
  613. if (count == 0)
  614. StrBuf->AppendStr(&buf, msg_fd(fd,28)); // No player found.
  615. else if (count == 1)
  616. StrBuf->AppendStr(&buf, msg_fd(fd,29)); // 1 player found.
  617. else
  618. StrBuf->Printf(&buf, msg_fd(fd,30), count); // %d players found.
  619. } else {
  620. if (count == 0)
  621. StrBuf->Printf(&buf, msg_fd(fd,54), map->list[map_id].name); // No player found in map '%s'.
  622. else if (count == 1)
  623. StrBuf->Printf(&buf, msg_fd(fd,55), map->list[map_id].name); // 1 player found in map '%s'.
  624. else
  625. StrBuf->Printf(&buf, msg_fd(fd,56), count, map->list[map_id].name); // %d players found in map '%s'.
  626. }
  627. clif->message(fd, StrBuf->Value(&buf));
  628. StrBuf->Destroy(&buf);
  629. return true;
  630. }
  631. /*==========================================
  632. *
  633. *------------------------------------------*/
  634. ACMD(whogm)
  635. {
  636. const struct map_session_data *pl_sd;
  637. struct s_mapiterator* iter;
  638. int j, count;
  639. int level;
  640. char match_text[CHAT_SIZE_MAX];
  641. char player_name[NAME_LENGTH];
  642. struct guild *g;
  643. struct party_data *p;
  644. memset(atcmd_output, '\0', sizeof(atcmd_output));
  645. memset(match_text, '\0', sizeof(match_text));
  646. memset(player_name, '\0', sizeof(player_name));
  647. if (sscanf(message, "%199[^\n]", match_text) < 1)
  648. strcpy(match_text, "");
  649. for (j = 0; match_text[j]; j++)
  650. match_text[j] = TOLOWER(match_text[j]);
  651. count = 0;
  652. level = pc_get_group_level(sd);
  653. iter = mapit_getallusers();
  654. for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_PC, mapit->next(iter))) {
  655. int pl_level = pc_get_group_level(pl_sd);
  656. if (!pl_level)
  657. continue;
  658. if (match_text[0]) {
  659. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  660. for (j = 0; player_name[j]; j++)
  661. player_name[j] = TOLOWER(player_name[j]);
  662. // search with no case sensitive
  663. if (strstr(player_name, match_text) == NULL)
  664. continue;
  665. }
  666. if (pl_level > level) {
  667. if (pc_isinvisible(pl_sd))
  668. continue;
  669. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,913), pl_sd->status.name); // Name: %s (GM)
  670. clif->message(fd, atcmd_output);
  671. count++;
  672. continue;
  673. }
  674. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,914), // Name: %s (GM:%d) | Location: %s %d %d
  675. pl_sd->status.name, pl_level,
  676. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  677. clif->message(fd, atcmd_output);
  678. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,915), // BLvl: %d | Job: %s (Lvl: %d)
  679. pl_sd->status.base_level,
  680. pc->job_name(pl_sd->status.class_), pl_sd->status.job_level);
  681. clif->message(fd, atcmd_output);
  682. p = party->search(pl_sd->status.party_id);
  683. g = pl_sd->guild;
  684. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,916), // Party: '%s' | Guild: '%s'
  685. p?p->party.name:msg_fd(fd,917), g?g->name:msg_fd(fd,917)); // None.
  686. clif->message(fd, atcmd_output);
  687. count++;
  688. }
  689. mapit->free(iter);
  690. if (count == 0)
  691. clif->message(fd, msg_fd(fd,150)); // No GM found.
  692. else if (count == 1)
  693. clif->message(fd, msg_fd(fd,151)); // 1 GM found.
  694. else {
  695. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,152), count); // %d GMs found.
  696. clif->message(fd, atcmd_output);
  697. }
  698. return true;
  699. }
  700. /*==========================================
  701. *
  702. *------------------------------------------*/
  703. ACMD(save)
  704. {
  705. pc->setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  706. if (sd->status.pet_id > 0 && sd->pd)
  707. intif->save_petdata(sd->status.account_id, &sd->pd->pet);
  708. chrif->save(sd,0);
  709. clif->message(fd, msg_fd(fd,6)); // Your save point has been changed.
  710. return true;
  711. }
  712. /*==========================================
  713. *
  714. *------------------------------------------*/
  715. ACMD(load) {
  716. int16 m;
  717. m = map->mapindex2mapid(sd->status.save_point.map);
  718. if (m >= 0 && map->list[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  719. clif->message(fd, msg_fd(fd,249)); // You are not authorized to warp to your save map.
  720. return false;
  721. }
  722. if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  723. clif->message(fd, msg_fd(fd,248)); // You are not authorized to warp from your current map.
  724. return false;
  725. }
  726. pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  727. clif->message(fd, msg_fd(fd,7)); // Warping to save point..
  728. return true;
  729. }
  730. /*==========================================
  731. *
  732. *------------------------------------------*/
  733. ACMD(speed)
  734. {
  735. int speed;
  736. memset(atcmd_output, '\0', sizeof(atcmd_output));
  737. if (!*message || sscanf(message, "%12d", &speed) < 1) {
  738. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  739. clif->message(fd, atcmd_output);
  740. return false;
  741. }
  742. sd->state.permanent_speed = 0;
  743. if (speed < 0)
  744. sd->base_status.speed = DEFAULT_WALK_SPEED;
  745. else
  746. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  747. if( sd->base_status.speed != DEFAULT_WALK_SPEED ) {
  748. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  749. clif->message(fd, msg_fd(fd,8)); // Speed changed.
  750. } else
  751. clif->message(fd, msg_fd(fd,172)); //Speed returned to normal.
  752. status_calc_bl(&sd->bl, SCB_SPEED);
  753. return true;
  754. }
  755. /*==========================================
  756. *
  757. *------------------------------------------*/
  758. ACMD(storage)
  759. {
  760. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  761. return false;
  762. if (storage->open(sd) == 1) { //Already open.
  763. clif->message(fd, msg_fd(fd,250));
  764. return false;
  765. }
  766. clif->message(fd, msg_fd(fd,919)); // Storage opened.
  767. return true;
  768. }
  769. /*==========================================
  770. *
  771. *------------------------------------------*/
  772. ACMD(guildstorage)
  773. {
  774. if (!sd->status.guild_id) {
  775. clif->message(fd, msg_fd(fd,252));
  776. return false;
  777. }
  778. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  779. return false;
  780. if (sd->state.storage_flag == STORAGE_FLAG_NORMAL) {
  781. clif->message(fd, msg_fd(fd,250));
  782. return false;
  783. }
  784. if (sd->state.storage_flag == STORAGE_FLAG_GUILD) {
  785. clif->message(fd, msg_fd(fd,251));
  786. return false;
  787. }
  788. if( gstorage->open(sd) ) {
  789. clif->message(fd, msg_fd(fd,1201)); // Your guild's storage has already been opened by another member, try again later.
  790. return false;
  791. }
  792. clif->message(fd, msg_fd(fd,920)); // Guild storage opened.
  793. return true;
  794. }
  795. /*==========================================
  796. *
  797. *------------------------------------------*/
  798. ACMD(option)
  799. {
  800. int param1 = 0, param2 = 0, param3 = 0;
  801. if (!*message || sscanf(message, "%12d %12d %12d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  802. {// failed to match the parameters so inform the user of the options
  803. const char* text;
  804. // attempt to find the setting information for this command
  805. text = atcommand_help_string( info );
  806. // notify the user of the requirement to enter an option
  807. clif->message(fd, msg_fd(fd,921)); // Please enter at least one option.
  808. if( text ) {// send the help text associated with this command
  809. clif->messageln( fd, text );
  810. }
  811. return false;
  812. }
  813. sd->sc.opt1 = param1;
  814. sd->sc.opt2 = param2;
  815. pc->setoption(sd, param3);
  816. clif->message(fd, msg_fd(fd,9)); // Options changed.
  817. return true;
  818. }
  819. /*==========================================
  820. *
  821. *------------------------------------------*/
  822. ACMD(hide) {
  823. if (pc_isinvisible(sd)) {
  824. sd->sc.option &= ~OPTION_INVISIBLE;
  825. if (sd->disguise != -1 )
  826. status->set_viewdata(&sd->bl, sd->disguise);
  827. else
  828. status->set_viewdata(&sd->bl, sd->status.class_);
  829. clif->message(fd, msg_fd(fd,10)); // Invisible: Off
  830. // increment the number of pvp players on the map
  831. map->list[sd->bl.m].users_pvp++;
  832. if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank ) {
  833. // register the player for ranking calculations
  834. sd->pvp_timer = timer->add( timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 );
  835. }
  836. //bugreport:2266
  837. map->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  838. } else {
  839. sd->sc.option |= OPTION_INVISIBLE;
  840. sd->vd.class_ = INVISIBLE_CLASS;
  841. clif->message(fd, msg_fd(fd,11)); // Invisible: On
  842. // decrement the number of pvp players on the map
  843. map->list[sd->bl.m].users_pvp--;
  844. if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {
  845. // unregister the player for ranking
  846. timer->delete( sd->pvp_timer, pc->calc_pvprank_timer );
  847. sd->pvp_timer = INVALID_TIMER;
  848. }
  849. }
  850. clif->changeoption(&sd->bl);
  851. return true;
  852. }
  853. /*==========================================
  854. * Changes a character's class
  855. *------------------------------------------*/
  856. ACMD(jobchange)
  857. {
  858. int job = 0, upper = 0;
  859. bool found = false;
  860. if (*message == '\0') { // No message, just show the list
  861. found = false;
  862. } else if (sscanf(message, "%12d %12d", &job, &upper) >= 1) { // Numeric job ID
  863. found = true;
  864. } else { // Job name
  865. int i;
  866. // Normal Jobs
  867. for (i = JOB_NOVICE; !found && i < JOB_MAX_BASIC; i++) {
  868. if (strncmpi(message, pc->job_name(i), 16) == 0) {
  869. job = i;
  870. found = true;
  871. break;
  872. }
  873. }
  874. // High Jobs, Babies and Third
  875. for (i = JOB_NOVICE_HIGH; !found && i < JOB_MAX; i++) {
  876. if (strncmpi(message, pc->job_name(i), 16) == 0) {
  877. job = i;
  878. found = true;
  879. break;
  880. }
  881. }
  882. }
  883. if (!found || !pc->db_checkid(job)) {
  884. const char *text = atcommand_help_string(info);
  885. if (text)
  886. clif->messageln(fd, text);
  887. return false;
  888. }
  889. // Deny direct transformation into dummy jobs
  890. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2
  891. || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER
  892. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2
  893. || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2
  894. || job == JOB_STAR_GLADIATOR2
  895. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2)
  896. || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
  897. ) {
  898. /* WHY DO WE LIST THEM THEN? */
  899. clif->message(fd, msg_fd(fd,923)); //"You can not change to this job by command."
  900. return true;
  901. }
  902. if (pc->jobchange(sd, job, upper) != 0) {
  903. clif->message(fd, msg_fd(fd,155)); // You are unable to change your job.
  904. return false;
  905. }
  906. clif->message(fd, msg_fd(fd,12)); // Your job has been changed.
  907. return true;
  908. }
  909. /*==========================================
  910. *
  911. *------------------------------------------*/
  912. ACMD(kill)
  913. {
  914. status_kill(&sd->bl);
  915. clif->message(sd->fd, msg_fd(fd,13)); // A pity! You've died.
  916. if (fd != sd->fd)
  917. clif->message(fd, msg_fd(fd,14)); // Character killed.
  918. return true;
  919. }
  920. /*==========================================
  921. *
  922. *------------------------------------------*/
  923. ACMD(alive)
  924. {
  925. if (!status->revive(&sd->bl, 100, 100)) {
  926. clif->message(fd, msg_fd(fd,867)); // "You're not dead."
  927. return false;
  928. }
  929. clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  930. clif->message(fd, msg_fd(fd,16)); // You've been revived! It's a miracle!
  931. return true;
  932. }
  933. /*==========================================
  934. * +kamic [LuzZza]
  935. *------------------------------------------*/
  936. ACMD(kami)
  937. {
  938. unsigned int color=0;
  939. memset(atcmd_output, '\0', sizeof(atcmd_output));
  940. if(*(info->command + 4) != 'c' && *(info->command + 4) != 'C') {
  941. if (!*message) {
  942. clif->message(fd, msg_fd(fd,980)); // Please enter a message (usage: @kami <message>).
  943. return false;
  944. }
  945. sscanf(message, "%199[^\n]", atcmd_output);
  946. if (stristr(info->command, "l") != NULL)
  947. clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  948. else
  949. intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(info->command + 4) == 'b' || *(info->command + 4) == 'B') ? BC_BLUE : BC_YELLOW);
  950. } else {
  951. if(!*message || (sscanf(message, "%10u %199[^\n]", &color, atcmd_output) < 2)) {
  952. clif->message(fd, msg_fd(fd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  953. return false;
  954. }
  955. if(color > 0xFFFFFF) {
  956. clif->message(fd, msg_fd(fd,982)); // Invalid color.
  957. return false;
  958. }
  959. intif->broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  960. }
  961. return true;
  962. }
  963. /*==========================================
  964. *
  965. *------------------------------------------*/
  966. ACMD(heal)
  967. {
  968. int hp = 0, sp = 0; // [Valaris] thanks to fov
  969. sscanf(message, "%12d %12d", &hp, &sp);
  970. // some overflow checks
  971. if( hp == INT_MIN ) hp++;
  972. if( sp == INT_MIN ) sp++;
  973. if ( hp == 0 && sp == 0 ) {
  974. if (!status_percent_heal(&sd->bl, 100, 100))
  975. clif->message(fd, msg_fd(fd,157)); // HP and SP have already been recovered.
  976. else
  977. clif->message(fd, msg_fd(fd,17)); // HP, SP recovered.
  978. return true;
  979. }
  980. if ( hp > 0 && sp >= 0 ) {
  981. if(!status->heal(&sd->bl, hp, sp, 0))
  982. clif->message(fd, msg_fd(fd,157)); // HP and SP are already with the good value.
  983. else
  984. clif->message(fd, msg_fd(fd,17)); // HP, SP recovered.
  985. return true;
  986. }
  987. if ( hp < 0 && sp <= 0 ) {
  988. status->damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  989. clif->damage(&sd->bl,&sd->bl, 0, 0, -hp, 0, BDT_ENDURE, 0);
  990. clif->message(fd, msg_fd(fd,156)); // HP or/and SP modified.
  991. return true;
  992. }
  993. //Opposing signs.
  994. if ( hp ) {
  995. if (hp > 0)
  996. status->heal(&sd->bl, hp, 0, 0);
  997. else {
  998. status->damage(NULL, &sd->bl, -hp, 0, 0, 0);
  999. clif->damage(&sd->bl,&sd->bl, 0, 0, -hp, 0, BDT_ENDURE, 0);
  1000. }
  1001. }
  1002. if ( sp ) {
  1003. if (sp > 0)
  1004. status->heal(&sd->bl, 0, sp, 0);
  1005. else
  1006. status->damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1007. }
  1008. clif->message(fd, msg_fd(fd,156)); // HP or/and SP modified.
  1009. return true;
  1010. }
  1011. /*==========================================
  1012. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1013. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound type>) (revised by [Mhalicot])
  1014. *------------------------------------------*/
  1015. ACMD(item)
  1016. {
  1017. char item_name[100];
  1018. int number = 0, item_id, flag = 0, bound = 0;
  1019. struct item item_tmp;
  1020. struct item_data *item_data;
  1021. int get_count, i;
  1022. memset(item_name, '\0', sizeof(item_name));
  1023. if (!strcmpi(info->command,"itembound") && (!*message || (
  1024. sscanf(message, "\"%99[^\"]\" %12d %12d", item_name, &number, &bound) < 2 &&
  1025. sscanf(message, "%99s %12d %12d", item_name, &number, &bound) < 2
  1026. ))) {
  1027. clif->message(fd, msg_fd(fd,295)); // Please enter an item name or ID (usage: @itembound <item name/ID> <quantity> <bound_type>).
  1028. return false;
  1029. } else if (!*message
  1030. || ( sscanf(message, "\"%99[^\"]\" %12d", item_name, &number) < 1
  1031. && sscanf(message, "%99s %12d", item_name, &number) < 1
  1032. )) {
  1033. clif->message(fd, msg_fd(fd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1034. return false;
  1035. }
  1036. if (number <= 0)
  1037. number = 1;
  1038. if ((item_data = itemdb->search_name(item_name)) == NULL &&
  1039. (item_data = itemdb->exists(atoi(item_name))) == NULL)
  1040. {
  1041. clif->message(fd, msg_fd(fd,19)); // Invalid item ID or name.
  1042. return false;
  1043. }
  1044. if(!strcmpi(info->command,"itembound") ) {
  1045. if( !(bound >= IBT_MIN && bound <= IBT_MAX) ) {
  1046. clif->message(fd, msg_fd(fd,298)); // Invalid bound type
  1047. return false;
  1048. }
  1049. switch( (enum e_item_bound_type)bound ) {
  1050. case IBT_CHARACTER:
  1051. case IBT_ACCOUNT:
  1052. break; /* no restrictions */
  1053. case IBT_PARTY:
  1054. if( !sd->status.party_id ) {
  1055. clif->message(fd, msg_fd(fd,1498)); //You can't add a party bound item to a character without party!
  1056. return false;
  1057. }
  1058. break;
  1059. case IBT_GUILD:
  1060. if( !sd->status.guild_id ) {
  1061. clif->message(fd, msg_fd(fd,1499)); //You can't add a guild bound item to a character without guild!
  1062. return false;
  1063. }
  1064. break;
  1065. }
  1066. }
  1067. item_id = item_data->nameid;
  1068. get_count = number;
  1069. //Check if it's stackable.
  1070. if (!itemdb->isstackable2(item_data)) {
  1071. if( bound && (item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) ) {
  1072. clif->message(fd, msg_fd(fd,498)); // Cannot create bounded pet eggs or pet armors.
  1073. return false;
  1074. }
  1075. get_count = 1;
  1076. }
  1077. for (i = 0; i < number; i += get_count) {
  1078. // if not pet egg
  1079. if (!pet->create_egg(sd, item_id)) {
  1080. memset(&item_tmp, 0, sizeof(item_tmp));
  1081. item_tmp.nameid = item_id;
  1082. item_tmp.identify = 1;
  1083. item_tmp.bound = (unsigned char)bound;
  1084. if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1085. clif->additem(sd, 0, 0, flag);
  1086. }
  1087. }
  1088. if (flag == 0)
  1089. clif->message(fd, msg_fd(fd,18)); // Item created.
  1090. return true;
  1091. }
  1092. /*==========================================
  1093. * @item2 and @itembound2 command (revised by [Mhalicot])
  1094. *------------------------------------------*/
  1095. ACMD(item2)
  1096. {
  1097. struct item item_tmp;
  1098. struct item_data *item_data;
  1099. char item_name[100];
  1100. int item_id, number = 0, bound = 0;
  1101. int identify = 0, refine = 0, attr = 0;
  1102. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1103. memset(item_name, '\0', sizeof(item_name));
  1104. if (!strcmpi(info->command,"itembound2") && (!*message || (
  1105. sscanf(message, "\"%99[^\"]\" %12d %12d %12d %12d %12d %12d %12d %12d %12d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1106. sscanf(message, "%99s %12d %12d %12d %12d %12d %12d %12d %12d %12d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))) {
  1107. clif->message(fd, msg_fd(fd,296)); // Please enter all parameters (usage: @itembound2 <item name/ID> <quantity>
  1108. clif->message(fd, msg_fd(fd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1109. return false;
  1110. } else if (!*message
  1111. || ( sscanf(message, "\"%99[^\"]\" %12d %12d %12d %12d %12d %12d %12d %12d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1112. && sscanf(message, "%99s %12d %12d %12d %12d %12d %12d %12d %12d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1113. )) {
  1114. clif->message(fd, msg_fd(fd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1115. clif->message(fd, msg_fd(fd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1116. return false;
  1117. }
  1118. if (number <= 0)
  1119. number = 1;
  1120. if( !strcmpi(info->command,"itembound2") && !(bound >= IBT_MIN && bound <= IBT_MAX) ) {
  1121. clif->message(fd, msg_fd(fd,298)); // Invalid bound type
  1122. return false;
  1123. }
  1124. item_id = 0;
  1125. if ((item_data = itemdb->search_name(item_name)) != NULL ||
  1126. (item_data = itemdb->exists(atoi(item_name))) != NULL)
  1127. item_id = item_data->nameid;
  1128. if (item_id > 500) {
  1129. int flag = 0;
  1130. int loop, get_count, i;
  1131. loop = 1;
  1132. get_count = number;
  1133. if( !strcmpi(info->command,"itembound2") )
  1134. bound = 1;
  1135. if( !itemdb->isstackable2(item_data) ) {
  1136. if( bound && (item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) ) {
  1137. clif->message(fd, msg_fd(fd,498)); // Cannot create bounded pet eggs or pet armors.
  1138. return false;
  1139. }
  1140. loop = number;
  1141. get_count = 1;
  1142. if (item_data->type == IT_PETEGG) {
  1143. identify = 1;
  1144. refine = 0;
  1145. }
  1146. if (item_data->type == IT_PETARMOR)
  1147. refine = 0;
  1148. } else {
  1149. identify = 1;
  1150. refine = attr = 0;
  1151. }
  1152. refine = cap_value(refine, 0, MAX_REFINE);
  1153. for (i = 0; i < loop; i++) {
  1154. memset(&item_tmp, 0, sizeof(item_tmp));
  1155. item_tmp.nameid = item_id;
  1156. item_tmp.identify = identify;
  1157. item_tmp.refine = refine;
  1158. item_tmp.attribute = attr;
  1159. item_tmp.bound = (unsigned char)bound;
  1160. item_tmp.card[0] = c1;
  1161. item_tmp.card[1] = c2;
  1162. item_tmp.card[2] = c3;
  1163. item_tmp.card[3] = c4;
  1164. if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1165. clif->additem(sd, 0, 0, flag);
  1166. }
  1167. if (flag == 0)
  1168. clif->message(fd, msg_fd(fd,18)); // Item created.
  1169. } else {
  1170. clif->message(fd, msg_fd(fd,19)); // Invalid item ID or name.
  1171. return false;
  1172. }
  1173. return true;
  1174. }
  1175. /*==========================================
  1176. *
  1177. *------------------------------------------*/
  1178. ACMD(itemreset)
  1179. {
  1180. int i;
  1181. for (i = 0; i < MAX_INVENTORY; i++) {
  1182. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1183. pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_NORMAL, LOG_TYPE_COMMAND);
  1184. }
  1185. }
  1186. clif->message(fd, msg_fd(fd,20)); // All of your items have been removed.
  1187. return true;
  1188. }
  1189. /*==========================================
  1190. * Atcommand @lvlup
  1191. *------------------------------------------*/
  1192. ACMD(baselevelup)
  1193. {
  1194. int level=0, i=0, status_point=0;
  1195. if (!*message || !(level = atoi(message))) {
  1196. clif->message(fd, msg_fd(fd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1197. return false;
  1198. }
  1199. if (level > 0) {
  1200. if (sd->status.base_level >= pc->maxbaselv(sd)) { // check for max level by Valaris
  1201. clif->message(fd, msg_fd(fd,47)); // Base level can't go any higher.
  1202. return false;
  1203. } // End Addition
  1204. if ((unsigned int)level > pc->maxbaselv(sd) || (unsigned int)level > pc->maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1205. level = pc->maxbaselv(sd) - sd->status.base_level;
  1206. for (i = 0; i < level; i++)
  1207. status_point += pc->gets_status_point(sd->status.base_level + i);
  1208. sd->status.status_point += status_point;
  1209. sd->status.base_level += (unsigned int)level;
  1210. status_calc_pc(sd, SCO_FORCE);
  1211. status_percent_heal(&sd->bl, 100, 100);
  1212. clif->misceffect(&sd->bl, 0);
  1213. clif->message(fd, msg_fd(fd,21)); // Base level raised.
  1214. } else {
  1215. if (sd->status.base_level == 1) {
  1216. clif->message(fd, msg_fd(fd,158)); // Base level can't go any lower.
  1217. return false;
  1218. }
  1219. level*=-1;
  1220. if ((unsigned int)level >= sd->status.base_level)
  1221. level = sd->status.base_level-1;
  1222. for (i = 0; i > -level; i--)
  1223. status_point += pc->gets_status_point(sd->status.base_level + i - 1);
  1224. if (sd->status.status_point < status_point)
  1225. pc->resetstate(sd);
  1226. if (sd->status.status_point < status_point)
  1227. sd->status.status_point = 0;
  1228. else
  1229. sd->status.status_point -= status_point;
  1230. sd->status.base_level -= (unsigned int)level;
  1231. clif->message(fd, msg_fd(fd,22)); // Base level lowered.
  1232. status_calc_pc(sd, SCO_FORCE);
  1233. }
  1234. sd->status.base_exp = 0;
  1235. clif->updatestatus(sd, SP_STATUSPOINT);
  1236. clif->updatestatus(sd, SP_BASELEVEL);
  1237. clif->updatestatus(sd, SP_BASEEXP);
  1238. clif->updatestatus(sd, SP_NEXTBASEEXP);
  1239. pc->baselevelchanged(sd);
  1240. if(sd->status.party_id)
  1241. party->send_levelup(sd);
  1242. return true;
  1243. }
  1244. /*==========================================
  1245. *
  1246. *------------------------------------------*/
  1247. ACMD(joblevelup)
  1248. {
  1249. int level=0;
  1250. if (!*message || !(level = atoi(message))) {
  1251. clif->message(fd, msg_fd(fd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1252. return false;
  1253. }
  1254. if (level > 0) {
  1255. if (sd->status.job_level >= pc->maxjoblv(sd)) {
  1256. clif->message(fd, msg_fd(fd,23)); // Job level can't go any higher.
  1257. return false;
  1258. }
  1259. if ((unsigned int)level > pc->maxjoblv(sd) || (unsigned int)level > pc->maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1260. level = pc->maxjoblv(sd) - sd->status.job_level;
  1261. sd->status.job_level += (unsigned int)level;
  1262. sd->status.skill_point += level;
  1263. clif->misceffect(&sd->bl, 1);
  1264. clif->message(fd, msg_fd(fd,24)); // Job level raised.
  1265. } else {
  1266. if (sd->status.job_level == 1) {
  1267. clif->message(fd, msg_fd(fd,159)); // Job level can't go any lower.
  1268. return false;
  1269. }
  1270. level *=-1;
  1271. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1272. level = sd->status.job_level-1;
  1273. sd->status.job_level -= (unsigned int)level;
  1274. if (sd->status.skill_point < level)
  1275. pc->resetskill(sd, PCRESETSKILL_NONE); //Reset skills since we need to subtract more points.
  1276. if (sd->status.skill_point < level)
  1277. sd->status.skill_point = 0;
  1278. else
  1279. sd->status.skill_point -= level;
  1280. clif->message(fd, msg_fd(fd,25)); // Job level lowered.
  1281. }
  1282. sd->status.job_exp = 0;
  1283. clif->updatestatus(sd, SP_JOBLEVEL);
  1284. clif->updatestatus(sd, SP_JOBEXP);
  1285. clif->updatestatus(sd, SP_NEXTJOBEXP);
  1286. clif->updatestatus(sd, SP_SKILLPOINT);
  1287. status_calc_pc(sd, SCO_FORCE);
  1288. return true;
  1289. }
  1290. /*==========================================
  1291. * @help
  1292. *------------------------------------------*/
  1293. ACMD(help) {
  1294. const char *command_name = NULL;
  1295. char *default_command = "help";
  1296. AtCommandInfo *tinfo = NULL;
  1297. if (!*message) {
  1298. command_name = default_command; // If no command_name specified, display help for @help.
  1299. } else {
  1300. if (*message == atcommand->at_symbol || *message == atcommand->char_symbol)
  1301. ++message;
  1302. command_name = atcommand->check_alias(message);
  1303. }
  1304. if (!atcommand->can_use2(sd, command_name, COMMAND_ATCOMMAND)) {
  1305. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,153), message); // "%s is Unknown Command"
  1306. clif->message(fd, atcmd_output);
  1307. atcommand->get_suggestions(sd, command_name, true);
  1308. return false;
  1309. }
  1310. tinfo = atcommand->get_info_byname(atcommand->check_alias(command_name));
  1311. if ( !tinfo || tinfo->help == NULL ) {
  1312. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,988), atcommand->at_symbol, command_name); // There is no help for %c%s.
  1313. clif->message(fd, atcmd_output);
  1314. atcommand->get_suggestions(sd, command_name, true);
  1315. return false;
  1316. }
  1317. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,989), atcommand->at_symbol, command_name); // Help for command %c%s:
  1318. clif->message(fd, atcmd_output);
  1319. { // Display aliases
  1320. DBIterator* iter;
  1321. AtCommandInfo *command_info;
  1322. AliasInfo *alias_info = NULL;
  1323. StringBuf buf;
  1324. bool has_aliases = false;
  1325. StrBuf->Init(&buf);
  1326. StrBuf->AppendStr(&buf, msg_fd(fd,990)); // Available aliases:
  1327. command_info = atcommand->get_info_byname(command_name);
  1328. iter = db_iterator(atcommand->alias_db);
  1329. for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1330. if (alias_info->command == command_info) {
  1331. StrBuf->Printf(&buf, " %s", alias_info->alias);
  1332. has_aliases = true;
  1333. }
  1334. }
  1335. dbi_destroy(iter);
  1336. if (has_aliases)
  1337. clif->message(fd, StrBuf->Value(&buf));
  1338. StrBuf->Destroy(&buf);
  1339. }
  1340. // Display help contents
  1341. clif->messageln(fd, tinfo->help);
  1342. return true;
  1343. }
  1344. /**
  1345. * Helper function, used in foreach calls to stop auto-attack timers.
  1346. *
  1347. * @see map_foreachinmap
  1348. *
  1349. * Arglist parameters:
  1350. * - (int) id: If 0, stop any attacks. Otherwise, the target block list id to stop attacking.
  1351. */
  1352. int atcommand_stopattack(struct block_list *bl,va_list ap)
  1353. {
  1354. struct unit_data *ud = NULL;
  1355. int id = 0;
  1356. nullpo_ret(bl);
  1357. ud = unit->bl2ud(bl);
  1358. id = va_arg(ap, int);
  1359. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target)) {
  1360. unit->stop_attack(bl);
  1361. return 1;
  1362. }
  1363. return 0;
  1364. }
  1365. /*==========================================
  1366. *
  1367. *------------------------------------------*/
  1368. int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1369. {
  1370. struct map_session_data *sd = NULL;
  1371. nullpo_ret(bl);
  1372. Assert_ret(bl->type == BL_PC);
  1373. sd = BL_UCAST(BL_PC, bl);
  1374. clif->pvpset(sd, 0, 0, 2);
  1375. if (sd->pvp_timer != INVALID_TIMER) {
  1376. timer->delete(sd->pvp_timer, pc->calc_pvprank_timer);
  1377. sd->pvp_timer = INVALID_TIMER;
  1378. }
  1379. return 0;
  1380. }
  1381. ACMD(pvpoff)
  1382. {
  1383. if (!map->list[sd->bl.m].flag.pvp) {
  1384. clif->message(fd, msg_fd(fd,160)); // PvP is already Off.
  1385. return false;
  1386. }
  1387. map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone);
  1388. map->list[sd->bl.m].flag.pvp = 0;
  1389. if (!battle_config.pk_mode) {
  1390. clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1391. clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1392. }
  1393. map->foreachinmap(atcommand->pvpoff_sub,sd->bl.m, BL_PC);
  1394. map->foreachinmap(atcommand->stopattack,sd->bl.m, BL_CHAR, 0);
  1395. clif->message(fd, msg_fd(fd,31)); // PvP: Off.
  1396. return true;
  1397. }
  1398. /*==========================================
  1399. *
  1400. *------------------------------------------*/
  1401. int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1402. {
  1403. struct map_session_data *sd = NULL;
  1404. nullpo_ret(bl);
  1405. Assert_ret(bl->type == BL_PC);
  1406. sd = BL_UCAST(BL_PC, bl);
  1407. if (sd->pvp_timer == INVALID_TIMER) {
  1408. sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0);
  1409. sd->pvp_rank = 0;
  1410. sd->pvp_lastusers = 0;
  1411. sd->pvp_point = 5;
  1412. sd->pvp_won = 0;
  1413. sd->pvp_lost = 0;
  1414. }
  1415. return 0;
  1416. }
  1417. ACMD(pvpon)
  1418. {
  1419. if (map->list[sd->bl.m].flag.pvp) {
  1420. clif->message(fd, msg_fd(fd,161)); // PvP is already On.
  1421. return false;
  1422. }
  1423. map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_PVP_NAME));
  1424. map->list[sd->bl.m].flag.pvp = 1;
  1425. if (!battle_config.pk_mode) {// display pvp circle and rank
  1426. clif->map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1427. clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1428. map->foreachinmap(atcommand->pvpon_sub,sd->bl.m, BL_PC);
  1429. }
  1430. clif->message(fd, msg_fd(fd,32)); // PvP: On.
  1431. return true;
  1432. }
  1433. /*==========================================
  1434. *
  1435. *------------------------------------------*/
  1436. ACMD(gvgoff) {
  1437. if (!map->list[sd->bl.m].flag.gvg) {
  1438. clif->message(fd, msg_fd(fd,162)); // GvG is already Off.
  1439. return false;
  1440. }
  1441. map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone);
  1442. map->list[sd->bl.m].flag.gvg = 0;
  1443. clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1444. clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1445. map->foreachinmap(atcommand->stopattack,sd->bl.m, BL_CHAR, 0);
  1446. clif->message(fd, msg_fd(fd,33)); // GvG: Off.
  1447. return true;
  1448. }
  1449. /*==========================================
  1450. *
  1451. *------------------------------------------*/
  1452. ACMD(gvgon)
  1453. {
  1454. if (map->list[sd->bl.m].flag.gvg) {
  1455. clif->message(fd, msg_fd(fd,163)); // GvG is already On.
  1456. return false;
  1457. }
  1458. map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME));
  1459. map->list[sd->bl.m].flag.gvg = 1;
  1460. clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1461. clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1462. clif->message(fd, msg_fd(fd,34)); // GvG: On.
  1463. return true;
  1464. }
  1465. /*==========================================
  1466. *
  1467. *------------------------------------------*/
  1468. ACMD(model)
  1469. {
  1470. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1471. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1472. if (!*message || sscanf(message, "%12d %12d %12d", &hair_style, &hair_color, &cloth_color) < 1) {
  1473. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
  1474. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1475. clif->message(fd, atcmd_output);
  1476. return false;
  1477. }
  1478. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1479. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1480. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1481. pc->changelook(sd, LOOK_HAIR, hair_style);
  1482. pc->changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1483. pc->changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1484. clif->message(fd, msg_fd(fd,36)); // Appearance changed.
  1485. } else {
  1486. clif->message(fd, msg_fd(fd,37)); // An invalid number was specified.
  1487. return false;
  1488. }
  1489. return true;
  1490. }
  1491. /*==========================================
  1492. * @bodystyle [Rytech]
  1493. *------------------------------------------*/
  1494. ACMD(bodystyle)
  1495. {
  1496. int body_style = 0;
  1497. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1498. if (!*message || sscanf(message, "%d", &body_style) < 1) {
  1499. sprintf(atcmd_output, "Please, enter a body style (usage: @bodystyle <body ID: %d-%d>).", MIN_BODY_STYLE, MAX_BODY_STYLE);
  1500. clif->message(fd, atcmd_output);
  1501. return false;
  1502. }
  1503. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1504. pc->changelook(sd, LOOK_BODY2, body_style);
  1505. clif->message(fd, msg_txt(36)); // Appearence changed.
  1506. } else {
  1507. clif->message(fd, msg_txt(37)); // An invalid number was specified.
  1508. return false;
  1509. }
  1510. return true;
  1511. }
  1512. /*==========================================
  1513. * @dye && @ccolor
  1514. *------------------------------------------*/
  1515. ACMD(dye)
  1516. {
  1517. int cloth_color = 0;
  1518. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1519. if (!*message || sscanf(message, "%12d", &cloth_color) < 1) {
  1520. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
  1521. clif->message(fd, atcmd_output);
  1522. return false;
  1523. }
  1524. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1525. pc->changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1526. clif->message(fd, msg_fd(fd,36)); // Appearance changed.
  1527. } else {
  1528. clif->message(fd, msg_fd(fd,37)); // An invalid number was specified.
  1529. return false;
  1530. }
  1531. return true;
  1532. }
  1533. /*==========================================
  1534. * @hairstyle && @hstyle
  1535. *------------------------------------------*/
  1536. ACMD(hair_style)
  1537. {
  1538. int hair_style = 0;
  1539. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1540. if (!*message || sscanf(message, "%12d", &hair_style) < 1) {
  1541. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
  1542. clif->message(fd, atcmd_output);
  1543. return false;
  1544. }
  1545. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1546. pc->changelook(sd, LOOK_HAIR, hair_style);
  1547. clif->message(fd, msg_fd(fd,36)); // Appearance changed.
  1548. } else {
  1549. clif->message(fd, msg_fd(fd,37)); // An invalid number was specified.
  1550. return false;
  1551. }
  1552. return true;
  1553. }
  1554. /*==========================================
  1555. * @haircolor && @hcolor
  1556. *------------------------------------------*/
  1557. ACMD(hair_color)
  1558. {
  1559. int hair_color = 0;
  1560. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1561. if (!*message || sscanf(message, "%12d", &hair_color) < 1) {
  1562. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
  1563. clif->message(fd, atcmd_output);
  1564. return false;
  1565. }
  1566. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1567. pc->changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1568. clif->message(fd, msg_fd(fd,36)); // Appearance changed.
  1569. } else {
  1570. clif->message(fd, msg_fd(fd,37)); // An invalid number was specified.
  1571. return false;
  1572. }
  1573. return true;
  1574. }
  1575. /*==========================================
  1576. * @go [city_number or city_name] - Updated by Harbin
  1577. *------------------------------------------*/
  1578. ACMD(go) {
  1579. int town = INT_MAX; // Initialized to INT_MAX instead of -1 to avoid conflicts with those who map [-3:-1] to @memo locations.
  1580. char map_name[MAP_NAME_LENGTH];
  1581. const struct {
  1582. char map[MAP_NAME_LENGTH];
  1583. int x, y;
  1584. int min_match; ///< Minimum string length to match
  1585. } data[] = {
  1586. { MAP_PRONTERA, 156, 191, 3 }, // 0 = Prontera
  1587. { MAP_MORROC, 156, 93, 4 }, // 1 = Morroc
  1588. { MAP_GEFFEN, 119, 59, 3 }, // 2 = Geffen
  1589. { MAP_PAYON, 162, 233, 3 }, // 3 = Payon
  1590. { MAP_ALBERTA, 192, 147, 3 }, // 4 = Alberta
  1591. #ifdef RENEWAL
  1592. { MAP_IZLUDE, 128, 146, 3 }, // 5 = Izlude (Renewal)
  1593. #else
  1594. { MAP_IZLUDE, 128, 114, 3 }, // 5 = Izlude
  1595. #endif
  1596. { MAP_ALDEBARAN, 140, 131, 3 }, // 6 = Aldebaran
  1597. { MAP_LUTIE, 147, 134, 3 }, // 7 = Lutie
  1598. { MAP_COMODO, 209, 143, 3 }, // 8 = Comodo
  1599. { MAP_YUNO, 157, 51, 3 }, // 9 = Juno
  1600. { MAP_AMATSU, 198, 84, 3 }, // 10 = Amatsu
  1601. { MAP_GONRYUN, 160, 120, 3 }, // 11 = Kunlun
  1602. { MAP_UMBALA, 89, 157, 3 }, // 12 = Umbala
  1603. { MAP_NIFLHEIM, 21, 153, 3 }, // 13 = Niflheim
  1604. { MAP_LOUYANG, 217, 40, 3 }, // 14 = Luoyang
  1605. { MAP_NOVICE, 53, 111, 3 }, // 15 = Training Grounds
  1606. { MAP_JAIL, 23, 61, 3 }, // 16 = Prison
  1607. { MAP_JAWAII, 249, 127, 3 }, // 17 = Jawaii
  1608. { MAP_AYOTHAYA, 151, 117, 3 }, // 18 = Ayothaya
  1609. { MAP_EINBROCH, 64, 200, 5 }, // 19 = Einbroch
  1610. { MAP_LIGHTHALZEN, 158, 92, 3 }, // 20 = Lighthalzen
  1611. { MAP_EINBECH, 70, 95, 5 }, // 21 = Einbech
  1612. { MAP_HUGEL, 96, 145, 3 }, // 22 = Hugel
  1613. { MAP_RACHEL, 130, 110, 3 }, // 23 = Rachel
  1614. { MAP_VEINS, 216, 123, 3 }, // 24 = Veins
  1615. { MAP_MOSCOVIA, 223, 184, 3 }, // 25 = Moscovia
  1616. { MAP_MIDCAMP, 180, 240, 3 }, // 26 = Midgard Camp
  1617. { MAP_MANUK, 282, 138, 3 }, // 27 = Manuk
  1618. { MAP_SPLENDIDE, 197, 176, 3 }, // 28 = Splendide
  1619. { MAP_BRASILIS, 182, 239, 3 }, // 29 = Brasilis
  1620. { MAP_DICASTES, 198, 187, 3 }, // 30 = El Dicastes
  1621. { MAP_MORA, 44, 151, 4 }, // 31 = Mora
  1622. { MAP_DEWATA, 200, 180, 3 }, // 32 = Dewata
  1623. { MAP_MALANGDO, 140, 114, 5 }, // 33 = Malangdo Island
  1624. { MAP_MALAYA, 242, 211, 5 }, // 34 = Malaya Port
  1625. { MAP_ECLAGE, 110, 39, 3 }, // 35 = Eclage
  1626. };
  1627. memset(map_name, '\0', sizeof(map_name));
  1628. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1629. if (!*message || sscanf(message, "%11s", map_name) < 1) {
  1630. // no value matched so send the list of locations
  1631. const char* text;
  1632. // attempt to find the text help string
  1633. text = atcommand_help_string( info );
  1634. clif->message(fd, msg_fd(fd,38)); // Invalid location number, or name.
  1635. if (text) { // send the text to the client
  1636. clif->messageln( fd, text );
  1637. }
  1638. return false;
  1639. }
  1640. // Numeric entry
  1641. if (ISDIGIT(*message) || (message[0] == '-' && ISDIGIT(message[1]))) {
  1642. town = atoi(message);
  1643. }
  1644. if (town < 0 || town >= ARRAYLENGTH(data)) {
  1645. int i;
  1646. map_name[MAP_NAME_LENGTH-1] = '\0';
  1647. // Match maps on the list
  1648. for (i = 0; i < ARRAYLENGTH(data); i++) {
  1649. if (strncmpi(map_name, data[i].map, data[i].min_match) == 0) {
  1650. town = i;
  1651. break;
  1652. }
  1653. }
  1654. }
  1655. if (town < 0 || town >= ARRAYLENGTH(data)) {
  1656. // Alternate spellings
  1657. if (strncmpi(map_name, "morroc", 4) == 0) { // Correct town name for 'morocc'
  1658. town = 1;
  1659. } else if (strncmpi(map_name, "lutie", 3) == 0) { // Correct town name for 'xmas'
  1660. town = 7;
  1661. } else if (strncmpi(map_name, "juno", 3) == 0) { // Correct town name for 'yuno'
  1662. town = 9;
  1663. } else if (strncmpi(map_name, "kunlun", 3) == 0) { // Original town name for 'gonryun'
  1664. town = 11;
  1665. } else if (strncmpi(map_name, "luoyang", 3) == 0) { // Original town name for 'louyang'
  1666. town = 14;
  1667. } else if (strncmpi(map_name, "startpoint", 3) == 0 // Easy to remember alternatives to 'new_1-1'
  1668. || strncmpi(map_name, "beginning", 3) == 0) {
  1669. town = 15;
  1670. } else if (strncmpi(map_name, "prison", 3) == 0 // Easy to remember alternatives to 'sec_pri'
  1671. || strncmpi(map_name, "jail", 3) == 0) {
  1672. town = 16;
  1673. } else if (strncmpi(map_name, "rael", 3) == 0) { // Original town name for 'rachel'
  1674. town = 23;
  1675. }
  1676. }
  1677. if (town >= 0 && town < ARRAYLENGTH(data)) {
  1678. int16 m = map->mapname2mapid(data[town].map);
  1679. if (m >= 0 && map->list[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1680. clif->message(fd, msg_fd(fd,247));
  1681. return false;
  1682. }
  1683. if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1684. clif->message(fd, msg_fd(fd,248));
  1685. return false;
  1686. }
  1687. if (pc->setpos(sd, mapindex->name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1688. clif->message(fd, msg_fd(fd,0)); // Warped.
  1689. } else {
  1690. clif->message(fd, msg_fd(fd,1)); // Map not found.
  1691. return false;
  1692. }
  1693. } else {
  1694. clif->message(fd, msg_fd(fd,38)); // Invalid location number or name.
  1695. return false;
  1696. }
  1697. return true;
  1698. }
  1699. /*==========================================
  1700. *
  1701. *------------------------------------------*/
  1702. ACMD(monster)
  1703. {
  1704. char name[NAME_LENGTH];
  1705. char monster[NAME_LENGTH];
  1706. char eventname[EVENT_NAME_LENGTH] = "";
  1707. int mob_id;
  1708. int number = 0;
  1709. int count;
  1710. int i, range;
  1711. short mx, my;
  1712. unsigned int size;
  1713. memset(name, '\0', sizeof(name));
  1714. memset(monster, '\0', sizeof(monster));
  1715. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1716. if (!*message) {
  1717. clif->message(fd, msg_fd(fd,80)); // Please specify a display name or monster name/id.
  1718. return false;
  1719. }
  1720. if (sscanf(message, "\"%23[^\"]\" %23s %12d", name, monster, &number) > 1 ||
  1721. sscanf(message, "%23s \"%23[^\"]\" %12d", monster, name, &number) > 1) {
  1722. //All data can be left as it is.
  1723. } else if ((count=sscanf(message, "%23s %12d %23s", monster, &number, name)) > 1) {
  1724. //Here, it is possible name was not given and we are using monster for it.
  1725. if (count < 3) //Blank mob's name.
  1726. name[0] = '\0';
  1727. } else if (sscanf(message, "%23s %23s %12d", name, monster, &number) > 1) {
  1728. //All data can be left as it is.
  1729. } else if (sscanf(message, "%23s", monster) > 0) {
  1730. //As before, name may be already filled.
  1731. name[0] = '\0';
  1732. } else {
  1733. clif->message(fd, msg_fd(fd,80)); // Give a display name and monster name/id please.
  1734. return false;
  1735. }
  1736. if ((mob_id = mob->db_searchname(monster)) == 0) // check name first (to avoid possible name beginning by a number)
  1737. mob_id = mob->db_checkid(atoi(monster));
  1738. if (mob_id == 0) {
  1739. clif->message(fd, msg_fd(fd,40)); // Invalid monster ID or name.
  1740. return false;
  1741. }
  1742. if (number <= 0)
  1743. number = 1;
  1744. if (!name[0])
  1745. strcpy(name, "--ja--");
  1746. // 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
  1747. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1748. number = battle_config.atc_spawn_quantity_limit;
  1749. if (strcmpi(info->command, "monstersmall") == 0)
  1750. size = SZ_MEDIUM;
  1751. else if (strcmpi(info->command, "monsterbig") == 0)
  1752. size = SZ_BIG;
  1753. else
  1754. size = SZ_SMALL;
  1755. if (battle_config.etc_log)
  1756. 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);
  1757. count = 0;
  1758. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1759. for (i = 0; i < number; i++) {
  1760. int k;
  1761. map->search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1762. k = mob->once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE|(mob_id == MOBID_EMPELIUM?0x200:0x0));
  1763. count += (k != 0) ? 1 : 0;
  1764. }
  1765. if (count != 0)
  1766. if (number == count)
  1767. clif->message(fd, msg_fd(fd,39)); // All monster summoned!
  1768. else {
  1769. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,240), count); // %d monster(s) summoned!
  1770. clif->message(fd, atcmd_output);
  1771. }
  1772. else {
  1773. clif->message(fd, msg_fd(fd,40)); // Invalid monster ID or name.
  1774. return false;
  1775. }
  1776. return true;
  1777. }
  1778. /*==========================================
  1779. *
  1780. *------------------------------------------*/
  1781. int atkillmonster_sub(struct block_list *bl, va_list ap)
  1782. {
  1783. struct mob_data *md = NULL;
  1784. int flag = va_arg(ap, int);
  1785. nullpo_ret(bl);
  1786. Assert_ret(bl->type == BL_MOB);
  1787. md = BL_UCAST(BL_MOB, bl);
  1788. if (md->guardian_data)
  1789. return 0; //Do not touch WoE mobs!
  1790. if (flag)
  1791. status_zap(bl,md->status.hp, 0);
  1792. else
  1793. status_kill(bl);
  1794. return 1;
  1795. }
  1796. ACMD(killmonster) {
  1797. int map_id, drop_flag;
  1798. char map_name[MAP_NAME_LENGTH_EXT];
  1799. memset(map_name, '\0', sizeof(map_name));
  1800. if (!*message || sscanf(message, "%15s", map_name) < 1) {
  1801. map_id = sd->bl.m;
  1802. } else {
  1803. if ((map_id = map->mapname2mapid(map_name)) < 0)
  1804. map_id = sd->bl.m;
  1805. }
  1806. drop_flag = strcmpi(info->command, "killmonster2");
  1807. map->foreachinmap(atcommand->atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1808. clif->message(fd, msg_fd(fd,165)); // All monsters killed!
  1809. return true;
  1810. }
  1811. /*==========================================
  1812. *
  1813. *------------------------------------------*/
  1814. ACMD(refine)
  1815. {
  1816. int j, position = 0, refine = 0, current_position, final_refine;
  1817. int count;
  1818. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1819. if (!*message || sscanf(message, "%12d %12d", &position, &refine) < 2) {
  1820. clif->message(fd, msg_fd(fd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1821. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1822. clif->message(fd, atcmd_output);
  1823. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,998), EQP_HAND_R); // %d: Right Hand
  1824. clif->message(fd, atcmd_output);
  1825. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,999), EQP_GARMENT); // %d: Garment
  1826. clif->message(fd, atcmd_output);
  1827. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1000), EQP_ACC_L); // %d: Left Accessory
  1828. clif->message(fd, atcmd_output);
  1829. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1001), EQP_ARMOR); // %d: Body Armor
  1830. clif->message(fd, atcmd_output);
  1831. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1002), EQP_HAND_L); // %d: Left Hand
  1832. clif->message(fd, atcmd_output);
  1833. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1003), EQP_SHOES); // %d: Shoes
  1834. clif->message(fd, atcmd_output);
  1835. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1004), EQP_ACC_R); // %d: Right Accessory
  1836. clif->message(fd, atcmd_output);
  1837. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1838. clif->message(fd, atcmd_output);
  1839. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1840. clif->message(fd, atcmd_output);
  1841. return false;
  1842. }
  1843. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1844. count = 0;
  1845. for (j = 0; j < EQI_MAX; j++) {
  1846. int idx = sd->equip_index[j];
  1847. if (idx < 0)
  1848. continue;
  1849. if(j == EQI_AMMO) continue; /* can't equip ammo */
  1850. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == idx)
  1851. continue;
  1852. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == idx)
  1853. continue;
  1854. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == idx || sd->equip_index[EQI_HEAD_LOW] == idx))
  1855. continue;
  1856. if(position && !(sd->status.inventory[idx].equip & position))
  1857. continue;
  1858. final_refine = cap_value(sd->status.inventory[idx].refine + refine, 0, MAX_REFINE);
  1859. if (sd->status.inventory[idx].refine != final_refine) {
  1860. sd->status.inventory[idx].refine = final_refine;
  1861. current_position = sd->status.inventory[idx].equip;
  1862. pc->unequipitem(sd, idx, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
  1863. clif->refine(fd, 0, idx, sd->status.inventory[idx].refine);
  1864. clif->delitem(sd, idx, 1, DELITEM_MATERIALCHANGE);
  1865. clif->additem(sd, idx, 1, 0);
  1866. pc->equipitem(sd, idx, current_position);
  1867. clif->misceffect(&sd->bl, 3);
  1868. count++;
  1869. }
  1870. }
  1871. if (count == 0)
  1872. clif->message(fd, msg_fd(fd,166)); // No item has been refined.
  1873. else if (count == 1)
  1874. clif->message(fd, msg_fd(fd,167)); // 1 item has been refined.
  1875. else {
  1876. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,168), count); // %d items have been refined.
  1877. clif->message(fd, atcmd_output);
  1878. }
  1879. return true;
  1880. }
  1881. /*==========================================
  1882. *
  1883. *------------------------------------------*/
  1884. ACMD(produce)
  1885. {
  1886. char item_name[100];
  1887. int item_id, attribute = 0, star = 0;
  1888. struct item_data *item_data;
  1889. struct item tmp_item;
  1890. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1891. memset(item_name, '\0', sizeof(item_name));
  1892. if (!*message || (
  1893. sscanf(message, "\"%99[^\"]\" %12d %12d", item_name, &attribute, &star) < 1 &&
  1894. sscanf(message, "%99s %12d %12d", item_name, &attribute, &star) < 1
  1895. )) {
  1896. clif->message(fd, msg_fd(fd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1897. return false;
  1898. }
  1899. if ( (item_data = itemdb->search_name(item_name)) == NULL &&
  1900. (item_data = itemdb->exists(atoi(item_name))) == NULL ) {
  1901. clif->message(fd, msg_fd(fd,170)); //This item is not an equipment.
  1902. return false;
  1903. }
  1904. item_id = item_data->nameid;
  1905. if (itemdb->isequip2(item_data)) {
  1906. int flag = 0;
  1907. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1908. attribute = ATTRIBUTE_NORMAL;
  1909. if (star < MIN_STAR || star > MAX_STAR)
  1910. star = 0;
  1911. memset(&tmp_item, 0, sizeof tmp_item);
  1912. tmp_item.nameid = item_id;
  1913. tmp_item.amount = 1;
  1914. tmp_item.identify = 1;
  1915. tmp_item.card[0] = CARD0_FORGE;
  1916. tmp_item.card[1] = item_data->type==IT_WEAPON?
  1917. ((star*5) << 8) + attribute:0;
  1918. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  1919. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  1920. clif->produce_effect(sd, 0, item_id);
  1921. clif->misceffect(&sd->bl, 3);
  1922. if ((flag = pc->additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  1923. clif->additem(sd, 0, 0, flag);
  1924. } else {
  1925. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  1926. clif->message(fd, atcmd_output);
  1927. return false;
  1928. }
  1929. return true;
  1930. }
  1931. /*==========================================
  1932. *
  1933. *------------------------------------------*/
  1934. ACMD(memo)
  1935. {
  1936. int position = 0;
  1937. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1938. if (!*message || sscanf(message, "%d", &position) < 1)
  1939. {
  1940. int i;
  1941. clif->message(sd->fd, msg_fd(fd,868)); // "Your current memo positions are:"
  1942. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  1943. {
  1944. if( sd->status.memo_point[i].map )
  1945. safesnprintf(atcmd_output, sizeof(atcmd_output), "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  1946. else
  1947. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,171), i); // %d - void
  1948. clif->message(sd->fd, atcmd_output);
  1949. }
  1950. return true;
  1951. }
  1952. if( position < 0 || position >= MAX_MEMOPOINTS )
  1953. {
  1954. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  1955. clif->message(fd, atcmd_output);
  1956. return false;
  1957. }
  1958. pc->memo(sd, position);
  1959. return true;
  1960. }
  1961. /*==========================================
  1962. *
  1963. *------------------------------------------*/
  1964. ACMD(gat) {
  1965. int y;
  1966. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1967. for (y = 2; y >= -2; y--) {
  1968. safesnprintf(atcmd_output, sizeof(atcmd_output), "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  1969. map->list[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  1970. map->getcell(sd->bl.m, &sd->bl, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  1971. map->getcell(sd->bl.m, &sd->bl, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  1972. map->getcell(sd->bl.m, &sd->bl, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  1973. map->getcell(sd->bl.m, &sd->bl, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  1974. map->getcell(sd->bl.m, &sd->bl, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  1975. clif->message(fd, atcmd_output);
  1976. }
  1977. return true;
  1978. }
  1979. /*==========================================
  1980. *
  1981. *------------------------------------------*/
  1982. ACMD(displaystatus)
  1983. {
  1984. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  1985. if (!*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  1986. clif->message(fd, msg_fd(fd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  1987. return false;
  1988. }
  1989. if (i < 2) flag = 1;
  1990. if (i < 3) tick = 0;
  1991. if( flag == 0 )
  1992. clif->sc_end(&sd->bl,sd->bl.id,AREA,type);
  1993. else
  1994. clif->status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  1995. return true;
  1996. }
  1997. /*==========================================
  1998. * @stpoint (Rewritten by [Yor])
  1999. *------------------------------------------*/
  2000. ACMD(statuspoint)
  2001. {
  2002. int point;
  2003. unsigned int new_status_point;
  2004. if (!*message || (point = atoi(message)) == 0) {
  2005. clif->message(fd, msg_fd(fd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2006. return false;
  2007. }
  2008. if(point < 0)
  2009. {
  2010. if(sd->status.status_point < (unsigned int)(-point))
  2011. {
  2012. new_status_point = 0;
  2013. }
  2014. else
  2015. {
  2016. new_status_point = sd->status.status_point + point;
  2017. }
  2018. }
  2019. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2020. {
  2021. new_status_point = UINT_MAX;
  2022. }
  2023. else
  2024. {
  2025. new_status_point = sd->status.status_point + point;
  2026. }
  2027. if (new_status_point != sd->status.status_point) {
  2028. sd->status.status_point = new_status_point;
  2029. clif->updatestatus(sd, SP_STATUSPOINT);
  2030. clif->message(fd, msg_fd(fd,174)); // Number of status points changed.
  2031. } else {
  2032. if (point < 0)
  2033. clif->message(fd, msg_fd(fd,41)); // Unable to decrease the number/value.
  2034. else
  2035. clif->message(fd, msg_fd(fd,149)); // Unable to increase the number/value.
  2036. return false;
  2037. }
  2038. return true;
  2039. }
  2040. /*==========================================
  2041. * @skpoint (Rewritten by [Yor])
  2042. *------------------------------------------*/
  2043. ACMD(skillpoint)
  2044. {
  2045. int point;
  2046. unsigned int new_skill_point;
  2047. if (!*message || (point = atoi(message)) == 0) {
  2048. clif->message(fd, msg_fd(fd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2049. return false;
  2050. }
  2051. if(point < 0)
  2052. {
  2053. if(sd->status.skill_point < (unsigned int)(-point))
  2054. {
  2055. new_skill_point = 0;
  2056. }
  2057. else
  2058. {
  2059. new_skill_point = sd->status.skill_point + point;
  2060. }
  2061. }
  2062. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2063. {
  2064. new_skill_point = UINT_MAX;
  2065. }
  2066. else
  2067. {
  2068. new_skill_point = sd->status.skill_point + point;
  2069. }
  2070. if (new_skill_point != sd->status.skill_point) {
  2071. sd->status.skill_point = new_skill_point;
  2072. clif->updatestatus(sd, SP_SKILLPOINT);
  2073. clif->message(fd, msg_fd(fd,175)); // Number of skill points changed.
  2074. } else {
  2075. if (point < 0)
  2076. clif->message(fd, msg_fd(fd,41)); // Unable to decrease the number/value.
  2077. else
  2078. clif->message(fd, msg_fd(fd,149)); // Unable to increase the number/value.
  2079. return false;
  2080. }
  2081. return true;
  2082. }
  2083. /*==========================================
  2084. * @zeny
  2085. *------------------------------------------*/
  2086. ACMD(zeny)
  2087. {
  2088. int zeny=0, ret=-1;
  2089. if (!*message || (zeny = atoi(message)) == 0) {
  2090. clif->message(fd, msg_fd(fd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2091. return false;
  2092. }
  2093. if(zeny > 0) {
  2094. if((ret=pc->getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2095. clif->message(fd, msg_fd(fd,149)); // Unable to increase the number/value.
  2096. }
  2097. else {
  2098. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2099. if((ret=pc->payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2100. clif->message(fd, msg_fd(fd,41)); // Unable to decrease the number/value.
  2101. }
  2102. if( ret ) //ret != 0 means cmd failure
  2103. return false;
  2104. clif->message(fd, msg_fd(fd,176));
  2105. return true;
  2106. }
  2107. /*==========================================
  2108. *
  2109. *------------------------------------------*/
  2110. ACMD(param) {
  2111. int i, value = 0, new_value, max;
  2112. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2113. short* stats[6];
  2114. //we don't use direct initialization because it isn't part of the c standard.
  2115. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2116. if (!*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2117. clif->message(fd, msg_fd(fd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2118. return false;
  2119. }
  2120. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(info->command, param[i]) == 0 );
  2121. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2122. clif->message(fd, msg_fd(fd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2123. return false;
  2124. }
  2125. stats[0] = &sd->status.str;
  2126. stats[1] = &sd->status.agi;
  2127. stats[2] = &sd->status.vit;
  2128. stats[3] = &sd->status.int_;
  2129. stats[4] = &sd->status.dex;
  2130. stats[5] = &sd->status.luk;
  2131. if( battle_config.atcommand_max_stat_bypass )
  2132. max = SHRT_MAX;
  2133. else
  2134. max = pc_maxparameter(sd);
  2135. if(value < 0 && *stats[i] <= -value) {
  2136. new_value = 1;
  2137. } else if(max - *stats[i] < value) {
  2138. new_value = max;
  2139. } else {
  2140. new_value = *stats[i] + value;
  2141. }
  2142. if (new_value != *stats[i]) {
  2143. *stats[i] = new_value;
  2144. clif->updatestatus(sd, SP_STR + i);
  2145. clif->updatestatus(sd, SP_USTR + i);
  2146. status_calc_pc(sd, SCO_FORCE);
  2147. clif->message(fd, msg_fd(fd,42)); // Stat changed.
  2148. } else {
  2149. if (value < 0)
  2150. clif->message(fd, msg_fd(fd,41)); // Unable to decrease the number/value.
  2151. else
  2152. clif->message(fd, msg_fd(fd,149)); // Unable to increase the number/value.
  2153. return false;
  2154. }
  2155. return true;
  2156. }
  2157. /*==========================================
  2158. * Stat all by fritz (rewritten by [Yor])
  2159. *------------------------------------------*/
  2160. ACMD(stat_all) {
  2161. int index, count, value, max, new_value;
  2162. short* stats[6];
  2163. //we don't use direct initialization because it isn't part of the c standard.
  2164. stats[0] = &sd->status.str;
  2165. stats[1] = &sd->status.agi;
  2166. stats[2] = &sd->status.vit;
  2167. stats[3] = &sd->status.int_;
  2168. stats[4] = &sd->status.dex;
  2169. stats[5] = &sd->status.luk;
  2170. if (!*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2171. value = pc_maxparameter(sd);
  2172. max = pc_maxparameter(sd);
  2173. } else {
  2174. if( battle_config.atcommand_max_stat_bypass )
  2175. max = SHRT_MAX;
  2176. else
  2177. max = pc_maxparameter(sd);
  2178. }
  2179. count = 0;
  2180. for (index = 0; index < ARRAYLENGTH(stats); index++) {
  2181. if (value > 0 && *stats[index] > max - value)
  2182. new_value = max;
  2183. else if (value < 0 && *stats[index] <= -value)
  2184. new_value = 1;
  2185. else
  2186. new_value = *stats[index] +value;
  2187. if (new_value != (int)*stats[index]) {
  2188. *stats[index] = new_value;
  2189. clif->updatestatus(sd, SP_STR + index);
  2190. clif->updatestatus(sd, SP_USTR + index);
  2191. count++;
  2192. }
  2193. }
  2194. if (count > 0) { // if at least 1 stat modified
  2195. status_calc_pc(sd, SCO_FORCE);
  2196. clif->message(fd, msg_fd(fd,84)); // All stats changed!
  2197. } else {
  2198. if (value < 0)
  2199. clif->message(fd, msg_fd(fd,177)); // You cannot decrease that stat anymore.
  2200. else
  2201. clif->message(fd, msg_fd(fd,178)); // You cannot increase that stat anymore.
  2202. return false;
  2203. }
  2204. return true;
  2205. }
  2206. /*==========================================
  2207. *
  2208. *------------------------------------------*/
  2209. ACMD(guildlevelup) {
  2210. int level = 0;
  2211. int16 added_level;
  2212. struct guild *guild_info;
  2213. if (!*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2214. clif->message(fd, msg_fd(fd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2215. return false;
  2216. }
  2217. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2218. clif->message(fd, msg_fd(fd,43)); // You're not in a guild.
  2219. return false;
  2220. }
  2221. #if 0 // By enabling this, only the guild leader can use this command
  2222. if (strcmp(sd->status.name, guild_info->master) != 0) {
  2223. clif->message(fd, msg_fd(fd,44)); // You're not the master of your guild.
  2224. return false;
  2225. }
  2226. #endif // 0
  2227. if (level > INT16_MAX || (level > 0 && level > MAX_GUILDLEVEL - guild_info->guild_lv)) // fix positive overflow
  2228. level = MAX_GUILDLEVEL - guild_info->guild_lv;
  2229. else if (level < INT16_MIN || (level < 0 && level < 1 - guild_info->guild_lv)) // fix negative overflow
  2230. level = 1 - guild_info->guild_lv;
  2231. added_level = (int16)level;
  2232. if (added_level != 0) {
  2233. intif->guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2234. clif->message(fd, msg_fd(fd,179)); // Guild level changed.
  2235. } else {
  2236. clif->message(fd, msg_fd(fd,45)); // Guild level change failed.
  2237. return false;
  2238. }
  2239. return true;
  2240. }
  2241. /*==========================================
  2242. *
  2243. *------------------------------------------*/
  2244. ACMD(makeegg)
  2245. {
  2246. struct item_data *item_data;
  2247. int id, pet_id;
  2248. if (!*message) {
  2249. clif->message(fd, msg_fd(fd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2250. return false;
  2251. }
  2252. if ((item_data = itemdb->search_name(message)) != NULL) // for egg name
  2253. id = item_data->nameid;
  2254. else
  2255. if ((id = mob->db_searchname(message)) != 0) // for monster name
  2256. ;
  2257. else
  2258. id = atoi(message);
  2259. pet_id = pet->search_petDB_index(id, PET_CLASS);
  2260. if (pet_id < 0)
  2261. pet_id = pet->search_petDB_index(id, PET_EGG);
  2262. if (pet_id >= 0) {
  2263. sd->catch_target_class = pet->db[pet_id].class_;
  2264. intif->create_pet(
  2265. sd->status.account_id, sd->status.char_id,
  2266. (short)pet->db[pet_id].class_, (short)mob->db(pet->db[pet_id].class_)->lv,
  2267. (short)pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate,
  2268. 100, 0, 1, pet->db[pet_id].jname);
  2269. } else {
  2270. clif->message(fd, msg_fd(fd,180)); // The monster/egg name/id doesn't exist.
  2271. return false;
  2272. }
  2273. return true;
  2274. }
  2275. /*==========================================
  2276. *
  2277. *------------------------------------------*/
  2278. ACMD(hatch)
  2279. {
  2280. if (sd->status.pet_id <= 0)
  2281. clif->sendegg(sd);
  2282. else {
  2283. clif->message(fd, msg_fd(fd,181)); // You already have a pet.
  2284. return false;
  2285. }
  2286. return true;
  2287. }
  2288. /*==========================================
  2289. *
  2290. *------------------------------------------*/
  2291. ACMD(petfriendly)
  2292. {
  2293. int friendly;
  2294. struct pet_data *pd;
  2295. if (!*message || (friendly = atoi(message)) < 0) {
  2296. clif->message(fd, msg_fd(fd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2297. return false;
  2298. }
  2299. pd = sd->pd;
  2300. if (!pd) {
  2301. clif->message(fd, msg_fd(fd,184)); // Sorry, but you have no pet.
  2302. return false;
  2303. }
  2304. if (friendly < 0 || friendly > 1000)
  2305. {
  2306. clif->message(fd, msg_fd(fd,37)); // An invalid number was specified.
  2307. return false;
  2308. }
  2309. if (friendly == pd->pet.intimate) {
  2310. clif->message(fd, msg_fd(fd,183)); // Pet intimacy is already at maximum.
  2311. return false;
  2312. }
  2313. pet->set_intimate(pd, friendly);
  2314. clif->send_petstatus(sd);
  2315. clif->message(fd, msg_fd(fd,182)); // Pet intimacy changed.
  2316. return true;
  2317. }
  2318. /*==========================================
  2319. *
  2320. *------------------------------------------*/
  2321. ACMD(pethungry)
  2322. {
  2323. int hungry;
  2324. struct pet_data *pd;
  2325. if (!*message || (hungry = atoi(message)) < 0) {
  2326. clif->message(fd, msg_fd(fd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2327. return false;
  2328. }
  2329. pd = sd->pd;
  2330. if (!sd->status.pet_id || !pd) {
  2331. clif->message(fd, msg_fd(fd,184)); // Sorry, but you have no pet.
  2332. return false;
  2333. }
  2334. if (hungry < 0 || hungry > 100) {
  2335. clif->message(fd, msg_fd(fd,37)); // An invalid number was specified.
  2336. return false;
  2337. }
  2338. if (hungry == pd->pet.hungry) {
  2339. clif->message(fd, msg_fd(fd,186)); // Pet hunger is already at maximum.
  2340. return false;
  2341. }
  2342. pd->pet.hungry = hungry;
  2343. clif->send_petstatus(sd);
  2344. clif->message(fd, msg_fd(fd,185)); // Pet hunger changed.
  2345. return true;
  2346. }
  2347. /*==========================================
  2348. *
  2349. *------------------------------------------*/
  2350. ACMD(petrename)
  2351. {
  2352. struct pet_data *pd;
  2353. if (!sd->status.pet_id || !sd->pd) {
  2354. clif->message(fd, msg_fd(fd,184)); // Sorry, but you have no pet.
  2355. return false;
  2356. }
  2357. pd = sd->pd;
  2358. if (!pd->pet.rename_flag) {
  2359. clif->message(fd, msg_fd(fd,188)); // You can already rename your pet.
  2360. return false;
  2361. }
  2362. pd->pet.rename_flag = 0;
  2363. intif->save_petdata(sd->status.account_id, &pd->pet);
  2364. clif->send_petstatus(sd);
  2365. clif->message(fd, msg_fd(fd,187)); // You can now rename your pet.
  2366. return true;
  2367. }
  2368. /*==========================================
  2369. *
  2370. *------------------------------------------*/
  2371. ACMD(recall) {
  2372. struct map_session_data *pl_sd = NULL;
  2373. if (!*message) {
  2374. clif->message(fd, msg_fd(fd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2375. return false;
  2376. }
  2377. if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
  2378. clif->message(fd, msg_fd(fd,3)); // Character not found.
  2379. return false;
  2380. }
  2381. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2382. {
  2383. clif->message(fd, msg_fd(fd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2384. return false;
  2385. }
  2386. if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2387. clif->message(fd, msg_fd(fd,1019)); // You are not authorized to warp someone to this map.
  2388. return false;
  2389. }
  2390. if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2391. clif->message(fd, msg_fd(fd,1020)); // You are not authorized to warp this player from their map.
  2392. return false;
  2393. }
  2394. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2395. return false;
  2396. }
  2397. pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2398. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,46), pl_sd->status.name); // %s recalled!
  2399. clif->message(fd, atcmd_output);
  2400. return true;
  2401. }
  2402. /*==========================================
  2403. * charblock command (usage: charblock <player_name>)
  2404. * This command do a definitiv ban on a player
  2405. *------------------------------------------*/
  2406. ACMD(char_block)
  2407. {
  2408. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2409. if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2410. clif->message(fd, msg_fd(fd,1021)); // Please enter a player name (usage: @block <char name>).
  2411. return false;
  2412. }
  2413. chrif->char_ask_name(sd->status.account_id, atcmd_player_name, CHAR_ASK_NAME_BLOCK, 0, 0, 0, 0, 0, 0);
  2414. clif->message(fd, msg_fd(fd,88)); // Character name sent to char-server to ask it.
  2415. return true;
  2416. }
  2417. /*==========================================
  2418. * charban command (usage: charban <time> <player_name>)
  2419. * This command do a limited ban on a player
  2420. * Time is done as follows:
  2421. * Adjustment value (-1, 1, +1, etc...)
  2422. * Modified element:
  2423. * a or y: year
  2424. * m: month
  2425. * j or d: day
  2426. * h: hour
  2427. * mn: minute
  2428. * s: second
  2429. * <example> @ban +1m-2mn1s-6y test_player
  2430. * this example adds 1 month and 1 second, and subtracts 2 minutes and 6 years at the same time.
  2431. *------------------------------------------*/
  2432. ACMD(char_ban)
  2433. {
  2434. char *modif_p;
  2435. int year, month, day, hour, minute, second;
  2436. time_t timestamp;
  2437. struct tm *tmtime;
  2438. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2439. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2440. if (!*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2441. clif->message(fd, msg_fd(fd,1022)); // Please enter ban time and a player name (usage: @ban <time> <char name>).
  2442. return false;
  2443. }
  2444. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2445. modif_p = atcmd_output;
  2446. year = month = day = hour = minute = second = 0;
  2447. while (modif_p[0] != '\0') {
  2448. int value = atoi(modif_p);
  2449. if (value == 0)
  2450. modif_p++;
  2451. else {
  2452. if (modif_p[0] == '-' || modif_p[0] == '+')
  2453. modif_p++;
  2454. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2455. modif_p++;
  2456. if (modif_p[0] == 's') {
  2457. second = value;
  2458. modif_p++;
  2459. } else if (modif_p[0] == 'n') {
  2460. minute = value;
  2461. modif_p++;
  2462. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  2463. minute = value;
  2464. modif_p = modif_p + 2;
  2465. } else if (modif_p[0] == 'h') {
  2466. hour = value;
  2467. modif_p++;
  2468. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2469. day = value;
  2470. modif_p++;
  2471. } else if (modif_p[0] == 'm') {
  2472. month = value;
  2473. modif_p++;
  2474. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2475. year = value;
  2476. modif_p++;
  2477. } else if (modif_p[0] != '\0') {
  2478. modif_p++;
  2479. }
  2480. }
  2481. }
  2482. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2483. clif->message(fd, msg_fd(fd,85)); // Invalid time for ban command.
  2484. return false;
  2485. }
  2486. /**
  2487. * We now check if you can adjust the ban to negative (and if this is the case)
  2488. **/
  2489. timestamp = time(NULL);
  2490. tmtime = localtime(&timestamp);
  2491. tmtime->tm_year = tmtime->tm_year + year;
  2492. tmtime->tm_mon = tmtime->tm_mon + month;
  2493. tmtime->tm_mday = tmtime->tm_mday + day;
  2494. tmtime->tm_hour = tmtime->tm_hour + hour;
  2495. tmtime->tm_min = tmtime->tm_min + minute;
  2496. tmtime->tm_sec = tmtime->tm_sec + second;
  2497. timestamp = mktime(tmtime);
  2498. if( timestamp <= time(NULL) && !pc->can_use_command(sd, "@unban") ) {
  2499. clif->message(fd,msg_fd(fd,1023)); // You are not allowed to reduce the length of a ban.
  2500. return false;
  2501. }
  2502. chrif->char_ask_name(sd->status.account_id, atcmd_player_name,
  2503. !strcmpi(info->command,"charban") ? CHAR_ASK_NAME_CHARBAN : CHAR_ASK_NAME_BAN, year, month, day, hour, minute, second);
  2504. clif->message(fd, msg_fd(fd,88)); // Character name sent to char-server to ask it.
  2505. return true;
  2506. }
  2507. /*==========================================
  2508. * charunblock command (usage: charunblock <player_name>)
  2509. *------------------------------------------*/
  2510. ACMD(char_unblock)
  2511. {
  2512. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2513. if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2514. clif->message(fd, msg_fd(fd,1024)); // Please enter a player name (usage: @unblock <char name>).
  2515. return false;
  2516. }
  2517. // send answer to login server via char-server
  2518. chrif->char_ask_name(sd->status.account_id, atcmd_player_name, CHAR_ASK_NAME_UNBLOCK, 0, 0, 0, 0, 0, 0);
  2519. clif->message(fd, msg_fd(fd,88)); // Character name sent to char-server to ask it.
  2520. return true;
  2521. }
  2522. /*==========================================
  2523. * charunban command (usage: charunban <player_name>)
  2524. *------------------------------------------*/
  2525. ACMD(char_unban)
  2526. {
  2527. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2528. if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2529. clif->message(fd, msg_fd(fd,1025)); // Please enter a player name (usage: @unban <char name>).
  2530. return false;
  2531. }
  2532. // send answer to login server via char-server
  2533. chrif->char_ask_name(sd->status.account_id, atcmd_player_name,
  2534. !strcmpi(info->command,"charunban") ? CHAR_ASK_NAME_CHARUNBAN : CHAR_ASK_NAME_UNBAN, 0, 0, 0, 0, 0, 0);
  2535. clif->message(fd, msg_fd(fd,88)); // Character name sent to char-server to ask it.
  2536. return true;
  2537. }
  2538. /*==========================================
  2539. *
  2540. *------------------------------------------*/
  2541. ACMD(night)
  2542. {
  2543. if (map->night_flag != 1) {
  2544. pc->map_night_timer(pc->night_timer_tid, 0, 0, 1);
  2545. } else {
  2546. clif->message(fd, msg_fd(fd,89)); // Night mode is already enabled.
  2547. return false;
  2548. }
  2549. return true;
  2550. }
  2551. /*==========================================
  2552. *
  2553. *------------------------------------------*/
  2554. ACMD(day)
  2555. {
  2556. if (map->night_flag != 0) {
  2557. pc->map_day_timer(pc->day_timer_tid, 0, 0, 1);
  2558. } else {
  2559. clif->message(fd, msg_fd(fd,90)); // Day mode is already enabled.
  2560. return false;
  2561. }
  2562. return true;
  2563. }
  2564. /*==========================================
  2565. *
  2566. *------------------------------------------*/
  2567. ACMD(doom)
  2568. {
  2569. struct map_session_data* pl_sd;
  2570. struct s_mapiterator* iter;
  2571. iter = mapit_getallusers();
  2572. for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) {
  2573. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) {
  2574. status_kill(&pl_sd->bl);
  2575. clif->specialeffect(&pl_sd->bl,450,AREA);
  2576. clif->message(pl_sd->fd, msg_fd(fd,61)); // The holy messenger has given judgment.
  2577. }
  2578. }
  2579. mapit->free(iter);
  2580. clif->message(fd, msg_fd(fd,62)); // Judgment was made.
  2581. return true;
  2582. }
  2583. /*==========================================
  2584. *
  2585. *------------------------------------------*/
  2586. ACMD(doommap)
  2587. {
  2588. struct map_session_data* pl_sd;
  2589. struct s_mapiterator* iter;
  2590. iter = mapit_getallusers();
  2591. for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) {
  2592. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) {
  2593. status_kill(&pl_sd->bl);
  2594. clif->specialeffect(&pl_sd->bl,450,AREA);
  2595. clif->message(pl_sd->fd, msg_fd(fd,61)); // The holy messenger has given judgment.
  2596. }
  2597. }
  2598. mapit->free(iter);
  2599. clif->message(fd, msg_fd(fd,62)); // Judgment was made.
  2600. return true;
  2601. }
  2602. /*==========================================
  2603. *
  2604. *------------------------------------------*/
  2605. void atcommand_raise_sub(struct map_session_data* sd)
  2606. {
  2607. nullpo_retv(sd);
  2608. status->revive(&sd->bl, 100, 100);
  2609. clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2610. clif->message(sd->fd, msg_sd(sd,63)); // Mercy has been shown.
  2611. }
  2612. /*==========================================
  2613. *
  2614. *------------------------------------------*/
  2615. ACMD(raise)
  2616. {
  2617. struct map_session_data* pl_sd;
  2618. struct s_mapiterator* iter;
  2619. iter = mapit_getallusers();
  2620. for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter)))
  2621. if( pc_isdead(pl_sd) )
  2622. atcommand->raise_sub(pl_sd);
  2623. mapit->free(iter);
  2624. clif->message(fd, msg_fd(fd,64)); // Mercy has been granted.
  2625. return true;
  2626. }
  2627. /*==========================================
  2628. *
  2629. *------------------------------------------*/
  2630. ACMD(raisemap)
  2631. {
  2632. struct map_session_data* pl_sd;
  2633. struct s_mapiterator* iter;
  2634. iter = mapit_getallusers();
  2635. for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter)))
  2636. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2637. atcommand->raise_sub(pl_sd);
  2638. mapit->free(iter);
  2639. clif->message(fd, msg_fd(fd,64)); // Mercy has been granted.
  2640. return true;
  2641. }
  2642. /*==========================================
  2643. *
  2644. *------------------------------------------*/
  2645. ACMD(kick)
  2646. {
  2647. struct map_session_data *pl_sd;
  2648. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2649. if (!*message) {
  2650. clif->message(fd, msg_fd(fd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2651. return false;
  2652. }
  2653. if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
  2654. clif->message(fd, msg_fd(fd,3)); // Character not found.
  2655. return false;
  2656. }
  2657. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  2658. {
  2659. clif->message(fd, msg_fd(fd,81)); // Your GM level don't authorize you to do this action on this player.
  2660. return false;
  2661. }
  2662. clif->GM_kick(sd, pl_sd);
  2663. return true;
  2664. }
  2665. /*==========================================
  2666. *
  2667. *------------------------------------------*/
  2668. ACMD(kickall)
  2669. {
  2670. struct map_session_data* pl_sd;
  2671. struct s_mapiterator* iter;
  2672. iter = mapit_getallusers();
  2673. for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) {
  2674. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2675. if (sd->status.account_id != pl_sd->status.account_id)
  2676. clif->GM_kick(NULL, pl_sd);
  2677. }
  2678. }
  2679. mapit->free(iter);
  2680. clif->message(fd, msg_fd(fd,195)); // All players have been kicked!
  2681. return true;
  2682. }
  2683. /*==========================================
  2684. *
  2685. *------------------------------------------*/
  2686. ACMD(allskill)
  2687. {
  2688. pc->allskillup(sd); // all skills
  2689. sd->status.skill_point = 0; // 0 skill points
  2690. clif->updatestatus(sd, SP_SKILLPOINT); // update
  2691. clif->message(fd, msg_fd(fd,76)); // All skills have been added to your skill tree.
  2692. return true;
  2693. }
  2694. /*==========================================
  2695. *
  2696. *------------------------------------------*/
  2697. ACMD(questskill)
  2698. {
  2699. uint16 skill_id, index;
  2700. if (!*message || (skill_id = atoi(message)) <= 0)
  2701. { // also send a list of skills applicable to this command
  2702. const char* text;
  2703. // attempt to find the text corresponding to this command
  2704. text = atcommand_help_string( info );
  2705. // send the error message as always
  2706. clif->message(fd, msg_fd(fd,1027)); // Please enter a quest skill number.
  2707. if( text ) {// send the skill ID list associated with this command
  2708. clif->messageln( fd, text );
  2709. }
  2710. return false;
  2711. }
  2712. if( !(index = skill->get_index(skill_id)) ) {
  2713. clif->message(fd, msg_fd(fd,198)); // This skill number doesn't exist.
  2714. return false;
  2715. }
  2716. if (!(skill->get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2717. clif->message(fd, msg_fd(fd,197)); // This skill number doesn't exist or isn't a quest skill.
  2718. return false;
  2719. }
  2720. if (pc->checkskill2(sd, index) > 0) {
  2721. clif->message(fd, msg_fd(fd,196)); // You already have this quest skill.
  2722. return false;
  2723. }
  2724. pc->skill(sd, skill_id, 1, SKILL_GRANT_PERMANENT);
  2725. clif->message(fd, msg_fd(fd,70)); // You have learned the skill.
  2726. return true;
  2727. }
  2728. /*==========================================
  2729. *
  2730. *------------------------------------------*/
  2731. ACMD(lostskill)
  2732. {
  2733. uint16 skill_id, index;
  2734. if (!*message || (skill_id = atoi(message)) <= 0)
  2735. { // also send a list of skills applicable to this command
  2736. const char* text;
  2737. // attempt to find the text corresponding to this command
  2738. text = atcommand_help_string( info );
  2739. // send the error message as always
  2740. clif->message(fd, msg_fd(fd,1027)); // Please enter a quest skill number.
  2741. if( text ) {// send the skill ID list associated with this command
  2742. clif->messageln( fd, text );
  2743. }
  2744. return false;
  2745. }
  2746. if (!( index = skill->get_index(skill_id))) {
  2747. clif->message(fd, msg_fd(fd,198)); // This skill number doesn't exist.
  2748. return false;
  2749. }
  2750. if (!(skill->get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2751. clif->message(fd, msg_fd(fd,197)); // This skill number doesn't exist or isn't a quest skill.
  2752. return false;
  2753. }
  2754. if (pc->checkskill2(sd, index) == 0) {
  2755. clif->message(fd, msg_fd(fd,201)); // You don't have this quest skill.
  2756. return false;
  2757. }
  2758. sd->status.skill[index].lv = 0;
  2759. sd->status.skill[index].flag = 0;
  2760. clif->deleteskill(sd,skill_id);
  2761. clif->message(fd, msg_fd(fd,71)); // You have forgotten the skill.
  2762. return true;
  2763. }
  2764. /*==========================================
  2765. *
  2766. *------------------------------------------*/
  2767. ACMD(spiritball)
  2768. {
  2769. int max_spiritballs;
  2770. int number;
  2771. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2772. if (!*message || (number = atoi(message)) < 0 || number > max_spiritballs)
  2773. {
  2774. char msg[CHAT_SIZE_MAX];
  2775. safesnprintf(msg, sizeof(msg), msg_fd(fd,1028), max_spiritballs); // Please enter an amount (usage: @spiritball <number: 0-%d>).
  2776. clif->message(fd, msg);
  2777. return false;
  2778. }
  2779. if( sd->spiritball > 0 )
  2780. pc->delspiritball(sd, sd->spiritball, 1);
  2781. sd->spiritball = number;
  2782. clif->spiritball(&sd->bl);
  2783. // no message, player can look the difference
  2784. return true;
  2785. }
  2786. /*==========================================
  2787. *
  2788. *------------------------------------------*/
  2789. ACMD(party)
  2790. {
  2791. char party_name[NAME_LENGTH];
  2792. memset(party_name, '\0', sizeof(party_name));
  2793. if (!*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  2794. clif->message(fd, msg_fd(fd,1029)); // Please enter a party name (usage: @party <party_name>).
  2795. return false;
  2796. }
  2797. party->create(sd, party_name, 0, 0);
  2798. return true;
  2799. }
  2800. /*==========================================
  2801. *
  2802. *------------------------------------------*/
  2803. ACMD(guild)
  2804. {
  2805. char guild_name[NAME_LENGTH];
  2806. int prev;
  2807. memset(guild_name, '\0', sizeof(guild_name));
  2808. if (!*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  2809. clif->message(fd, msg_fd(fd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2810. return false;
  2811. }
  2812. prev = battle_config.guild_emperium_check;
  2813. battle_config.guild_emperium_check = 0;
  2814. guild->create(sd, guild_name);
  2815. battle_config.guild_emperium_check = prev;
  2816. return true;
  2817. }
  2818. ACMD(breakguild)
  2819. {
  2820. if (sd->status.guild_id) { // Check if the player has a guild
  2821. struct guild *g = sd->guild; // Search the guild
  2822. if (g) { // Check if guild was found
  2823. if (sd->state.gmaster_flag) { // Check if player is guild master
  2824. int ret = 0;
  2825. ret = guild->dobreak(sd, g->name); // Break guild
  2826. if (ret) { // Check if anything went wrong
  2827. return true; // Guild was broken
  2828. } else {
  2829. return false; // Something went wrong
  2830. }
  2831. } else { // Not guild master
  2832. clif->message(fd, msg_fd(fd,1181)); // You need to be a Guild Master to use this command.
  2833. return false;
  2834. }
  2835. } else { // Guild was not found. HOW?
  2836. clif->message(fd, msg_fd(fd,252)); // You are not in a guild.
  2837. return false;
  2838. }
  2839. } else { // Player does not have a guild
  2840. clif->message(fd, msg_fd(fd,252)); // You are not in a guild.
  2841. return false;
  2842. }
  2843. return true;
  2844. }
  2845. /*==========================================
  2846. *
  2847. *------------------------------------------*/
  2848. ACMD(agitstart) {
  2849. if (map->agit_flag == 1) {
  2850. clif->message(fd, msg_fd(fd,73)); // War of Emperium is currently in progress.
  2851. return false;
  2852. }
  2853. map->agit_flag = 1;
  2854. guild->agit_start();
  2855. clif->message(fd, msg_fd(fd,72)); // War of Emperium has been initiated.
  2856. return true;
  2857. }
  2858. /*==========================================
  2859. *
  2860. *------------------------------------------*/
  2861. ACMD(agitstart2) {
  2862. if (map->agit2_flag == 1) {
  2863. clif->message(fd, msg_fd(fd,404)); // "War of Emperium SE is currently in progress."
  2864. return false;
  2865. }
  2866. map->agit2_flag = 1;
  2867. guild->agit2_start();
  2868. clif->message(fd, msg_fd(fd,403)); // "War of Emperium SE has been initiated."
  2869. return true;
  2870. }
  2871. /*==========================================
  2872. *
  2873. *------------------------------------------*/
  2874. ACMD(agitend) {
  2875. if (map->agit_flag == 0) {
  2876. clif->message(fd, msg_fd(fd,75)); // War of Emperium is currently not in progress.
  2877. return false;
  2878. }
  2879. map->agit_flag = 0;
  2880. guild->agit_end();
  2881. clif->message(fd, msg_fd(fd,74)); // War of Emperium has been ended.
  2882. return true;
  2883. }
  2884. /*==========================================
  2885. *
  2886. *------------------------------------------*/
  2887. ACMD(agitend2) {
  2888. if (map->agit2_flag == 0) {
  2889. clif->message(fd, msg_fd(fd,406)); // "War of Emperium SE is currently not in progress."
  2890. return false;
  2891. }
  2892. map->agit2_flag = 0;
  2893. guild->agit2_end();
  2894. clif->message(fd, msg_fd(fd,405)); // "War of Emperium SE has been ended."
  2895. return true;
  2896. }
  2897. /*==========================================
  2898. * @mapexit - shuts down the map server
  2899. *------------------------------------------*/
  2900. ACMD(mapexit) {
  2901. map->do_shutdown();
  2902. return true;
  2903. }
  2904. /*==========================================
  2905. * idsearch <part_of_name>: rewrite by [Yor]
  2906. *------------------------------------------*/
  2907. ACMD(idsearch)
  2908. {
  2909. char item_name[100];
  2910. unsigned int i, match;
  2911. struct item_data *item_array[MAX_SEARCH];
  2912. memset(item_name, '\0', sizeof(item_name));
  2913. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2914. if (!*message || sscanf(message, "%99s", item_name) < 0) {
  2915. clif->message(fd, msg_fd(fd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  2916. return false;
  2917. }
  2918. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,77), item_name); // Search results for '%s' (name: id):
  2919. clif->message(fd, atcmd_output);
  2920. match = itemdb->search_name_array(item_array, MAX_SEARCH, item_name, 0);
  2921. if (match > MAX_SEARCH) {
  2922. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,269), MAX_SEARCH, match);
  2923. clif->message(fd, atcmd_output);
  2924. match = MAX_SEARCH;
  2925. }
  2926. for(i = 0; i < match; i++) {
  2927. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  2928. clif->message(fd, atcmd_output);
  2929. }
  2930. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,79), match); // %d results found.
  2931. clif->message(fd, atcmd_output);
  2932. return true;
  2933. }
  2934. /*==========================================
  2935. * Recall All Characters Online To Your Location
  2936. *------------------------------------------*/
  2937. ACMD(recallall)
  2938. {
  2939. struct map_session_data* pl_sd;
  2940. struct s_mapiterator* iter;
  2941. int count;
  2942. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2943. if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2944. clif->message(fd, msg_fd(fd,1032)); // You are not authorized to warp someone to your current map.
  2945. return false;
  2946. }
  2947. count = 0;
  2948. iter = mapit_getallusers();
  2949. for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) {
  2950. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) {
  2951. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  2952. continue; // Don't waste time warping the character to the same place.
  2953. if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  2954. count++;
  2955. else {
  2956. if (pc_isdead(pl_sd)) { //Wake them up
  2957. pc->setstand(pl_sd);
  2958. pc->setrestartvalue(pl_sd,1);
  2959. }
  2960. pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2961. }
  2962. }
  2963. }
  2964. mapit->free(iter);
  2965. clif->message(fd, msg_fd(fd,92)); // All characters recalled!
  2966. if (count) {
  2967. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  2968. clif->message(fd, atcmd_output);
  2969. }
  2970. return true;
  2971. }
  2972. /*==========================================
  2973. * Recall online characters of a guild to your location
  2974. *------------------------------------------*/
  2975. ACMD(guildrecall)
  2976. {
  2977. struct map_session_data* pl_sd;
  2978. struct s_mapiterator* iter;
  2979. int count;
  2980. char guild_name[NAME_LENGTH];
  2981. struct guild *g;
  2982. memset(guild_name, '\0', sizeof(guild_name));
  2983. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2984. if (!*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  2985. clif->message(fd, msg_fd(fd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  2986. return false;
  2987. }
  2988. if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2989. clif->message(fd, msg_fd(fd,1032)); // You are not authorized to warp someone to your current map.
  2990. return false;
  2991. }
  2992. if ((g = guild->searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  2993. (g = guild->search(atoi(message))) == NULL)
  2994. {
  2995. clif->message(fd, msg_fd(fd,94)); // Incorrect name/ID, or no one from the guild is online.
  2996. return false;
  2997. }
  2998. count = 0;
  2999. iter = mapit_getallusers();
  3000. for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) {
  3001. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id) {
  3002. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
  3003. continue; // Skip GMs greater than you... or chars already on the cell
  3004. if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3005. count++;
  3006. else
  3007. pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3008. }
  3009. }
  3010. mapit->free(iter);
  3011. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3012. clif->message(fd, atcmd_output);
  3013. if (count) {
  3014. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3015. clif->message(fd, atcmd_output);
  3016. }
  3017. return true;
  3018. }
  3019. /*==========================================
  3020. * Recall online characters of a party to your location
  3021. *------------------------------------------*/
  3022. ACMD(partyrecall)
  3023. {
  3024. struct map_session_data* pl_sd;
  3025. struct s_mapiterator* iter;
  3026. char party_name[NAME_LENGTH];
  3027. struct party_data *p;
  3028. int count;
  3029. memset(party_name, '\0', sizeof(party_name));
  3030. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3031. if (!*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3032. clif->message(fd, msg_fd(fd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3033. return false;
  3034. }
  3035. if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3036. clif->message(fd, msg_fd(fd,1032)); // You are not authorized to warp someone to your current map.
  3037. return false;
  3038. }
  3039. if ((p = party->searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3040. (p = party->search(atoi(message))) == NULL)
  3041. {
  3042. clif->message(fd, msg_fd(fd,96)); // Incorrect name or ID, or no one from the party is online.
  3043. return false;
  3044. }
  3045. count = 0;
  3046. iter = mapit_getallusers();
  3047. for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) {
  3048. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id) {
  3049. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
  3050. continue; // Skip GMs greater than you... or chars already on the cell
  3051. if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3052. count++;
  3053. else
  3054. pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3055. }
  3056. }
  3057. mapit->free(iter);
  3058. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3059. clif->message(fd, atcmd_output);
  3060. if (count) {
  3061. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3062. clif->message(fd, atcmd_output);
  3063. }
  3064. return true;
  3065. }
  3066. /*==========================================
  3067. *
  3068. *------------------------------------------*/
  3069. ACMD(reloaditemdb)
  3070. {
  3071. itemdb->reload();
  3072. clif->message(fd, msg_fd(fd,97)); // Item database has been reloaded.
  3073. return true;
  3074. }
  3075. /*==========================================
  3076. *
  3077. *------------------------------------------*/
  3078. ACMD(reloadmobdb) {
  3079. mob->reload();
  3080. pet->read_db();
  3081. homun->reload();
  3082. mercenary->read_db();
  3083. mercenary->read_skilldb();
  3084. elemental->reload_db();
  3085. clif->message(fd, msg_fd(fd,98)); // Monster database has been reloaded.
  3086. return true;
  3087. }
  3088. /*==========================================
  3089. *
  3090. *------------------------------------------*/
  3091. ACMD(reloadskilldb)
  3092. {
  3093. skill->reload();
  3094. homun->reload_skill();
  3095. elemental->reload_skilldb();
  3096. mercenary->read_skilldb();
  3097. clif->message(fd, msg_fd(fd,99)); // Skill database has been reloaded.
  3098. return true;
  3099. }
  3100. /*==========================================
  3101. * @reloadatcommand - reloads conf/atcommand.conf conf/groups.conf
  3102. *------------------------------------------*/
  3103. ACMD(reloadatcommand) {
  3104. config_t run_test;
  3105. if (libconfig->read_file(&run_test, "conf/groups.conf")) {
  3106. clif->message(fd, msg_fd(fd,1036)); // Error reading groups.conf, reload failed.
  3107. return false;
  3108. }
  3109. libconfig->destroy(&run_test);
  3110. if (libconfig->read_file(&run_test, map->ATCOMMAND_CONF_FILENAME)) {
  3111. clif->message(fd, msg_fd(fd,1037)); // Error reading atcommand.conf, reload failed.
  3112. return false;
  3113. }
  3114. libconfig->destroy(&run_test);
  3115. atcommand->doload();
  3116. pcg->reload();
  3117. clif->message(fd, msg_fd(fd,254));
  3118. return true;
  3119. }
  3120. /*==========================================
  3121. * @reloadbattleconf - reloads /conf/battle.conf
  3122. *------------------------------------------*/
  3123. ACMD(reloadbattleconf)
  3124. {
  3125. struct Battle_Config prev_config;
  3126. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3127. battle->config_read(map->BATTLE_CONF_FILENAME);
  3128. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3129. || prev_config.item_rate_common != battle_config.item_rate_common
  3130. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3131. || prev_config.item_rate_card != battle_config.item_rate_card
  3132. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3133. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3134. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3135. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3136. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3137. || prev_config.item_rate_use != battle_config.item_rate_use
  3138. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3139. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3140. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3141. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3142. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3143. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3144. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3145. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3146. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3147. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3148. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3149. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3150. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3151. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3152. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3153. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3154. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3155. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3156. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3157. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3158. ) { // Exp or Drop rates changed.
  3159. mob->reload(); //Needed as well so rate changes take effect.
  3160. chrif->ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3161. }
  3162. clif->message(fd, msg_fd(fd,255));
  3163. return true;
  3164. }
  3165. /*==========================================
  3166. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3167. *------------------------------------------*/
  3168. ACMD(reloadstatusdb) {
  3169. status->readdb();
  3170. clif->message(fd, msg_fd(fd,256));
  3171. return true;
  3172. }
  3173. /*==========================================
  3174. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3175. *------------------------------------------*/
  3176. ACMD(reloadpcdb)
  3177. {
  3178. pc->readdb();
  3179. clif->message(fd, msg_fd(fd,257));
  3180. return true;
  3181. }
  3182. /*==========================================
  3183. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3184. *------------------------------------------*/
  3185. ACMD(reloadscript) {
  3186. struct s_mapiterator* iter;
  3187. struct map_session_data* pl_sd;
  3188. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3189. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3190. iter = mapit_getallusers();
  3191. for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) {
  3192. if (pl_sd->npc_id || pl_sd->npc_shopid) {
  3193. if (pl_sd->state.using_fake_npc) {
  3194. clif->clearunit_single(pl_sd->npc_id, CLR_OUTSIGHT, pl_sd->fd);
  3195. pl_sd->state.using_fake_npc = 0;
  3196. }
  3197. if (pl_sd->state.menu_or_input)
  3198. pl_sd->state.menu_or_input = 0;
  3199. if (pl_sd->npc_menu)
  3200. pl_sd->npc_menu = 0;
  3201. pl_sd->npc_id = 0;
  3202. pl_sd->npc_shopid = 0;
  3203. if (pl_sd->st && pl_sd->st->state != END)
  3204. pl_sd->st->state = END;
  3205. }
  3206. }
  3207. mapit->free(iter);
  3208. sockt->flush_fifos();
  3209. map->reloadnpc(true); // reload config files seeking for npcs
  3210. script->reload();
  3211. npc->reload();
  3212. clif->message(fd, msg_fd(fd,100)); // Scripts have been reloaded.
  3213. return true;
  3214. }
  3215. /*==========================================
  3216. * @mapinfo [0-3] <map name> by MC_Cameri
  3217. * => Shows information about the map [map name]
  3218. * 0 = no additional information
  3219. * 1 = Show users in that map and their location
  3220. * 2 = Shows NPCs in that map
  3221. * 3 = Shows the chats in that map
  3222. TODO# add the missing mapflags e.g. adjust_skill_damage to display
  3223. *------------------------------------------*/
  3224. ACMD(mapinfo)
  3225. {
  3226. const struct map_session_data *pl_sd;
  3227. struct s_mapiterator* iter;
  3228. const struct chat_data *cd = NULL;
  3229. char direction[12];
  3230. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3231. unsigned short m_index;
  3232. char mapname[24];
  3233. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3234. memset(mapname, '\0', sizeof(mapname));
  3235. memset(direction, '\0', sizeof(direction));
  3236. sscanf(message, "%12d %23[^\n]", &list, mapname);
  3237. if (list < 0 || list > 3) {
  3238. clif->message(fd, msg_fd(fd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3239. return false;
  3240. }
  3241. if (mapname[0] == '\0') {
  3242. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3243. m_id = map->mapindex2mapid(sd->mapindex);
  3244. } else {
  3245. m_id = map->mapname2mapid(mapname);
  3246. }
  3247. if (m_id < 0) {
  3248. clif->message(fd, msg_fd(fd,1)); // Map not found.
  3249. return false;
  3250. }
  3251. m_index = mapindex->name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3252. clif->message(fd, msg_fd(fd,1039)); // ------ Map Info ------
  3253. // count chats (for initial message)
  3254. chat_num = 0;
  3255. iter = mapit_getallusers();
  3256. for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_PC, mapit->next(iter))) {
  3257. if( pl_sd->mapindex == m_index ) {
  3258. if( pl_sd->state.vending )
  3259. vend_num++;
  3260. else if ((cd = map->id2cd(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd)
  3261. chat_num++;
  3262. }
  3263. }
  3264. mapit->free(iter);
  3265. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1040), mapname, map->list[m_id].zone->name, map->list[m_id].users, map->list[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
  3266. clif->message(fd, atcmd_output);
  3267. clif->message(fd, msg_fd(fd,1041)); // ------ Map Flags ------
  3268. if (map->list[m_id].flag.town)
  3269. clif->message(fd, msg_fd(fd,1042)); // Town Map
  3270. if (battle_config.autotrade_mapflag == map->list[m_id].flag.autotrade)
  3271. clif->message(fd, msg_fd(fd,1043)); // Autotrade Enabled
  3272. else
  3273. clif->message(fd, msg_fd(fd,1044)); // Autotrade Disabled
  3274. if (map->list[m_id].flag.battleground)
  3275. clif->message(fd, msg_fd(fd,1045)); // Battlegrounds ON
  3276. strcpy(atcmd_output,msg_fd(fd,1046)); // PvP Flags:
  3277. if (map->list[m_id].flag.pvp)
  3278. strcat(atcmd_output, msg_fd(fd,1047)); // Pvp ON |
  3279. if (map->list[m_id].flag.pvp_noguild)
  3280. strcat(atcmd_output, msg_fd(fd,1048)); // NoGuild |
  3281. if (map->list[m_id].flag.pvp_noparty)
  3282. strcat(atcmd_output, msg_fd(fd,1049)); // NoParty |
  3283. if (map->list[m_id].flag.pvp_nightmaredrop)
  3284. strcat(atcmd_output, msg_fd(fd,1050)); // NightmareDrop |
  3285. if (map->list[m_id].flag.pvp_nocalcrank)
  3286. strcat(atcmd_output, msg_fd(fd,1051)); // NoCalcRank |
  3287. clif->message(fd, atcmd_output);
  3288. strcpy(atcmd_output,msg_fd(fd,1052)); // GvG Flags:
  3289. if (map->list[m_id].flag.gvg)
  3290. strcat(atcmd_output, msg_fd(fd,1053)); // GvG ON |
  3291. if (map->list[m_id].flag.gvg_dungeon)
  3292. strcat(atcmd_output, msg_fd(fd,1054)); // GvG Dungeon |
  3293. if (map->list[m_id].flag.gvg_castle)
  3294. strcat(atcmd_output, msg_fd(fd,1055)); // GvG Castle |
  3295. if (map->list[m_id].flag.gvg_noparty)
  3296. strcat(atcmd_output, msg_fd(fd,1056)); // NoParty |
  3297. clif->message(fd, atcmd_output);
  3298. strcpy(atcmd_output,msg_fd(fd,1057)); // Teleport Flags:
  3299. if (map->list[m_id].flag.noteleport)
  3300. strcat(atcmd_output, msg_fd(fd,1058)); // NoTeleport |
  3301. if (map->list[m_id].flag.monster_noteleport)
  3302. strcat(atcmd_output, msg_fd(fd,1059)); // Monster NoTeleport |
  3303. if (map->list[m_id].flag.nowarp)
  3304. strcat(atcmd_output, msg_fd(fd,1060)); // NoWarp |
  3305. if (map->list[m_id].flag.nowarpto)
  3306. strcat(atcmd_output, msg_fd(fd,1061)); // NoWarpTo |
  3307. if (map->list[m_id].flag.noreturn)
  3308. strcat(atcmd_output, msg_fd(fd,1062)); // NoReturn |
  3309. if (map->list[m_id].flag.nomemo)
  3310. strcat(atcmd_output, msg_fd(fd,1064)); // NoMemo |
  3311. clif->message(fd, atcmd_output);
  3312. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3313. (map->list[m_id].flag.noexppenalty) ? msg_fd(fd,1066) : msg_fd(fd,1067),
  3314. (map->list[m_id].flag.nozenypenalty) ? msg_fd(fd,1066) : msg_fd(fd,1067)); // On / Off
  3315. clif->message(fd, atcmd_output);
  3316. if (map->list[m_id].flag.nosave) {
  3317. if (!map->list[m_id].save.map)
  3318. clif->message(fd, msg_fd(fd,1068)); // No Save (Return to last Save Point)
  3319. else if (map->list[m_id].save.x == -1 || map->list[m_id].save.y == -1 ) {
  3320. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1069), mapindex_id2name(map->list[m_id].save.map)); // No Save, Save Point: %s,Random
  3321. clif->message(fd, atcmd_output);
  3322. } else {
  3323. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1070), // No Save, Save Point: %s,%d,%d
  3324. mapindex_id2name(map->list[m_id].save.map),map->list[m_id].save.x,map->list[m_id].save.y);
  3325. clif->message(fd, atcmd_output);
  3326. }
  3327. }
  3328. strcpy(atcmd_output,msg_fd(fd,1071)); // Weather Flags:
  3329. if (map->list[m_id].flag.snow)
  3330. strcat(atcmd_output, msg_fd(fd,1072)); // Snow |
  3331. if (map->list[m_id].flag.fog)
  3332. strcat(atcmd_output, msg_fd(fd,1073)); // Fog |
  3333. if (map->list[m_id].flag.sakura)
  3334. strcat(atcmd_output, msg_fd(fd,1074)); // Sakura |
  3335. if (map->list[m_id].flag.clouds)
  3336. strcat(atcmd_output, msg_fd(fd,1075)); // Clouds |
  3337. if (map->list[m_id].flag.clouds2)
  3338. strcat(atcmd_output, msg_fd(fd,1076)); // Clouds2 |
  3339. if (map->list[m_id].flag.fireworks)
  3340. strcat(atcmd_output, msg_fd(fd,1077)); // Fireworks |
  3341. if (map->list[m_id].flag.leaves)
  3342. strcat(atcmd_output, msg_fd(fd,1078)); // Leaves |
  3343. if (map->list[m_id].flag.nightenabled)
  3344. strcat(atcmd_output, msg_fd(fd,1080)); // Displays Night |
  3345. clif->message(fd, atcmd_output);
  3346. strcpy(atcmd_output,msg_fd(fd,1081)); // Other Flags:
  3347. if (map->list[m_id].flag.nobranch)
  3348. strcat(atcmd_output, msg_fd(fd,1082)); // NoBranch |
  3349. if (map->list[m_id].flag.notrade)
  3350. strcat(atcmd_output, msg_fd(fd,1083)); // NoTrade |
  3351. if (map->list[m_id].flag.novending)
  3352. strcat(atcmd_output, msg_fd(fd,1084)); // NoVending |
  3353. if (map->list[m_id].flag.nodrop)
  3354. strcat(atcmd_output, msg_fd(fd,1085)); // NoDrop |
  3355. if (map->list[m_id].flag.noskill)
  3356. strcat(atcmd_output, msg_fd(fd,1086)); // NoSkill |
  3357. if (map->list[m_id].flag.noicewall)
  3358. strcat(atcmd_output, msg_fd(fd,1087)); // NoIcewall |
  3359. if (map->list[m_id].flag.allowks)
  3360. strcat(atcmd_output, msg_fd(fd,1088)); // AllowKS |
  3361. if (map->list[m_id].flag.reset)
  3362. strcat(atcmd_output, msg_fd(fd,1089)); // Reset |
  3363. clif->message(fd, atcmd_output);
  3364. strcpy(atcmd_output,msg_fd(fd,1090)); // Other Flags:
  3365. if (map->list[m_id].nocommand)
  3366. strcat(atcmd_output, msg_fd(fd,1091)); // NoCommand |
  3367. if (map->list[m_id].flag.nobaseexp)
  3368. strcat(atcmd_output, msg_fd(fd,1092)); // NoBaseEXP |
  3369. if (map->list[m_id].flag.nojobexp)
  3370. strcat(atcmd_output, msg_fd(fd,1093)); // NoJobEXP |
  3371. if (map->list[m_id].flag.nomobloot)
  3372. strcat(atcmd_output, msg_fd(fd,1094)); // NoMobLoot |
  3373. if (map->list[m_id].flag.nomvploot)
  3374. strcat(atcmd_output, msg_fd(fd,1095)); // NoMVPLoot |
  3375. if (map->list[m_id].flag.partylock)
  3376. strcat(atcmd_output, msg_fd(fd,1096)); // PartyLock |
  3377. if (map->list[m_id].flag.guildlock)
  3378. strcat(atcmd_output, msg_fd(fd,1097)); // GuildLock |
  3379. if (map->list[m_id].flag.noviewid != EQP_NONE)
  3380. strcat(atcmd_output, msg_fd(fd,1079)); // NoViewID |
  3381. clif->message(fd, atcmd_output);
  3382. switch (list) {
  3383. case 0:
  3384. // Do nothing. It's list 0, no additional display.
  3385. break;
  3386. case 1:
  3387. clif->message(fd, msg_fd(fd,1098)); // ----- Players in Map -----
  3388. iter = mapit_getallusers();
  3389. for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_PC, mapit->next(iter))) {
  3390. if (pl_sd->mapindex == m_index) {
  3391. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1099), // Player '%s' (session #%d) | Location: %d,%d
  3392. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3393. clif->message(fd, atcmd_output);
  3394. }
  3395. }
  3396. mapit->free(iter);
  3397. break;
  3398. case 2:
  3399. clif->message(fd, msg_fd(fd,1100)); // ----- NPCs in Map -----
  3400. for (i = 0; i < map->list[m_id].npc_num;) {
  3401. struct npc_data *nd = map->list[m_id].npc[i];
  3402. switch(nd->dir) {
  3403. case 0: strcpy(direction, msg_fd(fd,1101)); break; // North
  3404. case 1: strcpy(direction, msg_fd(fd,1102)); break; // North West
  3405. case 2: strcpy(direction, msg_fd(fd,1103)); break; // West
  3406. case 3: strcpy(direction, msg_fd(fd,1104)); break; // South West
  3407. case 4: strcpy(direction, msg_fd(fd,1105)); break; // South
  3408. case 5: strcpy(direction, msg_fd(fd,1106)); break; // South East
  3409. case 6: strcpy(direction, msg_fd(fd,1107)); break; // East
  3410. case 7: strcpy(direction, msg_fd(fd,1108)); break; // North East
  3411. case 9: strcpy(direction, msg_fd(fd,1109)); break; // North
  3412. default: strcpy(direction, msg_fd(fd,1110)); break; // Unknown
  3413. }
  3414. if(strcmp(nd->name,nd->exname) == 0)
  3415. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1111), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3416. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3417. else
  3418. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1112), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3419. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3420. clif->message(fd, atcmd_output);
  3421. }
  3422. break;
  3423. case 3:
  3424. clif->message(fd, msg_fd(fd,1113)); // ----- Chats in Map -----
  3425. iter = mapit_getallusers();
  3426. for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_PC, mapit->next(iter))) {
  3427. if ((cd = map->id2cd(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd) {
  3428. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1114), // Chat: %s | Player: %s | Location: %d %d
  3429. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3430. clif->message(fd, atcmd_output);
  3431. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1115), // Users: %d/%d | Password: %s | Public: %s
  3432. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_fd(fd,1116) : msg_fd(fd,1117)); // Yes / No
  3433. clif->message(fd, atcmd_output);
  3434. }
  3435. }
  3436. mapit->free(iter);
  3437. break;
  3438. default: // normally impossible to arrive here
  3439. clif->message(fd, msg_fd(fd,1118)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3440. return false;
  3441. }
  3442. return true;
  3443. }
  3444. /*==========================================
  3445. *
  3446. *------------------------------------------*/
  3447. ACMD(mount_peco)
  3448. {
  3449. if (sd->disguise != -1) {
  3450. clif->message(fd, msg_fd(fd,212)); // Cannot mount while in disguise.
  3451. return false;
  3452. }
  3453. if (sd->sc.data[SC_ALL_RIDING]) {
  3454. clif->message(fd, msg_fd(fd,1476)); // You are already mounting something else
  3455. return false;
  3456. }
  3457. if ((sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) {
  3458. if (!pc->checkskill(sd,RK_DRAGONTRAINING)) {
  3459. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,213), skill->get_desc(RK_DRAGONTRAINING)); // You need %s to mount!
  3460. clif->message(fd, atcmd_output);
  3461. return false;
  3462. }
  3463. if (!pc_isridingdragon(sd)) {
  3464. clif->message(sd->fd,msg_fd(fd,1119)); // You have mounted your Dragon.
  3465. pc->setridingdragon(sd, OPTION_DRAGON1);
  3466. } else {
  3467. clif->message(sd->fd,msg_fd(fd,1120)); // You have released your Dragon.
  3468. pc->setridingdragon(sd, 0);
  3469. }
  3470. return true;
  3471. }
  3472. if ((sd->class_&MAPID_THIRDMASK) == MAPID_RANGER) {
  3473. if (!pc->checkskill(sd,RA_WUGRIDER)) {
  3474. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,213), skill->get_desc(RA_WUGRIDER)); // You need %s to mount!
  3475. clif->message(fd, atcmd_output);
  3476. return false;
  3477. }
  3478. if (!pc_isridingwug(sd)) {
  3479. clif->message(sd->fd,msg_fd(fd,1121)); // You have mounted your Warg.
  3480. pc->setridingwug(sd, true);
  3481. } else {
  3482. clif->message(sd->fd,msg_fd(fd,1122)); // You have released your Warg.
  3483. pc->setridingwug(sd, false);
  3484. }
  3485. return true;
  3486. }
  3487. if ((sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC) {
  3488. if (!pc_ismadogear(sd)) {
  3489. clif->message(sd->fd,msg_fd(fd,1123)); // You have mounted your Mado Gear.
  3490. pc->setmadogear(sd, true);
  3491. } else {
  3492. clif->message(sd->fd,msg_fd(fd,1124)); // You have released your Mado Gear.
  3493. pc->setmadogear(sd, false);
  3494. }
  3495. return true;
  3496. }
  3497. if (sd->class_&MAPID_SWORDMAN && sd->class_&JOBL_2) {
  3498. if (!pc_isridingpeco(sd)) { // if actually no peco
  3499. if (!pc->checkskill(sd, KN_RIDING)) {
  3500. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,213), skill->get_desc(KN_RIDING)); // You need %s to mount!
  3501. clif->message(fd, atcmd_output);
  3502. return false;
  3503. }
  3504. pc->setridingpeco(sd, true);
  3505. clif->message(fd, msg_fd(fd,102)); // You have mounted a Peco Peco.
  3506. } else {//Dismount
  3507. pc->setridingpeco(sd, false);
  3508. clif->message(fd, msg_fd(fd,214)); // You have released your Peco Peco.
  3509. }
  3510. return true;
  3511. }
  3512. clif->message(fd, msg_fd(fd,215)); // Your class can't mount!
  3513. return false;
  3514. }
  3515. /*==========================================
  3516. *Spy Commands by Syrus22
  3517. *------------------------------------------*/
  3518. ACMD(guildspy) {
  3519. char guild_name[NAME_LENGTH];
  3520. struct guild *g;
  3521. memset(guild_name, '\0', sizeof(guild_name));
  3522. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3523. if (!map->enable_spy)
  3524. {
  3525. clif->message(fd, msg_fd(fd,1125)); // The mapserver has spy command support disabled.
  3526. return false;
  3527. }
  3528. if (!*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3529. clif->message(fd, msg_fd(fd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3530. return false;
  3531. }
  3532. if ((g = guild->searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3533. (g = guild->search(atoi(message))) != NULL) {
  3534. if (sd->guildspy == g->guild_id) {
  3535. sd->guildspy = 0;
  3536. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,103), g->name); // No longer spying on the %s guild.
  3537. clif->message(fd, atcmd_output);
  3538. } else {
  3539. sd->guildspy = g->guild_id;
  3540. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,104), g->name); // Spying on the %s guild.
  3541. clif->message(fd, atcmd_output);
  3542. }
  3543. } else {
  3544. clif->message(fd, msg_fd(fd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3545. return false;
  3546. }
  3547. return true;
  3548. }
  3549. /*==========================================
  3550. *
  3551. *------------------------------------------*/
  3552. ACMD(partyspy) {
  3553. char party_name[NAME_LENGTH];
  3554. struct party_data *p;
  3555. memset(party_name, '\0', sizeof(party_name));
  3556. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3557. if (!map->enable_spy)
  3558. {
  3559. clif->message(fd, msg_fd(fd,1125)); // The mapserver has spy command support disabled.
  3560. return false;
  3561. }
  3562. if (!*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3563. clif->message(fd, msg_fd(fd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3564. return false;
  3565. }
  3566. if ((p = party->searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3567. (p = party->search(atoi(message))) != NULL) {
  3568. if (sd->partyspy == p->party.party_id) {
  3569. sd->partyspy = 0;
  3570. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,105), p->party.name); // No longer spying on the %s party.
  3571. clif->message(fd, atcmd_output);
  3572. } else {
  3573. sd->partyspy = p->party.party_id;
  3574. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,106), p->party.name); // Spying on the %s party.
  3575. clif->message(fd, atcmd_output);
  3576. }
  3577. } else {
  3578. clif->message(fd, msg_fd(fd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3579. return false;
  3580. }
  3581. return true;
  3582. }
  3583. /*==========================================
  3584. * @repairall [Valaris]
  3585. *------------------------------------------*/
  3586. ACMD(repairall)
  3587. {
  3588. int count, i;
  3589. count = 0;
  3590. for (i = 0; i < MAX_INVENTORY; i++) {
  3591. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3592. sd->status.inventory[i].attribute = 0;
  3593. clif->produce_effect(sd, 0, sd->status.inventory[i].nameid);
  3594. count++;
  3595. }
  3596. }
  3597. if (count > 0) {
  3598. clif->misceffect(&sd->bl, 3);
  3599. clif->equiplist(sd);
  3600. clif->message(fd, msg_fd(fd,107)); // All items have been repaired.
  3601. } else {
  3602. clif->message(fd, msg_fd(fd,108)); // No item need to be repaired.
  3603. return false;
  3604. }
  3605. return true;
  3606. }
  3607. /*==========================================
  3608. * @nuke [Valaris]
  3609. *------------------------------------------*/
  3610. ACMD(nuke) {
  3611. struct map_session_data *pl_sd;
  3612. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3613. if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3614. clif->message(fd, msg_fd(fd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3615. return false;
  3616. }
  3617. if ((pl_sd = map->nick2sd(atcmd_player_name)) != NULL) {
  3618. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3619. skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, timer->gettick(), 0);
  3620. clif->message(fd, msg_fd(fd,109)); // Player has been nuked!
  3621. } else {
  3622. clif->message(fd, msg_fd(fd,81)); // Your GM level don't authorize you to do this action on this player.
  3623. return false;
  3624. }
  3625. } else {
  3626. clif->message(fd, msg_fd(fd,3)); // Character not found.
  3627. return false;
  3628. }
  3629. return true;
  3630. }
  3631. /*==========================================
  3632. * @tonpc
  3633. *------------------------------------------*/
  3634. ACMD(tonpc) {
  3635. char npcname[NAME_LENGTH+1];
  3636. struct npc_data *nd;
  3637. memset(npcname, 0, sizeof(npcname));
  3638. if (!*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3639. clif->message(fd, msg_fd(fd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3640. return false;
  3641. }
  3642. if ((nd = npc->name2id(npcname)) != NULL) {
  3643. if (nd->bl.m != -1 && pc->setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3644. clif->message(fd, msg_fd(fd,0)); // Warped.
  3645. else
  3646. return false;
  3647. } else {
  3648. clif->message(fd, msg_fd(fd,111)); // This NPC doesn't exist.
  3649. return false;
  3650. }
  3651. return true;
  3652. }
  3653. /*==========================================
  3654. *
  3655. *------------------------------------------*/
  3656. ACMD(shownpc)
  3657. {
  3658. char NPCname[NAME_LENGTH+1];
  3659. memset(NPCname, '\0', sizeof(NPCname));
  3660. if (!*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3661. clif->message(fd, msg_fd(fd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3662. return false;
  3663. }
  3664. if (npc->name2id(NPCname) != NULL) {
  3665. npc->enable(NPCname, 1);
  3666. clif->message(fd, msg_fd(fd,110)); // Npc Enabled.
  3667. } else {
  3668. clif->message(fd, msg_fd(fd,111)); // This NPC doesn't exist.
  3669. return false;
  3670. }
  3671. return true;
  3672. }
  3673. /*==========================================
  3674. *
  3675. *------------------------------------------*/
  3676. ACMD(hidenpc)
  3677. {
  3678. char NPCname[NAME_LENGTH+1];
  3679. memset(NPCname, '\0', sizeof(NPCname));
  3680. if (!*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3681. clif->message(fd, msg_fd(fd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3682. return false;
  3683. }
  3684. if (npc->name2id(NPCname) == NULL) {
  3685. clif->message(fd, msg_fd(fd,111)); // This NPC doesn't exist.
  3686. return false;
  3687. }
  3688. npc->enable(NPCname, 0);
  3689. clif->message(fd, msg_fd(fd,112)); // Npc Disabled.
  3690. return true;
  3691. }
  3692. ACMD(loadnpc)
  3693. {
  3694. FILE *fp;
  3695. if (!*message) {
  3696. clif->message(fd, msg_fd(fd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3697. return false;
  3698. }
  3699. // check if script file exists
  3700. if ((fp = fopen(message, "r")) == NULL) {
  3701. clif->message(fd, msg_fd(fd,261));
  3702. return false;
  3703. }
  3704. fclose(fp);
  3705. // add to list of script sources and run it
  3706. npc->addsrcfile(message);
  3707. npc->parsesrcfile(message,true);
  3708. npc->read_event_script();
  3709. clif->message(fd, msg_fd(fd,262));
  3710. return true;
  3711. }
  3712. ACMD(unloadnpc)
  3713. {
  3714. struct npc_data *nd;
  3715. char NPCname[NAME_LENGTH+1];
  3716. memset(NPCname, '\0', sizeof(NPCname));
  3717. if (!*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  3718. clif->message(fd, msg_fd(fd,1133)); // Please enter a NPC name (usage: @npcoff <NPC_name>).
  3719. return false;
  3720. }
  3721. if ((nd = npc->name2id(NPCname)) == NULL) {
  3722. clif->message(fd, msg_fd(fd,111)); // This NPC doesn't exist.
  3723. return false;
  3724. }
  3725. npc->unload_duplicates(nd);
  3726. npc->unload(nd,true);
  3727. npc->read_event_script();
  3728. clif->message(fd, msg_fd(fd,112)); // Npc Disabled.
  3729. return true;
  3730. }
  3731. /*==========================================
  3732. * time in txt for time command (by [Yor])
  3733. *------------------------------------------*/
  3734. char* txt_time(int fd, unsigned int duration) {
  3735. int days, hours, minutes, seconds;
  3736. static char temp1[CHAT_SIZE_MAX];
  3737. int tlen = 0;
  3738. memset(temp1, '\0', sizeof(temp1));
  3739. days = duration / (60 * 60 * 24);
  3740. duration = duration - (60 * 60 * 24 * days);
  3741. hours = duration / (60 * 60);
  3742. duration = duration - (60 * 60 * hours);
  3743. minutes = duration / 60;
  3744. seconds = duration - (60 * minutes);
  3745. if (days == 1)
  3746. tlen += sprintf(tlen + temp1, msg_fd(fd,219), days); // %d day
  3747. else if (days > 1)
  3748. tlen += sprintf(tlen + temp1, msg_fd(fd,220), days); // %d days
  3749. if (hours == 1)
  3750. tlen += sprintf(tlen + temp1, msg_fd(fd,221), hours); // %d hour
  3751. else if (hours > 1)
  3752. tlen += sprintf(tlen + temp1, msg_fd(fd,222), hours); // %d hours
  3753. if (minutes < 2)
  3754. tlen += sprintf(tlen + temp1, msg_fd(fd,223), minutes); // %d minute
  3755. else
  3756. tlen += sprintf(tlen + temp1, msg_fd(fd,224), minutes); // %d minutes
  3757. if (seconds == 1)
  3758. sprintf(tlen + temp1, msg_fd(fd,225), seconds); // and %d second
  3759. else if (seconds > 1)
  3760. sprintf(tlen + temp1, msg_fd(fd,226), seconds); // and %d seconds
  3761. return temp1;
  3762. }
  3763. /*==========================================
  3764. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3765. * Calculation management of GM modification (@day/@night GM commands) is done
  3766. *------------------------------------------*/
  3767. ACMD(servertime) {
  3768. time_t time_server; // variable for number of seconds (used with time() function)
  3769. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3770. char temp[CHAT_SIZE_MAX];
  3771. memset(temp, '\0', sizeof(temp));
  3772. time(&time_server); // get time in seconds since 1/1/1970
  3773. datetime = localtime(&time_server); // convert seconds in structure
  3774. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3775. strftime(temp, sizeof(temp)-1, msg_fd(fd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3776. clif->message(fd, temp);
  3777. if (pc->day_timer_tid != INVALID_TIMER && pc->night_timer_tid != INVALID_TIMER) {
  3778. const struct TimerData * timer_data = timer->get(pc->night_timer_tid);
  3779. const struct TimerData * timer_data2 = timer->get(pc->day_timer_tid);
  3780. if (map->night_flag == 0) {
  3781. sprintf(temp, msg_fd(fd,235), // Game time: The game is actually in daylight for %s.
  3782. txt_time(fd,(unsigned int)(DIFF_TICK(timer_data->tick,timer->gettick())/1000)));
  3783. clif->message(fd, temp);
  3784. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3785. sprintf(temp, msg_fd(fd,237), // Game time: After, the game will be in night for %s.
  3786. txt_time(fd,(unsigned int)(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)));
  3787. else
  3788. sprintf(temp, msg_fd(fd,237), // Game time: After, the game will be in night for %s.
  3789. txt_time(fd,(unsigned int)(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)));
  3790. clif->message(fd, temp);
  3791. } else {
  3792. sprintf(temp, msg_fd(fd,233), // Game time: The game is actually in night for %s.
  3793. txt_time(fd,(unsigned int)(DIFF_TICK(timer_data2->tick,timer->gettick()) / 1000)));
  3794. clif->message(fd, temp);
  3795. if (DIFF_TICK(timer_data2->tick,timer_data->tick) > 0)
  3796. sprintf(temp, msg_fd(fd,239), // Game time: After, the game will be in daylight for %s.
  3797. txt_time(fd,(unsigned int)((timer_data2->interval - DIFF_TICK(timer_data2->tick, timer_data->tick)) / 1000)));
  3798. else
  3799. sprintf(temp, msg_fd(fd,239), // Game time: After, the game will be in daylight for %s.
  3800. txt_time(fd,(unsigned int)(DIFF_TICK(timer_data->tick, timer_data2->tick) / 1000)));
  3801. clif->message(fd, temp);
  3802. }
  3803. sprintf(temp, msg_fd(fd,238), txt_time(fd,timer_data2->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3804. clif->message(fd, temp);
  3805. } else {
  3806. if (map->night_flag == 0)
  3807. clif->message(fd, msg_fd(fd,231)); // Game time: The game is in permanent daylight.
  3808. else
  3809. clif->message(fd, msg_fd(fd,232)); // Game time: The game is in permanent night.
  3810. }
  3811. return true;
  3812. }
  3813. //Added by Coltaro
  3814. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status->change_timer...).
  3815. //Well, using time_t could still work but for some reason that looks like more coding x_x
  3816. void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  3817. {
  3818. const int factor_year = 518400; //12*30*24*60 = 518400
  3819. const int factor_month = 43200; //30*24*60 = 43200
  3820. const int factor_day = 1440; //24*60 = 1440
  3821. const int factor_hour = 60;
  3822. nullpo_retv(year);
  3823. nullpo_retv(month);
  3824. nullpo_retv(day);
  3825. nullpo_retv(hour);
  3826. nullpo_retv(minute);
  3827. *year = jailtime/factor_year;
  3828. jailtime -= *year*factor_year;
  3829. *month = jailtime/factor_month;
  3830. jailtime -= *month*factor_month;
  3831. *day = jailtime/factor_day;
  3832. jailtime -= *day*factor_day;
  3833. *hour = jailtime/factor_hour;
  3834. jailtime -= *hour*factor_hour;
  3835. *minute = jailtime;
  3836. *year = *year > 0? *year : 0;
  3837. *month = *month > 0? *month : 0;
  3838. *day = *day > 0? *day : 0;
  3839. *hour = *hour > 0? *hour : 0;
  3840. *minute = *minute > 0? *minute : 0;
  3841. return;
  3842. }
  3843. /*==========================================
  3844. * @jail <char_name> by [Yor]
  3845. * Special warp! No check with nowarp and nowarpto flag
  3846. *------------------------------------------*/
  3847. ACMD(jail) {
  3848. struct map_session_data *pl_sd;
  3849. int x, y;
  3850. unsigned short m_index;
  3851. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3852. if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3853. clif->message(fd, msg_fd(fd,1134)); // Please enter a player name (usage: @jail <char_name>).
  3854. return false;
  3855. }
  3856. if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) {
  3857. clif->message(fd, msg_fd(fd,3)); // Character not found.
  3858. return false;
  3859. }
  3860. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  3861. // you can jail only lower or same GM
  3862. clif->message(fd, msg_fd(fd,81)); // Your GM level don't authorize you to do this action on this player.
  3863. return false;
  3864. }
  3865. if (pl_sd->sc.data[SC_JAILED])
  3866. {
  3867. clif->message(fd, msg_fd(fd,118)); // Player warped in jails.
  3868. return false;
  3869. }
  3870. switch(rnd() % 2) { //Jail Locations
  3871. case 0:
  3872. m_index = mapindex->name2id(MAP_JAIL);
  3873. x = 24;
  3874. y = 75;
  3875. break;
  3876. default:
  3877. m_index = mapindex->name2id(MAP_JAIL);
  3878. x = 49;
  3879. y = 75;
  3880. break;
  3881. }
  3882. //Duration of INT_MAX to specify infinity.
  3883. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  3884. clif->message(pl_sd->fd, msg_fd(fd,117)); // You have been jailed by a GM.
  3885. clif->message(fd, msg_fd(fd,118)); // Player warped in jails.
  3886. return true;
  3887. }
  3888. /*==========================================
  3889. * @unjail/@discharge <char_name> by [Yor]
  3890. * Special warp! No check with nowarp and nowarpto flag
  3891. *------------------------------------------*/
  3892. ACMD(unjail) {
  3893. struct map_session_data *pl_sd;
  3894. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3895. if (!*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3896. clif->message(fd, msg_fd(fd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  3897. return false;
  3898. }
  3899. if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) {
  3900. clif->message(fd, msg_fd(fd,3)); // Character not found.
  3901. return false;
  3902. }
  3903. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  3904. clif->message(fd, msg_fd(fd,81)); // Your GM level don't authorize you to do this action on this player.
  3905. return false;
  3906. }
  3907. if (!pl_sd->sc.data[SC_JAILED])
  3908. {
  3909. clif->message(fd, msg_fd(fd,119)); // This player is not in jails.
  3910. return false;
  3911. }
  3912. //Reset jail time to 1 sec.
  3913. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  3914. clif->message(pl_sd->fd, msg_fd(fd,120)); // A GM has discharged you from jail.
  3915. clif->message(fd, msg_fd(fd,121)); // Player unjailed.
  3916. return true;
  3917. }
  3918. ACMD(jailfor) {
  3919. struct map_session_data *pl_sd = NULL;
  3920. int year, month, day, hour, minute;
  3921. char * modif_p;
  3922. int jailtime = 0,x,y;
  3923. short m_index = 0;
  3924. if (!*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  3925. clif->message(fd, msg_fd(fd,400)); //Usage: @jailfor <time> <character name>
  3926. return false;
  3927. }
  3928. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3929. modif_p = atcmd_output;
  3930. year = month = day = hour = minute = 0;
  3931. while (modif_p[0] != '\0') {
  3932. int value = atoi(modif_p);
  3933. if (value == 0)
  3934. modif_p++;
  3935. else {
  3936. if (modif_p[0] == '-' || modif_p[0] == '+')
  3937. modif_p++;
  3938. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3939. modif_p++;
  3940. if (modif_p[0] == 'n') {
  3941. minute = value;
  3942. modif_p++;
  3943. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3944. minute = value;
  3945. modif_p = modif_p + 2;
  3946. } else if (modif_p[0] == 'h') {
  3947. hour = value;
  3948. modif_p++;
  3949. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3950. day = value;
  3951. modif_p++;
  3952. } else if (modif_p[0] == 'm') {
  3953. month = value;
  3954. modif_p++;
  3955. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3956. year = value;
  3957. modif_p++;
  3958. } else if (modif_p[0] != '\0') {
  3959. modif_p++;
  3960. }
  3961. }
  3962. }
  3963. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  3964. clif->message(fd, msg_fd(fd,1136)); // Invalid time for jail command.
  3965. return false;
  3966. }
  3967. if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) {
  3968. clif->message(fd, msg_fd(fd,3)); // Character not found.
  3969. return false;
  3970. }
  3971. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  3972. clif->message(fd, msg_fd(fd,81)); // Your GM level don't authorize you to do this action on this player.
  3973. return false;
  3974. }
  3975. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  3976. if(jailtime==0) {
  3977. clif->message(fd, msg_fd(fd,1136)); // Invalid time for jail command.
  3978. return false;
  3979. }
  3980. //Added by Coltaro
  3981. if (pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) {
  3982. //Update the player's jail time
  3983. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  3984. if (jailtime <= 0) {
  3985. jailtime = 0;
  3986. clif->message(pl_sd->fd, msg_fd(fd,120)); // GM has discharge you.
  3987. clif->message(fd, msg_fd(fd,121)); // Player unjailed
  3988. } else {
  3989. atcommand->get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  3990. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,402),msg_fd(fd,1137),year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  3991. clif->message(pl_sd->fd, atcmd_output);
  3992. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,402),msg_fd(fd,1138),year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  3993. clif->message(fd, atcmd_output);
  3994. }
  3995. } else if (jailtime < 0) {
  3996. clif->message(fd, msg_fd(fd,1136));
  3997. return false;
  3998. }
  3999. //Jail locations, add more as you wish.
  4000. switch(rnd()%2)
  4001. {
  4002. case 1: //Jail #1
  4003. m_index = mapindex->name2id(MAP_JAIL);
  4004. x = 49; y = 75;
  4005. break;
  4006. default: //Default Jail
  4007. m_index = mapindex->name2id(MAP_JAIL);
  4008. x = 24; y = 75;
  4009. break;
  4010. }
  4011. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status->change_timer).
  4012. return true;
  4013. }
  4014. //By Coltaro
  4015. ACMD(jailtime)
  4016. {
  4017. int year, month, day, hour, minute;
  4018. if (!sd->sc.data[SC_JAILED]) {
  4019. clif->message(fd, msg_fd(fd,1139)); // You are not in jail.
  4020. return false;
  4021. }
  4022. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4023. clif->message(fd, msg_fd(fd,1140)); // You have been jailed indefinitely.
  4024. return true;
  4025. }
  4026. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4027. clif->message(fd, msg_fd(fd,1141)); // You have been jailed for an unknown amount of time.
  4028. return false;
  4029. }
  4030. //Get remaining jail time
  4031. atcommand->get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4032. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,402),msg_fd(fd,1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4033. clif->message(fd, atcmd_output);
  4034. return true;
  4035. }
  4036. /*==========================================
  4037. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4038. *------------------------------------------*/
  4039. ACMD(disguise)
  4040. {
  4041. int id = 0;
  4042. if (!*message) {
  4043. clif->message(fd, msg_fd(fd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4044. return false;
  4045. }
  4046. if ((id = atoi(message)) > 0) {
  4047. //Acquired an ID
  4048. if (!mob->db_checkid(id) && !npc->db_checkid(id))
  4049. id = 0; //Invalid id for either mobs or npcs.
  4050. } else {
  4051. //Acquired a Name
  4052. if ((id = mob->db_searchname(message)) == 0)
  4053. {
  4054. struct npc_data* nd = npc->name2id(message);
  4055. if (nd != NULL)
  4056. id = nd->class_;
  4057. }
  4058. }
  4059. if (id == 0)
  4060. {
  4061. clif->message(fd, msg_fd(fd,123)); // Invalid Monster/NPC name/ID specified.
  4062. return false;
  4063. }
  4064. if (pc_hasmount(sd)) {
  4065. clif->message(fd, msg_fd(fd,1144)); // Character cannot be disguised while mounted.
  4066. return false;
  4067. }
  4068. if(sd->sc.data[SC_MONSTER_TRANSFORM])
  4069. {
  4070. clif->message(fd, msg_fd(fd,1487)); // Character cannot be disguised while in monster form.
  4071. return false;
  4072. }
  4073. pc->disguise(sd, id);
  4074. clif->message(fd, msg_fd(fd,122)); // Disguise applied.
  4075. return true;
  4076. }
  4077. /*==========================================
  4078. * DisguiseAll
  4079. *------------------------------------------*/
  4080. ACMD(disguiseall)
  4081. {
  4082. int mob_id=0;
  4083. struct map_session_data *pl_sd;
  4084. struct s_mapiterator* iter;
  4085. if (!*message) {
  4086. clif->message(fd, msg_fd(fd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4087. return false;
  4088. }
  4089. if ((mob_id = mob->db_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4090. mob_id = atoi(message);
  4091. if (!mob->db_checkid(mob_id) && !npc->db_checkid(mob_id)) { //if mob or npc...
  4092. clif->message(fd, msg_fd(fd,123)); // Monster/NPC name/id not found.
  4093. return false;
  4094. }
  4095. iter = mapit_getallusers();
  4096. for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter)))
  4097. pc->disguise(pl_sd, mob_id);
  4098. mapit->free(iter);
  4099. clif->message(fd, msg_fd(fd,122)); // Disguise applied.
  4100. return true;
  4101. }
  4102. /*==========================================
  4103. * DisguiseGuild
  4104. *------------------------------------------*/
  4105. ACMD(disguiseguild)
  4106. {
  4107. int id = 0, i;
  4108. char monster[NAME_LENGTH], guild_name[NAME_LENGTH];
  4109. struct guild *g;
  4110. memset(monster, '\0', sizeof(monster));
  4111. memset(guild_name, '\0', sizeof(guild_name));
  4112. if (!*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild_name) < 2) {
  4113. clif->message(fd, msg_fd(fd,1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>).
  4114. return false;
  4115. }
  4116. if( (id = atoi(monster)) > 0 ) {
  4117. if( !mob->db_checkid(id) && !npc->db_checkid(id) )
  4118. id = 0;
  4119. } else {
  4120. if( (id = mob->db_searchname(monster)) == 0 ) {
  4121. struct npc_data* nd = npc->name2id(monster);
  4122. if( nd != NULL )
  4123. id = nd->class_;
  4124. }
  4125. }
  4126. if( id == 0 ) {
  4127. clif->message(fd, msg_fd(fd,123)); // Monster/NPC name/id hasn't been found.
  4128. return false;
  4129. }
  4130. if( (g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(guild_name))) == NULL ) {
  4131. clif->message(fd, msg_fd(fd,94)); // Incorrect name/ID, or no one from the guild is online.
  4132. return false;
  4133. }
  4134. for (i = 0; i < g->max_member; i++) {
  4135. struct map_session_data *pl_sd = g->member[i].sd;
  4136. if (pl_sd && !pc_hasmount(pl_sd))
  4137. pc->disguise(pl_sd, id);
  4138. }
  4139. clif->message(fd, msg_fd(fd,122)); // Disguise applied.
  4140. return true;
  4141. }
  4142. /*==========================================
  4143. * @undisguise by [Yor]
  4144. *------------------------------------------*/
  4145. ACMD(undisguise)
  4146. {
  4147. if (sd->disguise != -1) {
  4148. pc->disguise(sd, -1);
  4149. clif->message(fd, msg_fd(fd,124)); // Disguise removed.
  4150. } else {
  4151. clif->message(fd, msg_fd(fd,125)); // You're not disguised.
  4152. return false;
  4153. }
  4154. return true;
  4155. }
  4156. /*==========================================
  4157. * UndisguiseAll
  4158. *------------------------------------------*/
  4159. ACMD(undisguiseall) {
  4160. struct map_session_data *pl_sd;
  4161. struct s_mapiterator* iter;
  4162. iter = mapit_getallusers();
  4163. for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter)))
  4164. if( pl_sd->disguise != -1 )
  4165. pc->disguise(pl_sd, -1);
  4166. mapit->free(iter);
  4167. clif->message(fd, msg_fd(fd,124)); // Disguise removed.
  4168. return true;
  4169. }
  4170. /*==========================================
  4171. * UndisguiseGuild
  4172. *------------------------------------------*/
  4173. ACMD(undisguiseguild)
  4174. {
  4175. char guild_name[NAME_LENGTH];
  4176. struct guild *g;
  4177. int i;
  4178. memset(guild_name, '\0', sizeof(guild_name));
  4179. if (!*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4180. clif->message(fd, msg_fd(fd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4181. return false;
  4182. }
  4183. if ((g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(message))) == NULL) {
  4184. clif->message(fd, msg_fd(fd,94)); // Incorrect name/ID, or no one from the guild is online.
  4185. return false;
  4186. }
  4187. for (i = 0; i < g->max_member; i++) {
  4188. struct map_session_data *pl_sd = g->member[i].sd;
  4189. if (pl_sd && pl_sd->disguise != -1)
  4190. pc->disguise(pl_sd, -1);
  4191. }
  4192. clif->message(fd, msg_fd(fd,124)); // Disguise removed.
  4193. return true;
  4194. }
  4195. /*==========================================
  4196. * @exp by [Skotlex]
  4197. *------------------------------------------*/
  4198. ACMD(exp)
  4199. {
  4200. char output[CHAT_SIZE_MAX];
  4201. double nextb, nextj;
  4202. memset(output, '\0', sizeof(output));
  4203. nextb = pc->nextbaseexp(sd);
  4204. if (nextb)
  4205. nextb = sd->status.base_exp*100.0/nextb;
  4206. nextj = pc->nextjobexp(sd);
  4207. if (nextj)
  4208. nextj = sd->status.job_exp*100.0/nextj;
  4209. sprintf(output, msg_fd(fd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4210. clif->message(fd, output);
  4211. return true;
  4212. }
  4213. /*==========================================
  4214. * @broadcast by [Valaris]
  4215. *------------------------------------------*/
  4216. ACMD(broadcast)
  4217. {
  4218. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4219. if (!*message) {
  4220. clif->message(fd, msg_fd(fd,1149)); // Please enter a message (usage: @broadcast <message>).
  4221. return false;
  4222. }
  4223. safesnprintf(atcmd_output, sizeof(atcmd_output), "%s: %s", sd->status.name, message);
  4224. intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4225. return true;
  4226. }
  4227. /*==========================================
  4228. * @localbroadcast by [Valaris]
  4229. *------------------------------------------*/
  4230. ACMD(localbroadcast)
  4231. {
  4232. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4233. if (!*message) {
  4234. clif->message(fd, msg_fd(fd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4235. return false;
  4236. }
  4237. safesnprintf(atcmd_output, sizeof(atcmd_output), "%s: %s", sd->status.name, message);
  4238. clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4239. return true;
  4240. }
  4241. /*==========================================
  4242. * @email <actual@email> <new@email> by [Yor]
  4243. *------------------------------------------*/
  4244. ACMD(email)
  4245. {
  4246. char actual_email[100];
  4247. char new_email[100];
  4248. memset(actual_email, '\0', sizeof(actual_email));
  4249. memset(new_email, '\0', sizeof(new_email));
  4250. if (!*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4251. clif->message(fd, msg_fd(fd,1151)); // Please enter two e-mail addresses (usage: @email <current@email> <new@email>).
  4252. return false;
  4253. }
  4254. if (e_mail_check(actual_email) == 0) {
  4255. clif->message(fd, msg_fd(fd,144)); // Invalid e-mail. If your email hasn't been set, use a@a.com.
  4256. return false;
  4257. } else if (e_mail_check(new_email) == 0) {
  4258. clif->message(fd, msg_fd(fd,145)); // Invalid new email. Please enter a real e-mail address.
  4259. return false;
  4260. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4261. clif->message(fd, msg_fd(fd,146)); // New email must be a real e-mail address.
  4262. return false;
  4263. } else if (strcmpi(actual_email, new_email) == 0) {
  4264. clif->message(fd, msg_fd(fd,147)); // New e-mail must be different from the current e-mail address.
  4265. return false;
  4266. }
  4267. chrif->changeemail(sd->status.account_id, actual_email, new_email);
  4268. clif->message(fd, msg_fd(fd,148)); // Information sended to login-server via char-server.
  4269. return true;
  4270. }
  4271. /*==========================================
  4272. *@effect
  4273. *------------------------------------------*/
  4274. ACMD(effect)
  4275. {
  4276. int type = 0, flag = 0;
  4277. if (!*message || sscanf(message, "%d", &type) < 1) {
  4278. clif->message(fd, msg_fd(fd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4279. return false;
  4280. }
  4281. clif->specialeffect(&sd->bl, type, (send_target)flag);
  4282. clif->message(fd, msg_fd(fd,229)); // Your effect has changed.
  4283. return true;
  4284. }
  4285. /*==========================================
  4286. * @killer by MouseJstr
  4287. * enable killing players even when not in pvp
  4288. *------------------------------------------*/
  4289. ACMD(killer)
  4290. {
  4291. sd->state.killer = !sd->state.killer;
  4292. if (sd->state.killer)
  4293. clif->message(fd, msg_fd(fd,241));
  4294. else {
  4295. clif->message(fd, msg_fd(fd,292));
  4296. pc_stop_attack(sd);
  4297. }
  4298. return true;
  4299. }
  4300. /*==========================================
  4301. * @killable by MouseJstr
  4302. * enable other people killing you
  4303. *------------------------------------------*/
  4304. ACMD(killable) {
  4305. sd->state.killable = !sd->state.killable;
  4306. if (sd->state.killable) {
  4307. clif->message(fd, msg_fd(fd,242));
  4308. } else {
  4309. clif->message(fd, msg_fd(fd,288));
  4310. map->foreachinrange(atcommand->stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4311. }
  4312. return true;
  4313. }
  4314. /*==========================================
  4315. * @skillon by MouseJstr
  4316. * turn skills on for the map
  4317. *------------------------------------------*/
  4318. ACMD(skillon) {
  4319. map->list[sd->bl.m].flag.noskill = 0;
  4320. clif->message(fd, msg_fd(fd,244));
  4321. return true;
  4322. }
  4323. /*==========================================
  4324. * @skilloff by MouseJstr
  4325. * Turn skills off on the map
  4326. *------------------------------------------*/
  4327. ACMD(skilloff) {
  4328. map->list[sd->bl.m].flag.noskill = 1;
  4329. clif->message(fd, msg_fd(fd,243));
  4330. return true;
  4331. }
  4332. /*==========================================
  4333. * @npcmove by MouseJstr
  4334. * move a npc
  4335. *------------------------------------------*/
  4336. ACMD(npcmove) {
  4337. int x = 0, y = 0, m;
  4338. struct npc_data *nd = 0;
  4339. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4340. if (!*message || sscanf(message, "%12d %12d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4341. clif->message(fd, msg_fd(fd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4342. return false;
  4343. }
  4344. if ((nd = npc->name2id(atcmd_player_name)) == NULL) {
  4345. clif->message(fd, msg_fd(fd,111)); // This NPC doesn't exist.
  4346. return false;
  4347. }
  4348. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL) {
  4349. clif->message(fd, msg_fd(fd,1154)); // NPC is not in this map.
  4350. return false; //Not on a map.
  4351. }
  4352. x = cap_value(x, 0, map->list[m].xs-1);
  4353. y = cap_value(y, 0, map->list[m].ys-1);
  4354. map->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4355. map->moveblock(&nd->bl, x, y, timer->gettick());
  4356. map->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4357. clif->message(fd, msg_fd(fd,1155)); // NPC moved.
  4358. return true;
  4359. }
  4360. /*==========================================
  4361. * @addwarp by MouseJstr
  4362. * Create a new static warp point.
  4363. *------------------------------------------*/
  4364. ACMD(addwarp)
  4365. {
  4366. char mapname[32], warpname[NAME_LENGTH+1];
  4367. int x,y;
  4368. unsigned short m;
  4369. struct npc_data* nd;
  4370. memset(warpname, '\0', sizeof(warpname));
  4371. if (!*message || sscanf(message, "%31s %12d %12d %23[^\n]", mapname, &x, &y, warpname) < 4) {
  4372. clif->message(fd, msg_fd(fd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4373. return false;
  4374. }
  4375. m = mapindex->name2id(mapname);
  4376. if( m == 0 )
  4377. {
  4378. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1157), mapname); // Unknown map '%s'.
  4379. clif->message(fd, atcmd_output);
  4380. return false;
  4381. }
  4382. nd = npc->add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4383. if( nd == NULL )
  4384. return false;
  4385. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1158), nd->exname); // New warp NPC '%s' created.
  4386. clif->message(fd, atcmd_output);
  4387. return true;
  4388. }
  4389. /*==========================================
  4390. * @follow by [MouseJstr]
  4391. * Follow a player .. staying no more then 5 spaces away
  4392. *------------------------------------------*/
  4393. ACMD(follow) {
  4394. struct map_session_data *pl_sd = NULL;
  4395. if (!*message) {
  4396. if (sd->followtarget == -1)
  4397. return false;
  4398. pc->stop_following (sd);
  4399. clif->message(fd, msg_fd(fd,1159)); // Follow mode OFF.
  4400. return true;
  4401. }
  4402. if ((pl_sd = map->nick2sd((char *)message)) == NULL)
  4403. {
  4404. clif->message(fd, msg_fd(fd,3)); // Character not found.
  4405. return false;
  4406. }
  4407. if (sd->followtarget == pl_sd->bl.id) {
  4408. pc->stop_following (sd);
  4409. clif->message(fd, msg_fd(fd,1159)); // Follow mode OFF.
  4410. } else {
  4411. pc->follow(sd, pl_sd->bl.id);
  4412. clif->message(fd, msg_fd(fd,1160)); // Follow mode ON.
  4413. }
  4414. return true;
  4415. }
  4416. /*==========================================
  4417. * @dropall by [MouseJstr]
  4418. * Drop all your possession on the ground
  4419. *------------------------------------------*/
  4420. ACMD(dropall)
  4421. {
  4422. int i;
  4423. for (i = 0; i < MAX_INVENTORY; i++) {
  4424. if (sd->status.inventory[i].amount) {
  4425. if(sd->status.inventory[i].equip != 0)
  4426. pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
  4427. pc->dropitem(sd, i, sd->status.inventory[i].amount);
  4428. }
  4429. }
  4430. return true;
  4431. }
  4432. /*==========================================
  4433. * @storeall by [MouseJstr]
  4434. * Put everything into storage
  4435. *------------------------------------------*/
  4436. ACMD(storeall)
  4437. {
  4438. int i;
  4439. if (sd->state.storage_flag != STORAGE_FLAG_NORMAL) {
  4440. //Open storage.
  4441. if (storage->open(sd) == 1) {
  4442. clif->message(fd, msg_fd(fd,1161)); // You currently cannot open your storage.
  4443. return false;
  4444. }
  4445. }
  4446. for (i = 0; i < MAX_INVENTORY; i++) {
  4447. if (sd->status.inventory[i].amount) {
  4448. if(sd->status.inventory[i].equip != 0)
  4449. pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
  4450. storage->add(sd, i, sd->status.inventory[i].amount);
  4451. }
  4452. }
  4453. storage->close(sd);
  4454. clif->message(fd, msg_fd(fd,1162)); // All items stored.
  4455. return true;
  4456. }
  4457. ACMD(clearstorage)
  4458. {
  4459. int i, j;
  4460. if (sd->state.storage_flag == STORAGE_FLAG_NORMAL) {
  4461. clif->message(fd, msg_fd(fd,250));
  4462. return false;
  4463. }
  4464. j = sd->status.storage.storage_amount;
  4465. for (i = 0; i < j; ++i) {
  4466. storage->delitem(sd, i, sd->status.storage.items[i].amount);
  4467. }
  4468. storage->close(sd);
  4469. clif->message(fd, msg_fd(fd,1394)); // Your storage was cleaned.
  4470. return true;
  4471. }
  4472. ACMD(cleargstorage)
  4473. {
  4474. int i, j;
  4475. struct guild *g;
  4476. struct guild_storage *guild_storage;
  4477. g = sd->guild;
  4478. if (g == NULL) {
  4479. clif->message(fd, msg_fd(fd,43));
  4480. return false;
  4481. }
  4482. if (sd->state.storage_flag == STORAGE_FLAG_NORMAL) {
  4483. clif->message(fd, msg_fd(fd,250));
  4484. return false;
  4485. }
  4486. if (sd->state.storage_flag == STORAGE_FLAG_GUILD) {
  4487. clif->message(fd, msg_fd(fd,251));
  4488. return false;
  4489. }
  4490. guild_storage = idb_get(gstorage->db,sd->status.guild_id);
  4491. if (guild_storage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4492. return false;
  4493. }
  4494. j = guild_storage->storage_amount;
  4495. guild_storage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4496. for (i = 0; i < j; ++i) {
  4497. gstorage->delitem(sd, guild_storage, i, guild_storage->items[i].amount);
  4498. }
  4499. gstorage->close(sd);
  4500. guild_storage->lock = 0; // Cleaning done, release lock
  4501. clif->message(fd, msg_fd(fd,1395)); // Your guild storage was cleaned.
  4502. return true;
  4503. }
  4504. ACMD(clearcart)
  4505. {
  4506. int i;
  4507. if (pc_iscarton(sd) == 0) {
  4508. clif->message(fd, msg_fd(fd,1396)); // You do not have a cart to be cleaned.
  4509. return false;
  4510. }
  4511. if (sd->state.vending) {
  4512. clif->message(fd, msg_fd(fd,548)); // You can't clean a cart while vending!
  4513. return false;
  4514. }
  4515. for( i = 0; i < MAX_CART; i++ )
  4516. if(sd->status.cart[i].nameid > 0)
  4517. pc->cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  4518. clif->clearcart(fd);
  4519. clif->updatestatus(sd,SP_CARTINFO);
  4520. clif->message(fd, msg_fd(fd,1397)); // Your cart was cleaned.
  4521. return true;
  4522. }
  4523. /*==========================================
  4524. * @skillid by [MouseJstr]
  4525. * lookup a skill by name
  4526. *------------------------------------------*/
  4527. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4528. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 /* "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33) */
  4529. ACMD(skillid) {
  4530. int i, found = 0;
  4531. size_t skillen;
  4532. DBIterator* iter;
  4533. DBKey key;
  4534. DBData *data;
  4535. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4536. if (!*message) {
  4537. clif->message(fd, msg_fd(fd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4538. return false;
  4539. }
  4540. skillen = strlen(message);
  4541. iter = db_iterator(skill->name2id_db);
  4542. for (data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key)) {
  4543. int idx = skill->get_index(DB->data2i(data));
  4544. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill->dbs->db[idx].desc, message, skillen) == 0) {
  4545. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str); // skill %d: %s (%s)
  4546. clif->message(fd, atcmd_output);
  4547. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill->dbs->db[idx].desc,message) ) ) {
  4548. snprintf(partials[found], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str);
  4549. found++;
  4550. }
  4551. }
  4552. dbi_destroy(iter);
  4553. if( found ) {
  4554. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1398), found); // -- Displaying first %d partial matches
  4555. clif->message(fd, atcmd_output);
  4556. }
  4557. for(i = 0; i < found; i++) { /* partials */
  4558. clif->message(fd, partials[i]);
  4559. }
  4560. return true;
  4561. }
  4562. /*==========================================
  4563. * @useskill by [MouseJstr]
  4564. * A way of using skills without having to find them in the skills menu
  4565. *------------------------------------------*/
  4566. ACMD(useskill) {
  4567. struct map_session_data *pl_sd = NULL;
  4568. struct block_list *bl;
  4569. uint16 skill_id;
  4570. uint16 skill_lv;
  4571. char target[100];
  4572. if (!*message || sscanf(message, "%5hu %5hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4573. clif->message(fd, msg_fd(fd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4574. return false;
  4575. }
  4576. if (!strcmp(target,"self"))
  4577. pl_sd = sd; //quick keyword
  4578. else if ((pl_sd = map->nick2sd(target)) == NULL) {
  4579. clif->message(fd, msg_fd(fd,3)); // Character not found.
  4580. return false;
  4581. }
  4582. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  4583. {
  4584. clif->message(fd, msg_fd(fd,81)); // Your GM level don't authorized you to do this action on this player.
  4585. return false;
  4586. }
  4587. if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL
  4588. && sd->hd && homun_alive(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4589. bl = &sd->hd->bl;
  4590. else
  4591. bl = &sd->bl;
  4592. pc->delinvincibletimer(sd);
  4593. if (skill->get_inf(skill_id)&INF_GROUND_SKILL)
  4594. unit->skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4595. else
  4596. unit->skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4597. return true;
  4598. }
  4599. /*==========================================
  4600. * @displayskill by [Skotlex]
  4601. * Debug command to locate new skill IDs. It sends the
  4602. * three possible skill-effect packets to the area.
  4603. *------------------------------------------*/
  4604. ACMD(displayskill) {
  4605. struct status_data *st;
  4606. int64 tick;
  4607. uint16 skill_id;
  4608. uint16 skill_lv = 1;
  4609. if (!*message || sscanf(message, "%5hu %5hu", &skill_id, &skill_lv) < 1) {
  4610. clif->message(fd, msg_fd(fd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4611. return false;
  4612. }
  4613. st = status->get_status_data(&sd->bl);
  4614. tick = timer->gettick();
  4615. clif->skill_damage(&sd->bl,&sd->bl, tick, st->amotion, st->dmotion, 1, 1, skill_id, skill_lv, BDT_SPLASH);
  4616. clif->skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4617. clif->skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4618. return true;
  4619. }
  4620. /*==========================================
  4621. * @skilltree by [MouseJstr]
  4622. * prints the skill tree for a player required to get to a skill
  4623. *------------------------------------------*/
  4624. ACMD(skilltree)
  4625. {
  4626. struct map_session_data *pl_sd = NULL;
  4627. uint16 skill_id;
  4628. int meets, j, c=0;
  4629. char target[NAME_LENGTH];
  4630. struct skill_tree_entry *entry;
  4631. if(!*message || sscanf(message, "%5hu %23[^\r\n]", &skill_id, target) != 2) {
  4632. clif->message(fd, msg_fd(fd,1167)); // Usage: @skilltree <skill ID> <target>
  4633. return false;
  4634. }
  4635. if ( (pl_sd = map->nick2sd(target)) == NULL ) {
  4636. clif->message(fd, msg_fd(fd,3)); // Character not found.
  4637. return false;
  4638. }
  4639. c = pc->calc_skilltree_normalize_job(pl_sd);
  4640. c = pc->mapid2jobid(c, pl_sd->status.sex);
  4641. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1168), pc->job_name(c), pc->checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
  4642. clif->message(fd, atcmd_output);
  4643. ARR_FIND(0, MAX_SKILL_TREE, j, pc->skill_tree[c][j].id == 0 || pc->skill_tree[c][j].id == skill_id);
  4644. if (j == MAX_SKILL_TREE || pc->skill_tree[c][j].id == 0) {
  4645. clif->message(fd, msg_fd(fd,1169)); // The player cannot use that skill.
  4646. return false;
  4647. }
  4648. entry = &pc->skill_tree[c][j];
  4649. meets = 1;
  4650. for (j = 0; j < VECTOR_LENGTH(entry->need); j++) {
  4651. struct skill_tree_requirement *req = &VECTOR_INDEX(entry->need, j);
  4652. if (pc->checkskill(sd, req->id) < req->lv) {
  4653. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1170), req->lv, skill->dbs->db[req->id].desc); // Player requires level %d of skill %s.
  4654. clif->message(fd, atcmd_output);
  4655. meets = 0;
  4656. }
  4657. }
  4658. if (meets == 1) {
  4659. clif->message(fd, msg_fd(fd,1171)); // The player meets all the requirements for that skill.
  4660. }
  4661. return true;
  4662. }
  4663. // Hand a ring with partners name on it to this char
  4664. void atcommand_getring(struct map_session_data* sd) {
  4665. int flag, item_id;
  4666. struct item item_tmp;
  4667. nullpo_retv(sd);
  4668. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4669. memset(&item_tmp, 0, sizeof(item_tmp));
  4670. item_tmp.nameid = item_id;
  4671. item_tmp.identify = 1;
  4672. item_tmp.card[0] = 255;
  4673. item_tmp.card[2] = sd->status.partner_id;
  4674. item_tmp.card[3] = sd->status.partner_id >> 16;
  4675. if((flag = pc->additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4676. clif->additem(sd,0,0,flag);
  4677. map->addflooritem(&sd->bl, &item_tmp, 1, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0);
  4678. }
  4679. }
  4680. /*==========================================
  4681. * @marry by [MouseJstr], fixed by Lupus
  4682. * Marry two players
  4683. *------------------------------------------*/
  4684. ACMD(marry) {
  4685. struct map_session_data *pl_sd = NULL;
  4686. char player_name[NAME_LENGTH] = "";
  4687. if (!*message || sscanf(message, "%23s", player_name) != 1) {
  4688. clif->message(fd, msg_fd(fd,1172)); // Usage: @marry <char name>
  4689. return false;
  4690. }
  4691. if ((pl_sd = map->nick2sd(player_name)) == NULL) {
  4692. clif->message(fd, msg_fd(fd,3));
  4693. return false;
  4694. }
  4695. if (pc->marriage(sd, pl_sd) == 0) {
  4696. clif->message(fd, msg_fd(fd,1173)); // They are married... wish them well.
  4697. clif->wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4698. atcommand->getring(sd); // Auto-give named rings (Aru)
  4699. atcommand->getring(pl_sd);
  4700. return true;
  4701. }
  4702. clif->message(fd, msg_fd(fd,1174)); // The two cannot wed because one is either a baby or already married.
  4703. return false;
  4704. }
  4705. /*==========================================
  4706. * @divorce by [MouseJstr], fixed by [Lupus]
  4707. * divorce two players
  4708. *------------------------------------------*/
  4709. ACMD(divorce)
  4710. {
  4711. if (pc->divorce(sd) != 0) {
  4712. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1175), sd->status.name); // '%s' is not married.
  4713. clif->message(fd, atcmd_output);
  4714. return false;
  4715. }
  4716. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4717. clif->message(fd, atcmd_output);
  4718. return true;
  4719. }
  4720. /*==========================================
  4721. * @changelook by [Celest]
  4722. *------------------------------------------*/
  4723. ACMD(changelook)
  4724. {
  4725. int i, j = 0, k = 0;
  4726. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE,LOOK_BODY2 };
  4727. if((i = sscanf(message, "%12d %12d", &j, &k)) < 1) {
  4728. clif->message(fd, msg_fd(fd,1177)); // Usage: @changelook {<position>} <view id>
  4729. clif->message(fd, msg_fd(fd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4730. return false;
  4731. } else if ( i == 2 ) {
  4732. if (j < 1 || j > 7)
  4733. j = 1;
  4734. j = pos[j - 1];
  4735. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4736. k = j; // swap
  4737. j = LOOK_HEAD_TOP;
  4738. }
  4739. clif->changelook(&sd->bl,j,k);
  4740. return true;
  4741. }
  4742. /*==========================================
  4743. * @autotrade by durf [Lupus] [Paradox924X]
  4744. * Turns on/off Autotrade for a specific player
  4745. *------------------------------------------*/
  4746. ACMD(autotrade)
  4747. {
  4748. if( map->list[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4749. clif->message(fd, msg_fd(fd,1179)); // Autotrade is not allowed in this map.
  4750. return false;
  4751. }
  4752. if( pc_isdead(sd) ) {
  4753. clif->message(fd, msg_fd(fd,1180)); // You cannot autotrade when dead.
  4754. return false;
  4755. }
  4756. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4757. clif->message(fd, msg_fd(fd,549)); // "You should have a shop open in order to use @autotrade."
  4758. return false;
  4759. }
  4760. sd->state.autotrade = 1;
  4761. if( battle_config.at_timeout ) {
  4762. int timeout = atoi(message);
  4763. status->change_start(NULL,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0,
  4764. ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, SCFLAG_NONE);
  4765. }
  4766. channel->quit(sd);
  4767. clif->authfail_fd(sd->fd, 15);
  4768. /* currently standalone is not supporting buyingstores, so we rely on the previous method */
  4769. if( sd->state.buyingstore )
  4770. return true;
  4771. #ifdef AUTOTRADE_PERSISTENCY
  4772. sd->state.autotrade = 2;/** state will enter pre-save, we use it to rule out some criterias **/
  4773. pc->autotrade_prepare(sd);
  4774. return false;/* we fail to not cause it to proceed on is_atcommand */
  4775. #else
  4776. return true;
  4777. #endif
  4778. }
  4779. /*==========================================
  4780. * @changegm by durf (changed by Lupus)
  4781. * Changes Master of your Guild to a specified guild member
  4782. *------------------------------------------*/
  4783. ACMD(changegm) {
  4784. struct guild *g;
  4785. struct map_session_data *pl_sd;
  4786. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  4787. clif->message(fd, msg_fd(fd,1181)); // You need to be a Guild Master to use this command.
  4788. return false;
  4789. }
  4790. if (map->list[sd->bl.m].flag.guildlock || map->list[sd->bl.m].flag.gvg_castle) {
  4791. clif->message(fd, msg_fd(fd,1182)); // You cannot change guild leaders in this map.
  4792. return false;
  4793. }
  4794. if (!message[0]) {
  4795. clif->message(fd, msg_fd(fd,1183)); // Usage: @changegm <guild_member_name>
  4796. return false;
  4797. }
  4798. if ((pl_sd=map->nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4799. clif->message(fd, msg_fd(fd,1184)); // Target character must be online and be a guild member.
  4800. return false;
  4801. }
  4802. guild->gm_change(sd->status.guild_id, pl_sd);
  4803. return true;
  4804. }
  4805. /*==========================================
  4806. * @changeleader by Skotlex
  4807. * Changes the leader of a party.
  4808. *------------------------------------------*/
  4809. ACMD(changeleader) {
  4810. if (!message[0]) {
  4811. clif->message(fd, msg_fd(fd,1185)); // Usage: @changeleader <party_member_name>
  4812. return false;
  4813. }
  4814. if (party->changeleader(sd, map->nick2sd((char *) message)))
  4815. return true;
  4816. return false;
  4817. }
  4818. /*==========================================
  4819. * @partyoption by Skotlex
  4820. * Used to change the item share setting of a party.
  4821. *------------------------------------------*/
  4822. ACMD(partyoption)
  4823. {
  4824. struct party_data *p;
  4825. int mi, option;
  4826. char w1[16], w2[16];
  4827. if (sd->status.party_id == 0 || (p = party->search(sd->status.party_id)) == NULL)
  4828. {
  4829. clif->message(fd, msg_fd(fd,282));
  4830. return false;
  4831. }
  4832. ARR_FIND(0, MAX_PARTY, mi, p->data[mi].sd == sd);
  4833. if (mi == MAX_PARTY)
  4834. return false; //Shouldn't happen
  4835. if (!p->party.member[mi].leader)
  4836. {
  4837. clif->message(fd, msg_fd(fd,282));
  4838. return false;
  4839. }
  4840. if (!*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  4841. {
  4842. clif->message(fd, msg_fd(fd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  4843. return false;
  4844. }
  4845. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0); // TODO: Add documentation for these values
  4846. //Change item share type.
  4847. if (option != p->party.item)
  4848. party->changeoption(sd, p->party.exp, option);
  4849. else
  4850. clif->message(fd, msg_fd(fd,286));
  4851. return true;
  4852. }
  4853. /*==========================================
  4854. * @autoloot by Upa-Kun
  4855. * Turns on/off AutoLoot for a specific player
  4856. *------------------------------------------*/
  4857. ACMD(autoloot)
  4858. {
  4859. int rate;
  4860. // autoloot command without value
  4861. if (!*message)
  4862. {
  4863. if (sd->state.autoloot)
  4864. rate = 0;
  4865. else
  4866. rate = 10000;
  4867. } else {
  4868. double drate;
  4869. drate = atof(message);
  4870. rate = (int)(drate*100);
  4871. }
  4872. if (rate < 0) rate = 0;
  4873. if (rate > 10000) rate = 10000;
  4874. sd->state.autoloot = rate;
  4875. if (sd->state.autoloot) {
  4876. snprintf(atcmd_output, sizeof atcmd_output, msg_fd(fd,1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below.
  4877. clif->message(fd, atcmd_output);
  4878. }else
  4879. clif->message(fd, msg_fd(fd,1188)); // Autoloot is now off.
  4880. return true;
  4881. }
  4882. /*==========================================
  4883. * @alootid
  4884. *------------------------------------------*/
  4885. ACMD(autolootitem)
  4886. {
  4887. struct item_data *item_data = NULL;
  4888. int i;
  4889. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  4890. if (*message) {
  4891. if (message[0] == '+') {
  4892. message++;
  4893. action = 1;
  4894. }
  4895. else if (message[0] == '-') {
  4896. message++;
  4897. action = 2;
  4898. }
  4899. else if (!strcmp(message,"reset"))
  4900. action = 4;
  4901. if (action < 3) // add or remove
  4902. {
  4903. if ((item_data = itemdb->exists(atoi(message))) == NULL)
  4904. item_data = itemdb->search_name(message);
  4905. if (!item_data) {
  4906. // No items founds in the DB with Id or Name
  4907. clif->message(fd, msg_fd(fd,1189)); // Item not found.
  4908. return false;
  4909. }
  4910. }
  4911. }
  4912. switch (action) {
  4913. case 1:
  4914. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4915. if (i != AUTOLOOTITEM_SIZE) {
  4916. clif->message(fd, msg_fd(fd,1190)); // You're already autolooting this item.
  4917. return false;
  4918. }
  4919. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  4920. if (i == AUTOLOOTITEM_SIZE) {
  4921. clif->message(fd, msg_fd(fd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  4922. return false;
  4923. }
  4924. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  4925. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  4926. clif->message(fd, atcmd_output);
  4927. sd->state.autolooting = 1;
  4928. break;
  4929. case 2:
  4930. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4931. if (i == AUTOLOOTITEM_SIZE) {
  4932. clif->message(fd, msg_fd(fd,1193)); // You're currently not autolooting this item.
  4933. return false;
  4934. }
  4935. sd->state.autolootid[i] = 0;
  4936. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
  4937. clif->message(fd, atcmd_output);
  4938. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  4939. if (i == AUTOLOOTITEM_SIZE) {
  4940. sd->state.autolooting = 0;
  4941. }
  4942. break;
  4943. case 3:
  4944. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  4945. clif->message(fd, atcmd_output);
  4946. clif->message(fd, msg_fd(fd,1196)); // To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
  4947. clif->message(fd, msg_fd(fd,1197)); // "@alootid reset" will clear your autolootitem list.
  4948. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  4949. if (i == AUTOLOOTITEM_SIZE) {
  4950. clif->message(fd, msg_fd(fd,1198)); // Your autolootitem list is empty.
  4951. } else {
  4952. clif->message(fd, msg_fd(fd,1199)); // Items on your autolootitem list:
  4953. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  4954. {
  4955. if (sd->state.autolootid[i] == 0)
  4956. continue;
  4957. if (!(item_data = itemdb->exists(sd->state.autolootid[i]))) {
  4958. ShowDebug("Non-existant item %d on autolootitem list (account_id: %d, char_id: %d)", sd->state.autolootid[i], sd->status.account_id, sd->status.char_id);
  4959. continue;
  4960. }
  4961. safesnprintf(atcmd_output, sizeof(atcmd_output), "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  4962. clif->message(fd, atcmd_output);
  4963. }
  4964. }
  4965. break;
  4966. case 4:
  4967. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  4968. clif->message(fd, msg_fd(fd,1200)); // Your autolootitem list has been reset.
  4969. sd->state.autolooting = 0;
  4970. break;
  4971. }
  4972. return true;
  4973. }
  4974. /*==========================================
  4975. * @autoloottype
  4976. * Credits:
  4977. * chriser,Aleos
  4978. *------------------------------------------*/
  4979. ACMD(autoloottype) {
  4980. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  4981. enum item_types type = -1;
  4982. int ITEM_NONE = 0;
  4983. if (*message) {
  4984. if (message[0] == '+') {
  4985. message++;
  4986. action = 1;
  4987. } else if (message[0] == '-') {
  4988. message++;
  4989. action = 2;
  4990. } else if (strcmp(message,"reset") == 0) {
  4991. action = 4;
  4992. }
  4993. if (action < 3) {
  4994. // add or remove
  4995. if (strncmp(message, "healing", 3) == 0)
  4996. type = IT_HEALING;
  4997. else if (strncmp(message, "usable", 3) == 0)
  4998. type = IT_USABLE;
  4999. else if (strncmp(message, "etc", 3) == 0)
  5000. type = IT_ETC;
  5001. else if (strncmp(message, "weapon", 3) == 0)
  5002. type = IT_WEAPON;
  5003. else if (strncmp(message, "armor", 3) == 0)
  5004. type = IT_ARMOR;
  5005. else if (strncmp(message, "card", 3) == 0)
  5006. type = IT_CARD;
  5007. else if (strncmp(message, "petegg", 4) == 0)
  5008. type = IT_PETEGG;
  5009. else if (strncmp(message, "petarmor", 4) == 0)
  5010. type = IT_PETARMOR;
  5011. else if (strncmp(message, "ammo", 3) == 0)
  5012. type = IT_AMMO;
  5013. else {
  5014. clif->message(fd, msg_fd(fd,1491)); // Item type not found.
  5015. return false;
  5016. }
  5017. }
  5018. }
  5019. switch (action) {
  5020. case 1:
  5021. if (sd->state.autoloottype&(1<<type)) {
  5022. clif->message(fd, msg_fd(fd,1490)); // You're already autolooting this item type.
  5023. return false;
  5024. }
  5025. sd->state.autoloottype |= (1<<type); // Stores the type
  5026. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1492), itemdb->typename(type)); // Autolooting item type: '%s'
  5027. clif->message(fd, atcmd_output);
  5028. break;
  5029. case 2:
  5030. if (!(sd->state.autoloottype&(1<<type))) {
  5031. clif->message(fd, msg_fd(fd,1493)); // You're currently not autolooting this item type.
  5032. return false;
  5033. }
  5034. sd->state.autoloottype &= ~(1<<type);
  5035. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1494), itemdb->typename(type)); // Removed item type: '%s' from your autoloottype list.
  5036. clif->message(fd, atcmd_output);
  5037. break;
  5038. case 3:
  5039. clif->message(fd, msg_fd(fd,38)); // Invalid location number, or name.
  5040. {
  5041. // attempt to find the text help string
  5042. const char *text = atcommand_help_string(info);
  5043. if (text) clif->messageln(fd, text); // send the text to the client
  5044. }
  5045. if (sd->state.autoloottype == ITEM_NONE) {
  5046. clif->message(fd, msg_fd(fd,1495)); // Your autoloottype list is empty.
  5047. } else {
  5048. int i;
  5049. clif->message(fd, msg_fd(fd,1496)); // Item types on your autoloottype list:
  5050. for(i=0; i < IT_MAX; i++) {
  5051. if (sd->state.autoloottype&(1<<i)) {
  5052. safesnprintf(atcmd_output, sizeof(atcmd_output), " '%s'", itemdb->typename(i));
  5053. clif->message(fd, atcmd_output);
  5054. }
  5055. }
  5056. }
  5057. break;
  5058. case 4:
  5059. sd->state.autoloottype = ITEM_NONE;
  5060. clif->message(fd, msg_fd(fd,1497)); // Your autoloottype list has been reset.
  5061. break;
  5062. }
  5063. return true;
  5064. }
  5065. /*==========================================
  5066. * It is made to snow.
  5067. *------------------------------------------*/
  5068. ACMD(snow)
  5069. {
  5070. if (map->list[sd->bl.m].flag.snow) {
  5071. map->list[sd->bl.m].flag.snow=0;
  5072. clif->weather(sd->bl.m);
  5073. clif->message(fd, msg_fd(fd,1203)); // Snow has stopped falling.
  5074. } else {
  5075. map->list[sd->bl.m].flag.snow=1;
  5076. clif->weather(sd->bl.m);
  5077. clif->message(fd, msg_fd(fd,1204)); // It has started to snow.
  5078. }
  5079. return true;
  5080. }
  5081. /*==========================================
  5082. * Cherry tree snowstorm is made to fall. (Sakura)
  5083. *------------------------------------------*/
  5084. ACMD(sakura) {
  5085. if (map->list[sd->bl.m].flag.sakura) {
  5086. map->list[sd->bl.m].flag.sakura=0;
  5087. clif->weather(sd->bl.m);
  5088. clif->message(fd, msg_fd(fd,1205)); // Cherry tree leaves no longer fall.
  5089. } else {
  5090. map->list[sd->bl.m].flag.sakura=1;
  5091. clif->weather(sd->bl.m);
  5092. clif->message(fd, msg_fd(fd,1206)); // Cherry tree leaves have begun to fall.
  5093. }
  5094. return true;
  5095. }
  5096. /*==========================================
  5097. * Clouds appear.
  5098. *------------------------------------------*/
  5099. ACMD(clouds) {
  5100. if (map->list[sd->bl.m].flag.clouds) {
  5101. map->list[sd->bl.m].flag.clouds=0;
  5102. clif->weather(sd->bl.m);
  5103. clif->message(fd, msg_fd(fd,1207)); // The clouds has disappear.
  5104. } else {
  5105. map->list[sd->bl.m].flag.clouds=1;
  5106. clif->weather(sd->bl.m);
  5107. clif->message(fd, msg_fd(fd,1208)); // Clouds appear.
  5108. }
  5109. return true;
  5110. }
  5111. /*==========================================
  5112. * Different type of clouds using effect 516
  5113. *------------------------------------------*/
  5114. ACMD(clouds2) {
  5115. if (map->list[sd->bl.m].flag.clouds2) {
  5116. map->list[sd->bl.m].flag.clouds2=0;
  5117. clif->weather(sd->bl.m);
  5118. clif->message(fd, msg_fd(fd,1209)); // The alternative clouds disappear.
  5119. } else {
  5120. map->list[sd->bl.m].flag.clouds2=1;
  5121. clif->weather(sd->bl.m);
  5122. clif->message(fd, msg_fd(fd,1210)); // Alternative clouds appear.
  5123. }
  5124. return true;
  5125. }
  5126. /*==========================================
  5127. * Fog hangs over.
  5128. *------------------------------------------*/
  5129. ACMD(fog) {
  5130. if (map->list[sd->bl.m].flag.fog) {
  5131. map->list[sd->bl.m].flag.fog=0;
  5132. clif->weather(sd->bl.m);
  5133. clif->message(fd, msg_fd(fd,1211)); // The fog has gone.
  5134. } else {
  5135. map->list[sd->bl.m].flag.fog=1;
  5136. clif->weather(sd->bl.m);
  5137. clif->message(fd, msg_fd(fd,1212)); // Fog hangs over.
  5138. }
  5139. return true;
  5140. }
  5141. /*==========================================
  5142. * Fallen leaves fall.
  5143. *------------------------------------------*/
  5144. ACMD(leaves) {
  5145. if (map->list[sd->bl.m].flag.leaves) {
  5146. map->list[sd->bl.m].flag.leaves=0;
  5147. clif->weather(sd->bl.m);
  5148. clif->message(fd, msg_fd(fd,1213)); // Leaves no longer fall.
  5149. } else {
  5150. map->list[sd->bl.m].flag.leaves=1;
  5151. clif->weather(sd->bl.m);
  5152. clif->message(fd, msg_fd(fd,1214)); // Fallen leaves fall.
  5153. }
  5154. return true;
  5155. }
  5156. /*==========================================
  5157. * Fireworks appear.
  5158. *------------------------------------------*/
  5159. ACMD(fireworks) {
  5160. if (map->list[sd->bl.m].flag.fireworks) {
  5161. map->list[sd->bl.m].flag.fireworks=0;
  5162. clif->weather(sd->bl.m);
  5163. clif->message(fd, msg_fd(fd,1215)); // Fireworks have ended.
  5164. } else {
  5165. map->list[sd->bl.m].flag.fireworks=1;
  5166. clif->weather(sd->bl.m);
  5167. clif->message(fd, msg_fd(fd,1216)); // Fireworks have launched.
  5168. }
  5169. return true;
  5170. }
  5171. /*==========================================
  5172. * Clearing Weather Effects by Dexity
  5173. *------------------------------------------*/
  5174. ACMD(clearweather)
  5175. {
  5176. map->list[sd->bl.m].flag.snow=0;
  5177. map->list[sd->bl.m].flag.sakura=0;
  5178. map->list[sd->bl.m].flag.clouds=0;
  5179. map->list[sd->bl.m].flag.clouds2=0;
  5180. map->list[sd->bl.m].flag.fog=0;
  5181. map->list[sd->bl.m].flag.fireworks=0;
  5182. map->list[sd->bl.m].flag.leaves=0;
  5183. clif->weather(sd->bl.m);
  5184. clif->message(fd, msg_fd(fd,291)); // "Weather effects will disappear after teleporting or refreshing."
  5185. return true;
  5186. }
  5187. /*===============================================================
  5188. * Sound Command - plays a sound for everyone around! [Codemaster]
  5189. *---------------------------------------------------------------*/
  5190. ACMD(sound)
  5191. {
  5192. char sound_file[100];
  5193. memset(sound_file, '\0', sizeof(sound_file));
  5194. if(!*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5195. clif->message(fd, msg_fd(fd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5196. return false;
  5197. }
  5198. if(strstr(sound_file, ".wav") == NULL)
  5199. strcat(sound_file, ".wav");
  5200. clif->soundeffectall(&sd->bl, sound_file, 0, AREA);
  5201. return true;
  5202. }
  5203. /*==========================================
  5204. * MOB Search
  5205. *------------------------------------------*/
  5206. ACMD(mobsearch)
  5207. {
  5208. char mob_name[100];
  5209. int mob_id;
  5210. int number = 0;
  5211. struct s_mapiterator *it;
  5212. const struct mob_data *md = NULL;
  5213. if (!*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5214. clif->message(fd, msg_fd(fd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5215. return false;
  5216. }
  5217. if ((mob_id = atoi(mob_name)) == 0)
  5218. mob_id = mob->db_searchname(mob_name);
  5219. if(mob_id > 0 && mob->db_checkid(mob_id) == 0){
  5220. snprintf(atcmd_output, sizeof atcmd_output, msg_fd(fd,1219),mob_name); // Invalid mob ID %s!
  5221. clif->message(fd, atcmd_output);
  5222. return false;
  5223. }
  5224. if (mob_id == atoi(mob_name))
  5225. strcpy(mob_name,mob->db(mob_id)->jname); // --ja--
  5226. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5227. snprintf(atcmd_output, sizeof atcmd_output, msg_fd(fd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5228. clif->message(fd, atcmd_output);
  5229. it = mapit_geteachmob();
  5230. for (md = BL_UCCAST(BL_MOB, mapit->first(it)); mapit->exists(it); md = BL_UCCAST(BL_MOB, mapit->next(it))) {
  5231. if( md->bl.m != sd->bl.m )
  5232. continue;
  5233. if( mob_id != -1 && md->class_ != mob_id )
  5234. continue;
  5235. ++number;
  5236. if( md->spawn_timer == INVALID_TIMER )
  5237. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5238. else
  5239. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5240. clif->message(fd, atcmd_output);
  5241. }
  5242. mapit->free(it);
  5243. return true;
  5244. }
  5245. /*==========================================
  5246. * @cleanmap - cleans items on the ground
  5247. * @cleanarea - cleans items on the ground within an specified area
  5248. *------------------------------------------*/
  5249. int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) {
  5250. nullpo_ret(bl);
  5251. map->clearflooritem(bl);
  5252. return 0;
  5253. }
  5254. ACMD(cleanmap) {
  5255. map->foreachinmap(atcommand->cleanfloor_sub, sd->bl.m, BL_ITEM);
  5256. clif->message(fd, msg_fd(fd,1221)); // All dropped items have been cleaned up.
  5257. return true;
  5258. }
  5259. ACMD(cleanarea) {
  5260. int x0 = 0, y0 = 0, x1 = 0, y1 = 0, n = 0;
  5261. if (!*message || (n=sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1)) < 1) {
  5262. map->foreachinrange(atcommand->cleanfloor_sub, &sd->bl, AREA_SIZE * 2, BL_ITEM);
  5263. } else if (n == 4) {
  5264. map->foreachinarea(atcommand->cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5265. } else {
  5266. map->foreachinrange(atcommand->cleanfloor_sub, &sd->bl, x0, BL_ITEM);
  5267. }
  5268. clif->message(fd, msg_fd(fd,1221)); // All dropped items have been cleaned up.
  5269. return true;
  5270. }
  5271. /*==========================================
  5272. * make a NPC/PET talk
  5273. * @npctalkc [SnakeDrak]
  5274. *------------------------------------------*/
  5275. ACMD(npctalk)
  5276. {
  5277. char name[NAME_LENGTH],mes[100],temp[100];
  5278. struct npc_data *nd;
  5279. bool ifcolor=(*(info->command + 7) != 'c' && *(info->command + 7) != 'C')?0:1;
  5280. unsigned int color = 0;
  5281. if (!pc->can_talk(sd))
  5282. return false;
  5283. if(!ifcolor) {
  5284. if (!*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5285. clif->message(fd, msg_fd(fd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5286. return false;
  5287. }
  5288. }
  5289. else {
  5290. if (!*message || sscanf(message, "%12u %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5291. clif->message(fd, msg_fd(fd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5292. return false;
  5293. }
  5294. }
  5295. if (!(nd = npc->name2id(name))) {
  5296. clif->message(fd, msg_fd(fd,111)); // This NPC doesn't exist
  5297. return false;
  5298. }
  5299. strtok(name, "#"); // discard extra name identifier if present
  5300. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5301. if(ifcolor) clif->messagecolor(&nd->bl,color,temp);
  5302. else clif->disp_overhead(&nd->bl, temp);
  5303. return true;
  5304. }
  5305. ACMD(pettalk)
  5306. {
  5307. char mes[100],temp[100];
  5308. struct pet_data *pd;
  5309. if (battle_config.min_chat_delay) {
  5310. if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 )
  5311. return true;
  5312. sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay;
  5313. }
  5314. if (!sd->status.pet_id || !(pd=sd->pd))
  5315. {
  5316. clif->message(fd, msg_fd(fd,184));
  5317. return false;
  5318. }
  5319. if (!pc->can_talk(sd))
  5320. return false;
  5321. if (!*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5322. clif->message(fd, msg_fd(fd,1224)); // Please enter a message (usage: @pettalk <message>).
  5323. return false;
  5324. }
  5325. if (message[0] == '/')
  5326. { // pet emotion processing
  5327. const char* emo[] = {
  5328. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5329. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5330. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5331. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5332. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5333. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5334. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5335. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5336. "/whisp"
  5337. };
  5338. int i;
  5339. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5340. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5341. if( i < ARRAYLENGTH(emo) )
  5342. {
  5343. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5344. sd->emotionlasttime = time(NULL);
  5345. return true;
  5346. }
  5347. sd->emotionlasttime = time(NULL);
  5348. clif->emotion(&pd->bl, i);
  5349. return true;
  5350. }
  5351. }
  5352. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5353. clif->disp_overhead(&pd->bl, temp);
  5354. return true;
  5355. }
  5356. /// @users - displays the number of players present on each map (and percentage)
  5357. /// #users displays on the target user instead of self
  5358. ACMD(users)
  5359. {
  5360. char buf[CHAT_SIZE_MAX];
  5361. int users[MAX_MAPINDEX];
  5362. int users_all;
  5363. struct s_mapiterator *iter;
  5364. const struct map_session_data *pl_sd = NULL;
  5365. memset(users, 0, sizeof(users));
  5366. users_all = 0;
  5367. // count users on each map
  5368. iter = mapit_getallusers();
  5369. for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_PC, mapit->next(iter))) {
  5370. if (pl_sd->mapindex >= MAX_MAPINDEX)
  5371. continue;// invalid mapindex
  5372. if (users[pl_sd->mapindex] < INT_MAX)
  5373. ++users[pl_sd->mapindex];
  5374. if (users_all < INT_MAX)
  5375. ++users_all;
  5376. }
  5377. mapit->free(iter);
  5378. if (users_all) {
  5379. int i;
  5380. // display results for each map
  5381. for (i = 0; i < MAX_MAPINDEX; ++i) {
  5382. if (users[i] == 0)
  5383. continue; // empty
  5384. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5385. clif->message(sd->fd, buf);
  5386. }
  5387. }
  5388. // display overall count
  5389. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5390. clif->message(sd->fd, buf);
  5391. return true;
  5392. }
  5393. /*==========================================
  5394. *
  5395. *------------------------------------------*/
  5396. ACMD(reset) {
  5397. pc->resetstate(sd);
  5398. pc->resetskill(sd, PCRESETSKILL_RESYNC);
  5399. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,208), sd->status.name); // '%s' skill and stats points reseted!
  5400. clif->message(fd, atcmd_output);
  5401. return true;
  5402. }
  5403. /*==========================================
  5404. *
  5405. *------------------------------------------*/
  5406. ACMD(summon)
  5407. {
  5408. char name[NAME_LENGTH];
  5409. int mob_id = 0;
  5410. int duration = 0;
  5411. struct mob_data *md;
  5412. int64 tick=timer->gettick();
  5413. if (!*message || sscanf(message, "%23s %12d", name, &duration) < 1)
  5414. {
  5415. clif->message(fd, msg_fd(fd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5416. return false;
  5417. }
  5418. if (duration < 1)
  5419. duration =1;
  5420. else if (duration > 60)
  5421. duration =60;
  5422. if ((mob_id = atoi(name)) == 0)
  5423. mob_id = mob->db_searchname(name);
  5424. if(mob_id == 0 || mob->db_checkid(mob_id) == 0)
  5425. {
  5426. clif->message(fd, msg_fd(fd,40)); // Invalid monster ID or name.
  5427. return false;
  5428. }
  5429. md = mob->once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5430. if(!md)
  5431. return false;
  5432. md->master_id = sd->bl.id;
  5433. md->special_state.ai = AI_ATTACK;
  5434. md->deletetimer = timer->add(tick+(duration*60000),mob->timer_delete,md->bl.id,0);
  5435. clif->specialeffect(&md->bl,344,AREA);
  5436. mob->spawn(md);
  5437. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5438. clif->skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5439. clif->message(fd, msg_fd(fd,39)); // All monster summoned!
  5440. return true;
  5441. }
  5442. /*==========================================
  5443. * @adjgroup
  5444. * Temporarily move player to another group
  5445. * Useful during beta testing to allow players to use GM commands for short periods of time
  5446. *------------------------------------------*/
  5447. ACMD(adjgroup)
  5448. {
  5449. int new_group = 0;
  5450. if (!*message || sscanf(message, "%12d", &new_group) != 1) {
  5451. clif->message(fd, msg_fd(fd,1226)); // Usage: @adjgroup <group_id>
  5452. return false;
  5453. }
  5454. if (pc->set_group(sd, new_group) != 0) {
  5455. clif->message(fd, msg_fd(fd,1227)); // Specified group does not exist.
  5456. return false;
  5457. }
  5458. clif->message(fd, msg_fd(fd,1228)); // Group changed successfully.
  5459. clif->message(sd->fd, msg_fd(fd,1229)); // Your group has changed.
  5460. return true;
  5461. }
  5462. /*==========================================
  5463. * @trade by [MouseJstr]
  5464. * Open a trade window with a remote player
  5465. *------------------------------------------*/
  5466. ACMD(trade) {
  5467. struct map_session_data *pl_sd = NULL;
  5468. if (!*message) {
  5469. clif->message(fd, msg_fd(fd,1230)); // Please enter a player name (usage: @trade <char name>).
  5470. return false;
  5471. }
  5472. if ( (pl_sd = map->nick2sd((char *)message)) == NULL ) {
  5473. clif->message(fd, msg_fd(fd,3)); // Character not found.
  5474. return false;
  5475. }
  5476. trade->request(sd, pl_sd);
  5477. return true;
  5478. }
  5479. /*==========================================
  5480. * @setbattleflag by [MouseJstr]
  5481. * set a battle_config flag without having to reboot
  5482. *------------------------------------------*/
  5483. ACMD(setbattleflag)
  5484. {
  5485. char flag[128], value[128];
  5486. if (!*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5487. clif->message(fd, msg_fd(fd,1231)); // Usage: @setbattleflag <flag> <value>
  5488. return false;
  5489. }
  5490. if (battle->config_set_value(flag, value) == 0) {
  5491. clif->message(fd, msg_fd(fd,1232)); // Unknown battle_config flag.
  5492. return false;
  5493. }
  5494. clif->message(fd, msg_fd(fd,1233)); // Set battle_config as requested.
  5495. return true;
  5496. }
  5497. /*==========================================
  5498. * @unmute [Valaris]
  5499. *------------------------------------------*/
  5500. ACMD(unmute) {
  5501. struct map_session_data *pl_sd = NULL;
  5502. if (!*message) {
  5503. clif->message(fd, msg_fd(fd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5504. return false;
  5505. }
  5506. if ((pl_sd = map->nick2sd((char *)message)) == NULL)
  5507. {
  5508. clif->message(fd, msg_fd(fd,3)); // Character not found.
  5509. return false;
  5510. }
  5511. if (!pl_sd->sc.data[SC_NOCHAT]) {
  5512. clif->message(sd->fd,msg_fd(fd,1235)); // Player is not muted.
  5513. return false;
  5514. }
  5515. pl_sd->status.manner = 0;
  5516. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5517. clif->message(sd->fd,msg_fd(fd,1236)); // Player unmuted.
  5518. return true;
  5519. }
  5520. /*==========================================
  5521. * @uptime by MC Cameri
  5522. *------------------------------------------*/
  5523. ACMD(uptime)
  5524. {
  5525. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5526. minute = 60, days = 0, hours = 0, minutes = 0;
  5527. seconds = timer->get_uptime();
  5528. days = seconds/day;
  5529. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5530. hours = seconds/hour;
  5531. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5532. minutes = seconds/minute;
  5533. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5534. snprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,245), days, hours, minutes, seconds);
  5535. clif->message(fd, atcmd_output);
  5536. return true;
  5537. }
  5538. /*==========================================
  5539. * @changesex <sex>
  5540. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5541. *------------------------------------------*/
  5542. ACMD(changesex) {
  5543. int i;
  5544. pc->resetskill(sd, PCRESETSKILL_CHSEX);
  5545. // to avoid any problem with equipment and invalid sex, equipment is unequipped.
  5546. for (i=0; i<EQI_MAX; i++)
  5547. if (sd->equip_index[i] >= 0) pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE);
  5548. chrif->changesex(sd, true);
  5549. return true;
  5550. }
  5551. /*================================================
  5552. * @mute - Mutes a player for a set amount of time
  5553. *------------------------------------------------*/
  5554. ACMD(mute) {
  5555. struct map_session_data *pl_sd = NULL;
  5556. int manner;
  5557. if (!*message || sscanf(message, "%12d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5558. clif->message(fd, msg_fd(fd,1237)); // Usage: @mute <time> <char name>
  5559. return false;
  5560. }
  5561. if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) {
  5562. clif->message(fd, msg_fd(fd,3)); // Character not found.
  5563. return false;
  5564. }
  5565. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  5566. {
  5567. clif->message(fd, msg_fd(fd,81)); // Your GM level don't authorize you to do this action on this player.
  5568. return false;
  5569. }
  5570. clif->manner_message(sd, 0);
  5571. clif->manner_message(pl_sd, 5);
  5572. if (pl_sd->status.manner < manner) {
  5573. pl_sd->status.manner -= manner;
  5574. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  5575. } else {
  5576. pl_sd->status.manner = 0;
  5577. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5578. }
  5579. clif->GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5580. return true;
  5581. }
  5582. /*==========================================
  5583. * @refresh (like @jumpto <<yourself>>)
  5584. *------------------------------------------*/
  5585. ACMD(refresh)
  5586. {
  5587. clif->refresh(sd);
  5588. return true;
  5589. }
  5590. ACMD(refreshall)
  5591. {
  5592. struct map_session_data* iter_sd;
  5593. struct s_mapiterator* iter;
  5594. iter = mapit_getallusers();
  5595. for (iter_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); iter_sd = BL_UCAST(BL_PC, mapit->next(iter)))
  5596. clif->refresh(iter_sd);
  5597. mapit->free(iter);
  5598. return true;
  5599. }
  5600. /*==========================================
  5601. * @identify
  5602. * => GM's magnifier.
  5603. *------------------------------------------*/
  5604. ACMD(identify)
  5605. {
  5606. int i,num;
  5607. for (i=num=0;i<MAX_INVENTORY;i++) {
  5608. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5609. num++;
  5610. }
  5611. }
  5612. if (num > 0) {
  5613. clif->item_identify_list(sd);
  5614. } else {
  5615. clif->message(fd,msg_fd(fd,1238)); // There are no items to appraise.
  5616. }
  5617. return true;
  5618. }
  5619. ACMD(misceffect) {
  5620. int effect = 0;
  5621. if (!*message)
  5622. return false;
  5623. if (sscanf(message, "%12d", &effect) < 1)
  5624. return false;
  5625. clif->misceffect(&sd->bl,effect);
  5626. return true;
  5627. }
  5628. /*==========================================
  5629. * MAIL SYSTEM
  5630. *------------------------------------------*/
  5631. ACMD(mail)
  5632. {
  5633. mail->openmail(sd);
  5634. return true;
  5635. }
  5636. /*==========================================
  5637. * Show Monster DB Info v 1.0
  5638. * originally by [Lupus]
  5639. *------------------------------------------*/
  5640. ACMD(mobinfo)
  5641. {
  5642. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5643. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5644. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5645. char atcmd_output2[CHAT_SIZE_MAX];
  5646. struct item_data *item_data;
  5647. struct mob_db *monster, *mob_array[MAX_SEARCH];
  5648. int count;
  5649. int i, k;
  5650. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5651. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5652. if (!*message) {
  5653. clif->message(fd, msg_fd(fd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  5654. return false;
  5655. }
  5656. // If monster identifier/name argument is a name
  5657. if ((i = mob->db_checkid(atoi(message)))) {
  5658. mob_array[0] = mob->db(i);
  5659. count = 1;
  5660. } else
  5661. count = mob->db_searchname_array(mob_array, MAX_SEARCH, message, 0);
  5662. if (!count) {
  5663. clif->message(fd, msg_fd(fd,40)); // Invalid monster ID or name.
  5664. return false;
  5665. }
  5666. if (count > MAX_SEARCH) {
  5667. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,269), MAX_SEARCH, count);
  5668. clif->message(fd, atcmd_output);
  5669. count = MAX_SEARCH;
  5670. }
  5671. for (k = 0; k < count; k++) {
  5672. unsigned int job_exp, base_exp;
  5673. int j;
  5674. monster = mob_array[k];
  5675. job_exp = monster->job_exp;
  5676. base_exp = monster->base_exp;
  5677. #ifdef RENEWAL_EXP
  5678. if( battle_config.atcommand_mobinfo_type ) {
  5679. base_exp = base_exp * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 1) / 100;
  5680. job_exp = job_exp * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 1) / 100;
  5681. }
  5682. #endif
  5683. // stats
  5684. if (monster->mexp)
  5685. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1240), monster->name, monster->jname, monster->sprite, monster->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  5686. else
  5687. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1241), monster->name, monster->jname, monster->sprite, monster->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  5688. clif->message(fd, atcmd_output);
  5689. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1242), monster->lv, monster->status.max_hp, base_exp, job_exp, MOB_HIT(monster), MOB_FLEE(monster)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
  5690. clif->message(fd, atcmd_output);
  5691. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  5692. monster->status.def, monster->status.mdef, monster->status.str, monster->status.agi,
  5693. monster->status.vit, monster->status.int_, monster->status.dex, monster->status.luk);
  5694. clif->message(fd, atcmd_output);
  5695. #ifdef RENEWAL
  5696. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1291), // ATK : %d~%d MATK : %d~%d Range : %d~%d~%d Size : %s Race : %s Element : %s(Lv : %d)
  5697. MOB_ATK1(monster), MOB_ATK2(monster), MOB_MATK1(monster), MOB_MATK2(monster), monster->status.rhw.range,
  5698. monster->range2 , monster->range3, msize[monster->status.size],
  5699. mrace[monster->status.race], melement[monster->status.def_ele], monster->status.ele_lv);
  5700. #else
  5701. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  5702. monster->status.rhw.atk, monster->status.rhw.atk2, monster->status.rhw.range,
  5703. monster->range2 , monster->range3, msize[monster->status.size],
  5704. mrace[monster->status.race], melement[monster->status.def_ele], monster->status.ele_lv);
  5705. #endif
  5706. clif->message(fd, atcmd_output);
  5707. // drops
  5708. clif->message(fd, msg_fd(fd,1245)); // Drops:
  5709. strcpy(atcmd_output, " ");
  5710. j = 0;
  5711. for (i = 0; i < MAX_MOB_DROP; i++) {
  5712. int droprate;
  5713. if (monster->dropitem[i].nameid <= 0 || monster->dropitem[i].p < 1 || (item_data = itemdb->exists(monster->dropitem[i].nameid)) == NULL)
  5714. continue;
  5715. droprate = monster->dropitem[i].p;
  5716. #ifdef RENEWAL_DROP
  5717. if( battle_config.atcommand_mobinfo_type ) {
  5718. droprate = droprate * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 2) / 100;
  5719. if (droprate <= 0 && !battle_config.drop_rate0item)
  5720. droprate = 1;
  5721. }
  5722. #endif
  5723. if (item_data->slot)
  5724. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  5725. else
  5726. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  5727. strcat(atcmd_output, atcmd_output2);
  5728. if (++j % 3 == 0) {
  5729. clif->message(fd, atcmd_output);
  5730. strcpy(atcmd_output, " ");
  5731. }
  5732. }
  5733. if (j == 0)
  5734. clif->message(fd, msg_fd(fd,1246)); // This monster has no drops.
  5735. else if (j % 3 != 0)
  5736. clif->message(fd, atcmd_output);
  5737. // mvp
  5738. if (monster->mexp) {
  5739. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1247), monster->mexp); // MVP Bonus EXP:%u
  5740. clif->message(fd, atcmd_output);
  5741. safestrncpy(atcmd_output, msg_fd(fd,1248), sizeof(atcmd_output)); // MVP Items:
  5742. j = 0;
  5743. for (i = 0; i < MAX_MVP_DROP; i++) {
  5744. if (monster->mvpitem[i].nameid <= 0 || (item_data = itemdb->exists(monster->mvpitem[i].nameid)) == NULL)
  5745. continue;
  5746. if (monster->mvpitem[i].p > 0) {
  5747. j++;
  5748. if(item_data->slot)
  5749. sprintf(atcmd_output2, " %s%s[%d] %02.02f%%",j != 1 ? "- " : "", item_data->jname, item_data->slot, (float)monster->mvpitem[i].p / 100);
  5750. else
  5751. sprintf(atcmd_output2, " %s%s %02.02f%%",j != 1 ? "- " : "", item_data->jname, (float)monster->mvpitem[i].p / 100);
  5752. strcat(atcmd_output, atcmd_output2);
  5753. }
  5754. }
  5755. if (j == 0)
  5756. clif->message(fd, msg_fd(fd,1249)); // This monster has no MVP prizes.
  5757. else
  5758. clif->message(fd, atcmd_output);
  5759. }
  5760. }
  5761. return true;
  5762. }
  5763. /*=========================================
  5764. * @showmobs by KarLaeda
  5765. * => For 15 sec displays the mobs on minimap
  5766. *------------------------------------------*/
  5767. ACMD(showmobs)
  5768. {
  5769. char mob_name[100];
  5770. int mob_id;
  5771. int number = 0;
  5772. struct s_mapiterator *it;
  5773. const struct mob_data *md = NULL;
  5774. if (sscanf(message, "%99[^\n]", mob_name) < 0) {
  5775. clif->message(fd, msg_fd(fd,546)); // Please enter a mob name/id (usage: @showmobs <mob name/id>)
  5776. return false;
  5777. }
  5778. if( (mob_id = atoi(mob_name)) == 0 )
  5779. mob_id = mob->db_searchname(mob_name);
  5780. if( mob_id == 0 ) {
  5781. snprintf(atcmd_output, sizeof atcmd_output, msg_fd(fd,547), mob_name); // Invalid mob name %s!
  5782. clif->message(fd, atcmd_output);
  5783. return false;
  5784. }
  5785. if(mob_id > 0 && mob->db_checkid(mob_id) == 0){
  5786. snprintf(atcmd_output, sizeof atcmd_output, msg_fd(fd,1250),mob_name); // Invalid mob id %s!
  5787. clif->message(fd, atcmd_output);
  5788. return false;
  5789. }
  5790. if (mob->db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)) {
  5791. // If player group does not have access to boss mobs.
  5792. clif->message(fd, msg_fd(fd,1251)); // Can't show boss mobs!
  5793. return false;
  5794. }
  5795. if(mob_id == atoi(mob_name))
  5796. strcpy(mob_name,mob->db(mob_id)->jname); // --ja--
  5797. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5798. snprintf(atcmd_output, sizeof atcmd_output, msg_fd(fd,1252), // Mob Search... %s %s
  5799. mob_name, mapindex_id2name(sd->mapindex));
  5800. clif->message(fd, atcmd_output);
  5801. it = mapit_geteachmob();
  5802. for (md = BL_UCCAST(BL_MOB, mapit->first(it)); mapit->next(it); md = BL_UCCAST(BL_MOB, mapit->next(it))) {
  5803. if( md->bl.m != sd->bl.m )
  5804. continue;
  5805. if( mob_id != -1 && md->class_ != mob_id )
  5806. continue;
  5807. if (md->special_state.ai != AI_NONE || md->master_id)
  5808. continue; // hide slaves and player summoned mobs
  5809. if( md->spawn_timer != INVALID_TIMER )
  5810. continue; // hide mobs waiting for respawn
  5811. ++number;
  5812. clif->viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  5813. }
  5814. mapit->free(it);
  5815. return true;
  5816. }
  5817. /*==========================================
  5818. * homunculus level up [orn]
  5819. *------------------------------------------*/
  5820. ACMD(homlevel) {
  5821. struct homun_data *hd;
  5822. int level = 0;
  5823. enum homun_type htype;
  5824. if (!*message || ( level = atoi(message) ) < 1) {
  5825. clif->message(fd, msg_fd(fd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  5826. return false;
  5827. }
  5828. if (!homun_alive(sd->hd)) {
  5829. clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
  5830. return false;
  5831. }
  5832. hd = sd->hd;
  5833. if ((htype = homun->class2type(hd->homunculus.class_)) == HT_INVALID) {
  5834. ShowError("atcommand_homlevel: invalid homun class %d (player %s)\n", hd->homunculus.class_,sd->status.name);
  5835. return false;
  5836. }
  5837. switch( htype ) {
  5838. case HT_REG:
  5839. case HT_EVO:
  5840. if( hd->homunculus.level >= battle_config.hom_max_level ) {
  5841. snprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1478), hd->homunculus.level); // Homun reached its maximum level of '%d'
  5842. clif->message(fd, atcmd_output);
  5843. return true;
  5844. }
  5845. break;
  5846. case HT_S:
  5847. if( hd->homunculus.level >= battle_config.hom_S_max_level ) {
  5848. snprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1478), hd->homunculus.level); // Homun reached its maximum level of '%d'
  5849. clif->message(fd, atcmd_output);
  5850. return true;
  5851. }
  5852. break;
  5853. default:
  5854. ShowError("atcommand_homlevel: unknown htype '%d'\n",htype);
  5855. return false;
  5856. }
  5857. do {
  5858. hd->homunculus.exp += hd->exp_next;
  5859. } while( hd->homunculus.level < level && homun->levelup(hd) );
  5860. status_calc_homunculus(hd,SCO_NONE);
  5861. status_percent_heal(&hd->bl, 100, 100);
  5862. clif->specialeffect(&hd->bl,568,AREA);
  5863. return true;
  5864. }
  5865. /*==========================================
  5866. * homunculus evolution H [orn]
  5867. *------------------------------------------*/
  5868. ACMD(homevolution)
  5869. {
  5870. if ( !homun_alive(sd->hd) ) {
  5871. clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
  5872. return false;
  5873. }
  5874. if ( !homun->evolve(sd->hd) ) {
  5875. clif->message(fd, msg_fd(fd,1255)); // Your homunculus doesn't evolve.
  5876. return false;
  5877. }
  5878. clif->homskillinfoblock(sd);
  5879. return true;
  5880. }
  5881. ACMD(hommutate) {
  5882. int homun_id;
  5883. enum homun_type m_class, m_id;
  5884. if (!homun_alive(sd->hd)) {
  5885. clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
  5886. return false;
  5887. }
  5888. if (*message == '\0') {
  5889. homun_id = HOMID_EIRA + (rnd() % 4);
  5890. } else {
  5891. homun_id = atoi(message);
  5892. }
  5893. m_class = homun->class2type(sd->hd->homunculus.class_);
  5894. m_id = homun->class2type(homun_id);
  5895. if (m_class == HT_EVO && m_id == HT_S && sd->hd->homunculus.level >= 99) {
  5896. homun->mutate(sd->hd, homun_id);
  5897. } else {
  5898. clif->emotion(&sd->hd->bl, E_SWT);
  5899. }
  5900. return true;
  5901. }
  5902. /*==========================================
  5903. * call choosen homunculus [orn]
  5904. *------------------------------------------*/
  5905. ACMD(makehomun) {
  5906. int homunid;
  5907. if (!*message) {
  5908. clif->message(fd, msg_fd(fd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  5909. return false;
  5910. }
  5911. homunid = atoi(message);
  5912. if (homunid == -1 && sd->status.hom_id && !(sd->hd && homun_alive(sd->hd))) {
  5913. if (!sd->hd)
  5914. homun->call(sd);
  5915. else if( sd->hd->homunculus.vaporize )
  5916. homun->ressurect(sd, 100, sd->bl.x, sd->bl.y);
  5917. else
  5918. homun->call(sd);
  5919. return true;
  5920. }
  5921. if (sd->status.hom_id) {
  5922. clif->message(fd, msg_fd(fd,450));
  5923. return false;
  5924. }
  5925. if (homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1)
  5926. {
  5927. clif->message(fd, msg_fd(fd,1257)); // Invalid Homunculus ID.
  5928. return false;
  5929. }
  5930. homun->creation_request(sd,homunid);
  5931. return true;
  5932. }
  5933. /*==========================================
  5934. * modify homunculus intimacy [orn]
  5935. *------------------------------------------*/
  5936. ACMD(homfriendly)
  5937. {
  5938. int friendly = 0;
  5939. if (!homun_alive(sd->hd)) {
  5940. clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
  5941. return false;
  5942. }
  5943. if (!*message) {
  5944. clif->message(fd, msg_fd(fd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  5945. return false;
  5946. }
  5947. friendly = atoi(message);
  5948. friendly = cap_value(friendly, 0, 1000);
  5949. sd->hd->homunculus.intimacy = friendly * 100 ;
  5950. clif->send_homdata(sd,SP_INTIMATE,friendly);
  5951. return true;
  5952. }
  5953. /*==========================================
  5954. * modify homunculus hunger [orn]
  5955. *------------------------------------------*/
  5956. ACMD(homhungry)
  5957. {
  5958. int hungry = 0;
  5959. if (!homun_alive(sd->hd)) {
  5960. clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
  5961. return false;
  5962. }
  5963. if (!*message) {
  5964. clif->message(fd, msg_fd(fd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  5965. return false;
  5966. }
  5967. hungry = atoi(message);
  5968. hungry = cap_value(hungry, 0, 100);
  5969. sd->hd->homunculus.hunger = hungry;
  5970. clif->send_homdata(sd,SP_HUNGRY,hungry);
  5971. return true;
  5972. }
  5973. /*==========================================
  5974. * make the homunculus speak [orn]
  5975. *------------------------------------------*/
  5976. ACMD(homtalk)
  5977. {
  5978. char mes[100],temp[100];
  5979. if (battle_config.min_chat_delay) {
  5980. if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0)
  5981. return true;
  5982. sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay;
  5983. }
  5984. if (!pc->can_talk(sd))
  5985. return false;
  5986. if (!homun_alive(sd->hd)) {
  5987. clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
  5988. return false;
  5989. }
  5990. if (!*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5991. clif->message(fd, msg_fd(fd,1260)); // Please enter a message (usage: @homtalk <message>).
  5992. return false;
  5993. }
  5994. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  5995. clif->disp_overhead(&sd->hd->bl, temp);
  5996. return true;
  5997. }
  5998. /*==========================================
  5999. * Show homunculus stats
  6000. *------------------------------------------*/
  6001. ACMD(hominfo) {
  6002. struct homun_data *hd;
  6003. struct status_data *st;
  6004. if (!homun_alive(sd->hd)) {
  6005. clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
  6006. return false;
  6007. }
  6008. hd = sd->hd;
  6009. st = status->get_status_data(&hd->bl);
  6010. clif->message(fd, msg_fd(fd,1261)); // Homunculus stats:
  6011. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_fd(fd,1262), // HP: %d/%d - SP: %d/%d
  6012. st->hp, st->max_hp, st->sp, st->max_sp);
  6013. clif->message(fd, atcmd_output);
  6014. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_fd(fd,1263), // ATK: %d - MATK: %d~%d
  6015. st->rhw.atk2 +st->batk, st->matk_min, st->matk_max);
  6016. clif->message(fd, atcmd_output);
  6017. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_fd(fd,1264), // Hungry: %d - Intimacy: %u
  6018. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6019. clif->message(fd, atcmd_output);
  6020. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6021. msg_fd(fd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6022. st->str, st->agi, st->vit,
  6023. st->int_, st->dex, st->luk);
  6024. clif->message(fd, atcmd_output);
  6025. return true;
  6026. }
  6027. ACMD(homstats)
  6028. {
  6029. struct homun_data *hd;
  6030. struct s_homunculus_db *db;
  6031. struct s_homunculus *hom;
  6032. int lv, min, max, evo;
  6033. if (!homun_alive(sd->hd)) {
  6034. clif->message(fd, msg_fd(fd,1254)); // You do not have a homunculus.
  6035. return false;
  6036. }
  6037. hd = sd->hd;
  6038. hom = &hd->homunculus;
  6039. db = hd->homunculusDB;
  6040. lv = hom->level;
  6041. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6042. msg_fd(fd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6043. clif->message(fd, atcmd_output);
  6044. lv--; //Since the first increase is at level 2.
  6045. evo = (hom->class_ == db->evo_class);
  6046. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6047. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6048. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_fd(fd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6049. clif->message(fd, atcmd_output);
  6050. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6051. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6052. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_fd(fd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6053. clif->message(fd, atcmd_output);
  6054. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6055. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6056. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_fd(fd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6057. clif->message(fd, atcmd_output);
  6058. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6059. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6060. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_fd(fd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6061. clif->message(fd, atcmd_output);
  6062. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6063. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6064. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_fd(fd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6065. clif->message(fd, atcmd_output);
  6066. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6067. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6068. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_fd(fd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6069. clif->message(fd, atcmd_output);
  6070. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6071. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6072. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_fd(fd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6073. clif->message(fd, atcmd_output);
  6074. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6075. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6076. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_fd(fd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6077. clif->message(fd, atcmd_output);
  6078. return true;
  6079. }
  6080. ACMD(homshuffle)
  6081. {
  6082. if (!sd->hd)
  6083. return false; // nothing to do
  6084. if (!homun->shuffle(sd->hd))
  6085. return false;
  6086. clif->message(sd->fd, msg_fd(fd,1275)); // Homunculus stats altered.
  6087. atcommand_homstats(fd, sd, command, message, info); //Print out the new stats
  6088. return true;
  6089. }
  6090. /*==========================================
  6091. * Show Items DB Info v 1.0
  6092. * originally by [Lupus]
  6093. *------------------------------------------*/
  6094. ACMD(iteminfo)
  6095. {
  6096. struct item_data *item_array[MAX_SEARCH];
  6097. int i, count = 1;
  6098. if (!*message) {
  6099. clif->message(fd, msg_fd(fd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6100. return false;
  6101. }
  6102. if ((item_array[0] = itemdb->exists(atoi(message))) == NULL)
  6103. count = itemdb->search_name_array(item_array, MAX_SEARCH, message, 0);
  6104. if (!count) {
  6105. clif->message(fd, msg_fd(fd,19)); // Invalid item ID or name.
  6106. return false;
  6107. }
  6108. if (count > MAX_SEARCH) {
  6109. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6110. clif->message(fd, atcmd_output);
  6111. count = MAX_SEARCH;
  6112. }
  6113. for (i = 0; i < count; i++) {
  6114. struct item_data *item_data = item_array[i];
  6115. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
  6116. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6117. itemdb->typename(item_data->type),
  6118. (item_data->script==NULL)? msg_fd(fd,1278) : msg_fd(fd,1279) // None / With script
  6119. );
  6120. clif->message(fd, atcmd_output);
  6121. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
  6122. clif->message(fd, atcmd_output);
  6123. if (item_data->maxchance == -1)
  6124. safestrncpy(atcmd_output, msg_fd(fd,1281), sizeof(atcmd_output)); // - Available in the shops only.
  6125. else if ( !battle_config.atcommand_mobinfo_type ) {
  6126. if( item_data->maxchance )
  6127. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6128. else
  6129. safestrncpy(atcmd_output, msg_fd(fd,1283), sizeof(atcmd_output)); // - Monsters don't drop this item.
  6130. }
  6131. clif->message(fd, atcmd_output);
  6132. }
  6133. return true;
  6134. }
  6135. /*==========================================
  6136. * Show who drops the item.
  6137. *------------------------------------------*/
  6138. ACMD(whodrops)
  6139. {
  6140. struct item_data *item_array[MAX_SEARCH];
  6141. int i,j, count = 1;
  6142. if (!*message) {
  6143. clif->message(fd, msg_fd(fd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6144. return false;
  6145. }
  6146. if ((item_array[0] = itemdb->exists(atoi(message))) == NULL)
  6147. count = itemdb->search_name_array(item_array, MAX_SEARCH, message, 0);
  6148. if (!count) {
  6149. clif->message(fd, msg_fd(fd,19)); // Invalid item ID or name.
  6150. return false;
  6151. }
  6152. if (count > MAX_SEARCH) {
  6153. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6154. clif->message(fd, atcmd_output);
  6155. count = MAX_SEARCH;
  6156. }
  6157. for (i = 0; i < count; i++) {
  6158. struct item_data *item_data = item_array[i];
  6159. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1285), item_data->jname,item_data->slot); // Item: '%s'[%d]
  6160. clif->message(fd, atcmd_output);
  6161. if (item_data->mob[0].chance == 0) {
  6162. safestrncpy(atcmd_output, msg_fd(fd,1286), sizeof(atcmd_output)); // - Item is not dropped by mobs.
  6163. clif->message(fd, atcmd_output);
  6164. } else {
  6165. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6166. clif->message(fd, atcmd_output);
  6167. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6168. {
  6169. safesnprintf(atcmd_output, sizeof(atcmd_output), "- %s (%02.02f%%)", mob->db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6170. clif->message(fd, atcmd_output);
  6171. }
  6172. }
  6173. }
  6174. return true;
  6175. }
  6176. ACMD(whereis)
  6177. {
  6178. struct mob_db *mob_array[MAX_SEARCH];
  6179. int count;
  6180. int i, j, k;
  6181. if (!*message) {
  6182. clif->message(fd, msg_fd(fd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6183. return false;
  6184. }
  6185. // If monster identifier/name argument is a name
  6186. if ((i = mob->db_checkid(atoi(message))))
  6187. {
  6188. mob_array[0] = mob->db(i);
  6189. count = 1;
  6190. } else
  6191. count = mob->db_searchname_array(mob_array, MAX_SEARCH, message, 0);
  6192. if (!count) {
  6193. clif->message(fd, msg_fd(fd,40)); // Invalid monster ID or name.
  6194. return false;
  6195. }
  6196. if (count > MAX_SEARCH) {
  6197. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,269), MAX_SEARCH, count);
  6198. clif->message(fd, atcmd_output);
  6199. count = MAX_SEARCH;
  6200. }
  6201. for (k = 0; k < count; k++) {
  6202. struct mob_db *monster = mob_array[k];
  6203. snprintf(atcmd_output, sizeof atcmd_output, msg_fd(fd,1289), monster->jname); // %s spawns in:
  6204. clif->message(fd, atcmd_output);
  6205. for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++) {
  6206. j = map->mapindex2mapid(monster->spawn[i].mapindex);
  6207. if (j < 0) continue;
  6208. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map->list[j].name, monster->spawn[i].qty);
  6209. clif->message(fd, atcmd_output);
  6210. }
  6211. if (i == 0)
  6212. clif->message(fd, msg_fd(fd,1290)); // This monster does not spawn normally.
  6213. }
  6214. return true;
  6215. }
  6216. ACMD(version) {
  6217. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1296), sysinfo->is64bit() ? 64 : 32, sysinfo->platform()); // Hercules %d-bit for %s
  6218. clif->message(fd, atcmd_output);
  6219. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1295), sysinfo->vcstype(), sysinfo->vcsrevision_src(), sysinfo->vcsrevision_scripts()); // %s revision '%s' (src) / '%s' (scripts)
  6220. clif->message(fd, atcmd_output);
  6221. return true;
  6222. }
  6223. /*==========================================
  6224. * @mutearea by MouseJstr
  6225. *------------------------------------------*/
  6226. int atcommand_mutearea_sub(struct block_list *bl, va_list ap)
  6227. { // As it is being used [ACMD(mutearea)] there's no need to be a bool, but if there's need to reuse it, it's better to be this way
  6228. int time, id;
  6229. struct map_session_data *pl_sd = BL_CAST(BL_PC, bl);
  6230. if (pl_sd == NULL)
  6231. return 0;
  6232. id = va_arg(ap, int);
  6233. time = va_arg(ap, int);
  6234. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6235. pl_sd->status.manner -= time;
  6236. if (pl_sd->status.manner < 0)
  6237. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6238. else
  6239. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6240. }
  6241. return 1;
  6242. }
  6243. ACMD(mutearea) {
  6244. int time;
  6245. if (!*message) {
  6246. clif->message(fd, msg_fd(fd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6247. return false;
  6248. }
  6249. time = atoi(message);
  6250. map->foreachinarea(atcommand->mutearea_sub,sd->bl.m,
  6251. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6252. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6253. return true;
  6254. }
  6255. ACMD(rates)
  6256. {
  6257. char buf[CHAT_SIZE_MAX];
  6258. memset(buf, '\0', sizeof(buf));
  6259. safesnprintf(buf, CHAT_SIZE_MAX, msg_fd(fd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6260. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6261. clif->message(fd, buf);
  6262. safesnprintf(buf, CHAT_SIZE_MAX, msg_fd(fd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6263. battle_config.item_rate_common/100., battle_config.item_rate_heal/100., battle_config.item_rate_use/100., battle_config.item_rate_equip/100., battle_config.item_rate_card/100.);
  6264. clif->message(fd, buf);
  6265. safesnprintf(buf, CHAT_SIZE_MAX, msg_fd(fd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6266. battle_config.item_rate_common_boss/100., battle_config.item_rate_heal_boss/100., battle_config.item_rate_use_boss/100., battle_config.item_rate_equip_boss/100., battle_config.item_rate_card_boss/100.);
  6267. clif->message(fd, buf);
  6268. safesnprintf(buf, CHAT_SIZE_MAX, msg_fd(fd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6269. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6270. clif->message(fd, buf);
  6271. return true;
  6272. }
  6273. /*==========================================
  6274. * @me by lordalfa
  6275. * => Displays the OUTPUT string on top of the Visible players Heads.
  6276. *------------------------------------------*/
  6277. ACMD(me)
  6278. {
  6279. char tempmes[CHAT_SIZE_MAX];
  6280. memset(tempmes, '\0', sizeof(tempmes));
  6281. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6282. if (!pc->can_talk(sd))
  6283. return false;
  6284. if (!*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6285. clif->message(fd, msg_fd(fd,1302)); // Please enter a message (usage: @me <message>).
  6286. return false;
  6287. }
  6288. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,270), sd->status.name, tempmes); // *%s %s*
  6289. clif->disp_overhead(&sd->bl, atcmd_output);
  6290. return true;
  6291. }
  6292. /*==========================================
  6293. * @size
  6294. * => Resize your character sprite. [Valaris]
  6295. *------------------------------------------*/
  6296. ACMD(size)
  6297. {
  6298. int size = 0;
  6299. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6300. if(sd->state.size) {
  6301. sd->state.size = SZ_SMALL;
  6302. pc->setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6303. }
  6304. sd->state.size = size;
  6305. if( size == SZ_MEDIUM )
  6306. clif->specialeffect(&sd->bl,420,AREA);
  6307. else if( size == SZ_BIG )
  6308. clif->specialeffect(&sd->bl,422,AREA);
  6309. clif->message(fd, msg_fd(fd,1303)); // Size change applied.
  6310. return true;
  6311. }
  6312. ACMD(sizeall)
  6313. {
  6314. int size;
  6315. struct map_session_data *pl_sd;
  6316. struct s_mapiterator* iter;
  6317. size = atoi(message);
  6318. size = cap_value(size,0,2);
  6319. iter = mapit_getallusers();
  6320. for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) {
  6321. if (pl_sd->state.size != size) {
  6322. if (pl_sd->state.size) {
  6323. pl_sd->state.size = SZ_SMALL;
  6324. pc->setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6325. }
  6326. pl_sd->state.size = size;
  6327. if (size == SZ_MEDIUM)
  6328. clif->specialeffect(&pl_sd->bl,420,AREA);
  6329. else if (size == SZ_BIG)
  6330. clif->specialeffect(&pl_sd->bl,422,AREA);
  6331. }
  6332. }
  6333. mapit->free(iter);
  6334. clif->message(fd, msg_fd(fd,1303)); // Size change applied.
  6335. return true;
  6336. }
  6337. ACMD(sizeguild)
  6338. {
  6339. int size = 0, i;
  6340. char guild_name[NAME_LENGTH];
  6341. struct map_session_data *pl_sd;
  6342. struct guild *g;
  6343. memset(guild_name, '\0', sizeof(guild_name));
  6344. if (!*message || sscanf(message, "%d %23[^\n]", &size, guild_name) < 2) {
  6345. clif->message(fd, msg_fd(fd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6346. return false;
  6347. }
  6348. if ((g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(guild_name))) == NULL) {
  6349. clif->message(fd, msg_fd(fd,94)); // Incorrect name/ID, or no one from the guild is online.
  6350. return false;
  6351. }
  6352. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6353. for (i = 0; i < g->max_member; i++) {
  6354. if ((pl_sd = g->member[i].sd) && pl_sd->state.size != size) {
  6355. if( pl_sd->state.size ) {
  6356. pl_sd->state.size = SZ_SMALL;
  6357. pc->setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6358. }
  6359. pl_sd->state.size = size;
  6360. if( size == SZ_MEDIUM )
  6361. clif->specialeffect(&pl_sd->bl,420,AREA);
  6362. else if( size == SZ_BIG )
  6363. clif->specialeffect(&pl_sd->bl,422,AREA);
  6364. }
  6365. }
  6366. clif->message(fd, msg_fd(fd,1303)); // Size change applied.
  6367. return true;
  6368. }
  6369. /*==========================================
  6370. * @monsterignore
  6371. * => Makes monsters ignore you. [Valaris]
  6372. *------------------------------------------*/
  6373. ACMD(monsterignore)
  6374. {
  6375. if (!sd->state.monster_ignore) {
  6376. sd->state.monster_ignore = 1;
  6377. clif->message(sd->fd, msg_fd(fd,1305)); // You are now immune to attacks.
  6378. } else {
  6379. sd->state.monster_ignore = 0;
  6380. clif->message(sd->fd, msg_fd(fd,1306)); // Returned to normal state.
  6381. }
  6382. return true;
  6383. }
  6384. /*==========================================
  6385. * @fakename
  6386. * => Gives your character a fake name. [Valaris]
  6387. *------------------------------------------*/
  6388. ACMD(fakename)
  6389. {
  6390. if (!*message)
  6391. {
  6392. if (sd->fakename[0])
  6393. {
  6394. sd->fakename[0] = '\0';
  6395. clif->charnameack(0, &sd->bl);
  6396. if( sd->disguise )
  6397. clif->charnameack(sd->fd, &sd->bl);
  6398. clif->message(sd->fd, msg_fd(fd,1307)); // Returned to real name.
  6399. return true;
  6400. }
  6401. clif->message(sd->fd, msg_fd(fd,1308)); // You must enter a name.
  6402. return false;
  6403. }
  6404. if (strlen(message) < 2)
  6405. {
  6406. clif->message(sd->fd, msg_fd(fd,1309)); // Fake name must be at least two characters.
  6407. return false;
  6408. }
  6409. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6410. clif->charnameack(0, &sd->bl);
  6411. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  6412. clif->charnameack(sd->fd, &sd->bl);
  6413. clif->message(sd->fd, msg_fd(fd,1310)); // Fake name enabled.
  6414. return true;
  6415. }
  6416. /*==========================================
  6417. * Ragnarok Resources
  6418. *------------------------------------------*/
  6419. ACMD(mapflag) {
  6420. #define CHECKFLAG( cmd ) do { if (map->list[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd);} while(0)
  6421. #define SETFLAG( cmd ) do { \
  6422. if (strcmp( flag_name , #cmd ) == 0) { \
  6423. map->list[ sd->bl.m ].flag.cmd = flag; \
  6424. safesnprintf(atcmd_output, sizeof(atcmd_output),"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag); \
  6425. clif->message(sd->fd,atcmd_output); \
  6426. return true; \
  6427. } \
  6428. } while(0)
  6429. char flag_name[100];
  6430. short flag=0,i;
  6431. memset(flag_name, '\0', sizeof(flag_name));
  6432. if (!*message || (sscanf(message, "%99s %5hd", flag_name, &flag) < 1)) {
  6433. clif->message(sd->fd,msg_fd(fd,1311)); // Enabled Mapflags in this map:
  6434. clif->message(sd->fd,"----------------------------------");
  6435. CHECKFLAG(autotrade); CHECKFLAG(allowks); CHECKFLAG(nomemo); CHECKFLAG(noteleport);
  6436. CHECKFLAG(noreturn); CHECKFLAG(monster_noteleport); CHECKFLAG(nosave); CHECKFLAG(nobranch);
  6437. CHECKFLAG(noexppenalty); CHECKFLAG(pvp); CHECKFLAG(pvp_noparty); CHECKFLAG(pvp_noguild);
  6438. CHECKFLAG(pvp_nightmaredrop); CHECKFLAG(pvp_nocalcrank); CHECKFLAG(gvg_castle); CHECKFLAG(gvg);
  6439. CHECKFLAG(gvg_dungeon); CHECKFLAG(gvg_noparty); CHECKFLAG(battleground); CHECKFLAG(nozenypenalty);
  6440. CHECKFLAG(notrade); CHECKFLAG(noskill); CHECKFLAG(nowarp); CHECKFLAG(nowarpto);
  6441. CHECKFLAG(noicewall); CHECKFLAG(snow); CHECKFLAG(clouds); CHECKFLAG(clouds2);
  6442. CHECKFLAG(fog); CHECKFLAG(fireworks); CHECKFLAG(sakura); CHECKFLAG(leaves);
  6443. CHECKFLAG(nobaseexp);
  6444. CHECKFLAG(nojobexp); CHECKFLAG(nomobloot); CHECKFLAG(nomvploot); CHECKFLAG(nightenabled);
  6445. CHECKFLAG(nodrop); CHECKFLAG(novending); CHECKFLAG(loadevent);
  6446. CHECKFLAG(nochat); CHECKFLAG(partylock); CHECKFLAG(guildlock); CHECKFLAG(src4instance);
  6447. CHECKFLAG(notomb); CHECKFLAG(nocashshop); CHECKFLAG(noviewid);
  6448. clif->message(sd->fd," ");
  6449. clif->message(sd->fd,msg_fd(fd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6450. clif->message(sd->fd,msg_fd(fd,1313)); // Type "@mapflag available" to list the available mapflags.
  6451. return true;
  6452. }
  6453. for (i = 0; flag_name[i]; i++) flag_name[i] = TOLOWER(flag_name[i]); //lowercase
  6454. if (strcmp( flag_name , "gvg" ) == 0) {
  6455. if( flag && !map->list[sd->bl.m].flag.gvg )
  6456. map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME));
  6457. else if ( !flag && map->list[sd->bl.m].flag.gvg )
  6458. map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone);
  6459. } else if ( strcmp( flag_name , "pvp" ) == 0 ) {
  6460. if ( flag && !map->list[sd->bl.m].flag.pvp )
  6461. map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_PVP_NAME));
  6462. else if ( !flag && map->list[sd->bl.m].flag.pvp )
  6463. map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone);
  6464. } else if ( strcmp( flag_name , "battleground" ) == 0 ) {
  6465. if ( flag && !map->list[sd->bl.m].flag.battleground )
  6466. map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_BG_NAME));
  6467. else if ( !flag && map->list[sd->bl.m].flag.battleground )
  6468. map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone);
  6469. }
  6470. SETFLAG(autotrade); SETFLAG(allowks); SETFLAG(nomemo); SETFLAG(noteleport);
  6471. SETFLAG(noreturn); SETFLAG(monster_noteleport); SETFLAG(nosave); SETFLAG(nobranch);
  6472. SETFLAG(noexppenalty); SETFLAG(pvp); SETFLAG(pvp_noparty); SETFLAG(pvp_noguild);
  6473. SETFLAG(pvp_nightmaredrop); SETFLAG(pvp_nocalcrank); SETFLAG(gvg_castle); SETFLAG(gvg);
  6474. SETFLAG(gvg_dungeon); SETFLAG(gvg_noparty); SETFLAG(battleground); SETFLAG(nozenypenalty);
  6475. SETFLAG(notrade); SETFLAG(noskill); SETFLAG(nowarp); SETFLAG(nowarpto);
  6476. SETFLAG(noicewall); SETFLAG(snow); SETFLAG(clouds); SETFLAG(clouds2);
  6477. SETFLAG(fog); SETFLAG(fireworks); SETFLAG(sakura); SETFLAG(leaves);
  6478. SETFLAG(nobaseexp);
  6479. SETFLAG(nojobexp); SETFLAG(nomobloot); SETFLAG(nomvploot); SETFLAG(nightenabled);
  6480. SETFLAG(nodrop); SETFLAG(novending); SETFLAG(loadevent);
  6481. SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock); SETFLAG(src4instance);
  6482. SETFLAG(notomb); SETFLAG(nocashshop); SETFLAG(noviewid);
  6483. clif->message(sd->fd,msg_fd(fd,1314)); // Invalid flag name or flag.
  6484. clif->message(sd->fd,msg_fd(fd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6485. clif->message(sd->fd,msg_fd(fd,1315)); // Available Flags:
  6486. clif->message(sd->fd,"----------------------------------");
  6487. clif->message(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6488. clif->message(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6489. clif->message(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6490. clif->message(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6491. clif->message(sd->fd,"fog, fireworks, sakura, leaves, nobaseexp, nojobexp, nomobloot,");
  6492. clif->message(sd->fd,"nomvploot, nightenabled, nodrop, novending, loadevent, nochat, partylock,");
  6493. clif->message(sd->fd,"guildlock, src4instance, notomb, nocashshop, noviewid");
  6494. #undef CHECKFLAG
  6495. #undef SETFLAG
  6496. return true;
  6497. }
  6498. /*===================================
  6499. * Remove some messages
  6500. *-----------------------------------*/
  6501. ACMD(showexp)
  6502. {
  6503. if (sd->state.showexp) {
  6504. sd->state.showexp = 0;
  6505. clif->message(fd, msg_fd(fd,1316)); // Gained exp will not be shown.
  6506. return true;
  6507. }
  6508. sd->state.showexp = 1;
  6509. clif->message(fd, msg_fd(fd,1317)); // Gained exp is now shown.
  6510. return true;
  6511. }
  6512. ACMD(showzeny)
  6513. {
  6514. if (sd->state.showzeny) {
  6515. sd->state.showzeny = 0;
  6516. clif->message(fd, msg_fd(fd,1318)); // Gained zeny will not be shown.
  6517. return true;
  6518. }
  6519. sd->state.showzeny = 1;
  6520. clif->message(fd, msg_fd(fd,1319)); // Gained zeny is now shown.
  6521. return true;
  6522. }
  6523. ACMD(showdelay)
  6524. {
  6525. if (sd->state.showdelay) {
  6526. sd->state.showdelay = 0;
  6527. clif->message(fd, msg_fd(fd,1320)); // Skill delay failures will not be shown.
  6528. return true;
  6529. }
  6530. sd->state.showdelay = 1;
  6531. clif->message(fd, msg_fd(fd,1321)); // Skill delay failures are now shown.
  6532. return true;
  6533. }
  6534. /*==========================================
  6535. * Duel organizing functions [LuzZza]
  6536. *
  6537. * @duel [limit|nick] - create a duel
  6538. * @invite <nick> - invite player
  6539. * @accept - accept invitation
  6540. * @reject - reject invitation
  6541. * @leave - leave duel
  6542. *------------------------------------------*/
  6543. ACMD(invite) {
  6544. unsigned int did = sd->duel_group;
  6545. struct map_session_data *target_sd = map->nick2sd((char *)message);
  6546. if (did == 0)
  6547. {
  6548. // "Duel: @invite without @duel."
  6549. clif->message(fd, msg_fd(fd,350));
  6550. return false;
  6551. }
  6552. if (duel->list[did].max_players_limit > 0 &&
  6553. duel->list[did].members_count >= duel->list[did].max_players_limit) {
  6554. // "Duel: Limit of players is reached."
  6555. clif->message(fd, msg_fd(fd,351));
  6556. return false;
  6557. }
  6558. if (target_sd == NULL) {
  6559. // "Duel: Player not found."
  6560. clif->message(fd, msg_fd(fd,352));
  6561. return false;
  6562. }
  6563. if (target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6564. // "Duel: Player already in duel."
  6565. clif->message(fd, msg_fd(fd,353));
  6566. return false;
  6567. }
  6568. if (battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6569. {
  6570. // "Duel: You can't invite %s because he/she isn't in the same map."
  6571. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,364), message);
  6572. clif->message(fd, atcmd_output);
  6573. return false;
  6574. }
  6575. duel->invite(did, sd, target_sd);
  6576. // "Duel: Invitation has been sent."
  6577. clif->message(fd, msg_fd(fd,354));
  6578. return true;
  6579. }
  6580. ACMD(duel) {
  6581. unsigned int maxpl = 0;
  6582. if (sd->duel_group > 0) {
  6583. duel->showinfo(sd->duel_group, sd);
  6584. return true;
  6585. }
  6586. if (sd->duel_invite > 0) {
  6587. // "Duel: @duel without @reject."
  6588. clif->message(fd, msg_fd(fd,355));
  6589. return false;
  6590. }
  6591. if (!duel->checktime(sd)) {
  6592. char output[CHAT_SIZE_MAX];
  6593. // "Duel: You can take part in duel only one time per %d minutes."
  6594. sprintf(output, msg_fd(fd,356), battle_config.duel_time_interval);
  6595. clif->message(fd, output);
  6596. return false;
  6597. }
  6598. if (message[0]) {
  6599. if (sscanf(message, "%12u", &maxpl) >= 1) {
  6600. if (maxpl < 2 || maxpl > 65535) {
  6601. clif->message(fd, msg_fd(fd,357)); // "Duel: Invalid value."
  6602. return false;
  6603. }
  6604. duel->create(sd, maxpl);
  6605. } else {
  6606. struct map_session_data *target_sd;
  6607. target_sd = map->nick2sd((char *)message);
  6608. if (target_sd != NULL) {
  6609. unsigned int newduel;
  6610. if ((newduel = duel->create(sd, 2)) != -1) {
  6611. if (target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6612. clif->message(fd, msg_fd(fd,353)); // "Duel: Player already in duel."
  6613. return false;
  6614. }
  6615. duel->invite(newduel, sd, target_sd);
  6616. clif->message(fd, msg_fd(fd,354)); // "Duel: Invitation has been sent."
  6617. }
  6618. } else {
  6619. // "Duel: Player not found."
  6620. clif->message(fd, msg_fd(fd,352));
  6621. return false;
  6622. }
  6623. }
  6624. } else
  6625. duel->create(sd, 0);
  6626. return true;
  6627. }
  6628. ACMD(leave) {
  6629. if (sd->duel_group <= 0) {
  6630. // "Duel: @leave without @duel."
  6631. clif->message(fd, msg_fd(fd,358));
  6632. return false;
  6633. }
  6634. duel->leave(sd->duel_group, sd);
  6635. clif->message(fd, msg_fd(fd,359)); // "Duel: You left the duel."
  6636. return true;
  6637. }
  6638. ACMD(accept) {
  6639. if (!duel->checktime(sd)) {
  6640. char output[CHAT_SIZE_MAX];
  6641. // "Duel: You can take part in duel only one time per %d minutes."
  6642. sprintf(output, msg_fd(fd,356), battle_config.duel_time_interval);
  6643. clif->message(fd, output);
  6644. return false;
  6645. }
  6646. if (sd->duel_invite <= 0) {
  6647. // "Duel: @accept without invitation."
  6648. clif->message(fd, msg_fd(fd,360));
  6649. return false;
  6650. }
  6651. if (duel->list[sd->duel_invite].max_players_limit > 0
  6652. && duel->list[sd->duel_invite].members_count >= duel->list[sd->duel_invite].max_players_limit) {
  6653. // "Duel: Limit of players is reached."
  6654. clif->message(fd, msg_fd(fd,351));
  6655. return false;
  6656. }
  6657. duel->accept(sd->duel_invite, sd);
  6658. // "Duel: Invitation has been accepted."
  6659. clif->message(fd, msg_fd(fd,361));
  6660. return true;
  6661. }
  6662. ACMD(reject) {
  6663. if (sd->duel_invite <= 0) {
  6664. // "Duel: @reject without invitation."
  6665. clif->message(fd, msg_fd(fd,362));
  6666. return false;
  6667. }
  6668. duel->reject(sd->duel_invite, sd);
  6669. // "Duel: Invitation has been rejected."
  6670. clif->message(fd, msg_fd(fd,363));
  6671. return true;
  6672. }
  6673. /*===================================
  6674. * Cash Points
  6675. *-----------------------------------*/
  6676. ACMD(cash)
  6677. {
  6678. char output[128];
  6679. int value;
  6680. int ret=0;
  6681. if (!*message || (value = atoi(message)) == 0) {
  6682. clif->message(fd, msg_fd(fd,1322)); // Please enter an amount.
  6683. return false;
  6684. }
  6685. if (!strcmpi(info->command,"cash")) {
  6686. if( value > 0 ) {
  6687. if( (ret=pc->getcash(sd, value, 0)) >= 0){
  6688. // If this option is set, the message is already sent by pc function
  6689. if( !battle_config.cashshop_show_points ){
  6690. sprintf(output, msg_fd(fd,505), ret, sd->cashPoints);
  6691. clif_disp_onlyself(sd, output, strlen(output));
  6692. clif->message(fd, output);
  6693. }
  6694. } else
  6695. clif->message(fd, msg_fd(fd,149)); // Unable to decrease the number/value.
  6696. } else {
  6697. if( (ret=pc->paycash(sd, -value, 0)) >= 0){
  6698. sprintf(output, msg_fd(fd,410), ret, sd->cashPoints);
  6699. clif_disp_onlyself(sd, output, strlen(output));
  6700. clif->message(fd, output);
  6701. } else
  6702. clif->message(fd, msg_fd(fd,41)); // Unable to decrease the number/value.
  6703. }
  6704. } else { // @points
  6705. if( value > 0 ) {
  6706. if( (ret=pc->getcash(sd, 0, value)) >= 0) {
  6707. // If this option is set, the message is already sent by pc function
  6708. if( !battle_config.cashshop_show_points ){
  6709. sprintf(output, msg_fd(fd,506), ret, sd->kafraPoints);
  6710. clif_disp_onlyself(sd, output, strlen(output));
  6711. clif->message(fd, output);
  6712. }
  6713. } else
  6714. clif->message(fd, msg_fd(fd,149)); // Unable to decrease the number/value.
  6715. } else {
  6716. if( (ret=pc->paycash(sd, -value, -value)) >= 0){
  6717. sprintf(output, msg_fd(fd,411), ret, sd->kafraPoints);
  6718. clif_disp_onlyself(sd, output, strlen(output));
  6719. clif->message(fd, output);
  6720. } else
  6721. clif->message(fd, msg_fd(fd,41)); // Unable to decrease the number/value.
  6722. }
  6723. }
  6724. return true;
  6725. }
  6726. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6727. ACMD(clone) {
  6728. int x=0,y=0,flag=0,master=0,i=0;
  6729. struct map_session_data *pl_sd=NULL;
  6730. if (!*message) {
  6731. clif->message(sd->fd,msg_fd(fd,1323)); // You must enter a player name or ID.
  6732. return false;
  6733. }
  6734. if ((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) {
  6735. clif->message(fd, msg_fd(fd,3)); // Character not found.
  6736. return false;
  6737. }
  6738. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  6739. clif->message(fd, msg_fd(fd,126)); // Cannot clone a player of higher GM level than yourself.
  6740. return false;
  6741. }
  6742. if (strcmpi(info->command, "clone") == 0)
  6743. flag = 1;
  6744. else if (strcmpi(info->command, "slaveclone") == 0) {
  6745. flag = 2;
  6746. if (pc_isdead(sd)){
  6747. //"Unable to spawn slave clone."
  6748. clif->message(fd, msg_fd(fd,129+flag*2));
  6749. return false;
  6750. }
  6751. master = sd->bl.id;
  6752. if (battle_config.atc_slave_clone_limit
  6753. && mob->countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6754. clif->message(fd, msg_fd(fd,127)); // You've reached your slave clones limit.
  6755. return false;
  6756. }
  6757. }
  6758. do {
  6759. x = sd->bl.x + (rnd() % 10 - 5);
  6760. y = sd->bl.y + (rnd() % 10 - 5);
  6761. } while (map->getcell(sd->bl.m, &sd->bl, x, y, CELL_CHKNOPASS) && i++ < 10);
  6762. if (i >= 10) {
  6763. x = sd->bl.x;
  6764. y = sd->bl.y;
  6765. }
  6766. if ((x = mob->clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6767. clif->message(fd, msg_fd(fd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6768. return true;
  6769. }
  6770. clif->message(fd, msg_fd(fd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6771. return false;
  6772. }
  6773. /*=====================================
  6774. * Autorejecting Invites/Deals [LuzZza]
  6775. * Usage: @noask
  6776. *-------------------------------------*/
  6777. ACMD(noask)
  6778. {
  6779. if (sd->state.noask) {
  6780. clif->message(fd, msg_fd(fd,391)); // Autorejecting is deactivated.
  6781. sd->state.noask = 0;
  6782. } else {
  6783. clif->message(fd, msg_fd(fd,390)); // Autorejecting is activated.
  6784. sd->state.noask = 1;
  6785. }
  6786. return true;
  6787. }
  6788. /*=====================================
  6789. * Send a @request message to all GMs of lowest_gm_level.
  6790. * Usage: @request <petition>
  6791. *-------------------------------------*/
  6792. ACMD(request)
  6793. {
  6794. if (!*message) {
  6795. clif->message(sd->fd,msg_fd(fd,277)); // Usage: @request <petition/message to online GMs>.
  6796. return false;
  6797. }
  6798. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,278), message); // (@request): %s
  6799. intif->wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  6800. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6801. clif->message(sd->fd,msg_fd(fd,279)); // @request sent.
  6802. return true;
  6803. }
  6804. /*==========================================
  6805. * Feel (SG save map) Reset [HiddenDragon]
  6806. *------------------------------------------*/
  6807. ACMD(feelreset)
  6808. {
  6809. pc->resetfeel(sd);
  6810. clif->message(fd, msg_fd(fd,1324)); // Reset 'Feeling' maps.
  6811. return true;
  6812. }
  6813. /*==========================================
  6814. * AUCTION SYSTEM
  6815. *------------------------------------------*/
  6816. ACMD(auction)
  6817. {
  6818. if (!battle_config.feature_auction) {
  6819. clif->messagecolor_self(sd->fd, COLOR_RED, msg_fd(fd,1484));
  6820. return false;
  6821. }
  6822. clif->auction_openwindow(sd);
  6823. return true;
  6824. }
  6825. /*==========================================
  6826. * Kill Steal Protection
  6827. *------------------------------------------*/
  6828. ACMD(ksprotection) {
  6829. if( sd->state.noks ) {
  6830. sd->state.noks = KSPROTECT_NONE;
  6831. clif->message(fd, msg_fd(fd,1325)); // [ K.S Protection Inactive ]
  6832. } else if (!*message || strcmpi(message, "party") == 0) {
  6833. // Default is Party
  6834. sd->state.noks = KSPROTECT_PARTY;
  6835. clif->message(fd, msg_fd(fd,1326)); // [ K.S Protection Active - Option: Party ]
  6836. } else if( strcmpi(message, "self") == 0 ) {
  6837. sd->state.noks = KSPROTECT_SELF;
  6838. clif->message(fd, msg_fd(fd,1327)); // [ K.S Protection Active - Option: Self ]
  6839. } else if( strcmpi(message, "guild") == 0 ) {
  6840. sd->state.noks = KSPROTECT_GUILD;
  6841. clif->message(fd, msg_fd(fd,1328)); // [ K.S Protection Active - Option: Guild ]
  6842. } else {
  6843. clif->message(fd, msg_fd(fd,1329)); // Usage: @noks <self|party|guild>
  6844. }
  6845. return true;
  6846. }
  6847. /*==========================================
  6848. * Map Kill Steal Protection Setting
  6849. *------------------------------------------*/
  6850. ACMD(allowks)
  6851. {
  6852. if( map->list[sd->bl.m].flag.allowks ) {
  6853. map->list[sd->bl.m].flag.allowks = 0;
  6854. clif->message(fd, msg_fd(fd,1330)); // [ Map K.S Protection Active ]
  6855. } else {
  6856. map->list[sd->bl.m].flag.allowks = 1;
  6857. clif->message(fd, msg_fd(fd,1331)); // [ Map K.S Protection Inactive ]
  6858. }
  6859. return true;
  6860. }
  6861. ACMD(resetstat)
  6862. {
  6863. pc->resetstate(sd);
  6864. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,207), sd->status.name);
  6865. clif->message(fd, atcmd_output);
  6866. return true;
  6867. }
  6868. ACMD(resetskill)
  6869. {
  6870. pc->resetskill(sd, PCRESETSKILL_RESYNC);
  6871. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,206), sd->status.name);
  6872. clif->message(fd, atcmd_output);
  6873. return true;
  6874. }
  6875. /*==========================================
  6876. * #storagelist: Displays the items list of a player's storage.
  6877. * #cartlist: Displays contents of target's cart.
  6878. * #itemlist: Displays contents of target's inventory.
  6879. *------------------------------------------*/
  6880. ACMD(itemlist)
  6881. {
  6882. int i, j, count, counter;
  6883. const char* location;
  6884. const struct item* items;
  6885. int size;
  6886. StringBuf buf;
  6887. if( strcmpi(info->command, "storagelist") == 0 ) {
  6888. location = "storage";
  6889. items = sd->status.storage.items;
  6890. size = MAX_STORAGE;
  6891. } else if( strcmpi(info->command, "cartlist") == 0 ) {
  6892. location = "cart";
  6893. items = sd->status.cart;
  6894. size = MAX_CART;
  6895. } else if( strcmpi(info->command, "itemlist") == 0 ) {
  6896. location = "inventory";
  6897. items = sd->status.inventory;
  6898. size = MAX_INVENTORY;
  6899. } else
  6900. return false;
  6901. StrBuf->Init(&buf);
  6902. count = 0; // total slots occupied
  6903. counter = 0; // total items found
  6904. for( i = 0; i < size; ++i )
  6905. {
  6906. const struct item* it = &items[i];
  6907. struct item_data* itd;
  6908. if( it->nameid == 0 || (itd = itemdb->exists(it->nameid)) == NULL )
  6909. continue;
  6910. counter += it->amount;
  6911. count++;
  6912. if( count == 1 )
  6913. {
  6914. StrBuf->Printf(&buf, msg_fd(fd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  6915. clif->message(fd, StrBuf->Value(&buf));
  6916. StrBuf->Clear(&buf);
  6917. }
  6918. if( it->refine )
  6919. StrBuf->Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  6920. else
  6921. StrBuf->Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  6922. if( it->equip ) {
  6923. char equipstr[CHAT_SIZE_MAX];
  6924. strcpy(equipstr, msg_fd(fd,1333)); // | equipped:
  6925. if( it->equip & EQP_GARMENT )
  6926. strcat(equipstr, msg_fd(fd,1334)); // garment,
  6927. if( it->equip & EQP_ACC_L )
  6928. strcat(equipstr, msg_fd(fd,1335)); // left accessory,
  6929. if( it->equip & EQP_ARMOR )
  6930. strcat(equipstr, msg_fd(fd,1336)); // body/armor,
  6931. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  6932. strcat(equipstr, msg_fd(fd,1337)); // right hand,
  6933. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  6934. strcat(equipstr, msg_fd(fd,1338)); // left hand,
  6935. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  6936. strcat(equipstr, msg_fd(fd,1339)); // both hands,
  6937. if( it->equip & EQP_SHOES )
  6938. strcat(equipstr, msg_fd(fd,1340)); // feet,
  6939. if( it->equip & EQP_ACC_R )
  6940. strcat(equipstr, msg_fd(fd,1341)); // right accessory,
  6941. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  6942. strcat(equipstr, msg_fd(fd,1342)); // lower head,
  6943. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  6944. strcat(equipstr, msg_fd(fd,1343)); // top head,
  6945. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  6946. strcat(equipstr, msg_fd(fd,1344)); // lower/top head,
  6947. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  6948. strcat(equipstr, msg_fd(fd,1345)); // mid head,
  6949. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  6950. strcat(equipstr, msg_fd(fd,1346)); // lower/mid head,
  6951. if( (it->equip & EQP_HELM) == EQP_HELM )
  6952. strcat(equipstr, msg_fd(fd,1347)); // lower/mid/top head,
  6953. // remove final ', '
  6954. equipstr[strlen(equipstr) - 2] = '\0';
  6955. StrBuf->AppendStr(&buf, equipstr);
  6956. }
  6957. clif->message(fd, StrBuf->Value(&buf));
  6958. StrBuf->Clear(&buf);
  6959. if( it->card[0] == CARD0_PET ) {
  6960. // pet egg
  6961. if (it->card[3])
  6962. StrBuf->Printf(&buf, msg_fd(fd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  6963. else
  6964. StrBuf->Printf(&buf, msg_fd(fd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  6965. } else if(it->card[0] == CARD0_FORGE) {
  6966. // forged item
  6967. StrBuf->Printf(&buf, msg_fd(fd,1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d)
  6968. } else if(it->card[0] == CARD0_CREATE) {
  6969. // created item
  6970. StrBuf->Printf(&buf, msg_fd(fd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  6971. } else {
  6972. // normal item
  6973. int counter2 = 0;
  6974. for( j = 0; j < itd->slot; ++j ) {
  6975. struct item_data* card;
  6976. if( it->card[j] == 0 || (card = itemdb->exists(it->card[j])) == NULL )
  6977. continue;
  6978. counter2++;
  6979. if( counter2 == 1 )
  6980. StrBuf->AppendStr(&buf, msg_fd(fd,1352)); // -> (card(s):
  6981. if( counter2 != 1 )
  6982. StrBuf->AppendStr(&buf, ", ");
  6983. StrBuf->Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  6984. }
  6985. if( counter2 > 0 )
  6986. StrBuf->AppendStr(&buf, ")");
  6987. }
  6988. if( StrBuf->Length(&buf) > 0 )
  6989. clif->message(fd, StrBuf->Value(&buf));
  6990. StrBuf->Clear(&buf);
  6991. }
  6992. if( count == 0 )
  6993. StrBuf->Printf(&buf, msg_fd(fd,1353), location); // No item found in this player's %s.
  6994. else
  6995. StrBuf->Printf(&buf, msg_fd(fd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  6996. clif->message(fd, StrBuf->Value(&buf));
  6997. StrBuf->Destroy(&buf);
  6998. return true;
  6999. }
  7000. ACMD(stats)
  7001. {
  7002. char job_jobname[100];
  7003. char output[CHAT_SIZE_MAX];
  7004. int i;
  7005. struct {
  7006. const char* format;
  7007. int value;
  7008. } output_table[] = {
  7009. { "Base Level - %d", 0 },
  7010. { NULL, 0 },
  7011. { "Hp - %d", 0 },
  7012. { "MaxHp - %d", 0 },
  7013. { "Sp - %d", 0 },
  7014. { "MaxSp - %d", 0 },
  7015. { "Str - %3d", 0 },
  7016. { "Agi - %3d", 0 },
  7017. { "Vit - %3d", 0 },
  7018. { "Int - %3d", 0 },
  7019. { "Dex - %3d", 0 },
  7020. { "Luk - %3d", 0 },
  7021. { "Zeny - %d", 0 },
  7022. { "Free SK Points - %d", 0 },
  7023. { "JobChangeLvl (2nd) - %d", 0 },
  7024. { "JobChangeLvl (3rd) - %d", 0 },
  7025. { NULL, 0 }
  7026. };
  7027. memset(job_jobname, '\0', sizeof(job_jobname));
  7028. memset(output, '\0', sizeof(output));
  7029. //direct array initialization with variables is not standard C compliant.
  7030. output_table[0].value = sd->status.base_level;
  7031. output_table[1].format = job_jobname;
  7032. output_table[1].value = sd->status.job_level;
  7033. output_table[2].value = sd->status.hp;
  7034. output_table[3].value = sd->status.max_hp;
  7035. output_table[4].value = sd->status.sp;
  7036. output_table[5].value = sd->status.max_sp;
  7037. output_table[6].value = sd->status.str;
  7038. output_table[7].value = sd->status.agi;
  7039. output_table[8].value = sd->status.vit;
  7040. output_table[9].value = sd->status.int_;
  7041. output_table[10].value = sd->status.dex;
  7042. output_table[11].value = sd->status.luk;
  7043. output_table[12].value = sd->status.zeny;
  7044. output_table[13].value = sd->status.skill_point;
  7045. output_table[14].value = sd->change_level_2nd;
  7046. output_table[15].value = sd->change_level_3rd;
  7047. sprintf(job_jobname, "Job - %s %s", pc->job_name(sd->status.class_), "(level %d)");
  7048. sprintf(output, msg_fd(fd,53), sd->status.name); // '%s' stats:
  7049. clif->message(fd, output);
  7050. for (i = 0; output_table[i].format != NULL; i++) {
  7051. sprintf(output, output_table[i].format, output_table[i].value);
  7052. clif->message(fd, output);
  7053. }
  7054. return true;
  7055. }
  7056. ACMD(delitem) {
  7057. char item_name[100];
  7058. int nameid, amount = 0, total, idx;
  7059. struct item_data* id;
  7060. if (!*message || (sscanf(message, "\"%99[^\"]\" %12d", item_name, &amount) < 2 && sscanf(message, "%99s %12d", item_name, &amount) < 2) || amount < 1)
  7061. {
  7062. clif->message(fd, msg_fd(fd,1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
  7063. return false;
  7064. }
  7065. if ((id = itemdb->search_name(item_name)) != NULL || (id = itemdb->exists(atoi(item_name))) != NULL)
  7066. {
  7067. nameid = id->nameid;
  7068. }
  7069. else
  7070. {
  7071. clif->message(fd, msg_fd(fd,19)); // Invalid item ID or name.
  7072. return false;
  7073. }
  7074. total = amount;
  7075. // delete items
  7076. while (amount && (idx = pc->search_inventory(sd, nameid)) != INDEX_NOT_FOUND) {
  7077. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7078. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7079. {// delete pet
  7080. intif->delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7081. }
  7082. pc->delitem(sd, idx, delamount, 0, DELITEM_NORMAL, LOG_TYPE_COMMAND);
  7083. amount-= delamount;
  7084. }
  7085. // notify target
  7086. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,113), total-amount); // %d item(s) removed by a GM.
  7087. clif->message(sd->fd, atcmd_output);
  7088. // notify source
  7089. if( amount == total )
  7090. {
  7091. clif->message(fd, msg_fd(fd,116)); // Character does not have the item.
  7092. }
  7093. else if( amount )
  7094. {
  7095. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7096. clif->message(fd, atcmd_output);
  7097. }
  7098. else
  7099. {
  7100. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,114), total); // %d item(s) removed from the player.
  7101. clif->message(fd, atcmd_output);
  7102. }
  7103. return true;
  7104. }
  7105. /*==========================================
  7106. * Custom Fonts
  7107. *------------------------------------------*/
  7108. ACMD(font) {
  7109. int font_id;
  7110. font_id = atoi(message);
  7111. if( font_id == 0 )
  7112. {
  7113. if( sd->status.font )
  7114. {
  7115. sd->status.font = 0;
  7116. clif->message(fd, msg_fd(fd,1356)); // Returning to normal font.
  7117. clif->font(sd);
  7118. }
  7119. else
  7120. {
  7121. clif->message(fd, msg_fd(fd,1357)); // Use @font <1-9> to change your message font.
  7122. clif->message(fd, msg_fd(fd,1358)); // Use 0 or no parameter to return to normal font.
  7123. }
  7124. }
  7125. else if( font_id < 0 || font_id > 9 )
  7126. clif->message(fd, msg_fd(fd,1359)); // Invalid font. Use a value from 0 to 9.
  7127. else if( font_id != sd->status.font )
  7128. {
  7129. sd->status.font = font_id;
  7130. clif->font(sd);
  7131. clif->message(fd, msg_fd(fd,1360)); // Font changed.
  7132. }
  7133. else
  7134. clif->message(fd, msg_fd(fd,1361)); // Already using this font.
  7135. return true;
  7136. }
  7137. /*==========================================
  7138. * type: 1 = commands (@), 2 = charcommands (#)
  7139. *------------------------------------------*/
  7140. void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7141. {
  7142. char line_buff[CHATBOX_SIZE];
  7143. char* cur = line_buff;
  7144. AtCommandInfo* cmd;
  7145. DBIterator *iter = db_iterator(atcommand->db);
  7146. int count = 0;
  7147. memset(line_buff,' ',CHATBOX_SIZE);
  7148. line_buff[CHATBOX_SIZE-1] = 0;
  7149. clif->message(fd, msg_fd(fd,273)); // "Available commands:"
  7150. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  7151. size_t slen;
  7152. switch( type ) {
  7153. case COMMAND_CHARCOMMAND:
  7154. if( cmd->char_groups[pcg->get_idx(sd->group)] == 0 )
  7155. continue;
  7156. break;
  7157. case COMMAND_ATCOMMAND:
  7158. if( cmd->at_groups[pcg->get_idx(sd->group)] == 0 )
  7159. continue;
  7160. break;
  7161. default:
  7162. continue;
  7163. }
  7164. slen = strlen(cmd->command);
  7165. // flush the text buffer if this command won't fit into it
  7166. if ( slen + cur - line_buff >= CHATBOX_SIZE )
  7167. {
  7168. clif->message(fd,line_buff);
  7169. cur = line_buff;
  7170. memset(line_buff,' ',CHATBOX_SIZE);
  7171. line_buff[CHATBOX_SIZE-1] = 0;
  7172. }
  7173. memcpy(cur,cmd->command,slen);
  7174. cur += slen+(10-slen%10);
  7175. count++;
  7176. }
  7177. dbi_destroy(iter);
  7178. clif->message(fd,line_buff);
  7179. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,274), count); // "%d commands found."
  7180. clif->message(fd, atcmd_output);
  7181. return;
  7182. }
  7183. /*==========================================
  7184. * @commands Lists available @ commands to you
  7185. *------------------------------------------*/
  7186. ACMD(commands)
  7187. {
  7188. atcommand->commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7189. return true;
  7190. }
  7191. /*==========================================
  7192. * @charcommands Lists available # commands to you
  7193. *------------------------------------------*/
  7194. ACMD(charcommands)
  7195. {
  7196. atcommand->commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7197. return true;
  7198. }
  7199. /* for new mounts */
  7200. ACMD(cashmount)
  7201. {
  7202. if (pc_hasmount(sd)) {
  7203. clif->message(fd, msg_fd(fd,1476)); // You are already mounting something else
  7204. return false;
  7205. }
  7206. clif->message(sd->fd,msg_fd(fd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7207. if (!sd->sc.data[SC_ALL_RIDING]) {
  7208. clif->message(sd->fd,msg_fd(fd,1363)); // You have mounted.
  7209. sc_start(NULL,&sd->bl,SC_ALL_RIDING,100,25,-1);
  7210. } else {
  7211. clif->message(sd->fd,msg_fd(fd,1364)); // You have released your mount.
  7212. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7213. }
  7214. return true;
  7215. }
  7216. ACMD(accinfo) {
  7217. char query[NAME_LENGTH];
  7218. if (!*message || strlen(message) > NAME_LENGTH ) {
  7219. clif->message(fd, msg_fd(fd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7220. clif->message(fd, msg_fd(fd,1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
  7221. return false;
  7222. }
  7223. //remove const type
  7224. safestrncpy(query, message, NAME_LENGTH);
  7225. intif->request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query );
  7226. return true;
  7227. }
  7228. /* [Ind] */
  7229. ACMD(set)
  7230. {
  7231. char reg[SCRIPT_VARNAME_LENGTH+1], val[254];
  7232. struct script_data* data;
  7233. int toset = 0;
  7234. bool is_str = false;
  7235. size_t len;
  7236. if (!*message || (toset = sscanf(message, "%32s %253[^\n]", reg, val)) < 1) {
  7237. clif->message(fd, msg_fd(fd,1367)); // Usage: @set <variable name> <value>
  7238. clif->message(fd, msg_fd(fd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7239. clif->message(fd, msg_fd(fd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7240. clif->message(fd, msg_fd(fd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7241. return false;
  7242. }
  7243. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7244. if( reg[0] == '.' ) {
  7245. clif->message(fd, msg_fd(fd,1371)); // NPC variables may not be used with @set.
  7246. return false;
  7247. } else if( reg[0] == '\'' ) {
  7248. clif->message(fd, msg_fd(fd,1372)); // Instance variables may not be used with @set.
  7249. return false;
  7250. }
  7251. is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
  7252. if( ( len = strlen(val) ) > 1 ) {
  7253. if( val[0] == '"' && val[len-1] == '"') {
  7254. val[len-1] = '\0'; //Strip quotes.
  7255. memmove(val, val+1, len-1);
  7256. }
  7257. }
  7258. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7259. if( is_str )
  7260. script->set_var(sd, reg, (void*) val);
  7261. else
  7262. script->set_var(sd, reg, (void*)h64BPTRSIZE((atoi(val))));
  7263. }
  7264. CREATE(data, struct script_data,1);
  7265. if( is_str ) {// string variable
  7266. switch( reg[0] ) {
  7267. case '@':
  7268. data->u.str = pc->readregstr(sd, script->add_str(reg));
  7269. break;
  7270. case '$':
  7271. data->u.str = mapreg->readregstr(script->add_str(reg));
  7272. break;
  7273. case '#':
  7274. if( reg[1] == '#' )
  7275. data->u.str = pc_readaccountreg2str(sd, script->add_str(reg));// global
  7276. else
  7277. data->u.str = pc_readaccountregstr(sd, script->add_str(reg));// local
  7278. break;
  7279. default:
  7280. data->u.str = pc_readglobalreg_str(sd, script->add_str(reg));
  7281. break;
  7282. }
  7283. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7284. data->type = C_CONSTSTR;
  7285. data->u.str = "";
  7286. } else {// duplicate string
  7287. data->type = C_STR;
  7288. data->u.str = aStrdup(data->u.str);
  7289. }
  7290. } else {// integer variable
  7291. data->type = C_INT;
  7292. switch( reg[0] ) {
  7293. case '@':
  7294. data->u.num = pc->readreg(sd, script->add_str(reg));
  7295. break;
  7296. case '$':
  7297. data->u.num = mapreg->readreg(script->add_str(reg));
  7298. break;
  7299. case '#':
  7300. if( reg[1] == '#' )
  7301. data->u.num = pc_readaccountreg2(sd, script->add_str(reg));// global
  7302. else
  7303. data->u.num = pc_readaccountreg(sd, script->add_str(reg));// local
  7304. break;
  7305. default:
  7306. data->u.num = pc_readglobalreg(sd, script->add_str(reg));
  7307. break;
  7308. }
  7309. }
  7310. switch( data->type ) {
  7311. case C_INT:
  7312. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1373),reg,data->u.num); // %s value is now :%d
  7313. break;
  7314. case C_STR:
  7315. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1374),reg,data->u.str); // %s value is now :%s
  7316. break;
  7317. case C_CONSTSTR:
  7318. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1375),reg); // %s is empty
  7319. break;
  7320. default:
  7321. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1376),reg,data->type); // %s data type is not supported :%u
  7322. break;
  7323. }
  7324. clif->message(fd, atcmd_output);
  7325. aFree(data);
  7326. return true;
  7327. }
  7328. ACMD(reloadquestdb) {
  7329. quest->reload();
  7330. clif->message(fd, msg_fd(fd,1377)); // Quest database has been reloaded.
  7331. return true;
  7332. }
  7333. ACMD(addperm) {
  7334. int perm_size = pcg->permission_count;
  7335. bool add = (strcmpi(info->command, "addperm") == 0) ? true : false;
  7336. int i;
  7337. if (!*message) {
  7338. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1378),command); // Usage: %s <permission_name>
  7339. clif->message(fd, atcmd_output);
  7340. clif->message(fd, msg_fd(fd,1379)); // -- Permission List
  7341. for( i = 0; i < perm_size; i++ ) {
  7342. safesnprintf(atcmd_output, sizeof(atcmd_output),"- %s",pcg->permissions[i].name);
  7343. clif->message(fd, atcmd_output);
  7344. }
  7345. return false;
  7346. }
  7347. ARR_FIND(0, perm_size, i, strcmpi(pcg->permissions[i].name, message) == 0);
  7348. if( i == perm_size ) {
  7349. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1380),message); // '%s' is not a known permission.
  7350. clif->message(fd, atcmd_output);
  7351. clif->message(fd, msg_fd(fd,1379)); // -- Permission List
  7352. for( i = 0; i < perm_size; i++ ) {
  7353. safesnprintf(atcmd_output, sizeof(atcmd_output),"- %s",pcg->permissions[i].name);
  7354. clif->message(fd, atcmd_output);
  7355. }
  7356. return false;
  7357. }
  7358. if( add && (sd->extra_temp_permissions&pcg->permissions[i].permission) ) {
  7359. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1381),sd->status.name,pcg->permissions[i].name); // User '%s' already possesses the '%s' permission.
  7360. clif->message(fd, atcmd_output);
  7361. return false;
  7362. } else if ( !add && !(sd->extra_temp_permissions&pcg->permissions[i].permission) ) {
  7363. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1382),sd->status.name,pcg->permissions[i].name); // User '%s' doesn't possess the '%s' permission.
  7364. clif->message(fd, atcmd_output);
  7365. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1383),sd->status.name); // -- User '%s' Permissions
  7366. clif->message(fd, atcmd_output);
  7367. for( i = 0; i < perm_size; i++ ) {
  7368. if( sd->extra_temp_permissions&pcg->permissions[i].permission ) {
  7369. safesnprintf(atcmd_output, sizeof(atcmd_output),"- %s",pcg->permissions[i].name);
  7370. clif->message(fd, atcmd_output);
  7371. }
  7372. }
  7373. return false;
  7374. }
  7375. if( add )
  7376. sd->extra_temp_permissions |= pcg->permissions[i].permission;
  7377. else
  7378. sd->extra_temp_permissions &=~ pcg->permissions[i].permission;
  7379. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7380. clif->message(fd, atcmd_output);
  7381. return true;
  7382. }
  7383. ACMD(unloadnpcfile)
  7384. {
  7385. if (!*message) {
  7386. clif->message(fd, msg_fd(fd,1385)); // Usage: @unloadnpcfile <file name>
  7387. return false;
  7388. }
  7389. if (npc->unloadfile(message)) {
  7390. clif->message(fd, msg_fd(fd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7391. } else {
  7392. clif->message(fd, msg_fd(fd,1387)); // File not found.
  7393. return false;
  7394. }
  7395. return true;
  7396. }
  7397. ACMD(cart) {
  7398. #define MC_CART_MDFY(x,idx) do { \
  7399. sd->status.skill[idx].id = (x)?MC_PUSHCART:0; \
  7400. sd->status.skill[idx].lv = (x)?1:0; \
  7401. sd->status.skill[idx].flag = (x)?1:0; \
  7402. } while(0)
  7403. int val = atoi(message);
  7404. bool need_skill = pc->checkskill(sd, MC_PUSHCART) ? false : true;
  7405. unsigned int index = skill->get_index(MC_PUSHCART);
  7406. if (!*message || val < 0 || val > MAX_CARTS) {
  7407. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7408. clif->message(fd, atcmd_output);
  7409. return false;
  7410. }
  7411. if( val == 0 && !pc_iscarton(sd) ) {
  7412. clif->message(fd, msg_fd(fd,1391)); // You do not possess a cart to be removed
  7413. return false;
  7414. }
  7415. if( need_skill ) {
  7416. MC_CART_MDFY(1,index);
  7417. }
  7418. if( pc->setcart(sd, val) ) {
  7419. if( need_skill ) {
  7420. MC_CART_MDFY(0,index);
  7421. }
  7422. return false;/* @cart failed */
  7423. }
  7424. if( need_skill ) {
  7425. MC_CART_MDFY(0,index);
  7426. }
  7427. clif->message(fd, msg_fd(fd,1392)); // Cart Added
  7428. return true;
  7429. #undef MC_CART_MDFY
  7430. }
  7431. /* [Ind/Hercules] */
  7432. ACMD(join)
  7433. {
  7434. struct channel_data *chan = NULL;
  7435. char name[HCS_NAME_LENGTH], pass[HCS_NAME_LENGTH];
  7436. enum channel_operation_status ret = HCS_STATUS_OK;
  7437. if (!*message || sscanf(message, "%19s %19s", name, pass) < 1) {
  7438. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1399),command); // Unknown Channel (usage: %s <#channel_name>)
  7439. clif->message(fd, atcmd_output);
  7440. return false;
  7441. }
  7442. chan = channel->search(name, sd);
  7443. if (!chan) {
  7444. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1400),name,command); // Unknown Channel '%s' (usage: %s <#channel_name>)
  7445. clif->message(fd, atcmd_output);
  7446. return false;
  7447. }
  7448. ret = channel->join(chan, sd, pass, false);
  7449. if (ret == HCS_STATUS_ALREADY) {
  7450. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1436),name); // You're already in the '%s' channel
  7451. clif->message(fd, atcmd_output);
  7452. return false;
  7453. }
  7454. if (ret == HCS_STATUS_NOPERM) {
  7455. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1401),name,command); // '%s' Channel is password protected (usage: %s <#channel_name> <password>)
  7456. clif->message(fd, atcmd_output);
  7457. return false;
  7458. }
  7459. if (ret == HCS_STATUS_BANNED) {
  7460. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1438),name); // You cannot join the '%s' channel because you've been banned from it
  7461. clif->message(fd, atcmd_output);
  7462. return false;
  7463. }
  7464. return true;
  7465. }
  7466. /* [Ind/Hercules] */
  7467. void atcommand_channel_help(int fd, const char *command, bool can_create) {
  7468. nullpo_retv(command);
  7469. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1404),command); // %s failed.
  7470. clif->message(fd, atcmd_output);
  7471. clif->message(fd, msg_fd(fd,1414));// --- Available options:
  7472. if( can_create ) {
  7473. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1415),command);// -- %s create <channel name> <channel password>
  7474. clif->message(fd, atcmd_output);
  7475. clif->message(fd, msg_fd(fd,1416));// - creates a new channel
  7476. }
  7477. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1417),command);// -- %s list
  7478. clif->message(fd, atcmd_output);
  7479. clif->message(fd, msg_fd(fd,1418));// - lists public channels
  7480. if( can_create ) {
  7481. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1419),command);// -- %s list colors
  7482. clif->message(fd, atcmd_output);
  7483. clif->message(fd, msg_fd(fd,1420));// - lists colors available to select for custom channels
  7484. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1421),command);// -- %s setcolor <channel name> <color name>
  7485. clif->message(fd, atcmd_output);
  7486. clif->message(fd, msg_fd(fd,1422));// - changes <channel name> color to <color name>
  7487. }
  7488. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1423),command);// -- %s leave <channel name>
  7489. clif->message(fd, atcmd_output);
  7490. clif->message(fd, msg_fd(fd,1424));// - leaves <channel name>
  7491. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1427),command);// -- %s bindto <channel name>
  7492. clif->message(fd, atcmd_output);
  7493. clif->message(fd, msg_fd(fd,1428));// - binds global chat to <channel name>, making anything you type in global be sent to the channel
  7494. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1429),command);// -- %s unbind
  7495. clif->message(fd, atcmd_output);
  7496. clif->message(fd, msg_fd(fd,1430));// - unbinds your global chat from its attached channel (if binded)
  7497. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1429),command);// -- %s unbind
  7498. clif->message(fd, atcmd_output);
  7499. if( can_create ) {
  7500. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1456),command);// -- %s ban <channel name> <character name>
  7501. clif->message(fd, atcmd_output);
  7502. clif->message(fd, msg_fd(fd,1457));// - bans <character name> from <channel name> channel
  7503. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1458),command);// -- %s banlist <channel name>
  7504. clif->message(fd, atcmd_output);
  7505. clif->message(fd, msg_fd(fd,1459));// - lists all banned characters from <channel name> channel
  7506. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1460),command);// -- %s unban <channel name> <character name>
  7507. clif->message(fd, atcmd_output);
  7508. clif->message(fd, msg_fd(fd,1461));// - unbans <character name> from <channel name> channel
  7509. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1467),command);// -- %s unbanall <channel name>
  7510. clif->message(fd, atcmd_output);
  7511. clif->message(fd, msg_fd(fd,1468));// - unbans everyone from <channel name>
  7512. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1462),command);// -- %s setopt <channel name> <option name> <option value>
  7513. clif->message(fd, atcmd_output);
  7514. clif->message(fd, msg_fd(fd,1463));// - adds or removes <option name> with <option value> to <channel name> channel
  7515. }
  7516. }
  7517. /* [Ind/Hercules] */
  7518. ACMD(channel) {
  7519. struct channel_data *chan;
  7520. char subcmd[HCS_NAME_LENGTH], sub1[HCS_NAME_LENGTH], sub2[HCS_NAME_LENGTH], sub3[HCS_NAME_LENGTH];
  7521. unsigned char k = 0;
  7522. sub1[0] = sub2[0] = sub3[0] = '\0';
  7523. if (!*message || sscanf(message, "%19s %19s %19s %19s", subcmd, sub1, sub2, sub3) < 1) {
  7524. atcommand->channel_help(fd,command, (channel->config->allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)));
  7525. return true;
  7526. }
  7527. if (strcmpi(subcmd,"create") == 0 && (channel->config->allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN))) {
  7528. // sub1 = channel name; sub2 = password; sub3 = unused
  7529. size_t len = strlen(sub1);
  7530. const char *pass = *sub2 ? sub2 : "";
  7531. if (sub1[0] != '#') {
  7532. clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#'
  7533. return false;
  7534. } else if (len < 3 || len > HCS_NAME_LENGTH) {
  7535. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1406), HCS_NAME_LENGTH);// Channel length must be between 3 and %d
  7536. clif->message(fd, atcmd_output);
  7537. return false;
  7538. } else if (sub3[0] != '\0') {
  7539. clif->message(fd, msg_fd(fd,1408)); // Channel password may not contain spaces
  7540. return false;
  7541. }
  7542. if (strcmpi(sub1 + 1, channel->config->local_name) == 0 || strcmpi(sub1 + 1, channel->config->ally_name) == 0 || strdb_exists(channel->db, sub1 + 1)) {
  7543. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
  7544. clif->message(fd, atcmd_output);
  7545. return false;
  7546. }
  7547. chan = channel->create(HCS_TYPE_PRIVATE, sub1 + 1, 0);
  7548. channel->set_password(chan, pass);
  7549. chan->owner = sd->status.char_id;
  7550. channel->join(chan, sd, pass, false);
  7551. } else if (strcmpi(subcmd,"list") == 0) {
  7552. // sub1 = list type; sub2 = unused; sub3 = unused
  7553. if (sub1[0] != '\0' && strcmpi(sub1,"colors") == 0) {
  7554. for (k = 0; k < channel->config->colors_count; k++) {
  7555. safesnprintf(atcmd_output, sizeof(atcmd_output), "[ %s list colors ] : %s", command, channel->config->colors_name[k]);
  7556. clif->messagecolor_self(fd, channel->config->colors[k], atcmd_output);
  7557. }
  7558. } else {
  7559. DBIterator *iter = db_iterator(channel->db);
  7560. bool show_all = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ? true : false;
  7561. clif->message(fd, msg_fd(fd,1410)); // -- Public Channels
  7562. if (channel->config->local) {
  7563. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1409), channel->config->local_name, map->list[sd->bl.m].channel ? db_size(map->list[sd->bl.m].channel->users) : 0);// - #%s ( %d users )
  7564. clif->message(fd, atcmd_output);
  7565. }
  7566. if (channel->config->ally && sd->status.guild_id) {
  7567. struct guild *g = sd->guild;
  7568. if( !g ) { dbi_destroy(iter); return false; }
  7569. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1409), channel->config->ally_name, db_size(g->channel->users));// - #%s ( %d users )
  7570. clif->message(fd, atcmd_output);
  7571. }
  7572. for (chan = dbi_first(iter); dbi_exists(iter); chan = dbi_next(iter)) {
  7573. if (show_all || chan->type == HCS_TYPE_PUBLIC || chan->type == HCS_TYPE_IRC) {
  7574. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1409), chan->name, db_size(chan->users));// - #%s ( %d users )
  7575. clif->message(fd, atcmd_output);
  7576. }
  7577. }
  7578. dbi_destroy(iter);
  7579. }
  7580. } else if (strcmpi(subcmd,"setcolor") == 0) {
  7581. // sub1 = channel name; sub2 = color; sub3 = unused
  7582. if (sub1[0] != '#') {
  7583. clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#'
  7584. return false;
  7585. }
  7586. if (!(chan = channel->search(sub1, sd))) {
  7587. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
  7588. clif->message(fd, atcmd_output);
  7589. return false;
  7590. }
  7591. if (chan->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
  7592. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
  7593. clif->message(fd, atcmd_output);
  7594. return false;
  7595. }
  7596. for (k = 0; k < channel->config->colors_count; k++) {
  7597. if (strcmpi(sub2, channel->config->colors_name[k]) == 0)
  7598. break;
  7599. }
  7600. if (k == channel->config->colors_count) {
  7601. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1411), sub2);// Unknown color '%s'
  7602. clif->message(fd, atcmd_output);
  7603. return false;
  7604. }
  7605. chan->color = k;
  7606. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1413), sub1, channel->config->colors_name[k]);// '%s' channel color updated to '%s'
  7607. clif->message(fd, atcmd_output);
  7608. } else if (strcmpi(subcmd,"leave") == 0) {
  7609. // sub1 = channel name; sub2 = unused; sub3 = unused
  7610. if (sub1[0] != '#') {
  7611. clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#'
  7612. return false;
  7613. }
  7614. for (k = 0; k < sd->channel_count; k++) {
  7615. if (strcmpi(sub1+1,sd->channels[k]->name) == 0)
  7616. break;
  7617. }
  7618. if (k == sd->channel_count) {
  7619. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1425),sub1);// You're not part of the '%s' channel
  7620. clif->message(fd, atcmd_output);
  7621. return false;
  7622. }
  7623. if (sd->channels[k]->type == HCS_TYPE_ALLY) {
  7624. do {
  7625. for (k = 0; k < sd->channel_count; k++) {
  7626. if (sd->channels[k]->type == HCS_TYPE_ALLY) {
  7627. channel->leave(sd->channels[k],sd);
  7628. break;
  7629. }
  7630. }
  7631. } while (k != sd->channel_count);
  7632. } else {
  7633. channel->leave(sd->channels[k],sd);
  7634. }
  7635. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1426),sub1); // You've left the '%s' channel
  7636. clif->message(fd, atcmd_output);
  7637. } else if (strcmpi(subcmd,"bindto") == 0) {
  7638. // sub1 = channel name; sub2 = unused; sub3 = unused
  7639. if (sub1[0] != '#') {
  7640. clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#'
  7641. return false;
  7642. }
  7643. for (k = 0; k < sd->channel_count; k++) {
  7644. if (strcmpi(sub1+1,sd->channels[k]->name) == 0)
  7645. break;
  7646. }
  7647. if (k == sd->channel_count) {
  7648. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1425),sub1);// You're not part of the '%s' channel
  7649. clif->message(fd, atcmd_output);
  7650. return false;
  7651. }
  7652. sd->gcbind = sd->channels[k];
  7653. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1431),sub1); // Your global chat is now bound to the '%s' channel
  7654. clif->message(fd, atcmd_output);
  7655. } else if (strcmpi(subcmd,"unbind") == 0) {
  7656. // sub1 = unused; sub2 = unused; sub3 = unused
  7657. if (sd->gcbind == NULL) {
  7658. clif->message(fd, msg_fd(fd,1432));// Your global chat is not bound to any channel
  7659. return false;
  7660. }
  7661. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1433),sd->gcbind->name); // Your global chat is no longer bound to the '#%s' channel
  7662. clif->message(fd, atcmd_output);
  7663. sd->gcbind = NULL;
  7664. } else if (strcmpi(subcmd,"ban") == 0) {
  7665. // sub1 = channel name; sub2 = unused; sub3 = unused
  7666. struct map_session_data *pl_sd = NULL;
  7667. char sub4[NAME_LENGTH]; ///< player name
  7668. enum channel_operation_status ret = HCS_STATUS_OK;
  7669. if (sub1[0] != '#') {
  7670. clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#'
  7671. return false;
  7672. }
  7673. if (!(chan = channel->search(sub1, sd))) {
  7674. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
  7675. clif->message(fd, atcmd_output);
  7676. return false;
  7677. }
  7678. if (!*message || sscanf(message, "%19s %19s %23[^\n]", subcmd, sub1, sub4) < 3) {
  7679. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1434), sub4);// Player '%s' was not found
  7680. clif->message(fd, atcmd_output);
  7681. return false;
  7682. }
  7683. if (sub4[0] == '\0' || (pl_sd = map->nick2sd(sub4)) == NULL) {
  7684. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1434), sub4);// Player '%s' was not found
  7685. clif->message(fd, atcmd_output);
  7686. return false;
  7687. }
  7688. ret = channel->ban(chan, sd, pl_sd);
  7689. if (ret == HCS_STATUS_NOPERM) {
  7690. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
  7691. clif->message(fd, atcmd_output);
  7692. return false;
  7693. }
  7694. if (ret == HCS_STATUS_ALREADY) {
  7695. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1465), pl_sd->status.name);// Player '%s' is already banned from this channel
  7696. clif->message(fd, atcmd_output);
  7697. return false;
  7698. }
  7699. if (ret != HCS_STATUS_OK/*ret == HCS_STATUS_FAIL*/) {
  7700. clif->message(fd, msg_fd(fd,1464)); // Ban failed, not possible to ban this user.
  7701. return false;
  7702. }
  7703. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1437),pl_sd->status.name,sub1); // Player '%s' has now been banned from '%s' channel
  7704. clif->message(fd, atcmd_output);
  7705. } else if (strcmpi(subcmd,"unban") == 0) {
  7706. // sub1 = channel name; sub2 = unused; sub3 = unused
  7707. struct map_session_data *pl_sd = NULL;
  7708. char sub4[NAME_LENGTH]; ///< player name
  7709. enum channel_operation_status ret = HCS_STATUS_OK;
  7710. if (sub1[0] != '#') {
  7711. clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#'
  7712. return false;
  7713. }
  7714. if (!(chan = channel->search(sub1, sd))) {
  7715. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
  7716. clif->message(fd, atcmd_output);
  7717. return false;
  7718. }
  7719. if (!*message || sscanf(message, "%19s %19s %23[^\n]", subcmd, sub1, sub4) < 3) {
  7720. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1434), sub4);// Player '%s' was not found
  7721. clif->message(fd, atcmd_output);
  7722. return false;
  7723. }
  7724. if (sub4[0] == '\0' || (pl_sd = map->nick2sd(sub4)) == NULL) {
  7725. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1434), sub4);// Player '%s' was not found
  7726. clif->message(fd, atcmd_output);
  7727. return false;
  7728. }
  7729. ret = channel->unban(chan, sd, pl_sd);
  7730. if (ret == HCS_STATUS_NOPERM) {
  7731. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
  7732. clif->message(fd, atcmd_output);
  7733. return false;
  7734. }
  7735. if (ret == HCS_STATUS_ALREADY) {
  7736. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1440), pl_sd->status.name);// Player '%s' is not banned from this channel
  7737. clif->message(fd, atcmd_output);
  7738. return false;
  7739. }
  7740. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1441),pl_sd->status.name,sub1); // Player '%s' has now been unbanned from the '%s' channel
  7741. clif->message(fd, atcmd_output);
  7742. } else if (strcmpi(subcmd,"unbanall") == 0) {
  7743. enum channel_operation_status ret = HCS_STATUS_OK;
  7744. // sub1 = channel name; sub2 = unused; sub3 = unused
  7745. if (sub1[0] != '#') {
  7746. clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#'
  7747. return false;
  7748. }
  7749. if (!(chan = channel->search(sub1, sd))) {
  7750. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
  7751. clif->message(fd, atcmd_output);
  7752. return false;
  7753. }
  7754. ret = channel->unban(chan, sd, NULL);
  7755. if (ret == HCS_STATUS_NOPERM) {
  7756. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
  7757. clif->message(fd, atcmd_output);
  7758. return false;
  7759. }
  7760. if (ret == HCS_STATUS_ALREADY) {
  7761. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1439), sub1);// Channel '%s' has no banned players
  7762. clif->message(fd, atcmd_output);
  7763. return false;
  7764. }
  7765. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1442),sub1); // Removed all bans from '%s' channel
  7766. clif->message(fd, atcmd_output);
  7767. } else if (strcmpi(subcmd,"banlist") == 0) {
  7768. // sub1 = channel name; sub2 = unused; sub3 = unused
  7769. DBIterator *iter = NULL;
  7770. DBKey key;
  7771. DBData *data;
  7772. bool isA = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)?true:false;
  7773. if (sub1[0] != '#') {
  7774. clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#'
  7775. return false;
  7776. }
  7777. if (!(chan = channel->search(sub1, sd))) {
  7778. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
  7779. clif->message(fd, atcmd_output);
  7780. return false;
  7781. }
  7782. if (chan->owner != sd->status.char_id && !isA) {
  7783. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
  7784. clif->message(fd, atcmd_output);
  7785. return false;
  7786. }
  7787. if (!chan->banned) {
  7788. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1439), sub1);// Channel '%s' has no banned players
  7789. clif->message(fd, atcmd_output);
  7790. return false;
  7791. }
  7792. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1443), chan->name);// -- '%s' ban list
  7793. clif->message(fd, atcmd_output);
  7794. iter = db_iterator(chan->banned);
  7795. for (data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key)) {
  7796. struct channel_ban_entry *entry = DB->data2ptr(data);
  7797. if (!isA)
  7798. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1444), entry->name);// - %s %s
  7799. else
  7800. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1445), entry->name, key.i);// - %s (%d)
  7801. clif->message(fd, atcmd_output);
  7802. }
  7803. dbi_destroy(iter);
  7804. } else if (strcmpi(subcmd,"setopt") == 0) {
  7805. // sub1 = channel name; sub2 = option name; sub3 = value
  7806. const char* opt_str[3] = {
  7807. "None",
  7808. "JoinAnnounce",
  7809. "MessageDelay",
  7810. };
  7811. if (sub1[0] != '#') {
  7812. clif->message(fd, msg_fd(fd,1405));// Channel name must start with a '#'
  7813. return false;
  7814. }
  7815. if (!(chan = channel->search(sub1, sd))) {
  7816. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1407), sub1);// Channel '%s' is not available
  7817. clif->message(fd, atcmd_output);
  7818. return false;
  7819. }
  7820. if (chan->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
  7821. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1412), sub1);// You're not the owner of channel '%s'
  7822. clif->message(fd, atcmd_output);
  7823. return false;
  7824. }
  7825. if (sub2[0] == '\0') {
  7826. clif->message(fd, msg_fd(fd,1446));// You need to input a option
  7827. return false;
  7828. }
  7829. for (k = 1; k < 3; k++) {
  7830. if (strcmpi(sub2,opt_str[k]) == 0)
  7831. break;
  7832. }
  7833. if (k == 3) {
  7834. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1447), sub2);// '%s' is not a known channel option
  7835. clif->message(fd, atcmd_output);
  7836. clif->message(fd, msg_fd(fd,1448)); // -- Available options
  7837. for (k = 1; k < 3; k++) {
  7838. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1444), opt_str[k]);// - '%s'
  7839. clif->message(fd, atcmd_output);
  7840. }
  7841. return false;
  7842. }
  7843. if (sub3[0] == '\0') {
  7844. if (k == HCS_OPT_MSG_DELAY) {
  7845. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1466), opt_str[k]);// For '%s' you need the amount of seconds (from 0 to 10)
  7846. clif->message(fd, atcmd_output);
  7847. return false;
  7848. } else if (chan->options & k) {
  7849. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1449), opt_str[k],opt_str[k]); // option '%s' is already enabled, if you'd like to disable it type '@channel setopt %s 0'
  7850. clif->message(fd, atcmd_output);
  7851. return false;
  7852. } else {
  7853. channel->set_options(chan, chan->options | k);
  7854. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1450), opt_str[k],chan->name);//option '%s' is now enabled for channel '%s'
  7855. clif->message(fd, atcmd_output);
  7856. return true;
  7857. }
  7858. } else {
  7859. int v = atoi(sub3);
  7860. if (k == HCS_OPT_MSG_DELAY) {
  7861. if (v < 0 || v > 10) {
  7862. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1451), v, opt_str[k]);// value '%d' for option '%s' is out of range (limit is 0-10)
  7863. clif->message(fd, atcmd_output);
  7864. return false;
  7865. }
  7866. if (v == 0) {
  7867. channel->set_options(chan, chan->options&~k);
  7868. chan->msg_delay = 0;
  7869. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1453), opt_str[k],chan->name,v);// option '%s' is now disabled for channel '%s'
  7870. clif->message(fd, atcmd_output);
  7871. return true;
  7872. } else {
  7873. channel->set_options(chan, chan->options | k);
  7874. chan->msg_delay = v;
  7875. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1452), opt_str[k],chan->name,v);// option '%s' is now enabled for channel '%s' with %d seconds
  7876. clif->message(fd, atcmd_output);
  7877. return true;
  7878. }
  7879. } else {
  7880. if (v) {
  7881. if (chan->options & k) {
  7882. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1449), opt_str[k],opt_str[k]); // option '%s' is already enabled, if you'd like to disable it type '@channel opt %s 0'
  7883. clif->message(fd, atcmd_output);
  7884. return false;
  7885. } else {
  7886. channel->set_options(chan, chan->options | k);
  7887. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1450), opt_str[k],chan->name);//option '%s' is now enabled for channel '%s'
  7888. clif->message(fd, atcmd_output);
  7889. }
  7890. } else {
  7891. if (!(chan->options & k)) {
  7892. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1454), opt_str[k],chan->name); // option '%s' is not enabled on channel '%s'
  7893. clif->message(fd, atcmd_output);
  7894. return false;
  7895. } else {
  7896. channel->set_options(chan, chan->options&~k);
  7897. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1453), opt_str[k],chan->name);// option '%s' is now disabled for channel '%s'
  7898. clif->message(fd, atcmd_output);
  7899. return true;
  7900. }
  7901. }
  7902. }
  7903. }
  7904. } else {
  7905. atcommand->channel_help(fd, command, (channel->config->allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)));
  7906. }
  7907. return true;
  7908. }
  7909. /* debug only, delete after */
  7910. ACMD(fontcolor) {
  7911. unsigned char k;
  7912. if (!*message) {
  7913. for (k = 0; k < channel->config->colors_count; k++) {
  7914. safesnprintf(atcmd_output, sizeof(atcmd_output), "[ %s ] : %s", command, channel->config->colors_name[k]);
  7915. clif->messagecolor_self(fd, channel->config->colors[k], atcmd_output);
  7916. }
  7917. return false;
  7918. }
  7919. if( message[0] == '0' ) {
  7920. sd->fontcolor = 0;
  7921. return true;
  7922. }
  7923. for( k = 0; k < channel->config->colors_count; k++ ) {
  7924. if (strcmpi(message, channel->config->colors_name[k]) == 0)
  7925. break;
  7926. }
  7927. if( k == channel->config->colors_count ) {
  7928. safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1411), message);// Unknown color '%s'
  7929. clif->message(fd, atcmd_output);
  7930. return false;
  7931. }
  7932. sd->fontcolor = k + 1;
  7933. safesnprintf(atcmd_output, sizeof(atcmd_output), "Color changed to '%s'", channel->config->colors_name[k]);
  7934. clif->messagecolor_self(fd, channel->config->colors[k], atcmd_output);
  7935. return true;
  7936. }
  7937. ACMD(searchstore){
  7938. int val = atoi(message);
  7939. switch (val) {
  7940. case 0://EFFECTTYPE_NORMAL
  7941. case 1://EFFECTTYPE_CASH
  7942. break;
  7943. default:
  7944. val = 0;
  7945. break;
  7946. }
  7947. searchstore->open(sd, 99, val);
  7948. return true;
  7949. }
  7950. ACMD(costume){
  7951. const char* names[] = {
  7952. "Wedding",
  7953. "Xmas",
  7954. "Summer",
  7955. "Hanbok",
  7956. #if PACKETVER >= 20131218
  7957. "Oktoberfest",
  7958. #endif
  7959. };
  7960. const int name2id[] = {
  7961. SC_WEDDING,
  7962. SC_XMAS,
  7963. SC_SUMMER,
  7964. SC_HANBOK,
  7965. #if PACKETVER >= 20131218
  7966. SC_OKTOBERFEST,
  7967. #endif
  7968. };
  7969. unsigned short k = 0, len = ARRAYLENGTH(names);
  7970. if (!*message) {
  7971. for( k = 0; k < len; k++ ) {
  7972. if( sd->sc.data[name2id[k]] ) {
  7973. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1473),names[k]);//Costume '%s' removed.
  7974. clif->message(sd->fd,atcmd_output);
  7975. status_change_end(&sd->bl,name2id[k],INVALID_TIMER);
  7976. return true;
  7977. }
  7978. }
  7979. clif->message(sd->fd,msg_fd(fd,1472));
  7980. for( k = 0; k < len; k++ ) {
  7981. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1471),names[k]);//-- %s
  7982. clif->message(sd->fd,atcmd_output);
  7983. }
  7984. return false;
  7985. }
  7986. for( k = 0; k < len; k++ ) {
  7987. if( sd->sc.data[name2id[k]] ) {
  7988. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1470),names[k]);// You're already with a '%s' costume, type '@costume' to remove it.
  7989. clif->message(sd->fd,atcmd_output);
  7990. return false;
  7991. }
  7992. }
  7993. for( k = 0; k < len; k++ ) {
  7994. if( strcmpi(message,names[k]) == 0 )
  7995. break;
  7996. }
  7997. if( k == len ) {
  7998. safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1469),message);// '%s' is not a known costume
  7999. clif->message(sd->fd,atcmd_output);
  8000. return false;
  8001. }
  8002. sc_start(NULL,&sd->bl, name2id[k], 100, 0, -1);
  8003. return true;
  8004. }
  8005. /* for debugging purposes (so users can easily provide us with debug info) */
  8006. /* should be trashed as soon as its no longer necessary */
  8007. ACMD(skdebug) {
  8008. safesnprintf(atcmd_output, sizeof(atcmd_output),"second: %u; third: %u", sd->sktree.second, sd->sktree.third);
  8009. clif->message(fd,atcmd_output);
  8010. safesnprintf(atcmd_output, sizeof(atcmd_output),"pc_calc_skilltree_normalize_job: %d",pc->calc_skilltree_normalize_job(sd));
  8011. clif->message(fd,atcmd_output);
  8012. safesnprintf(atcmd_output, sizeof(atcmd_output),"change_lv_2nd/3rd: %d/%d",sd->change_level_2nd,sd->change_level_3rd);
  8013. clif->message(fd,atcmd_output);
  8014. safesnprintf(atcmd_output, sizeof(atcmd_output),"pc_calc_skillpoint:%d",pc->calc_skillpoint(sd));
  8015. clif->message(fd,atcmd_output);
  8016. return true;
  8017. }
  8018. /**
  8019. * cooldown-debug
  8020. **/
  8021. ACMD(cddebug) {
  8022. int i;
  8023. struct skill_cd* cd = NULL;
  8024. if (!(cd = idb_get(skill->cd_db,sd->status.char_id))) {
  8025. clif->message(fd,"No cool down list found");
  8026. } else {
  8027. clif->messages(fd,"Found %d registered cooldowns",cd->cursor);
  8028. for(i = 0; i < cd->cursor; i++) {
  8029. if( cd->entry[i] ) {
  8030. const struct TimerData *td = timer->get(cd->entry[i]->timer);
  8031. if( !td || td->func != skill->blockpc_end ) {
  8032. clif->messages(fd,"Found invalid entry in slot %d for skill %s",i,skill->dbs->db[cd->entry[i]->skidx].name);
  8033. sd->blockskill[cd->entry[i]->skidx] = false;
  8034. }
  8035. }
  8036. }
  8037. }
  8038. if (!cd || (*message && !strcmpi(message,"reset"))) {
  8039. for(i = 0; i < MAX_SKILL; i++) {
  8040. if( sd->blockskill[i] ) {
  8041. clif->messages(fd,"Found skill '%s', unblocking...",skill->dbs->db[i].name);
  8042. sd->blockskill[i] = false;
  8043. }
  8044. }
  8045. if( cd ) {//reset
  8046. for(i = 0; i < cd->cursor; i++) {
  8047. if( !cd->entry[i] ) continue;
  8048. timer->delete(cd->entry[i]->timer,skill->blockpc_end);
  8049. ers_free(skill->cd_entry_ers, cd->entry[i]);
  8050. }
  8051. idb_remove(skill->cd_db,sd->status.char_id);
  8052. ers_free(skill->cd_ers, cd);
  8053. }
  8054. }
  8055. return true;
  8056. }
  8057. /**
  8058. *
  8059. **/
  8060. ACMD(lang) {
  8061. uint8 i;
  8062. if (!*message) {
  8063. clif->messages(fd,"Usage: @%s <Language>",info->command);
  8064. clif->messages(fd,"There are %d languages available:",script->max_lang_id);
  8065. for(i = 0; i < script->max_lang_id; i++)
  8066. clif->messages(fd,"- %s",script->languages[i]);
  8067. return false;
  8068. }
  8069. for(i = 0; i < script->max_lang_id; i++) {
  8070. if( strcmpi(message,script->languages[i]) == 0 ) {
  8071. if( i == sd->lang_id ) {
  8072. clif->messages(fd,"%s is already set as your language",script->languages[i]);
  8073. } else {
  8074. clif->messages(fd,"Your language has been changed from '%s' to '%s'",script->languages[sd->lang_id],script->languages[i]);
  8075. sd->lang_id = i;
  8076. }
  8077. break;
  8078. }
  8079. }
  8080. if( i == script->max_lang_id ) {
  8081. clif->messages(fd,"'%s' did not match any language available",message);
  8082. clif->messages(fd,"There are %d languages available:",script->max_lang_id);
  8083. for(i = 0; i < script->max_lang_id; i++)
  8084. clif->messages(fd,"- %s",script->languages[i]);
  8085. }
  8086. return true;
  8087. }
  8088. /**
  8089. * Fills the reference of available commands in atcommand DBMap
  8090. **/
  8091. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, NULL, true }
  8092. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, NULL, true }
  8093. void atcommand_basecommands(void) {
  8094. /**
  8095. * Command reference list, place the base of your commands here
  8096. **/
  8097. AtCommandInfo atcommand_base[] = {
  8098. ACMD_DEF2("warp", mapmove),
  8099. ACMD_DEF(where),
  8100. ACMD_DEF(jumpto),
  8101. ACMD_DEF(jump),
  8102. ACMD_DEF(who),
  8103. ACMD_DEF2("who2", who),
  8104. ACMD_DEF2("who3", who),
  8105. ACMD_DEF2("whomap", who),
  8106. ACMD_DEF2("whomap2", who),
  8107. ACMD_DEF2("whomap3", who),
  8108. ACMD_DEF(whogm),
  8109. ACMD_DEF(save),
  8110. ACMD_DEF(load),
  8111. ACMD_DEF(speed),
  8112. ACMD_DEF(storage),
  8113. ACMD_DEF(guildstorage),
  8114. ACMD_DEF(option),
  8115. ACMD_DEF(hide), // + /hide
  8116. ACMD_DEF(jobchange),
  8117. ACMD_DEF(kill),
  8118. ACMD_DEF(alive),
  8119. ACMD_DEF(kami),
  8120. ACMD_DEF2("kamib", kami),
  8121. ACMD_DEF2("kamic", kami),
  8122. ACMD_DEF2("lkami", kami),
  8123. ACMD_DEF(heal),
  8124. ACMD_DEF(item),
  8125. ACMD_DEF(item2),
  8126. ACMD_DEF2("itembound", item),
  8127. ACMD_DEF2("itembound2", item2),
  8128. ACMD_DEF(itemreset),
  8129. ACMD_DEF(clearstorage),
  8130. ACMD_DEF(cleargstorage),
  8131. ACMD_DEF(clearcart),
  8132. ACMD_DEF2("blvl", baselevelup),
  8133. ACMD_DEF2("jlvl", joblevelup),
  8134. ACMD_DEF(help),
  8135. ACMD_DEF(pvpoff),
  8136. ACMD_DEF(pvpon),
  8137. ACMD_DEF(gvgoff),
  8138. ACMD_DEF(gvgon),
  8139. ACMD_DEF(model),
  8140. ACMD_DEF(go),
  8141. ACMD_DEF(monster),
  8142. ACMD_DEF2("monstersmall", monster),
  8143. ACMD_DEF2("monsterbig", monster),
  8144. ACMD_DEF(killmonster),
  8145. ACMD_DEF2("killmonster2", killmonster),
  8146. ACMD_DEF(refine),
  8147. ACMD_DEF(produce),
  8148. ACMD_DEF(memo),
  8149. ACMD_DEF(gat),
  8150. ACMD_DEF(displaystatus),
  8151. ACMD_DEF2("stpoint", statuspoint),
  8152. ACMD_DEF2("skpoint", skillpoint),
  8153. ACMD_DEF(zeny),
  8154. ACMD_DEF2("str", param),
  8155. ACMD_DEF2("agi", param),
  8156. ACMD_DEF2("vit", param),
  8157. ACMD_DEF2("int", param),
  8158. ACMD_DEF2("dex", param),
  8159. ACMD_DEF2("luk", param),
  8160. ACMD_DEF2("glvl", guildlevelup),
  8161. ACMD_DEF(makeegg),
  8162. ACMD_DEF(hatch),
  8163. ACMD_DEF(petfriendly),
  8164. ACMD_DEF(pethungry),
  8165. ACMD_DEF(petrename),
  8166. ACMD_DEF(recall), // + /recall
  8167. ACMD_DEF(night),
  8168. ACMD_DEF(day),
  8169. ACMD_DEF(doom),
  8170. ACMD_DEF(doommap),
  8171. ACMD_DEF(raise),
  8172. ACMD_DEF(raisemap),
  8173. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  8174. ACMD_DEF(kickall),
  8175. ACMD_DEF(allskill),
  8176. ACMD_DEF(questskill),
  8177. ACMD_DEF(lostskill),
  8178. ACMD_DEF(spiritball),
  8179. ACMD_DEF(party),
  8180. ACMD_DEF(guild),
  8181. ACMD_DEF(breakguild),
  8182. ACMD_DEF(agitstart),
  8183. ACMD_DEF(agitend),
  8184. ACMD_DEF(mapexit),
  8185. ACMD_DEF(idsearch),
  8186. ACMD_DEF(broadcast), // + /b and /nb
  8187. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8188. ACMD_DEF(recallall),
  8189. ACMD_DEF(reloaditemdb),
  8190. ACMD_DEF(reloadmobdb),
  8191. ACMD_DEF(reloadskilldb),
  8192. ACMD_DEF(reloadscript),
  8193. ACMD_DEF(reloadatcommand),
  8194. ACMD_DEF(reloadbattleconf),
  8195. ACMD_DEF(reloadstatusdb),
  8196. ACMD_DEF(reloadpcdb),
  8197. ACMD_DEF(mapinfo),
  8198. ACMD_DEF(dye),
  8199. ACMD_DEF2("hairstyle", hair_style),
  8200. ACMD_DEF2("haircolor", hair_color),
  8201. ACMD_DEF2("allstats", stat_all),
  8202. ACMD_DEF2("block", char_block),
  8203. ACMD_DEF2("ban", char_ban),
  8204. ACMD_DEF2("charban", char_ban),/* char-specific ban time */
  8205. ACMD_DEF2("unblock", char_unblock),
  8206. ACMD_DEF2("charunban", char_unban),/* char-specific ban time */
  8207. ACMD_DEF2("unban", char_unban),
  8208. ACMD_DEF2("mount", mount_peco),
  8209. ACMD_DEF(guildspy),
  8210. ACMD_DEF(partyspy),
  8211. ACMD_DEF(repairall),
  8212. ACMD_DEF(guildrecall),
  8213. ACMD_DEF(partyrecall),
  8214. ACMD_DEF(nuke),
  8215. ACMD_DEF(shownpc),
  8216. ACMD_DEF(hidenpc),
  8217. ACMD_DEF(loadnpc),
  8218. ACMD_DEF(unloadnpc),
  8219. ACMD_DEF2("time", servertime),
  8220. ACMD_DEF(jail),
  8221. ACMD_DEF(unjail),
  8222. ACMD_DEF(jailfor),
  8223. ACMD_DEF(jailtime),
  8224. ACMD_DEF(disguise),
  8225. ACMD_DEF(undisguise),
  8226. ACMD_DEF(email),
  8227. ACMD_DEF(effect),
  8228. ACMD_DEF(follow),
  8229. ACMD_DEF(addwarp),
  8230. ACMD_DEF(skillon),
  8231. ACMD_DEF(skilloff),
  8232. ACMD_DEF(killer),
  8233. ACMD_DEF(npcmove),
  8234. ACMD_DEF(killable),
  8235. ACMD_DEF(dropall),
  8236. ACMD_DEF(storeall),
  8237. ACMD_DEF(skillid),
  8238. ACMD_DEF(useskill),
  8239. ACMD_DEF(displayskill),
  8240. ACMD_DEF(snow),
  8241. ACMD_DEF(sakura),
  8242. ACMD_DEF(clouds),
  8243. ACMD_DEF(clouds2),
  8244. ACMD_DEF(fog),
  8245. ACMD_DEF(fireworks),
  8246. ACMD_DEF(leaves),
  8247. ACMD_DEF(summon),
  8248. ACMD_DEF(adjgroup),
  8249. ACMD_DEF(trade),
  8250. ACMD_DEF(send),
  8251. ACMD_DEF(setbattleflag),
  8252. ACMD_DEF(unmute),
  8253. ACMD_DEF(clearweather),
  8254. ACMD_DEF(uptime),
  8255. ACMD_DEF(changesex),
  8256. ACMD_DEF(mute),
  8257. ACMD_DEF(refresh),
  8258. ACMD_DEF(refreshall),
  8259. ACMD_DEF(identify),
  8260. ACMD_DEF(misceffect),
  8261. ACMD_DEF(mobsearch),
  8262. ACMD_DEF(cleanmap),
  8263. ACMD_DEF(cleanarea),
  8264. ACMD_DEF(npctalk),
  8265. ACMD_DEF(pettalk),
  8266. ACMD_DEF(users),
  8267. ACMD_DEF(reset),
  8268. ACMD_DEF(skilltree),
  8269. ACMD_DEF(marry),
  8270. ACMD_DEF(divorce),
  8271. ACMD_DEF(sound),
  8272. ACMD_DEF(undisguiseall),
  8273. ACMD_DEF(disguiseall),
  8274. ACMD_DEF(changelook),
  8275. ACMD_DEF(autoloot),
  8276. ACMD_DEF2("alootid", autolootitem),
  8277. ACMD_DEF(autoloottype),
  8278. ACMD_DEF(mobinfo),
  8279. ACMD_DEF(exp),
  8280. ACMD_DEF(version),
  8281. ACMD_DEF(mutearea),
  8282. ACMD_DEF(rates),
  8283. ACMD_DEF(iteminfo),
  8284. ACMD_DEF(whodrops),
  8285. ACMD_DEF(whereis),
  8286. ACMD_DEF(mapflag),
  8287. ACMD_DEF(me),
  8288. ACMD_DEF(monsterignore),
  8289. ACMD_DEF(fakename),
  8290. ACMD_DEF(size),
  8291. ACMD_DEF(showexp),
  8292. ACMD_DEF(showzeny),
  8293. ACMD_DEF(showdelay),
  8294. ACMD_DEF(autotrade),
  8295. ACMD_DEF(changegm),
  8296. ACMD_DEF(changeleader),
  8297. ACMD_DEF(partyoption),
  8298. ACMD_DEF(invite),
  8299. ACMD_DEF(duel),
  8300. ACMD_DEF(leave),
  8301. ACMD_DEF(accept),
  8302. ACMD_DEF(reject),
  8303. ACMD_DEF(clone),
  8304. ACMD_DEF2("slaveclone", clone),
  8305. ACMD_DEF2("evilclone", clone),
  8306. ACMD_DEF(tonpc),
  8307. ACMD_DEF(commands),
  8308. ACMD_DEF(noask),
  8309. ACMD_DEF(request),
  8310. ACMD_DEF(homlevel),
  8311. ACMD_DEF(homevolution),
  8312. ACMD_DEF(hommutate),
  8313. ACMD_DEF(makehomun),
  8314. ACMD_DEF(homfriendly),
  8315. ACMD_DEF(homhungry),
  8316. ACMD_DEF(homtalk),
  8317. ACMD_DEF(hominfo),
  8318. ACMD_DEF(homstats),
  8319. ACMD_DEF(homshuffle),
  8320. ACMD_DEF(showmobs),
  8321. ACMD_DEF(feelreset),
  8322. ACMD_DEF(auction),
  8323. ACMD_DEF(mail),
  8324. ACMD_DEF2("noks", ksprotection),
  8325. ACMD_DEF(allowks),
  8326. ACMD_DEF(cash),
  8327. ACMD_DEF2("points", cash),
  8328. ACMD_DEF(agitstart2),
  8329. ACMD_DEF(agitend2),
  8330. ACMD_DEF2("skreset", resetskill),
  8331. ACMD_DEF2("streset", resetstat),
  8332. ACMD_DEF2("storagelist", itemlist),
  8333. ACMD_DEF2("cartlist", itemlist),
  8334. ACMD_DEF2("itemlist", itemlist),
  8335. ACMD_DEF(stats),
  8336. ACMD_DEF(delitem),
  8337. ACMD_DEF(charcommands),
  8338. ACMD_DEF(font),
  8339. ACMD_DEF(accinfo),
  8340. ACMD_DEF(set),
  8341. ACMD_DEF(reloadquestdb),
  8342. ACMD_DEF(undisguiseguild),
  8343. ACMD_DEF(disguiseguild),
  8344. ACMD_DEF(sizeall),
  8345. ACMD_DEF(sizeguild),
  8346. ACMD_DEF(addperm),
  8347. ACMD_DEF2("rmvperm", addperm),
  8348. ACMD_DEF(unloadnpcfile),
  8349. ACMD_DEF(cart),
  8350. ACMD_DEF(cashmount),
  8351. ACMD_DEF(join),
  8352. ACMD_DEF(channel),
  8353. ACMD_DEF(fontcolor),
  8354. ACMD_DEF(searchstore),
  8355. ACMD_DEF(costume),
  8356. ACMD_DEF(skdebug),
  8357. ACMD_DEF(cddebug),
  8358. ACMD_DEF(lang),
  8359. ACMD_DEF(bodystyle),
  8360. };
  8361. int i;
  8362. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8363. if(!atcommand->add(atcommand_base[i].command,atcommand_base[i].func,false)) { // Should not happen if atcommand_base[] array is OK
  8364. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8365. continue;
  8366. }
  8367. }
  8368. /* @commands from plugins */
  8369. HPM_map_atcommands();
  8370. return;
  8371. }
  8372. #undef ACMD_DEF
  8373. #undef ACMD_DEF2
  8374. bool atcommand_add(char *name, AtCommandFunc func, bool replace) {
  8375. AtCommandInfo* cmd;
  8376. nullpo_retr(false, name);
  8377. if( (cmd = atcommand->exists(name)) ) { //caller will handle/display on false
  8378. if( !replace )
  8379. return false;
  8380. } else {
  8381. CREATE(cmd, AtCommandInfo, 1);
  8382. strdb_put(atcommand->db, name, cmd);
  8383. }
  8384. safestrncpy(cmd->command, name, sizeof(cmd->command));
  8385. cmd->func = func;
  8386. cmd->help = NULL;
  8387. cmd->log = true;
  8388. return true;
  8389. }
  8390. /*==========================================
  8391. * Command lookup functions
  8392. *------------------------------------------*/
  8393. AtCommandInfo* atcommand_exists(const char* name) {
  8394. return strdb_get(atcommand->db, name);
  8395. }
  8396. AtCommandInfo* get_atcommandinfo_byname(const char *name) {
  8397. AtCommandInfo *cmd;
  8398. if ((cmd = strdb_get(atcommand->db, name)))
  8399. return cmd;
  8400. return NULL;
  8401. }
  8402. const char* atcommand_checkalias(const char *aliasname) {
  8403. AliasInfo *alias_info = NULL;
  8404. if ((alias_info = (AliasInfo*)strdb_get(atcommand->alias_db, aliasname)) != NULL)
  8405. return alias_info->command->command;
  8406. return aliasname;
  8407. }
  8408. /// AtCommand suggestion
  8409. void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool is_atcmd_cmd) {
  8410. DBIterator* atcommand_iter;
  8411. DBIterator* alias_iter;
  8412. AtCommandInfo* command_info = NULL;
  8413. AliasInfo* alias_info = NULL;
  8414. AtCommandType type = is_atcmd_cmd ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8415. char* full_match[MAX_SUGGESTIONS];
  8416. char* suggestions[MAX_SUGGESTIONS];
  8417. char* match;
  8418. int prefix_count = 0, full_count = 0;
  8419. bool can_use;
  8420. if (!battle_config.atcommand_suggestions_enabled)
  8421. return;
  8422. atcommand_iter = db_iterator(atcommand->db);
  8423. alias_iter = db_iterator(atcommand->alias_db);
  8424. // Build the matches
  8425. for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
  8426. match = strstr(command_info->command, name);
  8427. can_use = atcommand->can_use2(sd, command_info->command, type);
  8428. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8429. suggestions[prefix_count] = command_info->command;
  8430. ++prefix_count;
  8431. }
  8432. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8433. full_match[full_count] = command_info->command;
  8434. ++full_count;
  8435. }
  8436. }
  8437. for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
  8438. match = strstr(alias_info->alias, name);
  8439. can_use = atcommand->can_use2(sd, alias_info->command->command,type);
  8440. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8441. suggestions[prefix_count] = alias_info->alias;
  8442. ++prefix_count;
  8443. }
  8444. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8445. full_match[full_count] = alias_info->alias;
  8446. ++full_count;
  8447. }
  8448. }
  8449. if ((full_count+prefix_count) > 0) {
  8450. char buffer[512];
  8451. int i;
  8452. // Merge full match and prefix match results
  8453. if (prefix_count < MAX_SUGGESTIONS) {
  8454. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8455. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8456. }
  8457. // Build the suggestion string
  8458. strcpy(buffer, msg_sd(sd,205));
  8459. strcat(buffer,"\n");
  8460. for(i=0; i < prefix_count; ++i) {
  8461. strcat(buffer,suggestions[i]);
  8462. strcat(buffer," ");
  8463. }
  8464. clif->message(sd->fd, buffer);
  8465. }
  8466. dbi_destroy(atcommand_iter);
  8467. dbi_destroy(alias_iter);
  8468. }
  8469. /**
  8470. * Executes an at-command
  8471. * @param fd fd associated to the invoking character
  8472. * @param sd sd associated to the invoking character
  8473. * @param message atcommand arguments
  8474. * @param player_invoked true if the command was invoked by a player, false if invoked by the server (bypassing any restrictions)
  8475. */
  8476. bool atcommand_exec(const int fd, struct map_session_data *sd, const char *message, bool player_invoked) {
  8477. char charname[NAME_LENGTH], params[100];
  8478. char charname2[NAME_LENGTH];
  8479. char command[100];
  8480. char output[CHAT_SIZE_MAX];
  8481. //Reconstructed message
  8482. char atcmd_msg[CHAT_SIZE_MAX];
  8483. struct map_session_data *ssd = NULL; //sd for target
  8484. AtCommandInfo * info;
  8485. nullpo_retr(false, sd);
  8486. //Shouldn't happen
  8487. if ( !message || !*message )
  8488. return false;
  8489. //Block NOCHAT but do not display it as a normal message
  8490. if (pc_ismuted(&sd->sc, MANNER_NOCOMMAND))
  8491. return true;
  8492. // skip 10/11-langtype's codepage indicator, if detected
  8493. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand->at_symbol || message[3] == atcommand->char_symbol) )
  8494. message += 3;
  8495. //Should display as a normal message
  8496. if ( *message != atcommand->at_symbol && *message != atcommand->char_symbol )
  8497. return false;
  8498. if (player_invoked) {
  8499. //Commands are disabled on maps flagged as 'nocommand'
  8500. if ( map->list[sd->bl.m].nocommand && pc_get_group_level(sd) < map->list[sd->bl.m].nocommand ) {
  8501. clif->message(fd, msg_fd(fd,143));
  8502. return false;
  8503. }
  8504. }
  8505. if (*message == atcommand->char_symbol) {
  8506. do {
  8507. char params2[100];
  8508. int x, y, z;
  8509. //Checks to see if #command has a name or a name + parameters.
  8510. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  8511. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  8512. //z always has the value of the scan that was successful
  8513. z = ( x > 1 ) ? x : y;
  8514. //#command + name means the sufficient target was used and anything else after
  8515. //can be looked at by the actual command function since most scan to see if the
  8516. //right parameters are used.
  8517. if ( x > 2 ) {
  8518. sprintf(atcmd_msg, "%s %s", command, params);
  8519. break;
  8520. }
  8521. else if ( y > 2 ) {
  8522. sprintf(atcmd_msg, "%s %s", command, params2);
  8523. break;
  8524. }
  8525. //Regardless of what style the #command is used, if it's correct, it will always have
  8526. //this value if there is no parameter. Send it as just the #command
  8527. else if ( z == 2 ) {
  8528. sprintf(atcmd_msg, "%s", command);
  8529. break;
  8530. }
  8531. if( !pc_get_group_level(sd) ) {
  8532. if( x >= 1 || y >= 1 ) { /* we have command */
  8533. info = atcommand->get_info_byname(atcommand->check_alias(command + 1));
  8534. if( !info || info->char_groups[pcg->get_idx(sd->group)] == 0 ) /* if we can't use or doesn't exist: don't even display the command failed message */
  8535. return false;
  8536. } else
  8537. return false;/* display as normal message */
  8538. }
  8539. sprintf(output, msg_fd(fd,1388), atcommand->char_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8540. clif->message(fd, output);
  8541. return true;
  8542. } while(0);
  8543. }
  8544. else /*if (*message == atcommand->at_symbol)*/ {
  8545. //atcmd_msg is constructed above differently for charcommands
  8546. //it's copied from message if not a charcommand so it can
  8547. //pass through the rest of the code compatible with both symbols
  8548. sprintf(atcmd_msg, "%s", message);
  8549. }
  8550. pc->update_idle_time(sd, BCIDLE_ATCOMMAND);
  8551. //Clearing these to be used once more.
  8552. memset(command, '\0', sizeof(command));
  8553. memset(params, '\0', sizeof(params));
  8554. //check to see if any params exist within this command
  8555. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  8556. params[0] = '\0';
  8557. // @commands (script based)
  8558. if(player_invoked && atcommand->binding_count > 0) {
  8559. struct atcmd_binding_data * binding;
  8560. // Get atcommand binding
  8561. binding = atcommand->get_bind_byname(command);
  8562. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8563. if( binding != NULL
  8564. && binding->npc_event[0]
  8565. && (
  8566. (*atcmd_msg == atcommand->at_symbol && pc_get_group_level(sd) >= binding->group_lv)
  8567. || (*atcmd_msg == atcommand->char_symbol && pc_get_group_level(sd) >= binding->group_lv_char)
  8568. )
  8569. ) {
  8570. // Check if self or character invoking; if self == character invoked, then self invoke.
  8571. bool invokeFlag = ((*atcmd_msg == atcommand->at_symbol) ? 1 : 0);
  8572. // Check if the command initiated is a character command
  8573. if (*message == atcommand->char_symbol
  8574. && (ssd = map->nick2sd(charname)) == NULL
  8575. && (ssd = map->nick2sd(charname2)) == NULL
  8576. ) {
  8577. sprintf(output, msg_fd(fd,1389), command); // %s failed. Player not found.
  8578. clif->message(fd, output);
  8579. return true;
  8580. }
  8581. if( binding->log ) /* log only if this command should be logged [Ind/Hercules] */
  8582. logs->atcommand(sd, atcmd_msg);
  8583. npc->do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  8584. return true;
  8585. }
  8586. }
  8587. //Grab the command information and check for the proper GM level required to use it or if the command exists
  8588. info = atcommand->get_info_byname(atcommand->check_alias(command + 1));
  8589. if (info == NULL) {
  8590. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  8591. sprintf(output, msg_fd(fd,153), command); // "%s is Unknown Command."
  8592. clif->message(fd, output);
  8593. atcommand->get_suggestions(sd, command + 1, *message == atcommand->at_symbol);
  8594. return true;
  8595. } else
  8596. return false;
  8597. }
  8598. if (player_invoked) {
  8599. int i;
  8600. if ((*command == atcommand->at_symbol && info->at_groups[pcg->get_idx(sd->group)] == 0) ||
  8601. (*command == atcommand->char_symbol && info->char_groups[pcg->get_idx(sd->group)] == 0) ) {
  8602. return false;
  8603. }
  8604. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8605. clif->message(fd, msg_fd(fd,1393)); // You can't use commands while dead
  8606. return true;
  8607. }
  8608. for(i = 0; i < map->list[sd->bl.m].zone->disabled_commands_count; i++) {
  8609. if( info->func == map->list[sd->bl.m].zone->disabled_commands[i]->cmd ) {
  8610. if (pc_get_group_level(sd) < map->list[sd->bl.m].zone->disabled_commands[i]->group_lv) {
  8611. clif->messagecolor_self(sd->fd, COLOR_RED, "This command is disabled in this area");
  8612. return true;
  8613. } else {
  8614. break;/* already found the matching command, no need to keep checking -- just go on */
  8615. }
  8616. }
  8617. }
  8618. }
  8619. // Check if target is valid only if confirmed that player can use command.
  8620. if (*message == atcommand->char_symbol
  8621. && (ssd = map->nick2sd(charname)) == NULL
  8622. && (ssd = map->nick2sd(charname2)) == NULL
  8623. ) {
  8624. sprintf(output, msg_fd(fd,1389), command); // %s failed. Player not found.
  8625. clif->message(fd, output);
  8626. return true;
  8627. }
  8628. //Attempt to use the command
  8629. if ( (info->func(fd, (*atcmd_msg == atcommand->at_symbol) ? sd : ssd, command, params,info) != true) ) {
  8630. #ifdef AUTOTRADE_PERSISTENCY
  8631. if( info->func == atcommand_autotrade ) /** autotrade deletes caster, so we got nothing more to do here **/
  8632. return true;
  8633. #endif
  8634. sprintf(output,msg_fd(fd,154), command); // %s failed.
  8635. clif->message(fd, output);
  8636. return true;
  8637. }
  8638. if( info->log ) /* log only if this command should be logged [Ind/Hercules] */
  8639. logs->atcommand(sd, *atcmd_msg == atcommand->at_symbol ? atcmd_msg : message);
  8640. return true;
  8641. }
  8642. /*==========================================
  8643. *
  8644. *------------------------------------------*/
  8645. void atcommand_config_read(const char* config_filename) {
  8646. config_t atcommand_config;
  8647. config_setting_t *aliases = NULL, *help = NULL, *nolog = NULL;
  8648. const char *symbol = NULL;
  8649. int num_aliases = 0;
  8650. nullpo_retv(config_filename);
  8651. if (libconfig->read_file(&atcommand_config, config_filename))
  8652. return;
  8653. // Command symbols
  8654. if (libconfig->lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8655. if (ISPRINT(*symbol) && // no control characters
  8656. *symbol != '/' && // symbol of client commands
  8657. *symbol != '%' && // symbol of party chat
  8658. *symbol != '$' && // symbol of guild chat
  8659. *symbol != atcommand->char_symbol)
  8660. atcommand->at_symbol = *symbol;
  8661. }
  8662. if (libconfig->lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8663. if (ISPRINT(*symbol) && // no control characters
  8664. *symbol != '/' && // symbol of client commands
  8665. *symbol != '%' && // symbol of party chat
  8666. *symbol != '$' && // symbol of guild chat
  8667. *symbol != atcommand->at_symbol)
  8668. atcommand->char_symbol = *symbol;
  8669. }
  8670. // Command aliases
  8671. aliases = libconfig->lookup(&atcommand_config, "aliases");
  8672. if (aliases != NULL) {
  8673. int i = 0;
  8674. int count = libconfig->setting_length(aliases);
  8675. for (i = 0; i < count; ++i) {
  8676. config_setting_t *command;
  8677. const char *commandname = NULL;
  8678. int j = 0, alias_count = 0;
  8679. AtCommandInfo *commandinfo = NULL;
  8680. command = libconfig->setting_get_elem(aliases, i);
  8681. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8682. continue;
  8683. commandname = config_setting_name(command);
  8684. if ( !( commandinfo = atcommand->exists(commandname) ) ) {
  8685. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8686. continue;
  8687. }
  8688. alias_count = libconfig->setting_length(command);
  8689. for (j = 0; j < alias_count; ++j) {
  8690. const char *alias = libconfig->setting_get_string_elem(command, j);
  8691. if (alias != NULL) {
  8692. AliasInfo *alias_info;
  8693. if (strdb_exists(atcommand->alias_db, alias)) {
  8694. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8695. continue;
  8696. }
  8697. CREATE(alias_info, AliasInfo, 1);
  8698. alias_info->command = commandinfo;
  8699. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8700. strdb_put(atcommand->alias_db, alias, alias_info);
  8701. ++num_aliases;
  8702. }
  8703. }
  8704. }
  8705. }
  8706. nolog = libconfig->lookup(&atcommand_config, "nolog");
  8707. if (nolog != NULL) {
  8708. int i = 0;
  8709. int count = libconfig->setting_length(nolog);
  8710. for (i = 0; i < count; ++i) {
  8711. config_setting_t *command;
  8712. const char *commandname = NULL;
  8713. AtCommandInfo *commandinfo = NULL;
  8714. command = libconfig->setting_get_elem(nolog, i);
  8715. commandname = config_setting_name(command);
  8716. if ( !( commandinfo = atcommand->exists(commandname) ) ) {
  8717. ShowConfigWarning(command, "atcommand_config_read: can not disable logging for non-existent command %s", commandname);
  8718. continue;
  8719. }
  8720. commandinfo->log = false;
  8721. }
  8722. }
  8723. // Commands help
  8724. // We only check if all commands exist
  8725. help = libconfig->lookup(&atcommand_config, "help");
  8726. if (help != NULL) {
  8727. int count = libconfig->setting_length(help);
  8728. int i;
  8729. for (i = 0; i < count; ++i) {
  8730. config_setting_t *command;
  8731. const char *commandname;
  8732. AtCommandInfo *commandinfo = NULL;
  8733. command = libconfig->setting_get_elem(help, i);
  8734. commandname = config_setting_name(command);
  8735. if ( !( commandinfo = atcommand->exists(commandname) ) )
  8736. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8737. else {
  8738. if( commandinfo->help == NULL ) {
  8739. const char *str = libconfig->setting_get_string(command);
  8740. size_t len = strlen(str);
  8741. commandinfo->help = aMalloc(len + 1);
  8742. safestrncpy(commandinfo->help, str, len + 1);
  8743. }
  8744. }
  8745. }
  8746. }
  8747. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8748. libconfig->destroy(&atcommand_config);
  8749. return;
  8750. }
  8751. /**
  8752. * In group configuration file, setting for each command is either
  8753. * <commandname> : <bool> (only atcommand), or
  8754. * <commandname> : [ <bool>, <bool> ] ([ atcommand, charcommand ])
  8755. * Maps AtCommandType enums to indexes of <commandname> value array,
  8756. * COMMAND_ATCOMMAND (1) being index 0, COMMAND_CHARCOMMAND (2) being index 1.
  8757. * @private
  8758. */
  8759. static inline int atcommand_command_type2idx(AtCommandType type)
  8760. {
  8761. Assert_retr(0, type > 0);
  8762. return (type-1);
  8763. }
  8764. /**
  8765. * Loads permissions for groups to use commands.
  8766. *
  8767. */
  8768. void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **commands_, size_t sz)
  8769. {
  8770. DBIterator *iter = db_iterator(atcommand->db);
  8771. AtCommandInfo *atcmd;
  8772. nullpo_retv(groups);
  8773. nullpo_retv(commands_);
  8774. for (atcmd = dbi_first(iter); dbi_exists(iter); atcmd = dbi_next(iter)) {
  8775. int i;
  8776. CREATE(atcmd->at_groups, char, sz);
  8777. CREATE(atcmd->char_groups, char, sz);
  8778. for (i = 0; i < sz; i++) {
  8779. GroupSettings *group = groups[i];
  8780. config_setting_t *commands = commands_[i];
  8781. int result = 0;
  8782. int idx = -1;
  8783. if (group == NULL) {
  8784. ShowError("atcommand_db_load_groups: group is NULL\n");
  8785. continue;
  8786. }
  8787. idx = pcg->get_idx(group);
  8788. if (idx < 0 || idx >= sz) {
  8789. ShowError("atcommand_db_load_groups: index (%d) out of bounds [0,%"PRIuS"]\n", idx, sz - 1);
  8790. continue;
  8791. }
  8792. if (pcg->has_permission(group, PC_PERM_USE_ALL_COMMANDS)) {
  8793. atcmd->at_groups[idx] = atcmd->char_groups[idx] = 1;
  8794. continue;
  8795. }
  8796. if (commands != NULL) {
  8797. config_setting_t *cmd = NULL;
  8798. // <commandname> : <bool> (only atcommand)
  8799. if (config_setting_lookup_bool(commands, atcmd->command, &result) && result) {
  8800. atcmd->at_groups[idx] = 1;
  8801. }
  8802. else
  8803. // <commandname> : [ <bool>, <bool> ] ([ atcommand, charcommand ])
  8804. if ((cmd = config_setting_get_member(commands, atcmd->command)) != NULL &&
  8805. config_setting_is_aggregate(cmd) &&
  8806. config_setting_length(cmd) == 2
  8807. ) {
  8808. if (config_setting_get_bool_elem(cmd, atcommand_command_type2idx(COMMAND_ATCOMMAND))) {
  8809. atcmd->at_groups[idx] = 1;
  8810. }
  8811. if (config_setting_get_bool_elem(cmd, atcommand_command_type2idx(COMMAND_CHARCOMMAND))) {
  8812. atcmd->char_groups[idx] = 1;
  8813. }
  8814. }
  8815. }
  8816. }
  8817. }
  8818. dbi_destroy(iter);
  8819. return;
  8820. }
  8821. bool atcommand_can_use(struct map_session_data *sd, const char *command) {
  8822. AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command + 1));
  8823. nullpo_retr(false, sd);
  8824. nullpo_retr(false, command);
  8825. if (info == NULL)
  8826. return false;
  8827. if ((*command == atcommand->at_symbol && info->at_groups[pcg->get_idx(sd->group)] != 0) ||
  8828. (*command == atcommand->char_symbol && info->char_groups[pcg->get_idx(sd->group)] != 0) ) {
  8829. return true;
  8830. }
  8831. return false;
  8832. }
  8833. bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtCommandType type) {
  8834. AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command));
  8835. nullpo_retr(false, sd);
  8836. nullpo_retr(false, command);
  8837. if (info == NULL)
  8838. return false;
  8839. if ((type == COMMAND_ATCOMMAND && info->at_groups[pcg->get_idx(sd->group)] != 0) ||
  8840. (type == COMMAND_CHARCOMMAND && info->char_groups[pcg->get_idx(sd->group)] != 0) ) {
  8841. return true;
  8842. }
  8843. return false;
  8844. }
  8845. bool atcommand_hp_add(char *name, AtCommandFunc func) {
  8846. /* if commands are added after group permissions are thrown in, they end up with no permissions */
  8847. /* so we restrict commands to be linked in during boot */
  8848. if( core->runflag == MAPSERVER_ST_RUNNING ) {
  8849. ShowDebug("atcommand_hp_add: Commands can't be added after server is ready, skipping '%s'...\n",name);
  8850. return false;
  8851. }
  8852. return HPM_map_add_atcommand(name,func);
  8853. }
  8854. /**
  8855. * @see DBApply
  8856. */
  8857. int atcommand_db_clear_sub(DBKey key, DBData *data, va_list args) {
  8858. AtCommandInfo *cmd = DB->data2ptr(data);
  8859. aFree(cmd->at_groups);
  8860. aFree(cmd->char_groups);
  8861. if (cmd->help != NULL)
  8862. aFree(cmd->help);
  8863. return 0;
  8864. }
  8865. void atcommand_db_clear(void) {
  8866. if( atcommand->db != NULL ) {
  8867. atcommand->db->destroy(atcommand->db, atcommand->cmd_db_clear_sub);
  8868. atcommand->db = NULL;
  8869. }
  8870. if( atcommand->alias_db != NULL ) {
  8871. db_destroy(atcommand->alias_db);
  8872. atcommand->alias_db = NULL;
  8873. }
  8874. }
  8875. void atcommand_doload(void) {
  8876. if( core->runflag >= MAPSERVER_ST_RUNNING )
  8877. atcommand->cmd_db_clear();
  8878. if( atcommand->db == NULL )
  8879. atcommand->db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8880. if( atcommand->alias_db == NULL )
  8881. atcommand->alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8882. atcommand->base_commands(); //fills initial atcommand_db with known commands
  8883. atcommand->config_read(map->ATCOMMAND_CONF_FILENAME);
  8884. }
  8885. void atcommand_expand_message_table(void) {
  8886. RECREATE(atcommand->msg_table, char **, ++atcommand->max_message_table);
  8887. CREATE(atcommand->msg_table[atcommand->max_message_table - 1], char *, MAX_MSG);
  8888. }
  8889. void do_init_atcommand(bool minimal) {
  8890. if (minimal)
  8891. return;
  8892. atcommand->at_symbol = '@';
  8893. atcommand->char_symbol = '#';
  8894. atcommand->binding_count = 0;
  8895. atcommand->doload();
  8896. }
  8897. void do_final_atcommand(void) {
  8898. atcommand->cmd_db_clear();
  8899. }
  8900. void atcommand_defaults(void) {
  8901. atcommand = &atcommand_s;
  8902. atcommand->db = NULL;
  8903. atcommand->alias_db = NULL;
  8904. atcommand->init = do_init_atcommand;
  8905. atcommand->final = do_final_atcommand;
  8906. atcommand->exec = atcommand_exec;
  8907. atcommand->create = atcommand_hp_add;
  8908. atcommand->can_use = atcommand_can_use;
  8909. atcommand->can_use2 = atcommand_can_use2;
  8910. atcommand->load_groups = atcommand_db_load_groups;
  8911. atcommand->exists = atcommand_exists;
  8912. atcommand->msg_read = msg_config_read;
  8913. atcommand->final_msg = do_final_msg;
  8914. atcommand->get_bind_byname = get_atcommandbind_byname;
  8915. atcommand->get_info_byname = get_atcommandinfo_byname;
  8916. atcommand->check_alias = atcommand_checkalias;
  8917. atcommand->get_suggestions = atcommand_get_suggestions;
  8918. atcommand->config_read = atcommand_config_read;
  8919. atcommand->stopattack = atcommand_stopattack;
  8920. atcommand->pvpoff_sub = atcommand_pvpoff_sub;
  8921. atcommand->pvpon_sub = atcommand_pvpon_sub;
  8922. atcommand->atkillmonster_sub = atkillmonster_sub;
  8923. atcommand->raise_sub = atcommand_raise_sub;
  8924. atcommand->get_jail_time = get_jail_time;
  8925. atcommand->cleanfloor_sub = atcommand_cleanfloor_sub;
  8926. atcommand->mutearea_sub = atcommand_mutearea_sub;
  8927. atcommand->commands_sub = atcommand_commands_sub;
  8928. atcommand->getring = atcommand_getring;
  8929. atcommand->channel_help = atcommand_channel_help;
  8930. atcommand->cmd_db_clear = atcommand_db_clear;
  8931. atcommand->cmd_db_clear_sub = atcommand_db_clear_sub;
  8932. atcommand->doload = atcommand_doload;
  8933. atcommand->base_commands = atcommand_basecommands;
  8934. atcommand->add = atcommand_add;
  8935. atcommand->msg = atcommand_msg;
  8936. atcommand->expand_message_table = atcommand_expand_message_table;
  8937. atcommand->msgfd = atcommand_msgfd;
  8938. atcommand->msgsd = atcommand_msgsd;
  8939. }