yuhsing

Untitled

Mar 29th, 2013
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 280.06 KB | None | 0 0
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3.  
  4. #include "../common/cbasetypes.h"
  5. #include "../common/mmo.h"
  6. #include "../common/timer.h"
  7. #include "../common/nullpo.h"
  8. #include "../common/core.h"
  9. #include "../common/showmsg.h"
  10. #include "../common/malloc.h"
  11. #include "../common/socket.h"
  12. #include "../common/strlib.h"
  13. #include "../common/utils.h"
  14.  
  15. #include "atcommand.h"
  16. #include "battle.h"
  17. #include "chat.h"
  18. #include "clif.h"
  19. #include "chrif.h"
  20. #include "duel.h"
  21. #include "intif.h"
  22. #include "itemdb.h"
  23. #include "log.h"
  24. #include "map.h"
  25. #include "pc.h"
  26. #include "status.h"
  27. #include "skill.h"
  28. #include "mob.h"
  29. #include "npc.h"
  30. #include "pet.h"
  31. #include "homunculus.h"
  32. #include "mercenary.h"
  33. #include "party.h"
  34. #include "guild.h"
  35. #include "script.h"
  36. #include "storage.h"
  37. #include "trade.h"
  38. #include "unit.h"
  39.  
  40. #ifndef TXT_ONLY
  41. #include "mail.h"
  42. #endif
  43.  
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. #include <string.h>
  47. #include <math.h>
  48.  
  49. // extern variables
  50. char atcommand_symbol = '@'; // first char of the commands
  51. char charcommand_symbol = '#';
  52. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  53.  
  54. // local declarations
  55. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  56.  
  57. typedef struct AtCommandInfo
  58. {
  59. const char* command;
  60. int level;
  61. int level2;
  62. AtCommandFunc func;
  63. } AtCommandInfo;
  64.  
  65. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  66. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func);
  67.  
  68. ACMD_FUNC(commands);
  69.  
  70.  
  71. /*=========================================
  72. * Generic variables
  73. *-----------------------------------------*/
  74. char atcmd_output[CHAT_SIZE_MAX];
  75. char atcmd_player_name[NAME_LENGTH];
  76. char atcmd_temp[100];
  77.  
  78. // compare function for sorting high to lowest
  79. int hightolow_compare (const void * a, const void * b)
  80. {
  81. return ( *(int*)b - *(int*)a );
  82. }
  83.  
  84. // compare function for sorting lowest to highest
  85. int lowtohigh_compare (const void * a, const void * b)
  86. {
  87. return ( *(int*)a - *(int*)b );
  88. }
  89.  
  90. //-----------------------------------------------------------
  91. // Return the message string of the specified number by [Yor]
  92. //-----------------------------------------------------------
  93. const char* msg_txt(int msg_number)
  94. {
  95. if (msg_number >= 0 && msg_number < MAX_MSG &&
  96. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  97. return msg_table[msg_number];
  98.  
  99. return "??";
  100. }
  101.  
  102. //-----------------------------------------------------------
  103. // Returns Players title (from msg_athena.conf) [Lupus]
  104. //-----------------------------------------------------------
  105. static char* player_title_txt(int level)
  106. {
  107. const char* format;
  108. format = (level >= battle_config.title_lvl8) ? msg_txt(332)
  109. : (level >= battle_config.title_lvl7) ? msg_txt(331)
  110. : (level >= battle_config.title_lvl6) ? msg_txt(330)
  111. : (level >= battle_config.title_lvl5) ? msg_txt(329)
  112. : (level >= battle_config.title_lvl4) ? msg_txt(328)
  113. : (level >= battle_config.title_lvl3) ? msg_txt(327)
  114. : (level >= battle_config.title_lvl2) ? msg_txt(326)
  115. : (level >= battle_config.title_lvl1) ? msg_txt(325)
  116. : "";
  117. sprintf(atcmd_temp, format, level);
  118. return atcmd_temp;
  119. }
  120.  
  121.  
  122. /*==========================================
  123. * Read Message Data
  124. *------------------------------------------*/
  125. int msg_config_read(const char* cfgName)
  126. {
  127. int msg_number;
  128. char line[1024], w1[1024], w2[1024];
  129. FILE *fp;
  130. static int called = 1;
  131.  
  132. if ((fp = fopen(cfgName, "r")) == NULL) {
  133. ShowError("Messages file not found: %s\n", cfgName);
  134. return 1;
  135. }
  136.  
  137. if ((--called) == 0)
  138. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  139.  
  140. while(fgets(line, sizeof(line), fp))
  141. {
  142. if (line[0] == '/' && line[1] == '/')
  143. continue;
  144. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  145. continue;
  146.  
  147. if (strcmpi(w1, "import") == 0)
  148. msg_config_read(w2);
  149. else
  150. {
  151. msg_number = atoi(w1);
  152. if (msg_number >= 0 && msg_number < MAX_MSG)
  153. {
  154. if (msg_table[msg_number] != NULL)
  155. aFree(msg_table[msg_number]);
  156. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  157. strcpy(msg_table[msg_number],w2);
  158. }
  159. }
  160. }
  161.  
  162. fclose(fp);
  163.  
  164. return 0;
  165. }
  166.  
  167. /*==========================================
  168. * Cleanup Message Data
  169. *------------------------------------------*/
  170. void do_final_msg(void)
  171. {
  172. int i;
  173. for (i = 0; i < MAX_MSG; i++)
  174. aFree(msg_table[i]);
  175. }
  176.  
  177.  
  178. /*==========================================
  179. * @send (used for testing packet sends from the client)
  180. *------------------------------------------*/
  181. ACMD_FUNC(send)
  182. {
  183. int len=0,off,end,type;
  184. long num;
  185. (void)command; // not used
  186.  
  187. // read message type as hex number (without the 0x)
  188. if(!message || !*message ||
  189. !((sscanf(message, "len %x", &type)==1 && (len=1))
  190. || sscanf(message, "%x", &type)==1) )
  191. {
  192. clif_displaymessage(fd, "Usage:");
  193. clif_displaymessage(fd, " @send len <packet hex number>");
  194. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  195. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  196. return -1;
  197. }
  198.  
  199. #define PARSE_ERROR(error,p) \
  200. {\
  201. clif_displaymessage(fd, (error));\
  202. sprintf(atcmd_output, ">%s", (p));\
  203. clif_displaymessage(fd, atcmd_output);\
  204. }
  205. //define PARSE_ERROR
  206.  
  207. #define CHECK_EOS(p) \
  208. if(*(p) == 0){\
  209. clif_displaymessage(fd, "Unexpected end of string");\
  210. return -1;\
  211. }
  212. //define CHECK_EOS
  213.  
  214. #define SKIP_VALUE(p) \
  215. {\
  216. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  217. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  218. }
  219. //define SKIP_VALUE
  220.  
  221. #define GET_VALUE(p,num) \
  222. {\
  223. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  224. PARSE_ERROR("Invalid number in:",(p));\
  225. return -1;\
  226. }\
  227. }
  228. //define GET_VALUE
  229.  
  230. if (type > 0 && type < MAX_PACKET_DB) {
  231.  
  232. if(len)
  233. {// show packet length
  234. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  235. clif_displaymessage(fd, atcmd_output);
  236. return 0;
  237. }
  238.  
  239. len=packet_db[sd->packet_ver][type].len;
  240. off=2;
  241. if(len == 0)
  242. {// unknown packet - ERROR
  243. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  244. clif_displaymessage(fd, atcmd_output);
  245. return -1;
  246. } else if(len == -1)
  247. {// dynamic packet
  248. len=SHRT_MAX-4; // maximum length
  249. off=4;
  250. }
  251. WFIFOHEAD(fd, len);
  252. WFIFOW(fd,0)=TOW(type);
  253.  
  254. // parse packet contents
  255. SKIP_VALUE(message);
  256. while(*message != 0 && off < len){
  257. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  258. {// default (byte)
  259. GET_VALUE(message,num);
  260. WFIFOB(fd,off)=TOB(num);
  261. ++off;
  262. } else if(TOUPPER(*message) == 'B')
  263. {// byte
  264. ++message;
  265. GET_VALUE(message,num);
  266. WFIFOB(fd,off)=TOB(num);
  267. ++off;
  268. } else if(TOUPPER(*message) == 'W')
  269. {// word (2 bytes)
  270. ++message;
  271. GET_VALUE(message,num);
  272. WFIFOW(fd,off)=TOW(num);
  273. off+=2;
  274. } else if(TOUPPER(*message) == 'L')
  275. {// long word (4 bytes)
  276. ++message;
  277. GET_VALUE(message,num);
  278. WFIFOL(fd,off)=TOL(num);
  279. off+=4;
  280. } else if(TOUPPER(*message) == 'S')
  281. {// string - escapes are valid
  282. // get string length - num <= 0 means not fixed length (default)
  283. ++message;
  284. if(*message == '"'){
  285. num=0;
  286. } else {
  287. GET_VALUE(message,num);
  288. while(*message != '"')
  289. {// find start of string
  290. if(*message == 0 || ISSPACE(*message)){
  291. PARSE_ERROR("Not a string:",message);
  292. return -1;
  293. }
  294. ++message;
  295. }
  296. }
  297.  
  298. // parse string
  299. ++message;
  300. CHECK_EOS(message);
  301. end=(num<=0? 0: min(off+((int)num),len));
  302. for(; *message != '"' && (off < end || end == 0); ++off){
  303. if(*message == '\\'){
  304. ++message;
  305. CHECK_EOS(message);
  306. switch(*message){
  307. case 'a': num=0x07; break; // Bell
  308. case 'b': num=0x08; break; // Backspace
  309. case 't': num=0x09; break; // Horizontal tab
  310. case 'n': num=0x0A; break; // Line feed
  311. case 'v': num=0x0B; break; // Vertical tab
  312. case 'f': num=0x0C; break; // Form feed
  313. case 'r': num=0x0D; break; // Carriage return
  314. case 'e': num=0x1B; break; // Escape
  315. default: num=*message; break;
  316. case 'x': // Hexadecimal
  317. {
  318. ++message;
  319. CHECK_EOS(message);
  320. if(!ISXDIGIT(*message)){
  321. PARSE_ERROR("Not a hexadecimal digit:",message);
  322. return -1;
  323. }
  324. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  325. if(ISXDIGIT(*message)){
  326. ++message;
  327. CHECK_EOS(message);
  328. num<<=8;
  329. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  330. }
  331. WFIFOB(fd,off)=TOB(num);
  332. ++message;
  333. CHECK_EOS(message);
  334. continue;
  335. }
  336. case '0':
  337. case '1':
  338. case '2':
  339. case '3':
  340. case '4':
  341. case '5':
  342. case '6':
  343. case '7': // Octal
  344. {
  345. num=*message-'0'; // 1st octal digit
  346. ++message;
  347. CHECK_EOS(message);
  348. if(ISDIGIT(*message) && *message < '8'){
  349. num<<=3;
  350. num+=*message-'0'; // 2nd octal digit
  351. ++message;
  352. CHECK_EOS(message);
  353. if(ISDIGIT(*message) && *message < '8'){
  354. num<<=3;
  355. num+=*message-'0'; // 3rd octal digit
  356. ++message;
  357. CHECK_EOS(message);
  358. }
  359. }
  360. WFIFOB(fd,off)=TOB(num);
  361. continue;
  362. }
  363. }
  364. } else
  365. num=*message;
  366. WFIFOB(fd,off)=TOB(num);
  367. ++message;
  368. CHECK_EOS(message);
  369. }//for
  370. while(*message != '"')
  371. {// ignore extra characters
  372. ++message;
  373. CHECK_EOS(message);
  374. }
  375.  
  376. // terminate the string
  377. if(off < end)
  378. {// fill the rest with 0's
  379. memset(WFIFOP(fd,off),0,end-off);
  380. off=end;
  381. }
  382. } else
  383. {// unknown
  384. PARSE_ERROR("Unknown type of value in:",message);
  385. return -1;
  386. }
  387. SKIP_VALUE(message);
  388. }
  389.  
  390. if(packet_db[sd->packet_ver][type].len == -1)
  391. {// send dynamic packet
  392. WFIFOW(fd,2)=TOW(off);
  393. WFIFOSET(fd,off);
  394. } else
  395. {// send static packet
  396. if(off < len)
  397. memset(WFIFOP(fd,off),0,len-off);
  398. WFIFOSET(fd,len);
  399. }
  400. } else {
  401. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  402. return -1;
  403. }
  404. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  405. clif_displaymessage(fd, atcmd_output);
  406. return 0;
  407. #undef PARSE_ERROR
  408. #undef CHECK_EOS
  409. #undef SKIP_VALUE
  410. #undef GET_VALUE
  411. }
  412.  
  413. /*==========================================
  414. * @rura, @warp, @mapmove
  415. *------------------------------------------*/
  416. ACMD_FUNC(mapmove)
  417. {
  418. char map_name[MAP_NAME_LENGTH_EXT];
  419. unsigned short mapindex;
  420. short x = 0, y = 0;
  421. int m = -1;
  422.  
  423. nullpo_retr(-1, sd);
  424.  
  425. memset(map_name, '\0', sizeof(map_name));
  426.  
  427. if (!message || !*message ||
  428. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  429. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  430.  
  431. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  432. return -1;
  433. }
  434.  
  435. mapindex = mapindex_name2id(map_name);
  436. if (mapindex)
  437. m = map_mapindex2mapid(mapindex);
  438.  
  439. if (!mapindex) { // m < 0 means on different server! [Kevin]
  440. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  441. return -1;
  442. }
  443.  
  444. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  445. { //This is to prevent the pc_setpos call from printing an error.
  446. clif_displaymessage(fd, msg_txt(2));
  447. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  448. x = y = 0; //Invalid cell, use random spot.
  449. }
  450. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  451. clif_displaymessage(fd, msg_txt(247));
  452. return -1;
  453. }
  454. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  455. clif_displaymessage(fd, msg_txt(248));
  456. return -1;
  457. }
  458. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  459. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  460. return -1;
  461. }
  462.  
  463. clif_displaymessage(fd, msg_txt(0)); // Warped.
  464. return 0;
  465. }
  466.  
  467. /*==========================================
  468. * Displays where a character is. Corrected version by Silent. [Skotlex]
  469. *------------------------------------------*/
  470. ACMD_FUNC(where)
  471. {
  472. struct map_session_data* pl_sd;
  473.  
  474. nullpo_retr(-1, sd);
  475. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  476.  
  477. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  478. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  479. return -1;
  480. }
  481.  
  482. pl_sd = map_nick2sd(atcmd_player_name);
  483. if( pl_sd == NULL
  484. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  485. || (battle_config.hide_GM_session && pc_isGM(sd) < pc_isGM(pl_sd) && !(battle_config.who_display_aid && pc_isGM(sd) >= battle_config.who_display_aid))
  486. ) {
  487. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  488. return -1;
  489. }
  490.  
  491. 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);
  492. clif_displaymessage(fd, atcmd_output);
  493.  
  494. return 0;
  495. }
  496.  
  497. /*==========================================
  498. *
  499. *------------------------------------------*/
  500. ACMD_FUNC(jumpto)
  501. {
  502. struct map_session_data *pl_sd = NULL;
  503.  
  504. nullpo_retr(-1, sd);
  505.  
  506. if (!message || !*message) {
  507. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  508. return -1;
  509. }
  510.  
  511. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  512. {
  513. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  514. return -1;
  515. }
  516.  
  517. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  518. {
  519. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  520. return -1;
  521. }
  522.  
  523. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  524. {
  525. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  526. return -1;
  527. }
  528.  
  529. if( pc_isdead(sd) )
  530. {
  531. clif_displaymessage(fd, "You cannot use this command when dead.");
  532. return -1;
  533. }
  534.  
  535. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  536. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  537. clif_displaymessage(fd, atcmd_output);
  538.  
  539. return 0;
  540. }
  541.  
  542. /*==========================================
  543. *
  544. *------------------------------------------*/
  545. ACMD_FUNC(jump)
  546. {
  547. short x = 0, y = 0;
  548.  
  549. nullpo_retr(-1, sd);
  550.  
  551. memset(atcmd_output, '\0', sizeof(atcmd_output));
  552.  
  553. sscanf(message, "%hd %hd", &x, &y);
  554.  
  555. if (map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  556. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  557. return -1;
  558. }
  559.  
  560. if( pc_isdead(sd) )
  561. {
  562. clif_displaymessage(fd, "You cannot use this command when dead.");
  563. return -1;
  564. }
  565.  
  566. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  567. { //This is to prevent the pc_setpos call from printing an error.
  568. clif_displaymessage(fd, msg_txt(2));
  569. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  570. x = y = 0; //Invalid cell, use random spot.
  571. }
  572.  
  573. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  574. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  575. clif_displaymessage(fd, atcmd_output);
  576. return 0;
  577. }
  578.  
  579. /*==========================================
  580. * @who3 = Player name, his location
  581. *------------------------------------------*/
  582. ACMD_FUNC(who3)
  583. {
  584. char temp0[100];
  585. struct map_session_data *pl_sd;
  586. struct s_mapiterator* iter;
  587. int j, count;
  588. int pl_GM_level, GM_level;
  589. char match_text[100];
  590. char player_name[NAME_LENGTH];
  591.  
  592. nullpo_retr(-1, sd);
  593.  
  594. memset(atcmd_output, '\0', sizeof(atcmd_output));
  595. memset(match_text, '\0', sizeof(match_text));
  596. memset(player_name, '\0', sizeof(player_name));
  597.  
  598. if (sscanf(message, "%99[^\n]", match_text) < 1)
  599. strcpy(match_text, "");
  600. for (j = 0; match_text[j]; j++)
  601. match_text[j] = TOLOWER(match_text[j]);
  602.  
  603. count = 0;
  604. GM_level = pc_isGM(sd);
  605.  
  606. iter = mapit_getallusers();
  607. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  608. {
  609. pl_GM_level = pc_isGM(pl_sd);
  610. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  611. {// you can look only lower or same level
  612. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  613. for (j = 0; player_name[j]; j++)
  614. player_name[j] = TOLOWER(player_name[j]);
  615. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  616.  
  617. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  618. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  619. } else {
  620. atcmd_output[0]=0;
  621. }
  622. //Player name
  623. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  624. strcat(atcmd_output,temp0);
  625. //Player title, if exists
  626. if (pl_GM_level > 0) {
  627. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  628. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  629. strcat(atcmd_output,temp0);
  630. }
  631. //Players Location: map x y
  632. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  633. strcat(atcmd_output,temp0);
  634.  
  635. clif_displaymessage(fd, atcmd_output);
  636. count++;
  637. }
  638. }
  639. }
  640. mapit_free(iter);
  641.  
  642. if (count == 0)
  643. clif_displaymessage(fd, msg_txt(28)); // No player found.
  644. else if (count == 1)
  645. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  646. else {
  647. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  648. clif_displaymessage(fd, atcmd_output);
  649. }
  650.  
  651. return 0;
  652. }
  653.  
  654. /*==========================================
  655. * Player name, BLevel, Job,
  656. *------------------------------------------*/
  657. ACMD_FUNC(who2)
  658. {
  659. char temp0[100];
  660. struct map_session_data *pl_sd;
  661. struct s_mapiterator* iter;
  662. int j, count;
  663. int pl_GM_level, GM_level;
  664. char match_text[100];
  665. char player_name[NAME_LENGTH];
  666.  
  667. nullpo_retr(-1, sd);
  668.  
  669. memset(atcmd_output, '\0', sizeof(atcmd_output));
  670. memset(match_text, '\0', sizeof(match_text));
  671. memset(player_name, '\0', sizeof(player_name));
  672.  
  673. if (sscanf(message, "%99[^\n]", match_text) < 1)
  674. strcpy(match_text, "");
  675. for (j = 0; match_text[j]; j++)
  676. match_text[j] = TOLOWER(match_text[j]);
  677.  
  678. count = 0;
  679. GM_level = pc_isGM(sd);
  680.  
  681. iter = mapit_getallusers();
  682. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  683. {
  684. pl_GM_level = pc_isGM(pl_sd);
  685. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
  686. {// you can look only lower or same level
  687. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  688. for (j = 0; player_name[j]; j++)
  689. player_name[j] = TOLOWER(player_name[j]);
  690. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  691. //Players Name
  692. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  693. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  694. //Player title, if exists
  695. if (pl_GM_level > 0) {
  696. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  697. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  698. strcat(atcmd_output,temp0);
  699. }
  700. //Players Base Level / Job name
  701. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  702. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  703. strcat(atcmd_output,temp0);
  704.  
  705. clif_displaymessage(fd, atcmd_output);
  706. count++;
  707. }
  708. }
  709. }
  710. mapit_free(iter);
  711.  
  712. if (count == 0)
  713. clif_displaymessage(fd, msg_txt(28)); // No player found.
  714. else if (count == 1)
  715. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  716. else {
  717. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  718. clif_displaymessage(fd, atcmd_output);
  719. }
  720.  
  721. return 0;
  722. }
  723.  
  724. /*==========================================
  725. * Player name, Playrs Party / Guild name
  726. *------------------------------------------*/
  727. ACMD_FUNC(who)
  728. {
  729. char temp0[100];
  730. struct map_session_data *pl_sd;
  731. struct s_mapiterator* iter;
  732. int j, count;
  733. int pl_GM_level, GM_level;
  734. char match_text[100];
  735. char player_name[NAME_LENGTH];
  736. struct guild *g;
  737. struct party_data *p;
  738.  
  739. nullpo_retr(-1, sd);
  740.  
  741. memset(temp0, '\0', sizeof(temp0));
  742. memset(atcmd_output, '\0', sizeof(atcmd_output));
  743. memset(match_text, '\0', sizeof(match_text));
  744. memset(player_name, '\0', sizeof(player_name));
  745.  
  746. if (sscanf(message, "%99[^\n]", match_text) < 1)
  747. strcpy(match_text, "");
  748. for (j = 0; match_text[j]; j++)
  749. match_text[j] = TOLOWER(match_text[j]);
  750.  
  751. count = 0;
  752. GM_level = pc_isGM(sd);
  753.  
  754. iter = mapit_getallusers();
  755. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  756. {
  757. pl_GM_level = pc_isGM(pl_sd);
  758. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  759. {// you can look only lower or same level
  760. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  761. for (j = 0; player_name[j]; j++)
  762. player_name[j] = TOLOWER(player_name[j]);
  763. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  764. g = guild_search(pl_sd->status.guild_id);
  765. p = party_search(pl_sd->status.party_id);
  766. //Players Name
  767. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  768. //Player title, if exists
  769. if (pl_GM_level > 0) {
  770. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  771. strcat(atcmd_output,temp0);
  772. }
  773. //Players Party if exists
  774. if (p != NULL) {
  775. //sprintf(temp0," | Party: '%s'", p->name);
  776. sprintf(temp0, msg_txt(335), p->party.name);
  777. strcat(atcmd_output,temp0);
  778. }
  779. //Players Guild if exists
  780. if (g != NULL) {
  781. //sprintf(temp0," | Guild: '%s'", g->name);
  782. sprintf(temp0, msg_txt(336), g->name);
  783. strcat(atcmd_output,temp0);
  784. }
  785. clif_displaymessage(fd, atcmd_output);
  786. count++;
  787. }
  788. }
  789. }
  790. mapit_free(iter);
  791.  
  792. if (count == 0)
  793. clif_displaymessage(fd, msg_txt(28)); // No player found.
  794. else if (count == 1)
  795. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  796. else {
  797. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  798. clif_displaymessage(fd, atcmd_output);
  799. }
  800.  
  801. return 0;
  802. }
  803.  
  804. /*==========================================
  805. *
  806. *------------------------------------------*/
  807. ACMD_FUNC(whomap3)
  808. {
  809. struct map_session_data *pl_sd;
  810. struct s_mapiterator* iter;
  811. int count;
  812. int pl_GM_level, GM_level;
  813. int map_id;
  814. char map_name[MAP_NAME_LENGTH_EXT];
  815.  
  816. memset(atcmd_output, '\0', sizeof(atcmd_output));
  817. memset(map_name, '\0', sizeof(map_name));
  818.  
  819. if (!message || !*message)
  820. map_id = sd->bl.m;
  821. else {
  822. sscanf(message, "%15s", map_name);
  823. if ((map_id = map_mapname2mapid(map_name)) < 0)
  824. map_id = sd->bl.m;
  825. }
  826.  
  827. count = 0;
  828. GM_level = pc_isGM(sd);
  829.  
  830. iter = mapit_getallusers();
  831. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  832. {
  833. pl_GM_level = pc_isGM(pl_sd);
  834. if( pl_sd->bl.m != map_id )
  835. continue;
  836. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  837. continue;
  838.  
  839. if (pl_GM_level > 0)
  840. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  841. else
  842. sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  843. clif_displaymessage(fd, atcmd_output);
  844. count++;
  845. }
  846. mapit_free(iter);
  847.  
  848. if (count == 0)
  849. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  850. else if (count == 1)
  851. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  852. else {
  853. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  854. }
  855. clif_displaymessage(fd, atcmd_output);
  856.  
  857. return 0;
  858. }
  859.  
  860. /*==========================================
  861. *
  862. *------------------------------------------*/
  863. ACMD_FUNC(whomap2)
  864. {
  865. struct map_session_data *pl_sd;
  866. struct s_mapiterator* iter;
  867. int count;
  868. int pl_GM_level, GM_level;
  869. int map_id = 0;
  870. char map_name[MAP_NAME_LENGTH_EXT];
  871.  
  872. nullpo_retr(-1, sd);
  873.  
  874. memset(atcmd_output, '\0', sizeof(atcmd_output));
  875. memset(map_name, '\0', sizeof(map_name));
  876.  
  877. if (!message || !*message)
  878. map_id = sd->bl.m;
  879. else {
  880. sscanf(message, "%15s", map_name);
  881. if ((map_id = map_mapname2mapid(map_name)) < 0)
  882. map_id = sd->bl.m;
  883. }
  884.  
  885. count = 0;
  886. GM_level = pc_isGM(sd);
  887.  
  888. iter = mapit_getallusers();
  889. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  890. {
  891. pl_GM_level = pc_isGM(pl_sd);
  892. if( pl_sd->bl.m != map_id )
  893. continue;
  894. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  895. continue;
  896.  
  897. if (pl_GM_level > 0)
  898. sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  899. else
  900. sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  901. clif_displaymessage(fd, atcmd_output);
  902. count++;
  903. }
  904. mapit_free(iter);
  905.  
  906. if (count == 0)
  907. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  908. else if (count == 1)
  909. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  910. else {
  911. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  912. }
  913. clif_displaymessage(fd, atcmd_output);
  914.  
  915. return 0;
  916. }
  917.  
  918. /*==========================================
  919. *
  920. *------------------------------------------*/
  921. ACMD_FUNC(whomap)
  922. {
  923. char temp0[100];
  924. char temp1[100];
  925. struct map_session_data *pl_sd;
  926. struct s_mapiterator* iter;
  927. int count;
  928. int pl_GM_level, GM_level;
  929. int map_id = 0;
  930. char map_name[MAP_NAME_LENGTH_EXT];
  931. struct guild *g;
  932. struct party_data *p;
  933.  
  934. nullpo_retr(-1, sd);
  935.  
  936. memset(temp0, '\0', sizeof(temp0));
  937. memset(temp1, '\0', sizeof(temp1));
  938. memset(atcmd_output, '\0', sizeof(atcmd_output));
  939. memset(map_name, '\0', sizeof(map_name));
  940.  
  941. if (!message || !*message)
  942. map_id = sd->bl.m;
  943. else {
  944. sscanf(message, "%15s", map_name);
  945. if ((map_id = map_mapname2mapid(map_name)) < 0)
  946. map_id = sd->bl.m;
  947. }
  948.  
  949. count = 0;
  950. GM_level = pc_isGM(sd);
  951.  
  952. iter = mapit_getallusers();
  953. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  954. {
  955. pl_GM_level = pc_isGM(pl_sd);
  956. if( pl_sd->bl.m != map_id )
  957. continue;
  958. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  959. continue;
  960.  
  961. g = guild_search(pl_sd->status.guild_id);
  962. if (g == NULL)
  963. sprintf(temp1, "None");
  964. else
  965. sprintf(temp1, "%s", g->name);
  966. p = party_search(pl_sd->status.party_id);
  967. if (p == NULL)
  968. sprintf(temp0, "None");
  969. else
  970. sprintf(temp0, "%s", p->party.name);
  971. if (pl_GM_level > 0)
  972. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  973. else
  974. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  975. clif_displaymessage(fd, atcmd_output);
  976. count++;
  977. }
  978. mapit_free(iter);
  979.  
  980. if (count == 0)
  981. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  982. else if (count == 1)
  983. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  984. else {
  985. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  986. }
  987. clif_displaymessage(fd, atcmd_output);
  988.  
  989. return 0;
  990. }
  991.  
  992. /*==========================================
  993. *
  994. *------------------------------------------*/
  995. ACMD_FUNC(whogm)
  996. {
  997. struct map_session_data* pl_sd;
  998. struct s_mapiterator* iter;
  999. int j, count;
  1000. int pl_GM_level, GM_level;
  1001. char match_text[CHAT_SIZE_MAX];
  1002. char player_name[NAME_LENGTH];
  1003. struct guild *g;
  1004. struct party_data *p;
  1005.  
  1006. nullpo_retr(-1, sd);
  1007.  
  1008. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1009. memset(match_text, '\0', sizeof(match_text));
  1010. memset(player_name, '\0', sizeof(player_name));
  1011.  
  1012. if (sscanf(message, "%199[^\n]", match_text) < 1)
  1013. strcpy(match_text, "");
  1014. for (j = 0; match_text[j]; j++)
  1015. match_text[j] = TOLOWER(match_text[j]);
  1016.  
  1017. count = 0;
  1018. GM_level = pc_isGM(sd);
  1019.  
  1020. iter = mapit_getallusers();
  1021. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  1022. {
  1023. pl_GM_level = pc_isGM(pl_sd);
  1024. if (!pl_GM_level)
  1025. continue;
  1026.  
  1027. if (match_text[0])
  1028. {
  1029. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1030. for (j = 0; player_name[j]; j++)
  1031. player_name[j] = TOLOWER(player_name[j]);
  1032. // search with no case sensitive
  1033. if (strstr(player_name, match_text) == NULL)
  1034. continue;
  1035. }
  1036. if (pl_GM_level > GM_level) {
  1037. if (pl_sd->sc.option & OPTION_INVISIBLE)
  1038. continue;
  1039. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  1040. clif_displaymessage(fd, atcmd_output);
  1041. count++;
  1042. continue;
  1043. }
  1044.  
  1045. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  1046. pl_sd->status.name, pl_GM_level,
  1047. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1048. clif_displaymessage(fd, atcmd_output);
  1049.  
  1050. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  1051. pl_sd->status.base_level,
  1052. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1053. clif_displaymessage(fd, atcmd_output);
  1054.  
  1055. p = party_search(pl_sd->status.party_id);
  1056. g = guild_search(pl_sd->status.guild_id);
  1057.  
  1058. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  1059. p?p->party.name:"None", g?g->name:"None");
  1060.  
  1061. clif_displaymessage(fd, atcmd_output);
  1062. count++;
  1063. }
  1064. mapit_free(iter);
  1065.  
  1066. if (count == 0)
  1067. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  1068. else if (count == 1)
  1069. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  1070. else {
  1071. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  1072. clif_displaymessage(fd, atcmd_output);
  1073. }
  1074.  
  1075. return 0;
  1076. }
  1077.  
  1078. /*==========================================
  1079. *
  1080. *------------------------------------------*/
  1081. ACMD_FUNC(save)
  1082. {
  1083. nullpo_retr(-1, sd);
  1084.  
  1085. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1086. if (sd->status.pet_id > 0 && sd->pd)
  1087. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  1088.  
  1089. chrif_save(sd,0);
  1090.  
  1091. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  1092.  
  1093. return 0;
  1094. }
  1095.  
  1096. /*==========================================
  1097. *
  1098. *------------------------------------------*/
  1099. ACMD_FUNC(load)
  1100. {
  1101. int m;
  1102.  
  1103. nullpo_retr(-1, sd);
  1104.  
  1105. m = map_mapindex2mapid(sd->status.save_point.map);
  1106. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1107. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  1108. return -1;
  1109. }
  1110. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1111. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  1112. return -1;
  1113. }
  1114.  
  1115. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  1116. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  1117.  
  1118. return 0;
  1119. }
  1120.  
  1121. /*==========================================
  1122. *
  1123. *------------------------------------------*/
  1124. ACMD_FUNC(speed)
  1125. {
  1126. int speed;
  1127.  
  1128. nullpo_retr(-1, sd);
  1129.  
  1130. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1131.  
  1132. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  1133. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1134. clif_displaymessage(fd, atcmd_output);
  1135. return -1;
  1136. }
  1137.  
  1138. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  1139. status_calc_bl(&sd->bl, SCB_SPEED);
  1140. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1141. return 0;
  1142. }
  1143.  
  1144. /*==========================================
  1145. *
  1146. *------------------------------------------*/
  1147. ACMD_FUNC(storage)
  1148. {
  1149. nullpo_retr(-1, sd);
  1150.  
  1151. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  1152. return -1;
  1153.  
  1154. if (storage_storageopen(sd) == 1)
  1155. { //Already open.
  1156. clif_displaymessage(fd, msg_txt(250));
  1157. return -1;
  1158. }
  1159.  
  1160. clif_displaymessage(fd, "Storage opened.");
  1161.  
  1162. return 0;
  1163. }
  1164.  
  1165.  
  1166. /*==========================================
  1167. *
  1168. *------------------------------------------*/
  1169. ACMD_FUNC(guildstorage)
  1170. {
  1171. nullpo_retr(-1, sd);
  1172.  
  1173. if (!sd->status.guild_id) {
  1174. clif_displaymessage(fd, msg_txt(252));
  1175. return -1;
  1176. }
  1177.  
  1178. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  1179. return -1;
  1180.  
  1181. if (sd->state.storage_flag == 1) {
  1182. clif_displaymessage(fd, msg_txt(250));
  1183. return -1;
  1184. }
  1185.  
  1186. if (sd->state.storage_flag == 2) {
  1187. clif_displaymessage(fd, msg_txt(251));
  1188. return -1;
  1189. }
  1190.  
  1191. storage_guild_storageopen(sd);
  1192. clif_displaymessage(fd, "Guild storage opened.");
  1193. return 0;
  1194. }
  1195.  
  1196. /*==========================================
  1197. *
  1198. *------------------------------------------*/
  1199. ACMD_FUNC(option)
  1200. {
  1201. int param1 = 0, param2 = 0, param3 = 0;
  1202. nullpo_retr(-1, sd);
  1203.  
  1204. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1205. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1206. return -1;
  1207. }
  1208.  
  1209. sd->sc.opt1 = param1;
  1210. sd->sc.opt2 = param2;
  1211. pc_setoption(sd, param3);
  1212.  
  1213. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1214.  
  1215. return 0;
  1216. }
  1217.  
  1218. /*==========================================
  1219. *
  1220. *------------------------------------------*/
  1221. ACMD_FUNC(hide)
  1222. {
  1223. nullpo_retr(-1, sd);
  1224. if (sd->sc.option & OPTION_INVISIBLE) {
  1225. sd->sc.option &= ~OPTION_INVISIBLE;
  1226. if (sd->disguise)
  1227. status_set_viewdata(&sd->bl, sd->disguise);
  1228. else
  1229. status_set_viewdata(&sd->bl, sd->status.class_);
  1230. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1231. } else {
  1232. sd->sc.option |= OPTION_INVISIBLE;
  1233. sd->vd.class_ = INVISIBLE_CLASS;
  1234. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1235. }
  1236. clif_changeoption(&sd->bl);
  1237.  
  1238. return 0;
  1239. }
  1240.  
  1241. /*==========================================
  1242. * Changes a character's class
  1243. *------------------------------------------*/
  1244. ACMD_FUNC(jobchange)
  1245. {
  1246. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1247. int job = 0, upper = 0;
  1248. nullpo_retr(-1, sd);
  1249.  
  1250. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1251. {
  1252. int i, found = 0;
  1253. const struct { char name[16]; int id; } jobs[] = {
  1254. { "novice", 0 },
  1255. { "swordsman", 1 },
  1256. { "mage", 2 },
  1257. { "archer", 3 },
  1258. { "acolyte", 4 },
  1259. { "merchant", 5 },
  1260. { "thief", 6 },
  1261. { "knight", 7 },
  1262. { "priest", 8 },
  1263. { "priestess", 8 },
  1264. { "wizard", 9 },
  1265. { "blacksmith", 10 },
  1266. { "hunter", 11 },
  1267. { "assassin", 12 },
  1268. { "crusader", 14 },
  1269. { "monk", 15 },
  1270. { "sage", 16 },
  1271. { "rogue", 17 },
  1272. { "alchemist", 18 },
  1273. { "bard", 19 },
  1274. { "dancer", 20 },
  1275. { "super novice", 23 },
  1276. { "supernovice", 23 },
  1277. { "gunslinger", 24 },
  1278. { "gunner", 24 },
  1279. { "ninja", 25 },
  1280. { "high novice", 4001 },
  1281. { "swordsman high", 4002 },
  1282. { "mage high", 4003 },
  1283. { "archer high", 4004 },
  1284. { "acolyte high", 4005 },
  1285. { "merchant high", 4006 },
  1286. { "thief high", 4007 },
  1287. { "lord knight", 4008 },
  1288. { "high priest", 4009 },
  1289. { "high priestess", 4009 },
  1290. { "high wizard", 4010 },
  1291. { "whitesmith", 4011 },
  1292. { "sniper", 4012 },
  1293. { "assassin cross", 4013 },
  1294. { "paladin", 4015 },
  1295. { "champion", 4016 },
  1296. { "professor", 4017 },
  1297. { "stalker", 4018 },
  1298. { "creator", 4019 },
  1299. { "clown", 4020 },
  1300. { "gypsy", 4021 },
  1301. { "baby novice", 4023 },
  1302. { "baby swordsman", 4024 },
  1303. { "baby mage", 4025 },
  1304. { "baby archer", 4026 },
  1305. { "baby acolyte", 4027 },
  1306. { "baby merchant", 4028 },
  1307. { "baby thief", 4029 },
  1308. { "baby knight", 4030 },
  1309. { "baby priest", 4031 },
  1310. { "baby priestess", 4031 },
  1311. { "baby wizard", 4032 },
  1312. { "baby blacksmith",4033 },
  1313. { "baby hunter", 4034 },
  1314. { "baby assassin", 4035 },
  1315. { "baby crusader", 4037 },
  1316. { "baby monk", 4038 },
  1317. { "baby sage", 4039 },
  1318. { "baby rogue", 4040 },
  1319. { "baby alchemist", 4041 },
  1320. { "baby bard", 4042 },
  1321. { "baby dancer", 4043 },
  1322. { "super baby", 4045 },
  1323. { "taekwon", 4046 },
  1324. { "taekwon boy", 4046 },
  1325. { "taekwon girl", 4046 },
  1326. { "star gladiator", 4047 },
  1327. { "soul linker", 4049 },
  1328. };
  1329.  
  1330. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1331. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1332. job = jobs[i].id;
  1333. upper = 0;
  1334. found = 1;
  1335. break;
  1336. }
  1337. }
  1338.  
  1339. if (!found) {
  1340. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1341. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 N/A");
  1342. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1343. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1344. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1345. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1346. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1347. clif_displaymessage(fd, " 6 Thief 13 N/A 20 Dancer 27 N/A");
  1348. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 N/A");
  1349. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1350. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1351. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1352. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1353. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1354. clif_displaymessage(fd, "4007 Thief High 4014 N/A 4021 Gypsy");
  1355. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 N/A");
  1356. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1357. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1358. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1359. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1360. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1361. clif_displaymessage(fd, "4029 Baby Thief 4036 N/A 4043 Baby Dancer");
  1362. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1363. return -1;
  1364. }
  1365. }
  1366.  
  1367. if (job == 13 || job == 21 || job == 22 || job == 26 || job == 27
  1368. || job == 4014 || job == 4022 || job == 4036 || job == 4044 || job == 4048
  1369. ) // Deny direct transformation into dummy jobs
  1370. return 0;
  1371.  
  1372. if (pcdb_checkid(job))
  1373. {
  1374. if (pc_jobchange(sd, job, upper) == 0)
  1375. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1376. else {
  1377. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  1378. return -1;
  1379. }
  1380. } else {
  1381. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1382. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 N/A");
  1383. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1384. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1385. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1386. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1387. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1388. clif_displaymessage(fd, " 6 Thief 13 N/A 20 Dancer 27 N/A");
  1389. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 N/A");
  1390. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1391. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1392. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1393. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1394. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1395. clif_displaymessage(fd, "4007 Thief High 4014 N/A 4021 Gypsy");
  1396. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 N/A");
  1397. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1398. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1399. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1400. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1401. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1402. clif_displaymessage(fd, "4029 Baby Thief 4036 N/A 4043 Baby Dancer");
  1403. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1404. return -1;
  1405. }
  1406.  
  1407. return 0;
  1408. }
  1409.  
  1410. /*==========================================
  1411. *
  1412. *------------------------------------------*/
  1413. ACMD_FUNC(die)
  1414. {
  1415. nullpo_retr(-1, sd);
  1416. clif_specialeffect(&sd->bl,450,SELF);
  1417. status_kill(&sd->bl);
  1418. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1419.  
  1420. return 0;
  1421. }
  1422.  
  1423. /*==========================================
  1424. *
  1425. *------------------------------------------*/
  1426. ACMD_FUNC(kill)
  1427. {
  1428. struct map_session_data *pl_sd;
  1429. nullpo_retr(-1, sd);
  1430.  
  1431. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1432.  
  1433. if (!message || !*message) {
  1434. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1435. return -1;
  1436. }
  1437.  
  1438. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1439. {
  1440. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1441. return -1;
  1442. }
  1443.  
  1444. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1445. { // you can kill only lower or same level
  1446. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1447. return -1;
  1448. }
  1449.  
  1450. status_kill(&pl_sd->bl);
  1451. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1452. if (fd != pl_sd->fd)
  1453. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1454.  
  1455. return 0;
  1456. }
  1457.  
  1458. /*==========================================
  1459. *
  1460. *------------------------------------------*/
  1461. ACMD_FUNC(alive)
  1462. {
  1463. nullpo_retr(-1, sd);
  1464. if (!status_revive(&sd->bl, 100, 100))
  1465. {
  1466. clif_displaymessage(fd, "You're not dead.");
  1467. return -1;
  1468. }
  1469. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1470. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1471. return 0;
  1472. }
  1473.  
  1474. /*==========================================
  1475. * +kamic [LuzZza]
  1476. *------------------------------------------*/
  1477. ACMD_FUNC(kami)
  1478. {
  1479. unsigned long color=0;
  1480. nullpo_retr(-1, sd);
  1481.  
  1482. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1483.  
  1484. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1485.  
  1486. if (!message || !*message) {
  1487. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1488. return -1;
  1489. }
  1490.  
  1491. sscanf(message, "%199[^\n]", atcmd_output);
  1492. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1493.  
  1494. } else {
  1495.  
  1496. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1497. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1498. return -1;
  1499. }
  1500.  
  1501. if(color > 0xFFFFFF) {
  1502. clif_displaymessage(fd, "Invalid color.");
  1503. return -1;
  1504. }
  1505.  
  1506. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1507. }
  1508. return 0;
  1509. }
  1510.  
  1511. /*==========================================
  1512. *
  1513. *------------------------------------------*/
  1514. ACMD_FUNC(heal)
  1515. {
  1516. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1517. nullpo_retr(-1, sd);
  1518.  
  1519. sscanf(message, "%d %d", &hp, &sp);
  1520.  
  1521. // some overflow checks
  1522. if( hp == INT_MIN ) hp++;
  1523. if( sp == INT_MIN ) sp++;
  1524.  
  1525. if ( hp == 0 && sp == 0 ) {
  1526. if (!status_percent_heal(&sd->bl, 100, 100))
  1527. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1528. else
  1529. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1530. return 0;
  1531. }
  1532.  
  1533. if ( hp > 0 && sp >= 0 ) {
  1534. if(!status_heal(&sd->bl, hp, sp, 0))
  1535. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1536. else
  1537. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1538. return 0;
  1539. }
  1540.  
  1541. if ( hp < 0 && sp <= 0 ) {
  1542. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1543. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1544. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1545. return 0;
  1546. }
  1547.  
  1548. //Opposing signs.
  1549. if ( hp ) {
  1550. if (hp > 0)
  1551. status_heal(&sd->bl, hp, 0, 0);
  1552. else {
  1553. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1554. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1555. }
  1556. }
  1557.  
  1558. if ( sp ) {
  1559. if (sp > 0)
  1560. status_heal(&sd->bl, 0, sp, 0);
  1561. else
  1562. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1563. }
  1564.  
  1565. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1566. return 0;
  1567. }
  1568.  
  1569. /*==========================================
  1570. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1571. *------------------------------------------*/
  1572. ACMD_FUNC(item)
  1573. {
  1574. char item_name[100];
  1575. int number = 0, item_id, flag;
  1576. struct item item_tmp;
  1577. struct item_data *item_data;
  1578. int get_count, i;
  1579. nullpo_retr(-1, sd);
  1580.  
  1581. memset(item_name, '\0', sizeof(item_name));
  1582.  
  1583. if (!message || !*message || (
  1584. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1585. sscanf(message, "%99s %d", item_name, &number) < 1
  1586. )) {
  1587. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1588. return -1;
  1589. }
  1590.  
  1591. if (number <= 0)
  1592. number = 1;
  1593.  
  1594. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1595. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1596. {
  1597. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1598. return -1;
  1599. }
  1600.  
  1601. item_id = item_data->nameid;
  1602. get_count = number;
  1603. //Check if it's stackable.
  1604. if (!itemdb_isstackable2(item_data))
  1605. get_count = 1;
  1606.  
  1607. for (i = 0; i < number; i += get_count) {
  1608. // if not pet egg
  1609. if (!pet_create_egg(sd, item_id)) {
  1610. memset(&item_tmp, 0, sizeof(item_tmp));
  1611. item_tmp.nameid = item_id;
  1612. item_tmp.identify = 1;
  1613.  
  1614. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1615. clif_additem(sd, 0, 0, flag);
  1616. }
  1617. }
  1618.  
  1619. //Logs (A)dmins items [Lupus]
  1620. log_pick(&sd->bl, LOG_TYPE_COMMAND, item_id, number, NULL);
  1621.  
  1622. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1623. return 0;
  1624. }
  1625.  
  1626. /*==========================================
  1627. *
  1628. *------------------------------------------*/
  1629. ACMD_FUNC(item2)
  1630. {
  1631. struct item item_tmp;
  1632. struct item_data *item_data;
  1633. char item_name[100];
  1634. int item_id, number = 0;
  1635. int identify = 0, refine = 0, attr = 0;
  1636. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1637. int flag;
  1638. int loop, get_count, i;
  1639. nullpo_retr(-1, sd);
  1640.  
  1641. memset(item_name, '\0', sizeof(item_name));
  1642.  
  1643. if (!message || !*message || (
  1644. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1645. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1646. )) {
  1647. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1648. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1649. return -1;
  1650. }
  1651.  
  1652. if (number <= 0)
  1653. number = 1;
  1654.  
  1655. item_id = 0;
  1656. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1657. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1658. item_id = item_data->nameid;
  1659.  
  1660. if (item_id > 500) {
  1661. loop = 1;
  1662. get_count = number;
  1663. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1664. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1665. loop = number;
  1666. get_count = 1;
  1667. if (item_data->type == IT_PETEGG) {
  1668. identify = 1;
  1669. refine = 0;
  1670. }
  1671. if (item_data->type == IT_PETARMOR)
  1672. refine = 0;
  1673. if (refine > MAX_REFINE)
  1674. refine = MAX_REFINE;
  1675. } else {
  1676. identify = 1;
  1677. refine = attr = 0;
  1678. }
  1679. for (i = 0; i < loop; i++) {
  1680. memset(&item_tmp, 0, sizeof(item_tmp));
  1681. item_tmp.nameid = item_id;
  1682. item_tmp.identify = identify;
  1683. item_tmp.refine = refine;
  1684. item_tmp.attribute = attr;
  1685. item_tmp.card[0] = c1;
  1686. item_tmp.card[1] = c2;
  1687. item_tmp.card[2] = c3;
  1688. item_tmp.card[3] = c4;
  1689. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1690. clif_additem(sd, 0, 0, flag);
  1691. }
  1692.  
  1693. //Logs (A)dmins items [Lupus]
  1694. log_pick(&sd->bl, LOG_TYPE_COMMAND, item_tmp.nameid, number, &item_tmp);
  1695.  
  1696. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1697. } else {
  1698. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1699. return -1;
  1700. }
  1701.  
  1702. return 0;
  1703. }
  1704.  
  1705. /*==========================================
  1706. *
  1707. *------------------------------------------*/
  1708. ACMD_FUNC(itemreset)
  1709. {
  1710. int i;
  1711. nullpo_retr(-1, sd);
  1712.  
  1713. for (i = 0; i < MAX_INVENTORY; i++) {
  1714. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1715.  
  1716. //Logs (A)dmins items [Lupus]
  1717. log_pick(&sd->bl, LOG_TYPE_COMMAND, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  1718.  
  1719. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0);
  1720. }
  1721. }
  1722. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1723.  
  1724. return 0;
  1725. }
  1726.  
  1727. /*==========================================
  1728. * Atcommand @lvlup
  1729. *------------------------------------------*/
  1730. ACMD_FUNC(baselevelup)
  1731. {
  1732. int level=0, i=0, status_point=0;
  1733. nullpo_retr(-1, sd);
  1734. level = atoi(message);
  1735.  
  1736. if (!message || !*message || !level) {
  1737. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1738. return -1;
  1739. }
  1740.  
  1741. if (level > 0) {
  1742. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1743. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1744. return -1;
  1745. } // End Addition
  1746. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1747. level = pc_maxbaselv(sd) - sd->status.base_level;
  1748. for (i = 0; i < level; i++)
  1749. status_point += pc_gets_status_point(sd->status.base_level + i);
  1750.  
  1751. sd->status.status_point += status_point;
  1752. sd->status.base_level += (unsigned int)level;
  1753. status_percent_heal(&sd->bl, 100, 100);
  1754. clif_misceffect(&sd->bl, 0);
  1755. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1756. } else {
  1757. if (sd->status.base_level == 1) {
  1758. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1759. return -1;
  1760. }
  1761. level*=-1;
  1762. if ((unsigned int)level >= sd->status.base_level)
  1763. level = sd->status.base_level-1;
  1764. for (i = 0; i > -level; i--)
  1765. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1766. if (sd->status.status_point < status_point)
  1767. pc_resetstate(sd);
  1768. if (sd->status.status_point < status_point)
  1769. sd->status.status_point = 0;
  1770. else
  1771. sd->status.status_point -= status_point;
  1772. sd->status.base_level -= (unsigned int)level;
  1773. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1774. }
  1775. sd->status.base_exp = 0;
  1776. pc_onstatuschanged(sd, SP_STATUSPOINT);
  1777. pc_onstatuschanged(sd, SP_BASELEVEL);
  1778. pc_onstatuschanged(sd, SP_BASEEXP);
  1779. pc_onstatuschanged(sd, SP_NEXTBASEEXP);
  1780. status_calc_pc(sd, 0);
  1781. if(sd->status.party_id)
  1782. party_send_levelup(sd);
  1783. return 0;
  1784. }
  1785.  
  1786. /*==========================================
  1787. *
  1788. *------------------------------------------*/
  1789. ACMD_FUNC(joblevelup)
  1790. {
  1791. int level=0;
  1792. nullpo_retr(-1, sd);
  1793.  
  1794. level = atoi(message);
  1795.  
  1796. if (!message || !*message || !level) {
  1797. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1798. return -1;
  1799. }
  1800. if (level > 0) {
  1801. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1802. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1803. return -1;
  1804. }
  1805. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1806. level = pc_maxjoblv(sd) - sd->status.job_level;
  1807. sd->status.job_level += (unsigned int)level;
  1808. sd->status.skill_point += level;
  1809. clif_misceffect(&sd->bl, 1);
  1810. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1811. } else {
  1812. if (sd->status.job_level == 1) {
  1813. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1814. return -1;
  1815. }
  1816. level *=-1;
  1817. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1818. level = sd->status.job_level-1;
  1819. sd->status.job_level -= (unsigned int)level;
  1820. if (sd->status.skill_point < level)
  1821. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1822. if (sd->status.skill_point < level)
  1823. sd->status.skill_point = 0;
  1824. else
  1825. sd->status.skill_point -= level;
  1826. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1827. }
  1828. sd->status.job_exp = 0;
  1829. pc_onstatuschanged(sd, SP_JOBLEVEL);
  1830. pc_onstatuschanged(sd, SP_JOBEXP);
  1831. pc_onstatuschanged(sd, SP_NEXTJOBEXP);
  1832. pc_onstatuschanged(sd, SP_SKILLPOINT);
  1833. status_calc_pc(sd, 0);
  1834.  
  1835. return 0;
  1836. }
  1837.  
  1838. /*==========================================
  1839. * @help
  1840. *------------------------------------------*/
  1841. ACMD_FUNC(help)
  1842. {
  1843. char buf[2048], w1[2048], w2[2048];
  1844. int i, gm_level;
  1845. FILE* fp;
  1846. nullpo_retr(-1, sd);
  1847.  
  1848. memset(buf, '\0', sizeof(buf));
  1849.  
  1850. if ((fp = fopen(help_txt, "r")) != NULL) {
  1851. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1852. gm_level = pc_isGM(sd);
  1853. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1854. if (buf[0] == '/' && buf[1] == '/')
  1855. continue;
  1856. for (i = 0; buf[i] != '\0'; i++) {
  1857. if (buf[i] == '\r' || buf[i] == '\n') {
  1858. buf[i] = '\0';
  1859. break;
  1860. }
  1861. }
  1862. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1863. clif_displaymessage(fd, buf);
  1864. else if (gm_level >= atoi(w1))
  1865. clif_displaymessage(fd, w2);
  1866. }
  1867. fclose(fp);
  1868. } else {
  1869. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1870. return -1;
  1871. }
  1872.  
  1873. return 0;
  1874. }
  1875.  
  1876. /*==========================================
  1877. * @help2 - Char commands [Kayla]
  1878. *------------------------------------------*/
  1879. ACMD_FUNC(help2)
  1880. {
  1881. char buf[2048], w1[2048], w2[2048];
  1882. int i, gm_level;
  1883. FILE* fp;
  1884. nullpo_retr(-1, sd);
  1885.  
  1886. memset(buf, '\0', sizeof(buf));
  1887.  
  1888. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1889. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1890. gm_level = pc_isGM(sd);
  1891. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1892. if (buf[0] == '/' && buf[1] == '/')
  1893. continue;
  1894. for (i = 0; buf[i] != '\0'; i++) {
  1895. if (buf[i] == '\r' || buf[i] == '\n') {
  1896. buf[i] = '\0';
  1897. break;
  1898. }
  1899. }
  1900. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1901. clif_displaymessage(fd, buf);
  1902. else if (gm_level >= atoi(w1))
  1903. clif_displaymessage(fd, w2);
  1904. }
  1905. fclose(fp);
  1906. } else {
  1907. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1908. return -1;
  1909. }
  1910.  
  1911. return 0;
  1912. }
  1913.  
  1914.  
  1915. // helper function, used in foreach calls to stop auto-attack timers
  1916. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1917. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1918. {
  1919. struct unit_data *ud = unit_bl2ud(bl);
  1920. int id = va_arg(ap, int);
  1921. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1922. {
  1923. unit_stop_attack(bl);
  1924. return 1;
  1925. }
  1926. return 0;
  1927. }
  1928. /*==========================================
  1929. *
  1930. *------------------------------------------*/
  1931. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1932. {
  1933. TBL_PC* sd = (TBL_PC*)bl;
  1934. clif_pvpset(sd, 0, 0, 2);
  1935. if (sd->pvp_timer != INVALID_TIMER) {
  1936. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1937. sd->pvp_timer = INVALID_TIMER;
  1938. }
  1939. return 0;
  1940. }
  1941.  
  1942. ACMD_FUNC(pvpoff)
  1943. {
  1944. nullpo_retr(-1, sd);
  1945.  
  1946. if (!map[sd->bl.m].flag.pvp) {
  1947. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1948. return -1;
  1949. }
  1950.  
  1951. map[sd->bl.m].flag.pvp = 0;
  1952.  
  1953. if (!battle_config.pk_mode)
  1954. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1955. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1956. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1957. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1958. return 0;
  1959. }
  1960.  
  1961. /*==========================================
  1962. *
  1963. *------------------------------------------*/
  1964. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1965. {
  1966. TBL_PC* sd = (TBL_PC*)bl;
  1967. if (sd->pvp_timer == INVALID_TIMER) {
  1968. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1969. sd->pvp_rank = 0;
  1970. sd->pvp_lastusers = 0;
  1971. sd->pvp_point = 5;
  1972. sd->pvp_won = 0;
  1973. sd->pvp_lost = 0;
  1974. }
  1975. return 0;
  1976. }
  1977.  
  1978. ACMD_FUNC(pvpon)
  1979. {
  1980. nullpo_retr(-1, sd);
  1981.  
  1982. if (map[sd->bl.m].flag.pvp) {
  1983. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1984. return -1;
  1985. }
  1986.  
  1987. map[sd->bl.m].flag.pvp = 1;
  1988.  
  1989. if (!battle_config.pk_mode)
  1990. {// display pvp circle and rank
  1991. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1992. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1993. }
  1994.  
  1995. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1996.  
  1997. return 0;
  1998. }
  1999.  
  2000. /*==========================================
  2001. *
  2002. *------------------------------------------*/
  2003. ACMD_FUNC(gvgoff)
  2004. {
  2005. nullpo_retr(-1, sd);
  2006.  
  2007. if (!map[sd->bl.m].flag.gvg) {
  2008. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  2009. return -1;
  2010. }
  2011.  
  2012. map[sd->bl.m].flag.gvg = 0;
  2013. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  2014. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  2015. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  2016.  
  2017. return 0;
  2018. }
  2019.  
  2020. /*==========================================
  2021. *
  2022. *------------------------------------------*/
  2023. ACMD_FUNC(gvgon)
  2024. {
  2025. nullpo_retr(-1, sd);
  2026.  
  2027. if (map[sd->bl.m].flag.gvg) {
  2028. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  2029. return -1;
  2030. }
  2031.  
  2032. map[sd->bl.m].flag.gvg = 1;
  2033. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  2034. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  2035.  
  2036. return 0;
  2037. }
  2038.  
  2039. /*==========================================
  2040. *
  2041. *------------------------------------------*/
  2042. ACMD_FUNC(model)
  2043. {
  2044. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2045. nullpo_retr(-1, sd);
  2046.  
  2047. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2048.  
  2049. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2050. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2051. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2052. clif_displaymessage(fd, atcmd_output);
  2053. return -1;
  2054. }
  2055.  
  2056. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2057. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2058. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2059. pc_changelook(sd, LOOK_HAIR, hair_style);
  2060. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2061. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2062. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2063. } else {
  2064. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2065. return -1;
  2066. }
  2067.  
  2068. return 0;
  2069. }
  2070.  
  2071. /*==========================================
  2072. * @dye && @ccolor
  2073. *------------------------------------------*/
  2074. ACMD_FUNC(dye)
  2075. {
  2076. int cloth_color = 0;
  2077. nullpo_retr(-1, sd);
  2078.  
  2079. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2080.  
  2081. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2082. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2083. clif_displaymessage(fd, atcmd_output);
  2084. return -1;
  2085. }
  2086.  
  2087. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2088. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2089. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2090. } else {
  2091. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2092. return -1;
  2093. }
  2094.  
  2095. return 0;
  2096. }
  2097.  
  2098. /*==========================================
  2099. * @hairstyle && @hstyle
  2100. *------------------------------------------*/
  2101. ACMD_FUNC(hair_style)
  2102. {
  2103. int hair_style = 0;
  2104. nullpo_retr(-1, sd);
  2105.  
  2106. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2107.  
  2108. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2109. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2110. clif_displaymessage(fd, atcmd_output);
  2111. return -1;
  2112. }
  2113.  
  2114. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2115. pc_changelook(sd, LOOK_HAIR, hair_style);
  2116. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2117. } else {
  2118. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2119. return -1;
  2120. }
  2121.  
  2122. return 0;
  2123. }
  2124.  
  2125. /*==========================================
  2126. * @haircolor && @hcolor
  2127. *------------------------------------------*/
  2128. ACMD_FUNC(hair_color)
  2129. {
  2130. int hair_color = 0;
  2131. nullpo_retr(-1, sd);
  2132.  
  2133. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2134.  
  2135. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2136. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2137. clif_displaymessage(fd, atcmd_output);
  2138. return -1;
  2139. }
  2140.  
  2141. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2142. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2143. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2144. } else {
  2145. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2146. return -1;
  2147. }
  2148.  
  2149. return 0;
  2150. }
  2151.  
  2152.  
  2153. /*==========================================
  2154. * @go [location_number or location_name] - Updated by Harbin
  2155. *------------------------------------------*/
  2156. ACMD_FUNC(go)
  2157. {
  2158. int i;
  2159. int town;
  2160. int map_id;
  2161. char input[MAP_NAME_LENGTH];
  2162. size_t inputlen;
  2163. const char* mapname = NULL;
  2164.  
  2165. static const struct {
  2166. const char*const mapname;
  2167. int x, y;
  2168. const char*const displayname;
  2169. } data[] = {
  2170. { MAP_PRONTERA, 156, 191, "Prontera" }, // 0
  2171. { MAP_MORROC, 156, 93, "Morroc" }, // 1
  2172. { MAP_GEFFEN, 119, 59, "Geffen" }, // 2
  2173. { MAP_PAYON, 162, 233, "Payon" }, // 3
  2174. { MAP_ALBERTA, 192, 147, "Alberta" }, // 4
  2175. { MAP_IZLUDE, 128, 145, "Izlude" }, // 5
  2176. { MAP_ALDEBARAN, 140, 131, "Al De Baran" }, // 6
  2177. { MAP_LUTIE, 147, 134, "Lutie" }, // 7
  2178. { MAP_COMODO, 209, 143, "Comodo" }, // 8
  2179. { MAP_YUNO, 157, 51, "Yuno" }, // 9
  2180. { MAP_AMATSU, 198, 84, "Amatsu" }, // 10
  2181. { MAP_GONRYUN, 160, 120, "Gonryun" }, // 11
  2182. { MAP_UMBALA, 89, 157, "Umbala" }, // 12
  2183. { MAP_NIFLHEIM, 21, 153, "Niflheim" }, // 13
  2184. { MAP_LOUYANG, 217, 40, "Louyang" }, // 14
  2185. { MAP_NOVICE, 53, 111, "Novice Grounds" }, // 15
  2186. { MAP_JAIL, 23, 61, "Prison" }, // 16
  2187. { MAP_JAWAII, 249, 127, "Jawaii" }, // 17
  2188. { MAP_AYOTHAYA, 151, 117, "Ayothaya" }, // 18
  2189. { MAP_EINBROCH, 64, 200, "Einbroch" }, // 19
  2190. { MAP_LIGHTHALZEN, 158, 92, "Lighthalzen" }, // 20
  2191. { MAP_EINBECH, 70, 95, "Einbech" }, // 21
  2192. { MAP_HUGEL, 96, 145, "Hugel" }, // 22
  2193. { MAP_RACHEL, 130, 110, "Rachel" }, // 23
  2194. { MAP_VEINS, 216, 123, "Veins" }, // 24
  2195. { MAP_MOSCOVIA, 223, 184, "Moscovia" }, // 25
  2196. };
  2197.  
  2198. static const struct {
  2199. const char*const mapname; // mapname that must exist in the previous array
  2200. const char*const input; // lowercase name to match against the input
  2201. } names[] = {
  2202. { MAP_PRONTERA, "prontera" },
  2203. { MAP_MORROC, "morocc" },
  2204. { MAP_GEFFEN, "geffen" },
  2205. { MAP_PAYON, "payon" },
  2206. { MAP_PAYON, "paion" },
  2207. { MAP_ALBERTA, "alberta", },
  2208. { MAP_IZLUDE, "izlude" },
  2209. { MAP_IZLUDE, "islude" },
  2210. { MAP_ALDEBARAN, "aldebaran" },
  2211. { MAP_ALDEBARAN, "al" },
  2212. { MAP_LUTIE, "lutie" },
  2213. { MAP_LUTIE, "christmas" },
  2214. { MAP_LUTIE, "xmas" },
  2215. { MAP_LUTIE, "x-mas" },
  2216. { MAP_COMODO, "comodo" },
  2217. { MAP_YUNO , "yuno" },
  2218. { MAP_AMATSU, "amatsu" },
  2219. { MAP_GONRYUN, "gonryun" },
  2220. { MAP_UMBALA, "umbala" },
  2221. { MAP_NIFLHEIM, "niflheim" },
  2222. { MAP_LOUYANG, "louyang" },
  2223. { MAP_NOVICE, "new_1-1" },
  2224. { MAP_NOVICE, "startpoint" },
  2225. { MAP_NOVICE, "begining" },
  2226. { MAP_JAIL, "sec_pri" },
  2227. { MAP_JAIL, "prison" },
  2228. { MAP_JAIL, "jails" },
  2229. { MAP_JAWAII, "jawaii" },
  2230. { MAP_JAWAII, "jawai" },
  2231. { MAP_AYOTHAYA, "ayothaya" },
  2232. { MAP_AYOTHAYA, "ayotaya" },
  2233. { MAP_EINBROCH, "einbroch" },
  2234. { MAP_EINBROCH, "ainbroch" },
  2235. { MAP_LIGHTHALZEN, "lighthalzen" },
  2236. { MAP_EINBECH, "einbech" },
  2237. { MAP_HUGEL, "hugel" },
  2238. { MAP_RACHEL, "rachel" },
  2239. { MAP_VEINS, "veins" },
  2240. { MAP_MOSCOVIA, "moscovia" },
  2241. };
  2242.  
  2243. nullpo_retr(-1, sd);
  2244.  
  2245. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) )
  2246. {
  2247. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2248. return 0;
  2249. }
  2250.  
  2251. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2252. memset(input, '\0', sizeof(input));
  2253. inputlen = 0;
  2254.  
  2255. if( message != NULL )
  2256. {
  2257. sscanf(message, "%11s", input); // FIXME doesn't allow names with spaces
  2258. input[MAP_NAME_LENGTH-1] = '\0';
  2259. inputlen = strlen(input);
  2260. for( i = 0; i < inputlen; ++i )
  2261. input[i] = TOLOWER(input[i]); // lowercase
  2262. }
  2263.  
  2264. town = atoi(input); // 0 if not a number
  2265.  
  2266. if( inputlen == 0 || // no input
  2267. town < 0 || town >= ARRAYLENGTH(data) ) // invalid number
  2268. {
  2269. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  2270. clif_displaymessage(fd, msg_txt(82)); // Please provide a name or number from the list provided:
  2271. for( i = 0; i+2 < ARRAYLENGTH(data); i += 3 )
  2272. { // show every 3 maps
  2273. sprintf(atcmd_output, " %2d=%-15s %2d=%-15s %2d=%-15s", i, data[i].displayname, i+1, data[i+1].displayname, i+2, data[i+2].displayname);
  2274. clif_displaymessage(fd, atcmd_output);
  2275. }
  2276.  
  2277. if( i+1 < ARRAYLENGTH(data) )
  2278. { // show last 2 maps
  2279. sprintf(atcmd_output, " %2d=%-15s %2d=%-15s", i, data[i].displayname, i+1, data[i+1].displayname);
  2280. clif_displaymessage(fd, atcmd_output);
  2281. }
  2282. else if( i < ARRAYLENGTH(data) )
  2283. { // show last map
  2284. sprintf(atcmd_output, " %2d=%-15s", i, data[i].displayname);
  2285. clif_displaymessage(fd, atcmd_output);
  2286. }
  2287.  
  2288. return -1;
  2289. }
  2290.  
  2291. if( !ISDIGIT(input[0]) )
  2292. { // input is a name
  2293. int startswith_count = 0;
  2294. int startswith_arr[ARRAYLENGTH(names)];
  2295. memset(&startswith_arr, 0, sizeof(startswith_arr));
  2296.  
  2297. // try to match the input
  2298. for( i = 0; i < ARRAYLENGTH(names); ++i )
  2299. {
  2300. if( strncmp(names[i].input, input, inputlen) != 0 )
  2301. continue; // doesn't start with input
  2302.  
  2303. if( strcmp(input, names[i].input) == 0 )
  2304. { // exact match
  2305. mapname = names[i].mapname;
  2306. break;
  2307. }
  2308.  
  2309. startswith_arr[startswith_count] = i;
  2310. ++startswith_count;
  2311. }
  2312.  
  2313. for( i = 0; i < startswith_count; ++i )
  2314. { // show matches
  2315. sprintf(atcmd_output, "Found match: %s", names[startswith_arr[i]].input);
  2316. clif_displaymessage(fd, atcmd_output);
  2317. }
  2318.  
  2319. if( mapname == NULL )
  2320. {
  2321. if( startswith_count != 1 )
  2322. { // not a conclusive match
  2323. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2324. return -1;
  2325. }
  2326.  
  2327. mapname = names[startswith_arr[0]].mapname;
  2328. }
  2329.  
  2330. ARR_FIND(0, ARRAYLENGTH(data), town, strcmp(mapname, data[town].mapname) == 0);
  2331. if( town == ARRAYLENGTH(data) )
  2332. {
  2333. ShowError("atcommand_go: failed to get town (mapname='%s')\n", mapname);
  2334. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2335. return -1;
  2336. }
  2337. }
  2338.  
  2339. map_id = map_mapname2mapid(data[town].mapname);
  2340. if( map_id >= 0 && map[map_id].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd) )
  2341. {
  2342. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  2343. return -1;
  2344. }
  2345.  
  2346. if( sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd) )
  2347. {
  2348. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  2349. return -1;
  2350. }
  2351.  
  2352. if( pc_setpos(sd, mapindex_name2id(data[town].mapname), data[town].x, data[town].y, CLR_TELEPORT) != 0 )
  2353. {
  2354. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2355. return -1;
  2356. }
  2357.  
  2358. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2359. return 0;
  2360. }
  2361.  
  2362.  
  2363. /*==========================================
  2364. *
  2365. *------------------------------------------*/
  2366. ACMD_FUNC(monster)
  2367. {
  2368. char name[NAME_LENGTH];
  2369. char monster[NAME_LENGTH];
  2370. int mob_id;
  2371. int number = 0;
  2372. int count;
  2373. int i, k, range;
  2374. short mx, my;
  2375. nullpo_retr(-1, sd);
  2376.  
  2377. memset(name, '\0', sizeof(name));
  2378. memset(monster, '\0', sizeof(monster));
  2379. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2380.  
  2381. if (!message || !*message) {
  2382. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  2383. return -1;
  2384. }
  2385. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2386. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2387. //All data can be left as it is.
  2388. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2389. //Here, it is possible name was not given and we are using monster for it.
  2390. if (count < 3) //Blank mob's name.
  2391. name[0] = '\0';
  2392. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2393. //All data can be left as it is.
  2394. } else if (sscanf(message, "%23s", monster) > 0) {
  2395. //As before, name may be already filled.
  2396. name[0] = '\0';
  2397. } else {
  2398. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2399. return -1;
  2400. }
  2401.  
  2402. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2403. mob_id = mobdb_checkid(atoi(monster));
  2404.  
  2405. if (mob_id == 0) {
  2406. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2407. return -1;
  2408. }
  2409.  
  2410. if (mob_id == MOBID_EMPERIUM) {
  2411. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  2412. return -1;
  2413. }
  2414.  
  2415. if (number <= 0)
  2416. number = 1;
  2417.  
  2418. if( !name[0] )
  2419. strcpy(name, "--ja--");
  2420.  
  2421. // 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
  2422. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2423. number = battle_config.atc_spawn_quantity_limit;
  2424.  
  2425. if (battle_config.etc_log)
  2426. 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);
  2427.  
  2428. count = 0;
  2429. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2430. for (i = 0; i < number; i++) {
  2431. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2432. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
  2433. count += (k != 0) ? 1 : 0;
  2434. }
  2435.  
  2436. if (count != 0)
  2437. if (number == count)
  2438. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2439. else {
  2440. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2441. clif_displaymessage(fd, atcmd_output);
  2442. }
  2443. else {
  2444. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2445. return -1;
  2446. }
  2447.  
  2448. return 0;
  2449. }
  2450.  
  2451. // small monster spawning [Valaris]
  2452. ACMD_FUNC(monstersmall)
  2453. {
  2454. char name[NAME_LENGTH] = "";
  2455. char monster[NAME_LENGTH] = "";
  2456. int mob_id = 0;
  2457. int number = 0;
  2458. int x = 0;
  2459. int y = 0;
  2460. int count;
  2461. int i;
  2462.  
  2463. nullpo_retr(-1, sd);
  2464.  
  2465. if (!message || !*message) {
  2466. clif_displaymessage(fd, "Give a monster name/id please.");
  2467. return -1;
  2468. }
  2469.  
  2470. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2471. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2472. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2473. clif_displaymessage(fd, "Give a monster name/id please.");
  2474. return -1;
  2475. }
  2476.  
  2477. // If monster identifier/name argument is a name
  2478. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2479. mob_id = atoi(monster);
  2480.  
  2481. if (mob_id == 0) {
  2482. clif_displaymessage(fd, msg_txt(40));
  2483. return -1;
  2484. }
  2485.  
  2486. if (mob_id == MOBID_EMPERIUM) {
  2487. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2488. return -1;
  2489. }
  2490.  
  2491. if (mobdb_checkid(mob_id) == 0) {
  2492. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2493. return -1;
  2494. }
  2495.  
  2496. if (number <= 0)
  2497. number = 1;
  2498.  
  2499. if( !name[0] )
  2500. strcpy(name, "--ja--");
  2501.  
  2502. // 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
  2503. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2504. number = battle_config.atc_spawn_quantity_limit;
  2505.  
  2506. count = 0;
  2507. for (i = 0; i < number; i++) {
  2508. int mx, my;
  2509. if (x <= 0)
  2510. mx = sd->bl.x + (rand() % 11 - 5);
  2511. else
  2512. mx = x;
  2513. if (y <= 0)
  2514. my = sd->bl.y + (rand() % 11 - 5);
  2515. else
  2516. my = y;
  2517. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2518. }
  2519.  
  2520. if (count != 0)
  2521. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2522. else
  2523. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2524.  
  2525. return 0;
  2526. }
  2527. // big monster spawning [Valaris]
  2528. ACMD_FUNC(monsterbig)
  2529. {
  2530. char name[NAME_LENGTH] = "";
  2531. char monster[NAME_LENGTH] = "";
  2532. int mob_id = 0;
  2533. int number = 0;
  2534. int x = 0;
  2535. int y = 0;
  2536. int count;
  2537. int i;
  2538.  
  2539. nullpo_retr(-1, sd);
  2540.  
  2541. if (!message || !*message) {
  2542. clif_displaymessage(fd, "Give a monster name/id please.");
  2543. return -1;
  2544. }
  2545.  
  2546. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2547. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2548. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2549. clif_displaymessage(fd, "Give a monster name/id please.");
  2550. return -1;
  2551. }
  2552.  
  2553. // If monster identifier/name argument is a name
  2554. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2555. mob_id = atoi(monster);
  2556.  
  2557. if (mob_id == 0) {
  2558. clif_displaymessage(fd, msg_txt(40));
  2559. return -1;
  2560. }
  2561.  
  2562. if (mob_id == MOBID_EMPERIUM) {
  2563. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2564. return -1;
  2565. }
  2566.  
  2567. if (mobdb_checkid(mob_id) == 0) {
  2568. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2569. return -1;
  2570. }
  2571.  
  2572. if (number <= 0)
  2573. number = 1;
  2574.  
  2575. if( !name[0] )
  2576. strcpy(name, "--ja--");
  2577.  
  2578. // 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
  2579. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2580. number = battle_config.atc_spawn_quantity_limit;
  2581.  
  2582. count = 0;
  2583. for (i = 0; i < number; i++) {
  2584. int mx, my;
  2585. if (x <= 0)
  2586. mx = sd->bl.x + (rand() % 11 - 5);
  2587. else
  2588. mx = x;
  2589. if (y <= 0)
  2590. my = sd->bl.y + (rand() % 11 - 5);
  2591. else
  2592. my = y;
  2593. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2594. }
  2595.  
  2596. if (count != 0)
  2597. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2598. else
  2599. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2600.  
  2601. return 0;
  2602. }
  2603.  
  2604. /*==========================================
  2605. *
  2606. *------------------------------------------*/
  2607. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2608. {
  2609. struct mob_data *md;
  2610. int flag;
  2611.  
  2612. nullpo_ret(md=(struct mob_data *)bl);
  2613. flag = va_arg(ap, int);
  2614.  
  2615. if (md->guardian_data)
  2616. return 0; //Do not touch WoE mobs!
  2617.  
  2618. if (flag)
  2619. status_zap(bl,md->status.hp, 0);
  2620. else
  2621. status_kill(bl);
  2622. return 1;
  2623. }
  2624.  
  2625. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2626. {
  2627. int map_id;
  2628. char map_name[MAP_NAME_LENGTH_EXT];
  2629.  
  2630. if (!sd) return;
  2631.  
  2632. memset(map_name, '\0', sizeof(map_name));
  2633.  
  2634. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2635. map_id = sd->bl.m;
  2636. else {
  2637. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2638. map_id = sd->bl.m;
  2639. }
  2640.  
  2641. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2642.  
  2643. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2644.  
  2645. return;
  2646. }
  2647.  
  2648. ACMD_FUNC(killmonster)
  2649. {
  2650. atcommand_killmonster_sub(fd, sd, message, 1);
  2651. return 0;
  2652. }
  2653.  
  2654. /*==========================================
  2655. *
  2656. *------------------------------------------*/
  2657. ACMD_FUNC(killmonster2)
  2658. {
  2659. atcommand_killmonster_sub(fd, sd, message, 0);
  2660. return 0;
  2661. }
  2662.  
  2663. /*==========================================
  2664. *
  2665. *------------------------------------------*/
  2666. ACMD_FUNC(refine)
  2667. {
  2668. int i,j, position = 0, refine = 0, current_position, final_refine;
  2669. int count;
  2670. nullpo_retr(-1, sd);
  2671.  
  2672. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2673.  
  2674. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2675. clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
  2676. sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
  2677. clif_displaymessage(fd, atcmd_output);
  2678. sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
  2679. clif_displaymessage(fd, atcmd_output);
  2680. sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
  2681. clif_displaymessage(fd, atcmd_output);
  2682. sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
  2683. clif_displaymessage(fd, atcmd_output);
  2684. sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
  2685. clif_displaymessage(fd, atcmd_output);
  2686. sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
  2687. clif_displaymessage(fd, atcmd_output);
  2688. sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
  2689. clif_displaymessage(fd, atcmd_output);
  2690. sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
  2691. clif_displaymessage(fd, atcmd_output);
  2692. sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
  2693. clif_displaymessage(fd, atcmd_output);
  2694. sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
  2695. clif_displaymessage(fd, atcmd_output);
  2696. return -1;
  2697. }
  2698.  
  2699. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2700.  
  2701. count = 0;
  2702. for (j = 0; j < EQI_MAX-1; j++) {
  2703. if ((i = sd->equip_index[j]) < 0)
  2704. continue;
  2705. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2706. continue;
  2707. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2708. continue;
  2709. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2710. continue;
  2711.  
  2712. if(position && !(sd->status.inventory[i].equip & position))
  2713. continue;
  2714.  
  2715. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2716. if (sd->status.inventory[i].refine != final_refine) {
  2717. sd->status.inventory[i].refine = final_refine;
  2718. current_position = sd->status.inventory[i].equip;
  2719. pc_unequipitem(sd, i, 3);
  2720. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2721. clif_delitem(sd, i, 1, 3);
  2722. clif_additem(sd, i, 1, 0);
  2723. pc_equipitem(sd, i, current_position);
  2724. clif_misceffect(&sd->bl, 3);
  2725. count++;
  2726. }
  2727. }
  2728.  
  2729. if (count == 0)
  2730. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  2731. else if (count == 1)
  2732. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  2733. else {
  2734. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  2735. clif_displaymessage(fd, atcmd_output);
  2736. }
  2737.  
  2738. return 0;
  2739. }
  2740.  
  2741. /*==========================================
  2742. *
  2743. *------------------------------------------*/
  2744. ACMD_FUNC(produce)
  2745. {
  2746. char item_name[100];
  2747. int item_id, attribute = 0, star = 0;
  2748. int flag = 0;
  2749. struct item_data *item_data;
  2750. struct item tmp_item;
  2751. nullpo_retr(-1, sd);
  2752.  
  2753. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2754. memset(item_name, '\0', sizeof(item_name));
  2755.  
  2756. if (!message || !*message || (
  2757. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2758. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2759. )) {
  2760. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2761. return -1;
  2762. }
  2763.  
  2764. item_id = 0;
  2765. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2766. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2767. {
  2768. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2769. return -1;
  2770. }
  2771. item_id = item_data->nameid;
  2772. if (itemdb_isequip2(item_data)) {
  2773. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2774. attribute = ATTRIBUTE_NORMAL;
  2775. if (star < MIN_STAR || star > MAX_STAR)
  2776. star = 0;
  2777. memset(&tmp_item, 0, sizeof tmp_item);
  2778. tmp_item.nameid = item_id;
  2779. tmp_item.amount = 1;
  2780. tmp_item.identify = 1;
  2781. tmp_item.card[0] = CARD0_FORGE;
  2782. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2783. ((star*5) << 8) + attribute:0;
  2784. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2785. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2786. clif_produceeffect(sd, 0, item_id);
  2787. clif_misceffect(&sd->bl, 3);
  2788.  
  2789. //Logs (A)dmins items [Lupus]
  2790. log_pick(&sd->bl, LOG_TYPE_COMMAND, tmp_item.nameid, 1, &tmp_item);
  2791.  
  2792. if ((flag = pc_additem(sd, &tmp_item, 1)))
  2793. clif_additem(sd, 0, 0, flag);
  2794. } else {
  2795. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2796. clif_displaymessage(fd, atcmd_output);
  2797. return -1;
  2798. }
  2799.  
  2800. return 0;
  2801. }
  2802.  
  2803. /*==========================================
  2804. *
  2805. *------------------------------------------*/
  2806. ACMD_FUNC(memo)
  2807. {
  2808. int position = 0;
  2809. nullpo_retr(-1, sd);
  2810.  
  2811. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2812.  
  2813. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2814. {
  2815. int i;
  2816. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2817. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2818. {
  2819. if( sd->status.memo_point[i].map )
  2820. sprintf(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);
  2821. else
  2822. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2823. clif_displaymessage(sd->fd, atcmd_output);
  2824. }
  2825. return 0;
  2826. }
  2827.  
  2828. if( position < 0 || position >= MAX_MEMOPOINTS )
  2829. {
  2830. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2831. clif_displaymessage(fd, atcmd_output);
  2832. return -1;
  2833. }
  2834.  
  2835. pc_memo(sd, position);
  2836. return 0;
  2837. }
  2838.  
  2839. /*==========================================
  2840. *
  2841. *------------------------------------------*/
  2842. ACMD_FUNC(gat)
  2843. {
  2844. int y;
  2845. nullpo_retr(-1, sd);
  2846.  
  2847. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2848.  
  2849. for (y = 2; y >= -2; y--) {
  2850. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2851. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2852. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2853. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2854. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2855. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2856. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2857.  
  2858. clif_displaymessage(fd, atcmd_output);
  2859. }
  2860.  
  2861. return 0;
  2862. }
  2863.  
  2864. /*==========================================
  2865. *
  2866. *------------------------------------------*/
  2867. ACMD_FUNC(displaystatus)
  2868. {
  2869. int i, type, flag, tick;
  2870. nullpo_retr(-1, sd);
  2871.  
  2872. if (!message || !*message || (i = sscanf(message, "%d %d %d", &type, &flag, &tick)) < 1) {
  2873. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag> <tick>).");
  2874. return -1;
  2875. }
  2876. if (i < 2) flag = 1;
  2877. if (i < 3) tick = 0;
  2878.  
  2879. clif_status_change(&sd->bl, type, flag, tick);
  2880.  
  2881. return 0;
  2882. }
  2883.  
  2884. /*==========================================
  2885. * @stpoint (Rewritten by [Yor])
  2886. *------------------------------------------*/
  2887. ACMD_FUNC(statuspoint)
  2888. {
  2889. int point;
  2890. unsigned int new_status_point;
  2891.  
  2892. if (!message || !*message || (point = atoi(message)) == 0) {
  2893. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2894. return -1;
  2895. }
  2896.  
  2897. if(point < 0)
  2898. {
  2899. if(sd->status.status_point < (unsigned int)(-point))
  2900. {
  2901. new_status_point = 0;
  2902. }
  2903. else
  2904. {
  2905. new_status_point = sd->status.status_point + point;
  2906. }
  2907. }
  2908. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2909. {
  2910. new_status_point = UINT_MAX;
  2911. }
  2912. else
  2913. {
  2914. new_status_point = sd->status.status_point + point;
  2915. }
  2916.  
  2917. if (new_status_point != sd->status.status_point) {
  2918. sd->status.status_point = new_status_point;
  2919. pc_onstatuschanged(sd, SP_STATUSPOINT);
  2920. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2921. } else {
  2922. if (point < 0)
  2923. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2924. else
  2925. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2926. return -1;
  2927. }
  2928.  
  2929. return 0;
  2930. }
  2931.  
  2932. /*==========================================
  2933. * @skpoint (Rewritten by [Yor])
  2934. *------------------------------------------*/
  2935. ACMD_FUNC(skillpoint)
  2936. {
  2937. int point;
  2938. unsigned int new_skill_point;
  2939. nullpo_retr(-1, sd);
  2940.  
  2941. if (!message || !*message || (point = atoi(message)) == 0) {
  2942. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2943. return -1;
  2944. }
  2945.  
  2946. if(point < 0)
  2947. {
  2948. if(sd->status.skill_point < (unsigned int)(-point))
  2949. {
  2950. new_skill_point = 0;
  2951. }
  2952. else
  2953. {
  2954. new_skill_point = sd->status.skill_point + point;
  2955. }
  2956. }
  2957. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2958. {
  2959. new_skill_point = UINT_MAX;
  2960. }
  2961. else
  2962. {
  2963. new_skill_point = sd->status.skill_point + point;
  2964. }
  2965.  
  2966. if (new_skill_point != sd->status.skill_point) {
  2967. sd->status.skill_point = new_skill_point;
  2968. pc_onstatuschanged(sd, SP_SKILLPOINT);
  2969. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2970. } else {
  2971. if (point < 0)
  2972. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2973. else
  2974. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2975. return -1;
  2976. }
  2977.  
  2978. return 0;
  2979. }
  2980.  
  2981. /*==========================================
  2982. * @zeny (Rewritten by [Yor])
  2983. *------------------------------------------*/
  2984. ACMD_FUNC(zeny)
  2985. {
  2986. int zeny, new_zeny;
  2987. nullpo_retr(-1, sd);
  2988.  
  2989. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2990. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2991. return -1;
  2992. }
  2993.  
  2994. new_zeny = sd->status.zeny + zeny;
  2995. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2996. new_zeny = MAX_ZENY;
  2997. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2998. new_zeny = 0;
  2999.  
  3000. if (new_zeny != sd->status.zeny) {
  3001. sd->status.zeny = new_zeny;
  3002. pc_onstatuschanged(sd, SP_ZENY);
  3003. clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  3004. } else {
  3005. if (zeny < 0)
  3006. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  3007. else
  3008. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  3009. return -1;
  3010. }
  3011.  
  3012. return 0;
  3013. }
  3014.  
  3015. /*==========================================
  3016. *
  3017. *------------------------------------------*/
  3018. ACMD_FUNC(param)
  3019. {
  3020. int i, value = 0, new_value;
  3021. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  3022. short* status[6];
  3023. //we don't use direct initialization because it isn't part of the c standard.
  3024. nullpo_retr(-1, sd);
  3025.  
  3026. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3027.  
  3028. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3029. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  3030. clif_displaymessage(fd, atcmd_output);
  3031. return -1;
  3032. }
  3033.  
  3034. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  3035.  
  3036. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  3037. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  3038. clif_displaymessage(fd, atcmd_output);
  3039. return -1;
  3040. }
  3041.  
  3042. status[0] = &sd->status.str;
  3043. status[1] = &sd->status.agi;
  3044. status[2] = &sd->status.vit;
  3045. status[3] = &sd->status.int_;
  3046. status[4] = &sd->status.dex;
  3047. status[5] = &sd->status.luk;
  3048.  
  3049. if(value < 0 && *status[i] <= -value)
  3050. {
  3051. new_value = 1;
  3052. }
  3053. else if(SHRT_MAX - *status[i] < value)
  3054. {
  3055. new_value = SHRT_MAX;
  3056. }
  3057. else
  3058. {
  3059. new_value = *status[i] + value;
  3060. }
  3061.  
  3062. if (new_value != *status[i]) {
  3063. *status[i] = new_value;
  3064. pc_onstatuschanged(sd, SP_STR + i);
  3065. pc_onstatuschanged(sd, SP_USTR + i);
  3066. status_calc_pc(sd, 0);
  3067. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  3068. } else {
  3069. if (value < 0)
  3070. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  3071. else
  3072. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  3073. return -1;
  3074. }
  3075.  
  3076. return 0;
  3077. }
  3078.  
  3079. /*==========================================
  3080. * Stat all by fritz (rewritten by [Yor])
  3081. *------------------------------------------*/
  3082. ACMD_FUNC(stat_all)
  3083. {
  3084. int index, count, value, max, new_value;
  3085. short* status[6];
  3086. //we don't use direct initialization because it isn't part of the c standard.
  3087. nullpo_retr(-1, sd);
  3088.  
  3089. status[0] = &sd->status.str;
  3090. status[1] = &sd->status.agi;
  3091. status[2] = &sd->status.vit;
  3092. status[3] = &sd->status.int_;
  3093. status[4] = &sd->status.dex;
  3094. status[5] = &sd->status.luk;
  3095.  
  3096. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3097. value = pc_maxparameter(sd);
  3098. max = pc_maxparameter(sd);
  3099. } else {
  3100. max = SHRT_MAX;
  3101. }
  3102.  
  3103. count = 0;
  3104. for (index = 0; index < ARRAYLENGTH(status); index++) {
  3105.  
  3106. if (value > 0 && *status[index] > max - value)
  3107. new_value = max;
  3108. else if (value < 0 && *status[index] <= -value)
  3109. new_value = 1;
  3110. else
  3111. new_value = *status[index] +value;
  3112.  
  3113. if (new_value != (int)*status[index]) {
  3114. *status[index] = new_value;
  3115. pc_onstatuschanged(sd, SP_STR + index);
  3116. pc_onstatuschanged(sd, SP_USTR + index);
  3117. count++;
  3118. }
  3119. }
  3120.  
  3121. if (count > 0) { // if at least 1 stat modified
  3122. status_calc_pc(sd, 0);
  3123. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  3124. } else {
  3125. if (value < 0)
  3126. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  3127. else
  3128. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  3129. return -1;
  3130. }
  3131.  
  3132. return 0;
  3133. }
  3134.  
  3135. /*==========================================
  3136. *
  3137. *------------------------------------------*/
  3138. ACMD_FUNC(guildlevelup)
  3139. {
  3140. int level = 0;
  3141. short added_level;
  3142. struct guild *guild_info;
  3143. nullpo_retr(-1, sd);
  3144.  
  3145. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3146. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3147. return -1;
  3148. }
  3149.  
  3150. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3151. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  3152. return -1;
  3153. }
  3154. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  3155. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  3156. // return -1;
  3157. //}
  3158.  
  3159. added_level = (short)level;
  3160. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3161. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3162. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3163. added_level = 1 - guild_info->guild_lv;
  3164.  
  3165. if (added_level != 0) {
  3166. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  3167. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  3168. } else {
  3169. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  3170. return -1;
  3171. }
  3172.  
  3173. return 0;
  3174. }
  3175.  
  3176. /*==========================================
  3177. *
  3178. *------------------------------------------*/
  3179. ACMD_FUNC(makeegg)
  3180. {
  3181. struct item_data *item_data;
  3182. int id, pet_id;
  3183. nullpo_retr(-1, sd);
  3184.  
  3185. if (!message || !*message) {
  3186. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  3187. return -1;
  3188. }
  3189.  
  3190. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3191. id = item_data->nameid;
  3192. else
  3193. if ((id = mobdb_searchname(message)) != 0) // for monster name
  3194. ;
  3195. else
  3196. id = atoi(message);
  3197.  
  3198. pet_id = search_petDB_index(id, PET_CLASS);
  3199. if (pet_id < 0)
  3200. pet_id = search_petDB_index(id, PET_EGG);
  3201. if (pet_id >= 0) {
  3202. sd->catch_target_class = pet_db[pet_id].class_;
  3203. intif_create_pet(
  3204. sd->status.account_id, sd->status.char_id,
  3205. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3206. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3207. 100, 0, 1, pet_db[pet_id].jname);
  3208. } else {
  3209. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  3210. return -1;
  3211. }
  3212.  
  3213. return 0;
  3214. }
  3215.  
  3216. /*==========================================
  3217. *
  3218. *------------------------------------------*/
  3219. ACMD_FUNC(hatch)
  3220. {
  3221. nullpo_retr(-1, sd);
  3222. if (sd->status.pet_id <= 0)
  3223. clif_sendegg(sd);
  3224. else {
  3225. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  3226. return -1;
  3227. }
  3228.  
  3229. return 0;
  3230. }
  3231.  
  3232. /*==========================================
  3233. *
  3234. *------------------------------------------*/
  3235. ACMD_FUNC(petfriendly)
  3236. {
  3237. int friendly;
  3238. struct pet_data *pd;
  3239. nullpo_retr(-1, sd);
  3240.  
  3241. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3242. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3243. return -1;
  3244. }
  3245.  
  3246. pd = sd->pd;
  3247. if (!pd) {
  3248. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3249. return -1;
  3250. }
  3251.  
  3252. if (friendly < 0 || friendly > 1000)
  3253. {
  3254. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3255. return -1;
  3256. }
  3257.  
  3258. if (friendly == pd->pet.intimate) {
  3259. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  3260. return -1;
  3261. }
  3262.  
  3263. pet_set_intimate(pd, friendly);
  3264. clif_send_petstatus(sd);
  3265. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  3266. return 0;
  3267. }
  3268.  
  3269. /*==========================================
  3270. *
  3271. *------------------------------------------*/
  3272. ACMD_FUNC(pethungry)
  3273. {
  3274. int hungry;
  3275. struct pet_data *pd;
  3276. nullpo_retr(-1, sd);
  3277.  
  3278. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3279. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3280. return -1;
  3281. }
  3282.  
  3283. pd = sd->pd;
  3284. if (!sd->status.pet_id || !pd) {
  3285. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3286. return -1;
  3287. }
  3288. if (hungry < 0 || hungry > 100) {
  3289. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3290. return -1;
  3291. }
  3292. if (hungry == pd->pet.hungry) {
  3293. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  3294. return -1;
  3295. }
  3296.  
  3297. pd->pet.hungry = hungry;
  3298. clif_send_petstatus(sd);
  3299. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  3300.  
  3301. return 0;
  3302. }
  3303.  
  3304. /*==========================================
  3305. *
  3306. *------------------------------------------*/
  3307. ACMD_FUNC(petrename)
  3308. {
  3309. struct pet_data *pd;
  3310. nullpo_retr(-1, sd);
  3311. if (!sd->status.pet_id || !sd->pd) {
  3312. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3313. return -1;
  3314. }
  3315. pd = sd->pd;
  3316. if (!pd->pet.rename_flag) {
  3317. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  3318. return -1;
  3319. }
  3320.  
  3321. pd->pet.rename_flag = 0;
  3322. intif_save_petdata(sd->status.account_id, &pd->pet);
  3323. clif_send_petstatus(sd);
  3324. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  3325.  
  3326. return 0;
  3327. }
  3328.  
  3329. /*==========================================
  3330. *
  3331. *------------------------------------------*/
  3332. ACMD_FUNC(recall)
  3333. {
  3334. struct map_session_data *pl_sd = NULL;
  3335.  
  3336. nullpo_retr(-1, sd);
  3337.  
  3338. if (!message || !*message) {
  3339. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  3340. return -1;
  3341. }
  3342.  
  3343. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3344. {
  3345. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3346. return -1;
  3347. }
  3348.  
  3349. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3350. {
  3351. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  3352. return -1;
  3353. }
  3354.  
  3355. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3356. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3357. return -1;
  3358. }
  3359. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3360. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3361. return -1;
  3362. }
  3363. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3364. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  3365. clif_displaymessage(fd, atcmd_output);
  3366.  
  3367. return 0;
  3368. }
  3369.  
  3370. /*==========================================
  3371. * charblock command (usage: charblock <player_name>)
  3372. * This command do a definitiv ban on a player
  3373. *------------------------------------------*/
  3374. ACMD_FUNC(char_block)
  3375. {
  3376. nullpo_retr(-1, sd);
  3377.  
  3378. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3379.  
  3380. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3381. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3382. return -1;
  3383. }
  3384.  
  3385. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3386. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3387.  
  3388. return 0;
  3389. }
  3390.  
  3391. /*==========================================
  3392. * charban command (usage: charban <time> <player_name>)
  3393. * This command do a limited ban on a player
  3394. * Time is done as follows:
  3395. * Adjustment value (-1, 1, +1, etc...)
  3396. * Modified element:
  3397. * a or y: year
  3398. * m: month
  3399. * j or d: day
  3400. * h: hour
  3401. * mn: minute
  3402. * s: second
  3403. * <example> @ban +1m-2mn1s-6y test_player
  3404. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3405. *------------------------------------------*/
  3406. ACMD_FUNC(char_ban)
  3407. {
  3408. char * modif_p;
  3409. int year, month, day, hour, minute, second, value;
  3410. nullpo_retr(-1, sd);
  3411.  
  3412. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3413. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3414.  
  3415. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  3416. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3417. return -1;
  3418. }
  3419.  
  3420. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3421.  
  3422. modif_p = atcmd_output;
  3423. year = month = day = hour = minute = second = 0;
  3424. while (modif_p[0] != '\0') {
  3425. value = atoi(modif_p);
  3426. if (value == 0)
  3427. modif_p++;
  3428. else {
  3429. if (modif_p[0] == '-' || modif_p[0] == '+')
  3430. modif_p++;
  3431. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3432. modif_p++;
  3433. if (modif_p[0] == 's') {
  3434. second = value;
  3435. modif_p++;
  3436. } else if (modif_p[0] == 'n') {
  3437. minute = value;
  3438. modif_p++;
  3439. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3440. minute = value;
  3441. modif_p = modif_p + 2;
  3442. } else if (modif_p[0] == 'h') {
  3443. hour = value;
  3444. modif_p++;
  3445. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3446. day = value;
  3447. modif_p++;
  3448. } else if (modif_p[0] == 'm') {
  3449. month = value;
  3450. modif_p++;
  3451. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3452. year = value;
  3453. modif_p++;
  3454. } else if (modif_p[0] != '\0') {
  3455. modif_p++;
  3456. }
  3457. }
  3458. }
  3459. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3460. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  3461. return -1;
  3462. }
  3463.  
  3464. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3465. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3466.  
  3467. return 0;
  3468. }
  3469.  
  3470. /*==========================================
  3471. * charunblock command (usage: charunblock <player_name>)
  3472. *------------------------------------------*/
  3473. ACMD_FUNC(char_unblock)
  3474. {
  3475. nullpo_retr(-1, sd);
  3476.  
  3477. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3478.  
  3479. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3480. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3481. return -1;
  3482. }
  3483.  
  3484. // send answer to login server via char-server
  3485. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3486. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3487.  
  3488. return 0;
  3489. }
  3490.  
  3491. /*==========================================
  3492. * charunban command (usage: charunban <player_name>)
  3493. *------------------------------------------*/
  3494. ACMD_FUNC(char_unban)
  3495. {
  3496. nullpo_retr(-1, sd);
  3497.  
  3498. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3499.  
  3500. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3501. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3502. return -1;
  3503. }
  3504.  
  3505. // send answer to login server via char-server
  3506. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3507. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3508.  
  3509. return 0;
  3510. }
  3511.  
  3512. /*==========================================
  3513. *
  3514. *------------------------------------------*/
  3515. ACMD_FUNC(night)
  3516. {
  3517. nullpo_retr(-1, sd);
  3518.  
  3519. if (night_flag != 1) {
  3520. map_night_timer(night_timer_tid, 0, 0, 1);
  3521. } else {
  3522. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  3523. return -1;
  3524. }
  3525.  
  3526. return 0;
  3527. }
  3528.  
  3529. /*==========================================
  3530. *
  3531. *------------------------------------------*/
  3532. ACMD_FUNC(day)
  3533. {
  3534. nullpo_retr(-1, sd);
  3535.  
  3536. if (night_flag != 0) {
  3537. map_day_timer(day_timer_tid, 0, 0, 1);
  3538. } else {
  3539. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  3540. return -1;
  3541. }
  3542.  
  3543. return 0;
  3544. }
  3545.  
  3546. /*==========================================
  3547. *
  3548. *------------------------------------------*/
  3549. ACMD_FUNC(doom)
  3550. {
  3551. struct map_session_data* pl_sd;
  3552. struct s_mapiterator* iter;
  3553.  
  3554. nullpo_retr(-1, sd);
  3555.  
  3556. iter = mapit_getallusers();
  3557. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3558. {
  3559. if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
  3560. {
  3561. status_kill(&pl_sd->bl);
  3562. clif_specialeffect(&pl_sd->bl,450,AREA);
  3563. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3564. }
  3565. }
  3566. mapit_free(iter);
  3567.  
  3568. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3569.  
  3570. return 0;
  3571. }
  3572.  
  3573. /*==========================================
  3574. *
  3575. *------------------------------------------*/
  3576. ACMD_FUNC(doommap)
  3577. {
  3578. struct map_session_data* pl_sd;
  3579. struct s_mapiterator* iter;
  3580.  
  3581. nullpo_retr(-1, sd);
  3582.  
  3583. iter = mapit_getallusers();
  3584. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3585. {
  3586. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
  3587. {
  3588. status_kill(&pl_sd->bl);
  3589. clif_specialeffect(&pl_sd->bl,450,AREA);
  3590. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3591. }
  3592. }
  3593. mapit_free(iter);
  3594.  
  3595. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3596.  
  3597. return 0;
  3598. }
  3599.  
  3600. /*==========================================
  3601. *
  3602. *------------------------------------------*/
  3603. static void atcommand_raise_sub(struct map_session_data* sd)
  3604. {
  3605. if (!status_isdead(&sd->bl))
  3606. return;
  3607.  
  3608. if(!status_revive(&sd->bl, 100, 100))
  3609. return;
  3610. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3611. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3612. }
  3613.  
  3614. /*==========================================
  3615. *
  3616. *------------------------------------------*/
  3617. ACMD_FUNC(raise)
  3618. {
  3619. struct map_session_data* pl_sd;
  3620. struct s_mapiterator* iter;
  3621.  
  3622. nullpo_retr(-1, sd);
  3623.  
  3624. iter = mapit_getallusers();
  3625. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3626. atcommand_raise_sub(pl_sd);
  3627. mapit_free(iter);
  3628.  
  3629. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3630.  
  3631. return 0;
  3632. }
  3633.  
  3634. /*==========================================
  3635. *
  3636. *------------------------------------------*/
  3637. ACMD_FUNC(raisemap)
  3638. {
  3639. struct map_session_data* pl_sd;
  3640. struct s_mapiterator* iter;
  3641.  
  3642. nullpo_retr(-1, sd);
  3643.  
  3644. iter = mapit_getallusers();
  3645. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3646. if (sd->bl.m == pl_sd->bl.m)
  3647. atcommand_raise_sub(pl_sd);
  3648. mapit_free(iter);
  3649.  
  3650. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3651.  
  3652. return 0;
  3653. }
  3654.  
  3655. /*==========================================
  3656. *
  3657. *------------------------------------------*/
  3658. ACMD_FUNC(kick)
  3659. {
  3660. struct map_session_data *pl_sd;
  3661. nullpo_retr(-1, sd);
  3662.  
  3663. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3664.  
  3665. if (!message || !*message) {
  3666. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3667. return -1;
  3668. }
  3669.  
  3670. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3671. {
  3672. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3673. return -1;
  3674. }
  3675.  
  3676. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3677. {
  3678. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3679. return -1;
  3680. }
  3681.  
  3682. clif_GM_kick(sd, pl_sd);
  3683.  
  3684. return 0;
  3685. }
  3686.  
  3687. /*==========================================
  3688. *
  3689. *------------------------------------------*/
  3690. ACMD_FUNC(kickall)
  3691. {
  3692. struct map_session_data* pl_sd;
  3693. struct s_mapiterator* iter;
  3694. nullpo_retr(-1, sd);
  3695.  
  3696. iter = mapit_getallusers();
  3697. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3698. {
  3699. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3700. if (sd->status.account_id != pl_sd->status.account_id)
  3701. clif_GM_kick(NULL, pl_sd);
  3702. }
  3703. }
  3704. mapit_free(iter);
  3705.  
  3706. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3707.  
  3708. return 0;
  3709. }
  3710.  
  3711. /*==========================================
  3712. *
  3713. *------------------------------------------*/
  3714. ACMD_FUNC(allskill)
  3715. {
  3716. nullpo_retr(-1, sd);
  3717. pc_allskillup(sd); // all skills
  3718. sd->status.skill_point = 0; // 0 skill points
  3719. pc_onstatuschanged(sd, SP_SKILLPOINT); // update
  3720. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  3721.  
  3722. return 0;
  3723. }
  3724.  
  3725. /*==========================================
  3726. *
  3727. *------------------------------------------*/
  3728. ACMD_FUNC(questskill)
  3729. {
  3730. int skill_id;
  3731. nullpo_retr(-1, sd);
  3732.  
  3733. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3734. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3735. return -1;
  3736. }
  3737. if (skill_id < 0 || skill_id >= MAX_SKILL_DB) {
  3738. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3739. return -1;
  3740. }
  3741. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3742. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3743. return -1;
  3744. }
  3745. if (pc_checkskill(sd, skill_id) > 0) {
  3746. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3747. return -1;
  3748. }
  3749.  
  3750. pc_skill(sd, skill_id, 1, 0);
  3751. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3752.  
  3753. return 0;
  3754. }
  3755.  
  3756. /*==========================================
  3757. *
  3758. *------------------------------------------*/
  3759. ACMD_FUNC(lostskill)
  3760. {
  3761. int skill_id;
  3762. nullpo_retr(-1, sd);
  3763.  
  3764. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3765. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3766. return -1;
  3767. }
  3768. if (skill_id < 0 || skill_id >= MAX_SKILL) {
  3769. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3770. return -1;
  3771. }
  3772. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3773. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3774. return -1;
  3775. }
  3776. if (pc_checkskill(sd, skill_id) == 0) {
  3777. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3778. return -1;
  3779. }
  3780.  
  3781. sd->status.skill[skill_id].lv = 0;
  3782. sd->status.skill[skill_id].flag = 0;
  3783. clif_deleteskill(sd,skill_id);
  3784. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3785.  
  3786. return 0;
  3787. }
  3788.  
  3789. /*==========================================
  3790. *
  3791. *------------------------------------------*/
  3792. ACMD_FUNC(spiritball)
  3793. {
  3794. int max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  3795. int number;
  3796. nullpo_retr(-1, sd);
  3797.  
  3798. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  3799. {
  3800. char msg[CHAT_SIZE_MAX];
  3801. safesnprintf(msg, sizeof(msg), "Usage: @spiritball <number: 0-%d>", max_spiritballs);
  3802. clif_displaymessage(fd, msg);
  3803. return -1;
  3804. }
  3805.  
  3806. if( sd->spiritball > 0 )
  3807. pc_delspiritball(sd, sd->spiritball, 1);
  3808. sd->spiritball = number;
  3809. clif_spiritball(sd);
  3810. // no message, player can look the difference
  3811.  
  3812. return 0;
  3813. }
  3814.  
  3815. /*==========================================
  3816. *
  3817. *------------------------------------------*/
  3818. ACMD_FUNC(party)
  3819. {
  3820. char party[NAME_LENGTH];
  3821. nullpo_retr(-1, sd);
  3822.  
  3823. memset(party, '\0', sizeof(party));
  3824.  
  3825. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3826. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3827. return -1;
  3828. }
  3829.  
  3830. party_create(sd, party, 0, 0);
  3831.  
  3832. return 0;
  3833. }
  3834.  
  3835. /*==========================================
  3836. *
  3837. *------------------------------------------*/
  3838. ACMD_FUNC(guild)
  3839. {
  3840. char guild[NAME_LENGTH];
  3841. int prev;
  3842. nullpo_retr(-1, sd);
  3843.  
  3844. memset(guild, '\0', sizeof(guild));
  3845.  
  3846. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3847. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3848. return -1;
  3849. }
  3850.  
  3851. prev = battle_config.guild_emperium_check;
  3852. battle_config.guild_emperium_check = 0;
  3853. guild_create(sd, guild);
  3854. battle_config.guild_emperium_check = prev;
  3855.  
  3856. return 0;
  3857. }
  3858.  
  3859. /*==========================================
  3860. *
  3861. *------------------------------------------*/
  3862. ACMD_FUNC(agitstart)
  3863. {
  3864. nullpo_retr(-1, sd);
  3865. if (agit_flag == 1) {
  3866. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  3867. return -1;
  3868. }
  3869.  
  3870. agit_flag = 1;
  3871. guild_agit_start();
  3872. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  3873.  
  3874. return 0;
  3875. }
  3876.  
  3877. /*==========================================
  3878. *
  3879. *------------------------------------------*/
  3880. ACMD_FUNC(agitstart2)
  3881. {
  3882. nullpo_retr(-1, sd);
  3883. if (agit2_flag == 1) {
  3884. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  3885. return -1;
  3886. }
  3887.  
  3888. agit2_flag = 1;
  3889. guild_agit2_start();
  3890. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  3891.  
  3892. return 0;
  3893. }
  3894.  
  3895. /*==========================================
  3896. *
  3897. *------------------------------------------*/
  3898. ACMD_FUNC(agitend)
  3899. {
  3900. nullpo_retr(-1, sd);
  3901. if (agit_flag == 0) {
  3902. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3903. return -1;
  3904. }
  3905.  
  3906. agit_flag = 0;
  3907. guild_agit_end();
  3908. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3909.  
  3910. return 0;
  3911. }
  3912.  
  3913. /*==========================================
  3914. *
  3915. *------------------------------------------*/
  3916. ACMD_FUNC(agitend2)
  3917. {
  3918. nullpo_retr(-1, sd);
  3919. if (agit2_flag == 0) {
  3920. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3921. return -1;
  3922. }
  3923.  
  3924. agit2_flag = 0;
  3925. guild_agit2_end();
  3926. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3927.  
  3928. return 0;
  3929. }
  3930.  
  3931. /*==========================================
  3932. * @mapexit - shuts down the map server
  3933. *------------------------------------------*/
  3934. ACMD_FUNC(mapexit)
  3935. {
  3936. nullpo_retr(-1, sd);
  3937.  
  3938. do_shutdown();
  3939. return 0;
  3940. }
  3941.  
  3942. /*==========================================
  3943. * idsearch <part_of_name>: revrited by [Yor]
  3944. *------------------------------------------*/
  3945. ACMD_FUNC(idsearch)
  3946. {
  3947. char item_name[100];
  3948. unsigned int i, match;
  3949. struct item_data *item_array[MAX_SEARCH];
  3950. nullpo_retr(-1, sd);
  3951.  
  3952. memset(item_name, '\0', sizeof(item_name));
  3953. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3954.  
  3955. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3956. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3957. return -1;
  3958. }
  3959.  
  3960. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3961. clif_displaymessage(fd, atcmd_output);
  3962. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3963. if (match > MAX_SEARCH) {
  3964. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3965. clif_displaymessage(fd, atcmd_output);
  3966. match = MAX_SEARCH;
  3967. }
  3968. for(i = 0; i < match; i++) {
  3969. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3970. clif_displaymessage(fd, atcmd_output);
  3971. }
  3972. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3973. clif_displaymessage(fd, atcmd_output);
  3974.  
  3975. return 0;
  3976. }
  3977.  
  3978. /*==========================================
  3979. * Recall All Characters Online To Your Location
  3980. *------------------------------------------*/
  3981. ACMD_FUNC(recallall)
  3982. {
  3983. struct map_session_data* pl_sd;
  3984. struct s_mapiterator* iter;
  3985. int num_failed;
  3986. nullpo_retr(-1, sd);
  3987.  
  3988. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3989. clif_displaymessage(fd, "You are not authorised to warp players to your current map.");
  3990. return -1;
  3991. }
  3992.  
  3993. num_failed = 0;
  3994. iter = mapit_getallusers();
  3995. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3996. {
  3997. if( pl_sd->status.account_id == sd->status.account_id )
  3998. continue; // no point in recalling self
  3999. if( pc_isGM(pl_sd) > pc_isGM(sd) )
  4000. continue; // skip more powerful GMs
  4001. if( pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd) )
  4002. {
  4003. ++num_failed;
  4004. continue; // blocked by nowarp mapflag
  4005. }
  4006.  
  4007. if( pc_isdead(pl_sd) )
  4008. {// wake them up
  4009. pc_setstand(pl_sd);
  4010. pc_setrestartvalue(pl_sd,1);
  4011. }
  4012.  
  4013. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  4014. }
  4015. mapit_free(iter);
  4016.  
  4017. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  4018. if( num_failed != 0 )
  4019. {
  4020. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", num_failed);
  4021. clif_displaymessage(fd, atcmd_output);
  4022. }
  4023.  
  4024. return 0;
  4025. }
  4026.  
  4027. /*==========================================
  4028. * Recall online characters of a guild to your location
  4029. *------------------------------------------*/
  4030. ACMD_FUNC(guildrecall)
  4031. {
  4032. struct map_session_data* pl_sd;
  4033. struct s_mapiterator* iter;
  4034. char guild_name[NAME_LENGTH];
  4035. struct guild* g;
  4036. int num_failed;
  4037. nullpo_retr(-1, sd);
  4038.  
  4039. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4040. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4041. return -1;
  4042. }
  4043.  
  4044. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4045. clif_displaymessage(fd, "You are not authorised to warp players to your current map.");
  4046. return -1;
  4047. }
  4048.  
  4049. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  4050. (g = guild_search(atoi(message))) == NULL)
  4051. {
  4052. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4053. return -1;
  4054. }
  4055.  
  4056. num_failed = 0;
  4057. iter = mapit_getallusers();
  4058. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4059. {
  4060. if( pl_sd->status.account_id == sd->status.account_id )
  4061. continue; // no point in recalling self
  4062. if( pl_sd->status.guild_id != g->guild_id )
  4063. continue; // not the right guild
  4064. if( pc_isGM(pl_sd) > pc_isGM(sd) )
  4065. continue; // skip more powerful GMs
  4066. if( pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd) )
  4067. {
  4068. ++num_failed;
  4069. continue; // blocked by nowarp mapflag
  4070. }
  4071.  
  4072. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  4073. }
  4074. mapit_free(iter);
  4075.  
  4076. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  4077. clif_displaymessage(fd, atcmd_output);
  4078. if( num_failed != 0 )
  4079. {
  4080. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", num_failed);
  4081. clif_displaymessage(fd, atcmd_output);
  4082. }
  4083.  
  4084. return 0;
  4085. }
  4086.  
  4087. /*==========================================
  4088. * Recall online characters of a party to your location
  4089. *------------------------------------------*/
  4090. ACMD_FUNC(partyrecall)
  4091. {
  4092. struct map_session_data* pl_sd;
  4093. struct s_mapiterator* iter;
  4094. char party_name[NAME_LENGTH];
  4095. struct party_data* p;
  4096. int num_failed;
  4097. nullpo_retr(-1, sd);
  4098.  
  4099. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4100. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4101. return -1;
  4102. }
  4103.  
  4104. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4105. clif_displaymessage(fd, "You are not authorised to warp players to your current map.");
  4106. return -1;
  4107. }
  4108.  
  4109. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  4110. (p = party_search(atoi(message))) == NULL)
  4111. {
  4112. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  4113. return -1;
  4114. }
  4115.  
  4116. num_failed = 0;
  4117. iter = mapit_getallusers();
  4118. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4119. {
  4120. if( pl_sd->status.account_id == sd->status.account_id )
  4121. continue; // no point in recalling self
  4122. if( pl_sd->status.party_id != p->party.party_id )
  4123. continue; // not the right party
  4124. if( pc_isGM(pl_sd) > pc_isGM(sd) )
  4125. continue; // skip more powerful GMs
  4126. if( pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd) )
  4127. {
  4128. ++num_failed;
  4129. continue; // blocked by nowarp mapflag
  4130. }
  4131.  
  4132. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  4133. }
  4134. mapit_free(iter);
  4135.  
  4136. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  4137. clif_displaymessage(fd, atcmd_output);
  4138. if( num_failed != 0 )
  4139. {
  4140. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", num_failed);
  4141. clif_displaymessage(fd, atcmd_output);
  4142. }
  4143.  
  4144. return 0;
  4145. }
  4146.  
  4147. /*==========================================
  4148. *
  4149. *------------------------------------------*/
  4150. ACMD_FUNC(reloaditemdb)
  4151. {
  4152. nullpo_retr(-1, sd);
  4153. itemdb_reload();
  4154. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  4155.  
  4156. return 0;
  4157. }
  4158.  
  4159. /*==========================================
  4160. *
  4161. *------------------------------------------*/
  4162. ACMD_FUNC(reloadmobdb)
  4163. {
  4164. nullpo_retr(-1, sd);
  4165. mob_reload();
  4166. read_petdb();
  4167. merc_reload();
  4168. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  4169.  
  4170. return 0;
  4171. }
  4172.  
  4173. /*==========================================
  4174. *
  4175. *------------------------------------------*/
  4176. ACMD_FUNC(reloadskilldb)
  4177. {
  4178. nullpo_retr(-1, sd);
  4179. skill_reload();
  4180. merc_skill_reload();
  4181. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  4182.  
  4183. return 0;
  4184. }
  4185.  
  4186. /*==========================================
  4187. * @reloadatcommand - reloads atcommand_athena.conf
  4188. *------------------------------------------*/
  4189. ACMD_FUNC(reloadatcommand)
  4190. {
  4191. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4192. clif_displaymessage(fd, msg_txt(254));
  4193. return 0;
  4194. }
  4195. /*==========================================
  4196. * @reloadbattleconf - reloads battle_athena.conf
  4197. *------------------------------------------*/
  4198. ACMD_FUNC(reloadbattleconf)
  4199. {
  4200. struct Battle_Config prev_config;
  4201. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  4202.  
  4203. battle_config_read(BATTLE_CONF_FILENAME);
  4204.  
  4205. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  4206. || prev_config.item_rate_common != battle_config.item_rate_common
  4207. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  4208. || prev_config.item_rate_card != battle_config.item_rate_card
  4209. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  4210. || prev_config.item_rate_equip != battle_config.item_rate_equip
  4211. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  4212. || prev_config.item_rate_heal != battle_config.item_rate_heal
  4213. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  4214. || prev_config.item_rate_use != battle_config.item_rate_use
  4215. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  4216. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  4217. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  4218. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  4219. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  4220. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  4221. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  4222. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  4223. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  4224. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  4225. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  4226. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  4227. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  4228. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  4229. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  4230. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  4231. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  4232. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  4233. || prev_config.base_exp_rate != battle_config.base_exp_rate
  4234. || prev_config.job_exp_rate != battle_config.job_exp_rate
  4235. )
  4236. { // Exp or Drop rates changed.
  4237. mob_reload(); //Needed as well so rate changes take effect.
  4238. #ifndef TXT_ONLY
  4239. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  4240. #endif
  4241. }
  4242. clif_displaymessage(fd, msg_txt(255));
  4243. return 0;
  4244. }
  4245. /*==========================================
  4246. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  4247. *------------------------------------------*/
  4248. ACMD_FUNC(reloadstatusdb)
  4249. {
  4250. status_readdb();
  4251. clif_displaymessage(fd, msg_txt(256));
  4252. return 0;
  4253. }
  4254. /*==========================================
  4255. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  4256. *------------------------------------------*/
  4257. ACMD_FUNC(reloadpcdb)
  4258. {
  4259. pc_readdb();
  4260. clif_displaymessage(fd, msg_txt(257));
  4261. return 0;
  4262. }
  4263.  
  4264. /*==========================================
  4265. * @reloadmotd - reloads motd.txt
  4266. *------------------------------------------*/
  4267. ACMD_FUNC(reloadmotd)
  4268. {
  4269. pc_read_motd();
  4270. clif_displaymessage(fd, msg_txt(268));
  4271. return 0;
  4272. }
  4273.  
  4274. /*==========================================
  4275. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  4276. *------------------------------------------*/
  4277. ACMD_FUNC(reloadscript)
  4278. {
  4279. nullpo_retr(-1, sd);
  4280. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4281. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4282. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4283.  
  4284. flush_fifos();
  4285. script_reload();
  4286. npc_reload();
  4287.  
  4288. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  4289.  
  4290. return 0;
  4291. }
  4292.  
  4293. /*==========================================
  4294. * @mapinfo [0-3] <map name> by MC_Cameri
  4295. * => Shows information about the map [map name]
  4296. * 0 = no additional information
  4297. * 1 = Show users in that map and their location
  4298. * 2 = Shows NPCs in that map
  4299. * 3 = Shows the shops/chats in that map (not implemented)
  4300. *------------------------------------------*/
  4301. ACMD_FUNC(mapinfo)
  4302. {
  4303. struct map_session_data* pl_sd;
  4304. struct s_mapiterator* iter;
  4305. struct npc_data *nd = NULL;
  4306. struct chat_data *cd = NULL;
  4307. char direction[12];
  4308. int i, m_id, chat_num, list = 0;
  4309. unsigned short m_index;
  4310. char mapname[24];
  4311.  
  4312. nullpo_retr(-1, sd);
  4313.  
  4314. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4315. memset(mapname, '\0', sizeof(mapname));
  4316. memset(direction, '\0', sizeof(direction));
  4317.  
  4318. sscanf(message, "%d %23[^\n]", &list, mapname);
  4319.  
  4320. if (list < 0 || list > 3) {
  4321. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4322. return -1;
  4323. }
  4324.  
  4325. if (mapname[0] == '\0') {
  4326. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4327. m_id = map_mapindex2mapid(sd->mapindex);
  4328. } else {
  4329. m_id = map_mapname2mapid(mapname);
  4330. }
  4331.  
  4332. if (m_id < 0) {
  4333. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  4334. return -1;
  4335. }
  4336. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  4337.  
  4338. clif_displaymessage(fd, "------ Map Info ------");
  4339.  
  4340. // count chats (for initial message)
  4341. chat_num = 0;
  4342. iter = mapit_getallusers();
  4343. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4344. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  4345. chat_num++;
  4346. mapit_free(iter);
  4347.  
  4348. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", mapname, map[m_id].users, map[m_id].npc_num, chat_num);
  4349. clif_displaymessage(fd, atcmd_output);
  4350. clif_displaymessage(fd, "------ Map Flags ------");
  4351. if (map[m_id].flag.town)
  4352. clif_displaymessage(fd, "Town Map");
  4353.  
  4354. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  4355. clif_displaymessage(fd, "Autotrade Enabled");
  4356. else
  4357. clif_displaymessage(fd, "Autotrade Disabled");
  4358.  
  4359. if (map[m_id].flag.battleground)
  4360. clif_displaymessage(fd, "Battlegrounds ON");
  4361.  
  4362. strcpy(atcmd_output,"PvP Flags: ");
  4363. if (map[m_id].flag.pvp)
  4364. strcat(atcmd_output, "Pvp ON | ");
  4365. if (map[m_id].flag.pvp_noguild)
  4366. strcat(atcmd_output, "NoGuild | ");
  4367. if (map[m_id].flag.pvp_noparty)
  4368. strcat(atcmd_output, "NoParty | ");
  4369. if (map[m_id].flag.pvp_nightmaredrop)
  4370. strcat(atcmd_output, "NightmareDrop | ");
  4371. if (map[m_id].flag.pvp_nocalcrank)
  4372. strcat(atcmd_output, "NoCalcRank | ");
  4373. clif_displaymessage(fd, atcmd_output);
  4374.  
  4375. strcpy(atcmd_output,"GvG Flags: ");
  4376. if (map[m_id].flag.gvg)
  4377. strcat(atcmd_output, "GvG ON | ");
  4378. if (map[m_id].flag.gvg_dungeon)
  4379. strcat(atcmd_output, "GvG Dungeon | ");
  4380. if (map[m_id].flag.gvg_castle)
  4381. strcat(atcmd_output, "GvG Castle | ");
  4382. if (map[m_id].flag.gvg_noparty)
  4383. strcat(atcmd_output, "NoParty | ");
  4384. clif_displaymessage(fd, atcmd_output);
  4385.  
  4386. strcpy(atcmd_output,"Teleport Flags: ");
  4387. if (map[m_id].flag.noteleport)
  4388. strcat(atcmd_output, "NoTeleport | ");
  4389. if (map[m_id].flag.monster_noteleport)
  4390. strcat(atcmd_output, "Monster NoTeleport | ");
  4391. if (map[m_id].flag.nowarp)
  4392. strcat(atcmd_output, "NoWarp | ");
  4393. if (map[m_id].flag.nowarpto)
  4394. strcat(atcmd_output, "NoWarpTo | ");
  4395. if (map[m_id].flag.noreturn)
  4396. strcat(atcmd_output, "NoReturn | ");
  4397. if (map[m_id].flag.nogo)
  4398. strcat(atcmd_output, "NoGo | ");
  4399. if (map[m_id].flag.nomemo)
  4400. strcat(atcmd_output, "NoMemo | ");
  4401. clif_displaymessage(fd, atcmd_output);
  4402.  
  4403. sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  4404. clif_displaymessage(fd, atcmd_output);
  4405.  
  4406. if (map[m_id].flag.nosave) {
  4407. if (!map[m_id].save.map)
  4408. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  4409. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  4410. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  4411. else
  4412. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  4413. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  4414. clif_displaymessage(fd, atcmd_output);
  4415. }
  4416.  
  4417. strcpy(atcmd_output,"Weather Flags: ");
  4418. if (map[m_id].flag.snow)
  4419. strcat(atcmd_output, "Snow | ");
  4420. if (map[m_id].flag.fog)
  4421. strcat(atcmd_output, "Fog | ");
  4422. if (map[m_id].flag.sakura)
  4423. strcat(atcmd_output, "Sakura | ");
  4424. if (map[m_id].flag.clouds)
  4425. strcat(atcmd_output, "Clouds | ");
  4426. if (map[m_id].flag.clouds2)
  4427. strcat(atcmd_output, "Clouds2 | ");
  4428. if (map[m_id].flag.fireworks)
  4429. strcat(atcmd_output, "Fireworks | ");
  4430. if (map[m_id].flag.leaves)
  4431. strcat(atcmd_output, "Leaves | ");
  4432. if (map[m_id].flag.rain)
  4433. strcat(atcmd_output, "Rain | ");
  4434. if (map[m_id].flag.nightenabled)
  4435. strcat(atcmd_output, "Displays Night | ");
  4436. clif_displaymessage(fd, atcmd_output);
  4437.  
  4438. strcpy(atcmd_output,"Other Flags: ");
  4439. if (map[m_id].flag.nobranch)
  4440. strcat(atcmd_output, "NoBranch | ");
  4441. if (map[m_id].flag.notrade)
  4442. strcat(atcmd_output, "NoTrade | ");
  4443. if (map[m_id].flag.novending)
  4444. strcat(atcmd_output, "NoVending | ");
  4445. if (map[m_id].flag.nodrop)
  4446. strcat(atcmd_output, "NoDrop | ");
  4447. if (map[m_id].flag.noskill)
  4448. strcat(atcmd_output, "NoSkill | ");
  4449. if (map[m_id].flag.noicewall)
  4450. strcat(atcmd_output, "NoIcewall | ");
  4451. if (map[m_id].flag.allowks)
  4452. strcat(atcmd_output, "AllowKS | ");
  4453. if (map[m_id].flag.reset)
  4454. strcat(atcmd_output, "Reset | ");
  4455. clif_displaymessage(fd, atcmd_output);
  4456.  
  4457. strcpy(atcmd_output,"Other Flags: ");
  4458. if (map[m_id].nocommand)
  4459. strcat(atcmd_output, "NoCommand | ");
  4460. if (map[m_id].flag.nobaseexp)
  4461. strcat(atcmd_output, "NoBaseEXP | ");
  4462. if (map[m_id].flag.nojobexp)
  4463. strcat(atcmd_output, "NoJobEXP | ");
  4464. if (map[m_id].flag.nomobloot)
  4465. strcat(atcmd_output, "NoMobLoot | ");
  4466. if (map[m_id].flag.nomvploot)
  4467. strcat(atcmd_output, "NoMVPLoot | ");
  4468. if (map[m_id].flag.partylock)
  4469. strcat(atcmd_output, "PartyLock | ");
  4470. if (map[m_id].flag.guildlock)
  4471. strcat(atcmd_output, "GuildLock | ");
  4472. clif_displaymessage(fd, atcmd_output);
  4473.  
  4474. switch (list) {
  4475. case 0:
  4476. // Do nothing. It's list 0, no additional display.
  4477. break;
  4478. case 1:
  4479. clif_displaymessage(fd, "----- Players in Map -----");
  4480. iter = mapit_getallusers();
  4481. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4482. {
  4483. if (pl_sd->mapindex == m_index) {
  4484. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  4485. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  4486. clif_displaymessage(fd, atcmd_output);
  4487. }
  4488. }
  4489. mapit_free(iter);
  4490. break;
  4491. case 2:
  4492. clif_displaymessage(fd, "----- NPCs in Map -----");
  4493. for (i = 0; i < map[m_id].npc_num;)
  4494. {
  4495. nd = map[m_id].npc[i];
  4496. switch(nd->ud.dir) {
  4497. case 0: strcpy(direction, "North"); break;
  4498. case 1: strcpy(direction, "North West"); break;
  4499. case 2: strcpy(direction, "West"); break;
  4500. case 3: strcpy(direction, "South West"); break;
  4501. case 4: strcpy(direction, "South"); break;
  4502. case 5: strcpy(direction, "South East"); break;
  4503. case 6: strcpy(direction, "East"); break;
  4504. case 7: strcpy(direction, "North East"); break;
  4505. case 9: strcpy(direction, "North"); break;
  4506. default: strcpy(direction, "Unknown"); break;
  4507. }
  4508. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  4509. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  4510. clif_displaymessage(fd, atcmd_output);
  4511. }
  4512. break;
  4513. case 3:
  4514. clif_displaymessage(fd, "----- Chats in Map -----");
  4515. iter = mapit_getallusers();
  4516. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4517. {
  4518. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  4519. pl_sd->mapindex == m_index &&
  4520. cd->usersd[0] == pl_sd)
  4521. {
  4522. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  4523. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4524. clif_displaymessage(fd, atcmd_output);
  4525. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  4526. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  4527. clif_displaymessage(fd, atcmd_output);
  4528. }
  4529. }
  4530. mapit_free(iter);
  4531. break;
  4532. default: // normally impossible to arrive here
  4533. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4534. return -1;
  4535. break;
  4536. }
  4537.  
  4538. return 0;
  4539. }
  4540.  
  4541. /*==========================================
  4542. *
  4543. *------------------------------------------*/
  4544. ACMD_FUNC(mount_peco)
  4545. {
  4546. nullpo_retr(-1, sd);
  4547.  
  4548. if (!pc_isriding(sd)) { // if actually no peco
  4549. if (!pc_checkskill(sd, KN_RIDING))
  4550. {
  4551. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  4552. return -1;
  4553. }
  4554.  
  4555. if (sd->disguise)
  4556. {
  4557. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco Peco while in disguise.
  4558. return -1;
  4559. }
  4560.  
  4561. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4562. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  4563. } else { //Dismount
  4564. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4565. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  4566. }
  4567.  
  4568. return 0;
  4569. }
  4570.  
  4571. /*==========================================
  4572. *Spy Commands by Syrus22
  4573. *------------------------------------------*/
  4574. ACMD_FUNC(guildspy)
  4575. {
  4576. char guild_name[NAME_LENGTH];
  4577. struct guild *g;
  4578. nullpo_retr(-1, sd);
  4579.  
  4580. memset(guild_name, '\0', sizeof(guild_name));
  4581. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4582.  
  4583. if (!enable_spy)
  4584. {
  4585. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4586. return -1;
  4587. }
  4588. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4589. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  4590. return -1;
  4591. }
  4592.  
  4593. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4594. (g = guild_search(atoi(message))) != NULL) {
  4595. if (sd->guildspy == g->guild_id) {
  4596. sd->guildspy = 0;
  4597. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  4598. clif_displaymessage(fd, atcmd_output);
  4599. } else {
  4600. sd->guildspy = g->guild_id;
  4601. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  4602. clif_displaymessage(fd, atcmd_output);
  4603. }
  4604. } else {
  4605. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  4606. return -1;
  4607. }
  4608.  
  4609. return 0;
  4610. }
  4611.  
  4612. /*==========================================
  4613. *
  4614. *------------------------------------------*/
  4615. ACMD_FUNC(partyspy)
  4616. {
  4617. char party_name[NAME_LENGTH];
  4618. struct party_data *p;
  4619. nullpo_retr(-1, sd);
  4620.  
  4621. memset(party_name, '\0', sizeof(party_name));
  4622. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4623.  
  4624. if (!enable_spy)
  4625. {
  4626. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4627. return -1;
  4628. }
  4629.  
  4630. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4631. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  4632. return -1;
  4633. }
  4634.  
  4635. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4636. (p = party_search(atoi(message))) != NULL) {
  4637. if (sd->partyspy == p->party.party_id) {
  4638. sd->partyspy = 0;
  4639. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  4640. clif_displaymessage(fd, atcmd_output);
  4641. } else {
  4642. sd->partyspy = p->party.party_id;
  4643. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  4644. clif_displaymessage(fd, atcmd_output);
  4645. }
  4646. } else {
  4647. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  4648. return -1;
  4649. }
  4650.  
  4651. return 0;
  4652. }
  4653.  
  4654. /*==========================================
  4655. * @repairall [Valaris]
  4656. *------------------------------------------*/
  4657. ACMD_FUNC(repairall)
  4658. {
  4659. int count, i;
  4660. nullpo_retr(-1, sd);
  4661.  
  4662. count = 0;
  4663. for (i = 0; i < MAX_INVENTORY; i++) {
  4664. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  4665. sd->status.inventory[i].attribute = 0;
  4666. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  4667. count++;
  4668. }
  4669. }
  4670.  
  4671. if (count > 0) {
  4672. clif_misceffect(&sd->bl, 3);
  4673. clif_equiplist(sd);
  4674. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  4675. } else {
  4676. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  4677. return -1;
  4678. }
  4679.  
  4680. return 0;
  4681. }
  4682.  
  4683. /*==========================================
  4684. * @nuke [Valaris]
  4685. *------------------------------------------*/
  4686. ACMD_FUNC(nuke)
  4687. {
  4688. struct map_session_data *pl_sd;
  4689. nullpo_retr(-1, sd);
  4690.  
  4691. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4692.  
  4693. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4694. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  4695. return -1;
  4696. }
  4697.  
  4698. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4699. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  4700. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4701. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  4702. } else {
  4703. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4704. return -1;
  4705. }
  4706. } else {
  4707. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4708. return -1;
  4709. }
  4710.  
  4711. return 0;
  4712. }
  4713.  
  4714. /*==========================================
  4715. * @tonpc
  4716. *------------------------------------------*/
  4717. ACMD_FUNC(tonpc)
  4718. {
  4719. char npcname[NAME_LENGTH+1];
  4720. struct npc_data *nd;
  4721.  
  4722. nullpo_retr(-1, sd);
  4723.  
  4724. memset(npcname, 0, sizeof(npcname));
  4725.  
  4726. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4727. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4728. return -1;
  4729. }
  4730.  
  4731. if ((nd = npc_name2id(npcname)) != NULL) {
  4732. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  4733. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4734. else
  4735. return -1;
  4736. } else {
  4737. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4738. return -1;
  4739. }
  4740.  
  4741. return 0;
  4742. }
  4743.  
  4744. /*==========================================
  4745. *
  4746. *------------------------------------------*/
  4747. ACMD_FUNC(shownpc)
  4748. {
  4749. char NPCname[NAME_LENGTH+1];
  4750. nullpo_retr(-1, sd);
  4751.  
  4752. memset(NPCname, '\0', sizeof(NPCname));
  4753.  
  4754. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4755. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4756. return -1;
  4757. }
  4758.  
  4759. if (npc_name2id(NPCname) != NULL) {
  4760. npc_enable(NPCname, 1);
  4761. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4762. } else {
  4763. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4764. return -1;
  4765. }
  4766.  
  4767. return 0;
  4768. }
  4769.  
  4770. /*==========================================
  4771. *
  4772. *------------------------------------------*/
  4773. ACMD_FUNC(hidenpc)
  4774. {
  4775. char NPCname[NAME_LENGTH+1];
  4776. nullpo_retr(-1, sd);
  4777.  
  4778. memset(NPCname, '\0', sizeof(NPCname));
  4779.  
  4780. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4781. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4782. return -1;
  4783. }
  4784.  
  4785. if (npc_name2id(NPCname) == NULL) {
  4786. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4787. return -1;
  4788. }
  4789.  
  4790. npc_enable(NPCname, 0);
  4791. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4792. return 0;
  4793. }
  4794.  
  4795. ACMD_FUNC(loadnpc)
  4796. {
  4797. FILE *fp;
  4798.  
  4799. if (!message || !*message) {
  4800. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4801. return -1;
  4802. }
  4803.  
  4804. // check if script file exists
  4805. if ((fp = fopen(message, "r")) == NULL) {
  4806. clif_displaymessage(fd, msg_txt(261));
  4807. return -1;
  4808. }
  4809. fclose(fp);
  4810.  
  4811. // add to list of script sources and run it
  4812. npc_addsrcfile(message);
  4813. npc_parsesrcfile(message);
  4814. npc_read_event_script();
  4815.  
  4816. clif_displaymessage(fd, msg_txt(262));
  4817.  
  4818. return 0;
  4819. }
  4820.  
  4821. ACMD_FUNC(unloadnpc)
  4822. {
  4823. struct npc_data *nd;
  4824. char NPCname[NAME_LENGTH+1];
  4825. nullpo_retr(-1, sd);
  4826.  
  4827. memset(NPCname, '\0', sizeof(NPCname));
  4828.  
  4829. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  4830. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4831. return -1;
  4832. }
  4833.  
  4834. if ((nd = npc_name2id(NPCname)) == NULL) {
  4835. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4836. return -1;
  4837. }
  4838.  
  4839. npc_unload_duplicates(nd);
  4840. npc_unload(nd);
  4841. npc_read_event_script();
  4842. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4843. return 0;
  4844. }
  4845.  
  4846. /*==========================================
  4847. * time in txt for time command (by [Yor])
  4848. *------------------------------------------*/
  4849. char* txt_time(unsigned int duration)
  4850. {
  4851. int days, hours, minutes, seconds;
  4852. char temp[CHAT_SIZE_MAX];
  4853. static char temp1[CHAT_SIZE_MAX];
  4854.  
  4855. memset(temp, '\0', sizeof(temp));
  4856. memset(temp1, '\0', sizeof(temp1));
  4857.  
  4858. days = duration / (60 * 60 * 24);
  4859. duration = duration - (60 * 60 * 24 * days);
  4860. hours = duration / (60 * 60);
  4861. duration = duration - (60 * 60 * hours);
  4862. minutes = duration / 60;
  4863. seconds = duration - (60 * minutes);
  4864.  
  4865. if (days < 2)
  4866. sprintf(temp, msg_txt(219), days); // %d day
  4867. else
  4868. sprintf(temp, msg_txt(220), days); // %d days
  4869. if (hours < 2)
  4870. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4871. else
  4872. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4873. if (minutes < 2)
  4874. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4875. else
  4876. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4877. if (seconds < 2)
  4878. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4879. else
  4880. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4881.  
  4882. return temp1;
  4883. }
  4884.  
  4885. /*==========================================
  4886. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4887. * Calculation management of GM modification (@day/@night GM commands) is done
  4888. *------------------------------------------*/
  4889. ACMD_FUNC(servertime)
  4890. {
  4891. const struct TimerData * timer_data;
  4892. const struct TimerData * timer_data2;
  4893. time_t time_server; // variable for number of seconds (used with time() function)
  4894. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4895. char temp[CHAT_SIZE_MAX];
  4896. nullpo_retr(-1, sd);
  4897.  
  4898. memset(temp, '\0', sizeof(temp));
  4899.  
  4900. time(&time_server); // get time in seconds since 1/1/1970
  4901. datetime = localtime(&time_server); // convert seconds in structure
  4902. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4903. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4904. clif_displaymessage(fd, temp);
  4905.  
  4906. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4907. if (night_flag == 0)
  4908. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4909. else
  4910. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4911. } else if (battle_config.night_duration == 0)
  4912. if (night_flag == 1) { // we start with night
  4913. timer_data = get_timer(day_timer_tid);
  4914. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4915. clif_displaymessage(fd, temp);
  4916. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4917. } else
  4918. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4919. else if (battle_config.day_duration == 0)
  4920. if (night_flag == 0) { // we start with day
  4921. timer_data = get_timer(night_timer_tid);
  4922. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4923. clif_displaymessage(fd, temp);
  4924. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4925. } else
  4926. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4927. else {
  4928. if (night_flag == 0) {
  4929. timer_data = get_timer(night_timer_tid);
  4930. timer_data2 = get_timer(day_timer_tid);
  4931. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4932. clif_displaymessage(fd, temp);
  4933. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4934. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  4935. else
  4936. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  4937. clif_displaymessage(fd, temp);
  4938. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4939. clif_displaymessage(fd, temp);
  4940. } else {
  4941. timer_data = get_timer(day_timer_tid);
  4942. timer_data2 = get_timer(night_timer_tid);
  4943. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4944. clif_displaymessage(fd, temp);
  4945. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4946. sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  4947. else
  4948. sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  4949. clif_displaymessage(fd, temp);
  4950. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4951. clif_displaymessage(fd, temp);
  4952. }
  4953. }
  4954.  
  4955. return 0;
  4956. }
  4957.  
  4958. //Added by Coltaro
  4959. //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...).
  4960. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4961. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4962. {
  4963. const int factor_year = 518400; //12*30*24*60 = 518400
  4964. const int factor_month = 43200; //30*24*60 = 43200
  4965. const int factor_day = 1440; //24*60 = 1440
  4966. const int factor_hour = 60;
  4967.  
  4968. *year = jailtime/factor_year;
  4969. jailtime -= *year*factor_year;
  4970. *month = jailtime/factor_month;
  4971. jailtime -= *month*factor_month;
  4972. *day = jailtime/factor_day;
  4973. jailtime -= *day*factor_day;
  4974. *hour = jailtime/factor_hour;
  4975. jailtime -= *hour*factor_hour;
  4976. *minute = jailtime;
  4977.  
  4978. *year = *year > 0? *year : 0;
  4979. *month = *month > 0? *month : 0;
  4980. *day = *day > 0? *day : 0;
  4981. *hour = *hour > 0? *hour : 0;
  4982. *minute = *minute > 0? *minute : 0;
  4983. return;
  4984. }
  4985.  
  4986. /*==========================================
  4987. * @jail <char_name> by [Yor]
  4988. * Special warp! No check with nowarp and nowarpto flag
  4989. *------------------------------------------*/
  4990. ACMD_FUNC(jail)
  4991. {
  4992. struct map_session_data *pl_sd;
  4993. int x, y;
  4994. unsigned short m_index;
  4995. nullpo_retr(-1, sd);
  4996.  
  4997. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4998.  
  4999. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5000. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5001. return -1;
  5002. }
  5003.  
  5004. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5005. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5006. return -1;
  5007. }
  5008.  
  5009. if (pc_isGM(sd) < pc_isGM(pl_sd))
  5010. { // you can jail only lower or same GM
  5011. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5012. return -1;
  5013. }
  5014.  
  5015. if (pl_sd->sc.data[SC_JAILED])
  5016. {
  5017. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5018. return -1;
  5019. }
  5020.  
  5021. switch(rand() % 2) { //Jail Locations
  5022. case 0:
  5023. m_index = mapindex_name2id(MAP_JAIL);
  5024. x = 24;
  5025. y = 75;
  5026. break;
  5027. default:
  5028. m_index = mapindex_name2id(MAP_JAIL);
  5029. x = 49;
  5030. y = 75;
  5031. break;
  5032. }
  5033.  
  5034. //Duration of INT_MAX to specify infinity.
  5035. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  5036. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  5037. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5038. return 0;
  5039. }
  5040.  
  5041. /*==========================================
  5042. * @unjail/@discharge <char_name> by [Yor]
  5043. * Special warp! No check with nowarp and nowarpto flag
  5044. *------------------------------------------*/
  5045. ACMD_FUNC(unjail)
  5046. {
  5047. struct map_session_data *pl_sd;
  5048.  
  5049. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5050.  
  5051. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5052. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5053. return -1;
  5054. }
  5055.  
  5056. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5057. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5058. return -1;
  5059. }
  5060.  
  5061. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5062.  
  5063. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5064. return -1;
  5065. }
  5066.  
  5067. if (!pl_sd->sc.data[SC_JAILED])
  5068. {
  5069. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  5070. return -1;
  5071. }
  5072.  
  5073. //Reset jail time to 1 sec.
  5074. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  5075. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  5076. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  5077. return 0;
  5078. }
  5079.  
  5080. ACMD_FUNC(jailfor)
  5081. {
  5082. struct map_session_data *pl_sd = NULL;
  5083. int year, month, day, hour, minute, value;
  5084. char * modif_p;
  5085. int jailtime = 0,x,y;
  5086. short m_index = 0;
  5087. nullpo_retr(-1, sd);
  5088.  
  5089. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  5090. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  5091. return -1;
  5092. }
  5093.  
  5094. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  5095.  
  5096. modif_p = atcmd_output;
  5097. year = month = day = hour = minute = 0;
  5098. while (modif_p[0] != '\0') {
  5099. value = atoi(modif_p);
  5100. if (value == 0)
  5101. modif_p++;
  5102. else {
  5103. if (modif_p[0] == '-' || modif_p[0] == '+')
  5104. modif_p++;
  5105. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  5106. modif_p++;
  5107. if (modif_p[0] == 'n') {
  5108. minute = value;
  5109. modif_p++;
  5110. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  5111. minute = value;
  5112. modif_p = modif_p + 2;
  5113. } else if (modif_p[0] == 'h') {
  5114. hour = value;
  5115. modif_p++;
  5116. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  5117. day = value;
  5118. modif_p++;
  5119. } else if (modif_p[0] == 'm') {
  5120. month = value;
  5121. modif_p++;
  5122. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  5123. year = value;
  5124. modif_p++;
  5125. } else if (modif_p[0] != '\0') {
  5126. modif_p++;
  5127. }
  5128. }
  5129. }
  5130.  
  5131. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  5132. clif_displaymessage(fd, "Invalid time for jail command.");
  5133. return -1;
  5134. }
  5135.  
  5136. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5137. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5138. return -1;
  5139. }
  5140.  
  5141. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  5142. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5143. return -1;
  5144. }
  5145.  
  5146. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  5147.  
  5148. if(jailtime==0) {
  5149. clif_displaymessage(fd, "Invalid time for jail command.");
  5150. return -1;
  5151. }
  5152.  
  5153. //Added by Coltaro
  5154. if(pl_sd->sc.data[SC_JAILED] &&
  5155. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  5156. { //Update the player's jail time
  5157. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  5158. if (jailtime <= 0) {
  5159. jailtime = 0;
  5160. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5161. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  5162. } else {
  5163. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  5164. sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  5165. clif_displaymessage(pl_sd->fd, atcmd_output);
  5166. sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  5167. clif_displaymessage(fd, atcmd_output);
  5168. }
  5169. } else if (jailtime < 0) {
  5170. clif_displaymessage(fd, "Invalid time for jail command.");
  5171. return -1;
  5172. }
  5173.  
  5174. //Jail locations, add more as you wish.
  5175. switch(rand()%2)
  5176. {
  5177. case 1: //Jail #1
  5178. m_index = mapindex_name2id(MAP_JAIL);
  5179. x = 49; y = 75;
  5180. break;
  5181. default: //Default Jail
  5182. m_index = mapindex_name2id(MAP_JAIL);
  5183. x = 24; y = 75;
  5184. break;
  5185. }
  5186.  
  5187. sc_start4(&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).
  5188. return 0;
  5189. }
  5190.  
  5191.  
  5192. //By Coltaro
  5193. ACMD_FUNC(jailtime)
  5194. {
  5195. int year, month, day, hour, minute;
  5196.  
  5197. nullpo_retr(-1, sd);
  5198.  
  5199. if (!sd->sc.data[SC_JAILED]) {
  5200. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  5201. return -1;
  5202. }
  5203.  
  5204. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  5205. clif_displaymessage(fd, "You have been jailed indefinitely.");
  5206. return 0;
  5207. }
  5208.  
  5209. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  5210. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  5211. return -1;
  5212. }
  5213.  
  5214. //Get remaining jail time
  5215. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  5216. sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  5217.  
  5218. clif_displaymessage(fd, atcmd_output);
  5219.  
  5220. return 0;
  5221. }
  5222.  
  5223. /*==========================================
  5224. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5225. *------------------------------------------*/
  5226. ACMD_FUNC(disguise)
  5227. {
  5228. int id = 0;
  5229. nullpo_retr(-1, sd);
  5230.  
  5231. if (!message || !*message) {
  5232. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5233. return -1;
  5234. }
  5235.  
  5236. if ((id = atoi(message)) > 0)
  5237. { //Acquired an ID
  5238. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5239. id = 0; //Invalid id for either mobs or npcs.
  5240. } else { //Acquired a Name
  5241. if ((id = mobdb_searchname(message)) == 0)
  5242. {
  5243. struct npc_data* nd = npc_name2id(message);
  5244. if (nd != NULL)
  5245. id = nd->class_;
  5246. }
  5247. }
  5248.  
  5249. if (id == 0)
  5250. {
  5251. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  5252. return -1;
  5253. }
  5254.  
  5255. if(pc_isriding(sd))
  5256. {
  5257. //FIXME: wrong message [ultramage]
  5258. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  5259. return -1;
  5260. }
  5261.  
  5262. pc_disguise(sd, id);
  5263. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5264.  
  5265. return 0;
  5266. }
  5267.  
  5268. /*==========================================
  5269. * DisguiseAll
  5270. *------------------------------------------*/
  5271. ACMD_FUNC(disguiseall)
  5272. {
  5273. int mob_id=0;
  5274. struct map_session_data *pl_sd;
  5275. struct s_mapiterator* iter;
  5276. nullpo_retr(-1, sd);
  5277.  
  5278. if (!message || !*message) {
  5279. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  5280. return -1;
  5281. }
  5282.  
  5283. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5284. mob_id = atoi(message);
  5285.  
  5286. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  5287. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  5288. return -1;
  5289. }
  5290.  
  5291. iter = mapit_getallusers();
  5292. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  5293. pc_disguise(pl_sd, mob_id);
  5294. mapit_free(iter);
  5295.  
  5296. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5297. return 0;
  5298. }
  5299.  
  5300. /*==========================================
  5301. * @undisguise by [Yor]
  5302. *------------------------------------------*/
  5303. ACMD_FUNC(undisguise)
  5304. {
  5305. nullpo_retr(-1, sd);
  5306. if (sd->disguise) {
  5307. pc_disguise(sd, 0);
  5308. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5309. } else {
  5310. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  5311. return -1;
  5312. }
  5313.  
  5314. return 0;
  5315. }
  5316.  
  5317. /*==========================================
  5318. * UndisguiseAll
  5319. *------------------------------------------*/
  5320. ACMD_FUNC(undisguiseall)
  5321. {
  5322. struct map_session_data *pl_sd;
  5323. struct s_mapiterator* iter;
  5324. nullpo_retr(-1, sd);
  5325.  
  5326. iter = mapit_getallusers();
  5327. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  5328. if( pl_sd->disguise )
  5329. pc_disguise(pl_sd, 0);
  5330. mapit_free(iter);
  5331.  
  5332. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5333.  
  5334. return 0;
  5335. }
  5336.  
  5337. /*==========================================
  5338. * @exp by [Skotlex]
  5339. *------------------------------------------*/
  5340. ACMD_FUNC(exp)
  5341. {
  5342. char output[CHAT_SIZE_MAX];
  5343. double nextb, nextj;
  5344. nullpo_retr(-1, sd);
  5345. memset(output, '\0', sizeof(output));
  5346.  
  5347. nextb = pc_nextbaseexp(sd);
  5348. if (nextb)
  5349. nextb = sd->status.base_exp*100.0/nextb;
  5350.  
  5351. nextj = pc_nextjobexp(sd);
  5352. if (nextj)
  5353. nextj = sd->status.job_exp*100.0/nextj;
  5354.  
  5355. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5356. clif_displaymessage(fd, output);
  5357. return 0;
  5358. }
  5359.  
  5360.  
  5361. /*==========================================
  5362. * @broadcast by [Valaris]
  5363. *------------------------------------------*/
  5364. ACMD_FUNC(broadcast)
  5365. {
  5366. nullpo_retr(-1, sd);
  5367.  
  5368. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5369.  
  5370. if (!message || !*message) {
  5371. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5372. return -1;
  5373. }
  5374.  
  5375. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  5376. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  5377.  
  5378. return 0;
  5379. }
  5380.  
  5381. /*==========================================
  5382. * @localbroadcast by [Valaris]
  5383. *------------------------------------------*/
  5384. ACMD_FUNC(localbroadcast)
  5385. {
  5386. nullpo_retr(-1, sd);
  5387.  
  5388. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5389.  
  5390. if (!message || !*message) {
  5391. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5392. return -1;
  5393. }
  5394.  
  5395. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  5396.  
  5397. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  5398.  
  5399. return 0;
  5400. }
  5401.  
  5402. /*==========================================
  5403. * @email <actual@email> <new@email> by [Yor]
  5404. *------------------------------------------*/
  5405. ACMD_FUNC(email)
  5406. {
  5407. char actual_email[100];
  5408. char new_email[100];
  5409. nullpo_retr(-1, sd);
  5410.  
  5411. memset(actual_email, '\0', sizeof(actual_email));
  5412. memset(new_email, '\0', sizeof(new_email));
  5413.  
  5414. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5415. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5416. return -1;
  5417. }
  5418.  
  5419. if (e_mail_check(actual_email) == 0) {
  5420. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give [email protected].
  5421. return -1;
  5422. } else if (e_mail_check(new_email) == 0) {
  5423. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  5424. return -1;
  5425. } else if (strcmpi(new_email, "[email protected]") == 0) {
  5426. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  5427. return -1;
  5428. } else if (strcmpi(actual_email, new_email) == 0) {
  5429. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  5430. return -1;
  5431. }
  5432.  
  5433. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5434. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  5435. return 0;
  5436. }
  5437.  
  5438. /*==========================================
  5439. *@effect
  5440. *------------------------------------------*/
  5441. ACMD_FUNC(effect)
  5442. {
  5443. int type = 0, flag = 0;
  5444. nullpo_retr(-1, sd);
  5445.  
  5446. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  5447. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  5448. return -1;
  5449. }
  5450.  
  5451. clif_specialeffect(&sd->bl, type, (send_target)flag);
  5452. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  5453. return 0;
  5454. }
  5455.  
  5456. /*==========================================
  5457. * @killer by MouseJstr
  5458. * enable killing players even when not in pvp
  5459. *------------------------------------------*/
  5460. ACMD_FUNC(killer)
  5461. {
  5462. nullpo_retr(-1, sd);
  5463. sd->state.killer = !sd->state.killer;
  5464.  
  5465. if(sd->state.killer)
  5466. clif_displaymessage(fd, msg_txt(241));
  5467. else {
  5468. clif_displaymessage(fd, msg_txt(287));
  5469. pc_stop_attack(sd);
  5470. }
  5471. return 0;
  5472. }
  5473.  
  5474. /*==========================================
  5475. * @killable by MouseJstr
  5476. * enable other people killing you
  5477. *------------------------------------------*/
  5478. ACMD_FUNC(killable)
  5479. {
  5480. nullpo_retr(-1, sd);
  5481. sd->state.killable = !sd->state.killable;
  5482.  
  5483. if(sd->state.killable)
  5484. clif_displaymessage(fd, msg_txt(242));
  5485. else {
  5486. clif_displaymessage(fd, msg_txt(288));
  5487. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  5488. }
  5489. return 0;
  5490. }
  5491.  
  5492. /*==========================================
  5493. * @skillon by MouseJstr
  5494. * turn skills on for the map
  5495. *------------------------------------------*/
  5496. ACMD_FUNC(skillon)
  5497. {
  5498. nullpo_retr(-1, sd);
  5499. map[sd->bl.m].flag.noskill = 0;
  5500. clif_displaymessage(fd, msg_txt(244));
  5501. return 0;
  5502. }
  5503.  
  5504. /*==========================================
  5505. * @skilloff by MouseJstr
  5506. * Turn skills off on the map
  5507. *------------------------------------------*/
  5508. ACMD_FUNC(skilloff)
  5509. {
  5510. nullpo_retr(-1, sd);
  5511. map[sd->bl.m].flag.noskill = 1;
  5512. clif_displaymessage(fd, msg_txt(243));
  5513. return 0;
  5514. }
  5515.  
  5516. /*==========================================
  5517. * @npcmove by MouseJstr
  5518. * move a npc
  5519. *------------------------------------------*/
  5520. ACMD_FUNC(npcmove)
  5521. {
  5522. int x = 0, y = 0, m;
  5523. struct npc_data *nd = 0;
  5524. nullpo_retr(-1, sd);
  5525. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  5526.  
  5527. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  5528. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  5529. return -1;
  5530. }
  5531.  
  5532. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  5533. {
  5534. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5535. return -1;
  5536. }
  5537.  
  5538. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  5539. {
  5540. clif_displaymessage(fd, "NPC is not on this map.");
  5541. return -1; //Not on a map.
  5542. }
  5543.  
  5544. x = cap_value(x, 0, map[m].xs-1);
  5545. y = cap_value(y, 0, map[m].ys-1);
  5546. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  5547. map_moveblock(&nd->bl, x, y, gettick());
  5548. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  5549. clif_displaymessage(fd, "NPC moved.");
  5550.  
  5551. return 0;
  5552. }
  5553.  
  5554. /*==========================================
  5555. * @addwarp by MouseJstr
  5556. * Create a new static warp point.
  5557. *------------------------------------------*/
  5558. ACMD_FUNC(addwarp)
  5559. {
  5560. char mapname[32];
  5561. int x,y;
  5562. unsigned short m;
  5563. struct npc_data* nd;
  5564.  
  5565. nullpo_retr(-1, sd);
  5566.  
  5567. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  5568. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  5569. return -1;
  5570. }
  5571.  
  5572. m = mapindex_name2id(mapname);
  5573. if( m == 0 )
  5574. {
  5575. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  5576. clif_displaymessage(fd, atcmd_output);
  5577. return -1;
  5578. }
  5579.  
  5580. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  5581. if( nd == NULL )
  5582. return -1;
  5583.  
  5584. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  5585. clif_displaymessage(fd, atcmd_output);
  5586. return 0;
  5587. }
  5588.  
  5589. /*==========================================
  5590. * @follow by [MouseJstr]
  5591. * Follow a player .. staying no more then 5 spaces away
  5592. *------------------------------------------*/
  5593. ACMD_FUNC(follow)
  5594. {
  5595. struct map_session_data *pl_sd = NULL;
  5596. nullpo_retr(-1, sd);
  5597.  
  5598. if (!message || !*message) {
  5599. if (sd->followtarget == -1)
  5600. return -1;
  5601.  
  5602. pc_stop_following (sd);
  5603. clif_displaymessage(fd, "Follow mode OFF.");
  5604. return 0;
  5605. }
  5606.  
  5607. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5608. {
  5609. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5610. return -1;
  5611. }
  5612.  
  5613. if (sd->followtarget == pl_sd->bl.id) {
  5614. pc_stop_following (sd);
  5615. clif_displaymessage(fd, "Follow mode OFF.");
  5616. } else {
  5617. pc_follow(sd, pl_sd->bl.id);
  5618. clif_displaymessage(fd, "Follow mode ON.");
  5619. }
  5620.  
  5621. return 0;
  5622. }
  5623.  
  5624.  
  5625. /*==========================================
  5626. * @dropall by [MouseJstr]
  5627. * Drop all your possession on the ground
  5628. *------------------------------------------*/
  5629. ACMD_FUNC(dropall)
  5630. {
  5631. int i;
  5632. nullpo_retr(-1, sd);
  5633. for (i = 0; i < MAX_INVENTORY; i++) {
  5634. if (sd->status.inventory[i].amount) {
  5635. if(sd->status.inventory[i].equip != 0)
  5636. pc_unequipitem(sd, i, 3);
  5637. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  5638. }
  5639. }
  5640. return 0;
  5641. }
  5642.  
  5643. /*==========================================
  5644. * @storeall by [MouseJstr]
  5645. * Put everything into storage
  5646. *------------------------------------------*/
  5647. ACMD_FUNC(storeall)
  5648. {
  5649. int i;
  5650. nullpo_retr(-1, sd);
  5651.  
  5652. if (sd->state.storage_flag != 1)
  5653. { //Open storage.
  5654. if( storage_storageopen(sd) == 1 ) {
  5655. clif_displaymessage(fd, "You can't open the storage currently.");
  5656. return -1;
  5657. }
  5658. }
  5659.  
  5660. for (i = 0; i < MAX_INVENTORY; i++) {
  5661. if (sd->status.inventory[i].amount) {
  5662. if(sd->status.inventory[i].equip != 0)
  5663. pc_unequipitem(sd, i, 3);
  5664. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  5665. }
  5666. }
  5667. storage_storageclose(sd);
  5668.  
  5669. clif_displaymessage(fd, "It is done");
  5670. return 0;
  5671. }
  5672.  
  5673. /*==========================================
  5674. * @skillid by [MouseJstr]
  5675. * lookup a skill by name
  5676. *------------------------------------------*/
  5677. ACMD_FUNC(skillid)
  5678. {
  5679. int skillen, idx;
  5680. nullpo_retr(-1, sd);
  5681.  
  5682. if (!message || !*message)
  5683. {
  5684. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  5685. return -1;
  5686. }
  5687.  
  5688. skillen = strlen(message);
  5689.  
  5690. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  5691. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  5692. {
  5693. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  5694. clif_displaymessage(fd, atcmd_output);
  5695. }
  5696. }
  5697.  
  5698. return 0;
  5699. }
  5700.  
  5701. /*==========================================
  5702. * @useskill by [MouseJstr]
  5703. * A way of using skills without having to find them in the skills menu
  5704. *------------------------------------------*/
  5705. ACMD_FUNC(useskill)
  5706. {
  5707. struct map_session_data *pl_sd = NULL;
  5708. struct block_list *bl;
  5709. int skillnum;
  5710. int skilllv;
  5711. char target[100];
  5712. nullpo_retr(-1, sd);
  5713.  
  5714. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  5715. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  5716. return -1;
  5717. }
  5718.  
  5719. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5720. {
  5721. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5722. return -1;
  5723. }
  5724.  
  5725. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5726. {
  5727. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5728. return -1;
  5729. }
  5730.  
  5731. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  5732. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5733. bl = &sd->hd->bl;
  5734. else
  5735. bl = &sd->bl;
  5736.  
  5737. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  5738. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  5739. else
  5740. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  5741.  
  5742. return 0;
  5743. }
  5744.  
  5745. /*==========================================
  5746. * @displayskill by [Skotlex]
  5747. * Debug command to locate new skill IDs. It sends the
  5748. * three possible skill-effect packets to the area.
  5749. *------------------------------------------*/
  5750. ACMD_FUNC(displayskill)
  5751. {
  5752. struct status_data * status;
  5753. unsigned int tick;
  5754. int skillnum;
  5755. int skilllv = 1;
  5756. nullpo_retr(-1, sd);
  5757.  
  5758. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  5759. {
  5760. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  5761. return -1;
  5762. }
  5763. status = status_get_status_data(&sd->bl);
  5764. tick = gettick();
  5765. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  5766. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  5767. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  5768. return 0;
  5769. }
  5770.  
  5771. /*==========================================
  5772. * @skilltree by [MouseJstr]
  5773. * prints the skill tree for a player required to get to a skill
  5774. *------------------------------------------*/
  5775. ACMD_FUNC(skilltree)
  5776. {
  5777. struct map_session_data *pl_sd = NULL;
  5778. int skillnum;
  5779. int meets, j, c=0;
  5780. char target[NAME_LENGTH];
  5781. struct skill_tree_entry *ent;
  5782. nullpo_retr(-1, sd);
  5783.  
  5784. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  5785. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  5786. return -1;
  5787. }
  5788.  
  5789. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5790. {
  5791. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5792. return -1;
  5793. }
  5794.  
  5795. c = pc_calc_skilltree_normalize_job(pl_sd);
  5796. c = pc_mapid2jobid(c, pl_sd->status.sex);
  5797.  
  5798. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", job_name(c), pc_checkskill(pl_sd, NV_BASIC));
  5799. clif_displaymessage(fd, atcmd_output);
  5800.  
  5801. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  5802. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  5803. {
  5804. sprintf(atcmd_output, "I do not believe the player can use that skill");
  5805. clif_displaymessage(fd, atcmd_output);
  5806. return 0;
  5807. }
  5808.  
  5809. ent = &skill_tree[c][j];
  5810.  
  5811. meets = 1;
  5812. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  5813. {
  5814. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  5815. {
  5816. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  5817. clif_displaymessage(fd, atcmd_output);
  5818. meets = 0;
  5819. }
  5820. }
  5821. if (meets == 1) {
  5822. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  5823. clif_displaymessage(fd, atcmd_output);
  5824. }
  5825.  
  5826. return 0;
  5827. }
  5828.  
  5829. // Hand a ring with partners name on it to this char
  5830. void getring (struct map_session_data* sd)
  5831. {
  5832. int flag, item_id;
  5833. struct item item_tmp;
  5834. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5835.  
  5836. memset(&item_tmp, 0, sizeof(item_tmp));
  5837. item_tmp.nameid = item_id;
  5838. item_tmp.identify = 1;
  5839. item_tmp.card[0] = 255;
  5840. item_tmp.card[2] = sd->status.partner_id;
  5841. item_tmp.card[3] = sd->status.partner_id >> 16;
  5842.  
  5843. //Logs (A)dmins items [Lupus]
  5844. log_pick(&sd->bl, LOG_TYPE_COMMAND, item_id, 1, &item_tmp);
  5845.  
  5846. if((flag = pc_additem(sd,&item_tmp,1))) {
  5847. clif_additem(sd,0,0,flag);
  5848. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  5849. }
  5850. }
  5851.  
  5852. /*==========================================
  5853. * @marry by [MouseJstr], fixed by Lupus
  5854. * Marry two players
  5855. *------------------------------------------*/
  5856. ACMD_FUNC(marry)
  5857. {
  5858. struct map_session_data *pl_sd1 = NULL;
  5859. struct map_session_data *pl_sd2 = NULL;
  5860. char player1[128], player2[128]; //Length used for return error msgs
  5861.  
  5862. nullpo_retr(-1, sd);
  5863.  
  5864. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  5865. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  5866. return -1;
  5867. }
  5868.  
  5869. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  5870. sprintf(player2, "Cannot find player '%s' online", player1);
  5871. clif_displaymessage(fd, player2);
  5872. return -1;
  5873. }
  5874.  
  5875. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  5876. sprintf(player1, "Cannot find player '%s' online", player2);
  5877. clif_displaymessage(fd, player1);
  5878. return -1;
  5879. }
  5880.  
  5881. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  5882. clif_displaymessage(fd, "They are married.. wish them well");
  5883. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  5884. // Auto-give named rings (Aru)
  5885. getring (pl_sd1);
  5886. getring (pl_sd2);
  5887. return 0;
  5888. }
  5889.  
  5890. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  5891. return -1;
  5892. }
  5893.  
  5894. /*==========================================
  5895. * @divorce by [MouseJstr], fixed by [Lupus]
  5896. * divorce two players
  5897. *------------------------------------------*/
  5898. ACMD_FUNC(divorce)
  5899. {
  5900. struct map_session_data *pl_sd = NULL;
  5901.  
  5902. nullpo_retr(-1, sd);
  5903.  
  5904. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  5905. clif_displaymessage(fd, "Usage: @divorce <player>.");
  5906. return -1;
  5907. }
  5908.  
  5909. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5910. {
  5911. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5912. return -1;
  5913. }
  5914.  
  5915. if (pc_divorce(pl_sd) != 0) {
  5916. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5917. clif_displaymessage(fd, atcmd_output);
  5918. return -1;
  5919. }
  5920.  
  5921. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5922. clif_displaymessage(fd, atcmd_output);
  5923. return 0;
  5924. }
  5925.  
  5926. /*==========================================
  5927. * @changelook by [Celest]
  5928. *------------------------------------------*/
  5929. ACMD_FUNC(changelook)
  5930. {
  5931. int i, j = 0, k = 0;
  5932. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5933.  
  5934. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5935. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5936. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5937. return -1;
  5938. } else if (i == 2) {
  5939. if (j < 1) j = 1;
  5940. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5941. j = pos[j - 1];
  5942. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5943. k = j; // swap
  5944. j = LOOK_HEAD_TOP;
  5945. }
  5946.  
  5947. clif_changelook(&sd->bl,j,k);
  5948.  
  5949. return 0;
  5950. }
  5951.  
  5952. /*==========================================
  5953. * @autotrade by durf [Lupus] [Paradox924X]
  5954. * Turns on/off Autotrade for a specific player
  5955. *------------------------------------------*/
  5956. ACMD_FUNC(autotrade)
  5957. {
  5958. nullpo_retr(-1, sd);
  5959.  
  5960. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  5961. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  5962. return -1;
  5963. }
  5964.  
  5965. if( pc_isdead(sd) ) {
  5966. clif_displaymessage(fd, "Cannot Autotrade if you are dead.");
  5967. return -1;
  5968. }
  5969.  
  5970. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5971. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  5972. return -1;
  5973. }
  5974.  
  5975. sd->state.autotrade = 1;
  5976. if( battle_config.at_timeout )
  5977. {
  5978. int timeout = atoi(message);
  5979. status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  5980. }
  5981. clif_authfail_fd(fd, 15);
  5982.  
  5983. return 0;
  5984. }
  5985.  
  5986. /*==========================================
  5987. * @changegm by durf (changed by Lupus)
  5988. * Changes Master of your Guild to a specified guild member
  5989. *------------------------------------------*/
  5990. ACMD_FUNC(changegm)
  5991. {
  5992. struct guild *g;
  5993. struct map_session_data *pl_sd;
  5994. nullpo_retr(-1, sd);
  5995.  
  5996. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5997. {
  5998. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5999. return -1;
  6000. }
  6001.  
  6002. if( map[sd->bl.m].flag.guildlock )
  6003. {
  6004. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  6005. return -1;
  6006. }
  6007.  
  6008. if( !message[0] )
  6009. {
  6010. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6011. return -1;
  6012. }
  6013.  
  6014. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6015. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6016. return -1;
  6017. }
  6018.  
  6019. guild_gm_change(sd->status.guild_id, pl_sd);
  6020. return 0;
  6021. }
  6022.  
  6023. /*==========================================
  6024. * @changeleader by Skotlex
  6025. * Changes the leader of a party.
  6026. *------------------------------------------*/
  6027. ACMD_FUNC(changeleader)
  6028. {
  6029. nullpo_retr(-1, sd);
  6030.  
  6031. if( !message[0] )
  6032. {
  6033. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6034. return -1;
  6035. }
  6036.  
  6037. if (party_changeleader(sd, map_nick2sd((char *) message)))
  6038. return 0;
  6039. return -1;
  6040. }
  6041.  
  6042. /*==========================================
  6043. * @partyoption by Skotlex
  6044. * Used to change the item share setting of a party.
  6045. *------------------------------------------*/
  6046. ACMD_FUNC(partyoption)
  6047. {
  6048. struct party_data *p;
  6049. int mi, option;
  6050. char w1[16], w2[16];
  6051. nullpo_retr(-1, sd);
  6052.  
  6053. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6054. {
  6055. clif_displaymessage(fd, msg_txt(282));
  6056. return -1;
  6057. }
  6058.  
  6059. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  6060. if (mi == MAX_PARTY)
  6061. return -1; //Shouldn't happen
  6062.  
  6063. if (!p->party.member[mi].leader)
  6064. {
  6065. clif_displaymessage(fd, msg_txt(282));
  6066. return -1;
  6067. }
  6068.  
  6069. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  6070. {
  6071. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  6072. return -1;
  6073. }
  6074.  
  6075. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  6076.  
  6077. //Change item share type.
  6078. if (option != p->party.item)
  6079. party_changeoption(sd, p->party.exp, option);
  6080. else
  6081. clif_displaymessage(fd, msg_txt(286));
  6082.  
  6083. return 0;
  6084. }
  6085.  
  6086. /*==========================================
  6087. * @autoloot by Upa-Kun
  6088. * Turns on/off AutoLoot for a specific player
  6089. *------------------------------------------*/
  6090. ACMD_FUNC(autoloot)
  6091. {
  6092. int rate;
  6093. double drate;
  6094. nullpo_retr(-1, sd);
  6095. // autoloot command without value
  6096. if(!message || !*message)
  6097. {
  6098. if (sd->state.autoloot)
  6099. rate = 0;
  6100. else
  6101. rate = 10000;
  6102. } else {
  6103. drate = atof(message);
  6104. rate = (int)(drate*100);
  6105. }
  6106. if (rate < 0) rate = 0;
  6107. if (rate > 10000) rate = 10000;
  6108.  
  6109. sd->state.autoloot = rate;
  6110. if (sd->state.autoloot) {
  6111. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  6112. clif_displaymessage(fd, atcmd_output);
  6113. }else
  6114. clif_displaymessage(fd, "Autoloot is now off.");
  6115.  
  6116. return 0;
  6117. }
  6118.  
  6119. /*==========================================
  6120. * @alootid
  6121. *------------------------------------------*/
  6122. ACMD_FUNC(autolootitem)
  6123. {
  6124. struct item_data *item_data = NULL;
  6125.  
  6126. if (!message || !*message) {
  6127. if (sd->state.autolootid) {
  6128. sd->state.autolootid = 0;
  6129. clif_displaymessage(fd, "Autolootitem has been turned OFF.");
  6130. } else
  6131. clif_displaymessage(fd, "Please, enter item name or it's ID (usage: @alootid <item_name_or_ID>).");
  6132.  
  6133. return -1;
  6134. }
  6135.  
  6136. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  6137. item_data = itemdb_searchname(message);
  6138.  
  6139. if (!item_data) {
  6140. // No items founds in the DB with Id or Name
  6141. clif_displaymessage(fd, "Item not found.");
  6142. return -1;
  6143. }
  6144.  
  6145. sd->state.autolootid = item_data->nameid; // Autoloot Activated
  6146.  
  6147. sprintf(atcmd_output, "Autolooting item: '%s'/'%s' (%d)",
  6148. item_data->name, item_data->jname, item_data->nameid);
  6149. clif_displaymessage(fd, atcmd_output);
  6150.  
  6151. return 0;
  6152. }
  6153.  
  6154. /*==========================================
  6155. * It is made to rain.
  6156. *------------------------------------------*/
  6157. ACMD_FUNC(rain)
  6158. {
  6159. nullpo_retr(-1, sd);
  6160. if (map[sd->bl.m].flag.rain) {
  6161. map[sd->bl.m].flag.rain=0;
  6162. clif_weather(sd->bl.m);
  6163. clif_displaymessage(fd, "The rain has stopped.");
  6164. } else {
  6165. map[sd->bl.m].flag.rain=1;
  6166. clif_weather(sd->bl.m);
  6167. clif_displaymessage(fd, "It is made to rain.");
  6168. }
  6169. return 0;
  6170. }
  6171.  
  6172. /*==========================================
  6173. * It is made to snow.
  6174. *------------------------------------------*/
  6175. ACMD_FUNC(snow)
  6176. {
  6177. nullpo_retr(-1, sd);
  6178. if (map[sd->bl.m].flag.snow) {
  6179. map[sd->bl.m].flag.snow=0;
  6180. clif_weather(sd->bl.m);
  6181. clif_displaymessage(fd, "Snow has stopped falling.");
  6182. } else {
  6183. map[sd->bl.m].flag.snow=1;
  6184. clif_weather(sd->bl.m);
  6185. clif_displaymessage(fd, "It is made to snow.");
  6186. }
  6187.  
  6188. return 0;
  6189. }
  6190.  
  6191. /*==========================================
  6192. * Cherry tree snowstorm is made to fall. (Sakura)
  6193. *------------------------------------------*/
  6194. ACMD_FUNC(sakura)
  6195. {
  6196. nullpo_retr(-1, sd);
  6197. if (map[sd->bl.m].flag.sakura) {
  6198. map[sd->bl.m].flag.sakura=0;
  6199. clif_weather(sd->bl.m);
  6200. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6201. } else {
  6202. map[sd->bl.m].flag.sakura=1;
  6203. clif_weather(sd->bl.m);
  6204. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6205. }
  6206. return 0;
  6207. }
  6208.  
  6209. /*==========================================
  6210. * Clouds appear.
  6211. *------------------------------------------*/
  6212. ACMD_FUNC(clouds)
  6213. {
  6214. nullpo_retr(-1, sd);
  6215. if (map[sd->bl.m].flag.clouds) {
  6216. map[sd->bl.m].flag.clouds=0;
  6217. clif_weather(sd->bl.m);
  6218. clif_displaymessage(fd, "The clouds has disappear.");
  6219. } else {
  6220. map[sd->bl.m].flag.clouds=1;
  6221. clif_weather(sd->bl.m);
  6222. clif_displaymessage(fd, "Clouds appear.");
  6223. }
  6224.  
  6225. return 0;
  6226. }
  6227.  
  6228. /*==========================================
  6229. * Different type of clouds using effect 516
  6230. *------------------------------------------*/
  6231. ACMD_FUNC(clouds2)
  6232. {
  6233. nullpo_retr(-1, sd);
  6234. if (map[sd->bl.m].flag.clouds2) {
  6235. map[sd->bl.m].flag.clouds2=0;
  6236. clif_weather(sd->bl.m);
  6237. clif_displaymessage(fd, "The alternative clouds disappear.");
  6238. } else {
  6239. map[sd->bl.m].flag.clouds2=1;
  6240. clif_weather(sd->bl.m);
  6241. clif_displaymessage(fd, "Alternative clouds appear.");
  6242. }
  6243.  
  6244. return 0;
  6245. }
  6246.  
  6247. /*==========================================
  6248. * Fog hangs over.
  6249. *------------------------------------------*/
  6250. ACMD_FUNC(fog)
  6251. {
  6252. nullpo_retr(-1, sd);
  6253. if (map[sd->bl.m].flag.fog) {
  6254. map[sd->bl.m].flag.fog=0;
  6255. clif_weather(sd->bl.m);
  6256. clif_displaymessage(fd, "The fog has gone.");
  6257. } else {
  6258. map[sd->bl.m].flag.fog=1;
  6259. clif_weather(sd->bl.m);
  6260. clif_displaymessage(fd, "Fog hangs over.");
  6261. }
  6262. return 0;
  6263. }
  6264.  
  6265. /*==========================================
  6266. * Fallen leaves fall.
  6267. *------------------------------------------*/
  6268. ACMD_FUNC(leaves)
  6269. {
  6270. nullpo_retr(-1, sd);
  6271. if (map[sd->bl.m].flag.leaves) {
  6272. map[sd->bl.m].flag.leaves=0;
  6273. clif_weather(sd->bl.m);
  6274. clif_displaymessage(fd, "Leaves no longer fall.");
  6275. } else {
  6276. map[sd->bl.m].flag.leaves=1;
  6277. clif_weather(sd->bl.m);
  6278. clif_displaymessage(fd, "Fallen leaves fall.");
  6279. }
  6280.  
  6281. return 0;
  6282. }
  6283.  
  6284. /*==========================================
  6285. * Fireworks appear.
  6286. *------------------------------------------*/
  6287. ACMD_FUNC(fireworks)
  6288. {
  6289. nullpo_retr(-1, sd);
  6290. if (map[sd->bl.m].flag.fireworks) {
  6291. map[sd->bl.m].flag.fireworks=0;
  6292. clif_weather(sd->bl.m);
  6293. clif_displaymessage(fd, "Fireworks are ended.");
  6294. } else {
  6295. map[sd->bl.m].flag.fireworks=1;
  6296. clif_weather(sd->bl.m);
  6297. clif_displaymessage(fd, "Fireworks are launched.");
  6298. }
  6299.  
  6300. return 0;
  6301. }
  6302.  
  6303. /*==========================================
  6304. * Clearing Weather Effects by Dexity
  6305. *------------------------------------------*/
  6306. ACMD_FUNC(clearweather)
  6307. {
  6308. nullpo_retr(-1, sd);
  6309. map[sd->bl.m].flag.rain=0;
  6310. map[sd->bl.m].flag.snow=0;
  6311. map[sd->bl.m].flag.sakura=0;
  6312. map[sd->bl.m].flag.clouds=0;
  6313. map[sd->bl.m].flag.clouds2=0;
  6314. map[sd->bl.m].flag.fog=0;
  6315. map[sd->bl.m].flag.fireworks=0;
  6316. map[sd->bl.m].flag.leaves=0;
  6317. clif_weather(sd->bl.m);
  6318. clif_displaymessage(fd, msg_txt(291));
  6319.  
  6320. return 0;
  6321. }
  6322.  
  6323. /*===============================================================
  6324. * Sound Command - plays a sound for everyone around! [Codemaster]
  6325. *---------------------------------------------------------------*/
  6326. ACMD_FUNC(sound)
  6327. {
  6328. char sound_file[100];
  6329.  
  6330. memset(sound_file, '\0', sizeof(sound_file));
  6331.  
  6332. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6333. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6334. return -1;
  6335. }
  6336.  
  6337. if(strstr(sound_file, ".wav") == NULL)
  6338. strcat(sound_file, ".wav");
  6339.  
  6340. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  6341.  
  6342. return 0;
  6343. }
  6344.  
  6345. /*==========================================
  6346. * MOB Search
  6347. *------------------------------------------*/
  6348. ACMD_FUNC(mobsearch)
  6349. {
  6350. char mob_name[100];
  6351. int mob_id;
  6352. int number = 0;
  6353. struct s_mapiterator* it;
  6354.  
  6355. nullpo_retr(-1, sd);
  6356.  
  6357. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  6358. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  6359. return -1;
  6360. }
  6361.  
  6362. if ((mob_id = atoi(mob_name)) == 0)
  6363. mob_id = mobdb_searchname(mob_name);
  6364. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6365. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6366. clif_displaymessage(fd, atcmd_output);
  6367. return -1;
  6368. }
  6369. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6370. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6371. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6372.  
  6373. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  6374. clif_displaymessage(fd, atcmd_output);
  6375.  
  6376. it = mapit_geteachmob();
  6377. for(;;)
  6378. {
  6379. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6380. if( md == NULL )
  6381. break;// no more mobs
  6382.  
  6383. if( md->bl.m != sd->bl.m )
  6384. continue;
  6385. if( mob_id != -1 && md->class_ != mob_id )
  6386. continue;
  6387.  
  6388. ++number;
  6389. if( md->spawn_timer == INVALID_TIMER )
  6390. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  6391. else
  6392. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  6393. clif_displaymessage(fd, atcmd_output);
  6394. }
  6395. mapit_free(it);
  6396.  
  6397. return 0;
  6398. }
  6399.  
  6400. /*==========================================
  6401. * @cleanmap - cleans items on the ground
  6402. *------------------------------------------*/
  6403. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  6404. {
  6405. nullpo_ret(bl);
  6406. map_clearflooritem(bl->id);
  6407.  
  6408. return 0;
  6409. }
  6410.  
  6411. ACMD_FUNC(cleanmap)
  6412. {
  6413. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  6414. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  6415. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  6416. BL_ITEM);
  6417. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  6418. return 0;
  6419. }
  6420.  
  6421. /*==========================================
  6422. * make a NPC/PET talk
  6423. * @npctalkc [SnakeDrak]
  6424. *------------------------------------------*/
  6425. ACMD_FUNC(npctalk)
  6426. {
  6427. char name[NAME_LENGTH],mes[100],temp[100];
  6428. struct npc_data *nd;
  6429. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  6430. unsigned long color=0;
  6431.  
  6432. if (sd->sc.count && //no "chatting" while muted.
  6433. (sd->sc.data[SC_BERSERK] ||
  6434. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6435. return -1;
  6436.  
  6437. if(!ifcolor) {
  6438. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  6439. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  6440. return -1;
  6441. }
  6442. }
  6443. else {
  6444. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  6445. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalkc <color> <npc name>, <message>).");
  6446. return -1;
  6447. }
  6448. }
  6449.  
  6450. if (!(nd = npc_name2id(name))) {
  6451. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  6452. return -1;
  6453. }
  6454.  
  6455. strtok(name, "#"); // discard extra name identifier if present
  6456. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  6457.  
  6458. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  6459. else clif_message(&nd->bl, temp);
  6460.  
  6461. return 0;
  6462. }
  6463.  
  6464. ACMD_FUNC(pettalk)
  6465. {
  6466. char mes[100],temp[100];
  6467. struct pet_data *pd;
  6468.  
  6469. nullpo_retr(-1, sd);
  6470.  
  6471. if(!sd->status.pet_id || !(pd=sd->pd))
  6472. {
  6473. clif_displaymessage(fd, msg_txt(184));
  6474. return -1;
  6475. }
  6476.  
  6477. if (sd->sc.count && //no "chatting" while muted.
  6478. (sd->sc.data[SC_BERSERK] ||
  6479. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6480. return -1;
  6481.  
  6482. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6483. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  6484. return -1;
  6485. }
  6486.  
  6487. if (message[0] == '/')
  6488. {// pet emotion processing
  6489. const char* emo[] = {
  6490. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  6491. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  6492. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  6493. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  6494. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  6495. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  6496. };
  6497. int i;
  6498. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  6499. if( i < ARRAYLENGTH(emo) )
  6500. {
  6501. clif_emotion(&pd->bl, i);
  6502. return 0;
  6503. }
  6504. }
  6505.  
  6506. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  6507. clif_message(&pd->bl, temp);
  6508.  
  6509. return 0;
  6510. }
  6511.  
  6512. /// @users - displays the number of players present on each map (and percentage)
  6513. /// #users displays on the target user instead of self
  6514. ACMD_FUNC(users)
  6515. {
  6516. char buf[CHAT_SIZE_MAX];
  6517. int i;
  6518. int users[MAX_MAPINDEX];
  6519. int users_all;
  6520. struct s_mapiterator* iter;
  6521.  
  6522. memset(users, 0, sizeof(users));
  6523. users_all = 0;
  6524.  
  6525. // count users on each map
  6526. iter = mapit_getallusers();
  6527. for(;;)
  6528. {
  6529. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  6530. if( sd2 == NULL )
  6531. break;// no more users
  6532.  
  6533. if( sd2->mapindex >= MAX_MAPINDEX )
  6534. continue;// invalid mapindex
  6535.  
  6536. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  6537. if( users_all < INT_MAX ) ++users_all;
  6538. }
  6539. mapit_free(iter);
  6540.  
  6541. // display results for each map
  6542. for( i = 0; i < MAX_MAPINDEX; ++i )
  6543. {
  6544. if( users[i] == 0 )
  6545. continue;// empty
  6546.  
  6547. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  6548. clif_displaymessage(sd->fd, buf);
  6549. }
  6550.  
  6551. // display overall count
  6552. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  6553. clif_displaymessage(sd->fd, buf);
  6554.  
  6555. return 0;
  6556. }
  6557.  
  6558. /*==========================================
  6559. *
  6560. *------------------------------------------*/
  6561. ACMD_FUNC(reset)
  6562. {
  6563. pc_resetstate(sd);
  6564. pc_resetskill(sd,1);
  6565. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  6566. clif_displaymessage(fd, atcmd_output);
  6567. return 0;
  6568. }
  6569.  
  6570. /*==========================================
  6571. *
  6572. *------------------------------------------*/
  6573. ACMD_FUNC(summon)
  6574. {
  6575. char name[NAME_LENGTH];
  6576. int mob_id = 0;
  6577. int duration = 0;
  6578. struct mob_data *md;
  6579. unsigned int tick=gettick();
  6580.  
  6581. nullpo_retr(-1, sd);
  6582.  
  6583. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  6584. {
  6585. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  6586. return -1;
  6587. }
  6588.  
  6589. if (duration < 1)
  6590. duration =1;
  6591. else if (duration > 60)
  6592. duration =60;
  6593.  
  6594. if ((mob_id = atoi(name)) == 0)
  6595. mob_id = mobdb_searchname(name);
  6596. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  6597. {
  6598. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6599. return -1;
  6600. }
  6601.  
  6602. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  6603.  
  6604. if(!md)
  6605. return -1;
  6606.  
  6607. md->master_id=sd->bl.id;
  6608. md->special_state.ai=1;
  6609. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  6610. clif_specialeffect(&md->bl,344,AREA);
  6611. mob_spawn(md);
  6612. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  6613. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  6614. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  6615.  
  6616. return 0;
  6617. }
  6618.  
  6619. /*==========================================
  6620. * @adjcmdlvl by [MouseJstr]
  6621. *
  6622. * Temp adjust the GM level required to use a GM command
  6623. * Useful during beta testing to allow players to use GM commands for short periods of time
  6624. *------------------------------------------*/
  6625. ACMD_FUNC(adjcmdlvl)
  6626. {
  6627. int newlev, newremotelev;
  6628. char name[100];
  6629. AtCommandInfo* cmd;
  6630.  
  6631. nullpo_retr(-1, sd);
  6632.  
  6633. if (!message || !*message || sscanf(message, "%d %d %99s", &newlev, &newremotelev, name) != 3)
  6634. {
  6635. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <remote lvl> <command>.");
  6636. return -1;
  6637. }
  6638.  
  6639. cmd = get_atcommandinfo_byname(name);
  6640. if (cmd == NULL)
  6641. {
  6642. clif_displaymessage(fd, "@command not found.");
  6643. return -1;
  6644. }
  6645. else if (newlev > pc_isGM(sd) || newremotelev > pc_isGM(sd) )
  6646. {
  6647. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  6648. return -1;
  6649. }
  6650. else if (cmd->level > pc_isGM(sd) || cmd->level2 > pc_isGM(sd) )
  6651. {
  6652. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  6653. return -1;
  6654. }
  6655. else
  6656. {
  6657. cmd->level = newlev;
  6658. cmd->level2 = newremotelev;
  6659. clif_displaymessage(fd, "@command level changed.");
  6660. return 0;
  6661. }
  6662. }
  6663.  
  6664. /*==========================================
  6665. * @adjgmlvl by [MouseJstr]
  6666. * Create a temp GM
  6667. * Useful during beta testing to allow players to use GM commands for short periods of time
  6668. *------------------------------------------*/
  6669. ACMD_FUNC(adjgmlvl)
  6670. {
  6671. int newlev;
  6672. char user[NAME_LENGTH];
  6673. struct map_session_data *pl_sd;
  6674. nullpo_retr(-1, sd);
  6675.  
  6676. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  6677. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  6678. return -1;
  6679. }
  6680.  
  6681. if ( (pl_sd = map_nick2sd(user)) == NULL )
  6682. {
  6683. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6684. return -1;
  6685. }
  6686.  
  6687. pl_sd->gmlevel = newlev;
  6688.  
  6689. return 0;
  6690. }
  6691.  
  6692. /*==========================================
  6693. * @trade by [MouseJstr]
  6694. * Open a trade window with a remote player
  6695. *------------------------------------------*/
  6696. ACMD_FUNC(trade)
  6697. {
  6698. struct map_session_data *pl_sd = NULL;
  6699. nullpo_retr(-1, sd);
  6700.  
  6701. if (!message || !*message) {
  6702. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  6703. return -1;
  6704. }
  6705.  
  6706. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  6707. {
  6708. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6709. return -1;
  6710. }
  6711.  
  6712. trade_traderequest(sd, pl_sd);
  6713. return 0;
  6714. }
  6715.  
  6716. /*==========================================
  6717. * @setbattleflag by [MouseJstr]
  6718. * set a battle_config flag without having to reboot
  6719. *------------------------------------------*/
  6720. ACMD_FUNC(setbattleflag)
  6721. {
  6722. char flag[128], value[128];
  6723. nullpo_retr(-1, sd);
  6724.  
  6725. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  6726. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  6727. return -1;
  6728. }
  6729.  
  6730. if (battle_set_value(flag, value) == 0)
  6731. {
  6732. clif_displaymessage(fd, "unknown battle_config flag");
  6733. return -1;
  6734. }
  6735.  
  6736. clif_displaymessage(fd, "battle_config set as requested");
  6737.  
  6738. return 0;
  6739. }
  6740.  
  6741. /*==========================================
  6742. * @unmute [Valaris]
  6743. *------------------------------------------*/
  6744. ACMD_FUNC(unmute)
  6745. {
  6746. struct map_session_data *pl_sd = NULL;
  6747. nullpo_retr(-1, sd);
  6748.  
  6749. if (!message || !*message) {
  6750. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  6751. return -1;
  6752. }
  6753.  
  6754. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  6755. {
  6756. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6757. return -1;
  6758. }
  6759.  
  6760. if(!pl_sd->sc.data[SC_NOCHAT]) {
  6761. clif_displaymessage(sd->fd,"Player is not muted");
  6762. return -1;
  6763. }
  6764.  
  6765. pl_sd->status.manner = 0;
  6766. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6767. clif_displaymessage(sd->fd,"Player unmuted");
  6768.  
  6769. return 0;
  6770. }
  6771.  
  6772. /*==========================================
  6773. * @uptime by MC Cameri
  6774. *------------------------------------------*/
  6775. ACMD_FUNC(uptime)
  6776. {
  6777. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  6778. minute = 60, days = 0, hours = 0, minutes = 0;
  6779. nullpo_retr(-1, sd);
  6780.  
  6781. seconds = get_uptime();
  6782. days = seconds/day;
  6783. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6784. hours = seconds/hour;
  6785. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6786. minutes = seconds/minute;
  6787. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6788.  
  6789. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  6790. clif_displaymessage(fd, atcmd_output);
  6791.  
  6792. return 0;
  6793. }
  6794.  
  6795. /*==========================================
  6796. * @changesex <sex>
  6797. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  6798. *------------------------------------------*/
  6799. ACMD_FUNC(changesex)
  6800. {
  6801. nullpo_retr(-1, sd);
  6802. chrif_changesex(sd);
  6803. return 0;
  6804. }
  6805.  
  6806. /*================================================
  6807. * @mute - Mutes a player for a set amount of time
  6808. *------------------------------------------------*/
  6809. ACMD_FUNC(mute)
  6810. {
  6811. struct map_session_data *pl_sd = NULL;
  6812. int manner;
  6813. nullpo_retr(-1, sd);
  6814.  
  6815. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6816. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  6817. return -1;
  6818. }
  6819.  
  6820. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  6821. {
  6822. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6823. return -1;
  6824. }
  6825.  
  6826. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  6827. {
  6828. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6829. return -1;
  6830. }
  6831.  
  6832. clif_manner_message(sd, 0);
  6833. clif_manner_message(pl_sd, 5);
  6834.  
  6835. if( pl_sd->status.manner < manner ) {
  6836. pl_sd->status.manner -= manner;
  6837. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6838. } else {
  6839. pl_sd->status.manner = 0;
  6840. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6841. }
  6842.  
  6843. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6844.  
  6845. return 0;
  6846. }
  6847.  
  6848. /*==========================================
  6849. * @refresh (like @jumpto <<yourself>>)
  6850. *------------------------------------------*/
  6851. ACMD_FUNC(refresh)
  6852. {
  6853. nullpo_retr(-1, sd);
  6854. clif_refresh(sd);
  6855. return 0;
  6856. }
  6857.  
  6858. /*==========================================
  6859. * @identify
  6860. * => GM's magnifier.
  6861. *------------------------------------------*/
  6862. ACMD_FUNC(identify)
  6863. {
  6864. int i,num;
  6865.  
  6866. nullpo_retr(-1, sd);
  6867.  
  6868. for(i=num=0;i<MAX_INVENTORY;i++){
  6869. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  6870. num++;
  6871. }
  6872. }
  6873. if (num > 0) {
  6874. clif_item_identify_list(sd);
  6875. } else {
  6876. clif_displaymessage(fd,"There are no items to appraise.");
  6877. }
  6878. return 0;
  6879. }
  6880.  
  6881. /*==========================================
  6882. * @gmotd (Global MOTD)
  6883. * by davidsiaw :P
  6884. *------------------------------------------*/
  6885. ACMD_FUNC(gmotd)
  6886. {
  6887. char buf[CHAT_SIZE_MAX];
  6888. size_t len;
  6889. FILE* fp;
  6890.  
  6891. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6892. {
  6893. while( fgets(buf, sizeof(buf), fp) )
  6894. {
  6895. if( buf[0] == '/' && buf[1] == '/' )
  6896. {
  6897. continue;
  6898. }
  6899.  
  6900. len = strlen(buf);
  6901.  
  6902. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6903. {// strip trailing EOL characters
  6904. len--;
  6905. }
  6906.  
  6907. if( len )
  6908. {
  6909. buf[len] = 0;
  6910.  
  6911. intif_broadcast(buf, len+1, 0);
  6912. }
  6913. }
  6914. fclose(fp);
  6915. }
  6916. return 0;
  6917. }
  6918.  
  6919. ACMD_FUNC(misceffect)
  6920. {
  6921. int effect = 0;
  6922. nullpo_retr(-1, sd);
  6923. if (!message || !*message)
  6924. return -1;
  6925. if (sscanf(message, "%d", &effect) < 1)
  6926. return -1;
  6927. clif_misceffect(&sd->bl,effect);
  6928.  
  6929. return 0;
  6930. }
  6931.  
  6932. /*==========================================
  6933. * MAIL SYSTEM
  6934. *------------------------------------------*/
  6935. ACMD_FUNC(mail)
  6936. {
  6937. nullpo_ret(sd);
  6938. #ifndef TXT_ONLY
  6939. mail_openmail(sd);
  6940. #endif
  6941. return 0;
  6942. }
  6943.  
  6944. /*==========================================
  6945. * Show Monster DB Info v 1.0
  6946. * originally by [Lupus] eAthena
  6947. *------------------------------------------*/
  6948. ACMD_FUNC(mobinfo)
  6949. {
  6950. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  6951. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  6952. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  6953. char atcmd_output2[CHAT_SIZE_MAX];
  6954. struct item_data *item_data;
  6955. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6956. int count;
  6957. int i, j, k;
  6958.  
  6959. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6960. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6961.  
  6962. if (!message || !*message) {
  6963. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  6964. return -1;
  6965. }
  6966.  
  6967. // If monster identifier/name argument is a name
  6968. if ((i = mobdb_checkid(atoi(message))))
  6969. {
  6970. mob_array[0] = mob_db(i);
  6971. count = 1;
  6972. } else
  6973. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6974.  
  6975. if (!count) {
  6976. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6977. return -1;
  6978. }
  6979.  
  6980. if (count > MAX_SEARCH) {
  6981. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6982. clif_displaymessage(fd, atcmd_output);
  6983. count = MAX_SEARCH;
  6984. }
  6985. for (k = 0; k < count; k++) {
  6986. mob = mob_array[k];
  6987.  
  6988. // stats
  6989. if (mob->mexp)
  6990. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6991. else
  6992. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6993. clif_displaymessage(fd, atcmd_output);
  6994. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
  6995. clif_displaymessage(fd, atcmd_output);
  6996. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  6997. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  6998. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6999. clif_displaymessage(fd, atcmd_output);
  7000.  
  7001. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  7002. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  7003. mob->range2 , mob->range3, msize[mob->status.size],
  7004. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  7005. clif_displaymessage(fd, atcmd_output);
  7006. // drops
  7007. clif_displaymessage(fd, " Drops:");
  7008. strcpy(atcmd_output, " ");
  7009. j = 0;
  7010. for (i = 0; i < MAX_MOB_DROP; i++) {
  7011. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  7012. continue;
  7013. if (item_data->slot)
  7014. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  7015. else
  7016. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  7017. strcat(atcmd_output, atcmd_output2);
  7018. if (++j % 3 == 0) {
  7019. clif_displaymessage(fd, atcmd_output);
  7020. strcpy(atcmd_output, " ");
  7021. }
  7022. }
  7023. if (j == 0)
  7024. clif_displaymessage(fd, "This monster has no drops.");
  7025. else if (j % 3 != 0)
  7026. clif_displaymessage(fd, atcmd_output);
  7027. // mvp
  7028. if (mob->mexp) {
  7029. sprintf(atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  7030. clif_displaymessage(fd, atcmd_output);
  7031. strcpy(atcmd_output, " MVP Items:");
  7032. j = 0;
  7033. for (i = 0; i < 3; i++) {
  7034. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  7035. continue;
  7036. if (mob->mvpitem[i].p > 0) {
  7037. j++;
  7038. if (j == 1)
  7039. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  7040. else
  7041. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  7042. strcat(atcmd_output, atcmd_output2);
  7043. }
  7044. }
  7045. if (j == 0)
  7046. clif_displaymessage(fd, "This monster has no MVP prizes.");
  7047. else
  7048. clif_displaymessage(fd, atcmd_output);
  7049. }
  7050. }
  7051. return 0;
  7052. }
  7053.  
  7054. /*=========================================
  7055. * @showmobs by KarLaeda
  7056. * => For 15 sec displays the mobs on minimap
  7057. *------------------------------------------*/
  7058. ACMD_FUNC(showmobs)
  7059. {
  7060. char mob_name[100];
  7061. int mob_id;
  7062. int number = 0;
  7063. struct s_mapiterator* it;
  7064.  
  7065. nullpo_retr(-1, sd);
  7066.  
  7067. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  7068. return -1;
  7069.  
  7070. if((mob_id = atoi(mob_name)) == 0)
  7071. mob_id = mobdb_searchname(mob_name);
  7072. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7073. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7074. clif_displaymessage(fd, atcmd_output);
  7075. return 0;
  7076. }
  7077. // Uncomment the following line to show mini-bosses & MVP.
  7078. //#define SHOW_MVP
  7079. #ifndef SHOW_MVP
  7080. if(mob_db(mob_id)->status.mode&MD_BOSS){
  7081. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  7082. clif_displaymessage(fd, atcmd_output);
  7083. return 0;
  7084. }
  7085. #endif
  7086. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7087. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7088. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7089.  
  7090. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7091. mob_name, mapindex_id2name(sd->mapindex));
  7092. clif_displaymessage(fd, atcmd_output);
  7093.  
  7094. it = mapit_geteachmob();
  7095. for(;;)
  7096. {
  7097. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  7098. if( md == NULL )
  7099. break;// no more mobs
  7100.  
  7101. if( md->bl.m != sd->bl.m )
  7102. continue;
  7103. if( mob_id != -1 && md->class_ != mob_id )
  7104. continue;
  7105. if( md->special_state.ai || md->master_id )
  7106. continue; // hide slaves and player summoned mobs
  7107. if( md->spawn_timer != INVALID_TIMER )
  7108. continue; // hide mobs waiting for respawn
  7109.  
  7110. ++number;
  7111. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  7112. }
  7113. mapit_free(it);
  7114.  
  7115. return 0;
  7116. }
  7117.  
  7118. /*==========================================
  7119. * homunculus level up [orn]
  7120. *------------------------------------------*/
  7121. ACMD_FUNC(homlevel)
  7122. {
  7123. TBL_HOM * hd;
  7124. int level = 0, i = 0;
  7125.  
  7126. nullpo_retr(-1, sd);
  7127.  
  7128. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  7129. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <# of levels to level up>.");
  7130. return -1;
  7131. }
  7132.  
  7133. if ( !merc_is_hom_active(sd->hd) ) {
  7134. clif_displaymessage(fd, "You do not have a homunculus.");
  7135. return -1;
  7136. }
  7137.  
  7138. hd = sd->hd;
  7139.  
  7140. for (i = 1; i <= level && hd->exp_next; i++){
  7141. hd->homunculus.exp += hd->exp_next;
  7142. merc_hom_levelup(hd);
  7143. }
  7144. status_calc_homunculus(hd,0);
  7145. status_percent_heal(&hd->bl, 100, 100);
  7146. clif_specialeffect(&hd->bl,568,AREA);
  7147. return 0;
  7148. }
  7149.  
  7150. /*==========================================
  7151. * homunculus evolution H [orn]
  7152. *------------------------------------------*/
  7153. ACMD_FUNC(homevolution)
  7154. {
  7155. nullpo_retr(-1, sd);
  7156.  
  7157. if ( !merc_is_hom_active(sd->hd) ) {
  7158. clif_displaymessage(fd, "You do not have a homunculus.");
  7159. return -1;
  7160. }
  7161.  
  7162. if ( !merc_hom_evolution(sd->hd) ) {
  7163. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  7164. return -1;
  7165. }
  7166.  
  7167. return 0;
  7168. }
  7169.  
  7170. /*==========================================
  7171. * call choosen homunculus [orn]
  7172. *------------------------------------------*/
  7173. ACMD_FUNC(makehomun)
  7174. {
  7175. int homunid;
  7176. nullpo_retr(-1, sd);
  7177.  
  7178. if ( sd->status.hom_id ) {
  7179. clif_displaymessage(fd, msg_txt(450));
  7180. return -1;
  7181. }
  7182.  
  7183. if (!message || !*message) {
  7184. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  7185. return -1;
  7186. }
  7187.  
  7188. homunid = atoi(message);
  7189. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  7190. {
  7191. clif_displaymessage(fd, "Invalid Homunculus id.");
  7192. return -1;
  7193. }
  7194.  
  7195. merc_create_homunculus_request(sd,homunid);
  7196. return 0;
  7197. }
  7198.  
  7199. /*==========================================
  7200. * modify homunculus intimacy [orn]
  7201. *------------------------------------------*/
  7202. ACMD_FUNC(homfriendly)
  7203. {
  7204. int friendly = 0;
  7205.  
  7206. nullpo_retr(-1, sd);
  7207.  
  7208. if ( !merc_is_hom_active(sd->hd) ) {
  7209. clif_displaymessage(fd, "You do not have a homunculus.");
  7210. return -1;
  7211. }
  7212.  
  7213. if (!message || !*message) {
  7214. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  7215. return -1;
  7216. }
  7217.  
  7218. friendly = atoi(message);
  7219. friendly = cap_value(friendly, 0, 1000);
  7220.  
  7221. sd->hd->homunculus.intimacy = friendly * 100 ;
  7222. clif_send_homdata(sd,SP_INTIMATE,friendly);
  7223. return 0;
  7224. }
  7225.  
  7226. /*==========================================
  7227. * modify homunculus hunger [orn]
  7228. *------------------------------------------*/
  7229. ACMD_FUNC(homhungry)
  7230. {
  7231. int hungry = 0;
  7232.  
  7233. nullpo_retr(-1, sd);
  7234.  
  7235. if ( !merc_is_hom_active(sd->hd) ) {
  7236. clif_displaymessage(fd, "You do not have a homunculus.");
  7237. return -1;
  7238. }
  7239.  
  7240. if (!message || !*message) {
  7241. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  7242. return -1;
  7243. }
  7244.  
  7245. hungry = atoi(message);
  7246. hungry = cap_value(hungry, 0, 100);
  7247.  
  7248. sd->hd->homunculus.hunger = hungry;
  7249. clif_send_homdata(sd,SP_HUNGRY,hungry);
  7250. return 0;
  7251. }
  7252.  
  7253. /*==========================================
  7254. * make the homunculus speak [orn]
  7255. *------------------------------------------*/
  7256. ACMD_FUNC(homtalk)
  7257. {
  7258. char mes[100],temp[100];
  7259.  
  7260. nullpo_retr(-1, sd);
  7261.  
  7262. if (sd->sc.count && //no "chatting" while muted.
  7263. (sd->sc.data[SC_BERSERK] ||
  7264. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  7265. return -1;
  7266.  
  7267. if ( !merc_is_hom_active(sd->hd) ) {
  7268. clif_displaymessage(fd, "You do not have a homunculus.");
  7269. return -1;
  7270. }
  7271.  
  7272. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  7273. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  7274. return -1;
  7275. }
  7276.  
  7277. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  7278. clif_message(&sd->hd->bl, temp);
  7279.  
  7280. return 0;
  7281. }
  7282.  
  7283. /*==========================================
  7284. * Show homunculus stats
  7285. *------------------------------------------*/
  7286. ACMD_FUNC(hominfo)
  7287. {
  7288. struct homun_data *hd;
  7289. struct status_data *status;
  7290. nullpo_retr(-1, sd);
  7291.  
  7292. if ( !merc_is_hom_active(sd->hd) ) {
  7293. clif_displaymessage(fd, "You do not have a homunculus.");
  7294. return -1;
  7295. }
  7296.  
  7297. hd = sd->hd;
  7298. status = status_get_status_data(&hd->bl);
  7299. clif_displaymessage(fd, "Homunculus stats :");
  7300.  
  7301. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  7302. status->hp, status->max_hp, status->sp, status->max_sp);
  7303. clif_displaymessage(fd, atcmd_output);
  7304.  
  7305. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  7306. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  7307. clif_displaymessage(fd, atcmd_output);
  7308.  
  7309. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  7310. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  7311. clif_displaymessage(fd, atcmd_output);
  7312.  
  7313. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7314. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  7315. status->str, status->agi, status->vit,
  7316. status->int_, status->dex, status->luk);
  7317. clif_displaymessage(fd, atcmd_output);
  7318.  
  7319. return 0;
  7320. }
  7321.  
  7322. ACMD_FUNC(homstats)
  7323. {
  7324. struct homun_data *hd;
  7325. struct s_homunculus_db *db;
  7326. struct s_homunculus *hom;
  7327. int lv, min, max, evo;
  7328.  
  7329. nullpo_retr(-1, sd);
  7330.  
  7331. if ( !merc_is_hom_active(sd->hd) ) {
  7332. clif_displaymessage(fd, "You do not have a homunculus.");
  7333. return -1;
  7334. }
  7335.  
  7336. hd = sd->hd;
  7337.  
  7338. hom = &hd->homunculus;
  7339. db = hd->homunculusDB;
  7340. lv = hom->level;
  7341.  
  7342. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7343. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  7344. clif_displaymessage(fd, atcmd_output);
  7345. lv--; //Since the first increase is at level 2.
  7346.  
  7347. evo = (hom->class_ == db->evo_class);
  7348. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  7349. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  7350. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  7351. clif_displaymessage(fd, atcmd_output);
  7352.  
  7353. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  7354. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  7355. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  7356. clif_displaymessage(fd, atcmd_output);
  7357.  
  7358. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  7359. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  7360. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  7361. clif_displaymessage(fd, atcmd_output);
  7362.  
  7363. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  7364. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  7365. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  7366. clif_displaymessage(fd, atcmd_output);
  7367.  
  7368. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  7369. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  7370. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  7371. clif_displaymessage(fd, atcmd_output);
  7372.  
  7373. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  7374. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  7375. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  7376. clif_displaymessage(fd, atcmd_output);
  7377.  
  7378. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  7379. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  7380. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  7381. clif_displaymessage(fd, atcmd_output);
  7382.  
  7383. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  7384. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  7385. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  7386. clif_displaymessage(fd, atcmd_output);
  7387.  
  7388. return 0;
  7389. }
  7390.  
  7391. ACMD_FUNC(homshuffle)
  7392. {
  7393. nullpo_retr(-1, sd);
  7394.  
  7395. if(!sd->hd)
  7396. return -1; // nothing to do
  7397.  
  7398. if(!merc_hom_shuffle(sd->hd))
  7399. return -1;
  7400.  
  7401. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  7402. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  7403. return 0;
  7404. }
  7405.  
  7406. /*==========================================
  7407. * Show Items DB Info v 1.0
  7408. * originally by [Lupus] eAthena
  7409. *------------------------------------------*/
  7410. ACMD_FUNC(iteminfo)
  7411. {
  7412. struct item_data *item_data, *item_array[MAX_SEARCH];
  7413. int i, count = 1;
  7414.  
  7415. if (!message || !*message) {
  7416. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  7417. return -1;
  7418. }
  7419. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  7420. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7421.  
  7422. if (!count) {
  7423. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7424. return -1;
  7425. }
  7426.  
  7427. if (count > MAX_SEARCH) {
  7428. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  7429. clif_displaymessage(fd, atcmd_output);
  7430. count = MAX_SEARCH;
  7431. }
  7432. for (i = 0; i < count; i++) {
  7433. item_data = item_array[i];
  7434. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  7435. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  7436. itemdb_typename(item_data->type),
  7437. (item_data->script==NULL)? "None" : "With script"
  7438. );
  7439. clif_displaymessage(fd, atcmd_output);
  7440.  
  7441. sprintf(atcmd_output, "NPC Buy:%dz, Sell:%dz | Weight: %.1f ", item_data->value_buy, item_data->value_sell, item_data->weight/10. );
  7442. clif_displaymessage(fd, atcmd_output);
  7443.  
  7444. if (item_data->maxchance == -1)
  7445. strcpy(atcmd_output, " - Available in the shops only.");
  7446. else if (item_data->maxchance)
  7447. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  7448. else
  7449. strcpy(atcmd_output, " - Monsters don't drop this item.");
  7450. clif_displaymessage(fd, atcmd_output);
  7451.  
  7452. }
  7453. return 0;
  7454. }
  7455.  
  7456. /*==========================================
  7457. * Show who drops the item.
  7458. *------------------------------------------*/
  7459. ACMD_FUNC(whodrops)
  7460. {
  7461. struct item_data *item_data, *item_array[MAX_SEARCH];
  7462. int i,j, count = 1;
  7463.  
  7464. if (!message || !*message) {
  7465. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  7466. return -1;
  7467. }
  7468. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  7469. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7470.  
  7471. if (!count) {
  7472. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7473. return -1;
  7474. }
  7475.  
  7476. if (count > MAX_SEARCH) {
  7477. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  7478. clif_displaymessage(fd, atcmd_output);
  7479. count = MAX_SEARCH;
  7480. }
  7481. for (i = 0; i < count; i++) {
  7482. item_data = item_array[i];
  7483. sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
  7484. clif_displaymessage(fd, atcmd_output);
  7485.  
  7486. if (item_data->mob[0].chance == 0) {
  7487. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  7488. clif_displaymessage(fd, atcmd_output);
  7489. } else {
  7490. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  7491. clif_displaymessage(fd, atcmd_output);
  7492.  
  7493. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  7494. {
  7495. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  7496. clif_displaymessage(fd, atcmd_output);
  7497. }
  7498. }
  7499. }
  7500. return 0;
  7501. }
  7502.  
  7503. ACMD_FUNC(whereis)
  7504. {
  7505. struct mob_db *mob, *mob_array[MAX_SEARCH];
  7506. int count;
  7507. int i, j, k;
  7508.  
  7509. if (!message || !*message) {
  7510. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  7511. return -1;
  7512. }
  7513.  
  7514. // If monster identifier/name argument is a name
  7515. if ((i = mobdb_checkid(atoi(message))))
  7516. {
  7517. mob_array[0] = mob_db(i);
  7518. count = 1;
  7519. } else
  7520. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  7521.  
  7522. if (!count) {
  7523. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  7524. return -1;
  7525. }
  7526.  
  7527. if (count > MAX_SEARCH) {
  7528. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  7529. clif_displaymessage(fd, atcmd_output);
  7530. count = MAX_SEARCH;
  7531. }
  7532. for (k = 0; k < count; k++) {
  7533. mob = mob_array[k];
  7534. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  7535. clif_displaymessage(fd, atcmd_output);
  7536.  
  7537. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  7538. {
  7539. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  7540. if (j < 0) continue;
  7541. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  7542. clif_displaymessage(fd, atcmd_output);
  7543. }
  7544. if (i == 0)
  7545. clif_displaymessage(fd, "This monster does not spawn normally.");
  7546. }
  7547.  
  7548. return 0;
  7549. }
  7550.  
  7551. /*==========================================
  7552. * @adopt by [Veider]
  7553. * adopt a novice
  7554. *------------------------------------------*/
  7555. ACMD_FUNC(adopt)
  7556. {
  7557. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  7558. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  7559. char output[CHAT_SIZE_MAX];
  7560.  
  7561. nullpo_retr(-1, sd);
  7562.  
  7563. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  7564. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  7565. return -1;
  7566. }
  7567.  
  7568. if (battle_config.etc_log)
  7569. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  7570.  
  7571. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  7572. sprintf(output, "Cannot find player %s online", player1);
  7573. clif_displaymessage(fd, output);
  7574. return -1;
  7575. }
  7576.  
  7577. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  7578. sprintf(output, "Cannot find player %s online", player2);
  7579. clif_displaymessage(fd, output);
  7580. return -1;
  7581. }
  7582.  
  7583. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  7584. sprintf(output, "Cannot find player %s online", player3);
  7585. clif_displaymessage(fd, output);
  7586. return -1;
  7587. }
  7588.  
  7589. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  7590. return -1;
  7591. }
  7592.  
  7593. clif_displaymessage(fd, "They are family... wish them luck");
  7594. return 0;
  7595. }
  7596.  
  7597. ACMD_FUNC(version)
  7598. {
  7599. const char * revision;
  7600.  
  7601. if ((revision = get_svn_revision()) != 0) {
  7602. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  7603. clif_displaymessage(fd,atcmd_output);
  7604. } else
  7605. clif_displaymessage(fd,"Cannot determine SVN revision");
  7606.  
  7607. return 0;
  7608. }
  7609.  
  7610. /*==========================================
  7611. * @mutearea by MouseJstr
  7612. *------------------------------------------*/
  7613. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  7614. {
  7615.  
  7616. int time, id;
  7617. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  7618. if (pl_sd == NULL)
  7619. return 0;
  7620.  
  7621. id = va_arg(ap, int);
  7622. time = va_arg(ap, int);
  7623.  
  7624. if (id != bl->id && !pc_isGM(pl_sd)) {
  7625. pl_sd->status.manner -= time;
  7626. if (pl_sd->status.manner < 0)
  7627. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7628. else
  7629. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  7630. }
  7631. return 0;
  7632. }
  7633.  
  7634. ACMD_FUNC(mutearea)
  7635. {
  7636. int time;
  7637. nullpo_ret(sd);
  7638.  
  7639. if (!message || !*message) {
  7640. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  7641. return -1;
  7642. }
  7643.  
  7644. time = atoi(message);
  7645.  
  7646. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  7647. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  7648. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  7649.  
  7650. return 0;
  7651. }
  7652.  
  7653.  
  7654. ACMD_FUNC(rates)
  7655. {
  7656. char buf[CHAT_SIZE_MAX];
  7657.  
  7658. nullpo_ret(sd);
  7659. memset(buf, '\0', sizeof(buf));
  7660.  
  7661. snprintf(buf, CHAT_SIZE_MAX, "Experience rates: Base %.2fx / Job %.2fx",
  7662. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  7663. clif_displaymessage(fd, buf);
  7664. snprintf(buf, CHAT_SIZE_MAX, "Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  7665. 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.);
  7666. clif_displaymessage(fd, buf);
  7667. snprintf(buf, CHAT_SIZE_MAX, "Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  7668. 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.);
  7669. clif_displaymessage(fd, buf);
  7670. snprintf(buf, CHAT_SIZE_MAX, "Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx",
  7671. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  7672. clif_displaymessage(fd, buf);
  7673.  
  7674. return 0;
  7675. }
  7676.  
  7677. /*==========================================
  7678. * @me by lordalfa
  7679. * => Displays the OUTPUT string on top of the Visible players Heads.
  7680. *------------------------------------------*/
  7681. ACMD_FUNC(me)
  7682. {
  7683. char tempmes[CHAT_SIZE_MAX];
  7684. nullpo_retr(-1, sd);
  7685.  
  7686. memset(tempmes, '\0', sizeof(tempmes));
  7687. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7688.  
  7689. if (sd->sc.count && //no "chatting" while muted.
  7690. (sd->sc.data[SC_BERSERK] ||
  7691. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  7692. return -1;
  7693.  
  7694. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  7695. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  7696. return -1;
  7697. }
  7698.  
  7699. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  7700. clif_disp_overhead(sd, atcmd_output);
  7701.  
  7702. return 0;
  7703.  
  7704. }
  7705.  
  7706. /*==========================================
  7707. * @size
  7708. * => Resize your character sprite. [Valaris]
  7709. *------------------------------------------*/
  7710. ACMD_FUNC(size)
  7711. {
  7712. int size=0;
  7713.  
  7714. nullpo_retr(-1, sd);
  7715.  
  7716. size = atoi(message);
  7717. if(sd->state.size) {
  7718. sd->state.size=0;
  7719. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  7720. }
  7721.  
  7722. if(size==1) {
  7723. sd->state.size=1;
  7724. clif_specialeffect(&sd->bl,420,AREA);
  7725. } else if(size==2) {
  7726. sd->state.size=2;
  7727. clif_specialeffect(&sd->bl,422,AREA);
  7728. }
  7729.  
  7730. return 0;
  7731. }
  7732.  
  7733. /*==========================================
  7734. * @monsterignore
  7735. * => Makes monsters ignore you. [Valaris]
  7736. *------------------------------------------*/
  7737. ACMD_FUNC(monsterignore)
  7738. {
  7739. nullpo_retr(-1, sd);
  7740.  
  7741. if (!sd->state.monster_ignore) {
  7742. sd->state.monster_ignore = 1;
  7743. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  7744. } else {
  7745. sd->state.monster_ignore = 0;
  7746. clif_displaymessage(sd->fd, "Returned to normal state.");
  7747. }
  7748.  
  7749. return 0;
  7750. }
  7751. /*==========================================
  7752. * @fakename
  7753. * => Gives your character a fake name. [Valaris]
  7754. *------------------------------------------*/
  7755. ACMD_FUNC(fakename)
  7756. {
  7757. nullpo_retr(-1, sd);
  7758.  
  7759. if( !message || !*message )
  7760. {
  7761. if( sd->fakename[0] )
  7762. {
  7763. sd->fakename[0] = '\0';
  7764. clif_charnameack(0, &sd->bl);
  7765. clif_displaymessage(sd->fd, "Returned to real name.");
  7766. return 0;
  7767. }
  7768.  
  7769. clif_displaymessage(sd->fd, "You must enter a name.");
  7770. return -1;
  7771. }
  7772.  
  7773. if( strlen(message) < 2 )
  7774. {
  7775. clif_displaymessage(sd->fd, "Fake name must be at least two characters.");
  7776. return -1;
  7777. }
  7778.  
  7779. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  7780. clif_charnameack(0, &sd->bl);
  7781. clif_displaymessage(sd->fd, "Fake name enabled.");
  7782.  
  7783. return 0;
  7784. }
  7785.  
  7786. /*==========================================
  7787. * @mapflag [flag name] [1|0|zone] [map name] by Hybrid
  7788. * Set flags
  7789. * TODO: N/A atm
  7790. *------------------------------------------*/
  7791. ACMD_FUNC(mapflag)
  7792. {
  7793. char map_flag[100];
  7794. char map_name[MAP_NAME_LENGTH];
  7795. unsigned short mapindex;
  7796. int m = -1;
  7797. int state;
  7798.  
  7799. nullpo_retr(-1, sd);
  7800.  
  7801.  
  7802. memset(map_name, '\0', sizeof(map_name));
  7803. memset(map_flag, '\0', sizeof(map_flag));
  7804. if (!message || !*message ||
  7805. (sscanf(message, "%99s %d %11s", map_flag, &state, map_name) < 3 ) ) {
  7806. if ( sscanf(message, "%99s %d", map_flag, &state) < 2 ) {
  7807. clif_displaymessage(fd, "Usage: @mapflag <mapflag name> <state:1|0|zone> <map name>");
  7808. clif_displaymessage(fd, "Supported mapflags:");
  7809. clif_displaymessage(fd, "nomemo nowarp nowarpto noreturn monster_noteleport");
  7810. clif_displaymessage(fd, "nobranch nopenalty pvp gvg noexppenalty");
  7811. clif_displaymessage(fd, "notrade novending nodrop noskill noicewall");
  7812. clif_displaymessage(fd, "snow clouds clouds2 fog nozenypenalty");
  7813. clif_displaymessage(fd, "fireworks sakura leaves rain nightenabled");
  7814. clif_displaymessage(fd, "nogo noexp nobaseexp nojobexp noloot");
  7815. clif_displaymessage(fd, "nomvploot restricted loadevent nochat partylock");
  7816. clif_displaymessage(fd, "guildlock");
  7817. clif_displaymessage(fd, "");
  7818. clif_displaymessage(fd, "Restricted mapflag: use Zones (1-7) to set a zone, 0 to turn off all zones for the map");
  7819. return -1;
  7820. }
  7821. m = sd->bl.m;
  7822. }
  7823.  
  7824. if (state < 0) {
  7825. clif_displaymessage (fd, "Minimum value for state is 0 (off), auto-assumed 0");
  7826. state = 0;
  7827. }
  7828. if (state > 1 && strcmp(map_flag, "restricted")) {
  7829. clif_displaymessage(fd, "Zone use is only applicable with the restricted mapflag");
  7830. clif_displaymessage(fd, "Setting flag value to 1");
  7831. state = 1;
  7832. }
  7833. else if (state > 7) {
  7834. clif_displaymessage(fd, "Maximum zone value is 7");
  7835. return -1;
  7836. }
  7837.  
  7838. if (m == -1) {
  7839. mapindex = mapindex_name2id(map_name);
  7840. if (mapindex)
  7841. m = map_mapindex2mapid(mapindex);
  7842.  
  7843. if (!mapindex || m < 0) {
  7844. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  7845. return -1;
  7846. }
  7847. }
  7848.  
  7849. if (!strcmpi(map_flag,"nomemo")) {
  7850. map[m].flag.nomemo=state;
  7851. }
  7852. else if (!strcmpi(map_flag,"noteleport")) {
  7853. map[m].flag.noteleport=state;
  7854. }
  7855. else if (!strcmpi(map_flag,"nowarp")) {
  7856. map[m].flag.nowarp=state;
  7857. }
  7858. else if (!strcmpi(map_flag,"nowarpto")) {
  7859. map[m].flag.nowarpto=state;
  7860. }
  7861. else if (!strcmpi(map_flag,"noreturn")) {
  7862. map[m].flag.noreturn=state;
  7863. }
  7864. else if (!strcmpi(map_flag,"monster_noteleport")) {
  7865. map[m].flag.monster_noteleport=state;
  7866. }
  7867. else if (!strcmpi(map_flag,"nobranch")) {
  7868. map[m].flag.nobranch=state;
  7869. }
  7870. else if (!strcmpi(map_flag,"nopenalty")) {
  7871. map[m].flag.noexppenalty=state;
  7872. map[m].flag.nozenypenalty=state;
  7873. }
  7874. else if (!strcmpi(map_flag,"pvp")) {
  7875. map[m].flag.pvp=state;
  7876. if (state) {
  7877. if (map[m].flag.gvg || map[m].flag.gvg_dungeon || map[m].flag.gvg_castle)
  7878. clif_displaymessage(fd, "You can't set PvP and GvG flags for the same map! Removing GvG flags.");
  7879. map[m].flag.gvg=0;
  7880. map[m].flag.gvg_dungeon=0;
  7881. map[m].flag.gvg_castle=0;
  7882. if (!battle_config.pk_mode)
  7883. {// display pvp circle and rank
  7884. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  7885. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  7886. }
  7887. }
  7888. else {
  7889. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  7890. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  7891. }
  7892. }
  7893.  
  7894. // TODO: Add support for the following mapflags [Hybrid]
  7895. /*
  7896. else if (!strcmpi(map_flag,"pvp_noparty")) {
  7897. map[m].flag.pvp_noparty=state;
  7898. }
  7899. else if (!strcmpi(map_flag,"pvp_noguild")) {
  7900. map[m].flag.pvp_noguild=state;
  7901. }
  7902. else if (!strcmpi(map_flag, "pvp_nightmaredrop")) {
  7903. map[m].flag.pvp_nightmaredrop=state;
  7904. }
  7905. else if (!strcmpi(map_flag,"pvp_nocalcrank")) {
  7906. map[m].flag.pvp_nocalcrank=state;
  7907. } */
  7908. else if (!strcmpi(map_flag,"gvg")) {
  7909. map[m].flag.gvg=state;
  7910. if (state) {
  7911. if (map[m].flag.pvp) {
  7912. clif_displaymessage(fd, "You can't set PvP and GvG flags for the same map! Removing PvP flags.");
  7913. map[m].flag.pvp=0;
  7914. }
  7915. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  7916. }
  7917. else {
  7918. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  7919. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  7920. }
  7921. }
  7922.  
  7923. // TODO: Add support for the other GVG mapflags
  7924. /*else if (!strcmpi(map_flag,"gvg_noparty")) {
  7925. map[m].flag.gvg_noparty=state;
  7926. }
  7927. else if (!strcmpi(map_flag,"gvg_dungeon")) {
  7928. map[m].flag.gvg_dungeon=state;
  7929. if (map[m].flag.pvp)
  7930. {
  7931. clif_displaymessage(fd, "You can't set PvP and GvG flags for the same map! Removing PvP flags.");
  7932. map[m].flag.pvp=0;
  7933. }
  7934. }
  7935. else if (!strcmpi(map_flag,"gvg_castle")) {
  7936. map[m].flag.gvg_castle=state;
  7937. if (map[m].flag.pvp)
  7938. {
  7939. clif_displaymessage(fd, "You can't set PvP and GvG flags for the same map! Removing PvP flags.");
  7940. map[m].flag.pvp=0;
  7941. }
  7942. } */
  7943. else if (!strcmpi(map_flag,"noexppenalty")) {
  7944. map[m].flag.noexppenalty=state;
  7945. }
  7946. else if (!strcmpi(map_flag,"nozenypenalty")) {
  7947. map[m].flag.nozenypenalty=state;
  7948. }
  7949. else if (!strcmpi(map_flag,"notrade")) {
  7950. map[m].flag.notrade=state;
  7951. }
  7952. else if (!strcmpi(map_flag,"novending")) {
  7953. map[m].flag.novending=state;
  7954. }
  7955. else if (!strcmpi(map_flag,"nodrop")) {
  7956. map[m].flag.nodrop=state;
  7957. }
  7958. else if (!strcmpi(map_flag,"noskill")) {
  7959. map[m].flag.noskill=state;
  7960. }
  7961. else if (!strcmpi(map_flag,"noicewall")) {
  7962. map[m].flag.noicewall=state;
  7963. }
  7964. else if (!strcmpi(map_flag,"snow")) {
  7965. map[m].flag.snow=state;
  7966. }
  7967. else if (!strcmpi(map_flag,"clouds")) {
  7968. map[m].flag.clouds=state;
  7969. }
  7970. else if (!strcmpi(map_flag,"clouds2")) {
  7971. map[m].flag.clouds2=state;
  7972. }
  7973. else if (!strcmpi(map_flag,"fog")) {
  7974. map[m].flag.fog=state;
  7975. }
  7976. else if (!strcmpi(map_flag,"fireworks")) {
  7977. map[m].flag.fireworks=state;
  7978. }
  7979. else if (!strcmpi(map_flag,"sakura")) {
  7980. map[m].flag.sakura=state;
  7981. }
  7982. else if (!strcmpi(map_flag,"leaves")) {
  7983. map[m].flag.leaves=state;
  7984. }
  7985. else if (!strcmpi(map_flag,"rain")) {
  7986. map[m].flag.rain=state;
  7987. }
  7988. else if (!strcmpi(map_flag,"nightenabled")) {
  7989. map[m].flag.nightenabled=state;
  7990. }
  7991. else if (!strcmpi(map_flag,"nogo")) {
  7992. map[m].flag.nogo=state;
  7993. }
  7994. else if (!strcmpi(map_flag,"noexp")) {
  7995. map[m].flag.nobaseexp=state;
  7996. map[m].flag.nojobexp=state;
  7997. }
  7998. else if (!strcmpi(map_flag,"nobaseexp")) {
  7999. map[m].flag.nobaseexp=state;
  8000. }
  8001. else if (!strcmpi(map_flag,"nojobexp")) {
  8002. map[m].flag.nojobexp=state;
  8003. }
  8004. else if (!strcmpi(map_flag,"noloot")) {
  8005. map[m].flag.nomobloot=state;
  8006. map[m].flag.nomvploot=state;
  8007. }
  8008. else if (!strcmpi(map_flag,"nomobloot")) {
  8009. map[m].flag.nomobloot=state;
  8010. }
  8011. else if (!strcmpi(map_flag,"nomvploot")) {
  8012. map[m].flag.nomvploot=state;
  8013. }
  8014. else if (!strcmpi(map_flag,"restricted")) {
  8015. if (state) {
  8016. map[m].flag.restricted=1;
  8017. map[m].zone |= 1<<(state+1);
  8018. } else {
  8019. map[m].flag.restricted=0;
  8020. map[m].zone = 0;
  8021. }
  8022. }
  8023. else if (!strcmpi(map_flag,"loadevent")) {
  8024. map[m].flag.loadevent=state;
  8025. }
  8026. else if (!strcmpi(map_flag,"nochat")) {
  8027. map[m].flag.nochat=state;
  8028. }
  8029. else if (!strcmpi(map_flag,"partylock")) {
  8030. map[m].flag.partylock=state;
  8031. }
  8032. else if (!strcmpi(map_flag,"guildlock")) {
  8033. map[m].flag.guildlock=state;
  8034. }
  8035. else
  8036. {
  8037. clif_displaymessage(fd, "Invalid Mapflag");
  8038. return -1;
  8039. }
  8040.  
  8041. clif_displaymessage(fd, "Mapflag updated.");
  8042. return 0;
  8043. }
  8044.  
  8045. /*===================================
  8046. * Remove some messages
  8047. *-----------------------------------*/
  8048. ACMD_FUNC(showexp)
  8049. {
  8050. if (sd->state.showexp) {
  8051. sd->state.showexp = 0;
  8052. clif_displaymessage(fd, "Gained exp will not be shown.");
  8053. return 0;
  8054. }
  8055.  
  8056. sd->state.showexp = 1;
  8057. clif_displaymessage(fd, "Gained exp is now shown");
  8058. return 0;
  8059. }
  8060.  
  8061. ACMD_FUNC(showzeny)
  8062. {
  8063. if (sd->state.showzeny) {
  8064. sd->state.showzeny = 0;
  8065. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8066. return 0;
  8067. }
  8068.  
  8069. sd->state.showzeny = 1;
  8070. clif_displaymessage(fd, "Gained zeny is now shown");
  8071. return 0;
  8072. }
  8073.  
  8074. ACMD_FUNC(showdelay)
  8075. {
  8076. if (sd->state.showdelay) {
  8077. sd->state.showdelay = 0;
  8078. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8079. return 0;
  8080. }
  8081.  
  8082. sd->state.showdelay = 1;
  8083. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8084. return 0;
  8085. }
  8086.  
  8087. /*==========================================
  8088. * Duel organizing functions [LuzZza]
  8089. *
  8090. * @duel [limit|nick] - create a duel
  8091. * @invite <nick> - invite player
  8092. * @accept - accept invitation
  8093. * @reject - reject invitation
  8094. * @leave - leave duel
  8095. *------------------------------------------*/
  8096. ACMD_FUNC(invite)
  8097. {
  8098. unsigned int did = sd->duel_group;
  8099. struct map_session_data *target_sd = map_nick2sd((char *)message);
  8100.  
  8101. if(did <= 0) {
  8102. // "Duel: @invite without @duel."
  8103. clif_displaymessage(fd, msg_txt(350));
  8104. return 0;
  8105. }
  8106.  
  8107. if(duel_list[did].max_players_limit > 0 &&
  8108. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  8109.  
  8110. // "Duel: Limit of players is reached."
  8111. clif_displaymessage(fd, msg_txt(351));
  8112. return 0;
  8113. }
  8114.  
  8115. if(target_sd == NULL) {
  8116. // "Duel: Player not found."
  8117. clif_displaymessage(fd, msg_txt(352));
  8118. return 0;
  8119. }
  8120.  
  8121. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8122. // "Duel: Player already in duel."
  8123. clif_displaymessage(fd, msg_txt(353));
  8124. return 0;
  8125. }
  8126.  
  8127. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  8128. {
  8129. sprintf(atcmd_output, msg_txt(364), message);
  8130. clif_displaymessage(fd, atcmd_output);
  8131. return 0;
  8132. }
  8133.  
  8134. duel_invite(did, sd, target_sd);
  8135. // "Duel: Invitation has been sent."
  8136. clif_displaymessage(fd, msg_txt(354));
  8137. return 0;
  8138. }
  8139.  
  8140. ACMD_FUNC(duel)
  8141. {
  8142. char output[CHAT_SIZE_MAX];
  8143. unsigned int maxpl=0, newduel;
  8144. struct map_session_data *target_sd;
  8145.  
  8146. if(sd->duel_group > 0) {
  8147. duel_showinfo(sd->duel_group, sd);
  8148. return 0;
  8149. }
  8150.  
  8151. if(sd->duel_invite > 0) {
  8152. // "Duel: @duel without @reject."
  8153. clif_displaymessage(fd, msg_txt(355));
  8154. return 0;
  8155. }
  8156.  
  8157. if(!duel_checktime(sd)) {
  8158. // "Duel: You can take part in duel only one time per %d minutes."
  8159. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8160. clif_displaymessage(fd, output);
  8161. return 0;
  8162. }
  8163.  
  8164. if( message[0] ) {
  8165. if(sscanf(message, "%d", &maxpl) >= 1) {
  8166. if(maxpl < 2 || maxpl > 65535) {
  8167. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  8168. return 0;
  8169. }
  8170. duel_create(sd, maxpl);
  8171. } else {
  8172. target_sd = map_nick2sd((char *)message);
  8173. if(target_sd != NULL) {
  8174. if((newduel = duel_create(sd, 2)) != -1) {
  8175. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8176. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  8177. return 0;
  8178. }
  8179. duel_invite(newduel, sd, target_sd);
  8180. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  8181. }
  8182. } else {
  8183. // "Duel: Player not found."
  8184. clif_displaymessage(fd, msg_txt(352));
  8185. return 0;
  8186. }
  8187. }
  8188. } else
  8189. duel_create(sd, 0);
  8190.  
  8191. return 0;
  8192. }
  8193.  
  8194.  
  8195. ACMD_FUNC(leave)
  8196. {
  8197. if(sd->duel_group <= 0) {
  8198. // "Duel: @leave without @duel."
  8199. clif_displaymessage(fd, msg_txt(358));
  8200. return 0;
  8201. }
  8202.  
  8203. duel_leave(sd->duel_group, sd);
  8204. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  8205. return 0;
  8206. }
  8207.  
  8208. ACMD_FUNC(accept)
  8209. {
  8210. char output[CHAT_SIZE_MAX];
  8211.  
  8212. if(!duel_checktime(sd)) {
  8213. // "Duel: You can take part in duel only one time per %d minutes."
  8214. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8215. clif_displaymessage(fd, output);
  8216. return 0;
  8217. }
  8218.  
  8219. if(sd->duel_invite <= 0) {
  8220. // "Duel: @accept without invititation."
  8221. clif_displaymessage(fd, msg_txt(360));
  8222. return 0;
  8223. }
  8224.  
  8225. if( duel_list[sd->duel_invite].max_players_limit > 0 && duel_list[sd->duel_invite].members_count >= duel_list[sd->duel_invite].max_players_limit )
  8226. {
  8227. // "Duel: Limit of players is reached."
  8228. clif_displaymessage(fd, msg_txt(351));
  8229. return 0;
  8230. }
  8231.  
  8232. duel_accept(sd->duel_invite, sd);
  8233. // "Duel: Invitation has been accepted."
  8234. clif_displaymessage(fd, msg_txt(361));
  8235. return 0;
  8236. }
  8237.  
  8238. ACMD_FUNC(reject)
  8239. {
  8240. if(sd->duel_invite <= 0) {
  8241. // "Duel: @reject without invititation."
  8242. clif_displaymessage(fd, msg_txt(362));
  8243. return 0;
  8244. }
  8245.  
  8246. duel_reject(sd->duel_invite, sd);
  8247. // "Duel: Invitation has been rejected."
  8248. clif_displaymessage(fd, msg_txt(363));
  8249. return 0;
  8250. }
  8251.  
  8252. /*===================================
  8253. * Cash Points
  8254. *-----------------------------------*/
  8255. ACMD_FUNC(cash)
  8256. {
  8257. int value;
  8258. nullpo_retr(-1, sd);
  8259.  
  8260. if( !message || !*message || (value = atoi(message)) == 0 ) {
  8261. clif_displaymessage(fd, "Please, enter an amount.");
  8262. return -1;
  8263. }
  8264.  
  8265. if( !strcmpi(command+1,"cash") )
  8266. {
  8267. if( value > 0 )
  8268. pc_getcash(sd, value, 0);
  8269. else
  8270. pc_paycash(sd, -value, 0);
  8271. }
  8272. else
  8273. { // @points
  8274. if( value > 0 )
  8275. pc_getcash(sd, 0, value);
  8276. else
  8277. pc_paycash(sd, -value, -value);
  8278. }
  8279.  
  8280. return 0;
  8281. }
  8282.  
  8283. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8284. ACMD_FUNC(clone)
  8285. {
  8286. int x=0,y=0,flag=0,master=0,i=0;
  8287. struct map_session_data *pl_sd=NULL;
  8288.  
  8289. if (!message || !*message) {
  8290. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  8291. return 0;
  8292. }
  8293.  
  8294. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8295. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8296. return 0;
  8297. }
  8298.  
  8299. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  8300. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  8301. return 0;
  8302. }
  8303.  
  8304. if (strcmpi(command+1, "clone") == 0)
  8305. flag = 1;
  8306. else if (strcmpi(command+1, "slaveclone") == 0) {
  8307. flag = 2;
  8308. master = sd->bl.id;
  8309. if (battle_config.atc_slave_clone_limit
  8310. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8311. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  8312. return 0;
  8313. }
  8314. }
  8315.  
  8316. do {
  8317. x = sd->bl.x + (rand() % 10 - 5);
  8318. y = sd->bl.y + (rand() % 10 - 5);
  8319. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8320.  
  8321. if (i >= 10) {
  8322. x = sd->bl.x;
  8323. y = sd->bl.y;
  8324. }
  8325.  
  8326. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8327. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  8328. return 0;
  8329. }
  8330. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  8331. return 0;
  8332. }
  8333.  
  8334. /*===================================
  8335. * Main chat [LuzZza]
  8336. * Usage: @main <on|off|message>
  8337. *-----------------------------------*/
  8338. ACMD_FUNC(main)
  8339. {
  8340. if( message[0] ) {
  8341.  
  8342. if(strcmpi(message, "on") == 0) {
  8343. if(!sd->state.mainchat) {
  8344. sd->state.mainchat = 1;
  8345. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8346. } else {
  8347. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  8348. }
  8349. } else if(strcmpi(message, "off") == 0) {
  8350. if(sd->state.mainchat) {
  8351. sd->state.mainchat = 0;
  8352. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  8353. } else {
  8354. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  8355. }
  8356. } else {
  8357. if(!sd->state.mainchat) {
  8358. sd->state.mainchat = 1;
  8359. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8360. }
  8361. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  8362. clif_displaymessage(fd, msg_txt(387));
  8363. return -1;
  8364. }
  8365. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  8366. // I use 0xFE000000 color for signalizing that this message is
  8367. // main chat message. 0xFE000000 is invalid color, same using
  8368. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  8369. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0, 0, 0, 0);
  8370.  
  8371. // Chat logging type 'M' / Main Chat
  8372. log_chat(LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  8373. }
  8374.  
  8375. } else {
  8376.  
  8377. if(sd->state.mainchat)
  8378. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  8379. else
  8380. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  8381. }
  8382. return 0;
  8383. }
  8384.  
  8385. /*=====================================
  8386. * Autorejecting Invites/Deals [LuzZza]
  8387. * Usage: @noask
  8388. *-------------------------------------*/
  8389. ACMD_FUNC(noask)
  8390. {
  8391. if(sd->state.noask) {
  8392. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  8393. sd->state.noask = 0;
  8394. } else {
  8395. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  8396. sd->state.noask = 1;
  8397. }
  8398.  
  8399. return 0;
  8400. }
  8401.  
  8402. /*=====================================
  8403. * Send a @request message to all GMs of lowest_gm_level.
  8404. * Usage: @request <petition>
  8405. *-------------------------------------*/
  8406. ACMD_FUNC(request)
  8407. {
  8408. if (!message || !*message) {
  8409. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  8410. return -1;
  8411. }
  8412.  
  8413. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  8414. intif_wis_message_to_gm(sd->status.name, battle_config.lowest_gm_level, atcmd_output);
  8415. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  8416. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  8417. return 0;
  8418. }
  8419.  
  8420. /*==========================================
  8421. * Feel (SG save map) Reset [HiddenDragon]
  8422. *------------------------------------------*/
  8423. ACMD_FUNC(feelreset)
  8424. {
  8425. pc_resetfeel(sd);
  8426. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  8427.  
  8428. return 0;
  8429. }
  8430.  
  8431. /*==========================================
  8432. * AUCTION SYSTEM
  8433. *------------------------------------------*/
  8434. ACMD_FUNC(auction)
  8435. {
  8436. nullpo_ret(sd);
  8437.  
  8438. #ifndef TXT_ONLY
  8439. clif_Auction_openwindow(sd);
  8440. #endif
  8441.  
  8442. return 0;
  8443. }
  8444.  
  8445. /*==========================================
  8446. * Kill Steal Protection
  8447. *------------------------------------------*/
  8448. ACMD_FUNC(ksprotection)
  8449. {
  8450. nullpo_retr(-1,sd);
  8451.  
  8452. if( sd->state.noks ) {
  8453. sd->state.noks = 0;
  8454. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  8455. }
  8456. else
  8457. {
  8458. if( !message || !*message || !strcmpi(message, "party") )
  8459. { // Default is Party
  8460. sd->state.noks = 2;
  8461. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  8462. }
  8463. else if( !strcmpi(message, "self") )
  8464. {
  8465. sd->state.noks = 1;
  8466. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  8467. }
  8468. else if( !strcmpi(message, "guild") )
  8469. {
  8470. sd->state.noks = 3;
  8471. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  8472. }
  8473. else
  8474. sprintf(atcmd_output, "Usage: @noks <self|party|guild>");
  8475. }
  8476.  
  8477. clif_displaymessage(fd, atcmd_output);
  8478. return 0;
  8479. }
  8480. /*==========================================
  8481. * Map Kill Steal Protection Setting
  8482. *------------------------------------------*/
  8483. ACMD_FUNC(allowks)
  8484. {
  8485. nullpo_retr(-1,sd);
  8486.  
  8487. if( map[sd->bl.m].flag.allowks ) {
  8488. map[sd->bl.m].flag.allowks = 0;
  8489. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  8490. } else {
  8491. map[sd->bl.m].flag.allowks = 1;
  8492. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  8493. }
  8494.  
  8495. clif_displaymessage(fd, atcmd_output);
  8496. return 0;
  8497. }
  8498.  
  8499. ACMD_FUNC(resetstat)
  8500. {
  8501. nullpo_retr(-1, sd);
  8502.  
  8503. pc_resetstate(sd);
  8504. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  8505. clif_displaymessage(fd, atcmd_output);
  8506. return 0;
  8507. }
  8508.  
  8509. ACMD_FUNC(resetskill)
  8510. {
  8511. nullpo_retr(-1,sd);
  8512.  
  8513. pc_resetskill(sd,1);
  8514. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  8515. clif_displaymessage(fd, atcmd_output);
  8516. return 0;
  8517. }
  8518.  
  8519. /*==========================================
  8520. * #storagelist: Displays the items list of a player's storage.
  8521. * #cartlist: Displays contents of target's cart.
  8522. * #itemlist: Displays contents of target's inventory.
  8523. *------------------------------------------*/
  8524. ACMD_FUNC(itemlist)
  8525. {
  8526. int i, j, count, counter;
  8527. const char* location;
  8528. const struct item* items;
  8529. int size;
  8530. StringBuf buf;
  8531.  
  8532. nullpo_retr(-1, sd);
  8533.  
  8534. if( strcmp(command+1, "storagelist") == 0 )
  8535. {
  8536. location = "storage";
  8537. items = sd->status.storage.items;
  8538. size = MAX_STORAGE;
  8539. }
  8540. else
  8541. if( strcmp(command+1, "cartlist") == 0 )
  8542. {
  8543. location = "cart";
  8544. items = sd->status.cart;
  8545. size = MAX_CART;
  8546. }
  8547. else
  8548. if( strcmp(command+1, "itemlist") == 0 )
  8549. {
  8550. location = "inventory";
  8551. items = sd->status.inventory;
  8552. size = MAX_INVENTORY;
  8553. }
  8554. else
  8555. return 1;
  8556.  
  8557. StringBuf_Init(&buf);
  8558.  
  8559. count = 0; // total slots occupied
  8560. counter = 0; // total items found
  8561. for( i = 0; i < size; ++i )
  8562. {
  8563. const struct item* it = &items[i];
  8564. struct item_data* itd;
  8565.  
  8566. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  8567. continue;
  8568.  
  8569. counter += it->amount;
  8570. count++;
  8571.  
  8572. if( count == 1 )
  8573. {
  8574. StringBuf_Printf(&buf, "------ %s items list of '%s' ------", location, sd->status.name);
  8575. clif_displaymessage(fd, StringBuf_Value(&buf));
  8576. StringBuf_Clear(&buf);
  8577. }
  8578.  
  8579. if( it->refine )
  8580. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  8581. else
  8582. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  8583.  
  8584. if( it->equip )
  8585. {
  8586. char equipstr[CHAT_SIZE_MAX];
  8587. strcpy(equipstr, " | equipped: ");
  8588. if( it->equip & EQP_GARMENT )
  8589. strcat(equipstr, "garment, ");
  8590. if( it->equip & EQP_ACC_L )
  8591. strcat(equipstr, "left accessory, ");
  8592. if( it->equip & EQP_ARMOR )
  8593. strcat(equipstr, "body/armor, ");
  8594. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  8595. strcat(equipstr, "right hand, ");
  8596. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  8597. strcat(equipstr, "left hand, ");
  8598. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  8599. strcat(equipstr, "both hands, ");
  8600. if( it->equip & EQP_SHOES )
  8601. strcat(equipstr, "feet, ");
  8602. if( it->equip & EQP_ACC_R )
  8603. strcat(equipstr, "right accessory, ");
  8604. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  8605. strcat(equipstr, "lower head, ");
  8606. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  8607. strcat(equipstr, "top head, ");
  8608. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  8609. strcat(equipstr, "lower/top head, ");
  8610. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  8611. strcat(equipstr, "mid head, ");
  8612. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  8613. strcat(equipstr, "lower/mid head, ");
  8614. if( (it->equip & EQP_HELM) == EQP_HELM )
  8615. strcat(equipstr, "lower/mid/top head, ");
  8616. // remove final ', '
  8617. equipstr[strlen(equipstr) - 2] = '\0';
  8618. StringBuf_AppendStr(&buf, equipstr);
  8619. }
  8620.  
  8621. clif_displaymessage(fd, StringBuf_Value(&buf));
  8622. StringBuf_Clear(&buf);
  8623.  
  8624. if( it->card[0] == CARD0_PET )
  8625. {// pet egg
  8626. if (it->card[3])
  8627. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  8628. else
  8629. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  8630. }
  8631. else
  8632. if(it->card[0] == CARD0_FORGE)
  8633. {// forged item
  8634. StringBuf_Printf(&buf, " -> (crafted item, creator id: %u, star crumbs %d, element %d)", (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f);
  8635. }
  8636. else
  8637. if(it->card[0] == CARD0_CREATE)
  8638. {// created item
  8639. StringBuf_Printf(&buf, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(it->card[2], it->card[3]));
  8640. }
  8641. else
  8642. {// normal item
  8643. int counter2 = 0;
  8644.  
  8645. for( j = 0; j < itd->slot; ++j )
  8646. {
  8647. struct item_data* card;
  8648.  
  8649. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  8650. continue;
  8651.  
  8652. counter2++;
  8653.  
  8654. if( counter2 == 1 )
  8655. StringBuf_AppendStr(&buf, " -> (card(s): ");
  8656.  
  8657. if( counter2 != 1 )
  8658. StringBuf_AppendStr(&buf, ", ");
  8659.  
  8660. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  8661. }
  8662.  
  8663. if( counter2 > 0 )
  8664. StringBuf_AppendStr(&buf, ")");
  8665. }
  8666.  
  8667. if( StringBuf_Length(&buf) > 0 )
  8668. clif_displaymessage(fd, StringBuf_Value(&buf));
  8669.  
  8670. StringBuf_Clear(&buf);
  8671. }
  8672.  
  8673. if( count == 0 )
  8674. StringBuf_Printf(&buf, "No item found in this player's %s.", location);
  8675. else
  8676. StringBuf_Printf(&buf, "%d item(s) found in %d %s slots.", counter, count, location);
  8677.  
  8678. clif_displaymessage(fd, StringBuf_Value(&buf));
  8679.  
  8680. StringBuf_Destroy(&buf);
  8681.  
  8682. return 0;
  8683. }
  8684.  
  8685. ACMD_FUNC(stats)
  8686. {
  8687. char job_jobname[100];
  8688. char output[CHAT_SIZE_MAX];
  8689. int i;
  8690. struct {
  8691. const char* format;
  8692. int value;
  8693. } output_table[] = {
  8694. { "Base Level - %d", 0 },
  8695. { NULL, 0 },
  8696. { "Hp - %d", 0 },
  8697. { "MaxHp - %d", 0 },
  8698. { "Sp - %d", 0 },
  8699. { "MaxSp - %d", 0 },
  8700. { "Str - %3d", 0 },
  8701. { "Agi - %3d", 0 },
  8702. { "Vit - %3d", 0 },
  8703. { "Int - %3d", 0 },
  8704. { "Dex - %3d", 0 },
  8705. { "Luk - %3d", 0 },
  8706. { "Zeny - %d", 0 },
  8707. { "Free SK Points - %d", 0 },
  8708. { "JobChangeLvl - %d", 0 },
  8709. { NULL, 0 }
  8710. };
  8711.  
  8712. memset(job_jobname, '\0', sizeof(job_jobname));
  8713. memset(output, '\0', sizeof(output));
  8714.  
  8715. //direct array initialization with variables is not standard C compliant.
  8716. output_table[0].value = sd->status.base_level;
  8717. output_table[1].format = job_jobname;
  8718. output_table[1].value = sd->status.job_level;
  8719. output_table[2].value = sd->status.hp;
  8720. output_table[3].value = sd->status.max_hp;
  8721. output_table[4].value = sd->status.sp;
  8722. output_table[5].value = sd->status.max_sp;
  8723. output_table[6].value = sd->status.str;
  8724. output_table[7].value = sd->status.agi;
  8725. output_table[8].value = sd->status.vit;
  8726. output_table[9].value = sd->status.int_;
  8727. output_table[10].value = sd->status.dex;
  8728. output_table[11].value = sd->status.luk;
  8729. output_table[12].value = sd->status.zeny;
  8730. output_table[13].value = sd->status.skill_point;
  8731. output_table[14].value = sd->change_level;
  8732.  
  8733. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  8734. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  8735.  
  8736. clif_displaymessage(fd, output);
  8737.  
  8738. for (i = 0; output_table[i].format != NULL; i++) {
  8739. sprintf(output, output_table[i].format, output_table[i].value);
  8740. clif_displaymessage(fd, output);
  8741. }
  8742.  
  8743. return 0;
  8744. }
  8745.  
  8746. ACMD_FUNC(delitem)
  8747. {
  8748. char item_name[100];
  8749. int nameid, amount = 0, total, idx;
  8750. struct item_data* id;
  8751.  
  8752. nullpo_retr(-1, sd);
  8753.  
  8754. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  8755. {
  8756. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).");
  8757. return -1;
  8758. }
  8759.  
  8760. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  8761. {
  8762. nameid = id->nameid;
  8763. }
  8764. else
  8765. {
  8766. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  8767. return -1;
  8768. }
  8769.  
  8770. total = amount;
  8771.  
  8772. // delete items
  8773. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  8774. {
  8775. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  8776.  
  8777. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  8778. {// delete pet
  8779. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  8780. }
  8781.  
  8782. //Logs (A)dmins items [Lupus]
  8783. log_pick(&sd->bl, LOG_TYPE_COMMAND, nameid, -delamount, &sd->status.inventory[idx]);
  8784.  
  8785. pc_delitem(sd, idx, delamount, 0, 0);
  8786.  
  8787. amount-= delamount;
  8788. }
  8789.  
  8790. // notify target
  8791. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  8792. clif_displaymessage(sd->fd, atcmd_output);
  8793.  
  8794. // notify source
  8795. if( amount == total )
  8796. {
  8797. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  8798. }
  8799. else if( amount )
  8800. {
  8801. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  8802. clif_displaymessage(fd, atcmd_output);
  8803. }
  8804. else
  8805. {
  8806. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  8807. clif_displaymessage(fd, atcmd_output);
  8808. }
  8809.  
  8810. return 0;
  8811. }
  8812.  
  8813. /*==========================================
  8814. * Custom Fonts
  8815. *------------------------------------------*/
  8816. ACMD_FUNC(font)
  8817. {
  8818. int font_id;
  8819. nullpo_retr(-1,sd);
  8820.  
  8821. font_id = atoi(message);
  8822. if( font_id == 0 )
  8823. {
  8824. if( sd->user_font )
  8825. {
  8826. sd->user_font = 0;
  8827. clif_displaymessage(fd, "Returning to normal font.");
  8828. clif_font(sd);
  8829. }
  8830. else
  8831. {
  8832. clif_displaymessage(fd, "Use @font <1..9> to change your messages font.");
  8833. clif_displaymessage(fd, "Use 0 or no parameter to back to normal font.");
  8834. }
  8835. }
  8836. else if( font_id < 0 || font_id > 9 )
  8837. clif_displaymessage(fd, "Invalid font. Use a Value from 0 to 9.");
  8838. else if( font_id != sd->user_font )
  8839. {
  8840. sd->user_font = font_id;
  8841. clif_font(sd);
  8842. clif_displaymessage(fd, "Font changed.");
  8843. }
  8844. else
  8845. clif_displaymessage(fd, "Already using this font.");
  8846.  
  8847. return 0;
  8848. }
  8849.  
  8850. /*==========================================
  8851. * Custom Fonts
  8852. *------------------------------------------*/
  8853. ACMD_FUNC(newplayer)
  8854. {
  8855. nullpo_retr(-1,sd);
  8856. npc_event(sd,"Freebies::OnAtCommand",0);
  8857. return 0;
  8858. }
  8859.  
  8860.  
  8861. /*==========================================
  8862. * atcommand_info[] structure definition
  8863. *------------------------------------------*/
  8864.  
  8865. AtCommandInfo atcommand_info[] = {
  8866. { "rura", 40,40, atcommand_mapmove },
  8867. { "warp", 40,40, atcommand_mapmove },
  8868. { "mapmove", 40,40, atcommand_mapmove }, // + /mm
  8869. { "where", 1,1, atcommand_where },
  8870. { "jumpto", 20,20, atcommand_jumpto }, // + /shift
  8871. { "warpto", 20,20, atcommand_jumpto },
  8872. { "goto", 20,20, atcommand_jumpto },
  8873. { "jump", 40,40, atcommand_jump },
  8874. { "who", 20,20, atcommand_who },
  8875. { "whois", 20,20, atcommand_who },
  8876. { "who2", 20,20, atcommand_who2 },
  8877. { "who3", 20,20, atcommand_who3 },
  8878. { "whomap", 20,20, atcommand_whomap },
  8879. { "whomap2", 20,20, atcommand_whomap2 },
  8880. { "whomap3", 20,20, atcommand_whomap3 },
  8881. { "whogm", 20,20, atcommand_whogm },
  8882. { "save", 40,40, atcommand_save },
  8883. { "return", 40,40, atcommand_load },
  8884. { "load", 40,40, atcommand_load },
  8885. { "speed", 40,40, atcommand_speed },
  8886. { "storage", 1,1, atcommand_storage },
  8887. { "gstorage", 50,50, atcommand_guildstorage },
  8888. { "option", 40,40, atcommand_option },
  8889. { "hide", 40,40, atcommand_hide }, // + /hide
  8890. { "jobchange", 40,40, atcommand_jobchange },
  8891. { "job", 40,40, atcommand_jobchange },
  8892. { "die", 1,1, atcommand_die },
  8893. { "kill", 60,60, atcommand_kill },
  8894. { "alive", 60,60, atcommand_alive },
  8895. { "kami", 40,40, atcommand_kami },
  8896. { "kamib", 40,40, atcommand_kami },
  8897. { "kamic", 40,40, atcommand_kami },
  8898. { "heal", 40,60, atcommand_heal },
  8899. { "item", 60,60, atcommand_item },
  8900. { "item2", 60,60, atcommand_item2 },
  8901. { "itemreset", 40,40, atcommand_itemreset },
  8902. { "blvl", 60,60, atcommand_baselevelup },
  8903. { "lvup", 60,60, atcommand_baselevelup },
  8904. { "blevel", 60,60, atcommand_baselevelup },
  8905. { "baselvl", 60,60, atcommand_baselevelup },
  8906. { "baselvup", 60,60, atcommand_baselevelup },
  8907. { "baselevel", 60,60, atcommand_baselevelup },
  8908. { "baselvlup", 60,60, atcommand_baselevelup },
  8909. { "jlvl", 60,60, atcommand_joblevelup },
  8910. { "jlevel", 60,60, atcommand_joblevelup },
  8911. { "joblvl", 60,60, atcommand_joblevelup },
  8912. { "joblevel", 60,60, atcommand_joblevelup },
  8913. { "joblvup", 60,60, atcommand_joblevelup },
  8914. { "joblvlup", 60,60, atcommand_joblevelup },
  8915. { "h", 20,20, atcommand_help },
  8916. { "help", 20,20, atcommand_help },
  8917. { "h2", 20,20, atcommand_help2 },
  8918. { "help2", 20,20, atcommand_help2 },
  8919. { "pvpoff", 40,40, atcommand_pvpoff },
  8920. { "pvpon", 40,40, atcommand_pvpon },
  8921. { "gvgoff", 40,40, atcommand_gvgoff },
  8922. { "gpvpoff", 40,40, atcommand_gvgoff },
  8923. { "gvgon", 40,40, atcommand_gvgon },
  8924. { "gpvpon", 40,40, atcommand_gvgon },
  8925. { "model", 20,20, atcommand_model },
  8926. { "go", 10,10, atcommand_go },
  8927. { "monster", 50,50, atcommand_monster },
  8928. { "spawn", 50,50, atcommand_monster },
  8929. { "monstersmall", 50,50, atcommand_monstersmall },
  8930. { "monsterbig", 50,50, atcommand_monsterbig },
  8931. { "killmonster", 60,60, atcommand_killmonster },
  8932. { "killmonster2", 40,40, atcommand_killmonster2 },
  8933. { "refine", 60,60, atcommand_refine },
  8934. { "produce", 60,60, atcommand_produce },
  8935. { "memo", 40,40, atcommand_memo },
  8936. { "gat", 99,99, atcommand_gat },
  8937. { "displaystatus", 99,99, atcommand_displaystatus },
  8938. { "stpoint", 60,60, atcommand_statuspoint },
  8939. { "skpoint", 60,60, atcommand_skillpoint },
  8940. { "zeny", 60,60, atcommand_zeny },
  8941. { "str", 60,60, atcommand_param },
  8942. { "agi", 60,60, atcommand_param },
  8943. { "vit", 60,60, atcommand_param },
  8944. { "int", 60,60, atcommand_param },
  8945. { "dex", 60,60, atcommand_param },
  8946. { "luk", 60,60, atcommand_param },
  8947. { "glvl", 60,60, atcommand_guildlevelup },
  8948. { "glevel", 60,60, atcommand_guildlevelup },
  8949. { "guildlvl", 60,60, atcommand_guildlevelup },
  8950. { "guildlvup", 60,60, atcommand_guildlevelup },
  8951. { "guildlevel", 60,60, atcommand_guildlevelup },
  8952. { "guildlvlup", 60,60, atcommand_guildlevelup },
  8953. { "makeegg", 60,60, atcommand_makeegg },
  8954. { "hatch", 60,60, atcommand_hatch },
  8955. { "petfriendly", 40,40, atcommand_petfriendly },
  8956. { "pethungry", 40,40, atcommand_pethungry },
  8957. { "petrename", 1,1, atcommand_petrename },
  8958. { "recall", 60,60, atcommand_recall }, // + /recall
  8959. { "night", 80,80, atcommand_night },
  8960. { "day", 80,80, atcommand_day },
  8961. { "doom", 80,80, atcommand_doom },
  8962. { "doommap", 80,80, atcommand_doommap },
  8963. { "raise", 80,80, atcommand_raise },
  8964. { "raisemap", 80,80, atcommand_raisemap },
  8965. { "kick", 20,20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  8966. { "kickall", 99,99, atcommand_kickall },
  8967. { "allskill", 60,60, atcommand_allskill },
  8968. { "allskills", 60,60, atcommand_allskill },
  8969. { "skillall", 60,60, atcommand_allskill },
  8970. { "skillsall", 60,60, atcommand_allskill },
  8971. { "questskill", 40,40, atcommand_questskill },
  8972. { "lostskill", 40,40, atcommand_lostskill },
  8973. { "spiritball", 40,40, atcommand_spiritball },
  8974. { "party", 1,1, atcommand_party },
  8975. { "guild", 50,50, atcommand_guild },
  8976. { "agitstart", 60,60, atcommand_agitstart },
  8977. { "agitend", 60,60, atcommand_agitend },
  8978. { "mapexit", 99,99, atcommand_mapexit },
  8979. { "idsearch", 60,60, atcommand_idsearch },
  8980. { "broadcast", 40,40, atcommand_broadcast }, // + /b and /nb
  8981. { "localbroadcast", 40,40, atcommand_localbroadcast }, // + /lb and /nlb
  8982. { "recallall", 80,80, atcommand_recallall },
  8983. { "reloaditemdb", 99,99, atcommand_reloaditemdb },
  8984. { "reloadmobdb", 99,99, atcommand_reloadmobdb },
  8985. { "reloadskilldb", 99,99, atcommand_reloadskilldb },
  8986. { "reloadscript", 99,99, atcommand_reloadscript },
  8987. { "reloadatcommand", 99,99, atcommand_reloadatcommand },
  8988. { "reloadbattleconf", 99,99, atcommand_reloadbattleconf },
  8989. { "reloadstatusdb", 99,99, atcommand_reloadstatusdb },
  8990. { "reloadpcdb", 99,99, atcommand_reloadpcdb },
  8991. { "reloadmotd", 99,99, atcommand_reloadmotd },
  8992. { "mapinfo", 99,99, atcommand_mapinfo },
  8993. { "dye", 40,40, atcommand_dye },
  8994. { "ccolor", 40,40, atcommand_dye },
  8995. { "hairstyle", 40,40, atcommand_hair_style },
  8996. { "hstyle", 40,40, atcommand_hair_style },
  8997. { "haircolor", 40,40, atcommand_hair_color },
  8998. { "hcolor", 40,40, atcommand_hair_color },
  8999. { "statall", 60,60, atcommand_stat_all },
  9000. { "statsall", 60,60, atcommand_stat_all },
  9001. { "allstats", 60,60, atcommand_stat_all },
  9002. { "allstat", 60,60, atcommand_stat_all },
  9003. { "block", 60,60, atcommand_char_block },
  9004. { "charblock", 60,60, atcommand_char_block },
  9005. { "ban", 60,60, atcommand_char_ban },
  9006. { "banish", 60,60, atcommand_char_ban },
  9007. { "charban", 60,60, atcommand_char_ban },
  9008. { "charbanish", 60,60, atcommand_char_ban },
  9009. { "unblock", 60,60, atcommand_char_unblock },
  9010. { "charunblock", 60,60, atcommand_char_unblock },
  9011. { "unban", 60,60, atcommand_char_unban },
  9012. { "unbanish", 60,60, atcommand_char_unban },
  9013. { "charunban", 60,60, atcommand_char_unban },
  9014. { "charunbanish", 60,60, atcommand_char_unban },
  9015. { "mount", 20,20, atcommand_mount_peco },
  9016. { "mountpeco", 20,20, atcommand_mount_peco },
  9017. { "guildspy", 60,60, atcommand_guildspy },
  9018. { "partyspy", 60,60, atcommand_partyspy },
  9019. { "repairall", 60,60, atcommand_repairall },
  9020. { "guildrecall", 60,60, atcommand_guildrecall },
  9021. { "partyrecall", 60,60, atcommand_partyrecall },
  9022. { "nuke", 60,60, atcommand_nuke },
  9023. { "shownpc", 80,80, atcommand_shownpc },
  9024. { "hidenpc", 80,80, atcommand_hidenpc },
  9025. { "loadnpc", 80,80, atcommand_loadnpc },
  9026. { "unloadnpc", 80,80, atcommand_unloadnpc },
  9027. { "time", 1,1, atcommand_servertime },
  9028. { "date", 1,1, atcommand_servertime },
  9029. { "serverdate", 1,1, atcommand_servertime },
  9030. { "servertime", 1,1, atcommand_servertime },
  9031. { "jail", 60,60, atcommand_jail },
  9032. { "unjail", 60,60, atcommand_unjail },
  9033. { "discharge", 60,60, atcommand_unjail },
  9034. { "jailfor", 60,60, atcommand_jailfor },
  9035. { "jailtime", 1,1, atcommand_jailtime },
  9036. { "disguise", 20,20, atcommand_disguise },
  9037. { "undisguise", 20,20, atcommand_undisguise },
  9038. { "email", 1,1, atcommand_email },
  9039. { "effect", 40,40, atcommand_effect },
  9040. { "follow", 20,20, atcommand_follow },
  9041. { "addwarp", 60,60, atcommand_addwarp },
  9042. { "skillon", 80,80, atcommand_skillon },
  9043. { "skilloff", 80,80, atcommand_skilloff },
  9044. { "killer", 60,60, atcommand_killer },
  9045. { "npcmove", 80,80, atcommand_npcmove },
  9046. { "killable", 40,40, atcommand_killable },
  9047. { "dropall", 40,40, atcommand_dropall },
  9048. { "storeall", 40,40, atcommand_storeall },
  9049. { "skillid", 40,40, atcommand_skillid },
  9050. { "useskill", 40,40, atcommand_useskill },
  9051. { "displayskill", 99,99, atcommand_displayskill },
  9052. { "snow", 99,99, atcommand_snow },
  9053. { "sakura", 99,99, atcommand_sakura },
  9054. { "clouds", 99,99, atcommand_clouds },
  9055. { "clouds2", 99,99, atcommand_clouds2 },
  9056. { "fog", 99,99, atcommand_fog },
  9057. { "fireworks", 99,99, atcommand_fireworks },
  9058. { "leaves", 99,99, atcommand_leaves },
  9059. { "summon", 60,60, atcommand_summon },
  9060. { "adjgmlvl", 99,99, atcommand_adjgmlvl },
  9061. { "adjcmdlvl", 99,99, atcommand_adjcmdlvl },
  9062. { "trade", 60,60, atcommand_trade },
  9063. { "send", 99,99, atcommand_send },
  9064. { "setbattleflag", 99,99, atcommand_setbattleflag },
  9065. { "unmute", 80,80, atcommand_unmute },
  9066. { "clearweather", 99,99, atcommand_clearweather },
  9067. { "uptime", 1,1, atcommand_uptime },
  9068. { "changesex", 60,60, atcommand_changesex },
  9069. { "mute", 80,80, atcommand_mute },
  9070. { "refresh", 1,1, atcommand_refresh },
  9071. { "identify", 40,40, atcommand_identify },
  9072. { "gmotd", 20,20, atcommand_gmotd },
  9073. { "misceffect", 50,50, atcommand_misceffect },
  9074. { "mobsearch", 10,10, atcommand_mobsearch },
  9075. { "cleanmap", 40,40, atcommand_cleanmap },
  9076. { "npctalk", 20,20, atcommand_npctalk },
  9077. { "npctalkc", 20,20, atcommand_npctalk },
  9078. { "pettalk", 10,10, atcommand_pettalk },
  9079. { "users", 40,40, atcommand_users },
  9080. { "reset", 40,40, atcommand_reset },
  9081. { "skilltree", 40,40, atcommand_skilltree },
  9082. { "marry", 40,40, atcommand_marry },
  9083. { "divorce", 40,40, atcommand_divorce },
  9084. { "sound", 40,40, atcommand_sound },
  9085. { "undisguiseall", 99,99, atcommand_undisguiseall },
  9086. { "disguiseall", 99,99, atcommand_disguiseall },
  9087. { "changelook", 60,60, atcommand_changelook },
  9088. { "autoloot", 10,10, atcommand_autoloot },
  9089. { "alootid", 10,10, atcommand_autolootitem },
  9090. { "mobinfo", 1,1, atcommand_mobinfo },
  9091. { "monsterinfo", 1,1, atcommand_mobinfo },
  9092. { "mi", 1,1, atcommand_mobinfo },
  9093. { "exp", 1,1, atcommand_exp },
  9094. { "adopt", 40,40, atcommand_adopt },
  9095. { "version", 1,1, atcommand_version },
  9096. { "mutearea", 99,99, atcommand_mutearea },
  9097. { "stfu", 99,99, atcommand_mutearea },
  9098. { "rates", 1,1, atcommand_rates },
  9099. { "iteminfo", 1,1, atcommand_iteminfo },
  9100. { "ii", 1,1, atcommand_iteminfo },
  9101. { "whodrops", 1,1, atcommand_whodrops },
  9102. { "whereis", 10,10, atcommand_whereis },
  9103. { "mapflag", 99,99, atcommand_mapflag },
  9104. { "me", 20,20, atcommand_me },
  9105. { "monsterignore", 99,99, atcommand_monsterignore },
  9106. { "battleignore", 99,99, atcommand_monsterignore },
  9107. { "fakename", 20,20, atcommand_fakename },
  9108. { "size", 20,20, atcommand_size },
  9109. { "showexp", 10,10, atcommand_showexp},
  9110. { "showzeny", 10,10, atcommand_showzeny},
  9111. { "showdelay", 1,1, atcommand_showdelay},
  9112. { "autotrade", 10,10, atcommand_autotrade },
  9113. { "at", 10,10, atcommand_autotrade },
  9114. { "changegm", 10,10, atcommand_changegm },
  9115. { "changeleader", 10,10, atcommand_changeleader },
  9116. { "partyoption", 10,10, atcommand_partyoption},
  9117. { "invite", 1,1, atcommand_invite },
  9118. { "duel", 1,1, atcommand_duel },
  9119. { "leave", 1,1, atcommand_leave },
  9120. { "accept", 1,1, atcommand_accept },
  9121. { "reject", 1,1, atcommand_reject },
  9122. { "main", 1,1, atcommand_main },
  9123. { "clone", 50,50, atcommand_clone },
  9124. { "slaveclone", 50,50, atcommand_clone },
  9125. { "evilclone", 50,50, atcommand_clone },
  9126. { "tonpc", 40,40, atcommand_tonpc },
  9127. { "commands", 1,1, atcommand_commands },
  9128. { "noask", 1,1, atcommand_noask },
  9129. { "request", 20,20, atcommand_request },
  9130. { "hlvl", 60,60, atcommand_homlevel },
  9131. { "hlevel", 60,60, atcommand_homlevel },
  9132. { "homlvl", 60,60, atcommand_homlevel },
  9133. { "homlvup", 60,60, atcommand_homlevel },
  9134. { "homlevel", 60,60, atcommand_homlevel },
  9135. { "homevolve", 60,60, atcommand_homevolution },
  9136. { "homevolution", 60,60, atcommand_homevolution },
  9137. { "makehomun", 60,60, atcommand_makehomun },
  9138. { "homfriendly", 60,60, atcommand_homfriendly },
  9139. { "homhungry", 60,60, atcommand_homhungry },
  9140. { "homtalk", 10,10, atcommand_homtalk },
  9141. { "hominfo", 1,1, atcommand_hominfo },
  9142. { "homstats", 1,1, atcommand_homstats },
  9143. { "homshuffle", 60,60, atcommand_homshuffle },
  9144. { "showmobs", 10,10, atcommand_showmobs },
  9145. { "feelreset", 10,10, atcommand_feelreset },
  9146. { "auction", 1,1, atcommand_auction },
  9147. { "mail", 1,1, atcommand_mail },
  9148. { "noks", 1,1, atcommand_ksprotection },
  9149. { "allowks", 40,40, atcommand_allowks },
  9150. { "cash", 60,60, atcommand_cash },
  9151. { "points", 60,60, atcommand_cash },
  9152. { "agitstart2", 60,60, atcommand_agitstart2 },
  9153. { "agitend2", 60,60, atcommand_agitend2 },
  9154. { "skreset", 60,60, atcommand_resetskill },
  9155. { "streset", 60,60, atcommand_resetstat },
  9156. { "storagelist", 40,40, atcommand_itemlist },
  9157. { "cartlist", 40,40, atcommand_itemlist },
  9158. { "itemlist", 40,40, atcommand_itemlist },
  9159. { "stats", 40,40, atcommand_stats },
  9160. { "delitem", 60,60, atcommand_delitem },
  9161. { "charcommands", 1,1, atcommand_commands },
  9162. { "font", 1,1, atcommand_font },
  9163. { "newplayer", 0,0, atcommand_newplayer },
  9164. };
  9165.  
  9166.  
  9167. /*==========================================
  9168. * Command lookup functions
  9169. *------------------------------------------*/
  9170. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  9171. {
  9172. int i;
  9173. if( *name == atcommand_symbol || *name == charcommand_symbol ) name++; // for backwards compatibility
  9174. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, strcmpi(atcommand_info[i].command, name) == 0 );
  9175. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  9176. }
  9177.  
  9178. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func)
  9179. {
  9180. int i;
  9181. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, atcommand_info[i].func == func );
  9182. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  9183. }
  9184.  
  9185.  
  9186. /*==========================================
  9187. * Retrieve the command's required gm level
  9188. *------------------------------------------*/
  9189. int get_atcommand_level(const AtCommandFunc func)
  9190. {
  9191. AtCommandInfo* info = get_atcommandinfo_byfunc(func);
  9192. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  9193. }
  9194.  
  9195.  
  9196. /// Executes an at-command.
  9197. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  9198. {
  9199. char charname[NAME_LENGTH], params[100];
  9200. char charname2[NAME_LENGTH], params2[100];
  9201. char command[100];
  9202. char output[CHAT_SIZE_MAX];
  9203. int x, y, z;
  9204. int lv = 0;
  9205.  
  9206. //Reconstructed message
  9207. char atcmd_msg[CHAT_SIZE_MAX];
  9208.  
  9209. TBL_PC * ssd = NULL; //sd for target
  9210. AtCommandInfo * info;
  9211.  
  9212. nullpo_retr(false, sd);
  9213.  
  9214. //Shouldn't happen
  9215. if( !message || !*message )
  9216. return false;
  9217.  
  9218. //Block NOCHAT but do not display it as a normal message
  9219. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  9220. return true;
  9221.  
  9222. // skip 10/11-langtype's codepage indicator, if detected
  9223. if( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  9224. message += 3;
  9225.  
  9226. //Should display as a normal message
  9227. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  9228. return false;
  9229.  
  9230. // type value 0 = server invoked: bypass restrictions
  9231. // 1 = player invoked
  9232. if( type )
  9233. {
  9234. //Commands are disabled on maps flagged as 'nocommand'
  9235. if( map[sd->bl.m].nocommand && pc_isGM(sd) < map[sd->bl.m].nocommand )
  9236. {
  9237. clif_displaymessage(fd, msg_txt(143));
  9238. return false;
  9239. }
  9240.  
  9241. //Displays as a normal message for Non-GMs
  9242. if( battle_config.atc_gmonly != 0 && pc_isGM(sd) == 0 )
  9243. return false;
  9244. }
  9245.  
  9246. while (*message == charcommand_symbol)
  9247. {
  9248. //Checks to see if #command has a name or a name + parameters.
  9249. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  9250. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  9251.  
  9252. //z always has the value of the scan that was successful
  9253. z = ( x > 1 ) ? x : y;
  9254.  
  9255. if ( (ssd = map_nick2sd(charname)) == NULL && ( (ssd = map_nick2sd(charname2)) == NULL ) )
  9256. {
  9257. sprintf(output, "%s failed. Player not found.", command);
  9258. clif_displaymessage(fd, output);
  9259. return true;
  9260. }
  9261.  
  9262. //#command + name means the sufficient target was used and anything else after
  9263. //can be looked at by the actual command function since most scan to see if the
  9264. //right parameters are used.
  9265. if ( x > 2 ) {
  9266. sprintf(atcmd_msg, "%s %s", command, params);
  9267. break;
  9268. }
  9269. else if ( y > 2 ) {
  9270. sprintf(atcmd_msg, "%s %s", command, params2);
  9271. break;
  9272. }
  9273. //Regardless of what style the #command is used, if it's correct, it will always have
  9274. //this value if there is no parameter. Send it as just the #command
  9275. else if ( z == 2 ) {
  9276. sprintf(atcmd_msg, "%s", command);
  9277. break;
  9278. }
  9279.  
  9280. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  9281. clif_displaymessage(fd, output);
  9282. return true;
  9283. }
  9284.  
  9285. if (*message == atcommand_symbol) {
  9286. //atcmd_msg is constructed above differently for charcommands
  9287. //it's copied from message if not a charcommand so it can
  9288. //pass through the rest of the code compatible with both symbols
  9289. sprintf(atcmd_msg, "%s", message);
  9290. }
  9291.  
  9292. //Clearing these to be used once more.
  9293. memset(command, '\0', sizeof(command));
  9294. memset(params, '\0', sizeof(params));
  9295.  
  9296. //check to see if any params exist within this command
  9297. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  9298. params[0] = '\0';
  9299.  
  9300. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9301. info = get_atcommandinfo_byname(command);
  9302. if( info == NULL || info->func == NULL || ( type && ((*atcmd_msg == atcommand_symbol && pc_isGM(sd) < info->level) || (*atcmd_msg == charcommand_symbol && pc_isGM(sd) < info->level2)) ) )
  9303. {
  9304. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  9305. clif_displaymessage(fd, output);
  9306. return true;
  9307. }
  9308.  
  9309. //Attempt to use the command
  9310. if( strcmpi("adjgmlvl",command+1) && ssd ) { lv = ssd->gmlevel; ssd->gmlevel = sd->gmlevel; }
  9311. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  9312. {
  9313. sprintf(output,msg_txt(154), command); // %s failed.
  9314. clif_displaymessage(fd, output);
  9315. }
  9316. if( strcmpi("adjgmlvl",command+1) && ssd ) ssd->gmlevel = lv;
  9317.  
  9318. //Log atcommands
  9319. if( *atcmd_msg == atcommand_symbol )
  9320. log_atcommand(sd, info->level, atcmd_msg);
  9321.  
  9322. //Log Charcommands
  9323. if( *atcmd_msg == charcommand_symbol && ssd != NULL )
  9324. log_atcommand(sd, info->level2, message);
  9325.  
  9326. return true;
  9327. }
  9328.  
  9329.  
  9330. /*==========================================
  9331. *
  9332. *------------------------------------------*/
  9333. int atcommand_config_read(const char* cfgName)
  9334. {
  9335. char line[1024], w1[1024], w2[1024], w3[1024];
  9336. AtCommandInfo* p;
  9337. FILE* fp;
  9338.  
  9339. if( (fp = fopen(cfgName, "r")) == NULL )
  9340. {
  9341. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  9342. return 1;
  9343. }
  9344.  
  9345. while( fgets(line, sizeof(line), fp) )
  9346. {
  9347. if( line[0] == '/' && line[1] == '/' )
  9348. continue;
  9349.  
  9350. if( (sscanf(line, "%1023[^:]:%1023[^,],%1023s", w1, w2, w3)) != 3 && ( sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2
  9351. && strcmpi(w1, "import") != 0 ) && strcmpi(w1, "command_symbol") != 0 && strcmpi(w1, "char_symbol") != 0 )
  9352. continue;
  9353.  
  9354. p = get_atcommandinfo_byname(w1);
  9355. if( p != NULL )
  9356. {
  9357. p->level = atoi(w2);
  9358. p->level = cap_value(p->level, 0, 100);
  9359. if( (sscanf(line, "%1023[^:]:%1023s", w1, w2) == 2) && (sscanf(line, "%1023[^:]:%1023[^,],%1023s", w1, w2, w3)) != 3 )
  9360. {
  9361. ShowWarning("atcommand_conf: setting %s:%d is deprecated! Please see atcommand_athena.conf for the new setting format.\n",w1,atoi(w2));
  9362. ShowWarning("atcommand_conf: defaulting %s charcommand level to %d.\n",w1,atoi(w2));
  9363. p->level2 = atoi(w2);
  9364. }
  9365. else {
  9366. p->level2 = atoi(w3);
  9367. }
  9368. p->level2 = cap_value(p->level2, 0, 100);
  9369. }
  9370. else
  9371. if( strcmpi(w1, "import") == 0 )
  9372. atcommand_config_read(w2);
  9373. else
  9374. if( strcmpi(w1, "command_symbol") == 0 &&
  9375. w2[0] > 31 && // control characters
  9376. w2[0] != '/' && // symbol of standard ragnarok GM commands
  9377. w2[0] != '%' && // symbol of party chat speaking
  9378. w2[0] != '$' && // symbol of guild chat speaking
  9379. w2[0] != '#' ) // remote symbol
  9380. atcommand_symbol = w2[0];
  9381. else
  9382. if( strcmpi(w1, "char_symbol") == 0 &&
  9383. w2[0] > 31 &&
  9384. w2[0] != '/' &&
  9385. w2[0] != '%' &&
  9386. w2[0] != '$' &&
  9387. w2[0] != '@' )
  9388. charcommand_symbol = w2[0];
  9389. else
  9390. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  9391. }
  9392. fclose(fp);
  9393.  
  9394. return 0;
  9395. }
  9396.  
  9397. void do_init_atcommand()
  9398. {
  9399. }
  9400.  
  9401. void do_final_atcommand()
  9402. {
  9403. }
  9404.  
  9405.  
  9406. // commands that need to go _after_ the commands table
  9407.  
  9408. /*==========================================
  9409. * @commands Lists available @ commands to you
  9410. *------------------------------------------*/
  9411. ACMD_FUNC(commands)
  9412. {
  9413. char line_buff[CHATBOX_SIZE];
  9414. int i, gm_lvl = pc_isGM(sd), count = 0;
  9415. char* cur = line_buff;
  9416.  
  9417. memset(line_buff,' ',CHATBOX_SIZE);
  9418. line_buff[CHATBOX_SIZE-1] = 0;
  9419.  
  9420. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  9421.  
  9422. for( i = 0; i < ARRAYLENGTH(atcommand_info); i++ )
  9423. {
  9424. unsigned int slen;
  9425.  
  9426. if( gm_lvl < atcommand_info[i].level && stristr(command,"commands") )
  9427. continue;
  9428. if( gm_lvl < atcommand_info[i].level2 && stristr(command,"charcommands") )
  9429. continue;
  9430.  
  9431. slen = strlen(atcommand_info[i].command);
  9432.  
  9433. // flush the text buffer if this command won't fit into it
  9434. if( slen + cur - line_buff >= CHATBOX_SIZE )
  9435. {
  9436. clif_displaymessage(fd,line_buff);
  9437. cur = line_buff;
  9438. memset(line_buff,' ',CHATBOX_SIZE);
  9439. line_buff[CHATBOX_SIZE-1] = 0;
  9440. }
  9441.  
  9442. memcpy(cur,atcommand_info[i].command,slen);
  9443. cur += slen+(10-slen%10);
  9444.  
  9445. count++;
  9446. }
  9447. clif_displaymessage(fd,line_buff);
  9448.  
  9449. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  9450. clif_displaymessage(fd, atcmd_output);
  9451.  
  9452. return 0;
  9453. }
Advertisement
Add Comment
Please, Sign In to add comment