Advertisement
Guest User

Untitled

a guest
Oct 24th, 2013
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 298.99 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/random.h"
  12. #include "../common/socket.h"
  13. #include "../common/strlib.h"
  14. #include "../common/utils.h"
  15. #include "../common/conf.h"
  16.  
  17. #include "atcommand.h"
  18. #include "battle.h"
  19. #include "chat.h"
  20. #include "channel.h"
  21. #include "clif.h"
  22. #include "chrif.h"
  23. #include "duel.h"
  24. #include "instance.h"
  25. #include "intif.h"
  26. #include "itemdb.h"
  27. #include "log.h"
  28. #include "map.h"
  29. #include "pc.h"
  30. #include "pc_groups.h" // groupid2name
  31. #include "status.h"
  32. #include "skill.h"
  33. #include "mob.h"
  34. #include "npc.h"
  35. #include "pet.h"
  36. #include "homunculus.h"
  37. #include "mail.h"
  38. #include "mercenary.h"
  39. #include "elemental.h"
  40. #include "party.h"
  41. #include "guild.h"
  42. #include "script.h"
  43. #include "storage.h"
  44. #include "trade.h"
  45. #include "unit.h"
  46. #include "mapreg.h"
  47. #include "quest.h"
  48.  
  49. #include <stdio.h>
  50. #include <stdlib.h>
  51. #include <string.h>
  52. #include <math.h>
  53.  
  54.  
  55. #define ATCOMMAND_LENGTH 50
  56. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  57.  
  58. typedef struct AtCommandInfo AtCommandInfo;
  59. typedef struct AliasInfo AliasInfo;
  60.  
  61. int atcmd_binding_count = 0;
  62.  
  63. struct AtCommandInfo {
  64. char command[ATCOMMAND_LENGTH];
  65. AtCommandFunc func;
  66. char* at_groups;/* quick @commands "can-use" lookup */
  67. char* char_groups;/* quick @charcommands "can-use" lookup */
  68. int restriction; //prevent : 1 console, 2 script...
  69. };
  70.  
  71. struct AliasInfo {
  72. AtCommandInfo *command;
  73. char alias[ATCOMMAND_LENGTH];
  74. };
  75.  
  76.  
  77. char atcommand_symbol = '@'; // first char of the commands
  78. char charcommand_symbol = '#';
  79.  
  80. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  81. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  82. static config_t atcommand_config;
  83.  
  84. static char atcmd_output[CHAT_SIZE_MAX];
  85. static char atcmd_player_name[NAME_LENGTH];
  86.  
  87. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  88. static const char* atcommand_checkalias(const char *aliasname); // @help
  89. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  90.  
  91. // @commands (script-based)
  92. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  93. int i = 0;
  94.  
  95. if( *name == atcommand_symbol || *name == charcommand_symbol )
  96. name++; // for backwards compatibility
  97.  
  98. ARR_FIND( 0, atcmd_binding_count, i, strcmp(atcmd_binding[i]->command, name) == 0 );
  99.  
  100. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  101. }
  102.  
  103. /**
  104. * retrieves the help string associated with a given command.
  105. *
  106. * @param name the name of the command to retrieve help information for
  107. * @return the string associated with the command, or NULL
  108. */
  109. static const char* atcommand_help_string(const char* command)
  110. {
  111. const char* str = NULL;
  112. config_setting_t* info;
  113.  
  114. if( *command == atcommand_symbol || *command == charcommand_symbol )
  115. {// remove the prefix symbol for the raw name of the command
  116. command ++;
  117. }
  118.  
  119. // convert alias to the real command name
  120. command = atcommand_checkalias(command);
  121.  
  122. // attept to find the first default help command
  123. info = config_lookup(&atcommand_config, "help");
  124.  
  125. if( info == NULL )
  126. {// failed to find the help property in the configuration file
  127. return NULL;
  128. }
  129.  
  130. if( !config_setting_lookup_string( info, command, &str ) )
  131. {// failed to find the matching help string
  132. return NULL;
  133. }
  134.  
  135. // push the result from the method
  136. return str;
  137. }
  138.  
  139.  
  140. /*==========================================
  141. * @send (used for testing packet sends from the client)
  142. *------------------------------------------*/
  143. ACMD_FUNC(send)
  144. {
  145. int len=0,off,end,type;
  146. long num;
  147.  
  148. // read message type as hex number (without the 0x)
  149. if(!message || !*message ||
  150. !((sscanf(message, "len %x", &type)==1 && (len=1))
  151. || sscanf(message, "%x", &type)==1) )
  152. {
  153. int i;
  154. for (i = 900; i <= 903; ++i)
  155. clif_displaymessage(fd, msg_txt(sd,i));
  156. return -1;
  157. }
  158.  
  159. #define PARSE_ERROR(error,p) \
  160. {\
  161. clif_displaymessage(fd, (error));\
  162. sprintf(atcmd_output, ">%s", (p));\
  163. clif_displaymessage(fd, atcmd_output);\
  164. }
  165. //define PARSE_ERROR
  166.  
  167. #define CHECK_EOS(p) \
  168. if(*(p) == 0){\
  169. clif_displaymessage(fd, "Unexpected end of string");\
  170. return -1;\
  171. }
  172. //define CHECK_EOS
  173.  
  174. #define SKIP_VALUE(p) \
  175. {\
  176. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  177. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  178. }
  179. //define SKIP_VALUE
  180.  
  181. #define GET_VALUE(p,num) \
  182. {\
  183. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  184. PARSE_ERROR("Invalid number in:",(p));\
  185. return -1;\
  186. }\
  187. }
  188. //define GET_VALUE
  189.  
  190. if (type > 0 && type < MAX_PACKET_DB) {
  191.  
  192. if(len)
  193. {// show packet length
  194. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  195. clif_displaymessage(fd, atcmd_output);
  196. return 0;
  197. }
  198.  
  199. len=packet_db[sd->packet_ver][type].len;
  200. off=2;
  201. if(len == 0)
  202. {// unknown packet - ERROR
  203. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  204. clif_displaymessage(fd, atcmd_output);
  205. return -1;
  206. } else if(len == -1)
  207. {// dynamic packet
  208. len=SHRT_MAX-4; // maximum length
  209. off=4;
  210. }
  211. WFIFOHEAD(fd, len);
  212. WFIFOW(fd,0)=TOW(type);
  213.  
  214. // parse packet contents
  215. SKIP_VALUE(message);
  216. while(*message != 0 && off < len){
  217. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  218. {// default (byte)
  219. GET_VALUE(message,num);
  220. WFIFOB(fd,off)=TOB(num);
  221. ++off;
  222. } else if(TOUPPER(*message) == 'B')
  223. {// byte
  224. ++message;
  225. GET_VALUE(message,num);
  226. WFIFOB(fd,off)=TOB(num);
  227. ++off;
  228. } else if(TOUPPER(*message) == 'W')
  229. {// word (2 bytes)
  230. ++message;
  231. GET_VALUE(message,num);
  232. WFIFOW(fd,off)=TOW(num);
  233. off+=2;
  234. } else if(TOUPPER(*message) == 'L')
  235. {// long word (4 bytes)
  236. ++message;
  237. GET_VALUE(message,num);
  238. WFIFOL(fd,off)=TOL(num);
  239. off+=4;
  240. } else if(TOUPPER(*message) == 'S')
  241. {// string - escapes are valid
  242. // get string length - num <= 0 means not fixed length (default)
  243. ++message;
  244. if(*message == '"'){
  245. num=0;
  246. } else {
  247. GET_VALUE(message,num);
  248. while(*message != '"')
  249. {// find start of string
  250. if(*message == 0 || ISSPACE(*message)){
  251. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  252. return -1;
  253. }
  254. ++message;
  255. }
  256. }
  257.  
  258. // parse string
  259. ++message;
  260. CHECK_EOS(message);
  261. end=(num<=0? 0: min(off+((int)num),len));
  262. for(; *message != '"' && (off < end || end == 0); ++off){
  263. if(*message == '\\'){
  264. ++message;
  265. CHECK_EOS(message);
  266. switch(*message){
  267. case 'a': num=0x07; break; // Bell
  268. case 'b': num=0x08; break; // Backspace
  269. case 't': num=0x09; break; // Horizontal tab
  270. case 'n': num=0x0A; break; // Line feed
  271. case 'v': num=0x0B; break; // Vertical tab
  272. case 'f': num=0x0C; break; // Form feed
  273. case 'r': num=0x0D; break; // Carriage return
  274. case 'e': num=0x1B; break; // Escape
  275. default: num=*message; break;
  276. case 'x': // Hexadecimal
  277. {
  278. ++message;
  279. CHECK_EOS(message);
  280. if(!ISXDIGIT(*message)){
  281. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  282. return -1;
  283. }
  284. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  285. if(ISXDIGIT(*message)){
  286. ++message;
  287. CHECK_EOS(message);
  288. num<<=8;
  289. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  290. }
  291. WFIFOB(fd,off)=TOB(num);
  292. ++message;
  293. CHECK_EOS(message);
  294. continue;
  295. }
  296. case '0':
  297. case '1':
  298. case '2':
  299. case '3':
  300. case '4':
  301. case '5':
  302. case '6':
  303. case '7': // Octal
  304. {
  305. num=*message-'0'; // 1st octal digit
  306. ++message;
  307. CHECK_EOS(message);
  308. if(ISDIGIT(*message) && *message < '8'){
  309. num<<=3;
  310. num+=*message-'0'; // 2nd octal digit
  311. ++message;
  312. CHECK_EOS(message);
  313. if(ISDIGIT(*message) && *message < '8'){
  314. num<<=3;
  315. num+=*message-'0'; // 3rd octal digit
  316. ++message;
  317. CHECK_EOS(message);
  318. }
  319. }
  320. WFIFOB(fd,off)=TOB(num);
  321. continue;
  322. }
  323. }
  324. } else
  325. num=*message;
  326. WFIFOB(fd,off)=TOB(num);
  327. ++message;
  328. CHECK_EOS(message);
  329. }//for
  330. while(*message != '"')
  331. {// ignore extra characters
  332. ++message;
  333. CHECK_EOS(message);
  334. }
  335.  
  336. // terminate the string
  337. if(off < end)
  338. {// fill the rest with 0's
  339. memset(WFIFOP(fd,off),0,end-off);
  340. off=end;
  341. }
  342. } else
  343. {// unknown
  344. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  345. return -1;
  346. }
  347. SKIP_VALUE(message);
  348. }
  349.  
  350. if(packet_db[sd->packet_ver][type].len == -1)
  351. {// send dynamic packet
  352. WFIFOW(fd,2)=TOW(off);
  353. WFIFOSET(fd,off);
  354. } else
  355. {// send static packet
  356. if(off < len)
  357. memset(WFIFOP(fd,off),0,len-off);
  358. WFIFOSET(fd,len);
  359. }
  360. } else {
  361. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  362. return -1;
  363. }
  364. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  365. clif_displaymessage(fd, atcmd_output);
  366. return 0;
  367. #undef PARSE_ERROR
  368. #undef CHECK_EOS
  369. #undef SKIP_VALUE
  370. #undef GET_VALUE
  371. }
  372.  
  373. /*==========================================
  374. * @rura, @warp, @mapmove
  375. *------------------------------------------*/
  376. ACMD_FUNC(mapmove)
  377. {
  378. char map_name[MAP_NAME_LENGTH_EXT];
  379. unsigned short mapindex;
  380. short x = 0, y = 0;
  381. int16 m = -1;
  382.  
  383. nullpo_retr(-1, sd);
  384.  
  385. memset(map_name, '\0', sizeof(map_name));
  386.  
  387. if (!message || !*message ||
  388. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  389. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  390. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  391. return -1;
  392. }
  393.  
  394. mapindex = mapindex_name2id(map_name);
  395. if (mapindex)
  396. m = map_mapindex2mapid(mapindex);
  397.  
  398. if (!mapindex) { // m < 0 means on different server! [Kevin]
  399. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  400. return -1;
  401. }
  402.  
  403. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  404. { //This is to prevent the pc_setpos call from printing an error.
  405. clif_displaymessage(fd, msg_txt(sd,2));
  406. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  407. x = y = 0; //Invalid cell, use random spot.
  408. }
  409. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  410. clif_displaymessage(fd, msg_txt(sd,247));
  411. return -1;
  412. }
  413. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  414. clif_displaymessage(fd, msg_txt(sd,248));
  415. return -1;
  416. }
  417. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  418. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  419. return -1;
  420. }
  421.  
  422. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  423. return 0;
  424. }
  425.  
  426. /*==========================================
  427. * Displays where a character is. Corrected version by Silent. [Skotlex]
  428. *------------------------------------------*/
  429. ACMD_FUNC(where)
  430. {
  431. struct map_session_data* pl_sd;
  432.  
  433. nullpo_retr(-1, sd);
  434. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  435.  
  436. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  437. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  438. return -1;
  439. }
  440.  
  441. pl_sd = map_nick2sd(atcmd_player_name);
  442. if (pl_sd == NULL ||
  443. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  444. (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  445. ) {
  446. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  447. return -1;
  448. }
  449.  
  450. 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);
  451. clif_displaymessage(fd, atcmd_output);
  452.  
  453. return 0;
  454. }
  455.  
  456. /*==========================================
  457. *
  458. *------------------------------------------*/
  459. ACMD_FUNC(jumpto)
  460. {
  461. struct map_session_data *pl_sd = NULL;
  462.  
  463. nullpo_retr(-1, sd);
  464.  
  465. if (!message || !*message) {
  466. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  467. return -1;
  468. }
  469.  
  470. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  471. {
  472. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  473. return -1;
  474. }
  475.  
  476. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  477. {
  478. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  479. return -1;
  480. }
  481.  
  482. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  483. {
  484. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  485. return -1;
  486. }
  487.  
  488. if( pc_isdead(sd) )
  489. {
  490. clif_displaymessage(fd, msg_txt(sd,664));
  491. return -1;
  492. }
  493.  
  494. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  495. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  496. clif_displaymessage(fd, atcmd_output);
  497.  
  498. return 0;
  499. }
  500.  
  501. /*==========================================
  502. *
  503. *------------------------------------------*/
  504. ACMD_FUNC(jump)
  505. {
  506. short x = 0, y = 0;
  507.  
  508. nullpo_retr(-1, sd);
  509.  
  510. memset(atcmd_output, '\0', sizeof(atcmd_output));
  511.  
  512. sscanf(message, "%hd %hd", &x, &y);
  513.  
  514. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  515. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  516. return -1;
  517. }
  518.  
  519. if( pc_isdead(sd) )
  520. {
  521. clif_displaymessage(fd, msg_txt(sd,664));
  522. return -1;
  523. }
  524.  
  525. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  526. { //This is to prevent the pc_setpos call from printing an error.
  527. clif_displaymessage(fd, msg_txt(sd,2));
  528. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  529. x = y = 0; //Invalid cell, use random spot.
  530. }
  531.  
  532. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  533. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  534. clif_displaymessage(fd, atcmd_output);
  535. return 0;
  536. }
  537.  
  538. /*==========================================
  539. * Display list of online characters with
  540. * various info.
  541. *------------------------------------------*/
  542. ACMD_FUNC(who) {
  543. struct map_session_data *pl_sd = NULL;
  544. struct s_mapiterator *iter = NULL;
  545. char map_name[MAP_NAME_LENGTH_EXT] = "";
  546. char player_name[NAME_LENGTH] = "";
  547. int count = 0;
  548. int level = 0;
  549. StringBuf buf;
  550. /**
  551. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  552. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  553. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  554. */
  555. int display_type = 1;
  556. int map_id = -1;
  557.  
  558. nullpo_retr(-1, sd);
  559.  
  560. if (strstr(command, "map") != NULL) {
  561. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  562. map_id = sd->bl.m;
  563. } else {
  564. sscanf(message, "%23s", player_name);
  565. }
  566.  
  567. if (strstr(command, "2") != NULL)
  568. display_type = 2;
  569. else if (strstr(command, "3") != NULL)
  570. display_type = 3;
  571.  
  572. level = pc_get_group_level(sd);
  573. StringBuf_Init(&buf);
  574.  
  575. iter = mapit_getallusers();
  576. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  577. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  578. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  579. || (map_id >= 0 && pl_sd->bl.m != map_id))
  580. continue;
  581. switch (display_type) {
  582. case 2: {
  583. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  584. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  585. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  586. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  587. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  588. break;
  589. }
  590. case 3: {
  591. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  592. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  593. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  594. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  595. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  596. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  597. break;
  598. }
  599. default: {
  600. struct party_data *p = party_search(pl_sd->status.party_id);
  601. struct guild *g = pl_sd->guild;
  602.  
  603. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  604. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  605. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  606. if (p != NULL)
  607. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  608. if (g != NULL)
  609. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  610. break;
  611. }
  612. }
  613. clif_displaymessage(fd, StringBuf_Value(&buf));
  614. StringBuf_Clear(&buf);
  615. count++;
  616. }
  617. }
  618. mapit_free(iter);
  619.  
  620. if (map_id < 0) {
  621. if (count == 0)
  622. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  623. else if (count == 1)
  624. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  625. else
  626. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  627. } else {
  628. if (count == 0)
  629. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  630. else if (count == 1)
  631. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  632. else
  633. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  634. }
  635. clif_displaymessage(fd, StringBuf_Value(&buf));
  636. StringBuf_Destroy(&buf);
  637. return 0;
  638. }
  639.  
  640. /*==========================================
  641. *
  642. *------------------------------------------*/
  643. ACMD_FUNC(whogm)
  644. {
  645. struct map_session_data* pl_sd;
  646. struct s_mapiterator* iter;
  647. int j, count;
  648. int pl_level, level;
  649. char match_text[CHAT_SIZE_MAX];
  650. char player_name[NAME_LENGTH];
  651. struct guild *g;
  652. struct party_data *p;
  653.  
  654. nullpo_retr(-1, sd);
  655.  
  656. memset(atcmd_output, '\0', sizeof(atcmd_output));
  657. memset(match_text, '\0', sizeof(match_text));
  658. memset(player_name, '\0', sizeof(player_name));
  659.  
  660. if (sscanf(message, "%199[^\n]", match_text) < 1)
  661. strcpy(match_text, "");
  662. for (j = 0; match_text[j]; j++)
  663. match_text[j] = TOLOWER(match_text[j]);
  664.  
  665. count = 0;
  666. level = pc_get_group_level(sd);
  667.  
  668. iter = mapit_getallusers();
  669. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  670. {
  671. pl_level = pc_get_group_level(pl_sd);
  672. if (!pl_level)
  673. continue;
  674.  
  675. if (match_text[0])
  676. {
  677. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  678. for (j = 0; player_name[j]; j++)
  679. player_name[j] = TOLOWER(player_name[j]);
  680. // search with no case sensitive
  681. if (strstr(player_name, match_text) == NULL)
  682. continue;
  683. }
  684. if (pl_level > level) {
  685. if (pl_sd->sc.option & OPTION_INVISIBLE)
  686. continue;
  687. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  688. clif_displaymessage(fd, atcmd_output);
  689. count++;
  690. continue;
  691. }
  692.  
  693. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  694. pl_sd->status.name, pl_level,
  695. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  696. clif_displaymessage(fd, atcmd_output);
  697.  
  698. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  699. pl_sd->status.base_level,
  700. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  701. clif_displaymessage(fd, atcmd_output);
  702.  
  703. p = party_search(pl_sd->status.party_id);
  704. g = pl_sd->guild;
  705.  
  706. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  707. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  708.  
  709. clif_displaymessage(fd, atcmd_output);
  710. count++;
  711. }
  712. mapit_free(iter);
  713.  
  714. if (count == 0)
  715. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  716. else if (count == 1)
  717. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  718. else {
  719. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  720. clif_displaymessage(fd, atcmd_output);
  721. }
  722.  
  723. return 0;
  724. }
  725.  
  726. /*==========================================
  727. *
  728. *------------------------------------------*/
  729. ACMD_FUNC(save)
  730. {
  731. nullpo_retr(-1, sd);
  732.  
  733. if( map[sd->bl.m].instance_id ) {
  734. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  735. return 1;
  736. }
  737.  
  738. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  739. if (sd->status.pet_id > 0 && sd->pd)
  740. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  741.  
  742. chrif_save(sd,0);
  743.  
  744. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  745.  
  746. return 0;
  747. }
  748.  
  749. /*==========================================
  750. *
  751. *------------------------------------------*/
  752. ACMD_FUNC(load)
  753. {
  754. int16 m;
  755.  
  756. nullpo_retr(-1, sd);
  757.  
  758. m = map_mapindex2mapid(sd->status.save_point.map);
  759. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  760. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  761. return -1;
  762. }
  763. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  764. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  765. return -1;
  766. }
  767.  
  768. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  769. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  770.  
  771. return 0;
  772. }
  773.  
  774. /*==========================================
  775. *
  776. *------------------------------------------*/
  777. ACMD_FUNC(speed)
  778. {
  779. int speed;
  780.  
  781. nullpo_retr(-1, sd);
  782.  
  783. memset(atcmd_output, '\0', sizeof(atcmd_output));
  784.  
  785. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  786. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  787. clif_displaymessage(fd, atcmd_output);
  788. return -1;
  789. }
  790.  
  791. if (speed < 0) {
  792. sd->base_status.speed = DEFAULT_WALK_SPEED;
  793. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  794. } else {
  795. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  796. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  797. }
  798. status_calc_bl(&sd->bl, SCB_SPEED);
  799. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  800. return 0;
  801. }
  802.  
  803. /*==========================================
  804. *
  805. *------------------------------------------*/
  806. ACMD_FUNC(storage)
  807. {
  808. nullpo_retr(-1, sd);
  809.  
  810. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  811. return -1;
  812.  
  813. if (storage_storageopen(sd) == 1)
  814. { //Already open.
  815. clif_displaymessage(fd, msg_txt(sd,250));
  816. return -1;
  817. }
  818.  
  819. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  820.  
  821. return 0;
  822. }
  823.  
  824.  
  825. /*==========================================
  826. *
  827. *------------------------------------------*/
  828. ACMD_FUNC(guildstorage)
  829. {
  830. nullpo_retr(-1, sd);
  831.  
  832. if (!sd->status.guild_id) {
  833. clif_displaymessage(fd, msg_txt(sd,252));
  834. return -1;
  835. }
  836.  
  837. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  838. return -1;
  839.  
  840. if (sd->state.storage_flag == 1) {
  841. clif_displaymessage(fd, msg_txt(sd,250));
  842. return -1;
  843. }
  844.  
  845. if (sd->state.storage_flag == 2) {
  846. clif_displaymessage(fd, msg_txt(sd,251));
  847. return -1;
  848. }
  849.  
  850. storage_guild_storageopen(sd);
  851. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  852. return 0;
  853. }
  854.  
  855. /*==========================================
  856. *
  857. *------------------------------------------*/
  858. ACMD_FUNC(option)
  859. {
  860. int param1 = 0, param2 = 0, param3 = 0;
  861. nullpo_retr(-1, sd);
  862.  
  863. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  864. {// failed to match the parameters so inform the user of the options
  865. const char* text;
  866.  
  867. // attempt to find the setting information for this command
  868. text = atcommand_help_string( command );
  869.  
  870. // notify the user of the requirement to enter an option
  871. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  872.  
  873. if( text )
  874. {// send the help text associated with this command
  875. clif_displaymessage( fd, text );
  876. }
  877.  
  878. return -1;
  879. }
  880.  
  881. sd->sc.opt1 = param1;
  882. sd->sc.opt2 = param2;
  883. pc_setoption(sd, param3);
  884.  
  885. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  886.  
  887. return 0;
  888. }
  889.  
  890. /*==========================================
  891. *
  892. *------------------------------------------*/
  893. ACMD_FUNC(hide)
  894. {
  895. nullpo_retr(-1, sd);
  896. if (sd->sc.option & OPTION_INVISIBLE) {
  897. sd->sc.option &= ~OPTION_INVISIBLE;
  898. if (sd->disguise)
  899. status_set_viewdata(&sd->bl, sd->disguise);
  900. else
  901. status_set_viewdata(&sd->bl, sd->status.class_);
  902. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  903.  
  904. // increment the number of pvp players on the map
  905. map[sd->bl.m].users_pvp++;
  906.  
  907. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  908. {// register the player for ranking calculations
  909. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  910. }
  911. //bugreport:2266
  912. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  913. } else {
  914. sd->sc.option |= OPTION_INVISIBLE;
  915. sd->vd.class_ = INVISIBLE_CLASS;
  916. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  917.  
  918. // decrement the number of pvp players on the map
  919. map[sd->bl.m].users_pvp--;
  920.  
  921. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  922. {// unregister the player for ranking
  923. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  924. sd->pvp_timer = INVALID_TIMER;
  925. }
  926. }
  927. clif_changeoption(&sd->bl);
  928.  
  929. return 0;
  930. }
  931.  
  932. /*==========================================
  933. * Changes a character's class
  934. *------------------------------------------*/
  935. ACMD_FUNC(jobchange)
  936. {
  937. int job = 0, upper = 0;
  938. const char* text;
  939. nullpo_retr(-1, sd);
  940.  
  941. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  942. int i;
  943. bool found = false;
  944.  
  945. upper = 0;
  946.  
  947. // Normal Jobs
  948. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ){
  949. if (strncmpi(message, job_name(i), 16) == 0) {
  950. job = i;
  951. found = true;
  952. }
  953. }
  954.  
  955. // High Jobs, Babys and Third
  956. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ){
  957. if (strncmpi(message, job_name(i), 16) == 0) {
  958. job = i;
  959. found = true;
  960. }
  961. }
  962.  
  963. if (!found) {
  964. text = atcommand_help_string(command);
  965. if (text)
  966. clif_displaymessage(fd, text);
  967. return -1;
  968. }
  969. }
  970.  
  971. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK
  972. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  973. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
  974. ){ // Deny direct transformation into dummy jobs
  975. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  976. return 0;
  977. }
  978.  
  979. if (pcdb_checkid(job))
  980. {
  981. if (pc_jobchange(sd, job, upper) == 0)
  982. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  983. else {
  984. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  985. return -1;
  986. }
  987. } else {
  988. text = atcommand_help_string(command);
  989. if (text)
  990. clif_displaymessage(fd, text);
  991. return -1;
  992. }
  993.  
  994. return 0;
  995. }
  996.  
  997. /*==========================================
  998. *
  999. *------------------------------------------*/
  1000. ACMD_FUNC(kill)
  1001. {
  1002. nullpo_retr(-1, sd);
  1003. status_kill(&sd->bl);
  1004. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  1005. if (fd != sd->fd)
  1006. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  1007. return 0;
  1008. }
  1009.  
  1010. /*==========================================
  1011. *
  1012. *------------------------------------------*/
  1013. ACMD_FUNC(alive)
  1014. {
  1015. nullpo_retr(-1, sd);
  1016. if (!status_revive(&sd->bl, 100, 100))
  1017. {
  1018. clif_displaymessage(fd, msg_txt(sd,667));
  1019. return -1;
  1020. }
  1021. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1022. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  1023. return 0;
  1024. }
  1025.  
  1026. /*==========================================
  1027. * +kamic [LuzZza]
  1028. *------------------------------------------*/
  1029. ACMD_FUNC(kami)
  1030. {
  1031. unsigned long color=0;
  1032. nullpo_retr(-1, sd);
  1033.  
  1034. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1035.  
  1036. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1037. if (!message || !*message) {
  1038. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1039. return -1;
  1040. }
  1041.  
  1042. sscanf(message, "%199[^\n]", atcmd_output);
  1043. if (strstr(command, "l") != NULL)
  1044. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  1045. else
  1046. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1047. } else {
  1048. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1049. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  1050. return -1;
  1051. }
  1052.  
  1053. if(color > 0xFFFFFF) {
  1054. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  1055. return -1;
  1056. }
  1057. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1058. }
  1059. return 0;
  1060. }
  1061.  
  1062. /*==========================================
  1063. *
  1064. *------------------------------------------*/
  1065. ACMD_FUNC(heal)
  1066. {
  1067. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1068. nullpo_retr(-1, sd);
  1069.  
  1070. sscanf(message, "%d %d", &hp, &sp);
  1071.  
  1072. // some overflow checks
  1073. if( hp == INT_MIN ) hp++;
  1074. if( sp == INT_MIN ) sp++;
  1075.  
  1076. if ( hp == 0 && sp == 0 ) {
  1077. if (!status_percent_heal(&sd->bl, 100, 100))
  1078. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1079. else
  1080. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1081. return 0;
  1082. }
  1083.  
  1084. if ( hp > 0 && sp >= 0 ) {
  1085. if(!status_heal(&sd->bl, hp, sp, 0))
  1086. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1087. else
  1088. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1089. return 0;
  1090. }
  1091.  
  1092. if ( hp < 0 && sp <= 0 ) {
  1093. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1094. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1095. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1096. return 0;
  1097. }
  1098.  
  1099. //Opposing signs.
  1100. if ( hp ) {
  1101. if (hp > 0)
  1102. status_heal(&sd->bl, hp, 0, 0);
  1103. else {
  1104. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1105. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1106. }
  1107. }
  1108.  
  1109. if ( sp ) {
  1110. if (sp > 0)
  1111. status_heal(&sd->bl, 0, sp, 0);
  1112. else
  1113. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1114. }
  1115.  
  1116. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1117. return 0;
  1118. }
  1119.  
  1120. /*==========================================
  1121. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1122. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1123. *------------------------------------------*/
  1124. ACMD_FUNC(item)
  1125. {
  1126. char item_name[100];
  1127. int number = 0, flag = 0, bound = 0;
  1128. struct item item_tmp;
  1129. struct item_data *item_data[10];
  1130. int get_count, i, j=0;
  1131. char *itemlist;
  1132.  
  1133. nullpo_retr(-1, sd);
  1134. memset(item_name, '\0', sizeof(item_name));
  1135.  
  1136. if (!strcmpi(command+1,"itembound") && (!message || !*message || (
  1137. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &number, &bound) < 2 &&
  1138. sscanf(message, "%99s %d %d", item_name, &number, &bound) < 2
  1139. ))) {
  1140. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1141. return -1;
  1142. } else if (!message || !*message || (
  1143. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1144. sscanf(message, "%99s %d", item_name, &number) < 1
  1145. )) {
  1146. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1147. return -1;
  1148. }
  1149. itemlist = strtok(item_name, ":");
  1150. while (itemlist != NULL && j<10) {
  1151. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1152. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1153. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1154. return -1;
  1155. }
  1156. itemlist = strtok(NULL, ":"); //next itemline
  1157. j++;
  1158. }
  1159.  
  1160. if( bound < 0 || bound > 4 ) {
  1161. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1162. return -1;
  1163. }
  1164.  
  1165. if (number <= 0)
  1166. number = 1;
  1167. get_count = number;
  1168.  
  1169. for(j--; j>=0; j--){ //produce items in list
  1170. int16 item_id = item_data[j]->nameid;
  1171. //Check if it's stackable.
  1172. if (!itemdb_isstackable2(item_data[j]))
  1173. get_count = 1;
  1174.  
  1175. for (i = 0; i < number; i += get_count) {
  1176. // if not pet egg
  1177. if (!pet_create_egg(sd, item_id)) {
  1178. memset(&item_tmp, 0, sizeof(item_tmp));
  1179. item_tmp.nameid = item_id;
  1180. item_tmp.identify = 1;
  1181. item_tmp.bound = bound;
  1182.  
  1183. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1184. clif_additem(sd, 0, 0, flag);
  1185. }
  1186. }
  1187. }
  1188.  
  1189. if (flag == 0)
  1190. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1191. return 0;
  1192. }
  1193.  
  1194. /*==========================================
  1195. *
  1196. *------------------------------------------*/
  1197. ACMD_FUNC(item2)
  1198. {
  1199. struct item item_tmp;
  1200. struct item_data *item_data;
  1201. char item_name[100];
  1202. int item_id, number = 0, bound = 0;
  1203. int identify = 0, refine = 0, attr = 0;
  1204. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1205. nullpo_retr(-1, sd);
  1206.  
  1207. memset(item_name, '\0', sizeof(item_name));
  1208.  
  1209. if (!strcmpi(command+1,"itembound2") && (!message || !*message || (
  1210. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1211. sscanf(message, "%99s %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))) {
  1212. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1213. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1214. return -1;
  1215. } else if ( !message || !*message || (
  1216. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1217. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1218. )) {
  1219. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1220. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1221. return -1;
  1222. }
  1223.  
  1224. if (number <= 0)
  1225. number = 1;
  1226.  
  1227. if( bound < 0 || bound > 4 ) {
  1228. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1229. return -1;
  1230. }
  1231.  
  1232. item_id = 0;
  1233. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1234. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1235. item_id = item_data->nameid;
  1236.  
  1237. if (item_id > 500) {
  1238. int flag = 0;
  1239. int loop, get_count, i;
  1240. loop = 1;
  1241. get_count = number;
  1242. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1243. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1244. loop = number;
  1245. get_count = 1;
  1246. if (item_data->type == IT_PETEGG) {
  1247. identify = 1;
  1248. refine = 0;
  1249. }
  1250. if (item_data->type == IT_PETARMOR)
  1251. refine = 0;
  1252. if (refine > MAX_REFINE)
  1253. refine = MAX_REFINE;
  1254. } else {
  1255. identify = 1;
  1256. refine = attr = 0;
  1257. }
  1258. for (i = 0; i < loop; i++) {
  1259. memset(&item_tmp, 0, sizeof(item_tmp));
  1260. item_tmp.nameid = item_id;
  1261. item_tmp.identify = identify;
  1262. item_tmp.refine = refine;
  1263. item_tmp.attribute = attr;
  1264. item_tmp.card[0] = c1;
  1265. item_tmp.card[1] = c2;
  1266. item_tmp.card[2] = c3;
  1267. item_tmp.card[3] = c4;
  1268. item_tmp.bound = bound;
  1269. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1270. clif_additem(sd, 0, 0, flag);
  1271. }
  1272.  
  1273. if (flag == 0)
  1274. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1275. } else {
  1276. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1277. return -1;
  1278. }
  1279.  
  1280. return 0;
  1281. }
  1282.  
  1283. /*==========================================
  1284. *
  1285. *------------------------------------------*/
  1286. ACMD_FUNC(itemreset)
  1287. {
  1288. int i;
  1289. nullpo_retr(-1, sd);
  1290.  
  1291. for (i = 0; i < MAX_INVENTORY; i++) {
  1292. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1293. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1294. }
  1295. }
  1296. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1297.  
  1298. return 0;
  1299. }
  1300.  
  1301. /*==========================================
  1302. * Atcommand @lvlup
  1303. *------------------------------------------*/
  1304. ACMD_FUNC(baselevelup)
  1305. {
  1306. int level=0, i=0, status_point=0;
  1307. nullpo_retr(-1, sd);
  1308. level = atoi(message);
  1309.  
  1310. if (!message || !*message || !level) {
  1311. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1312. return -1;
  1313. }
  1314.  
  1315. if (level > 0) {
  1316. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1317. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1318. return -1;
  1319. } // End Addition
  1320. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1321. level = pc_maxbaselv(sd) - sd->status.base_level;
  1322. for (i = 0; i < level; i++)
  1323. status_point += pc_gets_status_point(sd->status.base_level + i);
  1324.  
  1325. sd->status.status_point += status_point;
  1326. sd->status.base_level += (unsigned int)level;
  1327. status_percent_heal(&sd->bl, 100, 100);
  1328. clif_misceffect(&sd->bl, 0);
  1329. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1330. } else {
  1331. if (sd->status.base_level == 1) {
  1332. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1333. return -1;
  1334. }
  1335. level*=-1;
  1336. if ((unsigned int)level >= sd->status.base_level)
  1337. level = sd->status.base_level-1;
  1338. for (i = 0; i > -level; i--)
  1339. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1340. if (sd->status.status_point < status_point)
  1341. pc_resetstate(sd);
  1342. if (sd->status.status_point < status_point)
  1343. sd->status.status_point = 0;
  1344. else
  1345. sd->status.status_point -= status_point;
  1346. sd->status.base_level -= (unsigned int)level;
  1347. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1348. }
  1349. sd->status.base_exp = 0;
  1350. clif_updatestatus(sd, SP_STATUSPOINT);
  1351. clif_updatestatus(sd, SP_BASELEVEL);
  1352. clif_updatestatus(sd, SP_BASEEXP);
  1353. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1354. status_calc_pc(sd, 0);
  1355. pc_baselevelchanged(sd);
  1356. if(sd->status.party_id)
  1357. party_send_levelup(sd);
  1358. return 0;
  1359. }
  1360.  
  1361. /*==========================================
  1362. *
  1363. *------------------------------------------*/
  1364. ACMD_FUNC(joblevelup)
  1365. {
  1366. int level=0;
  1367. nullpo_retr(-1, sd);
  1368.  
  1369. level = atoi(message);
  1370.  
  1371. if (!message || !*message || !level) {
  1372. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1373. return -1;
  1374. }
  1375. if (level > 0) {
  1376. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1377. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1378. return -1;
  1379. }
  1380. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1381. level = pc_maxjoblv(sd) - sd->status.job_level;
  1382. sd->status.job_level += (unsigned int)level;
  1383. sd->status.skill_point += level;
  1384. clif_misceffect(&sd->bl, 1);
  1385. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1386. } else {
  1387. if (sd->status.job_level == 1) {
  1388. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1389. return -1;
  1390. }
  1391. level *=-1;
  1392. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1393. level = sd->status.job_level-1;
  1394. sd->status.job_level -= (unsigned int)level;
  1395. if (sd->status.skill_point < level)
  1396. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1397. if (sd->status.skill_point < level)
  1398. sd->status.skill_point = 0;
  1399. else
  1400. sd->status.skill_point -= level;
  1401. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1402. }
  1403. sd->status.job_exp = 0;
  1404. clif_updatestatus(sd, SP_JOBLEVEL);
  1405. clif_updatestatus(sd, SP_JOBEXP);
  1406. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1407. clif_updatestatus(sd, SP_SKILLPOINT);
  1408. status_calc_pc(sd, 0);
  1409.  
  1410. return 0;
  1411. }
  1412.  
  1413. /*==========================================
  1414. * @help
  1415. *------------------------------------------*/
  1416. ACMD_FUNC(help)
  1417. {
  1418. config_setting_t *help;
  1419. const char *text = NULL;
  1420. const char *command_name = NULL;
  1421. char *default_command = "help";
  1422.  
  1423. nullpo_retr(-1, sd);
  1424.  
  1425. help = config_lookup(&atcommand_config, "help");
  1426. if (help == NULL) {
  1427. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1428. return -1;
  1429. }
  1430.  
  1431. if (!message || !*message) {
  1432. command_name = default_command; // If no command_name specified, display help for @help.
  1433. } else {
  1434. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1435. ++message;
  1436. command_name = atcommand_checkalias(message);
  1437. }
  1438.  
  1439. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1440. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1441. clif_displaymessage(fd, atcmd_output);
  1442. atcommand_get_suggestions(sd, command_name, true);
  1443. return -1;
  1444. }
  1445.  
  1446. if (!config_setting_lookup_string(help, command_name, &text)) {
  1447. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1448. clif_displaymessage(fd, atcmd_output);
  1449. atcommand_get_suggestions(sd, command_name, true);
  1450. return -1;
  1451. }
  1452.  
  1453. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1454. clif_displaymessage(fd, atcmd_output);
  1455.  
  1456. { // Display aliases
  1457. DBIterator* iter;
  1458. AtCommandInfo *command_info;
  1459. AliasInfo *alias_info = NULL;
  1460. StringBuf buf;
  1461. bool has_aliases = false;
  1462.  
  1463. StringBuf_Init(&buf);
  1464. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1465. command_info = get_atcommandinfo_byname(command_name);
  1466. iter = db_iterator(atcommand_alias_db);
  1467. for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1468. if (alias_info->command == command_info) {
  1469. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1470. has_aliases = true;
  1471. }
  1472. }
  1473. dbi_destroy(iter);
  1474. if (has_aliases)
  1475. clif_displaymessage(fd, StringBuf_Value(&buf));
  1476. StringBuf_Destroy(&buf);
  1477. }
  1478.  
  1479. // Display help contents
  1480. clif_displaymessage(fd, text);
  1481. return 0;
  1482. }
  1483.  
  1484. // helper function, used in foreach calls to stop auto-attack timers
  1485. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1486. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1487. {
  1488. struct unit_data *ud = unit_bl2ud(bl);
  1489. int id = va_arg(ap, int);
  1490. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1491. {
  1492. unit_stop_attack(bl);
  1493. return 1;
  1494. }
  1495. return 0;
  1496. }
  1497. /*==========================================
  1498. *
  1499. *------------------------------------------*/
  1500. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1501. {
  1502. TBL_PC* sd = (TBL_PC*)bl;
  1503. clif_pvpset(sd, 0, 0, 2);
  1504. if (sd->pvp_timer != INVALID_TIMER) {
  1505. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1506. sd->pvp_timer = INVALID_TIMER;
  1507. }
  1508. return 0;
  1509. }
  1510.  
  1511. ACMD_FUNC(pvpoff)
  1512. {
  1513. nullpo_retr(-1, sd);
  1514.  
  1515. if (!map[sd->bl.m].flag.pvp) {
  1516. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1517. return -1;
  1518. }
  1519.  
  1520. map[sd->bl.m].flag.pvp = 0;
  1521.  
  1522. if (!battle_config.pk_mode){
  1523. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1524. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1525. }
  1526. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1527. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1528. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1529. return 0;
  1530. }
  1531.  
  1532. /*==========================================
  1533. *
  1534. *------------------------------------------*/
  1535. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1536. {
  1537. TBL_PC* sd = (TBL_PC*)bl;
  1538. if (sd->pvp_timer == INVALID_TIMER) {
  1539. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1540. sd->pvp_rank = 0;
  1541. sd->pvp_lastusers = 0;
  1542. sd->pvp_point = 5;
  1543. sd->pvp_won = 0;
  1544. sd->pvp_lost = 0;
  1545. }
  1546. return 0;
  1547. }
  1548.  
  1549. ACMD_FUNC(pvpon)
  1550. {
  1551. nullpo_retr(-1, sd);
  1552.  
  1553. if (map[sd->bl.m].flag.pvp) {
  1554. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1555. return -1;
  1556. }
  1557.  
  1558. map[sd->bl.m].flag.pvp = 1;
  1559.  
  1560. if (!battle_config.pk_mode) {// display pvp circle and rank
  1561. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1562. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1563. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1564. }
  1565.  
  1566. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1567.  
  1568. return 0;
  1569. }
  1570.  
  1571. /*==========================================
  1572. *
  1573. *------------------------------------------*/
  1574. ACMD_FUNC(gvgoff)
  1575. {
  1576. nullpo_retr(-1, sd);
  1577.  
  1578. if (!map[sd->bl.m].flag.gvg) {
  1579. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1580. return -1;
  1581. }
  1582.  
  1583. map[sd->bl.m].flag.gvg = 0;
  1584. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1585. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1586. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1587. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1588.  
  1589. return 0;
  1590. }
  1591.  
  1592. /*==========================================
  1593. *
  1594. *------------------------------------------*/
  1595. ACMD_FUNC(gvgon)
  1596. {
  1597. nullpo_retr(-1, sd);
  1598.  
  1599. if (map[sd->bl.m].flag.gvg) {
  1600. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1601. return -1;
  1602. }
  1603.  
  1604. map[sd->bl.m].flag.gvg = 1;
  1605. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1606. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1607. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1608.  
  1609. return 0;
  1610. }
  1611.  
  1612. /*==========================================
  1613. *
  1614. *------------------------------------------*/
  1615. ACMD_FUNC(model)
  1616. {
  1617. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1618. nullpo_retr(-1, sd);
  1619.  
  1620. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1621.  
  1622. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1623. sprintf(atcmd_output, msg_txt(sd,991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
  1624. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1625. clif_displaymessage(fd, atcmd_output);
  1626. return -1;
  1627. }
  1628.  
  1629. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1630. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1631. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1632. pc_changelook(sd, LOOK_HAIR, hair_style);
  1633. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1634. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1635. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1636. } else {
  1637. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1638. return -1;
  1639. }
  1640.  
  1641. return 0;
  1642. }
  1643.  
  1644. /*==========================================
  1645. * @dye && @ccolor
  1646. *------------------------------------------*/
  1647. ACMD_FUNC(dye)
  1648. {
  1649. int cloth_color = 0;
  1650. nullpo_retr(-1, sd);
  1651.  
  1652. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1653.  
  1654. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1655. sprintf(atcmd_output, msg_txt(sd,992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
  1656. clif_displaymessage(fd, atcmd_output);
  1657. return -1;
  1658. }
  1659.  
  1660. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1661. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1662. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1663. } else {
  1664. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1665. return -1;
  1666. }
  1667.  
  1668. return 0;
  1669. }
  1670.  
  1671. /*==========================================
  1672. * @hairstyle && @hstyle
  1673. *------------------------------------------*/
  1674. ACMD_FUNC(hair_style)
  1675. {
  1676. int hair_style = 0;
  1677. nullpo_retr(-1, sd);
  1678.  
  1679. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1680.  
  1681. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1682. sprintf(atcmd_output, msg_txt(sd,993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
  1683. clif_displaymessage(fd, atcmd_output);
  1684. return -1;
  1685. }
  1686.  
  1687. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1688. pc_changelook(sd, LOOK_HAIR, hair_style);
  1689. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1690. } else {
  1691. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1692. return -1;
  1693. }
  1694.  
  1695. return 0;
  1696. }
  1697.  
  1698. /*==========================================
  1699. * @haircolor && @hcolor
  1700. *------------------------------------------*/
  1701. ACMD_FUNC(hair_color)
  1702. {
  1703. int hair_color = 0;
  1704. nullpo_retr(-1, sd);
  1705.  
  1706. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1707.  
  1708. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1709. sprintf(atcmd_output, msg_txt(sd,994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
  1710. clif_displaymessage(fd, atcmd_output);
  1711. return -1;
  1712. }
  1713.  
  1714. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1715. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1716. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1717. } else {
  1718. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1719. return -1;
  1720. }
  1721.  
  1722. return 0;
  1723. }
  1724.  
  1725. /*==========================================
  1726. * @go [city_number or city_name] - Updated by Harbin
  1727. *------------------------------------------*/
  1728. ACMD_FUNC(go)
  1729. {
  1730. int i;
  1731. int town;
  1732. char map_name[MAP_NAME_LENGTH];
  1733. int16 m;
  1734.  
  1735. const struct {
  1736. char map[MAP_NAME_LENGTH];
  1737. int x, y;
  1738. } data[] = {
  1739. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1740. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1741. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1742. { MAP_PAYON, 162, 233 }, // 3=Payon
  1743. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1744. #ifdef RENEWAL
  1745. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1746. #else
  1747. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1748. #endif
  1749. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1750. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1751. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1752. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1753. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1754. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1755. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1756. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1757. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1758. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1759. { MAP_JAIL, 23, 61 }, // 16=Prison
  1760. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1761. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1762. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1763. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1764. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1765. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1766. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1767. { MAP_VEINS, 216, 123 }, // 24=Veins
  1768. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1769. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1770. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1771. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1772. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1773. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1774. { MAP_MORA, 44, 151 }, // 31=Mora
  1775. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1776. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1777. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1778. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1779. };
  1780.  
  1781. nullpo_retr(-1, sd);
  1782.  
  1783. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1784. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1785. return 0;
  1786. }
  1787.  
  1788. memset(map_name, '\0', sizeof(map_name));
  1789. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1790.  
  1791. // get the number
  1792. town = atoi(message);
  1793.  
  1794. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1795. {// no value matched so send the list of locations
  1796. const char* text;
  1797.  
  1798. // attempt to find the text help string
  1799. text = atcommand_help_string( command );
  1800.  
  1801. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1802.  
  1803. if( text )
  1804. {// send the text to the client
  1805. clif_displaymessage( fd, text );
  1806. }
  1807.  
  1808. return -1;
  1809. }
  1810.  
  1811. // get possible name of the city
  1812. map_name[MAP_NAME_LENGTH-1] = '\0';
  1813. for (i = 0; map_name[i]; i++)
  1814. map_name[i] = TOLOWER(map_name[i]);
  1815. // try to identify the map name
  1816. if (strncmp(map_name, "prontera", 3) == 0) {
  1817. town = 0;
  1818. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1819. strncmp(map_name, "morroc", 4) == 0) {
  1820. town = 1;
  1821. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1822. town = 2;
  1823. } else if (strncmp(map_name, "payon", 3) == 0) {
  1824. town = 3;
  1825. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1826. town = 4;
  1827. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1828. town = 5;
  1829. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1830. town = 6;
  1831. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1832. strcmp(map_name, "christmas") == 0 ||
  1833. strncmp(map_name, "xmas", 3) == 0 ||
  1834. strncmp(map_name, "x-mas", 3) == 0) {
  1835. town = 7;
  1836. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1837. town = 8;
  1838. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1839. strncmp(map_name, "yuno", 3) == 0) {
  1840. town = 9;
  1841. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1842. town = 10;
  1843. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1844. strncmp(map_name, "gonryun", 3) == 0) {
  1845. town = 11;
  1846. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1847. town = 12;
  1848. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1849. town = 13;
  1850. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1851. town = 14;
  1852. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1853. strncmp(map_name, "startpoint", 3) == 0 ||
  1854. strncmp(map_name, "beginning", 3) == 0) {
  1855. town = 15;
  1856. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1857. strncmp(map_name, "prison", 3) == 0 ||
  1858. strncmp(map_name, "jail", 3) == 0) {
  1859. town = 16;
  1860. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1861. town = 17;
  1862. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1863. town = 18;
  1864. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1865. town = 19;
  1866. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1867. town = 20;
  1868. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1869. town = 21;
  1870. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1871. town = 22;
  1872. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1873. town = 23;
  1874. } else if (strncmp(map_name, "veins", 3) == 0) {
  1875. town = 24;
  1876. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1877. town = 25;
  1878. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1879. town = 26;
  1880. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1881. town = 27;
  1882. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1883. town = 28;
  1884. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1885. town = 29;
  1886. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1887. town = 30;
  1888. } else if (strcmp(map_name, "mora") == 0) {
  1889. town = 31;
  1890. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1891. town = 32;
  1892. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1893. town = 33;
  1894. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1895. town = 34;
  1896. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1897. town = 35;
  1898. }
  1899.  
  1900. if (town >= 0 && town < ARRAYLENGTH(data))
  1901. {
  1902. m = map_mapname2mapid(data[town].map);
  1903. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1904. clif_displaymessage(fd, msg_txt(sd,247));
  1905. return -1;
  1906. }
  1907. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1908. clif_displaymessage(fd, msg_txt(sd,248));
  1909. return -1;
  1910. }
  1911. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1912. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1913. } else {
  1914. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1915. return -1;
  1916. }
  1917. } else { // if you arrive here, you have an error in town variable when reading of names
  1918. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1919. return -1;
  1920. }
  1921.  
  1922. return 0;
  1923. }
  1924.  
  1925. /*==========================================
  1926. *
  1927. *------------------------------------------*/
  1928. ACMD_FUNC(monster)
  1929. {
  1930. char name[NAME_LENGTH];
  1931. char monster[NAME_LENGTH];
  1932. char eventname[EVENT_NAME_LENGTH] = "";
  1933. int mob_id;
  1934. int number = 0;
  1935. int count;
  1936. int i, k, range;
  1937. short mx, my;
  1938. unsigned int size;
  1939. nullpo_retr(-1, sd);
  1940.  
  1941. memset(name, '\0', sizeof(name));
  1942. memset(monster, '\0', sizeof(monster));
  1943. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1944.  
  1945. if (!message || !*message) {
  1946. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1947. return -1;
  1948. }
  1949. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1950. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1951. //All data can be left as it is.
  1952. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1953. //Here, it is possible name was not given and we are using monster for it.
  1954. if (count < 3) //Blank mob's name.
  1955. name[0] = '\0';
  1956. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1957. //All data can be left as it is.
  1958. } else if (sscanf(message, "%23s", monster) > 0) {
  1959. //As before, name may be already filled.
  1960. name[0] = '\0';
  1961. } else {
  1962. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1963. return -1;
  1964. }
  1965.  
  1966. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1967. mob_id = mobdb_checkid(atoi(monster));
  1968.  
  1969. if (mob_id == 0) {
  1970. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1971. return -1;
  1972. }
  1973.  
  1974. if (mob_id == MOBID_EMPERIUM) {
  1975. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1976. return -1;
  1977. }
  1978.  
  1979. if (number <= 0)
  1980. number = 1;
  1981.  
  1982. if( !name[0] )
  1983. strcpy(name, "--ja--");
  1984.  
  1985. // 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
  1986. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1987. number = battle_config.atc_spawn_quantity_limit;
  1988.  
  1989. if (strcmp(command+1, "monstersmall") == 0)
  1990. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1991. else if (strcmp(command+1, "monsterbig") == 0)
  1992. size = SZ_BIG;
  1993. else
  1994. size = SZ_SMALL;
  1995.  
  1996. if (battle_config.etc_log)
  1997. 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);
  1998.  
  1999. count = 0;
  2000. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2001. for (i = 0; i < number; i++) {
  2002. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2003. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  2004. count += (k != 0) ? 1 : 0;
  2005. }
  2006.  
  2007. if (count != 0)
  2008. if (number == count)
  2009. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  2010. else {
  2011. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  2012. clif_displaymessage(fd, atcmd_output);
  2013. }
  2014. else {
  2015. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  2016. return -1;
  2017. }
  2018.  
  2019. return 0;
  2020. }
  2021.  
  2022. /*==========================================
  2023. *
  2024. *------------------------------------------*/
  2025. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2026. {
  2027. struct mob_data *md;
  2028. int flag;
  2029.  
  2030. nullpo_ret(md=(struct mob_data *)bl);
  2031. flag = va_arg(ap, int);
  2032.  
  2033. if (md->guardian_data)
  2034. return 0; //Do not touch WoE mobs!
  2035.  
  2036. if (flag)
  2037. status_zap(bl,md->status.hp, 0);
  2038. else
  2039. status_kill(bl);
  2040. return 1;
  2041. }
  2042.  
  2043. ACMD_FUNC(killmonster)
  2044. {
  2045. int map_id, drop_flag;
  2046. char map_name[MAP_NAME_LENGTH_EXT];
  2047. nullpo_retr(-1, sd);
  2048.  
  2049. memset(map_name, '\0', sizeof(map_name));
  2050.  
  2051. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2052. map_id = sd->bl.m;
  2053. else {
  2054. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2055. map_id = sd->bl.m;
  2056. }
  2057.  
  2058. drop_flag = strcmp(command+1, "killmonster2");
  2059.  
  2060. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  2061.  
  2062. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  2063.  
  2064. return 0;
  2065. }
  2066.  
  2067. /*==========================================
  2068. *
  2069. *------------------------------------------*/
  2070. ACMD_FUNC(refine)
  2071. {
  2072. int i,j, position = 0, refine = 0, current_position, final_refine;
  2073. int count;
  2074. nullpo_retr(-1, sd);
  2075.  
  2076. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2077.  
  2078. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2079. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  2080. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  2081. clif_displaymessage(fd, atcmd_output);
  2082. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  2083. clif_displaymessage(fd, atcmd_output);
  2084. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  2085. clif_displaymessage(fd, atcmd_output);
  2086. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  2087. clif_displaymessage(fd, atcmd_output);
  2088. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  2089. clif_displaymessage(fd, atcmd_output);
  2090. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  2091. clif_displaymessage(fd, atcmd_output);
  2092. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  2093. clif_displaymessage(fd, atcmd_output);
  2094. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  2095. clif_displaymessage(fd, atcmd_output);
  2096. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  2097. clif_displaymessage(fd, atcmd_output);
  2098. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  2099. clif_displaymessage(fd, atcmd_output);
  2100. return -1;
  2101. }
  2102.  
  2103. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2104.  
  2105. count = 0;
  2106. for (j = 0; j < EQI_MAX-1; j++) {
  2107. if ((i = sd->equip_index[j]) < 0)
  2108. continue;
  2109. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2110. continue;
  2111. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2112. continue;
  2113. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2114. continue;
  2115.  
  2116. if(position && !(sd->status.inventory[i].equip & position))
  2117. continue;
  2118.  
  2119. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2120. if (sd->status.inventory[i].refine != final_refine) {
  2121. sd->status.inventory[i].refine = final_refine;
  2122. current_position = sd->status.inventory[i].equip;
  2123. pc_unequipitem(sd, i, 3);
  2124. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2125. clif_delitem(sd, i, 1, 3);
  2126. clif_additem(sd, i, 1, 0);
  2127. pc_equipitem(sd, i, current_position);
  2128. clif_misceffect(&sd->bl, 3);
  2129. count++;
  2130. }
  2131. }
  2132.  
  2133. if (count == 0)
  2134. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  2135. else if (count == 1)
  2136. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  2137. else {
  2138. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  2139. clif_displaymessage(fd, atcmd_output);
  2140. }
  2141.  
  2142. return 0;
  2143. }
  2144.  
  2145. /*==========================================
  2146. *
  2147. *------------------------------------------*/
  2148. ACMD_FUNC(produce)
  2149. {
  2150. char item_name[100];
  2151. int item_id, attribute = 0, star = 0;
  2152. struct item_data *item_data;
  2153. struct item tmp_item;
  2154. nullpo_retr(-1, sd);
  2155.  
  2156. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2157. memset(item_name, '\0', sizeof(item_name));
  2158.  
  2159. if (!message || !*message || (
  2160. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2161. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2162. )) {
  2163. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2164. return -1;
  2165. }
  2166.  
  2167. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  2168. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  2169. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  2170. return -1;
  2171. }
  2172.  
  2173. item_id = item_data->nameid;
  2174.  
  2175. if (itemdb_isequip2(item_data)) {
  2176. int flag = 0;
  2177. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2178. attribute = ATTRIBUTE_NORMAL;
  2179. if (star < MIN_STAR || star > MAX_STAR)
  2180. star = 0;
  2181. memset(&tmp_item, 0, sizeof tmp_item);
  2182. tmp_item.nameid = item_id;
  2183. tmp_item.amount = 1;
  2184. tmp_item.identify = 1;
  2185. tmp_item.card[0] = CARD0_FORGE;
  2186. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2187. ((star*5) << 8) + attribute:0;
  2188. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2189. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2190. clif_produceeffect(sd, 0, item_id);
  2191. clif_misceffect(&sd->bl, 3);
  2192.  
  2193. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2194. clif_additem(sd, 0, 0, flag);
  2195. } else {
  2196. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2197. clif_displaymessage(fd, atcmd_output);
  2198. return -1;
  2199. }
  2200.  
  2201. return 0;
  2202. }
  2203.  
  2204. /*==========================================
  2205. *
  2206. *------------------------------------------*/
  2207. ACMD_FUNC(memo)
  2208. {
  2209. int position = 0;
  2210. nullpo_retr(-1, sd);
  2211.  
  2212. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2213.  
  2214. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2215. {
  2216. int i;
  2217. clif_displaymessage(sd->fd, msg_txt(sd,668));
  2218. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2219. {
  2220. if( sd->status.memo_point[i].map )
  2221. 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);
  2222. else
  2223. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2224. clif_displaymessage(sd->fd, atcmd_output);
  2225. }
  2226. return 0;
  2227. }
  2228.  
  2229. if( position < 0 || position >= MAX_MEMOPOINTS )
  2230. {
  2231. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2232. clif_displaymessage(fd, atcmd_output);
  2233. return -1;
  2234. }
  2235.  
  2236. return !pc_memo( sd, position );
  2237. }
  2238.  
  2239. /*==========================================
  2240. *
  2241. *------------------------------------------*/
  2242. ACMD_FUNC(gat)
  2243. {
  2244. int y;
  2245. nullpo_retr(-1, sd);
  2246.  
  2247. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2248.  
  2249. for (y = 2; y >= -2; y--) {
  2250. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2251. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2252. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2253. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2254. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2255. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2256. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2257.  
  2258. clif_displaymessage(fd, atcmd_output);
  2259. }
  2260.  
  2261. return 0;
  2262. }
  2263.  
  2264. /*==========================================
  2265. *
  2266. *------------------------------------------*/
  2267. ACMD_FUNC(displaystatus)
  2268. {
  2269. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2270. nullpo_retr(-1, sd);
  2271.  
  2272. if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2273. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2274. return -1;
  2275. }
  2276. if (i < 2) flag = 1;
  2277. if (i < 3) tick = 0;
  2278.  
  2279. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2280.  
  2281. return 0;
  2282. }
  2283.  
  2284. /*==========================================
  2285. * @stpoint (Rewritten by [Yor])
  2286. *------------------------------------------*/
  2287. ACMD_FUNC(statuspoint)
  2288. {
  2289. int point;
  2290. unsigned int new_status_point;
  2291.  
  2292. if (!message || !*message || (point = atoi(message)) == 0) {
  2293. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2294. return -1;
  2295. }
  2296.  
  2297. if(point < 0)
  2298. {
  2299. if(sd->status.status_point < (unsigned int)(-point))
  2300. {
  2301. new_status_point = 0;
  2302. }
  2303. else
  2304. {
  2305. new_status_point = sd->status.status_point + point;
  2306. }
  2307. }
  2308. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2309. {
  2310. new_status_point = UINT_MAX;
  2311. }
  2312. else
  2313. {
  2314. new_status_point = sd->status.status_point + point;
  2315. }
  2316.  
  2317. if (new_status_point != sd->status.status_point) {
  2318. sd->status.status_point = new_status_point;
  2319. clif_updatestatus(sd, SP_STATUSPOINT);
  2320. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2321. } else {
  2322. if (point < 0)
  2323. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2324. else
  2325. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2326. return -1;
  2327. }
  2328.  
  2329. return 0;
  2330. }
  2331.  
  2332. /*==========================================
  2333. * @skpoint (Rewritten by [Yor])
  2334. *------------------------------------------*/
  2335. ACMD_FUNC(skillpoint)
  2336. {
  2337. int point;
  2338. unsigned int new_skill_point;
  2339. nullpo_retr(-1, sd);
  2340.  
  2341. if (!message || !*message || (point = atoi(message)) == 0) {
  2342. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2343. return -1;
  2344. }
  2345.  
  2346. if(point < 0)
  2347. {
  2348. if(sd->status.skill_point < (unsigned int)(-point))
  2349. {
  2350. new_skill_point = 0;
  2351. }
  2352. else
  2353. {
  2354. new_skill_point = sd->status.skill_point + point;
  2355. }
  2356. }
  2357. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2358. {
  2359. new_skill_point = UINT_MAX;
  2360. }
  2361. else
  2362. {
  2363. new_skill_point = sd->status.skill_point + point;
  2364. }
  2365.  
  2366. if (new_skill_point != sd->status.skill_point) {
  2367. sd->status.skill_point = new_skill_point;
  2368. clif_updatestatus(sd, SP_SKILLPOINT);
  2369. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2370. } else {
  2371. if (point < 0)
  2372. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2373. else
  2374. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2375. return -1;
  2376. }
  2377.  
  2378. return 0;
  2379. }
  2380.  
  2381. /*==========================================
  2382. * @zeny
  2383. *------------------------------------------*/
  2384. ACMD_FUNC(zeny)
  2385. {
  2386. int zeny=0, ret=-1;
  2387. nullpo_retr(-1, sd);
  2388.  
  2389. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2390. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2391. return -1;
  2392. }
  2393.  
  2394. if(zeny > 0){
  2395. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2396. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2397. }
  2398. else {
  2399. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2400. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2401. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2402. }
  2403. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2404. return 0;
  2405. }
  2406.  
  2407. /*==========================================
  2408. *
  2409. *------------------------------------------*/
  2410. ACMD_FUNC(param)
  2411. {
  2412. int i, value = 0, new_value, max;
  2413. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2414. short* status[6];
  2415. //we don't use direct initialization because it isn't part of the c standard.
  2416. nullpo_retr(-1, sd);
  2417.  
  2418. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2419.  
  2420. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2421. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2422. return -1;
  2423. }
  2424.  
  2425. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2426.  
  2427. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2428. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2429. return -1;
  2430. }
  2431.  
  2432. status[0] = &sd->status.str;
  2433. status[1] = &sd->status.agi;
  2434. status[2] = &sd->status.vit;
  2435. status[3] = &sd->status.int_;
  2436. status[4] = &sd->status.dex;
  2437. status[5] = &sd->status.luk;
  2438.  
  2439. if( battle_config.atcommand_max_stat_bypass )
  2440. max = SHRT_MAX;
  2441. else
  2442. max = pc_maxparameter(sd);
  2443.  
  2444. if(value < 0 && *status[i] <= -value) {
  2445. new_value = 1;
  2446. } else if(max - *status[i] < value) {
  2447. new_value = max;
  2448. } else {
  2449. new_value = *status[i] + value;
  2450. }
  2451.  
  2452. if (new_value != *status[i]) {
  2453. *status[i] = new_value;
  2454. clif_updatestatus(sd, SP_STR + i);
  2455. clif_updatestatus(sd, SP_USTR + i);
  2456. status_calc_pc(sd, 0);
  2457. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2458. } else {
  2459. if (value < 0)
  2460. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2461. else
  2462. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2463. return -1;
  2464. }
  2465.  
  2466. return 0;
  2467. }
  2468.  
  2469. /*==========================================
  2470. * Stat all by fritz (rewritten by [Yor])
  2471. *------------------------------------------*/
  2472. ACMD_FUNC(stat_all)
  2473. {
  2474. int index, count, value, max, new_value;
  2475. short* status[6];
  2476. //we don't use direct initialization because it isn't part of the c standard.
  2477. nullpo_retr(-1, sd);
  2478.  
  2479. status[0] = &sd->status.str;
  2480. status[1] = &sd->status.agi;
  2481. status[2] = &sd->status.vit;
  2482. status[3] = &sd->status.int_;
  2483. status[4] = &sd->status.dex;
  2484. status[5] = &sd->status.luk;
  2485.  
  2486. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2487. value = pc_maxparameter(sd);
  2488. max = pc_maxparameter(sd);
  2489. } else {
  2490. if( battle_config.atcommand_max_stat_bypass )
  2491. max = SHRT_MAX;
  2492. else
  2493. max = pc_maxparameter(sd);
  2494. }
  2495.  
  2496. count = 0;
  2497. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2498.  
  2499. if (value > 0 && *status[index] > max - value)
  2500. new_value = max;
  2501. else if (value < 0 && *status[index] <= -value)
  2502. new_value = 1;
  2503. else
  2504. new_value = *status[index] +value;
  2505.  
  2506. if (new_value != (int)*status[index]) {
  2507. *status[index] = new_value;
  2508. clif_updatestatus(sd, SP_STR + index);
  2509. clif_updatestatus(sd, SP_USTR + index);
  2510. count++;
  2511. }
  2512. }
  2513.  
  2514. if (count > 0) { // if at least 1 stat modified
  2515. status_calc_pc(sd, 0);
  2516. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2517. } else {
  2518. if (value < 0)
  2519. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2520. else
  2521. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2522. return -1;
  2523. }
  2524.  
  2525. return 0;
  2526. }
  2527.  
  2528. /*==========================================
  2529. *
  2530. *------------------------------------------*/
  2531. ACMD_FUNC(guildlevelup) {
  2532. int level = 0;
  2533. short added_level;
  2534. struct guild *guild_info;
  2535. nullpo_retr(-1, sd);
  2536.  
  2537. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2538. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2539. return -1;
  2540. }
  2541.  
  2542. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2543. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2544. return -1;
  2545. }
  2546. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2547. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2548. // return -1;
  2549. //}
  2550.  
  2551. added_level = (short)level;
  2552. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2553. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2554. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2555. added_level = 1 - guild_info->guild_lv;
  2556.  
  2557. if (added_level != 0) {
  2558. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2559. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2560. } else {
  2561. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2562. return -1;
  2563. }
  2564.  
  2565. return 0;
  2566. }
  2567.  
  2568. /*==========================================
  2569. *
  2570. *------------------------------------------*/
  2571. ACMD_FUNC(makeegg) {
  2572. struct item_data *item_data;
  2573. int id, pet_id;
  2574. nullpo_retr(-1, sd);
  2575.  
  2576. if (!message || !*message) {
  2577. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2578. return -1;
  2579. }
  2580.  
  2581. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2582. id = item_data->nameid;
  2583. else
  2584. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2585. ;
  2586. else
  2587. id = atoi(message);
  2588.  
  2589. pet_id = search_petDB_index(id, PET_CLASS);
  2590. if (pet_id < 0)
  2591. pet_id = search_petDB_index(id, PET_EGG);
  2592. if (pet_id >= 0) {
  2593. sd->catch_target_class = pet_db[pet_id].class_;
  2594. intif_create_pet(
  2595. sd->status.account_id, sd->status.char_id,
  2596. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2597. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2598. 100, 0, 1, pet_db[pet_id].jname);
  2599. } else {
  2600. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2601. return -1;
  2602. }
  2603.  
  2604. return 0;
  2605. }
  2606.  
  2607. /*==========================================
  2608. *
  2609. *------------------------------------------*/
  2610. ACMD_FUNC(hatch) {
  2611. nullpo_retr(-1, sd);
  2612. if (sd->status.pet_id <= 0)
  2613. clif_sendegg(sd);
  2614. else {
  2615. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2616. return -1;
  2617. }
  2618.  
  2619. return 0;
  2620. }
  2621.  
  2622. /*==========================================
  2623. *
  2624. *------------------------------------------*/
  2625. ACMD_FUNC(petfriendly) {
  2626. int friendly;
  2627. struct pet_data *pd;
  2628. nullpo_retr(-1, sd);
  2629.  
  2630. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2631. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2632. return -1;
  2633. }
  2634.  
  2635. pd = sd->pd;
  2636. if (!pd) {
  2637. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2638. return -1;
  2639. }
  2640.  
  2641. if (friendly < 0 || friendly > 1000)
  2642. {
  2643. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2644. return -1;
  2645. }
  2646.  
  2647. if (friendly == pd->pet.intimate) {
  2648. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2649. return -1;
  2650. }
  2651.  
  2652. pet_set_intimate(pd, friendly);
  2653. clif_send_petstatus(sd);
  2654. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2655. return 0;
  2656. }
  2657.  
  2658. /*==========================================
  2659. *
  2660. *------------------------------------------*/
  2661. ACMD_FUNC(pethungry)
  2662. {
  2663. int hungry;
  2664. struct pet_data *pd;
  2665. nullpo_retr(-1, sd);
  2666.  
  2667. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2668. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2669. return -1;
  2670. }
  2671.  
  2672. pd = sd->pd;
  2673. if (!sd->status.pet_id || !pd) {
  2674. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2675. return -1;
  2676. }
  2677. if (hungry < 0 || hungry > 100) {
  2678. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2679. return -1;
  2680. }
  2681. if (hungry == pd->pet.hungry) {
  2682. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2683. return -1;
  2684. }
  2685.  
  2686. pd->pet.hungry = hungry;
  2687. clif_send_petstatus(sd);
  2688. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2689.  
  2690. return 0;
  2691. }
  2692.  
  2693. /*==========================================
  2694. *
  2695. *------------------------------------------*/
  2696. ACMD_FUNC(petrename)
  2697. {
  2698. struct pet_data *pd;
  2699. nullpo_retr(-1, sd);
  2700. if (!sd->status.pet_id || !sd->pd) {
  2701. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2702. return -1;
  2703. }
  2704. pd = sd->pd;
  2705. if (!pd->pet.rename_flag) {
  2706. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2707. return -1;
  2708. }
  2709.  
  2710. pd->pet.rename_flag = 0;
  2711. intif_save_petdata(sd->status.account_id, &pd->pet);
  2712. clif_send_petstatus(sd);
  2713. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2714.  
  2715. return 0;
  2716. }
  2717.  
  2718. /*==========================================
  2719. *
  2720. *------------------------------------------*/
  2721. ACMD_FUNC(recall) {
  2722. struct map_session_data *pl_sd = NULL;
  2723.  
  2724. nullpo_retr(-1, sd);
  2725.  
  2726. if (!message || !*message) {
  2727. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2728. return -1;
  2729. }
  2730.  
  2731. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2732. {
  2733. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2734. return -1;
  2735. }
  2736.  
  2737. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2738. {
  2739. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2740. return -1;
  2741. }
  2742.  
  2743. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2744. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2745. return -1;
  2746. }
  2747. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2748. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2749. return -1;
  2750. }
  2751. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2752. return -1;
  2753. }
  2754. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2755. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2756. clif_displaymessage(fd, atcmd_output);
  2757.  
  2758. return 0;
  2759. }
  2760.  
  2761. /*==========================================
  2762. * charblock command (usage: charblock <player_name>)
  2763. * This command do a definitiv ban on a player
  2764. *------------------------------------------*/
  2765. ACMD_FUNC(char_block)
  2766. {
  2767. nullpo_retr(-1, sd);
  2768.  
  2769. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2770.  
  2771. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2772. clif_displaymessage(fd, msg_txt(sd,1021)); // Please enter a player name (usage: @charblock/@block <char name>).
  2773. return -1;
  2774. }
  2775.  
  2776. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2777. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2778.  
  2779. return 0;
  2780. }
  2781.  
  2782. /*==========================================
  2783. * charban command (usage: charban <time> <player_name>)
  2784. * This command do a limited ban on a player
  2785. * Time is done as follows:
  2786. * Adjustment value (-1, 1, +1, etc...)
  2787. * Modified element:
  2788. * a or y: year
  2789. * m: month
  2790. * j or d: day
  2791. * h: hour
  2792. * mn: minute
  2793. * s: second
  2794. * <example> @ban +1m-2mn1s-6y test_player
  2795. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2796. *------------------------------------------*/
  2797. ACMD_FUNC(char_ban)
  2798. {
  2799. char * modif_p;
  2800. int year, month, day, hour, minute, second, value;
  2801. time_t timestamp;
  2802. struct tm *tmtime;
  2803. nullpo_retr(-1, sd);
  2804.  
  2805. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2806. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2807.  
  2808. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2809. clif_displaymessage(fd, msg_txt(sd,1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <char name>).
  2810. return -1;
  2811. }
  2812.  
  2813. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2814.  
  2815. modif_p = atcmd_output;
  2816. year = month = day = hour = minute = second = 0;
  2817. while (modif_p[0] != '\0') {
  2818. value = atoi(modif_p);
  2819. if (value == 0)
  2820. modif_p++;
  2821. else {
  2822. if (modif_p[0] == '-' || modif_p[0] == '+')
  2823. modif_p++;
  2824. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2825. modif_p++;
  2826. if (modif_p[0] == 's') {
  2827. second = value;
  2828. modif_p++;
  2829. } else if (modif_p[0] == 'n') {
  2830. minute = value;
  2831. modif_p++;
  2832. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  2833. minute = value;
  2834. modif_p = modif_p + 2;
  2835. } else if (modif_p[0] == 'h') {
  2836. hour = value;
  2837. modif_p++;
  2838. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2839. day = value;
  2840. modif_p++;
  2841. } else if (modif_p[0] == 'm') {
  2842. month = value;
  2843. modif_p++;
  2844. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2845. year = value;
  2846. modif_p++;
  2847. } else if (modif_p[0] != '\0') {
  2848. modif_p++;
  2849. }
  2850. }
  2851. }
  2852. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2853. clif_displaymessage(fd, msg_txt(sd,85)); // Invalid time for ban command.
  2854. return -1;
  2855. }
  2856. /**
  2857. * We now check if you can adjust the ban to negative (and if this is the case)
  2858. **/
  2859. timestamp = time(NULL);
  2860. tmtime = localtime(&timestamp);
  2861. tmtime->tm_year = tmtime->tm_year + year;
  2862. tmtime->tm_mon = tmtime->tm_mon + month;
  2863. tmtime->tm_mday = tmtime->tm_mday + day;
  2864. tmtime->tm_hour = tmtime->tm_hour + hour;
  2865. tmtime->tm_min = tmtime->tm_min + minute;
  2866. tmtime->tm_sec = tmtime->tm_sec + second;
  2867. timestamp = mktime(tmtime);
  2868. if( timestamp <= time(NULL) && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) ) {
  2869. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to reduce the length of a ban.
  2870. return -1;
  2871. }
  2872.  
  2873. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2874. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2875.  
  2876. return 0;
  2877. }
  2878.  
  2879. /*==========================================
  2880. * charunblock command (usage: charunblock <player_name>)
  2881. *------------------------------------------*/
  2882. ACMD_FUNC(char_unblock)
  2883. {
  2884. nullpo_retr(-1, sd);
  2885.  
  2886. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2887.  
  2888. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2889. clif_displaymessage(fd, msg_txt(sd,1024)); // Please enter a player name (usage: @charunblock <char name>).
  2890. return -1;
  2891. }
  2892.  
  2893. // send answer to login server via char-server
  2894. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2895. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2896.  
  2897. return 0;
  2898. }
  2899.  
  2900. /*==========================================
  2901. * charunban command (usage: charunban <player_name>)
  2902. *------------------------------------------*/
  2903. ACMD_FUNC(char_unban)
  2904. {
  2905. nullpo_retr(-1, sd);
  2906.  
  2907. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2908.  
  2909. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2910. clif_displaymessage(fd, msg_txt(sd,1025)); // Please enter a player name (usage: @charunban <char name>).
  2911. return -1;
  2912. }
  2913.  
  2914. // send answer to login server via char-server
  2915. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2916. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2917.  
  2918. return 0;
  2919. }
  2920.  
  2921. /*==========================================
  2922. *
  2923. *------------------------------------------*/
  2924. ACMD_FUNC(night)
  2925. {
  2926. nullpo_retr(-1, sd);
  2927.  
  2928. if (night_flag != 1) {
  2929. map_night_timer(night_timer_tid, 0, 0, 1);
  2930. } else {
  2931. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2932. return -1;
  2933. }
  2934.  
  2935. return 0;
  2936. }
  2937.  
  2938. /*==========================================
  2939. *
  2940. *------------------------------------------*/
  2941. ACMD_FUNC(day)
  2942. {
  2943. nullpo_retr(-1, sd);
  2944.  
  2945. if (night_flag != 0) {
  2946. map_day_timer(day_timer_tid, 0, 0, 1);
  2947. } else {
  2948. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2949. return -1;
  2950. }
  2951.  
  2952. return 0;
  2953. }
  2954.  
  2955. /*==========================================
  2956. *
  2957. *------------------------------------------*/
  2958. ACMD_FUNC(doom)
  2959. {
  2960. struct map_session_data* pl_sd;
  2961. struct s_mapiterator* iter;
  2962.  
  2963. nullpo_retr(-1, sd);
  2964.  
  2965. iter = mapit_getallusers();
  2966. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2967. {
  2968. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2969. {
  2970. status_kill(&pl_sd->bl);
  2971. clif_specialeffect(&pl_sd->bl,450,AREA);
  2972. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2973. }
  2974. }
  2975. mapit_free(iter);
  2976.  
  2977. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2978.  
  2979. return 0;
  2980. }
  2981.  
  2982. /*==========================================
  2983. *
  2984. *------------------------------------------*/
  2985. ACMD_FUNC(doommap)
  2986. {
  2987. struct map_session_data* pl_sd;
  2988. struct s_mapiterator* iter;
  2989.  
  2990. nullpo_retr(-1, sd);
  2991.  
  2992. iter = mapit_getallusers();
  2993. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2994. {
  2995. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2996. {
  2997. status_kill(&pl_sd->bl);
  2998. clif_specialeffect(&pl_sd->bl,450,AREA);
  2999. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  3000. }
  3001. }
  3002. mapit_free(iter);
  3003.  
  3004. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  3005.  
  3006. return 0;
  3007. }
  3008.  
  3009. /*==========================================
  3010. *
  3011. *------------------------------------------*/
  3012. static void atcommand_raise_sub(struct map_session_data* sd) {
  3013.  
  3014. status_revive(&sd->bl, 100, 100);
  3015.  
  3016. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3017. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  3018. }
  3019.  
  3020. /*==========================================
  3021. *
  3022. *------------------------------------------*/
  3023. ACMD_FUNC(raise)
  3024. {
  3025. struct map_session_data* pl_sd;
  3026. struct s_mapiterator* iter;
  3027.  
  3028. nullpo_retr(-1, sd);
  3029.  
  3030. iter = mapit_getallusers();
  3031. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3032. if( pc_isdead(pl_sd) )
  3033. atcommand_raise_sub(pl_sd);
  3034. mapit_free(iter);
  3035.  
  3036. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  3037.  
  3038. return 0;
  3039. }
  3040.  
  3041. /*==========================================
  3042. *
  3043. *------------------------------------------*/
  3044. ACMD_FUNC(raisemap)
  3045. {
  3046. struct map_session_data* pl_sd;
  3047. struct s_mapiterator* iter;
  3048.  
  3049. nullpo_retr(-1, sd);
  3050.  
  3051. iter = mapit_getallusers();
  3052. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3053. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  3054. atcommand_raise_sub(pl_sd);
  3055. mapit_free(iter);
  3056.  
  3057. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  3058.  
  3059. return 0;
  3060. }
  3061.  
  3062. /*==========================================
  3063. *
  3064. *------------------------------------------*/
  3065. ACMD_FUNC(kick)
  3066. {
  3067. struct map_session_data *pl_sd;
  3068. nullpo_retr(-1, sd);
  3069.  
  3070. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3071.  
  3072. if (!message || !*message) {
  3073. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  3074. return -1;
  3075. }
  3076.  
  3077. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3078. {
  3079. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3080. return -1;
  3081. }
  3082.  
  3083. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  3084. {
  3085. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3086. return -1;
  3087. }
  3088.  
  3089. clif_GM_kick(sd, pl_sd);
  3090.  
  3091. return 0;
  3092. }
  3093.  
  3094. /*==========================================
  3095. *
  3096. *------------------------------------------*/
  3097. ACMD_FUNC(kickall)
  3098. {
  3099. struct map_session_data* pl_sd;
  3100. struct s_mapiterator* iter;
  3101. nullpo_retr(-1, sd);
  3102.  
  3103. iter = mapit_getallusers();
  3104. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3105. {
  3106. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  3107. if (sd->status.account_id != pl_sd->status.account_id)
  3108. clif_GM_kick(NULL, pl_sd);
  3109. }
  3110. }
  3111. mapit_free(iter);
  3112.  
  3113. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  3114.  
  3115. return 0;
  3116. }
  3117.  
  3118. /*==========================================
  3119. *
  3120. *------------------------------------------*/
  3121. ACMD_FUNC(allskill)
  3122. {
  3123. nullpo_retr(-1, sd);
  3124. pc_allskillup(sd); // all skills
  3125. sd->status.skill_point = 0; // 0 skill points
  3126. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3127. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  3128.  
  3129. return 0;
  3130. }
  3131.  
  3132. /*==========================================
  3133. *
  3134. *------------------------------------------*/
  3135. ACMD_FUNC(questskill)
  3136. {
  3137. uint16 skill_id;
  3138. nullpo_retr(-1, sd);
  3139.  
  3140. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3141. {// also send a list of skills applicable to this command
  3142. const char* text;
  3143.  
  3144. // attempt to find the text corresponding to this command
  3145. text = atcommand_help_string( command );
  3146.  
  3147. // send the error message as always
  3148. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3149.  
  3150. if( text )
  3151. {// send the skill ID list associated with this command
  3152. clif_displaymessage( fd, text );
  3153. }
  3154.  
  3155. return -1;
  3156. }
  3157. if (skill_id >= MAX_SKILL_DB) {
  3158. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3159. return -1;
  3160. }
  3161. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3162. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3163. return -1;
  3164. }
  3165. if (pc_checkskill(sd, skill_id) > 0) {
  3166. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  3167. return -1;
  3168. }
  3169.  
  3170. pc_skill(sd, skill_id, 1, 0);
  3171. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  3172.  
  3173. return 0;
  3174. }
  3175.  
  3176. /*==========================================
  3177. *
  3178. *------------------------------------------*/
  3179. ACMD_FUNC(lostskill)
  3180. {
  3181. uint16 skill_id;
  3182. nullpo_retr(-1, sd);
  3183.  
  3184. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3185. {// also send a list of skills applicable to this command
  3186. const char* text;
  3187.  
  3188. // attempt to find the text corresponding to this command
  3189. text = atcommand_help_string( command );
  3190.  
  3191. // send the error message as always
  3192. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3193.  
  3194. if( text )
  3195. {// send the skill ID list associated with this command
  3196. clif_displaymessage( fd, text );
  3197. }
  3198.  
  3199. return -1;
  3200. }
  3201. if (skill_id >= MAX_SKILL) {
  3202. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3203. return -1;
  3204. }
  3205. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3206. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3207. return -1;
  3208. }
  3209. if (pc_checkskill(sd, skill_id) == 0) {
  3210. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  3211. return -1;
  3212. }
  3213.  
  3214. sd->status.skill[skill_id].lv = 0;
  3215. sd->status.skill[skill_id].flag = SKILL_FLAG_PERMANENT;
  3216. clif_deleteskill(sd,skill_id);
  3217. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  3218.  
  3219. return 0;
  3220. }
  3221.  
  3222. /*==========================================
  3223. *
  3224. *------------------------------------------*/
  3225. ACMD_FUNC(spiritball)
  3226. {
  3227. int max_spiritballs;
  3228. int number;
  3229. nullpo_retr(-1, sd);
  3230.  
  3231. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  3232.  
  3233. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  3234. {
  3235. char msg[CHAT_SIZE_MAX];
  3236. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  3237. clif_displaymessage(fd, msg);
  3238. return -1;
  3239. }
  3240.  
  3241. if( sd->spiritball > 0 )
  3242. pc_delspiritball(sd, sd->spiritball, 1);
  3243. sd->spiritball = number;
  3244. clif_spiritball(&sd->bl);
  3245. // no message, player can look the difference
  3246.  
  3247. return 0;
  3248. }
  3249.  
  3250. /*==========================================
  3251. *
  3252. *------------------------------------------*/
  3253. ACMD_FUNC(party)
  3254. {
  3255. char party[NAME_LENGTH];
  3256. nullpo_retr(-1, sd);
  3257.  
  3258. memset(party, '\0', sizeof(party));
  3259.  
  3260. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3261. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  3262. return -1;
  3263. }
  3264.  
  3265. party_create(sd, party, 0, 0);
  3266.  
  3267. return 0;
  3268. }
  3269.  
  3270. /*==========================================
  3271. *
  3272. *------------------------------------------*/
  3273. ACMD_FUNC(guild)
  3274. {
  3275. char guild[NAME_LENGTH];
  3276. int prev;
  3277. nullpo_retr(-1, sd);
  3278.  
  3279. memset(guild, '\0', sizeof(guild));
  3280.  
  3281. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3282. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  3283. return -1;
  3284. }
  3285.  
  3286. prev = battle_config.guild_emperium_check;
  3287. battle_config.guild_emperium_check = 0;
  3288. guild_create(sd, guild);
  3289. battle_config.guild_emperium_check = prev;
  3290.  
  3291. return 0;
  3292. }
  3293.  
  3294. ACMD_FUNC(breakguild)
  3295. {
  3296. nullpo_retr(-1, sd);
  3297.  
  3298. if (sd->status.guild_id) { // Check if the player has a guild
  3299. struct guild *g;
  3300. g = sd->guild; // Search the guild
  3301. if (g) { // Check if guild was found
  3302. if (sd->state.gmaster_flag) { // Check if player is guild master
  3303. int ret = 0;
  3304. ret = guild_break(sd, g->name); // Break guild
  3305. if (ret) { // Check if anything went wrong
  3306. return 0; // Guild was broken
  3307. } else {
  3308. return -1; // Something went wrong
  3309. }
  3310. } else { // Not guild master
  3311. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  3312. return -1;
  3313. }
  3314. } else { // Guild was not found. HOW?
  3315. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3316. return -1;
  3317. }
  3318. } else { // Player does not have a guild
  3319. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3320. return -1;
  3321. }
  3322. return 0;
  3323. }
  3324.  
  3325. /*==========================================
  3326. *
  3327. *------------------------------------------*/
  3328. ACMD_FUNC(agitstart)
  3329. {
  3330. nullpo_retr(-1, sd);
  3331. if (agit_flag == 1) {
  3332. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  3333. return -1;
  3334. }
  3335.  
  3336. agit_flag = 1;
  3337. guild_agit_start();
  3338. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  3339.  
  3340. return 0;
  3341. }
  3342.  
  3343. /*==========================================
  3344. *
  3345. *------------------------------------------*/
  3346. ACMD_FUNC(agitstart2)
  3347. {
  3348. nullpo_retr(-1, sd);
  3349. if (agit2_flag == 1) {
  3350. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  3351. return -1;
  3352. }
  3353.  
  3354. agit2_flag = 1;
  3355. guild_agit2_start();
  3356. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  3357.  
  3358. return 0;
  3359. }
  3360.  
  3361. /*==========================================
  3362. *
  3363. *------------------------------------------*/
  3364. ACMD_FUNC(agitend)
  3365. {
  3366. nullpo_retr(-1, sd);
  3367. if (agit_flag == 0) {
  3368. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3369. return -1;
  3370. }
  3371.  
  3372. agit_flag = 0;
  3373. guild_agit_end();
  3374. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3375.  
  3376. return 0;
  3377. }
  3378.  
  3379. /*==========================================
  3380. *
  3381. *------------------------------------------*/
  3382. ACMD_FUNC(agitend2)
  3383. {
  3384. nullpo_retr(-1, sd);
  3385. if (agit2_flag == 0) {
  3386. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3387. return -1;
  3388. }
  3389.  
  3390. agit2_flag = 0;
  3391. guild_agit2_end();
  3392. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3393.  
  3394. return 0;
  3395. }
  3396.  
  3397. /*==========================================
  3398. * @mapexit - shuts down the map server
  3399. *------------------------------------------*/
  3400. ACMD_FUNC(mapexit)
  3401. {
  3402. nullpo_retr(-1, sd);
  3403.  
  3404. do_shutdown();
  3405. return 0;
  3406. }
  3407.  
  3408. /*==========================================
  3409. * idsearch <part_of_name>: revrited by [Yor]
  3410. *------------------------------------------*/
  3411. ACMD_FUNC(idsearch)
  3412. {
  3413. char item_name[100];
  3414. unsigned int i, match;
  3415. struct item_data *item_array[MAX_SEARCH];
  3416. nullpo_retr(-1, sd);
  3417.  
  3418. memset(item_name, '\0', sizeof(item_name));
  3419. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3420.  
  3421. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3422. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3423. return -1;
  3424. }
  3425.  
  3426. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3427. clif_displaymessage(fd, atcmd_output);
  3428. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3429. if (match > MAX_SEARCH) {
  3430. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, match);
  3431. clif_displaymessage(fd, atcmd_output);
  3432. match = MAX_SEARCH;
  3433. }
  3434. for(i = 0; i < match; i++) {
  3435. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3436. clif_displaymessage(fd, atcmd_output);
  3437. }
  3438. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3439. clif_displaymessage(fd, atcmd_output);
  3440.  
  3441. return 0;
  3442. }
  3443.  
  3444. /*==========================================
  3445. * Recall All Characters Online To Your Location
  3446. *------------------------------------------*/
  3447. ACMD_FUNC(recallall)
  3448. {
  3449. struct map_session_data* pl_sd;
  3450. struct s_mapiterator* iter;
  3451. int count;
  3452. nullpo_retr(-1, sd);
  3453.  
  3454. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3455.  
  3456. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3457. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp somenone to your current map.
  3458. return -1;
  3459. }
  3460.  
  3461. count = 0;
  3462. iter = mapit_getallusers();
  3463. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3464. {
  3465. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3466. {
  3467. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3468. continue; // Don't waste time warping the character to the same place.
  3469. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3470. count++;
  3471. else {
  3472. if (pc_isdead(pl_sd)) { //Wake them up
  3473. pc_setstand(pl_sd);
  3474. pc_setrestartvalue(pl_sd,1);
  3475. }
  3476. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3477. }
  3478. }
  3479. }
  3480. mapit_free(iter);
  3481.  
  3482. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3483. if (count) {
  3484. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3485. clif_displaymessage(fd, atcmd_output);
  3486. }
  3487.  
  3488. return 0;
  3489. }
  3490.  
  3491. /*==========================================
  3492. * Recall online characters of a guild to your location
  3493. *------------------------------------------*/
  3494. ACMD_FUNC(guildrecall)
  3495. {
  3496. struct map_session_data* pl_sd;
  3497. struct s_mapiterator* iter;
  3498. int count;
  3499. char guild_name[NAME_LENGTH];
  3500. struct guild *g;
  3501. nullpo_retr(-1, sd);
  3502.  
  3503. memset(guild_name, '\0', sizeof(guild_name));
  3504. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3505.  
  3506. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3507. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3508. return -1;
  3509. }
  3510.  
  3511. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3512. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp somenone to your current map.
  3513. return -1;
  3514. }
  3515.  
  3516. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3517. (g = guild_search(atoi(message))) == NULL)
  3518. {
  3519. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3520. return -1;
  3521. }
  3522.  
  3523. count = 0;
  3524.  
  3525. iter = mapit_getallusers();
  3526. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3527. {
  3528. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3529. {
  3530. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
  3531. continue; // Skip GMs greater than you... or chars already on the cell
  3532. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3533. count++;
  3534. else
  3535. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3536. }
  3537. }
  3538. mapit_free(iter);
  3539.  
  3540. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3541. clif_displaymessage(fd, atcmd_output);
  3542. if (count) {
  3543. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3544. clif_displaymessage(fd, atcmd_output);
  3545. }
  3546.  
  3547. return 0;
  3548. }
  3549.  
  3550. /*==========================================
  3551. * Recall online characters of a party to your location
  3552. *------------------------------------------*/
  3553. ACMD_FUNC(partyrecall)
  3554. {
  3555. struct map_session_data* pl_sd;
  3556. struct s_mapiterator* iter;
  3557. char party_name[NAME_LENGTH];
  3558. struct party_data *p;
  3559. int count;
  3560. nullpo_retr(-1, sd);
  3561.  
  3562. memset(party_name, '\0', sizeof(party_name));
  3563. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3564.  
  3565. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3566. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3567. return -1;
  3568. }
  3569.  
  3570. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3571. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp somenone to your current map.
  3572. return -1;
  3573. }
  3574.  
  3575. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3576. (p = party_search(atoi(message))) == NULL)
  3577. {
  3578. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3579. return -1;
  3580. }
  3581.  
  3582. count = 0;
  3583.  
  3584. iter = mapit_getallusers();
  3585. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3586. {
  3587. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3588. {
  3589. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
  3590. continue; // Skip GMs greater than you... or chars already on the cell
  3591. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3592. count++;
  3593. else
  3594. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3595. }
  3596. }
  3597. mapit_free(iter);
  3598.  
  3599. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3600. clif_displaymessage(fd, atcmd_output);
  3601. if (count) {
  3602. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3603. clif_displaymessage(fd, atcmd_output);
  3604. }
  3605.  
  3606. return 0;
  3607. }
  3608.  
  3609. /*==========================================
  3610. *
  3611. *------------------------------------------*/
  3612. void atcommand_doload();
  3613. ACMD_FUNC(reload) {
  3614. nullpo_retr(-1, sd);
  3615.  
  3616. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3617. const char* text;
  3618.  
  3619. text = atcommand_help_string( command );
  3620. if(text)
  3621. clif_displaymessage( fd, text );
  3622. return -1;
  3623. }
  3624.  
  3625. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3626. itemdb_reload();
  3627. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3628. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3629. mob_reload();
  3630. read_petdb();
  3631. merc_reload();
  3632. read_mercenarydb();
  3633. read_mercenary_skilldb();
  3634. reload_elementaldb();
  3635. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3636. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3637. skill_reload();
  3638. merc_skill_reload();
  3639. reload_elemental_skilldb();
  3640. read_mercenary_skilldb();
  3641. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3642. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3643. config_t run_test;
  3644.  
  3645. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3646. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3647. return -1;
  3648. }
  3649.  
  3650. config_destroy(&run_test);
  3651.  
  3652. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3653. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3654. return -1;
  3655. }
  3656.  
  3657. config_destroy(&run_test);
  3658.  
  3659. atcommand_doload();
  3660. pc_groups_reload();
  3661. clif_displaymessage(fd, msg_txt(sd,254));
  3662. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3663. struct Battle_Config prev_config;
  3664. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3665.  
  3666. battle_config_read(BATTLE_CONF_FILENAME);
  3667.  
  3668. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3669. || prev_config.item_rate_common != battle_config.item_rate_common
  3670. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3671. || prev_config.item_rate_card != battle_config.item_rate_card
  3672. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3673. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3674. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3675. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3676. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3677. || prev_config.item_rate_use != battle_config.item_rate_use
  3678. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3679. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3680. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3681. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3682. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3683. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3684. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3685. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3686. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3687. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3688. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3689. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3690. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3691. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3692. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3693. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3694. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3695. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3696. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3697. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3698. )
  3699. { // Exp or Drop rates changed.
  3700. mob_reload(); //Needed as well so rate changes take effect.
  3701. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3702. }
  3703. clif_displaymessage(fd, msg_txt(sd,255));
  3704. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3705. status_readdb();
  3706. clif_displaymessage(fd, msg_txt(sd,256));
  3707. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3708. pc_readdb();
  3709. clif_displaymessage(fd, msg_txt(sd,257));
  3710. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3711. pc_read_motd();
  3712. clif_displaymessage(fd, msg_txt(sd,268));
  3713. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3714. struct s_mapiterator* iter;
  3715. struct map_session_data* pl_sd;
  3716. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3717. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3718.  
  3719. iter = mapit_getallusers();
  3720. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3721. pc_close_npc(pl_sd,2);
  3722. mapit_free(iter);
  3723.  
  3724. flush_fifos();
  3725. map_reloadnpc(true); // reload config files seeking for npcs
  3726. script_reload();
  3727. npc_reload();
  3728.  
  3729. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3730. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3731. map_msg_reload();
  3732. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3733. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3734. do_reload_quest();
  3735. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3736. } else if (strstr(command, "packetdb") || strncmp(message, "packetdb", 4) == 0) {
  3737. packetdb_readdb();
  3738. clif_displaymessage(fd, msg_txt(sd,1477)); // Packet database has been reloaded.
  3739. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3740. instance_readdb();
  3741. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3742. }
  3743.  
  3744.  
  3745. return 0;
  3746. }
  3747. /*==========================================
  3748. * @partysharelvl <share_range> [Akinari]
  3749. * Updates char server party share level range in runtime
  3750. * Temporary - Permanent update in inter_athena.conf
  3751. *------------------------------------------*/
  3752. ACMD_FUNC(partysharelvl) {
  3753. unsigned int share_lvl;
  3754.  
  3755. nullpo_retr(-1, sd);
  3756.  
  3757. if(!message || !*message) {
  3758. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3759. return -1;
  3760. } else
  3761. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3762.  
  3763. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3764. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3765. else //Char server offline
  3766. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3767.  
  3768. return 0;
  3769. }
  3770.  
  3771. /*==========================================
  3772. * @mapinfo [0-3] <map name> by MC_Cameri
  3773. * => Shows information about the map [map name]
  3774. * 0 = no additional information
  3775. * 1 = Show users in that map and their location
  3776. * 2 = Shows NPCs in that map
  3777. * 3 = Shows the chats in that map
  3778. *------------------------------------------*/
  3779. ACMD_FUNC(mapinfo) {
  3780. struct map_session_data* pl_sd;
  3781. struct s_mapiterator* iter;
  3782. struct npc_data *nd = NULL;
  3783. struct chat_data *cd = NULL;
  3784. char direction[12];
  3785. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3786. unsigned short m_index;
  3787. char mapname[24];
  3788.  
  3789. nullpo_retr(-1, sd);
  3790.  
  3791. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3792. memset(mapname, '\0', sizeof(mapname));
  3793. memset(direction, '\0', sizeof(direction));
  3794.  
  3795. sscanf(message, "%d %23[^\n]", &list, mapname);
  3796.  
  3797. if (list < 0 || list > 3) {
  3798. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3799. return -1;
  3800. }
  3801.  
  3802. if (mapname[0] == '\0') {
  3803. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3804. m_id = map_mapindex2mapid(sd->mapindex);
  3805. } else {
  3806. m_id = map_mapname2mapid(mapname);
  3807. }
  3808.  
  3809. if (m_id < 0) {
  3810. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3811. return -1;
  3812. }
  3813. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3814.  
  3815. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3816.  
  3817. // count chats (for initial message)
  3818. chat_num = 0;
  3819. iter = mapit_getallusers();
  3820. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3821. if( pl_sd->mapindex == m_index ) {
  3822. if( pl_sd->state.vending )
  3823. vend_num++;
  3824. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3825. chat_num++;
  3826. }
  3827. }
  3828. mapit_free(iter);
  3829.  
  3830. sprintf(atcmd_output, msg_txt(sd,1040), mapname, map[m_id].users, map[m_id].npc_num, chat_num, vend_num); // Map: %s | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
  3831. clif_displaymessage(fd, atcmd_output);
  3832. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3833. if (map[m_id].flag.town)
  3834. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3835. if (map[m_id].flag.restricted){
  3836. sprintf(atcmd_output, " Restricted (zone %d)",map[m_id].zone);
  3837. clif_displaymessage(fd, atcmd_output);
  3838. }
  3839.  
  3840. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3841. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3842. else
  3843. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3844.  
  3845. if (map[m_id].flag.battleground){
  3846. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3847. clif_displaymessage(fd, atcmd_output);
  3848. }
  3849.  
  3850. /* Skill damage adjustment info [Cydh] */
  3851. #ifdef ADJUST_SKILL_DAMAGE
  3852. if (map[m_id].flag.skill_damage) {
  3853. int j;
  3854. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3855. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3856. ,map[m_id].adjust.damage.pc
  3857. ,map[m_id].adjust.damage.mob
  3858. ,map[m_id].adjust.damage.boss
  3859. ,map[m_id].adjust.damage.other
  3860. ,map[m_id].adjust.damage.caster);
  3861. clif_displaymessage(fd, atcmd_output);
  3862. if (map[m_id].skill_damage[0].skill_id) {
  3863. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3864. for (j = 0; j < MAX_MAP_SKILL_MODIFIER; j++) {
  3865. if (map[m_id].skill_damage[j].skill_id) {
  3866. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3867. ,j+1
  3868. ,skill_db[skill_get_index(map[m_id].skill_damage[j].skill_id)].name
  3869. ,map[m_id].skill_damage[j].pc
  3870. ,map[m_id].skill_damage[j].mob
  3871. ,map[m_id].skill_damage[j].boss
  3872. ,map[m_id].skill_damage[j].other
  3873. ,map[m_id].skill_damage[j].caster);
  3874. clif_displaymessage(fd,atcmd_output);
  3875. }
  3876. }
  3877. }
  3878. }
  3879. #endif
  3880.  
  3881. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3882. if (map[m_id].flag.pvp)
  3883. strcat(atcmd_output, " Pvp ON |");
  3884. if (map[m_id].flag.pvp_noguild)
  3885. strcat(atcmd_output, " NoGuild |");
  3886. if (map[m_id].flag.pvp_noparty)
  3887. strcat(atcmd_output, " NoParty |");
  3888. if (map[m_id].flag.pvp_nightmaredrop)
  3889. strcat(atcmd_output, " NightmareDrop |");
  3890. if (map[m_id].flag.pvp_nocalcrank)
  3891. strcat(atcmd_output, " NoCalcRank |");
  3892. clif_displaymessage(fd, atcmd_output);
  3893.  
  3894. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3895. if (map[m_id].flag.gvg)
  3896. strcat(atcmd_output, " GvG ON |");
  3897. if (map[m_id].flag.gvg_dungeon)
  3898. strcat(atcmd_output, " GvG Dungeon |");
  3899. if (map[m_id].flag.gvg_castle)
  3900. strcat(atcmd_output, " GvG Castle |");
  3901. if (map[m_id].flag.gvg_noparty)
  3902. strcat(atcmd_output, " NoParty |");
  3903. clif_displaymessage(fd, atcmd_output);
  3904.  
  3905. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3906. if (map[m_id].flag.noteleport)
  3907. strcat(atcmd_output, " NoTeleport |");
  3908. if (map[m_id].flag.monster_noteleport)
  3909. strcat(atcmd_output, " Monster NoTeleport |");
  3910. if (map[m_id].flag.nowarp)
  3911. strcat(atcmd_output, " NoWarp |");
  3912. if (map[m_id].flag.nowarpto)
  3913. strcat(atcmd_output, " NoWarpTo |");
  3914. if (map[m_id].flag.noreturn)
  3915. strcat(atcmd_output, " NoReturn |");
  3916. if (map[m_id].flag.nogo)
  3917. strcat(atcmd_output, " NoGo |"); //
  3918. if (map[m_id].flag.nomemo)
  3919. strcat(atcmd_output, " NoMemo |");
  3920. clif_displaymessage(fd, atcmd_output);
  3921.  
  3922. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3923. (map[m_id].flag.noexppenalty) ? msg_txt(sd,1066) : msg_txt(sd,1067), (map[m_id].flag.nozenypenalty) ? msg_txt(sd,1066) : msg_txt(sd,1067)); // On / Off
  3924. clif_displaymessage(fd, atcmd_output);
  3925.  
  3926. if (map[m_id].flag.nosave) {
  3927. if (!map[m_id].save.map)
  3928. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3929. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3930. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3931. clif_displaymessage(fd, atcmd_output);
  3932. }
  3933. else {
  3934. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3935. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3936. clif_displaymessage(fd, atcmd_output);
  3937. }
  3938. }
  3939.  
  3940. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3941. if (map[m_id].flag.snow)
  3942. strcat(atcmd_output, " Snow |");
  3943. if (map[m_id].flag.fog)
  3944. strcat(atcmd_output, " Fog |");
  3945. if (map[m_id].flag.sakura)
  3946. strcat(atcmd_output, " Sakura |");
  3947. if (map[m_id].flag.clouds)
  3948. strcat(atcmd_output, " Clouds |");
  3949. if (map[m_id].flag.clouds2)
  3950. strcat(atcmd_output, " Clouds2 |");
  3951. if (map[m_id].flag.fireworks)
  3952. strcat(atcmd_output, " Fireworks |");
  3953. if (map[m_id].flag.leaves)
  3954. strcat(atcmd_output, " Leaves |");
  3955. if (map[m_id].flag.nightenabled)
  3956. strcat(atcmd_output, " Displays Night |");
  3957. clif_displaymessage(fd, atcmd_output);
  3958.  
  3959. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3960. if (map[m_id].flag.nobranch)
  3961. strcat(atcmd_output, " NoBranch |");
  3962. if (map[m_id].flag.notrade)
  3963. strcat(atcmd_output, " NoTrade |");
  3964. if (map[m_id].flag.novending)
  3965. strcat(atcmd_output, " NoVending |");
  3966. if (map[m_id].flag.nodrop)
  3967. strcat(atcmd_output, " NoDrop |");
  3968. if (map[m_id].flag.noskill)
  3969. strcat(atcmd_output, " NoSkill |");
  3970. if (map[m_id].flag.noicewall)
  3971. strcat(atcmd_output, " NoIcewall |");
  3972. if (map[m_id].flag.allowks)
  3973. strcat(atcmd_output, " AllowKS |");
  3974. if (map[m_id].flag.reset)
  3975. strcat(atcmd_output, " Reset |");
  3976. clif_displaymessage(fd, atcmd_output);
  3977.  
  3978. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3979. if (map[m_id].nocommand)
  3980. strcat(atcmd_output, " NoCommand |");
  3981. if (map[m_id].flag.nobaseexp)
  3982. strcat(atcmd_output, " NoBaseEXP |");
  3983. if (map[m_id].flag.nojobexp)
  3984. strcat(atcmd_output, " NoJobEXP |");
  3985. if (map[m_id].flag.nomobloot)
  3986. strcat(atcmd_output, " NoMobLoot |");
  3987. if (map[m_id].flag.nomvploot)
  3988. strcat(atcmd_output, " NoMVPLoot |");
  3989. if (map[m_id].flag.partylock)
  3990. strcat(atcmd_output, " PartyLock |");
  3991. if (map[m_id].flag.guildlock)
  3992. strcat(atcmd_output, " GuildLock |");
  3993. if (map[m_id].flag.loadevent)
  3994. strcat(atcmd_output, " Loadevent |");
  3995. if (map[m_id].flag.chmautojoin)
  3996. strcat(atcmd_output, " Chmautojoin |");
  3997. if (map[m_id].flag.nousecart)
  3998. strcat(atcmd_output, " NoUsecart |");
  3999. if (map[m_id].flag.noitemconsumption)
  4000. strcat(atcmd_output, " NoItemConsumption |");
  4001. if (map[m_id].flag.nosumstarmiracle)
  4002. strcat(atcmd_output, " NoSumStarMiracle |");
  4003. if (map[m_id].flag.nomineeffect)
  4004. strcat(atcmd_output, " NoMineEffect |");
  4005. if (map[m_id].flag.nolockon)
  4006. strcat(atcmd_output, " NoLockOn |");
  4007. if (map[m_id].flag.notomb)
  4008. strcat(atcmd_output, " NoTomb |");
  4009. clif_displaymessage(fd, atcmd_output);
  4010.  
  4011. switch (list) {
  4012. case 0:
  4013. // Do nothing. It's list 0, no additional display.
  4014. break;
  4015. case 1:
  4016. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  4017. iter = mapit_getallusers();
  4018. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4019. {
  4020. if (pl_sd->mapindex == m_index) {
  4021. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  4022. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  4023. clif_displaymessage(fd, atcmd_output);
  4024. }
  4025. }
  4026. mapit_free(iter);
  4027. break;
  4028. case 2:
  4029. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  4030. for (i = 0; i < map[m_id].npc_num;)
  4031. {
  4032. nd = map[m_id].npc[i];
  4033. switch(nd->ud.dir) {
  4034. case 0: strcpy(direction, msg_txt(sd,491)); break; // North
  4035. case 1: strcpy(direction, msg_txt(sd,492)); break; // North West
  4036. case 2: strcpy(direction, msg_txt(sd,493)); break; // West
  4037. case 3: strcpy(direction, msg_txt(sd,494)); break; // South West
  4038. case 4: strcpy(direction, msg_txt(sd,495)); break; // South
  4039. case 5: strcpy(direction, msg_txt(sd,496)); break; // South East
  4040. case 6: strcpy(direction, msg_txt(sd,497)); break; // East
  4041. case 7: strcpy(direction, msg_txt(sd,498)); break; // North East
  4042. case 9: strcpy(direction, msg_txt(sd,491)); break; // North
  4043. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  4044. }
  4045. if(strcmp(nd->name,nd->exname) == 0)
  4046. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  4047. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  4048. else
  4049. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  4050. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  4051. clif_displaymessage(fd, atcmd_output);
  4052. }
  4053. break;
  4054. case 3:
  4055. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  4056. iter = mapit_getallusers();
  4057. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4058. {
  4059. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  4060. pl_sd->mapindex == m_index &&
  4061. cd->usersd[0] == pl_sd)
  4062. {
  4063. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  4064. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4065. clif_displaymessage(fd, atcmd_output);
  4066. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  4067. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  4068. clif_displaymessage(fd, atcmd_output);
  4069. }
  4070. }
  4071. mapit_free(iter);
  4072. break;
  4073. default: // normally impossible to arrive here
  4074. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  4075. return -1;
  4076. break;
  4077. }
  4078.  
  4079. return 0;
  4080. }
  4081.  
  4082. /*==========================================
  4083. *
  4084. *------------------------------------------*/
  4085. ACMD_FUNC(mount_peco)
  4086. {
  4087. nullpo_retr(-1, sd);
  4088.  
  4089. if (sd->disguise) {
  4090. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  4091. return -1;
  4092. }
  4093.  
  4094. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  4095. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  4096. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  4097. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  4098. } else {
  4099. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  4100. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  4101. }
  4102. return 0;
  4103. }
  4104. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 ) {
  4105. if( !pc_isridingwug(sd) ) {
  4106. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  4107. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  4108. } else {
  4109. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  4110. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  4111. }
  4112. return 0;
  4113. }
  4114. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  4115. if( !pc_ismadogear(sd) ) {
  4116. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  4117. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  4118. } else {
  4119. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  4120. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  4121. }
  4122. return 0;
  4123. }
  4124. if (!pc_isriding(sd)) { // if actually no peco
  4125.  
  4126. if (!pc_checkskill(sd, KN_RIDING)) {
  4127. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  4128. return -1;
  4129. }
  4130.  
  4131. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4132. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  4133. } else {//Dismount
  4134. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4135. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  4136. }
  4137.  
  4138. return 0;
  4139. }
  4140.  
  4141. /*==========================================
  4142. *Spy Commands by Syrus22
  4143. *------------------------------------------*/
  4144. ACMD_FUNC(guildspy)
  4145. {
  4146. char guild_name[NAME_LENGTH];
  4147. struct guild *g;
  4148. nullpo_retr(-1, sd);
  4149.  
  4150. memset(guild_name, '\0', sizeof(guild_name));
  4151. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4152.  
  4153. if (!enable_spy)
  4154. {
  4155. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4156. return -1;
  4157. }
  4158. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4159. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  4160. return -1;
  4161. }
  4162.  
  4163. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4164. (g = guild_search(atoi(message))) != NULL) {
  4165. if (sd->guildspy == g->guild_id) {
  4166. sd->guildspy = 0;
  4167. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  4168. clif_displaymessage(fd, atcmd_output);
  4169. } else {
  4170. sd->guildspy = g->guild_id;
  4171. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  4172. clif_displaymessage(fd, atcmd_output);
  4173. }
  4174. } else {
  4175. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  4176. return -1;
  4177. }
  4178.  
  4179. return 0;
  4180. }
  4181.  
  4182. /*==========================================
  4183. *
  4184. *------------------------------------------*/
  4185. ACMD_FUNC(partyspy)
  4186. {
  4187. char party_name[NAME_LENGTH];
  4188. struct party_data *p;
  4189. nullpo_retr(-1, sd);
  4190.  
  4191. memset(party_name, '\0', sizeof(party_name));
  4192. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4193.  
  4194. if (!enable_spy)
  4195. {
  4196. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4197. return -1;
  4198. }
  4199.  
  4200. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4201. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  4202. return -1;
  4203. }
  4204.  
  4205. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4206. (p = party_search(atoi(message))) != NULL) {
  4207. if (sd->partyspy == p->party.party_id) {
  4208. sd->partyspy = 0;
  4209. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  4210. clif_displaymessage(fd, atcmd_output);
  4211. } else {
  4212. sd->partyspy = p->party.party_id;
  4213. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  4214. clif_displaymessage(fd, atcmd_output);
  4215. }
  4216. } else {
  4217. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  4218. return -1;
  4219. }
  4220.  
  4221. return 0;
  4222. }
  4223.  
  4224. /*==========================================
  4225. * @repairall [Valaris]
  4226. *------------------------------------------*/
  4227. ACMD_FUNC(repairall)
  4228. {
  4229. int count, i;
  4230. nullpo_retr(-1, sd);
  4231.  
  4232. count = 0;
  4233. for (i = 0; i < MAX_INVENTORY; i++) {
  4234. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  4235. sd->status.inventory[i].attribute = 0;
  4236. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  4237. count++;
  4238. }
  4239. }
  4240.  
  4241. if (count > 0) {
  4242. clif_misceffect(&sd->bl, 3);
  4243. clif_equiplist(sd);
  4244. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  4245. } else {
  4246. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  4247. return -1;
  4248. }
  4249.  
  4250. return 0;
  4251. }
  4252.  
  4253. /*==========================================
  4254. * @nuke [Valaris]
  4255. *------------------------------------------*/
  4256. ACMD_FUNC(nuke)
  4257. {
  4258. struct map_session_data *pl_sd;
  4259. nullpo_retr(-1, sd);
  4260.  
  4261. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4262.  
  4263. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4264. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  4265. return -1;
  4266. }
  4267.  
  4268. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4269. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  4270. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4271. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  4272. } else {
  4273. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4274. return -1;
  4275. }
  4276. } else {
  4277. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4278. return -1;
  4279. }
  4280.  
  4281. return 0;
  4282. }
  4283.  
  4284. /*==========================================
  4285. * @tonpc
  4286. *------------------------------------------*/
  4287. ACMD_FUNC(tonpc)
  4288. {
  4289. char npcname[NAME_LENGTH+1];
  4290. struct npc_data *nd;
  4291.  
  4292. nullpo_retr(-1, sd);
  4293.  
  4294. memset(npcname, 0, sizeof(npcname));
  4295.  
  4296. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4297. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  4298. return -1;
  4299. }
  4300.  
  4301. if ((nd = npc_name2id(npcname)) != NULL) {
  4302. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  4303. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  4304. else
  4305. return -1;
  4306. } else {
  4307. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4308. return -1;
  4309. }
  4310.  
  4311. return 0;
  4312. }
  4313.  
  4314. /*==========================================
  4315. *
  4316. *------------------------------------------*/
  4317. ACMD_FUNC(shownpc)
  4318. {
  4319. char NPCname[NAME_LENGTH+1];
  4320. nullpo_retr(-1, sd);
  4321.  
  4322. memset(NPCname, '\0', sizeof(NPCname));
  4323.  
  4324. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4325. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  4326. return -1;
  4327. }
  4328.  
  4329. if (npc_name2id(NPCname) != NULL) {
  4330. npc_enable(NPCname, 1);
  4331. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  4332. } else {
  4333. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4334. return -1;
  4335. }
  4336.  
  4337. return 0;
  4338. }
  4339.  
  4340. /*==========================================
  4341. *
  4342. *------------------------------------------*/
  4343. ACMD_FUNC(hidenpc)
  4344. {
  4345. char NPCname[NAME_LENGTH+1];
  4346. nullpo_retr(-1, sd);
  4347.  
  4348. memset(NPCname, '\0', sizeof(NPCname));
  4349.  
  4350. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4351. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  4352. return -1;
  4353. }
  4354.  
  4355. if (npc_name2id(NPCname) == NULL) {
  4356. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4357. return -1;
  4358. }
  4359.  
  4360. npc_enable(NPCname, 0);
  4361. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4362. return 0;
  4363. }
  4364.  
  4365. ACMD_FUNC(loadnpc)
  4366. {
  4367. FILE *fp;
  4368.  
  4369. if (!message || !*message) {
  4370. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  4371. return -1;
  4372. }
  4373.  
  4374. // check if script file exists
  4375. if ((fp = fopen(message, "r")) == NULL) {
  4376. clif_displaymessage(fd, msg_txt(sd,261));
  4377. return -1;
  4378. }
  4379. fclose(fp);
  4380.  
  4381. // add to list of script sources and run it
  4382. npc_addsrcfile(message);
  4383. npc_parsesrcfile(message,true);
  4384. npc_read_event_script();
  4385.  
  4386. clif_displaymessage(fd, msg_txt(sd,262));
  4387.  
  4388. return 0;
  4389. }
  4390.  
  4391. ACMD_FUNC(unloadnpc)
  4392. {
  4393. struct npc_data *nd;
  4394. char NPCname[NAME_LENGTH+1];
  4395. nullpo_retr(-1, sd);
  4396.  
  4397. memset(NPCname, '\0', sizeof(NPCname));
  4398.  
  4399. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  4400. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  4401. return -1;
  4402. }
  4403.  
  4404. if ((nd = npc_name2id(NPCname)) == NULL) {
  4405. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4406. return -1;
  4407. }
  4408.  
  4409. npc_unload_duplicates(nd);
  4410. npc_unload(nd,true);
  4411. npc_read_event_script();
  4412. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4413. return 0;
  4414. }
  4415.  
  4416. /*==========================================
  4417. * time in txt for time command (by [Yor])
  4418. *------------------------------------------*/
  4419. char* txt_time(unsigned int duration)
  4420. {
  4421. int days, hours, minutes, seconds;
  4422. char temp[CHAT_SIZE_MAX];
  4423. static char temp1[CHAT_SIZE_MAX];
  4424.  
  4425. memset(temp, '\0', sizeof(temp));
  4426. memset(temp1, '\0', sizeof(temp1));
  4427.  
  4428. days = duration / (60 * 60 * 24);
  4429. duration = duration - (60 * 60 * 24 * days);
  4430. hours = duration / (60 * 60);
  4431. duration = duration - (60 * 60 * hours);
  4432. minutes = duration / 60;
  4433. seconds = duration - (60 * minutes);
  4434.  
  4435. if (days == 1)
  4436. sprintf(temp, msg_txt(NULL,219), days); // %d day
  4437. else if (days > 1)
  4438. sprintf(temp, msg_txt(NULL,220), days); // %d days
  4439. if (hours == 1)
  4440. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  4441. else if (hours > 1)
  4442. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  4443. if (minutes < 2)
  4444. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  4445. else
  4446. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  4447. if (seconds == 1)
  4448. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  4449. else if (seconds > 1)
  4450. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  4451.  
  4452. return temp1;
  4453. }
  4454.  
  4455. /*==========================================
  4456. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4457. * Calculation management of GM modification (@day/@night GM commands) is done
  4458. *------------------------------------------*/
  4459. ACMD_FUNC(servertime)
  4460. {
  4461. const struct TimerData * timer_data;
  4462. const struct TimerData * timer_data2;
  4463. time_t time_server; // variable for number of seconds (used with time() function)
  4464. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4465. char temp[CHAT_SIZE_MAX];
  4466. nullpo_retr(-1, sd);
  4467.  
  4468. memset(temp, '\0', sizeof(temp));
  4469.  
  4470. time(&time_server); // get time in seconds since 1/1/1970
  4471. datetime = localtime(&time_server); // convert seconds in structure
  4472. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4473. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4474. clif_displaymessage(fd, temp);
  4475.  
  4476. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4477. if (night_flag == 0)
  4478. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4479. else
  4480. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4481. } else if (battle_config.night_duration == 0)
  4482. if (night_flag == 1) { // we start with night
  4483. timer_data = get_timer(day_timer_tid);
  4484. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4485. clif_displaymessage(fd, temp);
  4486. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4487. } else
  4488. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4489. else if (battle_config.day_duration == 0)
  4490. if (night_flag == 0) { // we start with day
  4491. timer_data = get_timer(night_timer_tid);
  4492. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4493. clif_displaymessage(fd, temp);
  4494. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4495. } else
  4496. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4497. else {
  4498. if (night_flag == 0) {
  4499. timer_data = get_timer(night_timer_tid);
  4500. timer_data2 = get_timer(day_timer_tid);
  4501. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4502. clif_displaymessage(fd, temp);
  4503. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4504. sprintf(temp, msg_txt(sd,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.
  4505. else
  4506. sprintf(temp, msg_txt(sd,237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  4507. clif_displaymessage(fd, temp);
  4508. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4509. clif_displaymessage(fd, temp);
  4510. } else {
  4511. timer_data = get_timer(day_timer_tid);
  4512. timer_data2 = get_timer(night_timer_tid);
  4513. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4514. clif_displaymessage(fd, temp);
  4515. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4516. sprintf(temp, msg_txt(sd,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.
  4517. else
  4518. sprintf(temp, msg_txt(sd,239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  4519. clif_displaymessage(fd, temp);
  4520. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4521. clif_displaymessage(fd, temp);
  4522. }
  4523. }
  4524.  
  4525. return 0;
  4526. }
  4527.  
  4528. //Added by Coltaro
  4529. //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...).
  4530. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4531. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4532. {
  4533. const int factor_year = 518400; //12*30*24*60 = 518400
  4534. const int factor_month = 43200; //30*24*60 = 43200
  4535. const int factor_day = 1440; //24*60 = 1440
  4536. const int factor_hour = 60;
  4537.  
  4538. *year = jailtime/factor_year;
  4539. jailtime -= *year*factor_year;
  4540. *month = jailtime/factor_month;
  4541. jailtime -= *month*factor_month;
  4542. *day = jailtime/factor_day;
  4543. jailtime -= *day*factor_day;
  4544. *hour = jailtime/factor_hour;
  4545. jailtime -= *hour*factor_hour;
  4546. *minute = jailtime;
  4547.  
  4548. *year = *year > 0? *year : 0;
  4549. *month = *month > 0? *month : 0;
  4550. *day = *day > 0? *day : 0;
  4551. *hour = *hour > 0? *hour : 0;
  4552. *minute = *minute > 0? *minute : 0;
  4553. return;
  4554. }
  4555.  
  4556. /*==========================================
  4557. * @jail <char_name> by [Yor]
  4558. * Special warp! No check with nowarp and nowarpto flag
  4559. *------------------------------------------*/
  4560. ACMD_FUNC(jail)
  4561. {
  4562. struct map_session_data *pl_sd;
  4563. int x, y;
  4564. unsigned short m_index;
  4565. nullpo_retr(-1, sd);
  4566.  
  4567. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4568.  
  4569. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4570. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4571. return -1;
  4572. }
  4573.  
  4574. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4575. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4576. return -1;
  4577. }
  4578.  
  4579. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  4580. { // you can jail only lower or same GM
  4581. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4582. return -1;
  4583. }
  4584.  
  4585. if (pl_sd->sc.data[SC_JAILED])
  4586. {
  4587. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4588. return -1;
  4589. }
  4590.  
  4591. switch(rnd() % 2) { //Jail Locations
  4592. case 0:
  4593. m_index = mapindex_name2id(MAP_JAIL);
  4594. x = 24;
  4595. y = 75;
  4596. break;
  4597. default:
  4598. m_index = mapindex_name2id(MAP_JAIL);
  4599. x = 49;
  4600. y = 75;
  4601. break;
  4602. }
  4603.  
  4604. //Duration of INT_MAX to specify infinity.
  4605. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4606. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4607. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4608. return 0;
  4609. }
  4610.  
  4611. /*==========================================
  4612. * @unjail/@discharge <char_name> by [Yor]
  4613. * Special warp! No check with nowarp and nowarpto flag
  4614. *------------------------------------------*/
  4615. ACMD_FUNC(unjail)
  4616. {
  4617. struct map_session_data *pl_sd;
  4618.  
  4619. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4620.  
  4621. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4622. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4623. return -1;
  4624. }
  4625.  
  4626. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4627. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4628. return -1;
  4629. }
  4630.  
  4631. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4632.  
  4633. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4634. return -1;
  4635. }
  4636.  
  4637. if (!pl_sd->sc.data[SC_JAILED])
  4638. {
  4639. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4640. return -1;
  4641. }
  4642.  
  4643. //Reset jail time to 1 sec.
  4644. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4645. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4646. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4647. return 0;
  4648. }
  4649.  
  4650. ACMD_FUNC(jailfor)
  4651. {
  4652. struct map_session_data *pl_sd = NULL;
  4653. int year, month, day, hour, minute, value;
  4654. char * modif_p;
  4655. int jailtime = 0,x,y;
  4656. short m_index = 0;
  4657. nullpo_retr(-1, sd);
  4658.  
  4659. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4660. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4661. return -1;
  4662. }
  4663.  
  4664. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4665.  
  4666. modif_p = atcmd_output;
  4667. year = month = day = hour = minute = 0;
  4668. while (modif_p[0] != '\0') {
  4669. value = atoi(modif_p);
  4670. if (value == 0)
  4671. modif_p++;
  4672. else {
  4673. if (modif_p[0] == '-' || modif_p[0] == '+')
  4674. modif_p++;
  4675. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4676. modif_p++;
  4677. if (modif_p[0] == 'n') {
  4678. minute = value;
  4679. modif_p++;
  4680. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4681. minute = value;
  4682. modif_p = modif_p + 2;
  4683. } else if (modif_p[0] == 'h') {
  4684. hour = value;
  4685. modif_p++;
  4686. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4687. day = value;
  4688. modif_p++;
  4689. } else if (modif_p[0] == 'm') {
  4690. month = value;
  4691. modif_p++;
  4692. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4693. year = value;
  4694. modif_p++;
  4695. } else if (modif_p[0] != '\0') {
  4696. modif_p++;
  4697. }
  4698. }
  4699. }
  4700.  
  4701. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4702. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4703. return -1;
  4704. }
  4705.  
  4706. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4707. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4708. return -1;
  4709. }
  4710.  
  4711. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4712. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4713. return -1;
  4714. }
  4715.  
  4716. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4717.  
  4718. if(jailtime==0) {
  4719. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4720. return -1;
  4721. }
  4722.  
  4723. //Added by Coltaro
  4724. if(pl_sd->sc.data[SC_JAILED] &&
  4725. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4726. { //Update the player's jail time
  4727. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4728. if (jailtime <= 0) {
  4729. jailtime = 0;
  4730. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4731. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4732. } else {
  4733. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4734. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1137),year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  4735. clif_displaymessage(pl_sd->fd, atcmd_output);
  4736. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1138),year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  4737. clif_displaymessage(fd, atcmd_output);
  4738. }
  4739. } else if (jailtime < 0) {
  4740. clif_displaymessage(fd, msg_txt(sd,1136));
  4741. return -1;
  4742. }
  4743.  
  4744. //Jail locations, add more as you wish.
  4745. switch(rnd()%2)
  4746. {
  4747. case 1: //Jail #1
  4748. m_index = mapindex_name2id(MAP_JAIL);
  4749. x = 49; y = 75;
  4750. break;
  4751. default: //Default Jail
  4752. m_index = mapindex_name2id(MAP_JAIL);
  4753. x = 24; y = 75;
  4754. break;
  4755. }
  4756.  
  4757. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
  4758. return 0;
  4759. }
  4760.  
  4761.  
  4762. //By Coltaro
  4763. ACMD_FUNC(jailtime)
  4764. {
  4765. int year, month, day, hour, minute;
  4766.  
  4767. nullpo_retr(-1, sd);
  4768.  
  4769. if (!sd->sc.data[SC_JAILED]) {
  4770. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4771. return -1;
  4772. }
  4773.  
  4774. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4775. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4776. return 0;
  4777. }
  4778.  
  4779. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4780. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4781. return -1;
  4782. }
  4783.  
  4784. //Get remaining jail time
  4785. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4786. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4787.  
  4788. clif_displaymessage(fd, atcmd_output);
  4789.  
  4790. return 0;
  4791. }
  4792.  
  4793. /*==========================================
  4794. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4795. *------------------------------------------*/
  4796. ACMD_FUNC(disguise)
  4797. {
  4798. int id = 0;
  4799. nullpo_retr(-1, sd);
  4800.  
  4801. if (!message || !*message) {
  4802. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4803. return -1;
  4804. }
  4805.  
  4806. if ((id = atoi(message)) > 0)
  4807. { //Acquired an ID
  4808. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4809. id = 0; //Invalid id for either mobs or npcs.
  4810. } else { //Acquired a Name
  4811. if ((id = mobdb_searchname(message)) == 0)
  4812. {
  4813. struct npc_data* nd = npc_name2id(message);
  4814. if (nd != NULL)
  4815. id = nd->class_;
  4816. }
  4817. }
  4818.  
  4819. if (id == 0)
  4820. {
  4821. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4822. return -1;
  4823. }
  4824.  
  4825. if(pc_isriding(sd))
  4826. {
  4827. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4828. return -1;
  4829. }
  4830.  
  4831. pc_disguise(sd, id);
  4832. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4833.  
  4834. return 0;
  4835. }
  4836.  
  4837. /*==========================================
  4838. * DisguiseAll
  4839. *------------------------------------------*/
  4840. ACMD_FUNC(disguiseall)
  4841. {
  4842. int mob_id=0;
  4843. struct map_session_data *pl_sd;
  4844. struct s_mapiterator* iter;
  4845. nullpo_retr(-1, sd);
  4846.  
  4847. if (!message || !*message) {
  4848. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4849. return -1;
  4850. }
  4851.  
  4852. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4853. mob_id = atoi(message);
  4854.  
  4855. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4856. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4857. return -1;
  4858. }
  4859.  
  4860. iter = mapit_getallusers();
  4861. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4862. pc_disguise(pl_sd, mob_id);
  4863. mapit_free(iter);
  4864.  
  4865. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4866. return 0;
  4867. }
  4868.  
  4869. /*==========================================
  4870. * DisguiseGuild
  4871. *------------------------------------------*/
  4872. ACMD_FUNC(disguiseguild)
  4873. {
  4874. int id = 0, i;
  4875. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4876. struct map_session_data *pl_sd;
  4877. struct guild *g;
  4878.  
  4879. memset(monster, '\0', sizeof(monster));
  4880. memset(guild, '\0', sizeof(guild));
  4881.  
  4882. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4883. clif_displaymessage(fd, msg_txt(sd,1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>).
  4884. return -1;
  4885. }
  4886.  
  4887. if( (id = atoi(monster)) > 0 ) {
  4888. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4889. id = 0;
  4890. } else {
  4891. if( (id = mobdb_searchname(monster)) == 0 ) {
  4892. struct npc_data* nd = npc_name2id(monster);
  4893. if( nd != NULL )
  4894. id = nd->class_;
  4895. }
  4896. }
  4897.  
  4898. if( id == 0 ) {
  4899. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4900. return -1;
  4901. }
  4902.  
  4903. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4904. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4905. return -1;
  4906. }
  4907.  
  4908. for( i = 0; i < g->max_member; i++ )
  4909. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4910. pc_disguise(pl_sd, id);
  4911.  
  4912. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4913. return 0;
  4914. }
  4915.  
  4916.  
  4917. /*==========================================
  4918. * @undisguise by [Yor]
  4919. *------------------------------------------*/
  4920. ACMD_FUNC(undisguise)
  4921. {
  4922. nullpo_retr(-1, sd);
  4923. if (sd->disguise) {
  4924. pc_disguise(sd, 0);
  4925. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4926. } else {
  4927. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4928. return -1;
  4929. }
  4930.  
  4931. return 0;
  4932. }
  4933.  
  4934. /*==========================================
  4935. * UndisguiseAll
  4936. *------------------------------------------*/
  4937. ACMD_FUNC(undisguiseall)
  4938. {
  4939. struct map_session_data *pl_sd;
  4940. struct s_mapiterator* iter;
  4941. nullpo_retr(-1, sd);
  4942.  
  4943. iter = mapit_getallusers();
  4944. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4945. if( pl_sd->disguise )
  4946. pc_disguise(pl_sd, 0);
  4947. mapit_free(iter);
  4948.  
  4949. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4950.  
  4951. return 0;
  4952. }
  4953.  
  4954. /*==========================================
  4955. * UndisguiseGuild
  4956. *------------------------------------------*/
  4957. ACMD_FUNC(undisguiseguild)
  4958. {
  4959. char guild_name[NAME_LENGTH];
  4960. struct map_session_data *pl_sd;
  4961. struct guild *g;
  4962. int i;
  4963. nullpo_retr(-1, sd);
  4964.  
  4965. memset(guild_name, '\0', sizeof(guild_name));
  4966.  
  4967. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4968. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4969. return -1;
  4970. }
  4971.  
  4972. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4973. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4974. return -1;
  4975. }
  4976.  
  4977. for(i = 0; i < g->max_member; i++)
  4978. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4979. pc_disguise(pl_sd, 0);
  4980.  
  4981. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4982.  
  4983. return 0;
  4984. }
  4985.  
  4986. /*==========================================
  4987. * @exp by [Skotlex]
  4988. *------------------------------------------*/
  4989. ACMD_FUNC(exp)
  4990. {
  4991. char output[CHAT_SIZE_MAX];
  4992. double nextb, nextj;
  4993. nullpo_retr(-1, sd);
  4994. memset(output, '\0', sizeof(output));
  4995.  
  4996. nextb = pc_nextbaseexp(sd);
  4997. if (nextb)
  4998. nextb = sd->status.base_exp*100.0/nextb;
  4999.  
  5000. nextj = pc_nextjobexp(sd);
  5001. if (nextj)
  5002. nextj = sd->status.job_exp*100.0/nextj;
  5003.  
  5004. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  5005. clif_displaymessage(fd, output);
  5006. return 0;
  5007. }
  5008.  
  5009.  
  5010. /*==========================================
  5011. * @broadcast by [Valaris]
  5012. *------------------------------------------*/
  5013. ACMD_FUNC(broadcast)
  5014. {
  5015. nullpo_retr(-1, sd);
  5016.  
  5017. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5018.  
  5019. if (!message || !*message) {
  5020. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  5021. return -1;
  5022. }
  5023.  
  5024. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  5025. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  5026.  
  5027. return 0;
  5028. }
  5029.  
  5030. /*==========================================
  5031. * @localbroadcast by [Valaris]
  5032. *------------------------------------------*/
  5033. ACMD_FUNC(localbroadcast)
  5034. {
  5035. nullpo_retr(-1, sd);
  5036.  
  5037. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5038.  
  5039. if (!message || !*message) {
  5040. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  5041. return -1;
  5042. }
  5043.  
  5044. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  5045.  
  5046. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  5047.  
  5048. return 0;
  5049. }
  5050.  
  5051. /*==========================================
  5052. * @email <actual@email> <new@email> by [Yor]
  5053. *------------------------------------------*/
  5054. ACMD_FUNC(email)
  5055. {
  5056. char actual_email[100];
  5057. char new_email[100];
  5058. nullpo_retr(-1, sd);
  5059.  
  5060. memset(actual_email, '\0', sizeof(actual_email));
  5061. memset(new_email, '\0', sizeof(new_email));
  5062.  
  5063. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5064. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  5065. return -1;
  5066. }
  5067.  
  5068. if (e_mail_check(actual_email) == 0) {
  5069. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  5070. return -1;
  5071. } else if (e_mail_check(new_email) == 0) {
  5072. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  5073. return -1;
  5074. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5075. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  5076. return -1;
  5077. } else if (strcmpi(actual_email, new_email) == 0) {
  5078. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  5079. return -1;
  5080. }
  5081.  
  5082. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5083. clif_displaymessage(fd, msg_txt(sd,148)); // Information sended to login-server via char-server.
  5084. return 0;
  5085. }
  5086.  
  5087. /*==========================================
  5088. *@effect
  5089. *------------------------------------------*/
  5090. ACMD_FUNC(effect)
  5091. {
  5092. int type = 0, flag = 0;
  5093. nullpo_retr(-1, sd);
  5094.  
  5095. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  5096. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  5097. return -1;
  5098. }
  5099.  
  5100. clif_specialeffect(&sd->bl, type, (send_target)flag);
  5101. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  5102. return 0;
  5103. }
  5104.  
  5105. /*==========================================
  5106. * @killer by MouseJstr
  5107. * enable killing players even when not in pvp
  5108. *------------------------------------------*/
  5109. ACMD_FUNC(killer)
  5110. {
  5111. nullpo_retr(-1, sd);
  5112. sd->state.killer = !sd->state.killer;
  5113.  
  5114. if(sd->state.killer)
  5115. clif_displaymessage(fd, msg_txt(sd,241));
  5116. else {
  5117. clif_displaymessage(fd, msg_txt(sd,292));
  5118. pc_stop_attack(sd);
  5119. }
  5120. return 0;
  5121. }
  5122.  
  5123. /*==========================================
  5124. * @killable by MouseJstr
  5125. * enable other people killing you
  5126. *------------------------------------------*/
  5127. ACMD_FUNC(killable)
  5128. {
  5129. nullpo_retr(-1, sd);
  5130. sd->state.killable = !sd->state.killable;
  5131.  
  5132. if(sd->state.killable)
  5133. clif_displaymessage(fd, msg_txt(sd,242));
  5134. else {
  5135. clif_displaymessage(fd, msg_txt(sd,288));
  5136. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  5137. }
  5138. return 0;
  5139. }
  5140.  
  5141. /*==========================================
  5142. * @skillon by MouseJstr
  5143. * turn skills on for the map
  5144. *------------------------------------------*/
  5145. ACMD_FUNC(skillon)
  5146. {
  5147. nullpo_retr(-1, sd);
  5148. map[sd->bl.m].flag.noskill = 0;
  5149. clif_displaymessage(fd, msg_txt(sd,244));
  5150. return 0;
  5151. }
  5152.  
  5153. /*==========================================
  5154. * @skilloff by MouseJstr
  5155. * Turn skills off on the map
  5156. *------------------------------------------*/
  5157. ACMD_FUNC(skilloff)
  5158. {
  5159. nullpo_retr(-1, sd);
  5160. map[sd->bl.m].flag.noskill = 1;
  5161. clif_displaymessage(fd, msg_txt(sd,243));
  5162. return 0;
  5163. }
  5164.  
  5165. /*==========================================
  5166. * @npcmove by MouseJstr
  5167. * move a npc
  5168. *------------------------------------------*/
  5169. ACMD_FUNC(npcmove)
  5170. {
  5171. int x = 0, y = 0, m;
  5172. struct npc_data *nd = 0;
  5173. nullpo_retr(-1, sd);
  5174. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  5175.  
  5176. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  5177. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  5178. return -1;
  5179. }
  5180.  
  5181. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  5182. {
  5183. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  5184. return -1;
  5185. }
  5186.  
  5187. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  5188. {
  5189. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  5190. return -1; //Not on a map.
  5191. }
  5192.  
  5193. x = cap_value(x, 0, map[m].xs-1);
  5194. y = cap_value(y, 0, map[m].ys-1);
  5195. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  5196. map_moveblock(&nd->bl, x, y, gettick());
  5197. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  5198. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved.
  5199.  
  5200. return 0;
  5201. }
  5202.  
  5203. /*==========================================
  5204. * @addwarp by MouseJstr
  5205. * Create a new static warp point.
  5206. *------------------------------------------*/
  5207. ACMD_FUNC(addwarp)
  5208. {
  5209. char mapname[32], warpname[NAME_LENGTH+1];
  5210. int x,y;
  5211. unsigned short m;
  5212. struct npc_data* nd;
  5213.  
  5214. nullpo_retr(-1, sd);
  5215. memset(warpname, '\0', sizeof(warpname));
  5216.  
  5217. if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
  5218. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  5219. return -1;
  5220. }
  5221.  
  5222. m = mapindex_name2id(mapname);
  5223. if( m == 0 )
  5224. {
  5225. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  5226. clif_displaymessage(fd, atcmd_output);
  5227. return -1;
  5228. }
  5229.  
  5230. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  5231. if( nd == NULL )
  5232. return -1;
  5233.  
  5234. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  5235. clif_displaymessage(fd, atcmd_output);
  5236. return 0;
  5237. }
  5238.  
  5239. /*==========================================
  5240. * @follow by [MouseJstr]
  5241. * Follow a player .. staying no more then 5 spaces away
  5242. *------------------------------------------*/
  5243. ACMD_FUNC(follow)
  5244. {
  5245. struct map_session_data *pl_sd = NULL;
  5246. nullpo_retr(-1, sd);
  5247.  
  5248. if (!message || !*message) {
  5249. if (sd->followtarget == -1)
  5250. return -1;
  5251.  
  5252. pc_stop_following (sd);
  5253. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  5254. return 0;
  5255. }
  5256.  
  5257. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5258. {
  5259. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5260. return -1;
  5261. }
  5262.  
  5263. if (sd->followtarget == pl_sd->bl.id) {
  5264. pc_stop_following (sd);
  5265. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  5266. } else {
  5267. pc_follow(sd, pl_sd->bl.id);
  5268. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  5269. }
  5270.  
  5271. return 0;
  5272. }
  5273.  
  5274.  
  5275. /*==========================================
  5276. * @dropall by [MouseJstr]
  5277. * Drop all your possession on the ground
  5278. *------------------------------------------*/
  5279. ACMD_FUNC(dropall)
  5280. {
  5281. int i;
  5282. nullpo_retr(-1, sd);
  5283. for (i = 0; i < MAX_INVENTORY; i++) {
  5284. if (sd->status.inventory[i].amount) {
  5285. if(sd->status.inventory[i].equip != 0)
  5286. pc_unequipitem(sd, i, 3);
  5287. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  5288. }
  5289. }
  5290. return 0;
  5291. }
  5292.  
  5293. /*==========================================
  5294. * @storeall by [MouseJstr]
  5295. * Put everything into storage
  5296. *------------------------------------------*/
  5297. ACMD_FUNC(storeall)
  5298. {
  5299. int i;
  5300. nullpo_retr(-1, sd);
  5301.  
  5302. if (sd->state.storage_flag != 1)
  5303. { //Open storage.
  5304. if( storage_storageopen(sd) == 1 ) {
  5305. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  5306. return -1;
  5307. }
  5308. }
  5309.  
  5310. for (i = 0; i < MAX_INVENTORY; i++) {
  5311. if (sd->status.inventory[i].amount) {
  5312. if(sd->status.inventory[i].equip != 0)
  5313. pc_unequipitem(sd, i, 3);
  5314. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  5315. }
  5316. }
  5317. storage_storageclose(sd);
  5318.  
  5319. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  5320. return 0;
  5321. }
  5322.  
  5323. ACMD_FUNC(clearstorage)
  5324. {
  5325. int i, j;
  5326. nullpo_retr(-1, sd);
  5327.  
  5328. if (sd->state.storage_flag == 1) {
  5329. clif_displaymessage(fd, msg_txt(sd,250));
  5330. return -1;
  5331. }
  5332.  
  5333. j = sd->status.storage.storage_amount;
  5334. for (i = 0; i < j; ++i) {
  5335. storage_delitem(sd, i, sd->status.storage.items[i].amount);
  5336. }
  5337. storage_storageclose(sd);
  5338.  
  5339. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  5340. return 0;
  5341. }
  5342.  
  5343. ACMD_FUNC(cleargstorage)
  5344. {
  5345. int i, j;
  5346. struct guild *g;
  5347. struct guild_storage *gstorage;
  5348. nullpo_retr(-1, sd);
  5349.  
  5350. g = sd->guild;
  5351.  
  5352. if (g == NULL) {
  5353. clif_displaymessage(fd, msg_txt(sd,43));
  5354. return -1;
  5355. }
  5356.  
  5357. if (sd->state.storage_flag == 1) {
  5358. clif_displaymessage(fd, msg_txt(sd,250));
  5359. return -1;
  5360. }
  5361.  
  5362. if (sd->state.storage_flag == 2) {
  5363. clif_displaymessage(fd, msg_txt(sd,251));
  5364. return -1;
  5365. }
  5366.  
  5367. gstorage = guild2storage2(sd->status.guild_id);
  5368. if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  5369. return -1;
  5370. }
  5371.  
  5372. j = gstorage->storage_amount;
  5373. gstorage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  5374. for (i = 0; i < j; ++i) {
  5375. guild_storage_delitem(sd, gstorage, i, gstorage->items[i].amount);
  5376. }
  5377. storage_guild_storageclose(sd);
  5378. gstorage->lock = 0; // Cleaning done, release lock
  5379.  
  5380. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  5381. return 0;
  5382. }
  5383.  
  5384. ACMD_FUNC(clearcart)
  5385. {
  5386. int i;
  5387. nullpo_retr(-1, sd);
  5388.  
  5389. if (pc_iscarton(sd) == 0) {
  5390. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  5391. return -1;
  5392. }
  5393.  
  5394. if (sd->state.vending == 1) { //Somehow...
  5395. return -1;
  5396. }
  5397.  
  5398. for( i = 0; i < MAX_CART; i++ )
  5399. if(sd->status.cart[i].nameid > 0)
  5400. pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  5401.  
  5402. clif_clearcart(fd);
  5403. clif_updatestatus(sd,SP_CARTINFO);
  5404.  
  5405. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  5406. return 0;
  5407. }
  5408.  
  5409. /*==========================================
  5410. * @skillid by [MouseJstr]
  5411. * lookup a skill by name
  5412. *------------------------------------------*/
  5413. #define MAX_SKILLID_PARTIAL_RESULTS 5
  5414. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  5415. ACMD_FUNC(skillid) {
  5416. int skillen, idx, i, found = 0;
  5417. DBIterator* iter;
  5418. DBKey key;
  5419. DBData *data;
  5420. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  5421.  
  5422. nullpo_retr(-1, sd);
  5423.  
  5424. if (!message || !*message) {
  5425. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  5426. return -1;
  5427. }
  5428.  
  5429. skillen = strlen(message);
  5430.  
  5431. iter = db_iterator(skilldb_name2id);
  5432.  
  5433. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  5434. idx = skill_get_index(db_data2i(data));
  5435. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0) {
  5436. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str); // skill %d: %s (%s)
  5437. clif_displaymessage(fd, atcmd_output);
  5438. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx].desc,message) ) ) {
  5439. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str);
  5440. }
  5441. }
  5442.  
  5443. dbi_destroy(iter);
  5444.  
  5445. if( found ) {
  5446. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  5447. clif_displaymessage(fd, atcmd_output);
  5448. }
  5449.  
  5450. for(i = 0; i < found; i++) { /* partials */
  5451. clif_displaymessage(fd, partials[i]);
  5452. }
  5453.  
  5454. return 0;
  5455. }
  5456.  
  5457. /*==========================================
  5458. * @useskill by [MouseJstr]
  5459. * A way of using skills without having to find them in the skills menu
  5460. *------------------------------------------*/
  5461. ACMD_FUNC(useskill)
  5462. {
  5463. struct map_session_data *pl_sd = NULL;
  5464. struct block_list *bl;
  5465. uint16 skill_id;
  5466. uint16 skill_lv;
  5467. char target[100];
  5468. nullpo_retr(-1, sd);
  5469.  
  5470. if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  5471. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
  5472. return -1;
  5473. }
  5474.  
  5475. if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
  5476. else if ( (pl_sd = map_nick2sd(target)) == NULL ){
  5477. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5478. return -1;
  5479. }
  5480.  
  5481. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5482. {
  5483. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5484. return -1;
  5485. }
  5486.  
  5487. if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL
  5488. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5489. bl = &sd->hd->bl;
  5490. else
  5491. bl = &sd->bl;
  5492.  
  5493. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  5494. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  5495. else
  5496. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  5497.  
  5498. return 0;
  5499. }
  5500.  
  5501. /*==========================================
  5502. * @displayskill by [Skotlex]
  5503. * Debug command to locate new skill IDs. It sends the
  5504. * three possible skill-effect packets to the area.
  5505. *------------------------------------------*/
  5506. ACMD_FUNC(displayskill)
  5507. {
  5508. struct status_data * status;
  5509. unsigned int tick;
  5510. uint16 skill_id;
  5511. uint16 skill_lv = 1;
  5512. nullpo_retr(-1, sd);
  5513.  
  5514. if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1)
  5515. {
  5516. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  5517. return -1;
  5518. }
  5519. status = status_get_status_data(&sd->bl);
  5520. tick = gettick();
  5521. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
  5522. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  5523. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  5524. return 0;
  5525. }
  5526.  
  5527. /*==========================================
  5528. * @skilltree by [MouseJstr]
  5529. * prints the skill tree for a player required to get to a skill
  5530. *------------------------------------------*/
  5531. ACMD_FUNC(skilltree)
  5532. {
  5533. struct map_session_data *pl_sd = NULL;
  5534. uint16 skill_id;
  5535. int meets, j, c=0;
  5536. char target[NAME_LENGTH];
  5537. struct skill_tree_entry *ent;
  5538. nullpo_retr(-1, sd);
  5539.  
  5540. if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) {
  5541. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
  5542. return -1;
  5543. }
  5544.  
  5545. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5546. {
  5547. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5548. return -1;
  5549. }
  5550.  
  5551. c = pc_calc_skilltree_normalize_job(pl_sd);
  5552. c = pc_mapid2jobid(c, pl_sd->status.sex);
  5553.  
  5554. sprintf(atcmd_output, msg_txt(sd,1168), job_name(c), pc_checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
  5555. clif_displaymessage(fd, atcmd_output);
  5556.  
  5557. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
  5558. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  5559. {
  5560. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  5561. return 0;
  5562. }
  5563.  
  5564. ent = &skill_tree[c][j];
  5565.  
  5566. meets = 1;
  5567. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  5568. {
  5569. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  5570. {
  5571. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].lv, skill_db[ent->need[j].id].desc); // Player requires level %d of skill %s.
  5572. clif_displaymessage(fd, atcmd_output);
  5573. meets = 0;
  5574. }
  5575. }
  5576. if (meets == 1) {
  5577. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  5578. }
  5579.  
  5580. return 0;
  5581. }
  5582.  
  5583. // Hand a ring with partners name on it to this char
  5584. void getring (struct map_session_data* sd)
  5585. {
  5586. int flag, item_id;
  5587. struct item item_tmp;
  5588. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5589.  
  5590. memset(&item_tmp, 0, sizeof(item_tmp));
  5591. item_tmp.nameid = item_id;
  5592. item_tmp.identify = 1;
  5593. item_tmp.card[0] = 255;
  5594. item_tmp.card[2] = sd->status.partner_id;
  5595. item_tmp.card[3] = sd->status.partner_id >> 16;
  5596.  
  5597. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5598. clif_additem(sd,0,0,flag);
  5599. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4);
  5600. }
  5601. }
  5602.  
  5603. /*==========================================
  5604. * @marry by [MouseJstr], fixed by Lupus
  5605. * Marry two players
  5606. *------------------------------------------*/
  5607. ACMD_FUNC(marry)
  5608. {
  5609. struct map_session_data *pl_sd = NULL;
  5610. char player_name[NAME_LENGTH] = "";
  5611.  
  5612. nullpo_retr(-1, sd);
  5613.  
  5614. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  5615. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5616. return -1;
  5617. }
  5618.  
  5619. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  5620. clif_displaymessage(fd, msg_txt(sd,3));
  5621. return -1;
  5622. }
  5623.  
  5624. if (pc_marriage(sd, pl_sd) == 0) {
  5625. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5626. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5627. getring(sd); // Auto-give named rings (Aru)
  5628. getring(pl_sd);
  5629. return 0;
  5630. }
  5631.  
  5632. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5633. return -1;
  5634. }
  5635.  
  5636. /*==========================================
  5637. * @divorce by [MouseJstr], fixed by [Lupus]
  5638. * divorce two players
  5639. *------------------------------------------*/
  5640. ACMD_FUNC(divorce)
  5641. {
  5642. nullpo_retr(-1, sd);
  5643.  
  5644. if (pc_divorce(sd) != 0) {
  5645. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5646. clif_displaymessage(fd, atcmd_output);
  5647. return -1;
  5648. }
  5649.  
  5650. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5651. clif_displaymessage(fd, atcmd_output);
  5652. return 0;
  5653. }
  5654.  
  5655. /*==========================================
  5656. * @changelook by [Celest]
  5657. *------------------------------------------*/
  5658. ACMD_FUNC(changelook)
  5659. {
  5660. int i, j = 0, k = 0;
  5661. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  5662.  
  5663. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5664. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5665. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  5666. return -1;
  5667. } else if ( i == 2 ) {
  5668. if (j < 1 || j > 7)
  5669. j = 1;
  5670. j = pos[j - 1];
  5671. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5672. k = j; // swap
  5673. j = LOOK_HEAD_TOP;
  5674. }
  5675.  
  5676. clif_changelook(&sd->bl,j,k);
  5677.  
  5678. return 0;
  5679. }
  5680.  
  5681. /*==========================================
  5682. * @autotrade by durf [Lupus] [Paradox924X]
  5683. * Turns on/off Autotrade for a specific player
  5684. *------------------------------------------*/
  5685. ACMD_FUNC(autotrade) {
  5686. nullpo_retr(-1, sd);
  5687.  
  5688. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  5689. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5690. return -1;
  5691. }
  5692.  
  5693. if( pc_isdead(sd) ) {
  5694. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5695. return -1;
  5696. }
  5697.  
  5698. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5699. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5700. return -1;
  5701. }
  5702.  
  5703. sd->state.autotrade = 1;
  5704. if( battle_config.at_timeout ) {
  5705. int timeout = atoi(message);
  5706. status_change_start(NULL,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  5707. }
  5708.  
  5709. channel_pcquit(sd,0xF); //leave all chan
  5710. clif_authfail_fd(sd->fd, 15);
  5711.  
  5712. return 0;
  5713. }
  5714.  
  5715. /*==========================================
  5716. * @changegm by durf (changed by Lupus)
  5717. * Changes Master of your Guild to a specified guild member
  5718. *------------------------------------------*/
  5719. ACMD_FUNC(changegm)
  5720. {
  5721. struct guild *g;
  5722. struct map_session_data *pl_sd;
  5723. nullpo_retr(-1, sd);
  5724.  
  5725. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  5726. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5727. return -1;
  5728. }
  5729.  
  5730. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  5731. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5732. return -1;
  5733. }
  5734.  
  5735. if( !message[0] ) {
  5736. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5737. return -1;
  5738. }
  5739.  
  5740. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5741. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5742. return -1;
  5743. }
  5744.  
  5745. guild_gm_change(sd->status.guild_id, pl_sd);
  5746. return 0;
  5747. }
  5748.  
  5749. /*==========================================
  5750. * @changeleader by Skotlex
  5751. * Changes the leader of a party.
  5752. *------------------------------------------*/
  5753. ACMD_FUNC(changeleader)
  5754. {
  5755. nullpo_retr(-1, sd);
  5756.  
  5757. if( !message[0] )
  5758. {
  5759. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5760. return -1;
  5761. }
  5762.  
  5763. if (party_changeleader(sd, map_nick2sd((char *) message),NULL))
  5764. return 0;
  5765. return -1;
  5766. }
  5767.  
  5768. /*==========================================
  5769. * @partyoption by Skotlex
  5770. * Used to change the item share setting of a party.
  5771. *------------------------------------------*/
  5772. ACMD_FUNC(partyoption)
  5773. {
  5774. struct party_data *p;
  5775. int mi, option;
  5776. char w1[16], w2[16];
  5777. nullpo_retr(-1, sd);
  5778.  
  5779. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5780. {
  5781. clif_displaymessage(fd, msg_txt(sd,282));
  5782. return -1;
  5783. }
  5784.  
  5785. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5786. if (mi == MAX_PARTY)
  5787. return -1; //Shouldn't happen
  5788.  
  5789. if (!p->party.member[mi].leader)
  5790. {
  5791. clif_displaymessage(fd, msg_txt(sd,282));
  5792. return -1;
  5793. }
  5794.  
  5795. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5796. {
  5797. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5798. return -1;
  5799. }
  5800.  
  5801. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5802.  
  5803. //Change item share type.
  5804. if (option != p->party.item)
  5805. party_changeoption(sd, p->party.exp, option);
  5806. else
  5807. clif_displaymessage(fd, msg_txt(sd,286));
  5808.  
  5809. return 0;
  5810. }
  5811.  
  5812. /*==========================================
  5813. * @autoloot by Upa-Kun
  5814. * Turns on/off AutoLoot for a specific player
  5815. *------------------------------------------*/
  5816. ACMD_FUNC(autoloot)
  5817. {
  5818. int rate;
  5819. nullpo_retr(-1, sd);
  5820. // autoloot command without value
  5821. if(!message || !*message)
  5822. {
  5823. if (sd->state.autoloot)
  5824. rate = 0;
  5825. else
  5826. rate = 10000;
  5827. } else {
  5828. double drate;
  5829. drate = atof(message);
  5830. rate = (int)(drate*100);
  5831. }
  5832. if (rate < 0) rate = 0;
  5833. if (rate > 10000) rate = 10000;
  5834.  
  5835. sd->state.autoloot = rate;
  5836. if (sd->state.autoloot) {
  5837. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below.
  5838. clif_displaymessage(fd, atcmd_output);
  5839. }else
  5840. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5841.  
  5842. return 0;
  5843. }
  5844.  
  5845. /*==========================================
  5846. * @alootid
  5847. *------------------------------------------*/
  5848. ACMD_FUNC(autolootitem)
  5849. {
  5850. struct item_data *item_data = NULL;
  5851. int i;
  5852. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5853.  
  5854. if (message && *message) {
  5855. if (message[0] == '+') {
  5856. message++;
  5857. action = 1;
  5858. }
  5859. else if (message[0] == '-') {
  5860. message++;
  5861. action = 2;
  5862. }
  5863. else if (!strcmp(message,"reset"))
  5864. action = 4;
  5865. }
  5866.  
  5867. if (action < 3) // add or remove
  5868. {
  5869. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5870. item_data = itemdb_searchname(message);
  5871. if (!item_data) {
  5872. // No items founds in the DB with Id or Name
  5873. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5874. return -1;
  5875. }
  5876. }
  5877.  
  5878. switch(action) {
  5879. case 1:
  5880. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5881. if (i != AUTOLOOTITEM_SIZE) {
  5882. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5883. return -1;
  5884. }
  5885. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5886. if (i == AUTOLOOTITEM_SIZE) {
  5887. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5888. return -1;
  5889. }
  5890. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5891. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5892. clif_displaymessage(fd, atcmd_output);
  5893. sd->state.autolooting = 1;
  5894. break;
  5895. case 2:
  5896. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5897. if (i == AUTOLOOTITEM_SIZE) {
  5898. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5899. return -1;
  5900. }
  5901. sd->state.autolootid[i] = 0;
  5902. sprintf(atcmd_output, msg_txt(sd,1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
  5903. clif_displaymessage(fd, atcmd_output);
  5904. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5905. if (i == AUTOLOOTITEM_SIZE) {
  5906. sd->state.autolooting = 0;
  5907. }
  5908. break;
  5909. case 3:
  5910. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5911. clif_displaymessage(fd, atcmd_output);
  5912. clif_displaymessage(fd, msg_txt(sd,1196)); // To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
  5913. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5914. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5915. if (i == AUTOLOOTITEM_SIZE) {
  5916. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5917. } else {
  5918. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5919. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5920. {
  5921. if (sd->state.autolootid[i] == 0)
  5922. continue;
  5923. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5924. ShowDebug("Non-existant item %d on autolootitem list (account_id: %d, char_id: %d)", sd->state.autolootid[i], sd->status.account_id, sd->status.char_id);
  5925. continue;
  5926. }
  5927. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5928. clif_displaymessage(fd, atcmd_output);
  5929. }
  5930. }
  5931. break;
  5932. case 4:
  5933. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5934. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5935. sd->state.autolooting = 0;
  5936. break;
  5937. }
  5938. return 0;
  5939. }
  5940. /**
  5941. * No longer available, keeping here just in case it's back someday. [Ind]
  5942. **/
  5943. /*==========================================
  5944. * It is made to rain.
  5945. *------------------------------------------*/
  5946. //ACMD_FUNC(rain)
  5947. //{
  5948. // nullpo_retr(-1, sd);
  5949. // if (map[sd->bl.m].flag.rain) {
  5950. // map[sd->bl.m].flag.rain=0;
  5951. // clif_weather(sd->bl.m);
  5952. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5953. // } else {
  5954. // map[sd->bl.m].flag.rain=1;
  5955. // clif_weather(sd->bl.m);
  5956. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5957. // }
  5958. // return 0;
  5959. //}
  5960.  
  5961. /*==========================================
  5962. * It is made to snow.
  5963. *------------------------------------------*/
  5964. ACMD_FUNC(snow)
  5965. {
  5966. nullpo_retr(-1, sd);
  5967. if (map[sd->bl.m].flag.snow) {
  5968. map[sd->bl.m].flag.snow=0;
  5969. clif_weather(sd->bl.m);
  5970. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5971. } else {
  5972. map[sd->bl.m].flag.snow=1;
  5973. clif_weather(sd->bl.m);
  5974. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5975. }
  5976.  
  5977. return 0;
  5978. }
  5979.  
  5980. /*==========================================
  5981. * Cherry tree snowstorm is made to fall. (Sakura)
  5982. *------------------------------------------*/
  5983. ACMD_FUNC(sakura)
  5984. {
  5985. nullpo_retr(-1, sd);
  5986. if (map[sd->bl.m].flag.sakura) {
  5987. map[sd->bl.m].flag.sakura=0;
  5988. clif_weather(sd->bl.m);
  5989. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5990. } else {
  5991. map[sd->bl.m].flag.sakura=1;
  5992. clif_weather(sd->bl.m);
  5993. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5994. }
  5995. return 0;
  5996. }
  5997.  
  5998. /*==========================================
  5999. * Clouds appear.
  6000. *------------------------------------------*/
  6001. ACMD_FUNC(clouds)
  6002. {
  6003. nullpo_retr(-1, sd);
  6004. if (map[sd->bl.m].flag.clouds) {
  6005. map[sd->bl.m].flag.clouds=0;
  6006. clif_weather(sd->bl.m);
  6007. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  6008. } else {
  6009. map[sd->bl.m].flag.clouds=1;
  6010. clif_weather(sd->bl.m);
  6011. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  6012. }
  6013.  
  6014. return 0;
  6015. }
  6016.  
  6017. /*==========================================
  6018. * Different type of clouds using effect 516
  6019. *------------------------------------------*/
  6020. ACMD_FUNC(clouds2)
  6021. {
  6022. nullpo_retr(-1, sd);
  6023. if (map[sd->bl.m].flag.clouds2) {
  6024. map[sd->bl.m].flag.clouds2=0;
  6025. clif_weather(sd->bl.m);
  6026. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  6027. } else {
  6028. map[sd->bl.m].flag.clouds2=1;
  6029. clif_weather(sd->bl.m);
  6030. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  6031. }
  6032.  
  6033. return 0;
  6034. }
  6035.  
  6036. /*==========================================
  6037. * Fog hangs over.
  6038. *------------------------------------------*/
  6039. ACMD_FUNC(fog)
  6040. {
  6041. nullpo_retr(-1, sd);
  6042. if (map[sd->bl.m].flag.fog) {
  6043. map[sd->bl.m].flag.fog=0;
  6044. clif_weather(sd->bl.m);
  6045. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  6046. } else {
  6047. map[sd->bl.m].flag.fog=1;
  6048. clif_weather(sd->bl.m);
  6049. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  6050. }
  6051. return 0;
  6052. }
  6053.  
  6054. /*==========================================
  6055. * Fallen leaves fall.
  6056. *------------------------------------------*/
  6057. ACMD_FUNC(leaves)
  6058. {
  6059. nullpo_retr(-1, sd);
  6060. if (map[sd->bl.m].flag.leaves) {
  6061. map[sd->bl.m].flag.leaves=0;
  6062. clif_weather(sd->bl.m);
  6063. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  6064. } else {
  6065. map[sd->bl.m].flag.leaves=1;
  6066. clif_weather(sd->bl.m);
  6067. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  6068. }
  6069.  
  6070. return 0;
  6071. }
  6072.  
  6073. /*==========================================
  6074. * Fireworks appear.
  6075. *------------------------------------------*/
  6076. ACMD_FUNC(fireworks)
  6077. {
  6078. nullpo_retr(-1, sd);
  6079. if (map[sd->bl.m].flag.fireworks) {
  6080. map[sd->bl.m].flag.fireworks=0;
  6081. clif_weather(sd->bl.m);
  6082. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  6083. } else {
  6084. map[sd->bl.m].flag.fireworks=1;
  6085. clif_weather(sd->bl.m);
  6086. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  6087. }
  6088.  
  6089. return 0;
  6090. }
  6091.  
  6092. /*==========================================
  6093. * Clearing Weather Effects by Dexity
  6094. *------------------------------------------*/
  6095. ACMD_FUNC(clearweather)
  6096. {
  6097. nullpo_retr(-1, sd);
  6098. /**
  6099. * No longer available, keeping here just in case it's back someday. [Ind]
  6100. **/
  6101. //map[sd->bl.m].flag.rain=0;
  6102. map[sd->bl.m].flag.snow=0;
  6103. map[sd->bl.m].flag.sakura=0;
  6104. map[sd->bl.m].flag.clouds=0;
  6105. map[sd->bl.m].flag.clouds2=0;
  6106. map[sd->bl.m].flag.fog=0;
  6107. map[sd->bl.m].flag.fireworks=0;
  6108. map[sd->bl.m].flag.leaves=0;
  6109. clif_weather(sd->bl.m);
  6110. clif_displaymessage(fd, msg_txt(sd,291));
  6111.  
  6112. return 0;
  6113. }
  6114.  
  6115. /*===============================================================
  6116. * Sound Command - plays a sound for everyone around! [Codemaster]
  6117. *---------------------------------------------------------------*/
  6118. ACMD_FUNC(sound)
  6119. {
  6120. char sound_file[100];
  6121.  
  6122. memset(sound_file, '\0', sizeof(sound_file));
  6123.  
  6124. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6125. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  6126. return -1;
  6127. }
  6128.  
  6129. if(strstr(sound_file, ".wav") == NULL)
  6130. strcat(sound_file, ".wav");
  6131.  
  6132. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  6133.  
  6134. return 0;
  6135. }
  6136.  
  6137. /*==========================================
  6138. * MOB Search
  6139. *------------------------------------------*/
  6140. ACMD_FUNC(mobsearch)
  6141. {
  6142. char mob_name[100];
  6143. int mob_id;
  6144. int number = 0;
  6145. struct s_mapiterator* it;
  6146.  
  6147. nullpo_retr(-1, sd);
  6148.  
  6149. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  6150. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  6151. return -1;
  6152. }
  6153.  
  6154. if ((mob_id = atoi(mob_name)) == 0)
  6155. mob_id = mobdb_searchname(mob_name);
  6156. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6157. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  6158. clif_displaymessage(fd, atcmd_output);
  6159. return -1;
  6160. }
  6161. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6162. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6163. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6164.  
  6165. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  6166. clif_displaymessage(fd, atcmd_output);
  6167.  
  6168. it = mapit_geteachmob();
  6169. for(;;)
  6170. {
  6171. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6172. if( md == NULL )
  6173. break;// no more mobs
  6174.  
  6175. if( md->bl.m != sd->bl.m )
  6176. continue;
  6177. if( mob_id != -1 && md->class_ != mob_id )
  6178. continue;
  6179.  
  6180. ++number;
  6181. if( md->spawn_timer == INVALID_TIMER )
  6182. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  6183. else
  6184. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  6185. clif_displaymessage(fd, atcmd_output);
  6186. }
  6187. mapit_free(it);
  6188.  
  6189. return 0;
  6190. }
  6191.  
  6192. /*==========================================
  6193. * @cleanmap - cleans items on the ground
  6194. * @cleanarea - cleans items on the ground within an specified area
  6195. *------------------------------------------*/
  6196. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  6197. {
  6198. nullpo_ret(bl);
  6199. map_clearflooritem(bl);
  6200.  
  6201. return 0;
  6202. }
  6203.  
  6204. ACMD_FUNC(cleanmap)
  6205. {
  6206. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  6207. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  6208. return 0;
  6209. }
  6210.  
  6211. ACMD_FUNC(cleanarea)
  6212. {
  6213. int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  6214.  
  6215. if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
  6216. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - (AREA_SIZE * 2), sd->bl.y - (AREA_SIZE * 2), sd->bl.x + (AREA_SIZE * 2), sd->bl.y + (AREA_SIZE * 2), BL_ITEM);
  6217. }
  6218. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) {
  6219. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - x0, sd->bl.y - x0, sd->bl.x + x0, sd->bl.y + x0, BL_ITEM);
  6220. }
  6221. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
  6222. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  6223. }
  6224.  
  6225. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  6226. return 0;
  6227. }
  6228.  
  6229. /*==========================================
  6230. * make a NPC/PET talk
  6231. * @npctalkc [SnakeDrak]
  6232. *------------------------------------------*/
  6233. ACMD_FUNC(npctalk)
  6234. {
  6235. char name[NAME_LENGTH],mes[100],temp[100];
  6236. struct npc_data *nd;
  6237. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  6238. unsigned long color=0;
  6239.  
  6240. if (sd->sc.cant.chat)
  6241. return -1; //no "chatting" while muted.
  6242.  
  6243. if(!ifcolor) {
  6244. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  6245. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  6246. return -1;
  6247. }
  6248. }
  6249. else {
  6250. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  6251. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  6252. return -1;
  6253. }
  6254. }
  6255.  
  6256. if (!(nd = npc_name2id(name))) {
  6257. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  6258. return -1;
  6259. }
  6260.  
  6261. strtok(name, "#"); // discard extra name identifier if present
  6262. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  6263.  
  6264. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  6265. else clif_disp_overhead(&nd->bl, temp);
  6266.  
  6267. return 0;
  6268. }
  6269.  
  6270. ACMD_FUNC(pettalk)
  6271. {
  6272. char mes[100],temp[100];
  6273. struct pet_data *pd;
  6274.  
  6275. nullpo_retr(-1, sd);
  6276.  
  6277. if ( battle_config.min_chat_delay ) {
  6278. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6279. return 0;
  6280. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6281. }
  6282.  
  6283. if(!sd->status.pet_id || !(pd=sd->pd))
  6284. {
  6285. clif_displaymessage(fd, msg_txt(sd,184));
  6286. return -1;
  6287. }
  6288.  
  6289. if (sd->sc.cant.chat)
  6290. return -1; //no "chatting" while muted.
  6291.  
  6292. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6293. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  6294. return -1;
  6295. }
  6296.  
  6297. if (message[0] == '/')
  6298. {// pet emotion processing
  6299. const char* emo[] = {
  6300. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  6301. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  6302. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  6303. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  6304. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  6305. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  6306. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  6307. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  6308. "/whisp"
  6309. };
  6310. int i;
  6311. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  6312. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  6313. if( i < ARRAYLENGTH(emo) )
  6314. {
  6315. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  6316. sd->emotionlasttime = time(NULL);
  6317. return 0;
  6318. }
  6319. sd->emotionlasttime = time(NULL);
  6320.  
  6321. clif_emotion(&pd->bl, i);
  6322. return 0;
  6323. }
  6324. }
  6325.  
  6326. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  6327. clif_disp_overhead(&pd->bl, temp);
  6328.  
  6329. return 0;
  6330. }
  6331.  
  6332. /// @users - displays the number of players present on each map (and percentage)
  6333. /// #users displays on the target user instead of self
  6334. ACMD_FUNC(users)
  6335. {
  6336. char buf[CHAT_SIZE_MAX];
  6337. int i;
  6338. int users[MAX_MAPINDEX];
  6339. int users_all;
  6340. struct s_mapiterator* iter;
  6341.  
  6342. memset(users, 0, sizeof(users));
  6343. users_all = 0;
  6344.  
  6345. // count users on each map
  6346. iter = mapit_getallusers();
  6347. for(;;)
  6348. {
  6349. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  6350. if( sd2 == NULL )
  6351. break;// no more users
  6352.  
  6353. if( sd2->mapindex >= MAX_MAPINDEX )
  6354. continue;// invalid mapindex
  6355.  
  6356. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  6357. if( users_all < INT_MAX ) ++users_all;
  6358. }
  6359. mapit_free(iter);
  6360.  
  6361. // display results for each map
  6362. for( i = 0; i < MAX_MAPINDEX; ++i )
  6363. {
  6364. if( users[i] == 0 )
  6365. continue;// empty
  6366.  
  6367. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  6368. clif_displaymessage(sd->fd, buf);
  6369. }
  6370.  
  6371. // display overall count
  6372. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  6373. clif_displaymessage(sd->fd, buf);
  6374.  
  6375. return 0;
  6376. }
  6377.  
  6378. /*==========================================
  6379. *
  6380. *------------------------------------------*/
  6381. ACMD_FUNC(reset)
  6382. {
  6383. pc_resetstate(sd);
  6384. pc_resetskill(sd,1);
  6385. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  6386. clif_displaymessage(fd, atcmd_output);
  6387. return 0;
  6388. }
  6389.  
  6390. /*==========================================
  6391. *
  6392. *------------------------------------------*/
  6393. ACMD_FUNC(summon)
  6394. {
  6395. char name[NAME_LENGTH];
  6396. int mob_id = 0;
  6397. int duration = 0;
  6398. struct mob_data *md;
  6399. unsigned int tick=gettick();
  6400.  
  6401. nullpo_retr(-1, sd);
  6402.  
  6403. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  6404. {
  6405. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  6406. return -1;
  6407. }
  6408.  
  6409. if (duration < 1)
  6410. duration =1;
  6411. else if (duration > 60)
  6412. duration =60;
  6413.  
  6414. if ((mob_id = atoi(name)) == 0)
  6415. mob_id = mobdb_searchname(name);
  6416. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  6417. {
  6418. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6419. return -1;
  6420. }
  6421.  
  6422. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  6423.  
  6424. if(!md)
  6425. return -1;
  6426.  
  6427. md->master_id=sd->bl.id;
  6428. md->special_state.ai=AI_ATTACK;
  6429. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  6430. clif_specialeffect(&md->bl,344,AREA);
  6431. mob_spawn(md);
  6432. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  6433. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  6434. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  6435.  
  6436. return 0;
  6437. }
  6438.  
  6439. /*==========================================
  6440. * @adjgroup
  6441. * Temporarily move player to another group
  6442. * Useful during beta testing to allow players to use GM commands for short periods of time
  6443. *------------------------------------------*/
  6444. ACMD_FUNC(adjgroup)
  6445. {
  6446. int new_group = 0;
  6447. nullpo_retr(-1, sd);
  6448.  
  6449. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  6450. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  6451. return -1;
  6452. }
  6453.  
  6454. if (!pc_group_exists(new_group)) {
  6455. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  6456. return -1;
  6457. }
  6458.  
  6459. sd->group_id = new_group;
  6460. pc_group_pc_load(sd);/* update cache */
  6461. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  6462. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  6463. return 0;
  6464. }
  6465.  
  6466. /*==========================================
  6467. * @trade by [MouseJstr]
  6468. * Open a trade window with a remote player
  6469. *------------------------------------------*/
  6470. ACMD_FUNC(trade)
  6471. {
  6472. struct map_session_data *pl_sd = NULL;
  6473. nullpo_retr(-1, sd);
  6474.  
  6475. if (!message || !*message) {
  6476. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  6477. return -1;
  6478. }
  6479.  
  6480. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  6481. {
  6482. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6483. return -1;
  6484. }
  6485.  
  6486. trade_traderequest(sd, pl_sd);
  6487. return 0;
  6488. }
  6489.  
  6490. /*==========================================
  6491. * @setbattleflag by [MouseJstr]
  6492. * set a battle_config flag without having to reboot
  6493. *------------------------------------------*/
  6494. ACMD_FUNC(setbattleflag)
  6495. {
  6496. char flag[128], value[128];
  6497. nullpo_retr(-1, sd);
  6498.  
  6499. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  6500. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value>
  6501. return -1;
  6502. }
  6503.  
  6504. if (battle_set_value(flag, value) == 0)
  6505. {
  6506. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  6507. return -1;
  6508. }
  6509.  
  6510. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  6511.  
  6512. return 0;
  6513. }
  6514.  
  6515. /*==========================================
  6516. * @unmute [Valaris]
  6517. *------------------------------------------*/
  6518. ACMD_FUNC(unmute)
  6519. {
  6520. struct map_session_data *pl_sd = NULL;
  6521. nullpo_retr(-1, sd);
  6522.  
  6523. if (!message || !*message) {
  6524. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  6525. return -1;
  6526. }
  6527.  
  6528. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  6529. {
  6530. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6531. return -1;
  6532. }
  6533.  
  6534. if(!pl_sd->sc.data[SC_NOCHAT]) {
  6535. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  6536. return -1;
  6537. }
  6538.  
  6539. pl_sd->status.manner = 0;
  6540. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6541. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  6542.  
  6543. return 0;
  6544. }
  6545.  
  6546. /*==========================================
  6547. * @uptime by MC Cameri
  6548. *------------------------------------------*/
  6549. ACMD_FUNC(uptime)
  6550. {
  6551. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  6552. minute = 60, days = 0, hours = 0, minutes = 0;
  6553. nullpo_retr(-1, sd);
  6554.  
  6555. seconds = get_uptime();
  6556. days = seconds/day;
  6557. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6558. hours = seconds/hour;
  6559. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6560. minutes = seconds/minute;
  6561. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6562.  
  6563. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds);
  6564. clif_displaymessage(fd, atcmd_output);
  6565.  
  6566. return 0;
  6567. }
  6568.  
  6569. /*==========================================
  6570. * @changesex <sex>
  6571. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  6572. *------------------------------------------*/
  6573. ACMD_FUNC(changesex)
  6574. {
  6575. int i;
  6576. nullpo_retr(-1, sd);
  6577. pc_resetskill(sd,4);
  6578. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6579. for( i=0; i<EQI_MAX; i++ )
  6580. if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
  6581. chrif_changesex(sd);
  6582. return 0;
  6583. }
  6584.  
  6585. /*================================================
  6586. * @mute - Mutes a player for a set amount of time
  6587. *------------------------------------------------*/
  6588. ACMD_FUNC(mute)
  6589. {
  6590. struct map_session_data *pl_sd = NULL;
  6591. int manner;
  6592. nullpo_retr(-1, sd);
  6593.  
  6594. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6595. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  6596. return -1;
  6597. }
  6598.  
  6599. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  6600. {
  6601. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6602. return -1;
  6603. }
  6604.  
  6605. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  6606. {
  6607. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6608. return -1;
  6609. }
  6610.  
  6611. clif_manner_message(sd, 0);
  6612. clif_manner_message(pl_sd, 5);
  6613.  
  6614. if( pl_sd->status.manner < manner ) {
  6615. pl_sd->status.manner -= manner;
  6616. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6617. } else {
  6618. pl_sd->status.manner = 0;
  6619. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6620. }
  6621.  
  6622. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6623.  
  6624. return 0;
  6625. }
  6626.  
  6627. /*==========================================
  6628. * @refresh (like @jumpto <<yourself>>)
  6629. *------------------------------------------*/
  6630. ACMD_FUNC(refresh)
  6631. {
  6632. nullpo_retr(-1, sd);
  6633. clif_refresh(sd);
  6634. return 0;
  6635. }
  6636.  
  6637. ACMD_FUNC(refreshall)
  6638. {
  6639. struct map_session_data* iter_sd;
  6640. struct s_mapiterator* iter;
  6641. nullpo_retr(-1, sd);
  6642.  
  6643. iter = mapit_getallusers();
  6644. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6645. clif_refresh(iter_sd);
  6646. mapit_free(iter);
  6647. return 0;
  6648. }
  6649.  
  6650. /*==========================================
  6651. * @identify
  6652. * => GM's magnifier.
  6653. *------------------------------------------*/
  6654. ACMD_FUNC(identify)
  6655. {
  6656. int i,num;
  6657.  
  6658. nullpo_retr(-1, sd);
  6659.  
  6660. for(i=num=0;i<MAX_INVENTORY;i++){
  6661. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  6662. num++;
  6663. }
  6664. }
  6665. if (num > 0) {
  6666. clif_item_identify_list(sd);
  6667. } else {
  6668. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6669. }
  6670. return 0;
  6671. }
  6672.  
  6673. /*===============================================
  6674. * @identifyall
  6675. * => Indentify all items in inventory - Akinari
  6676. *-----------------------------------------------*/
  6677. ACMD_FUNC(identifyall)
  6678. {
  6679. int i;
  6680. nullpo_retr(-1, sd);
  6681. for(i=0; i<MAX_INVENTORY; i++) {
  6682. if (sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1) {
  6683. sd->status.inventory[i].identify=1;
  6684. clif_item_identified(sd,i,0);
  6685. }
  6686. }
  6687. return 0;
  6688. }
  6689.  
  6690. /*==========================================
  6691. * @gmotd (Global MOTD)
  6692. * by davidsiaw :P
  6693. *------------------------------------------*/
  6694. ACMD_FUNC(gmotd)
  6695. {
  6696. FILE* fp;
  6697.  
  6698. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6699. {
  6700. char buf[CHAT_SIZE_MAX];
  6701. size_t len;
  6702.  
  6703. while( fgets(buf, sizeof(buf), fp) )
  6704. {
  6705. if( buf[0] == '/' && buf[1] == '/' )
  6706. {
  6707. continue;
  6708. }
  6709.  
  6710. len = strlen(buf);
  6711.  
  6712. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6713. {// strip trailing EOL characters
  6714. len--;
  6715. }
  6716.  
  6717. if( len )
  6718. {
  6719. buf[len] = 0;
  6720.  
  6721. intif_broadcast(buf, len+1, 0);
  6722. }
  6723. }
  6724. fclose(fp);
  6725. }
  6726. return 0;
  6727. }
  6728.  
  6729. ACMD_FUNC(misceffect)
  6730. {
  6731. int effect = 0;
  6732. nullpo_retr(-1, sd);
  6733. if (!message || !*message)
  6734. return -1;
  6735. if (sscanf(message, "%d", &effect) < 1)
  6736. return -1;
  6737. clif_misceffect(&sd->bl,effect);
  6738.  
  6739. return 0;
  6740. }
  6741.  
  6742. /*==========================================
  6743. * MAIL SYSTEM
  6744. *------------------------------------------*/
  6745. ACMD_FUNC(mail)
  6746. {
  6747. nullpo_ret(sd);
  6748. mail_openmail(sd);
  6749. return 0;
  6750. }
  6751.  
  6752. /*==========================================
  6753. * Show Monster DB Info v 1.0
  6754. * originally by [Lupus]
  6755. *------------------------------------------*/
  6756. ACMD_FUNC(mobinfo)
  6757. {
  6758. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  6759. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  6760. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  6761. char atcmd_output2[CHAT_SIZE_MAX];
  6762. struct item_data *item_data;
  6763. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6764. int count;
  6765. int i, j, k;
  6766. unsigned int base_exp, job_exp;
  6767.  
  6768. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6769. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6770.  
  6771. if (!message || !*message) {
  6772. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6773. return -1;
  6774. }
  6775.  
  6776. // If monster identifier/name argument is a name
  6777. if ((i = mobdb_checkid(atoi(message))))
  6778. {
  6779. mob_array[0] = mob_db(i);
  6780. count = 1;
  6781. } else
  6782. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6783.  
  6784. if (!count) {
  6785. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6786. return -1;
  6787. }
  6788.  
  6789. if (count > MAX_SEARCH) {
  6790. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6791. clif_displaymessage(fd, atcmd_output);
  6792. count = MAX_SEARCH;
  6793. }
  6794. for (k = 0; k < count; k++) {
  6795. mob = mob_array[k];
  6796. base_exp = mob->base_exp;
  6797. job_exp = mob->job_exp;
  6798.  
  6799. #ifdef RENEWAL_EXP
  6800. if( battle_config.atcommand_mobinfo_type ) {
  6801. base_exp = base_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 1) / 100;
  6802. job_exp = job_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 1) / 100;
  6803. }
  6804. #endif
  6805. // stats
  6806. if (mob->mexp)
  6807. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6808. else
  6809. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6810. clif_displaymessage(fd, atcmd_output);
  6811. sprintf(atcmd_output, msg_txt(sd,1242), mob->lv, mob->status.max_hp, base_exp, job_exp, MOB_HIT(mob), MOB_FLEE(mob)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
  6812. clif_displaymessage(fd, atcmd_output);
  6813. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6814. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6815. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6816. clif_displaymessage(fd, atcmd_output);
  6817.  
  6818. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6819. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6820. mob->range2 , mob->range3, msize[mob->status.size],
  6821. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6822. clif_displaymessage(fd, atcmd_output);
  6823. // drops
  6824. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6825. strcpy(atcmd_output, " ");
  6826. j = 0;
  6827. for (i = 0; i < MAX_MOB_DROP; i++) {
  6828. int droprate;
  6829. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6830. continue;
  6831. droprate = mob->dropitem[i].p;
  6832.  
  6833. #ifdef RENEWAL_DROP
  6834. if( battle_config.atcommand_mobinfo_type ) {
  6835. droprate = droprate * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 2) / 100;
  6836. if (droprate <= 0 && !battle_config.drop_rate0item)
  6837. droprate = 1;
  6838. }
  6839. #endif
  6840. if (item_data->slot)
  6841. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6842. else
  6843. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6844. strcat(atcmd_output, atcmd_output2);
  6845. if (++j % 3 == 0) {
  6846. clif_displaymessage(fd, atcmd_output);
  6847. strcpy(atcmd_output, " ");
  6848. }
  6849. }
  6850. if (j == 0)
  6851. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6852. else if (j % 3 != 0)
  6853. clif_displaymessage(fd, atcmd_output);
  6854. // mvp
  6855. if (mob->mexp) {
  6856. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6857. clif_displaymessage(fd, atcmd_output);
  6858. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6859. j = 0;
  6860. for (i = 0; i < MAX_MVP_DROP; i++) {
  6861. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6862. continue;
  6863. if (mob->mvpitem[i].p > 0) {
  6864. j++;
  6865. if (j == 1) {
  6866. if (item_data->slot)
  6867. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->mvpitem[i].p / 100);
  6868. else
  6869. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6870. } else {
  6871. if (item_data->slot)
  6872. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->mvpitem[i].p / 100);
  6873. else
  6874. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6875. }
  6876. strcat(atcmd_output, atcmd_output2);
  6877. }
  6878. }
  6879. if (j == 0)
  6880. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6881. else
  6882. clif_displaymessage(fd, atcmd_output);
  6883. }
  6884. }
  6885. return 0;
  6886. }
  6887.  
  6888. /*=========================================
  6889. * @showmobs by KarLaeda
  6890. * => For 15 sec displays the mobs on minimap
  6891. *------------------------------------------*/
  6892. ACMD_FUNC(showmobs)
  6893. {
  6894. char mob_name[100];
  6895. int mob_id;
  6896. int number = 0;
  6897. struct s_mapiterator* it;
  6898.  
  6899. nullpo_retr(-1, sd);
  6900.  
  6901. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6902. return -1;
  6903.  
  6904. if((mob_id = atoi(mob_name)) == 0)
  6905. mob_id = mobdb_searchname(mob_name);
  6906. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6907. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6908. clif_displaymessage(fd, atcmd_output);
  6909. return 0;
  6910. }
  6911.  
  6912. if(mob_db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  6913. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6914. return 0;
  6915. }
  6916.  
  6917. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6918. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6919. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6920.  
  6921. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6922. mob_name, mapindex_id2name(sd->mapindex));
  6923. clif_displaymessage(fd, atcmd_output);
  6924.  
  6925. it = mapit_geteachmob();
  6926. for(;;)
  6927. {
  6928. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6929. if( md == NULL )
  6930. break;// no more mobs
  6931.  
  6932. if( md->bl.m != sd->bl.m )
  6933. continue;
  6934. if( mob_id != -1 && md->class_ != mob_id )
  6935. continue;
  6936. if( md->special_state.ai || md->master_id )
  6937. continue; // hide slaves and player summoned mobs
  6938. if( md->spawn_timer != INVALID_TIMER )
  6939. continue; // hide mobs waiting for respawn
  6940.  
  6941. ++number;
  6942. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6943. }
  6944. mapit_free(it);
  6945.  
  6946. return 0;
  6947. }
  6948.  
  6949. /*==========================================
  6950. * homunculus level up [orn]
  6951. *------------------------------------------*/
  6952. ACMD_FUNC(homlevel)
  6953. {
  6954. TBL_HOM * hd;
  6955. int level = 0, i = 0;
  6956.  
  6957. nullpo_retr(-1, sd);
  6958.  
  6959. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6960. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6961. return -1;
  6962. }
  6963.  
  6964. if ( !merc_is_hom_active(sd->hd) ) {
  6965. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6966. return -1;
  6967. }
  6968.  
  6969. hd = sd->hd;
  6970.  
  6971. for (i = 1; i <= level && hd->exp_next; i++){
  6972. hd->homunculus.exp += hd->exp_next;
  6973. if( !merc_hom_levelup(hd) ){
  6974. break;
  6975. }
  6976. }
  6977. status_calc_homunculus(hd,0);
  6978. status_percent_heal(&hd->bl, 100, 100);
  6979. clif_specialeffect(&hd->bl,568,AREA);
  6980. return 0;
  6981. }
  6982.  
  6983. /*==========================================
  6984. * homunculus evolution H [orn]
  6985. *------------------------------------------*/
  6986. ACMD_FUNC(homevolution)
  6987. {
  6988. nullpo_retr(-1, sd);
  6989.  
  6990. if ( !merc_is_hom_active(sd->hd) ) {
  6991. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6992. return -1;
  6993. }
  6994.  
  6995. if ( !merc_hom_evolution(sd->hd) ) {
  6996. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6997. return -1;
  6998. }
  6999. clif_homskillinfoblock(sd);
  7000. return 0;
  7001. }
  7002.  
  7003. ACMD_FUNC(hommutate)
  7004. {
  7005. int homun_id, m_class = 0, m_id;
  7006. nullpo_retr(-1, sd);
  7007.  
  7008. if (!merc_is_hom_active(sd->hd)) {
  7009. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  7010. return -1;
  7011. }
  7012.  
  7013. if (!message || !*message) {
  7014. homun_id = 6048 + (rnd() % 4);
  7015. } else {
  7016. homun_id = atoi(message);
  7017. }
  7018.  
  7019. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  7020. m_id = hom_class2mapid(homun_id);
  7021.  
  7022. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  7023. hom_mutate(sd->hd, homun_id);
  7024. } else {
  7025. clif_emotion(&sd->hd->bl, E_SWT);
  7026. }
  7027. return 0;
  7028. }
  7029.  
  7030. /*==========================================
  7031. * call choosen homunculus [orn]
  7032. *------------------------------------------*/
  7033. ACMD_FUNC(makehomun)
  7034. {
  7035. int homunid;
  7036. nullpo_retr(-1, sd);
  7037.  
  7038. if ( sd->status.hom_id ) {
  7039. clif_displaymessage(fd, msg_txt(sd,450));
  7040. return -1;
  7041. }
  7042.  
  7043. if (!message || !*message) {
  7044. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  7045. return -1;
  7046. }
  7047.  
  7048. homunid = atoi(message);
  7049. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  7050. {
  7051. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  7052. return -1;
  7053. }
  7054.  
  7055. merc_create_homunculus_request(sd,homunid);
  7056. return 0;
  7057. }
  7058.  
  7059. /*==========================================
  7060. * modify homunculus intimacy [orn]
  7061. *------------------------------------------*/
  7062. ACMD_FUNC(homfriendly)
  7063. {
  7064. int friendly = 0;
  7065.  
  7066. nullpo_retr(-1, sd);
  7067.  
  7068. if ( !merc_is_hom_active(sd->hd) ) {
  7069. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  7070. return -1;
  7071. }
  7072.  
  7073. if (!message || !*message) {
  7074. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  7075. return -1;
  7076. }
  7077.  
  7078. friendly = atoi(message);
  7079. friendly = cap_value(friendly, 0, 1000);
  7080.  
  7081. sd->hd->homunculus.intimacy = friendly * 100 ;
  7082. clif_send_homdata(sd,SP_INTIMATE,friendly);
  7083. return 0;
  7084. }
  7085.  
  7086. /*==========================================
  7087. * modify homunculus hunger [orn]
  7088. *------------------------------------------*/
  7089. ACMD_FUNC(homhungry)
  7090. {
  7091. int hungry = 0;
  7092.  
  7093. nullpo_retr(-1, sd);
  7094.  
  7095. if ( !merc_is_hom_active(sd->hd) ) {
  7096. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  7097. return -1;
  7098. }
  7099.  
  7100. if (!message || !*message) {
  7101. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  7102. return -1;
  7103. }
  7104.  
  7105. hungry = atoi(message);
  7106. hungry = cap_value(hungry, 0, 100);
  7107.  
  7108. sd->hd->homunculus.hunger = hungry;
  7109. clif_send_homdata(sd,SP_HUNGRY,hungry);
  7110. return 0;
  7111. }
  7112.  
  7113. /*==========================================
  7114. * make the homunculus speak [orn]
  7115. *------------------------------------------*/
  7116. ACMD_FUNC(homtalk)
  7117. {
  7118. char mes[100],temp[100];
  7119.  
  7120. nullpo_retr(-1, sd);
  7121.  
  7122. if ( battle_config.min_chat_delay ) {
  7123. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  7124. return 0;
  7125. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  7126. }
  7127.  
  7128. if (sd->sc.cant.chat)
  7129. return -1; //no "chatting" while muted.
  7130.  
  7131. if ( !merc_is_hom_active(sd->hd) ) {
  7132. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  7133. return -1;
  7134. }
  7135.  
  7136. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  7137. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  7138. return -1;
  7139. }
  7140.  
  7141. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  7142. clif_disp_overhead(&sd->hd->bl, temp);
  7143.  
  7144. return 0;
  7145. }
  7146.  
  7147. /*==========================================
  7148. * Show homunculus stats
  7149. *------------------------------------------*/
  7150. ACMD_FUNC(hominfo)
  7151. {
  7152. struct homun_data *hd;
  7153. struct status_data *status;
  7154. nullpo_retr(-1, sd);
  7155.  
  7156. if ( !merc_is_hom_active(sd->hd) ) {
  7157. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  7158. return -1;
  7159. }
  7160.  
  7161. hd = sd->hd;
  7162. status = status_get_status_data(&hd->bl);
  7163. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  7164.  
  7165. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  7166. status->hp, status->max_hp, status->sp, status->max_sp);
  7167. clif_displaymessage(fd, atcmd_output);
  7168.  
  7169. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  7170. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  7171. clif_displaymessage(fd, atcmd_output);
  7172.  
  7173. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  7174. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  7175. clif_displaymessage(fd, atcmd_output);
  7176.  
  7177. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7178. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  7179. status->str, status->agi, status->vit,
  7180. status->int_, status->dex, status->luk);
  7181. clif_displaymessage(fd, atcmd_output);
  7182.  
  7183. return 0;
  7184. }
  7185.  
  7186. ACMD_FUNC(homstats)
  7187. {
  7188. struct homun_data *hd;
  7189. struct s_homunculus_db *db;
  7190. struct s_homunculus *hom;
  7191. int lv, min, max, evo;
  7192.  
  7193. nullpo_retr(-1, sd);
  7194.  
  7195. if ( !merc_is_hom_active(sd->hd) ) {
  7196. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  7197. return -1;
  7198. }
  7199.  
  7200. hd = sd->hd;
  7201.  
  7202. hom = &hd->homunculus;
  7203. db = hd->homunculusDB;
  7204. lv = hom->level;
  7205.  
  7206. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7207. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  7208. clif_displaymessage(fd, atcmd_output);
  7209. lv--; //Since the first increase is at level 2.
  7210.  
  7211. evo = (hom->class_ == db->evo_class);
  7212. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  7213. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  7214. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  7215. clif_displaymessage(fd, atcmd_output);
  7216.  
  7217. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  7218. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  7219. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  7220. clif_displaymessage(fd, atcmd_output);
  7221.  
  7222. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  7223. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  7224. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  7225. clif_displaymessage(fd, atcmd_output);
  7226.  
  7227. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  7228. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  7229. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  7230. clif_displaymessage(fd, atcmd_output);
  7231.  
  7232. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  7233. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  7234. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  7235. clif_displaymessage(fd, atcmd_output);
  7236.  
  7237. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  7238. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  7239. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  7240. clif_displaymessage(fd, atcmd_output);
  7241.  
  7242. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  7243. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  7244. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  7245. clif_displaymessage(fd, atcmd_output);
  7246.  
  7247. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  7248. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  7249. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  7250. clif_displaymessage(fd, atcmd_output);
  7251.  
  7252. return 0;
  7253. }
  7254.  
  7255. ACMD_FUNC(homshuffle)
  7256. {
  7257. nullpo_retr(-1, sd);
  7258.  
  7259. if(!sd->hd)
  7260. return -1; // nothing to do
  7261.  
  7262. if(!merc_hom_shuffle(sd->hd))
  7263. return -1;
  7264.  
  7265. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  7266. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  7267. return 0;
  7268. }
  7269.  
  7270. /*==========================================
  7271. * Show Items DB Info v 1.0
  7272. * originally by [Lupus]
  7273. *------------------------------------------*/
  7274. ACMD_FUNC(iteminfo)
  7275. {
  7276. struct item_data *item_data, *item_array[MAX_SEARCH];
  7277. int i, count = 1;
  7278.  
  7279. if (!message || !*message) {
  7280. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  7281. return -1;
  7282. }
  7283. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  7284. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7285.  
  7286. if (!count) {
  7287. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7288. return -1;
  7289. }
  7290.  
  7291. if (count > MAX_SEARCH) {
  7292. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  7293. clif_displaymessage(fd, atcmd_output);
  7294. count = MAX_SEARCH;
  7295. }
  7296. for (i = 0; i < count; i++) {
  7297. item_data = item_array[i];
  7298. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
  7299. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  7300. itemdb_typename(item_data->type),
  7301. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  7302. );
  7303. clif_displaymessage(fd, atcmd_output);
  7304.  
  7305. sprintf(atcmd_output, msg_txt(sd,1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
  7306. clif_displaymessage(fd, atcmd_output);
  7307.  
  7308. if (item_data->maxchance == -1)
  7309. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  7310. else if (!battle_config.atcommand_mobinfo_type && item_data->maxchance)
  7311. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  7312. else
  7313. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  7314. clif_displaymessage(fd, atcmd_output);
  7315.  
  7316. }
  7317. return 0;
  7318. }
  7319.  
  7320. /*==========================================
  7321. * Show who drops the item.
  7322. *------------------------------------------*/
  7323. ACMD_FUNC(whodrops)
  7324. {
  7325. struct item_data *item_data, *item_array[MAX_SEARCH];
  7326. int i,j, count = 1;
  7327.  
  7328. if (!message || !*message) {
  7329. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  7330. return -1;
  7331. }
  7332. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  7333. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7334.  
  7335. if (!count) {
  7336. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7337. return -1;
  7338. }
  7339.  
  7340. if (count > MAX_SEARCH) {
  7341. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  7342. clif_displaymessage(fd, atcmd_output);
  7343. count = MAX_SEARCH;
  7344. }
  7345. for (i = 0; i < count; i++) {
  7346. item_data = item_array[i];
  7347. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%d)
  7348. clif_displaymessage(fd, atcmd_output);
  7349.  
  7350. if (item_data->mob[0].chance == 0) {
  7351. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  7352. clif_displaymessage(fd, atcmd_output);
  7353. } else {
  7354. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  7355. clif_displaymessage(fd, atcmd_output);
  7356.  
  7357. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  7358. {
  7359. int dropchance = item_data->mob[j].chance;
  7360.  
  7361. #ifdef RENEWAL_DROP
  7362. if( battle_config.atcommand_mobinfo_type )
  7363. dropchance = dropchance * pc_level_penalty_mod(sd, mob_db(item_data->mob[j].id)->lv, mob_db(item_data->mob[j].id)->status.race, mob_db(item_data->mob[j].id)->status.mode, 2) / 100;
  7364. #endif
  7365. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, dropchance/100.);
  7366. clif_displaymessage(fd, atcmd_output);
  7367. }
  7368. }
  7369. }
  7370. return 0;
  7371. }
  7372.  
  7373. ACMD_FUNC(whereis)
  7374. {
  7375. struct mob_db *mob, *mob_array[MAX_SEARCH];
  7376. int count;
  7377. int i, j, k;
  7378.  
  7379. if (!message || !*message) {
  7380. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  7381. return -1;
  7382. }
  7383.  
  7384. // If monster identifier/name argument is a name
  7385. if ((i = mobdb_checkid(atoi(message))))
  7386. {
  7387. mob_array[0] = mob_db(i);
  7388. count = 1;
  7389. } else
  7390. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  7391.  
  7392. if (!count) {
  7393. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  7394. return -1;
  7395. }
  7396.  
  7397. if (count > MAX_SEARCH) {
  7398. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  7399. clif_displaymessage(fd, atcmd_output);
  7400. count = MAX_SEARCH;
  7401. }
  7402. for (k = 0; k < count; k++) {
  7403. mob = mob_array[k];
  7404. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  7405. clif_displaymessage(fd, atcmd_output);
  7406.  
  7407. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  7408. {
  7409. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  7410. if (j < 0) continue;
  7411. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  7412. clif_displaymessage(fd, atcmd_output);
  7413. }
  7414. if (i == 0)
  7415. clif_displaymessage(fd, msg_txt(sd,1290)); // This monster does not spawn normally.
  7416. }
  7417.  
  7418. return 0;
  7419. }
  7420.  
  7421. ACMD_FUNC(version)
  7422. {
  7423. const char * revision;
  7424.  
  7425. if ((revision = get_svn_revision()) != 0) {
  7426. sprintf(atcmd_output,msg_txt(sd,1295),revision); // rAthena Version SVN r%s
  7427. clif_displaymessage(fd,atcmd_output);
  7428. } else
  7429. clif_displaymessage(fd,msg_txt(sd,1296)); // Cannot determine SVN revision.
  7430.  
  7431. return 0;
  7432. }
  7433.  
  7434. /*==========================================
  7435. * @mutearea by MouseJstr
  7436. *------------------------------------------*/
  7437. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  7438. {
  7439.  
  7440. int time, id;
  7441. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  7442. if (pl_sd == NULL)
  7443. return 0;
  7444.  
  7445. id = va_arg(ap, int);
  7446. time = va_arg(ap, int);
  7447.  
  7448. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  7449. pl_sd->status.manner -= time;
  7450. if (pl_sd->status.manner < 0)
  7451. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  7452. else
  7453. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  7454. }
  7455. return 0;
  7456. }
  7457.  
  7458. ACMD_FUNC(mutearea)
  7459. {
  7460. int time;
  7461. nullpo_ret(sd);
  7462.  
  7463. if (!message || !*message) {
  7464. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  7465. return -1;
  7466. }
  7467.  
  7468. time = atoi(message);
  7469.  
  7470. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  7471. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  7472. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  7473.  
  7474. return 0;
  7475. }
  7476.  
  7477.  
  7478. ACMD_FUNC(rates)
  7479. {
  7480. char buf[CHAT_SIZE_MAX];
  7481.  
  7482. nullpo_ret(sd);
  7483. memset(buf, '\0', sizeof(buf));
  7484.  
  7485. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  7486. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  7487. clif_displaymessage(fd, buf);
  7488. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7489. 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.);
  7490. clif_displaymessage(fd, buf);
  7491. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7492. 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.);
  7493. clif_displaymessage(fd, buf);
  7494. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  7495. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  7496. clif_displaymessage(fd, buf);
  7497.  
  7498. return 0;
  7499. }
  7500.  
  7501. /*==========================================
  7502. * @me by lordalfa
  7503. * => Displays the OUTPUT string on top of the Visible players Heads.
  7504. *------------------------------------------*/
  7505. ACMD_FUNC(me)
  7506. {
  7507. char tempmes[CHAT_SIZE_MAX];
  7508. nullpo_retr(-1, sd);
  7509.  
  7510. memset(tempmes, '\0', sizeof(tempmes));
  7511. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7512.  
  7513. if (sd->sc.cant.chat)
  7514. return -1; //no "chatting" while muted.
  7515.  
  7516. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  7517. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  7518. return -1;
  7519. }
  7520.  
  7521. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  7522. clif_disp_overhead(&sd->bl, atcmd_output);
  7523.  
  7524. return 0;
  7525.  
  7526. }
  7527.  
  7528. /*==========================================
  7529. * @size
  7530. * => Resize your character sprite. [Valaris]
  7531. *------------------------------------------*/
  7532. ACMD_FUNC(size)
  7533. {
  7534. int size = 0;
  7535. nullpo_retr(-1, sd);
  7536.  
  7537. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  7538.  
  7539. if(sd->state.size) {
  7540. sd->state.size = SZ_SMALL;
  7541. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  7542. }
  7543.  
  7544. sd->state.size = size;
  7545. if( size == SZ_MEDIUM )
  7546. clif_specialeffect(&sd->bl,420,AREA);
  7547. else if( size == SZ_BIG )
  7548. clif_specialeffect(&sd->bl,422,AREA);
  7549.  
  7550. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7551. return 0;
  7552. }
  7553.  
  7554. ACMD_FUNC(sizeall)
  7555. {
  7556. int size;
  7557. struct map_session_data *pl_sd;
  7558. struct s_mapiterator* iter;
  7559.  
  7560. size = atoi(message);
  7561. size = cap_value(size,0,2);
  7562.  
  7563. iter = mapit_getallusers();
  7564. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  7565. if( pl_sd->state.size != size ) {
  7566. if( pl_sd->state.size ) {
  7567. pl_sd->state.size = SZ_SMALL;
  7568. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7569. }
  7570.  
  7571. pl_sd->state.size = size;
  7572. if( size == SZ_MEDIUM )
  7573. clif_specialeffect(&pl_sd->bl,420,AREA);
  7574. else if( size == SZ_BIG )
  7575. clif_specialeffect(&pl_sd->bl,422,AREA);
  7576. }
  7577. }
  7578. mapit_free(iter);
  7579.  
  7580. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7581. return 0;
  7582. }
  7583.  
  7584. ACMD_FUNC(sizeguild)
  7585. {
  7586. int size = 0, i;
  7587. char guild[NAME_LENGTH];
  7588. struct map_session_data *pl_sd;
  7589. struct guild *g;
  7590. nullpo_retr(-1, sd);
  7591.  
  7592. memset(guild, '\0', sizeof(guild));
  7593.  
  7594. if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
  7595. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  7596. return -1;
  7597. }
  7598.  
  7599. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  7600. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  7601. return -1;
  7602. }
  7603.  
  7604. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7605.  
  7606. for( i = 0; i < g->max_member; i++ ) {
  7607. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  7608. if( pl_sd->state.size ) {
  7609. pl_sd->state.size = SZ_SMALL;
  7610. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7611. }
  7612.  
  7613. pl_sd->state.size = size;
  7614. if( size == SZ_MEDIUM )
  7615. clif_specialeffect(&pl_sd->bl,420,AREA);
  7616. else if( size == SZ_BIG )
  7617. clif_specialeffect(&pl_sd->bl,422,AREA);
  7618. }
  7619. }
  7620.  
  7621. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7622. return 0;
  7623. }
  7624.  
  7625. /*==========================================
  7626. * @monsterignore
  7627. * => Makes monsters ignore you. [Valaris]
  7628. *------------------------------------------*/
  7629. ACMD_FUNC(monsterignore)
  7630. {
  7631. nullpo_retr(-1, sd);
  7632.  
  7633. if (!sd->state.monster_ignore) {
  7634. sd->state.monster_ignore = 1;
  7635. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  7636. } else {
  7637. sd->state.monster_ignore = 0;
  7638. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  7639. }
  7640.  
  7641. return 0;
  7642. }
  7643. /*==========================================
  7644. * @fakename
  7645. * => Gives your character a fake name. [Valaris]
  7646. *------------------------------------------*/
  7647. ACMD_FUNC(fakename)
  7648. {
  7649. nullpo_retr(-1, sd);
  7650.  
  7651. if( !message || !*message )
  7652. {
  7653. if( sd->fakename[0] )
  7654. {
  7655. sd->fakename[0] = '\0';
  7656. clif_charnameack(0, &sd->bl);
  7657. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  7658. return 0;
  7659. }
  7660.  
  7661. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  7662. return -1;
  7663. }
  7664.  
  7665. if( strlen(message) < 2 )
  7666. {
  7667. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  7668. return -1;
  7669. }
  7670.  
  7671. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  7672. clif_charnameack(0, &sd->bl);
  7673. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  7674.  
  7675. return 0;
  7676. }
  7677.  
  7678. /*==========================================
  7679. * Ragnarok Resources
  7680. *------------------------------------------*/
  7681. ACMD_FUNC(mapflag) {
  7682. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  7683. #define setflag( cmd ) \
  7684. if ( strcmp( flag_name , #cmd ) == 0 ){\
  7685. map[ sd->bl.m ].flag.cmd = flag;\
  7686. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  7687. clif_displaymessage(sd->fd,atcmd_output);\
  7688. return 0;\
  7689. }
  7690. char flag_name[100];
  7691. short flag=0,i;
  7692. nullpo_retr(-1, sd);
  7693. memset(flag_name, '\0', sizeof(flag_name));
  7694.  
  7695. if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
  7696. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  7697. clif_displaymessage(sd->fd,"----------------------------------");
  7698. checkflag(town); checkflag(autotrade); checkflag(allowks); checkflag(nomemo);
  7699. checkflag(noteleport); checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave);
  7700. checkflag(nobranch); checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty);
  7701. checkflag(pvp_noguild); checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle);
  7702. checkflag(gvg); checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);
  7703. checkflag(nozenypenalty); checkflag(notrade); checkflag(noskill); checkflag(nowarp);
  7704. checkflag(nowarpto); checkflag(noicewall); checkflag(snow); checkflag(clouds);
  7705. checkflag(clouds2); checkflag(fog); checkflag(fireworks); checkflag(sakura);
  7706. checkflag(leaves); checkflag(nogo); checkflag(nobaseexp); checkflag(nojobexp);
  7707. checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); checkflag(restricted);
  7708. checkflag(nodrop); checkflag(novending); checkflag(loadevent); checkflag(nochat);
  7709. checkflag(partylock); checkflag(guildlock); checkflag(reset); checkflag(chmautojoin);
  7710. checkflag(nousecart); checkflag(noitemconsumption); checkflag(nosumstarmiracle); checkflag(nomineeffect);
  7711. checkflag(nolockon); checkflag(notomb);
  7712. #ifdef ADJUST_SKILL_DAMAGE
  7713. checkflag(skill_damage);
  7714. #endif
  7715. clif_displaymessage(sd->fd," ");
  7716. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7717. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  7718. return 1;
  7719. }
  7720. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  7721.  
  7722. setflag(town); setflag(autotrade); setflag(allowks); setflag(nomemo);
  7723. setflag(noteleport); setflag(noreturn); setflag(monster_noteleport); setflag(nosave);
  7724. setflag(nobranch); setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty);
  7725. setflag(pvp_noguild); setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle);
  7726. setflag(gvg); setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground);
  7727. setflag(nozenypenalty); setflag(notrade); setflag(noskill); setflag(nowarp);
  7728. setflag(nowarpto); setflag(noicewall); setflag(snow); setflag(clouds);
  7729. setflag(clouds2); setflag(fog); setflag(fireworks); setflag(sakura);
  7730. setflag(leaves); setflag(nogo); setflag(nobaseexp); setflag(nojobexp);
  7731. setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); setflag(restricted);
  7732. setflag(nodrop); setflag(novending); setflag(loadevent); setflag(nochat);
  7733. setflag(partylock); setflag(guildlock); setflag(reset); setflag(chmautojoin);
  7734. setflag(nousecart); setflag(noitemconsumption); setflag(nosumstarmiracle); setflag(nomineeffect);
  7735. setflag(nolockon); setflag(notomb);
  7736. #ifdef ADJUST_SKILL_DAMAGE
  7737. setflag(skill_damage);
  7738. #endif
  7739.  
  7740. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  7741. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7742. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  7743. clif_displaymessage(sd->fd,"----------------------------------");
  7744. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  7745. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  7746. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  7747. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  7748. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot, nomvploot,");
  7749. clif_displaymessage(sd->fd,"nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock, guildlock,");
  7750. clif_displaymessage(sd->fd,"reset, chmautojoin, nousecart, noitemconsumption, nosumstarmiracle, nolockon, notomb");
  7751. #ifdef ADJUST_SKILL_DAMAGE
  7752. clif_displaymessage(sd->fd,"skill_damage");
  7753. #endif
  7754.  
  7755. #undef checkflag
  7756. #undef setflag
  7757.  
  7758. return 0;
  7759. }
  7760.  
  7761. /*===================================
  7762. * Remove some messages
  7763. *-----------------------------------*/
  7764. ACMD_FUNC(showexp)
  7765. {
  7766. if (sd->state.showexp) {
  7767. sd->state.showexp = 0;
  7768. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7769. return 0;
  7770. }
  7771.  
  7772. sd->state.showexp = 1;
  7773. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7774. return 0;
  7775. }
  7776.  
  7777. ACMD_FUNC(showzeny)
  7778. {
  7779. if (sd->state.showzeny) {
  7780. sd->state.showzeny = 0;
  7781. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7782. return 0;
  7783. }
  7784.  
  7785. sd->state.showzeny = 1;
  7786. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7787. return 0;
  7788. }
  7789.  
  7790. ACMD_FUNC(showdelay)
  7791. {
  7792. if (sd->state.showdelay) {
  7793. sd->state.showdelay = 0;
  7794. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7795. return 0;
  7796. }
  7797.  
  7798. sd->state.showdelay = 1;
  7799. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7800. return 0;
  7801. }
  7802.  
  7803. /*==========================================
  7804. * Duel organizing functions [LuzZza]
  7805. *
  7806. * @duel [limit|nick] - create a duel
  7807. * @invite <nick> - invite player
  7808. * @accept - accept invitation
  7809. * @reject - reject invitation
  7810. * @leave - leave duel
  7811. *------------------------------------------*/
  7812. ACMD_FUNC(invite)
  7813. {
  7814. unsigned int did = sd->duel_group;
  7815. struct map_session_data *target_sd = map_nick2sd((char *)message);
  7816.  
  7817. if(did == 0) {
  7818. // "Duel: @invite without @duel."
  7819. clif_displaymessage(fd, msg_txt(sd,350));
  7820. return 0;
  7821. }
  7822.  
  7823. if(duel_list[did].max_players_limit > 0 &&
  7824. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  7825.  
  7826. // "Duel: Limit of players is reached."
  7827.  
  7828. clif_displaymessage(fd, msg_txt(sd,351));
  7829. return 0;
  7830. }
  7831.  
  7832. if(target_sd == NULL) {
  7833. // "Duel: Player not found."
  7834. clif_displaymessage(fd, msg_txt(sd,352));
  7835. return 0;
  7836. }
  7837.  
  7838. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7839. // "Duel: Player already in duel."
  7840. clif_displaymessage(fd, msg_txt(sd,353));
  7841. return 0;
  7842. }
  7843.  
  7844. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7845. {
  7846. sprintf(atcmd_output, msg_txt(sd,364), message);
  7847. clif_displaymessage(fd, atcmd_output);
  7848. return 0;
  7849. }
  7850.  
  7851. duel_invite(did, sd, target_sd);
  7852. // "Duel: Invitation has been sent."
  7853. clif_displaymessage(fd, msg_txt(sd,354));
  7854. return 0;
  7855. }
  7856.  
  7857. ACMD_FUNC(duel)
  7858. {
  7859. unsigned int maxpl = 0;
  7860.  
  7861. if(sd->duel_group > 0) {
  7862. duel_showinfo(sd->duel_group, sd);
  7863. return 0;
  7864. }
  7865.  
  7866. if(sd->duel_invite > 0) {
  7867. // "Duel: @duel without @reject."
  7868. clif_displaymessage(fd, msg_txt(sd,355));
  7869. return 0;
  7870. }
  7871.  
  7872. if(!duel_checktime(sd)) {
  7873. char output[CHAT_SIZE_MAX];
  7874. // "Duel: You can take part in duel only one time per %d minutes."
  7875. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  7876. clif_displaymessage(fd, output);
  7877. return 0;
  7878. }
  7879.  
  7880. if( message[0] ) {
  7881. if(sscanf(message, "%d", &maxpl) >= 1) {
  7882. if(maxpl < 2 || maxpl > 65535) {
  7883. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7884. return 0;
  7885. }
  7886. duel_create(sd, maxpl);
  7887. } else {
  7888. struct map_session_data *target_sd;
  7889. target_sd = map_nick2sd((char *)message);
  7890. if(target_sd != NULL) {
  7891. unsigned int newduel;
  7892. if((newduel = duel_create(sd, 2)) != -1) {
  7893. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7894. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7895. return 0;
  7896. }
  7897. duel_invite(newduel, sd, target_sd);
  7898. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7899. }
  7900. } else {
  7901. // "Duel: Player not found."
  7902. clif_displaymessage(fd, msg_txt(sd,352));
  7903. return 0;
  7904. }
  7905. }
  7906. } else
  7907. duel_create(sd, 0);
  7908.  
  7909. return 0;
  7910. }
  7911.  
  7912.  
  7913. ACMD_FUNC(leave)
  7914. {
  7915. if(sd->duel_group <= 0) {
  7916. // "Duel: @leave without @duel."
  7917. clif_displaymessage(fd, msg_txt(sd,358));
  7918. return 0;
  7919. }
  7920.  
  7921. duel_leave(sd->duel_group, sd);
  7922. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7923. return 0;
  7924. }
  7925.  
  7926. ACMD_FUNC(accept)
  7927. {
  7928. if(!duel_checktime(sd)) {
  7929. char output[CHAT_SIZE_MAX];
  7930. // "Duel: You can take part in duel only one time per %d minutes."
  7931. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  7932. clif_displaymessage(fd, output);
  7933. return 0;
  7934. }
  7935.  
  7936. if(sd->duel_invite <= 0) {
  7937. // "Duel: @accept without invititation."
  7938. clif_displaymessage(fd, msg_txt(sd,360));
  7939. return 0;
  7940. }
  7941.  
  7942. 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 )
  7943. {
  7944. // "Duel: Limit of players is reached."
  7945. clif_displaymessage(fd, msg_txt(sd,351));
  7946. return 0;
  7947. }
  7948.  
  7949. duel_accept(sd->duel_invite, sd);
  7950. // "Duel: Invitation has been accepted."
  7951. clif_displaymessage(fd, msg_txt(sd,361));
  7952. return 0;
  7953. }
  7954.  
  7955. ACMD_FUNC(reject)
  7956. {
  7957. if(sd->duel_invite <= 0) {
  7958. // "Duel: @reject without invititation."
  7959. clif_displaymessage(fd, msg_txt(sd,362));
  7960. return 0;
  7961. }
  7962.  
  7963. duel_reject(sd->duel_invite, sd);
  7964. // "Duel: Invitation has been rejected."
  7965. clif_displaymessage(fd, msg_txt(sd,363));
  7966. return 0;
  7967. }
  7968.  
  7969. /*===================================
  7970. * Cash Points
  7971. *-----------------------------------*/
  7972. ACMD_FUNC(cash)
  7973. {
  7974. char output[128];
  7975. int value;
  7976. int ret=0;
  7977. nullpo_retr(-1, sd);
  7978.  
  7979. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7980. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7981. return -1;
  7982. }
  7983.  
  7984. if( !strcmpi(command+1,"cash") )
  7985. {
  7986. if( value > 0 ) {
  7987. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7988. // If this option is set, the message is already sent by pc function
  7989. if( !battle_config.cashshop_show_points ){
  7990. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints);
  7991. clif_disp_onlyself(sd, output, strlen(output));
  7992. }
  7993. }
  7994. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7995. } else {
  7996. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7997. // If this option is set, the message is already sent by pc function
  7998. if( !battle_config.cashshop_show_points ){
  7999. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints);
  8000. clif_disp_onlyself(sd, output, strlen(output));
  8001. }
  8002. }
  8003. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  8004. }
  8005. }
  8006. else
  8007. { // @points
  8008. if( value > 0 ) {
  8009. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  8010. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints);
  8011. clif_disp_onlyself(sd, output, strlen(output));
  8012. }
  8013. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  8014. } else {
  8015. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  8016. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints);
  8017. clif_disp_onlyself(sd, output, strlen(output));
  8018. }
  8019. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  8020. }
  8021. }
  8022.  
  8023. return 0;
  8024. }
  8025.  
  8026. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8027. ACMD_FUNC(clone)
  8028. {
  8029. int x=0,y=0,flag=0,master=0,i=0;
  8030. struct map_session_data *pl_sd=NULL;
  8031.  
  8032. if (!message || !*message) {
  8033. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  8034. return 0;
  8035. }
  8036.  
  8037. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8038. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8039. return 0;
  8040. }
  8041.  
  8042. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8043. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  8044. return 0;
  8045. }
  8046.  
  8047. if (strcmpi(command+1, "clone") == 0)
  8048. flag = 1;
  8049. else if (strcmpi(command+1, "slaveclone") == 0) {
  8050. flag = 2;
  8051. if(pc_isdead(sd)){
  8052. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  8053. return 0;
  8054. }
  8055. master = sd->bl.id;
  8056. if (battle_config.atc_slave_clone_limit
  8057. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8058. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  8059. return 0;
  8060. }
  8061. }
  8062.  
  8063. do {
  8064. x = sd->bl.x + (rnd() % 10 - 5);
  8065. y = sd->bl.y + (rnd() % 10 - 5);
  8066. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8067.  
  8068. if (i >= 10) {
  8069. x = sd->bl.x;
  8070. y = sd->bl.y;
  8071. }
  8072.  
  8073. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8074. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  8075. return 0;
  8076. }
  8077. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  8078. return 0;
  8079. }
  8080.  
  8081. /*=====================================
  8082. * Autorejecting Invites/Deals [LuzZza]
  8083. * Usage: @noask
  8084. *-------------------------------------*/
  8085. ACMD_FUNC(noask)
  8086. {
  8087. if(sd->state.noask) {
  8088. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  8089. sd->state.noask = 0;
  8090. } else {
  8091. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  8092. sd->state.noask = 1;
  8093. }
  8094.  
  8095. return 0;
  8096. }
  8097.  
  8098. /*=====================================
  8099. * Send a @request message to all GMs of lowest_gm_level.
  8100. * Usage: @request <petition>
  8101. *-------------------------------------*/
  8102. ACMD_FUNC(request)
  8103. {
  8104. if (!message || !*message) {
  8105. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  8106. return -1;
  8107. }
  8108.  
  8109. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  8110. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  8111. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  8112. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  8113. return 0;
  8114. }
  8115.  
  8116. /*==========================================
  8117. * Feel (SG save map) Reset [HiddenDragon]
  8118. *------------------------------------------*/
  8119. ACMD_FUNC(feelreset)
  8120. {
  8121. pc_resetfeel(sd);
  8122. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  8123.  
  8124. return 0;
  8125. }
  8126.  
  8127. /*==========================================
  8128. * AUCTION SYSTEM
  8129. *------------------------------------------*/
  8130. ACMD_FUNC(auction)
  8131. {
  8132. nullpo_ret(sd);
  8133.  
  8134. clif_Auction_openwindow(sd);
  8135.  
  8136. return 0;
  8137. }
  8138.  
  8139. /*==========================================
  8140. * Kill Steal Protection
  8141. *------------------------------------------*/
  8142. ACMD_FUNC(ksprotection)
  8143. {
  8144. nullpo_retr(-1,sd);
  8145.  
  8146. if( sd->state.noks ) {
  8147. sd->state.noks = 0;
  8148. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  8149. }
  8150. else
  8151. {
  8152. if( !message || !*message || !strcmpi(message, "party") )
  8153. { // Default is Party
  8154. sd->state.noks = 2;
  8155. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  8156. }
  8157. else if( !strcmpi(message, "self") )
  8158. {
  8159. sd->state.noks = 1;
  8160. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  8161. }
  8162. else if( !strcmpi(message, "guild") )
  8163. {
  8164. sd->state.noks = 3;
  8165. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  8166. }
  8167. else
  8168. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  8169. }
  8170. return 0;
  8171. }
  8172. /*==========================================
  8173. * Map Kill Steal Protection Setting
  8174. *------------------------------------------*/
  8175. ACMD_FUNC(allowks)
  8176. {
  8177. nullpo_retr(-1,sd);
  8178.  
  8179. if( map[sd->bl.m].flag.allowks ) {
  8180. map[sd->bl.m].flag.allowks = 0;
  8181. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  8182. } else {
  8183. map[sd->bl.m].flag.allowks = 1;
  8184. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  8185. }
  8186. return 0;
  8187. }
  8188.  
  8189. ACMD_FUNC(resetstat)
  8190. {
  8191. nullpo_retr(-1, sd);
  8192.  
  8193. pc_resetstate(sd);
  8194. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name);
  8195. clif_displaymessage(fd, atcmd_output);
  8196. return 0;
  8197. }
  8198.  
  8199. ACMD_FUNC(resetskill)
  8200. {
  8201. nullpo_retr(-1,sd);
  8202.  
  8203. pc_resetskill(sd,1);
  8204. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name);
  8205. clif_displaymessage(fd, atcmd_output);
  8206. return 0;
  8207. }
  8208.  
  8209. /*==========================================
  8210. * #storagelist: Displays the items list of a player's storage.
  8211. * #cartlist: Displays contents of target's cart.
  8212. * #itemlist: Displays contents of target's inventory.
  8213. *------------------------------------------*/
  8214. ACMD_FUNC(itemlist)
  8215. {
  8216. int i, j, count, counter;
  8217. const char* location;
  8218. const struct item* items;
  8219. int size;
  8220. StringBuf buf;
  8221.  
  8222. nullpo_retr(-1, sd);
  8223.  
  8224. if( strcmp(command+1, "storagelist") == 0 )
  8225. {
  8226. location = "storage";
  8227. items = sd->status.storage.items;
  8228. size = MAX_STORAGE;
  8229. }
  8230. else
  8231. if( strcmp(command+1, "cartlist") == 0 )
  8232. {
  8233. location = "cart";
  8234. items = sd->status.cart;
  8235. size = MAX_CART;
  8236. }
  8237. else
  8238. if( strcmp(command+1, "itemlist") == 0 )
  8239. {
  8240. location = "inventory";
  8241. items = sd->status.inventory;
  8242. size = MAX_INVENTORY;
  8243. }
  8244. else
  8245. return 1;
  8246.  
  8247. StringBuf_Init(&buf);
  8248.  
  8249. count = 0; // total slots occupied
  8250. counter = 0; // total items found
  8251. for( i = 0; i < size; ++i )
  8252. {
  8253. const struct item* it = &items[i];
  8254. struct item_data* itd;
  8255.  
  8256. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  8257. continue;
  8258.  
  8259. counter += it->amount;
  8260. count++;
  8261.  
  8262. if( count == 1 )
  8263. {
  8264. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  8265. clif_displaymessage(fd, StringBuf_Value(&buf));
  8266. StringBuf_Clear(&buf);
  8267. }
  8268.  
  8269. if( it->refine )
  8270. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  8271. else
  8272. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  8273.  
  8274. if( it->equip )
  8275. {
  8276. char equipstr[CHAT_SIZE_MAX];
  8277. strcpy(equipstr, msg_txt(sd,1333)); // | equipped:
  8278. if( it->equip & EQP_GARMENT )
  8279. strcat(equipstr, msg_txt(sd,1334)); // garment,
  8280. if( it->equip & EQP_ACC_L )
  8281. strcat(equipstr, msg_txt(sd,1335)); // left accessory,
  8282. if( it->equip & EQP_ARMOR )
  8283. strcat(equipstr, msg_txt(sd,1336)); // body/armor,
  8284. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  8285. strcat(equipstr, msg_txt(sd,1337)); // right hand,
  8286. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  8287. strcat(equipstr, msg_txt(sd,1338)); // left hand,
  8288. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  8289. strcat(equipstr, msg_txt(sd,1339)); // both hands,
  8290. if( it->equip & EQP_SHOES )
  8291. strcat(equipstr, msg_txt(sd,1340)); // feet,
  8292. if( it->equip & EQP_ACC_R )
  8293. strcat(equipstr, msg_txt(sd,1341)); // right accessory,
  8294. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  8295. strcat(equipstr, msg_txt(sd,1342)); // lower head,
  8296. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  8297. strcat(equipstr, msg_txt(sd,1343)); // top head,
  8298. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  8299. strcat(equipstr, msg_txt(sd,1344)); // lower/top head,
  8300. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  8301. strcat(equipstr, msg_txt(sd,1345)); // mid head,
  8302. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  8303. strcat(equipstr, msg_txt(sd,1346)); // lower/mid head,
  8304. if( (it->equip & EQP_HELM) == EQP_HELM )
  8305. strcat(equipstr, msg_txt(sd,1347)); // lower/mid/top head,
  8306. // remove final ', '
  8307. equipstr[strlen(equipstr) - 2] = '\0';
  8308. StringBuf_AppendStr(&buf, equipstr);
  8309. }
  8310.  
  8311. clif_displaymessage(fd, StringBuf_Value(&buf));
  8312. StringBuf_Clear(&buf);
  8313.  
  8314. if( it->card[0] == CARD0_PET )
  8315. {// pet egg
  8316. if (it->card[3])
  8317. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  8318. else
  8319. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  8320. }
  8321. else
  8322. if(it->card[0] == CARD0_FORGE)
  8323. {// forged item
  8324. StringBuf_Printf(&buf, msg_txt(sd,1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d)
  8325. }
  8326. else
  8327. if(it->card[0] == CARD0_CREATE)
  8328. {// created item
  8329. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  8330. }
  8331. else
  8332. {// normal item
  8333. int counter2 = 0;
  8334.  
  8335. for( j = 0; j < itd->slot; ++j )
  8336. {
  8337. struct item_data* card;
  8338.  
  8339. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  8340. continue;
  8341.  
  8342. counter2++;
  8343.  
  8344. if( counter2 == 1 )
  8345. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  8346.  
  8347. if( counter2 != 1 )
  8348. StringBuf_AppendStr(&buf, ", ");
  8349.  
  8350. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  8351. }
  8352.  
  8353. if( counter2 > 0 )
  8354. StringBuf_AppendStr(&buf, ")");
  8355. }
  8356.  
  8357. if( StringBuf_Length(&buf) > 0 )
  8358. clif_displaymessage(fd, StringBuf_Value(&buf));
  8359.  
  8360. StringBuf_Clear(&buf);
  8361. }
  8362.  
  8363. if( count == 0 )
  8364. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  8365. else
  8366. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  8367.  
  8368. clif_displaymessage(fd, StringBuf_Value(&buf));
  8369.  
  8370. StringBuf_Destroy(&buf);
  8371.  
  8372. return 0;
  8373. }
  8374.  
  8375. ACMD_FUNC(stats)
  8376. {
  8377. char job_jobname[100];
  8378. char output[CHAT_SIZE_MAX];
  8379. int i;
  8380. struct {
  8381. const char* format;
  8382. int value;
  8383. } output_table[] = {
  8384. { "Base Level - %d", 0 },
  8385. { NULL, 0 },
  8386. { "Hp - %d", 0 },
  8387. { "MaxHp - %d", 0 },
  8388. { "Sp - %d", 0 },
  8389. { "MaxSp - %d", 0 },
  8390. { "Str - %3d", 0 },
  8391. { "Agi - %3d", 0 },
  8392. { "Vit - %3d", 0 },
  8393. { "Int - %3d", 0 },
  8394. { "Dex - %3d", 0 },
  8395. { "Luk - %3d", 0 },
  8396. { "Zeny - %d", 0 },
  8397. { "Free SK Points - %d", 0 },
  8398. { "JobChangeLvl (2nd) - %d", 0 },
  8399. { "JobChangeLvl (3rd) - %d", 0 },
  8400. { NULL, 0 }
  8401. };
  8402.  
  8403. memset(job_jobname, '\0', sizeof(job_jobname));
  8404. memset(output, '\0', sizeof(output));
  8405.  
  8406. //direct array initialization with variables is not standard C compliant.
  8407. output_table[0].value = sd->status.base_level;
  8408. output_table[1].format = job_jobname;
  8409. output_table[1].value = sd->status.job_level;
  8410. output_table[2].value = sd->status.hp;
  8411. output_table[3].value = sd->status.max_hp;
  8412. output_table[4].value = sd->status.sp;
  8413. output_table[5].value = sd->status.max_sp;
  8414. output_table[6].value = sd->status.str;
  8415. output_table[7].value = sd->status.agi;
  8416. output_table[8].value = sd->status.vit;
  8417. output_table[9].value = sd->status.int_;
  8418. output_table[10].value = sd->status.dex;
  8419. output_table[11].value = sd->status.luk;
  8420. output_table[12].value = sd->status.zeny;
  8421. output_table[13].value = sd->status.skill_point;
  8422. output_table[14].value = sd->change_level_2nd;
  8423. output_table[15].value = sd->change_level_3rd;
  8424.  
  8425. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  8426. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  8427.  
  8428. clif_displaymessage(fd, output);
  8429.  
  8430. for (i = 0; output_table[i].format != NULL; i++) {
  8431. sprintf(output, output_table[i].format, output_table[i].value);
  8432. clif_displaymessage(fd, output);
  8433. }
  8434.  
  8435. return 0;
  8436. }
  8437.  
  8438. ACMD_FUNC(delitem)
  8439. {
  8440. char item_name[100];
  8441. int nameid, amount = 0, total, idx;
  8442. struct item_data* id;
  8443.  
  8444. nullpo_retr(-1, sd);
  8445.  
  8446. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  8447. {
  8448. clif_displaymessage(fd, msg_txt(sd,1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
  8449. return -1;
  8450. }
  8451.  
  8452. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  8453. {
  8454. nameid = id->nameid;
  8455. }
  8456. else
  8457. {
  8458. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  8459. return -1;
  8460. }
  8461.  
  8462. total = amount;
  8463.  
  8464. // delete items
  8465. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  8466. {
  8467. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  8468.  
  8469. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  8470. {// delete pet
  8471. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  8472. }
  8473. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  8474.  
  8475. amount-= delamount;
  8476. }
  8477.  
  8478. // notify target
  8479. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  8480. clif_displaymessage(sd->fd, atcmd_output);
  8481.  
  8482. // notify source
  8483. if( amount == total )
  8484. {
  8485. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  8486. }
  8487. else if( amount )
  8488. {
  8489. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  8490. clif_displaymessage(fd, atcmd_output);
  8491. }
  8492. else
  8493. {
  8494. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  8495. clif_displaymessage(fd, atcmd_output);
  8496. }
  8497.  
  8498. return 0;
  8499. }
  8500.  
  8501. /*==========================================
  8502. * Custom Fonts
  8503. *------------------------------------------*/
  8504. ACMD_FUNC(font)
  8505. {
  8506. int font_id;
  8507. nullpo_retr(-1,sd);
  8508.  
  8509. font_id = atoi(message);
  8510. if( font_id == 0 )
  8511. {
  8512. if( sd->user_font )
  8513. {
  8514. sd->user_font = 0;
  8515. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  8516. clif_font(sd);
  8517. }
  8518. else
  8519. {
  8520. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  8521. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  8522. }
  8523. }
  8524. else if( font_id < 0 || font_id > 9 )
  8525. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  8526. else if( font_id != sd->user_font )
  8527. {
  8528. sd->user_font = font_id;
  8529. clif_font(sd);
  8530. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  8531. }
  8532. else
  8533. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  8534.  
  8535. return 0;
  8536. }
  8537.  
  8538. /*==========================================
  8539. * type: 1 = commands (@), 2 = charcommands (#)
  8540. *------------------------------------------*/
  8541. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  8542. {
  8543. char line_buff[CHATBOX_SIZE];
  8544. char* cur = line_buff;
  8545. AtCommandInfo* cmd;
  8546. DBIterator *iter = db_iterator(atcommand_db);
  8547. int count = 0;
  8548.  
  8549. memset(line_buff,' ',CHATBOX_SIZE);
  8550. line_buff[CHATBOX_SIZE-1] = 0;
  8551.  
  8552. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  8553.  
  8554. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8555. unsigned int slen = 0;
  8556.  
  8557. switch( type ) {
  8558. case COMMAND_CHARCOMMAND:
  8559. if( cmd->char_groups[sd->group_pos] == 0 )
  8560. continue;
  8561. break;
  8562. case COMMAND_ATCOMMAND:
  8563. if( cmd->at_groups[sd->group_pos] == 0 )
  8564. continue;
  8565. break;
  8566. default:
  8567. continue;
  8568. }
  8569.  
  8570.  
  8571. slen = strlen(cmd->command);
  8572.  
  8573. // flush the text buffer if this command won't fit into it
  8574. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8575. clif_displaymessage(fd,line_buff);
  8576. cur = line_buff;
  8577. memset(line_buff,' ',CHATBOX_SIZE);
  8578. line_buff[CHATBOX_SIZE-1] = 0;
  8579. }
  8580.  
  8581. memcpy(cur,cmd->command,slen);
  8582. cur += slen+(10-slen%10);
  8583.  
  8584. count++;
  8585. }
  8586. dbi_destroy(iter);
  8587. clif_displaymessage(fd,line_buff);
  8588.  
  8589. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  8590. clif_displaymessage(fd, atcmd_output);
  8591.  
  8592. return;
  8593. }
  8594.  
  8595. /*==========================================
  8596. * @commands Lists available @ commands to you
  8597. *------------------------------------------*/
  8598. ACMD_FUNC(commands)
  8599. {
  8600. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  8601. return 0;
  8602. }
  8603.  
  8604. /*==========================================
  8605. * @charcommands Lists available # commands to you
  8606. *------------------------------------------*/
  8607. ACMD_FUNC(charcommands)
  8608. {
  8609. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  8610. return 0;
  8611. }
  8612. /* for new mounts */
  8613. ACMD_FUNC(mount2) {
  8614.  
  8615. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  8616. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  8617. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  8618. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  8619. } else {
  8620. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  8621. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  8622. }
  8623. return 0;
  8624. }
  8625.  
  8626. ACMD_FUNC(accinfo) {
  8627. char query[NAME_LENGTH];
  8628.  
  8629. if (!message || !*message || strlen(message) > NAME_LENGTH ) {
  8630. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  8631. clif_displaymessage(fd, msg_txt(sd,1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
  8632. return -1;
  8633. }
  8634.  
  8635. //remove const type
  8636. safestrncpy(query, message, NAME_LENGTH);
  8637.  
  8638. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query );
  8639.  
  8640. return 0;
  8641. }
  8642.  
  8643. /* [Ind] */
  8644. ACMD_FUNC(set) {
  8645. char reg[32], val[128];
  8646. struct script_data* data;
  8647. int toset = 0, len;
  8648. bool is_str = false;
  8649.  
  8650. if( !message || !*message || (toset = sscanf(message, "%31s %128[^\n]s", reg, val)) < 1 ) {
  8651. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  8652. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  8653. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  8654. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  8655. return -1;
  8656. }
  8657.  
  8658. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  8659. if( reg[0] == '.' ) {
  8660. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  8661. return -1;
  8662. } else if( reg[0] == '\'' ) {
  8663. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  8664. return -1;
  8665. }
  8666.  
  8667. is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
  8668.  
  8669. if( ( len = strlen(val) ) > 1 ) {
  8670. if( val[0] == '"' && val[len-1] == '"') {
  8671. val[len-1] = '\0'; //Strip quotes.
  8672. memmove(val, val+1, len-1);
  8673. }
  8674. }
  8675.  
  8676. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  8677. if( is_str )
  8678. set_var(sd, reg, (void*) val);
  8679. else
  8680. set_var(sd, reg, (void*)__64BPRTSIZE((atoi(val))));
  8681.  
  8682. }
  8683.  
  8684. CREATE(data, struct script_data,1);
  8685.  
  8686.  
  8687. if( is_str ) {// string variable
  8688.  
  8689. switch( reg[0] ) {
  8690. case '@':
  8691. data->u.str = pc_readregstr(sd, add_str(reg));
  8692. break;
  8693. case '$':
  8694. data->u.str = mapreg_readregstr(add_str(reg));
  8695. break;
  8696. case '#':
  8697. if( reg[1] == '#' )
  8698. data->u.str = pc_readaccountreg2str(sd, reg);// global
  8699. else
  8700. data->u.str = pc_readaccountregstr(sd, reg);// local
  8701. break;
  8702. default:
  8703. data->u.str = pc_readglobalreg_str(sd, reg);
  8704. break;
  8705. }
  8706.  
  8707. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  8708. data->type = C_CONSTSTR;
  8709. data->u.str = "";
  8710. } else {// duplicate string
  8711. data->type = C_STR;
  8712. data->u.str = aStrdup(data->u.str);
  8713. }
  8714.  
  8715. } else {// integer variable
  8716.  
  8717. data->type = C_INT;
  8718. switch( reg[0] ) {
  8719. case '@':
  8720. data->u.num = pc_readreg(sd, add_str(reg));
  8721. break;
  8722. case '$':
  8723. data->u.num = mapreg_readreg(add_str(reg));
  8724. break;
  8725. case '#':
  8726. if( reg[1] == '#' )
  8727. data->u.num = pc_readaccountreg2(sd, reg);// global
  8728. else
  8729. data->u.num = pc_readaccountreg(sd, reg);// local
  8730. break;
  8731. default:
  8732. data->u.num = pc_readglobalreg(sd, reg);
  8733. break;
  8734. }
  8735.  
  8736. }
  8737.  
  8738.  
  8739. switch( data->type ) {
  8740. case C_INT:
  8741. sprintf(atcmd_output,msg_txt(sd,1373),reg,data->u.num); // %s value is now :%d
  8742. break;
  8743. case C_STR:
  8744. sprintf(atcmd_output,msg_txt(sd,1374),reg,data->u.str); // %s value is now :%s
  8745. break;
  8746. case C_CONSTSTR:
  8747. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  8748. break;
  8749. default:
  8750. sprintf(atcmd_output,msg_txt(sd,1376),reg,data->type); // %s data type is not supported :%u
  8751. break;
  8752. }
  8753.  
  8754. clif_displaymessage(fd, atcmd_output);
  8755.  
  8756. aFree(data);
  8757.  
  8758. return 0;
  8759. }
  8760. ACMD_FUNC(addperm) {
  8761. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  8762. bool add = (strcmpi(command+1, "addperm") == 0) ? true : false;
  8763. int i;
  8764.  
  8765. if( !message || !*message ) {
  8766. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  8767. clif_displaymessage(fd, atcmd_output);
  8768. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8769. for( i = 0; i < perm_size; i++ ) {
  8770. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8771. clif_displaymessage(fd, atcmd_output);
  8772. }
  8773. return -1;
  8774. }
  8775.  
  8776. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  8777.  
  8778. if( i == perm_size ) {
  8779. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  8780. clif_displaymessage(fd, atcmd_output);
  8781. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8782. for( i = 0; i < perm_size; i++ ) {
  8783. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8784. clif_displaymessage(fd, atcmd_output);
  8785. }
  8786. return -1;
  8787. }
  8788.  
  8789. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  8790. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  8791. clif_displaymessage(fd, atcmd_output);
  8792. return -1;
  8793. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  8794. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  8795. clif_displaymessage(fd, atcmd_output);
  8796. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  8797. clif_displaymessage(fd, atcmd_output);
  8798. for( i = 0; i < perm_size; i++ ) {
  8799. if( sd->permissions&pc_g_permission_name[i].permission ) {
  8800. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8801. clif_displaymessage(fd, atcmd_output);
  8802. }
  8803. }
  8804.  
  8805. return -1;
  8806. }
  8807.  
  8808. if( add )
  8809. sd->permissions |= pc_g_permission_name[i].permission;
  8810. else
  8811. sd->permissions &=~ pc_g_permission_name[i].permission;
  8812.  
  8813.  
  8814. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  8815. clif_displaymessage(fd, atcmd_output);
  8816.  
  8817. return 0;
  8818. }
  8819. ACMD_FUNC(unloadnpcfile) {
  8820.  
  8821. if( !message || !*message ) {
  8822. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  8823. return -1;
  8824. }
  8825.  
  8826. if( npc_unloadfile(message) )
  8827. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  8828. else {
  8829. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  8830. return -1;
  8831. }
  8832. return 0;
  8833. }
  8834. ACMD_FUNC(cart) {
  8835. #define MC_CART_MDFY(x) \
  8836. sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
  8837. sd->status.skill[MC_PUSHCART].lv = x?1:0; \
  8838. sd->status.skill[MC_PUSHCART].flag = x?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  8839.  
  8840. int val = atoi(message);
  8841. bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true;
  8842.  
  8843. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  8844. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  8845. clif_displaymessage(fd, atcmd_output);
  8846. return -1;
  8847. }
  8848.  
  8849. if( val == 0 && !pc_iscarton(sd) ) {
  8850. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  8851. return -1;
  8852. }
  8853.  
  8854. if( need_skill ) {
  8855. MC_CART_MDFY(1);
  8856. }
  8857.  
  8858. if( pc_setcart(sd, val) ) {
  8859. if( need_skill ) {
  8860. MC_CART_MDFY(0);
  8861. }
  8862. return -1;/* @cart failed */
  8863. }
  8864.  
  8865. if( need_skill ) {
  8866. MC_CART_MDFY(0);
  8867. }
  8868.  
  8869. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8870.  
  8871. return 0;
  8872. #undef MC_CART_MDFY
  8873. }
  8874.  
  8875. /* Channel System [Ind] */
  8876. ACMD_FUNC(join){
  8877. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8878.  
  8879. if( !message || !*message || sscanf(message, "%s %s", chname, pass) < 1 ) {
  8880. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8881. clif_displaymessage(fd, atcmd_output);
  8882. return -1;
  8883. }
  8884. return channel_pcjoin(sd, chname, pass);
  8885. }
  8886. /*
  8887. * Display available option for @channel command
  8888. * @command : the name of used command (for alias case)
  8889. */
  8890. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  8891. {
  8892. int fd = sd->fd;
  8893. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8894. bool can_create = (can_delete || Channel_Config.user_chenable);
  8895. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8896.  
  8897. //option create
  8898. if( can_create ) {
  8899. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8900. clif_displaymessage(fd, atcmd_output);
  8901. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8902. }
  8903.  
  8904. //option delete
  8905. if(can_delete){
  8906. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8907. clif_displaymessage(fd, atcmd_output);
  8908. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8909. }
  8910.  
  8911. //option list
  8912. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8913. clif_displaymessage(fd, atcmd_output);
  8914. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8915. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8916. clif_displaymessage(fd, atcmd_output);
  8917. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8918. if( can_create ) {
  8919. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8920. clif_displaymessage(fd, atcmd_output);
  8921. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8922. }
  8923.  
  8924. //option setcolor
  8925. if(can_create){
  8926. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8927. clif_displaymessage(fd, atcmd_output);
  8928. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8929. }
  8930.  
  8931. //option join
  8932. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8933. clif_displaymessage(fd, atcmd_output);
  8934. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8935.  
  8936. //option leave
  8937. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8938. clif_displaymessage(fd, atcmd_output);
  8939. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8940.  
  8941. //option bindto
  8942. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8943. clif_displaymessage(fd, atcmd_output);
  8944. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8945.  
  8946. //option unbind
  8947. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8948. clif_displaymessage(fd, atcmd_output);
  8949. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8950.  
  8951. //option ban/unban/banlist
  8952. if( can_create ) {
  8953. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8954. clif_displaymessage(fd, atcmd_output);
  8955. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8956. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8957. clif_displaymessage(fd, atcmd_output);
  8958. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8959. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8960. clif_displaymessage(fd, atcmd_output);
  8961. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8962. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8963. clif_displaymessage(fd, atcmd_output);
  8964. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8965. }
  8966.  
  8967. //option setopt
  8968. if(can_create){
  8969. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8970. clif_displaymessage(fd, atcmd_output);
  8971. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8972. }
  8973.  
  8974. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8975. clif_displaymessage(fd, atcmd_output);
  8976. }
  8977.  
  8978. ACMD_FUNC(channel) {
  8979. char key[CHAN_NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[CHAN_NAME_LENGTH], sub3[CHAN_NAME_LENGTH];
  8980. sub1[0] = sub2[0] = sub3[0] = '\0';
  8981.  
  8982. if( !message || !*message || sscanf(message, "%s %s %s %s", key, sub1, sub2, sub3) < 1 ) {
  8983. atcmd_channel_help(sd,command);
  8984. return 0;
  8985. }
  8986.  
  8987. if( strcmpi(key,"create") == 0 && ( Channel_Config.user_chenable || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8988. if(sub3[0] != '\0'){
  8989. clif_displaymessage(fd, msg_txt(sd,1408)); // Channel password may not contain spaces.
  8990. return -1;
  8991. }
  8992. return channel_pccreate(sd,sub1,sub2);
  8993. } else if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8994. return channel_pcdelete(sd,sub1);
  8995. } else if ( strcmpi(key,"list") == 0 ) {
  8996. return channel_display_list(sd,sub1);
  8997. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8998. return channel_pccolor(sd, sub1, sub2);
  8999. } else if ( strcmpi(key,"join") == 0 ) {
  9000. return channel_pcjoin(sd, sub1, sub2);
  9001. }else if ( strcmpi(key,"leave") == 0 ) {
  9002. return channel_pcleave(sd, sub1);
  9003. } else if ( strcmpi(key,"bindto") == 0 ) {
  9004. return channel_pcbind(sd, sub1);
  9005. } else if ( strcmpi(key,"unbind") == 0 ) {
  9006. return channel_pcunbind(sd);
  9007. } else if ( strcmpi(key,"ban") == 0 ) {
  9008. return channel_pcban(sd,sub1,map_nick2sd(sub2),0);
  9009. } else if ( strcmpi(key,"banlist") == 0 ) {
  9010. return channel_pcban(sd,sub1,NULL,3);
  9011. } else if ( strcmpi(key,"unban") == 0 ) {
  9012. return channel_pcban(sd,sub1,map_nick2sd(sub2),1);
  9013. } else if ( strcmpi(key,"unbanall") == 0 ) {
  9014. return channel_pcban(sd,sub1,NULL,2);
  9015. } else if ( strcmpi(key,"setopt") == 0 ) {
  9016. return channel_pcsetopt(sd,sub1,sub2,sub3);
  9017. } else {
  9018. atcmd_channel_help(sd,command);
  9019. }
  9020.  
  9021. return 0;
  9022. }
  9023.  
  9024. ACMD_FUNC(fontcolor)
  9025. {
  9026. unsigned char k;
  9027.  
  9028. if( !message || !*message ) {
  9029. channel_display_list(sd,"colors");
  9030. return -1;
  9031. }
  9032.  
  9033. if( strcmpi(message,"Normal") == 0 ) {
  9034. sd->fontcolor = 0;
  9035. } else {
  9036. ARR_FIND(0,Channel_Config.colors_count,k,( strcmpi(message,Channel_Config.colors_name[k]) == 0 ));
  9037. if( k == Channel_Config.colors_count ) {
  9038. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  9039. clif_displaymessage(fd, atcmd_output);
  9040. return -1;
  9041. }
  9042. sd->fontcolor = k;
  9043. }
  9044. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  9045. clif_displaymessage(fd, atcmd_output);
  9046.  
  9047. return 0;
  9048. }
  9049.  
  9050. ACMD_FUNC(langtype)
  9051. {
  9052. char langstr[8];
  9053. int i=0, test=0;
  9054.  
  9055. memset(langstr, '\0', sizeof(langstr));
  9056.  
  9057. if(sscanf(message, "%3s", langstr) >= 1){
  9058. int lang=-1;
  9059. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  9060. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  9061. char output[100];
  9062. pc_setaccountreg(sd, "#langtype", lang); //For login/char
  9063. sd->langtype = lang;
  9064. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  9065. clif_displaymessage(fd,output);
  9066. return 0;
  9067. } else if (lang != -1) { //defined langage but failed check
  9068. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  9069. return -1;
  9070. }
  9071. }
  9072.  
  9073. //wrong or no entry
  9074. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  9075. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  9076. while(test!=-1){ //out of range
  9077. test = msg_checklangtype(i,false);
  9078. if(test == 1)
  9079. clif_displaymessage(fd,msg_langtype2langstr(i));
  9080. i++;
  9081. }
  9082. return -1;
  9083. }
  9084.  
  9085. #include "../custom/atcommand.inc"
  9086. /**
  9087. * Fills the reference of available commands in atcommand DBMap
  9088. **/
  9089. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  9090. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  9091. //define with restriction
  9092. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  9093. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  9094. void atcommand_basecommands(void) {
  9095. /**
  9096. * Command reference list, place the base of your commands here
  9097. * TODO : all restricted command are crashing case, please look into it
  9098. **/
  9099. AtCommandInfo atcommand_base[] = {
  9100. #include "../custom/atcommand_def.inc"
  9101. ACMD_DEF2R("warp", mapmove, 1),
  9102. ACMD_DEF(where),
  9103. ACMD_DEF(jumpto),
  9104. ACMD_DEF(jump),
  9105. ACMD_DEF(who),
  9106. ACMD_DEF2("who2", who),
  9107. ACMD_DEF2("who3", who),
  9108. ACMD_DEF2("whomap", who),
  9109. ACMD_DEF2("whomap2", who),
  9110. ACMD_DEF2("whomap3", who),
  9111. ACMD_DEF(whogm),
  9112. ACMD_DEF(save),
  9113. ACMD_DEF(load),
  9114. ACMD_DEF(speed),
  9115. ACMD_DEF(storage),
  9116. ACMD_DEF(guildstorage),
  9117. ACMD_DEF(option),
  9118. ACMD_DEF(hide), // + /hide
  9119. ACMD_DEFR(jobchange, 1),
  9120. ACMD_DEF(kill),
  9121. ACMD_DEF(alive),
  9122. ACMD_DEF(kami),
  9123. ACMD_DEF2("kamib", kami),
  9124. ACMD_DEF2("kamic", kami),
  9125. ACMD_DEF2("lkami", kami),
  9126. ACMD_DEF(heal),
  9127. ACMD_DEF(item),
  9128. ACMD_DEF(item2),
  9129. ACMD_DEF2("itembound",item),
  9130. ACMD_DEF2("itembound2",item2),
  9131. ACMD_DEF(itemreset),
  9132. ACMD_DEF(clearstorage),
  9133. ACMD_DEF(cleargstorage),
  9134. ACMD_DEF(clearcart),
  9135. ACMD_DEF2R("blvl", baselevelup, 1),
  9136. ACMD_DEF2("jlvl", joblevelup),
  9137. ACMD_DEF(help),
  9138. ACMD_DEF(pvpoff),
  9139. ACMD_DEF(pvpon),
  9140. ACMD_DEF(gvgoff),
  9141. ACMD_DEF(gvgon),
  9142. ACMD_DEF(model),
  9143. ACMD_DEFR(go, 1),
  9144. ACMD_DEF(monster),
  9145. ACMD_DEF2("monstersmall", monster),
  9146. ACMD_DEF2("monsterbig", monster),
  9147. ACMD_DEF(killmonster),
  9148. ACMD_DEF2("killmonster2", killmonster),
  9149. ACMD_DEF(refine),
  9150. ACMD_DEF(produce),
  9151. ACMD_DEF(memo),
  9152. ACMD_DEF(gat),
  9153. ACMD_DEF(displaystatus),
  9154. ACMD_DEF2("stpoint", statuspoint),
  9155. ACMD_DEF2("skpoint", skillpoint),
  9156. ACMD_DEF(zeny),
  9157. ACMD_DEF2("str", param),
  9158. ACMD_DEF2("agi", param),
  9159. ACMD_DEF2("vit", param),
  9160. ACMD_DEF2("int", param),
  9161. ACMD_DEF2("dex", param),
  9162. ACMD_DEF2("luk", param),
  9163. ACMD_DEF2("glvl", guildlevelup),
  9164. ACMD_DEF(makeegg),
  9165. ACMD_DEF(hatch),
  9166. ACMD_DEF(petfriendly),
  9167. ACMD_DEF(pethungry),
  9168. ACMD_DEF(petrename),
  9169. ACMD_DEF(recall), // + /recall
  9170. ACMD_DEF(night),
  9171. ACMD_DEF(day),
  9172. ACMD_DEF(doom),
  9173. ACMD_DEF(doommap),
  9174. ACMD_DEF(raise),
  9175. ACMD_DEF(raisemap),
  9176. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  9177. ACMD_DEF(kickall),
  9178. ACMD_DEF(allskill),
  9179. ACMD_DEF(questskill),
  9180. ACMD_DEF(lostskill),
  9181. ACMD_DEF(spiritball),
  9182. ACMD_DEF(party),
  9183. ACMD_DEF(guild),
  9184. ACMD_DEF(breakguild),
  9185. ACMD_DEF(agitstart),
  9186. ACMD_DEF(agitend),
  9187. ACMD_DEF(mapexit),
  9188. ACMD_DEF(idsearch),
  9189. ACMD_DEF(broadcast), // + /b and /nb
  9190. ACMD_DEF(localbroadcast), // + /lb and /nlb
  9191. ACMD_DEF(recallall),
  9192. ACMD_DEFR(reload,2),
  9193. ACMD_DEF2("reloaditemdb", reload),
  9194. ACMD_DEF2("reloadmobdb", reload),
  9195. ACMD_DEF2("reloadskilldb", reload),
  9196. ACMD_DEF2R("reloadscript", reload,2),
  9197. ACMD_DEF2("reloadatcommand", reload),
  9198. ACMD_DEF2("reloadbattleconf", reload),
  9199. ACMD_DEF2("reloadstatusdb", reload),
  9200. ACMD_DEF2("reloadpcdb", reload),
  9201. ACMD_DEF2("reloadmotd", reload),
  9202. ACMD_DEF2("reloadquestdb", reload),
  9203. ACMD_DEF2("reloadmsgconf", reload),
  9204. ACMD_DEF2("reloadpacketdb", reload),
  9205. ACMD_DEF2("reloadinstancedb", reload),
  9206. ACMD_DEF(partysharelvl),
  9207. ACMD_DEF(mapinfo),
  9208. ACMD_DEF(dye),
  9209. ACMD_DEF2("hairstyle", hair_style),
  9210. ACMD_DEF2("haircolor", hair_color),
  9211. ACMD_DEF2("allstats", stat_all),
  9212. ACMD_DEF2("block", char_block),
  9213. ACMD_DEF2("ban", char_ban),
  9214. ACMD_DEF2("unblock", char_unblock),
  9215. ACMD_DEF2("unban", char_unban),
  9216. ACMD_DEF2("mount", mount_peco),
  9217. ACMD_DEF(guildspy),
  9218. ACMD_DEF(partyspy),
  9219. ACMD_DEF(repairall),
  9220. ACMD_DEF(guildrecall),
  9221. ACMD_DEF(partyrecall),
  9222. ACMD_DEF(nuke),
  9223. ACMD_DEF(shownpc),
  9224. ACMD_DEF(hidenpc),
  9225. ACMD_DEF(loadnpc),
  9226. ACMD_DEF(unloadnpc),
  9227. ACMD_DEF2("time", servertime),
  9228. ACMD_DEF(jail),
  9229. ACMD_DEF(unjail),
  9230. ACMD_DEF(jailfor),
  9231. ACMD_DEF(jailtime),
  9232. ACMD_DEF(disguise),
  9233. ACMD_DEF(undisguise),
  9234. ACMD_DEF(email),
  9235. ACMD_DEF(effect),
  9236. ACMD_DEF(follow),
  9237. ACMD_DEF(addwarp),
  9238. ACMD_DEF(skillon),
  9239. ACMD_DEF(skilloff),
  9240. ACMD_DEF(killer),
  9241. ACMD_DEF(npcmove),
  9242. ACMD_DEF(killable),
  9243. ACMD_DEF(dropall),
  9244. ACMD_DEF(storeall),
  9245. ACMD_DEF(skillid),
  9246. ACMD_DEF(useskill),
  9247. ACMD_DEF(displayskill),
  9248. ACMD_DEF(snow),
  9249. ACMD_DEF(sakura),
  9250. ACMD_DEF(clouds),
  9251. ACMD_DEF(clouds2),
  9252. ACMD_DEF(fog),
  9253. ACMD_DEF(fireworks),
  9254. ACMD_DEF(leaves),
  9255. ACMD_DEF(summon),
  9256. ACMD_DEF(adjgroup),
  9257. ACMD_DEF(trade),
  9258. ACMD_DEF(send),
  9259. ACMD_DEF(setbattleflag),
  9260. ACMD_DEF(unmute),
  9261. ACMD_DEF(clearweather),
  9262. ACMD_DEF(uptime),
  9263. ACMD_DEF(changesex),
  9264. ACMD_DEF(mute),
  9265. ACMD_DEF(refresh),
  9266. ACMD_DEF(refreshall),
  9267. ACMD_DEF(identify),
  9268. ACMD_DEF(identifyall),
  9269. ACMD_DEF(gmotd),
  9270. ACMD_DEF(misceffect),
  9271. ACMD_DEF(mobsearch),
  9272. ACMD_DEF(cleanmap),
  9273. ACMD_DEF(cleanarea),
  9274. ACMD_DEF(npctalk),
  9275. ACMD_DEF(pettalk),
  9276. ACMD_DEF(users),
  9277. ACMD_DEF(reset),
  9278. ACMD_DEF(skilltree),
  9279. ACMD_DEF(marry),
  9280. ACMD_DEF(divorce),
  9281. ACMD_DEF(sound),
  9282. ACMD_DEF(undisguiseall),
  9283. ACMD_DEF(disguiseall),
  9284. ACMD_DEF(changelook),
  9285. ACMD_DEF(autoloot),
  9286. ACMD_DEF2("alootid", autolootitem),
  9287. ACMD_DEF(mobinfo),
  9288. ACMD_DEF(exp),
  9289. ACMD_DEF(version),
  9290. ACMD_DEF(mutearea),
  9291. ACMD_DEF(rates),
  9292. ACMD_DEF(iteminfo),
  9293. ACMD_DEF(whodrops),
  9294. ACMD_DEF(whereis),
  9295. ACMD_DEF(mapflag),
  9296. ACMD_DEF(me),
  9297. ACMD_DEF(monsterignore),
  9298. ACMD_DEF(fakename),
  9299. ACMD_DEF(size),
  9300. ACMD_DEF(showexp),
  9301. ACMD_DEF(showzeny),
  9302. ACMD_DEF(showdelay),
  9303. ACMD_DEF(autotrade),
  9304. ACMD_DEF(changegm),
  9305. ACMD_DEF(changeleader),
  9306. ACMD_DEF(partyoption),
  9307. ACMD_DEF(invite),
  9308. ACMD_DEF(duel),
  9309. ACMD_DEF(leave),
  9310. ACMD_DEF(accept),
  9311. ACMD_DEF(reject),
  9312. ACMD_DEF(clone),
  9313. ACMD_DEF2("slaveclone", clone),
  9314. ACMD_DEF2("evilclone", clone),
  9315. ACMD_DEF(tonpc),
  9316. ACMD_DEF(commands),
  9317. ACMD_DEF(noask),
  9318. ACMD_DEF(request),
  9319. ACMD_DEF(homlevel),
  9320. ACMD_DEF(homevolution),
  9321. ACMD_DEF(hommutate),
  9322. ACMD_DEF(makehomun),
  9323. ACMD_DEF(homfriendly),
  9324. ACMD_DEF(homhungry),
  9325. ACMD_DEF(homtalk),
  9326. ACMD_DEF(hominfo),
  9327. ACMD_DEF(homstats),
  9328. ACMD_DEF(homshuffle),
  9329. ACMD_DEF(showmobs),
  9330. ACMD_DEF(feelreset),
  9331. ACMD_DEF(auction),
  9332. ACMD_DEF(mail),
  9333. ACMD_DEF2("noks", ksprotection),
  9334. ACMD_DEF(allowks),
  9335. ACMD_DEF(cash),
  9336. ACMD_DEF2("points", cash),
  9337. ACMD_DEF(agitstart2),
  9338. ACMD_DEF(agitend2),
  9339. ACMD_DEF(resetskill),
  9340. ACMD_DEF(resetstat),
  9341. ACMD_DEF2("storagelist", itemlist),
  9342. ACMD_DEF2("cartlist", itemlist),
  9343. ACMD_DEF2("itemlist", itemlist),
  9344. ACMD_DEF(stats),
  9345. ACMD_DEF(delitem),
  9346. ACMD_DEF(charcommands),
  9347. ACMD_DEF(font),
  9348. ACMD_DEF(accinfo),
  9349. ACMD_DEF(set),
  9350. ACMD_DEF(undisguiseguild),
  9351. ACMD_DEF(disguiseguild),
  9352. ACMD_DEF(sizeall),
  9353. ACMD_DEF(sizeguild),
  9354. ACMD_DEF(addperm),
  9355. ACMD_DEF2("rmvperm", addperm),
  9356. ACMD_DEF(unloadnpcfile),
  9357. ACMD_DEF(cart),
  9358. ACMD_DEF(mount2),
  9359. ACMD_DEF(join),
  9360. ACMD_DEF(channel),
  9361. ACMD_DEF(fontcolor),
  9362. ACMD_DEF(langtype),
  9363. ACMD_DEF(reloadmsgconf)
  9364. };
  9365. AtCommandInfo* atcommand;
  9366. int i;
  9367.  
  9368. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  9369. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  9370. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  9371. continue;
  9372. }
  9373. CREATE(atcommand, AtCommandInfo, 1);
  9374. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  9375. atcommand->func = atcommand_base[i].func;
  9376. atcommand->restriction = atcommand_base[i].restriction;
  9377. strdb_put(atcommand_db, atcommand->command, atcommand);
  9378. }
  9379. return;
  9380. }
  9381.  
  9382. /*==========================================
  9383. * Command lookup functions
  9384. *------------------------------------------*/
  9385. bool atcommand_exists(const char* name)
  9386. {
  9387. return strdb_exists(atcommand_db, name);
  9388. }
  9389.  
  9390. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  9391. {
  9392. if (strdb_exists(atcommand_db, name))
  9393. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  9394. return NULL;
  9395. }
  9396.  
  9397. static const char* atcommand_checkalias(const char *aliasname)
  9398. {
  9399. AliasInfo *alias_info = NULL;
  9400. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  9401. return alias_info->command->command;
  9402. return aliasname;
  9403. }
  9404.  
  9405. /// AtCommand suggestion
  9406. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  9407. DBIterator* atcommand_iter;
  9408. DBIterator* alias_iter;
  9409. AtCommandInfo* command_info = NULL;
  9410. AliasInfo* alias_info = NULL;
  9411. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  9412. char* full_match[MAX_SUGGESTIONS];
  9413. char* suggestions[MAX_SUGGESTIONS];
  9414. char* match;
  9415. int prefix_count = 0, full_count = 0;
  9416. bool can_use;
  9417.  
  9418. if (!battle_config.atcommand_suggestions_enabled)
  9419. return;
  9420.  
  9421. atcommand_iter = db_iterator(atcommand_db);
  9422. alias_iter = db_iterator(atcommand_alias_db);
  9423.  
  9424. // Build the matches
  9425. for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
  9426. match = strstr(command_info->command, name);
  9427. can_use = pc_can_use_command(sd, command_info->command, type);
  9428. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  9429. suggestions[prefix_count] = command_info->command;
  9430. ++prefix_count;
  9431. }
  9432. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  9433. full_match[full_count] = command_info->command;
  9434. ++full_count;
  9435. }
  9436. }
  9437.  
  9438. for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
  9439. match = strstr(alias_info->alias, name);
  9440. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  9441. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  9442. suggestions[prefix_count] = alias_info->alias;
  9443. ++prefix_count;
  9444. }
  9445. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  9446. full_match[full_count] = alias_info->alias;
  9447. ++full_count;
  9448. }
  9449. }
  9450.  
  9451. if ((full_count+prefix_count) > 0) {
  9452. char buffer[512];
  9453. int i;
  9454.  
  9455. // Merge full match and prefix match results
  9456. if (prefix_count < MAX_SUGGESTIONS) {
  9457. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  9458. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  9459. }
  9460.  
  9461. // Build the suggestion string
  9462. strcpy(buffer, msg_txt(sd,205));
  9463. strcat(buffer,"\n");
  9464.  
  9465. for(i=0; i < prefix_count; ++i) {
  9466. strcat(buffer,suggestions[i]);
  9467. strcat(buffer," ");
  9468. }
  9469.  
  9470. clif_displaymessage(sd->fd, buffer);
  9471. }
  9472.  
  9473. dbi_destroy(atcommand_iter);
  9474. dbi_destroy(alias_iter);
  9475. }
  9476.  
  9477. /*
  9478. * Executes an at-command
  9479. * \param type :
  9480. * 0 : script call (atcommand)
  9481. * 1 : normal player @atcommand
  9482. * 2 : console
  9483. * 3 : script call (useatcmd)
  9484. */
  9485. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  9486. {
  9487. char charname[NAME_LENGTH], params[100];
  9488. char charname2[NAME_LENGTH], params2[100];
  9489. char command[100];
  9490. char output[CHAT_SIZE_MAX];
  9491.  
  9492. //Reconstructed message
  9493. char atcmd_msg[CHAT_SIZE_MAX];
  9494.  
  9495. TBL_PC * ssd = NULL; //sd for target
  9496. AtCommandInfo * info;
  9497.  
  9498. nullpo_retr(false, sd);
  9499.  
  9500. //Shouldn't happen
  9501. if ( !message || !*message )
  9502. return false;
  9503.  
  9504. //Block NOCHAT but do not display it as a normal message
  9505. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  9506. return true;
  9507.  
  9508. // skip 10/11-langtype's codepage indicator, if detected
  9509. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  9510. message += 3;
  9511.  
  9512. //Should display as a normal message
  9513. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  9514. return false;
  9515.  
  9516. // type value 0|2 = script|console invoked: bypass restrictions
  9517. if ( type == 1 || type == 3) {
  9518. //Commands are disabled on maps flagged as 'nocommand'
  9519. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  9520. clif_displaymessage(fd, msg_txt(sd,143));
  9521. return false;
  9522. }
  9523. }
  9524.  
  9525. if (*message == charcommand_symbol) {
  9526. do {
  9527. int x, y, z;
  9528.  
  9529. //Checks to see if #command has a name or a name + parameters.
  9530. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  9531. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  9532.  
  9533. //z always has the value of the scan that was successful
  9534. z = ( x > 1 ) ? x : y;
  9535.  
  9536. //#command + name means the sufficient target was used and anything else after
  9537. //can be looked at by the actual command function since most scan to see if the
  9538. //right parameters are used.
  9539. if ( x > 2 ) {
  9540. sprintf(atcmd_msg, "%s %s", command, params);
  9541. break;
  9542. }
  9543. else if ( y > 2 ) {
  9544. sprintf(atcmd_msg, "%s %s", command, params2);
  9545. break;
  9546. }
  9547. //Regardless of what style the #command is used, if it's correct, it will always have
  9548. //this value if there is no parameter. Send it as just the #command
  9549. else if ( z == 2 ) {
  9550. sprintf(atcmd_msg, "%s", command);
  9551. break;
  9552. }
  9553.  
  9554. if( !pc_get_group_level(sd) ) {
  9555. if( x >= 1 || y >= 1 ) { /* we have command */
  9556. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  9557. if( !info || info->char_groups[sd->group_pos] == 0 ) /* if we can't use or doesn't exist: don't even display the command failed message */
  9558. return false;
  9559. } else
  9560. return false;/* display as normal message */
  9561. }
  9562.  
  9563. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  9564. clif_displaymessage(fd, output);
  9565. return true;
  9566. } while(0);
  9567. }
  9568. else if (*message == atcommand_symbol) {
  9569. //atcmd_msg is constructed above differently for charcommands
  9570. //it's copied from message if not a charcommand so it can
  9571. //pass through the rest of the code compatible with both symbols
  9572. sprintf(atcmd_msg, "%s", message);
  9573. }
  9574.  
  9575. //Clearing these to be used once more.
  9576. memset(command, '\0', sizeof(command));
  9577. memset(params, '\0', sizeof(params));
  9578.  
  9579. //check to see if any params exist within this command
  9580. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  9581. params[0] = '\0';
  9582.  
  9583. // @commands (script based)
  9584. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  9585. struct atcmd_binding_data * binding;
  9586.  
  9587. // Check if the command initiated is a character command
  9588. if (*message == charcommand_symbol &&
  9589. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  9590. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  9591. clif_displaymessage(fd, output);
  9592. return true;
  9593. }
  9594.  
  9595. // Get atcommand binding
  9596. binding = get_atcommandbind_byname(command);
  9597.  
  9598. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  9599. if( binding != NULL && binding->npc_event[0] &&
  9600. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  9601. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  9602. {
  9603. // Check if self or character invoking; if self == character invoked, then self invoke.
  9604. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  9605. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  9606. return true;
  9607. }
  9608. }
  9609.  
  9610. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9611. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  9612. if (info == NULL) {
  9613. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  9614. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9615. clif_displaymessage(fd, output);
  9616. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  9617. return true;
  9618. } else
  9619. return false;
  9620. }
  9621.  
  9622. //check restriction
  9623. if(info->restriction){
  9624. if(info->restriction&1 && type == 2) //console prevent
  9625. return true;
  9626. if(info->restriction&2 && (type == 0 || type == 3) ) //scripts prevent
  9627. return true;
  9628. }
  9629.  
  9630. // type == 1 : player invoked
  9631. if (type == 1) {
  9632. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  9633. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  9634. return false;
  9635. }
  9636. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9637. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9638. return true;
  9639. }
  9640. }
  9641.  
  9642. // Check if target is valid only if confirmed that player can use command.
  9643. if (*message == charcommand_symbol &&
  9644. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  9645. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  9646. clif_displaymessage(fd, output);
  9647. return true;
  9648. }
  9649.  
  9650. //Attempt to use the command
  9651. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  9652. {
  9653. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9654. clif_displaymessage(fd, output);
  9655. return true;
  9656. }
  9657.  
  9658. //Log only if successful.
  9659. if ( *atcmd_msg == atcommand_symbol )
  9660. log_atcommand(sd, atcmd_msg);
  9661. else if ( *atcmd_msg == charcommand_symbol )
  9662. log_atcommand(sd, message);
  9663.  
  9664. return true;
  9665. }
  9666.  
  9667. /*==========================================
  9668. *
  9669. *------------------------------------------*/
  9670. static void atcommand_config_read(const char* config_filename)
  9671. {
  9672. config_setting_t *aliases = NULL, *help = NULL;
  9673. const char *symbol = NULL;
  9674. int num_aliases = 0;
  9675.  
  9676. if (conf_read_file(&atcommand_config, config_filename))
  9677. return;
  9678.  
  9679. // Command symbols
  9680. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  9681. if (ISPRINT(*symbol) && // no control characters
  9682. *symbol != '/' && // symbol of client commands
  9683. *symbol != '%' && // symbol of party chat
  9684. *symbol != '$' && // symbol of guild chat
  9685. *symbol != charcommand_symbol)
  9686. atcommand_symbol = *symbol;
  9687. }
  9688.  
  9689. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  9690. if (ISPRINT(*symbol) && // no control characters
  9691. *symbol != '/' && // symbol of client commands
  9692. *symbol != '%' && // symbol of party chat
  9693. *symbol != '$' && // symbol of guild chat
  9694. *symbol != atcommand_symbol)
  9695. charcommand_symbol = *symbol;
  9696. }
  9697.  
  9698. // Command aliases
  9699. aliases = config_lookup(&atcommand_config, "aliases");
  9700. if (aliases != NULL) {
  9701. int i = 0;
  9702. int count = config_setting_length(aliases);
  9703.  
  9704. for (i = 0; i < count; ++i) {
  9705. config_setting_t *command;
  9706. const char *commandname = NULL;
  9707. int j = 0, alias_count = 0;
  9708. AtCommandInfo *commandinfo = NULL;
  9709.  
  9710. command = config_setting_get_elem(aliases, i);
  9711. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  9712. continue;
  9713. commandname = config_setting_name(command);
  9714. if (!atcommand_exists(commandname)) {
  9715. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  9716. continue;
  9717. }
  9718. commandinfo = get_atcommandinfo_byname(commandname);
  9719. alias_count = config_setting_length(command);
  9720. for (j = 0; j < alias_count; ++j) {
  9721. const char *alias = config_setting_get_string_elem(command, j);
  9722. if (alias != NULL) {
  9723. AliasInfo *alias_info;
  9724. if (strdb_exists(atcommand_alias_db, alias)) {
  9725. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  9726. continue;
  9727. }
  9728. CREATE(alias_info, AliasInfo, 1);
  9729. alias_info->command = commandinfo;
  9730. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  9731. strdb_put(atcommand_alias_db, alias, alias_info);
  9732. ++num_aliases;
  9733. }
  9734. }
  9735. }
  9736. }
  9737.  
  9738. // Commands help
  9739. // We only check if all commands exist
  9740. help = config_lookup(&atcommand_config, "help");
  9741. if (help != NULL) {
  9742. int count = config_setting_length(help);
  9743. int i;
  9744.  
  9745. for (i = 0; i < count; ++i) {
  9746. config_setting_t *command;
  9747. const char *commandname;
  9748.  
  9749. command = config_setting_get_elem(help, i);
  9750. commandname = config_setting_name(command);
  9751. if (!atcommand_exists(commandname))
  9752. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  9753. }
  9754. }
  9755.  
  9756. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  9757. return;
  9758. }
  9759. void atcommand_db_load_groups(int* group_ids) {
  9760. DBIterator *iter = db_iterator(atcommand_db);
  9761. AtCommandInfo* cmd;
  9762. int i;
  9763.  
  9764. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  9765. cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
  9766. cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
  9767. for(i = 0; i < pc_group_max; i++) {
  9768. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  9769. cmd->at_groups[i] = 1;
  9770. else
  9771. cmd->at_groups[i] = 0;
  9772. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  9773. cmd->char_groups[i] = 1;
  9774. else
  9775. cmd->char_groups[i] = 0;
  9776. }
  9777. }
  9778.  
  9779. dbi_destroy(iter);
  9780.  
  9781. return;
  9782. }
  9783. void atcommand_db_clear(void) {
  9784.  
  9785. if (atcommand_db != NULL) {
  9786. DBIterator *iter = db_iterator(atcommand_db);
  9787. AtCommandInfo* cmd;
  9788.  
  9789. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  9790. aFree(cmd->at_groups);
  9791. aFree(cmd->char_groups);
  9792. }
  9793.  
  9794. dbi_destroy(iter);
  9795.  
  9796. db_destroy(atcommand_db);
  9797. }
  9798. if (atcommand_alias_db != NULL)
  9799. db_destroy(atcommand_alias_db);
  9800.  
  9801. config_destroy(&atcommand_config);
  9802. }
  9803.  
  9804. void atcommand_doload(void) {
  9805. atcommand_db_clear();
  9806. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  9807. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  9808. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9809. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  9810. }
  9811.  
  9812. void do_init_atcommand(void) {
  9813. atcommand_doload();
  9814. }
  9815.  
  9816. void do_final_atcommand(void) {
  9817. atcommand_db_clear();
  9818. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement