// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "../common/cbasetypes.h"
#include "../common/mmo.h"
#include "../common/timer.h"
#include "../common/nullpo.h"
#include "../common/core.h"
#include "../common/showmsg.h"
#include "../common/malloc.h"
#include "../common/socket.h"
#include "../common/strlib.h"
#include "../common/utils.h"
#include "atcommand.h"
#include "battle.h"
#include "battleground.h"
#include "chat.h"
#include "channel.h"
#include "clif.h"
#include "chrif.h"
#include "duel.h"
#include "intif.h"
#include "itemdb.h"
#include "log.h"
#include "map.h"
#include "pc.h"
#include "status.h"
#include "skill.h"
#include "mob.h"
#include "npc.h"
#include "pet.h"
#include "homunculus.h"
#include "mercenary.h"
#include "elemental.h"
#include "party.h"
#include "guild.h"
#include "script.h"
#include "storage.h"
#include "trade.h"
#include "unit.h"
#include "achievement.h"
#ifndef TXT_ONLY
#include "mail.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
// extern variables
char atcommand_symbol = '@'; // first char of the commands
char charcommand_symbol = '#';
char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
// local declarations
#define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
typedef struct AtCommandInfo
{
const char* command;
int level;
int level2;
int premium;
AtCommandFunc func;
} AtCommandInfo;
static AtCommandInfo* get_atcommandinfo_byname(const char* name);
static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func);
static bool premium_usage = false;
ACMD_FUNC(commands);
/*=========================================
* Generic variables
*-----------------------------------------*/
char atcmd_output[CHAT_SIZE_MAX];
char atcmd_player_name[NAME_LENGTH];
char atcmd_temp[100];
// compare function for sorting high to lowest
int hightolow_compare (const void * a, const void * b)
{
return ( *(int*)b - *(int*)a );
}
// compare function for sorting lowest to highest
int lowtohigh_compare (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
//-----------------------------------------------------------
// Return the message string of the specified number by [Yor]
//-----------------------------------------------------------
const char* msg_txt(int msg_number)
{
if (msg_number >= 0 && msg_number < MAX_MSG &&
msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
return msg_table[msg_number];
return "??";
}
//-----------------------------------------------------------
// Returns Players title (from msg_athena.conf) [Lupus]
//-----------------------------------------------------------
static char* player_title_txt(int level)
{
const char* format;
format = (level >= battle_config.title_lvl8) ? msg_txt(332)
: (level >= battle_config.title_lvl7) ? msg_txt(331)
: (level >= battle_config.title_lvl6) ? msg_txt(330)
: (level >= battle_config.title_lvl5) ? msg_txt(329)
: (level >= battle_config.title_lvl4) ? msg_txt(328)
: (level >= battle_config.title_lvl3) ? msg_txt(327)
: (level >= battle_config.title_lvl2) ? msg_txt(326)
: (level >= battle_config.title_lvl1) ? msg_txt(325)
: "";
sprintf(atcmd_temp, format, level);
return atcmd_temp;
}
/*==========================================
* Read Message Data
*------------------------------------------*/
int msg_config_read(const char* cfgName)
{
int msg_number;
char line[1024], w1[1024], w2[1024];
FILE *fp;
static int called = 1;
if ((fp = fopen(cfgName, "r")) == NULL) {
ShowError("Messages file not found: %s\n", cfgName);
return 1;
}
if ((--called) == 0)
memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
while(fgets(line, sizeof(line), fp))
{
if (line[0] == '/' && line[1] == '/')
continue;
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
continue;
if (strcmpi(w1, "import") == 0)
msg_config_read(w2);
else
{
msg_number = atoi(w1);
if (msg_number >= 0 && msg_number < MAX_MSG)
{
if (msg_table[msg_number] != NULL)
aFree(msg_table[msg_number]);
msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
strcpy(msg_table[msg_number],w2);
}
}
}
fclose(fp);
return 0;
}
/*==========================================
* Cleanup Message Data
*------------------------------------------*/
void do_final_msg(void)
{
int i;
for (i = 0; i < MAX_MSG; i++)
aFree(msg_table[i]);
}
/*==========================================
* @send (used for testing packet sends from the client)
*------------------------------------------*/
ACMD_FUNC(send)
{
int len=0,off,end,type;
long num;
(void)command; // not used
// read message type as hex number (without the 0x)
if(!message || !*message ||
!((sscanf(message, "len %x", &type)==1 && (len=1))
|| sscanf(message, "%x", &type)==1) )
{
clif_displaymessage(fd, "Usage:");
clif_displaymessage(fd, " @send len <packet hex number>");
clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
return -1;
}
#define PARSE_ERROR(error,p) \
{\
clif_displaymessage(fd, (error));\
sprintf(atcmd_output, ">%s", (p));\
clif_displaymessage(fd, atcmd_output);\
}
//define PARSE_ERROR
#define CHECK_EOS(p) \
if(*(p) == 0){\
clif_displaymessage(fd, "Unexpected end of string");\
return -1;\
}
//define CHECK_EOS
#define SKIP_VALUE(p) \
{\
while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
}
//define SKIP_VALUE
#define GET_VALUE(p,num) \
{\
if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
PARSE_ERROR("Invalid number in:",(p));\
return -1;\
}\
}
//define GET_VALUE
if (type > 0 && type < MAX_PACKET_DB) {
if(len)
{// show packet length
sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
clif_displaymessage(fd, atcmd_output);
return 0;
}
len=packet_db[sd->packet_ver][type].len;
off=2;
if(len == 0)
{// unknown packet - ERROR
sprintf(atcmd_output, "Unknown packet: 0x%x", type);
clif_displaymessage(fd, atcmd_output);
return -1;
} else if(len == -1)
{// dynamic packet
len=SHRT_MAX-4; // maximum length
off=4;
}
WFIFOHEAD(fd, len);
WFIFOW(fd,0)=TOW(type);
// parse packet contents
SKIP_VALUE(message);
while(*message != 0 && off < len){
if(ISDIGIT(*message) || *message == '-' || *message == '+')
{// default (byte)
GET_VALUE(message,num);
WFIFOB(fd,off)=TOB(num);
++off;
} else if(TOUPPER(*message) == 'B')
{// byte
++message;
GET_VALUE(message,num);
WFIFOB(fd,off)=TOB(num);
++off;
} else if(TOUPPER(*message) == 'W')
{// word (2 bytes)
++message;
GET_VALUE(message,num);
WFIFOW(fd,off)=TOW(num);
off+=2;
} else if(TOUPPER(*message) == 'L')
{// long word (4 bytes)
++message;
GET_VALUE(message,num);
WFIFOL(fd,off)=TOL(num);
off+=4;
} else if(TOUPPER(*message) == 'S')
{// string - escapes are valid
// get string length - num <= 0 means not fixed length (default)
++message;
if(*message == '"'){
num=0;
} else {
GET_VALUE(message,num);
while(*message != '"')
{// find start of string
if(*message == 0 || ISSPACE(*message)){
PARSE_ERROR("Not a string:",message);
return -1;
}
++message;
}
}
// parse string
++message;
CHECK_EOS(message);
end=(num<=0? 0: min(off+((int)num),len));
for(; *message != '"' && (off < end || end == 0); ++off){
if(*message == '\\'){
++message;
CHECK_EOS(message);
switch(*message){
case 'a': num=0x07; break; // Bell
case 'b': num=0x08; break; // Backspace
case 't': num=0x09; break; // Horizontal tab
case 'n': num=0x0A; break; // Line feed
case 'v': num=0x0B; break; // Vertical tab
case 'f': num=0x0C; break; // Form feed
case 'r': num=0x0D; break; // Carriage return
case 'e': num=0x1B; break; // Escape
default: num=*message; break;
case 'x': // Hexadecimal
{
++message;
CHECK_EOS(message);
if(!ISXDIGIT(*message)){
PARSE_ERROR("Not a hexadecimal digit:",message);
return -1;
}
num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
if(ISXDIGIT(*message)){
++message;
CHECK_EOS(message);
num<<=8;
num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
}
WFIFOB(fd,off)=TOB(num);
++message;
CHECK_EOS(message);
continue;
}
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7': // Octal
{
num=*message-'0'; // 1st octal digit
++message;
CHECK_EOS(message);
if(ISDIGIT(*message) && *message < '8'){
num<<=3;
num+=*message-'0'; // 2nd octal digit
++message;
CHECK_EOS(message);
if(ISDIGIT(*message) && *message < '8'){
num<<=3;
num+=*message-'0'; // 3rd octal digit
++message;
CHECK_EOS(message);
}
}
WFIFOB(fd,off)=TOB(num);
continue;
}
}
} else
num=*message;
WFIFOB(fd,off)=TOB(num);
++message;
CHECK_EOS(message);
}//for
while(*message != '"')
{// ignore extra characters
++message;
CHECK_EOS(message);
}
// terminate the string
if(off < end)
{// fill the rest with 0's
memset(WFIFOP(fd,off),0,end-off);
off=end;
}
} else
{// unknown
PARSE_ERROR("Unknown type of value in:",message);
return -1;
}
SKIP_VALUE(message);
}
if(packet_db[sd->packet_ver][type].len == -1)
{// send dynamic packet
WFIFOW(fd,2)=TOW(off);
WFIFOSET(fd,off);
} else
{// send static packet
if(off < len)
memset(WFIFOP(fd,off),0,len-off);
WFIFOSET(fd,len);
}
} else {
clif_displaymessage(fd, msg_txt(259)); // Invalid packet
return -1;
}
sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
clif_displaymessage(fd, atcmd_output);
return 0;
#undef PARSE_ERROR
#undef CHECK_EOS
#undef SKIP_VALUE
#undef GET_VALUE
}
/*==========================================
* @rura, @warp, @mapmove
*------------------------------------------*/
ACMD_FUNC(mapmove)
{
char map_name[MAP_NAME_LENGTH_EXT];
unsigned short mapindex;
short x = 0, y = 0;
int m = -1;
nullpo_retr(-1, sd);
memset(map_name, '\0', sizeof(map_name));
if (!message || !*message ||
(sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
return -1;
}
if( battle_config.pvpmode_nowarp_cmd && sd->state.pvpmode )
{
clif_displaymessage(sd->fd,"You can not use @go while on PVP Mode.");
return -1;
}
mapindex = mapindex_name2id(map_name);
if (mapindex)
m = map_mapindex2mapid(mapindex);
if (!mapindex) { // m < 0 means on different server! [Kevin]
clif_displaymessage(fd, msg_txt(1)); // Map not found.
return -1;
}
if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
{ //This is to prevent the pc_setpos call from printing an error.
clif_displaymessage(fd, msg_txt(2));
if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
x = y = 0; //Invalid cell, use random spot.
}
if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, msg_txt(247));
return -1;
}
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, msg_txt(248));
return -1;
}
if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
clif_displaymessage(fd, msg_txt(1)); // Map not found.
return -1;
}
clif_displaymessage(fd, msg_txt(0)); // Warped.
return 0;
}
/*==========================================
* Displays where a character is. Corrected version by Silent. [Skotlex]
*------------------------------------------*/
ACMD_FUNC(where)
{
struct map_session_data* pl_sd;
nullpo_retr(-1, sd);
memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
return -1;
}
pl_sd = map_nick2sd(atcmd_player_name);
if( pl_sd == NULL
|| strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
|| (battle_config.hide_GM_session && pc_isGM(sd) < pc_isGM(pl_sd) && !(battle_config.who_display_aid && pc_isGM(sd) >= battle_config.who_display_aid))
) {
clif_displaymessage(fd, msg_txt(3)); // Character not found.
return -1;
}
snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
clif_displaymessage(fd, atcmd_output);
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(jumpto)
{
struct map_session_data *pl_sd = NULL;
nullpo_retr(-1, sd);
if (!message || !*message) {
clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
return -1;
}
if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
{
clif_displaymessage(fd, msg_txt(3)); // Character not found.
return -1;
}
if (pl_sd == sd)
{
clif_displaymessage(fd, "But you are already where you are...");
return -1;
}
if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
return -1;
}
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
{
clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
return -1;
}
if( pc_isdead(sd) )
{
clif_displaymessage(fd, "You cannot use this command when dead.");
return -1;
}
pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
clif_displaymessage(fd, atcmd_output);
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(jump)
{
short x = 0, y = 0;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
sscanf(message, "%hd %hd", &x, &y);
if (map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
return -1;
}
if( pc_isdead(sd) )
{
clif_displaymessage(fd, "You cannot use this command when dead.");
return -1;
}
if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
{ //This is to prevent the pc_setpos call from printing an error.
clif_displaymessage(fd, msg_txt(2));
if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
x = y = 0; //Invalid cell, use random spot.
}
pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
clif_displaymessage(fd, atcmd_output);
return 0;
}
/*==========================================
* @who3 = Player name, his location
*------------------------------------------*/
ACMD_FUNC(who3)
{
char temp0[100];
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
int j, count;
int pl_GM_level, GM_level;
char match_text[100];
char player_name[NAME_LENGTH];
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(match_text, '\0', sizeof(match_text));
memset(player_name, '\0', sizeof(player_name));
if (sscanf(message, "%99[^\n]", match_text) < 1)
strcpy(match_text, "");
for (j = 0; match_text[j]; j++)
match_text[j] = TOLOWER(match_text[j]);
count = 0;
GM_level = pc_isGM(sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
pl_GM_level = pc_isGM(pl_sd);
if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
{// you can look only lower or same level
memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
for (j = 0; player_name[j]; j++)
player_name[j] = TOLOWER(player_name[j]);
if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
} else {
atcmd_output[0]=0;
}
//Player name
sprintf(temp0, msg_txt(333), pl_sd->status.name);
strcat(atcmd_output,temp0);
//Player title, if exists
if (pl_GM_level > 0) {
//sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
strcat(atcmd_output,temp0);
}
//Players Location: map x y
sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
strcat(atcmd_output,temp0);
clif_displaymessage(fd, atcmd_output);
count++;
}
}
}
mapit_free(iter);
if (count == 0)
clif_displaymessage(fd, msg_txt(28)); // No player found.
else if (count == 1)
clif_displaymessage(fd, msg_txt(29)); // 1 player found.
else {
sprintf(atcmd_output, msg_txt(30), count); // %d players found.
clif_displaymessage(fd, atcmd_output);
}
return 0;
}
/*==========================================
* Player name, BLevel, Job,
*------------------------------------------*/
ACMD_FUNC(who2)
{
char temp0[100];
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
int j, count;
int pl_GM_level, GM_level;
char match_text[100];
char player_name[NAME_LENGTH];
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(match_text, '\0', sizeof(match_text));
memset(player_name, '\0', sizeof(player_name));
if (sscanf(message, "%99[^\n]", match_text) < 1)
strcpy(match_text, "");
for (j = 0; match_text[j]; j++)
match_text[j] = TOLOWER(match_text[j]);
count = 0;
GM_level = pc_isGM(sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
pl_GM_level = pc_isGM(pl_sd);
if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
{// you can look only lower or same level
memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
for (j = 0; player_name[j]; j++)
player_name[j] = TOLOWER(player_name[j]);
if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
//Players Name
//sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
//Player title, if exists
if (pl_GM_level > 0) {
//sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
strcat(atcmd_output,temp0);
}
//Players Base Level / Job name
//sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
strcat(atcmd_output,temp0);
clif_displaymessage(fd, atcmd_output);
count++;
}
}
}
mapit_free(iter);
if (count == 0)
clif_displaymessage(fd, msg_txt(28)); // No player found.
else if (count == 1)
clif_displaymessage(fd, msg_txt(29)); // 1 player found.
else {
sprintf(atcmd_output, msg_txt(30), count); // %d players found.
clif_displaymessage(fd, atcmd_output);
}
return 0;
}
/*==========================================
* Player name, Playrs Party / Guild name
*------------------------------------------*/
ACMD_FUNC(who)
{
char temp0[100];
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
int j, count;
int pl_GM_level, GM_level;
char match_text[100];
char player_name[NAME_LENGTH];
struct guild *g;
struct party_data *p;
nullpo_retr(-1, sd);
memset(temp0, '\0', sizeof(temp0));
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(match_text, '\0', sizeof(match_text));
memset(player_name, '\0', sizeof(player_name));
if (sscanf(message, "%99[^\n]", match_text) < 1)
strcpy(match_text, "");
for (j = 0; match_text[j]; j++)
match_text[j] = TOLOWER(match_text[j]);
count = 0;
GM_level = pc_isGM(sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
pl_GM_level = pc_isGM(pl_sd);
if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
{// you can look only lower or same level
memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
for (j = 0; player_name[j]; j++)
player_name[j] = TOLOWER(player_name[j]);
if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
g = guild_search(pl_sd->status.guild_id);
p = party_search(pl_sd->status.party_id);
//Players Name
sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
//Player title, if exists
if (pl_GM_level > 0) {
sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
strcat(atcmd_output,temp0);
}
//Players Party if exists
if (p != NULL) {
//sprintf(temp0," | Party: '%s'", p->name);
sprintf(temp0, msg_txt(335), p->party.name);
strcat(atcmd_output,temp0);
}
//Players Guild if exists
if (g != NULL) {
//sprintf(temp0," | Guild: '%s'", g->name);
sprintf(temp0, msg_txt(336), g->name);
strcat(atcmd_output,temp0);
}
clif_displaymessage(fd, atcmd_output);
count++;
}
}
}
mapit_free(iter);
if (count == 0)
clif_displaymessage(fd, msg_txt(28)); // No player found.
else if (count == 1)
clif_displaymessage(fd, msg_txt(29)); // 1 player found.
else {
sprintf(atcmd_output, msg_txt(30), count); // %d players found.
clif_displaymessage(fd, atcmd_output);
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(whomap3)
{
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
int count;
int pl_GM_level, GM_level;
int map_id;
char map_name[MAP_NAME_LENGTH_EXT];
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(map_name, '\0', sizeof(map_name));
if (!message || !*message)
map_id = sd->bl.m;
else {
sscanf(message, "%15s", map_name);
if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
count = 0;
GM_level = pc_isGM(sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
pl_GM_level = pc_isGM(pl_sd);
if( pl_sd->bl.m != map_id )
continue;
if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
continue;
if (pl_GM_level > 0)
sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
else
sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
clif_displaymessage(fd, atcmd_output);
count++;
}
mapit_free(iter);
if (count == 0)
sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
else if (count == 1)
sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
else {
sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
}
clif_displaymessage(fd, atcmd_output);
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(whomap2)
{
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
int count;
int pl_GM_level, GM_level;
int map_id = 0;
char map_name[MAP_NAME_LENGTH_EXT];
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(map_name, '\0', sizeof(map_name));
if (!message || !*message)
map_id = sd->bl.m;
else {
sscanf(message, "%15s", map_name);
if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
count = 0;
GM_level = pc_isGM(sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
pl_GM_level = pc_isGM(pl_sd);
if( pl_sd->bl.m != map_id )
continue;
if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
continue;
if (pl_GM_level > 0)
sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
else
sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
clif_displaymessage(fd, atcmd_output);
count++;
}
mapit_free(iter);
if (count == 0)
sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
else if (count == 1)
sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
else {
sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
}
clif_displaymessage(fd, atcmd_output);
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(whomap)
{
char temp0[100];
char temp1[100];
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
int count;
int pl_GM_level, GM_level;
int map_id = 0;
char map_name[MAP_NAME_LENGTH_EXT];
struct guild *g;
struct party_data *p;
nullpo_retr(-1, sd);
memset(temp0, '\0', sizeof(temp0));
memset(temp1, '\0', sizeof(temp1));
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(map_name, '\0', sizeof(map_name));
if (!message || !*message)
map_id = sd->bl.m;
else {
sscanf(message, "%15s", map_name);
if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
count = 0;
GM_level = pc_isGM(sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
pl_GM_level = pc_isGM(pl_sd);
if( pl_sd->bl.m != map_id )
continue;
if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
continue;
g = guild_search(pl_sd->status.guild_id);
if (g == NULL)
sprintf(temp1, "None");
else
sprintf(temp1, "%s", g->name);
p = party_search(pl_sd->status.party_id);
if (p == NULL)
sprintf(temp0, "None");
else
sprintf(temp0, "%s", p->party.name);
if (pl_GM_level > 0)
sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
else
sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
clif_displaymessage(fd, atcmd_output);
count++;
}
mapit_free(iter);
if (count == 0)
sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
else if (count == 1)
sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
else {
sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
}
clif_displaymessage(fd, atcmd_output);
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(whogm)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
int j, count;
int pl_GM_level, GM_level;
char match_text[CHAT_SIZE_MAX];
char player_name[NAME_LENGTH];
struct guild *g;
struct party_data *p;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(match_text, '\0', sizeof(match_text));
memset(player_name, '\0', sizeof(player_name));
if (sscanf(message, "%199[^\n]", match_text) < 1)
strcpy(match_text, "");
for (j = 0; match_text[j]; j++)
match_text[j] = TOLOWER(match_text[j]);
count = 0;
GM_level = pc_isGM(sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
pl_GM_level = pc_isGM(pl_sd);
if (!pl_GM_level)
continue;
if (match_text[0])
{
memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
for (j = 0; player_name[j]; j++)
player_name[j] = TOLOWER(player_name[j]);
// search with no case sensitive
if (strstr(player_name, match_text) == NULL)
continue;
}
if (pl_GM_level > GM_level) {
if (pl_sd->sc.option & OPTION_INVISIBLE)
continue;
sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
clif_displaymessage(fd, atcmd_output);
count++;
continue;
}
sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
pl_sd->status.name, pl_GM_level,
mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
pl_sd->status.base_level,
job_name(pl_sd->status.class_), pl_sd->status.job_level);
clif_displaymessage(fd, atcmd_output);
p = party_search(pl_sd->status.party_id);
g = guild_search(pl_sd->status.guild_id);
sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
p?p->party.name:"None", g?g->name:"None");
clif_displaymessage(fd, atcmd_output);
count++;
}
mapit_free(iter);
if (count == 0)
clif_displaymessage(fd, msg_txt(150)); // No GM found.
else if (count == 1)
clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
else {
sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
clif_displaymessage(fd, atcmd_output);
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(save)
{
nullpo_retr(-1, sd);
pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
if (sd->status.pet_id > 0 && sd->pd)
intif_save_petdata(sd->status.account_id, &sd->pd->pet);
chrif_save(sd,0);
clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(load)
{
int m;
nullpo_retr(-1, sd);
m = map_mapindex2mapid(sd->status.save_point.map);
if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
return -1;
}
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
return -1;
}
pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(speed)
{
int speed;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
clif_displaymessage(fd, atcmd_output);
return -1;
}
sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
status_calc_bl(&sd->bl, SCB_SPEED);
clif_displaymessage(fd, msg_txt(8)); // Speed changed.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(storage)
{
nullpo_retr(-1, sd);
if( sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag )
return -1;
if( premium_usage && map_flag_gvg(sd->bl.m) )
return -1;
if (storage_storageopen(sd) == 1)
{ //Already open.
clif_displaymessage(fd, msg_txt(250));
return -1;
}
clif_displaymessage(fd, "Storage opened.");
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(guildstorage)
{
nullpo_retr(-1, sd);
if (!sd->status.guild_id) {
clif_displaymessage(fd, msg_txt(252));
return -1;
}
if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
return -1;
if (sd->state.storage_flag == 1 || sd->state.storage_flag == 3) {
clif_displaymessage(fd, msg_txt(250));
return -1;
}
if (sd->state.storage_flag == 2) {
clif_displaymessage(fd, msg_txt(251));
return -1;
}
storage_guild_storageopen(sd);
clif_displaymessage(fd, "Guild storage opened.");
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(option)
{
int param1 = 0, param2 = 0, param3 = 0;
nullpo_retr(-1, sd);
if (!message || !*message || sscanf(message, "%d %d %d", ¶m1, ¶m2, ¶m3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
return -1;
}
sd->sc.opt1 = param1;
sd->sc.opt2 = param2;
pc_setoption(sd, param3);
clif_displaymessage(fd, msg_txt(9)); // Options changed.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(hide)
{
nullpo_retr(-1, sd);
if (sd->sc.option & OPTION_INVISIBLE) {
sd->sc.option &= ~OPTION_INVISIBLE;
if (sd->disguise)
status_set_viewdata(&sd->bl, sd->disguise);
else
status_set_viewdata(&sd->bl, sd->status.class_);
clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
} else {
sd->sc.option |= OPTION_INVISIBLE;
sd->vd.class_ = INVISIBLE_CLASS;
clif_displaymessage(fd, msg_txt(11)); // Invisible: On
}
clif_changeoption(&sd->bl);
return 0;
}
/*==========================================
* Changes a character's class
*------------------------------------------*/
ACMD_FUNC(jobchange)
{
//FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
int job = 0, upper = 0;
nullpo_retr(-1, sd);
if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
{
int i, found = 0;
const struct { char name[16]; int id; } jobs[] = {
{ "novice", 0 },
{ "swordsman", 1 },
{ "mage", 2 },
{ "archer", 3 },
{ "acolyte", 4 },
{ "merchant", 5 },
{ "thief", 6 },
{ "knight", 7 },
{ "priest", 8 },
{ "priestess", 8 },
{ "wizard", 9 },
{ "blacksmith", 10 },
{ "hunter", 11 },
{ "assassin", 12 },
{ "crusader", 14 },
{ "monk", 15 },
{ "sage", 16 },
{ "rogue", 17 },
{ "alchemist", 18 },
{ "bard", 19 },
{ "dancer", 20 },
{ "super novice", 23 },
{ "supernovice", 23 },
{ "gunslinger", 24 },
{ "gunner", 24 },
{ "ninja", 25 },
{ "high novice", 4001 },
{ "swordsman high", 4002 },
{ "mage high", 4003 },
{ "archer high", 4004 },
{ "acolyte high", 4005 },
{ "merchant high", 4006 },
{ "thief high", 4007 },
{ "lord knight", 4008 },
{ "high priest", 4009 },
{ "high priestess", 4009 },
{ "high wizard", 4010 },
{ "whitesmith", 4011 },
{ "sniper", 4012 },
{ "assassin cross", 4013 },
{ "paladin", 4015 },
{ "champion", 4016 },
{ "professor", 4017 },
{ "stalker", 4018 },
{ "creator", 4019 },
{ "clown", 4020 },
{ "gypsy", 4021 },
{ "baby novice", 4023 },
{ "baby swordsman", 4024 },
{ "baby mage", 4025 },
{ "baby archer", 4026 },
{ "baby acolyte", 4027 },
{ "baby merchant", 4028 },
{ "baby thief", 4029 },
{ "baby knight", 4030 },
{ "baby priest", 4031 },
{ "baby priestess", 4031 },
{ "baby wizard", 4032 },
{ "baby blacksmith",4033 },
{ "baby hunter", 4034 },
{ "baby assassin", 4035 },
{ "baby crusader", 4037 },
{ "baby monk", 4038 },
{ "baby sage", 4039 },
{ "baby rogue", 4040 },
{ "baby alchemist", 4041 },
{ "baby bard", 4042 },
{ "baby dancer", 4043 },
{ "super baby", 4045 },
{ "taekwon", 4046 },
{ "taekwon boy", 4046 },
{ "taekwon girl", 4046 },
{ "star gladiator", 4047 },
{ "soul linker", 4049 },
{ "gangsi", 4050 },
{ "bongun", 4050 },
{ "munak", 4050 },
{ "death knight", 4051 },
{ "dark collector", 4052 },
{ "rune knight", 4054 },
{ "warlock", 4055 },
{ "ranger", 4056 },
{ "arch bishop", 4057 },
{ "mechanic", 4058 },
{ "guillotine", 4059 },
{ "rune knight2", 4060 },
{ "warlock2", 4061 },
{ "ranger2", 4062 },
{ "arch bishop2", 4063 },
{ "mechanic2", 4064 },
{ "guillotine2", 4065 },
{ "royal guard", 4066 },
{ "sorcerer", 4067 },
{ "minstrel", 4068 },
{ "wanderer", 4069 },
{ "sura", 4070 },
{ "genetic", 4071 },
{ "shadow chaser", 4072 },
{ "royal guard2", 4073 },
{ "sorcerer2", 4074 },
{ "minstrel2", 4075 },
{ "wanderer2", 4076 },
{ "sura2", 4077 },
{ "genetic2", 4078 },
{ "shadow chaser2", 4079 },
{ "baby rune", 4096 },
{ "baby warlock", 4097 },
{ "baby ranger", 4098 },
{ "baby bishop", 4099 },
{ "baby mechanic", 4100 },
{ "baby cross", 4101 },
{ "baby guard", 4102 },
{ "baby sorcerer", 4103 },
{ "baby minstrel", 4104 },
{ "baby wanderer", 4105 },
{ "baby sura", 4106 },
{ "baby genetic", 4107 },
{ "baby chaser", 4108 },
{ "super novice e", 4190 },
{ "super baby e", 4191 },
{ "kagerou", 4211 },
{ "oboro", 4212 },
};
for (i=0; i < ARRAYLENGTH(jobs); i++) {
if (strncmpi(message, jobs[i].name, 16) == 0) {
job = jobs[i].id;
upper = 0;
found = 1;
break;
}
}
if (!found) {
clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
clif_displaymessage(fd, "----- Novice / 1st Class -----");
clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
clif_displaymessage(fd, "----- 2nd Class -----");
clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
clif_displaymessage(fd, " 20 Dancer");
clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
clif_displaymessage(fd, "4021 Gypsy");
clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
clif_displaymessage(fd, "4072 Shadow Chaser");
clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
clif_displaymessage(fd, "4079 Shadow Chaser");
clif_displaymessage(fd, "----- Expanded Class -----");
clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 4046 Taekwon");
clif_displaymessage(fd, "4047 Star Gladiator 4049 Soul Linker 4050 Gangsi 4051 Death Knight");
clif_displaymessage(fd, "4052 Dark Collector 4190 Extended Super Novice 4191 Extended Super Baby");
clif_displaymessage(fd, "4211 Kagerou 4212 Oboro");
clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
clif_displaymessage(fd, "4045 Super Baby");
clif_displaymessage(fd, "---- 3rd Baby Class ----");
clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
clif_displaymessage(fd, "4108 Baby Shadow Chaser");
clif_displaymessage(fd, "---- Modes, And Others ----");
clif_displaymessage(fd, " 22 Wedding 26 Christmas");
clif_displaymessage(fd, " 27 Summer 4048 Star Gladiator (Union)");
clif_displaymessage(fd, "---- Mounts (Not Allowed) ----");
clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco)");
clif_displaymessage(fd, "4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4080 Rune Knight (Dragon)");
clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
return -1;
}
}
switch( job )
{
case 13: case 21: case 4014: case 4022: case 4036:
case 4044: case 4080: case 4081: case 4082: case 4083:
case 4084: case 4085: case 4086: case 4087: case 4109:
case 4110: case 4111: case 4112:
return 0; // Deny direct transformation into dummy jobs
}
if (pcdb_checkid(job))
{
if (pc_jobchange(sd, job, upper) == 0)
clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
else {
clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
return -1;
}
} else {
clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job name/ID>).");
clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
clif_displaymessage(fd, "----- 2nd Class -----");
clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
clif_displaymessage(fd, " 20 Dancer");
clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
clif_displaymessage(fd, "4021 Gypsy");
clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
clif_displaymessage(fd, "4072 Shadow Chaser");
clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
clif_displaymessage(fd, "4079 Shadow Chaser");
clif_displaymessage(fd, "----- Expanded Class -----");
clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 4046 Taekwon");
clif_displaymessage(fd, "4047 Star Gladiator 4049 Soul Linker 4050 Gangsi 4051 Death Knight");
clif_displaymessage(fd, "4052 Dark Collector 4190 Extended Super Novice 4191 Extended Super Baby");
clif_displaymessage(fd, "4211 Kagerou 4212 Oboro");
clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
clif_displaymessage(fd, "4045 Super Baby");
clif_displaymessage(fd, "---- 3rd Baby Class ----");
clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
clif_displaymessage(fd, "4108 Baby Shadow Chaser");
clif_displaymessage(fd, "---- Modes, And Others ----");
clif_displaymessage(fd, " 22 Wedding 26 Christmas");
clif_displaymessage(fd, " 27 Summer 4048 Star Gladiator (Union)");
clif_displaymessage(fd, "---- Mounts (Not Allowed) ----");
clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco)");
clif_displaymessage(fd, "4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4080 Rune Knight (Dragon)");
clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
return -1;
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(die)
{
nullpo_retr(-1, sd);
clif_specialeffect(&sd->bl,450,SELF);
status_kill(&sd->bl);
clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(kill)
{
struct map_session_data *pl_sd;
nullpo_retr(-1, sd);
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message) {
clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
return -1;
}
if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
{
clif_displaymessage(fd, msg_txt(3)); // Character not found.
return -1;
}
if (pc_isGM(sd) < pc_isGM(pl_sd))
{ // you can kill only lower or same level
clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
return -1;
}
status_kill(&pl_sd->bl);
clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
if (fd != pl_sd->fd)
clif_displaymessage(fd, msg_txt(14)); // Character killed.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(alive)
{
nullpo_retr(-1, sd);
if (!status_revive(&sd->bl, 100, 100))
{
clif_displaymessage(fd, "You're not dead.");
return -1;
}
clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
return 0;
}
/*==========================================
* +kamic [LuzZza]
*------------------------------------------*/
ACMD_FUNC(kami)
{
unsigned long color=0;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
if(*(command + 5) != 'c' && *(command + 5) != 'C') {
if (!message || !*message) {
clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
return -1;
}
sscanf(message, "%199[^\n]", atcmd_output);
intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
} else {
if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
return -1;
}
if(color > 0xFFFFFF) {
clif_displaymessage(fd, "Invalid color.");
return -1;
}
intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(heal)
{
int hp = 0, sp = 0; // [Valaris] thanks to fov
nullpo_retr(-1, sd);
sscanf(message, "%d %d", &hp, &sp);
// some overflow checks
if( hp == INT_MIN ) hp++;
if( sp == INT_MIN ) sp++;
if ( hp == 0 && sp == 0 ) {
if (!status_percent_heal(&sd->bl, 100, 100))
clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
else
clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
return 0;
}
if ( hp > 0 && sp >= 0 ) {
if(!status_heal(&sd->bl, hp, sp, 0))
clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
else
clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
return 0;
}
if ( hp < 0 && sp <= 0 ) {
status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
return 0;
}
//Opposing signs.
if ( hp ) {
if (hp > 0)
status_heal(&sd->bl, hp, 0, 0);
else {
status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
}
}
if ( sp ) {
if (sp > 0)
status_heal(&sd->bl, 0, sp, 0);
else
status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
}
clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
return 0;
}
/*==========================================
* @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
*------------------------------------------*/
ACMD_FUNC(item)
{
char item_name[100];
int number = 0, item_id, flag, type = 0;
struct item item_tmp;
struct item_data *item_data;
int get_count, i;
nullpo_retr(-1, sd);
memset(item_name, '\0', sizeof(item_name));
if (!message || !*message || (
sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
sscanf(message, "%99s %d", item_name, &number) < 1
)) {
clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
return -1;
}
if (number <= 0)
number = 1;
if ((item_data = itemdb_searchname(item_name)) == NULL &&
(item_data = itemdb_exists(atoi(item_name))) == NULL)
{
clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
return -1;
}
if( !strcmpi(command+1,"bounditem") )
type = 1;
else if( !strcmpi(command+1,"costumeitem") )
{
if( !battle_config.costume_reserved_char_id )
{
clif_displaymessage(fd, "Costume convertion is disable. Set a value for costume_reserved_char_id on your eAmod.conf file.");
return -1;
}
if( !(item_data->equip&EQP_HEAD_LOW) &&
!(item_data->equip&EQP_HEAD_MID) &&
!(item_data->equip&EQP_HEAD_TOP) &&
!(item_data->equip&EQP_COS_HEAD_LOW) &&
!(item_data->equip&EQP_COS_HEAD_MID) &&
!(item_data->equip&EQP_COS_HEAD_TOP) )
{
clif_displaymessage(fd, "You cannot costume this item. Costume only work for headgears");
return -1;
}
type = 2;
}
item_id = item_data->nameid;
get_count = number;
//Check if it's stackable.
if( !itemdb_isstackable2(item_data) )
{
if( type == 1 && (item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) )
{
clif_displaymessage(fd, "Cannot create bounded pet eggs or pet armors.");
return -1;
}
get_count = 1;
}
else if( type == 1 )
{
clif_displaymessage(fd, "Cannot create bounded stackable items.");
return -1;
}
for( i = 0; i < number; i += get_count )
{
// if not pet egg
if( !pet_create_egg(sd, item_id) )
{
memset(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = item_id;
item_tmp.identify = 1;
if( type == 1 )
item_tmp.bound = 1;
else if( type == 2 )
{ // Costume Item
item_tmp.card[0] = CARD0_CREATE;
item_tmp.card[2] = GetWord(battle_config.costume_reserved_char_id, 0);
item_tmp.card[3] = GetWord(battle_config.costume_reserved_char_id, 1);
}
if( (flag = pc_additem(sd, &item_tmp, get_count)) )
clif_additem(sd, 0, 0, flag);
}
//Logs (A)dmins items [Lupus]
log_pick_pc(sd, LOG_TYPE_COMMAND, item_id, get_count, NULL, item_tmp.serial);
item_tmp.serial = 0;
}
clif_displaymessage(fd, msg_txt(18)); // Item created.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(item2)
{
struct item item_tmp;
struct item_data *item_data;
char item_name[100];
int item_id, number = 0;
int identify = 0, refine = 0, attr = 0;
int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
int flag, bound = 0;
int loop, get_count, i;
nullpo_retr(-1, sd);
memset(item_name, '\0', sizeof(item_name));
if (!message || !*message || (
sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
)) {
clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
return -1;
}
if (number <= 0)
number = 1;
item_id = 0;
if ((item_data = itemdb_searchname(item_name)) != NULL ||
(item_data = itemdb_exists(atoi(item_name))) != NULL)
item_id = item_data->nameid;
if( item_id > 500 )
{
if( !strcmpi(command+1,"bounditem2") )
bound = 1;
if( !itemdb_isstackable2(item_data) )
{
if( bound && (item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) )
{
clif_displaymessage(fd, "Cannot create bounded pet eggs or pet armors.");
return -1;
}
loop = number;
get_count = 1;
if( item_data->type == IT_PETEGG )
{
identify = 1;
refine = 0;
}
if( item_data->type == IT_PETARMOR )
refine = 0;
if( refine > MAX_REFINE )
refine = MAX_REFINE;
}
else
{
if( bound )
{
clif_displaymessage(fd, "Cannot create bounded stackable items.");
return -1;
}
loop = 1;
get_count = number;
identify = 1;
refine = attr = 0;
}
for( i = 0; i < loop; i++ )
{
memset(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = item_id;
item_tmp.identify = identify;
item_tmp.refine = refine;
item_tmp.attribute = attr;
item_tmp.card[0] = c1;
item_tmp.card[1] = c2;
item_tmp.card[2] = c3;
item_tmp.card[3] = c4;
item_tmp.bound = bound;
if( (flag = pc_additem(sd, &item_tmp, get_count)) )
clif_additem(sd, 0, 0, flag);
//Logs (A)dmins items [Lupus]
log_pick_pc(sd, LOG_TYPE_COMMAND, item_tmp.nameid, number, &item_tmp, item_tmp.serial);
item_tmp.serial = 0;
}
clif_displaymessage(fd, msg_txt(18)); // Item created.
}
else
{
clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
return -1;
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(itemreset)
{
int i;
nullpo_retr(-1, sd);
for (i = 0; i < MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
//Logs (A)dmins items [Lupus]
log_pick_pc(sd, LOG_TYPE_COMMAND, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i], sd->status.inventory[i].serial );
pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0);
}
}
clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
return 0;
}
/*==========================================
* Atcommand @lvlup
*------------------------------------------*/
ACMD_FUNC(baselevelup)
{
int level=0, i=0, status_point=0;
nullpo_retr(-1, sd);
level = atoi(message);
if (!message || !*message || !level) {
clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
return -1;
}
if (level > 0) {
if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
return -1;
} // End Addition
if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
level = pc_maxbaselv(sd) - sd->status.base_level;
for (i = 0; i < level; i++)
status_point += pc_gets_status_point(sd->status.base_level + i);
sd->status.status_point += status_point;
sd->status.base_level += (unsigned int)level;
status_percent_heal(&sd->bl, 100, 100);
clif_misceffect(&sd->bl, 0);
clif_displaymessage(fd, msg_txt(21)); // Base level raised.
} else {
if (sd->status.base_level == 1) {
clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
return -1;
}
level*=-1;
if ((unsigned int)level >= sd->status.base_level)
level = sd->status.base_level-1;
for (i = 0; i > -level; i--)
status_point += pc_gets_status_point(sd->status.base_level + i - 1);
if (sd->status.status_point < status_point)
pc_resetstate(sd);
if (sd->status.status_point < status_point)
sd->status.status_point = 0;
else
sd->status.status_point -= status_point;
sd->status.base_level -= (unsigned int)level;
clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
}
sd->status.base_exp = 0;
clif_updatestatus(sd, SP_STATUSPOINT);
clif_updatestatus(sd, SP_BASELEVEL);
clif_updatestatus(sd, SP_BASEEXP);
clif_updatestatus(sd, SP_NEXTBASEEXP);
status_calc_pc(sd, 0);
if(sd->status.party_id)
party_send_levelup(sd);
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(joblevelup)
{
int level=0;
nullpo_retr(-1, sd);
level = atoi(message);
if (!message || !*message || !level) {
clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
return -1;
}
if (level > 0) {
if (sd->status.job_level == pc_maxjoblv(sd)) {
clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
return -1;
}
if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
level = pc_maxjoblv(sd) - sd->status.job_level;
sd->status.job_level += (unsigned int)level;
sd->status.skill_point += level;
clif_misceffect(&sd->bl, 1);
clif_displaymessage(fd, msg_txt(24)); // Job level raised.
} else {
if (sd->status.job_level == 1) {
clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
return -1;
}
level *=-1;
if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
level = sd->status.job_level-1;
sd->status.job_level -= (unsigned int)level;
if (sd->status.skill_point < level)
pc_resetskill(sd,0); //Reset skills since we need to substract more points.
if (sd->status.skill_point < level)
sd->status.skill_point = 0;
else
sd->status.skill_point -= level;
clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
}
sd->status.job_exp = 0;
clif_updatestatus(sd, SP_JOBLEVEL);
clif_updatestatus(sd, SP_JOBEXP);
clif_updatestatus(sd, SP_NEXTJOBEXP);
clif_updatestatus(sd, SP_SKILLPOINT);
status_calc_pc(sd, 0);
return 0;
}
/*==========================================
* @help
*------------------------------------------*/
ACMD_FUNC(help)
{
char buf[2048], w1[2048], w2[2048];
int i, gm_level;
FILE* fp;
nullpo_retr(-1, sd);
memset(buf, '\0', sizeof(buf));
if ((fp = fopen(help_txt, "r")) != NULL) {
clif_displaymessage(fd, msg_txt(26)); // Help commands:
gm_level = pc_isGM(sd);
while(fgets(buf, sizeof(buf), fp) != NULL) {
if (buf[0] == '/' && buf[1] == '/')
continue;
for (i = 0; buf[i] != '\0'; i++) {
if (buf[i] == '\r' || buf[i] == '\n') {
buf[i] = '\0';
break;
}
}
if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
clif_displaymessage(fd, buf);
else if (gm_level >= atoi(w1))
clif_displaymessage(fd, w2);
}
fclose(fp);
} else {
clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
return -1;
}
return 0;
}
/*==========================================
* @help2 - Char commands [Kayla]
*------------------------------------------*/
ACMD_FUNC(help2)
{
char buf[2048], w1[2048], w2[2048];
int i, gm_level;
FILE* fp;
nullpo_retr(-1, sd);
memset(buf, '\0', sizeof(buf));
if ((fp = fopen(help2_txt, "r")) != NULL) {
clif_displaymessage(fd, msg_txt(26)); // Help commands:
gm_level = pc_isGM(sd);
while(fgets(buf, sizeof(buf), fp) != NULL) {
if (buf[0] == '/' && buf[1] == '/')
continue;
for (i = 0; buf[i] != '\0'; i++) {
if (buf[i] == '\r' || buf[i] == '\n') {
buf[i] = '\0';
break;
}
}
if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
clif_displaymessage(fd, buf);
else if (gm_level >= atoi(w1))
clif_displaymessage(fd, w2);
}
fclose(fp);
} else {
clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
return -1;
}
return 0;
}
// helper function, used in foreach calls to stop auto-attack timers
// parameter: '0' - everyone, 'id' - only those attacking someone with that id
static int atcommand_stopattack(struct block_list *bl,va_list ap)
{
struct unit_data *ud = unit_bl2ud(bl);
int id = va_arg(ap, int);
if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
{
unit_stop_attack(bl);
return 1;
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
{
TBL_PC* sd = (TBL_PC*)bl;
clif_pvpset(sd, 0, 0, 2);
if (sd->pvp_timer != INVALID_TIMER) {
delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
sd->pvp_timer = INVALID_TIMER;
}
return 0;
}
ACMD_FUNC(pvpoff)
{
nullpo_retr(-1, sd);
if (!map[sd->bl.m].flag.pvp) {
clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
return -1;
}
map[sd->bl.m].flag.pvp = 0;
if (!battle_config.pk_mode)
clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
return 0;
}
/*==========================================
*
*------------------------------------------*/
static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
{
TBL_PC* sd = (TBL_PC*)bl;
if (sd->state.pvpmode)
pc_pvpmodeoff(sd, 1, 1);
if (sd->pvp_timer == INVALID_TIMER) {
sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
sd->pvp_rank = 0;
sd->pvp_lastusers = 0;
sd->pvp_point = 5;
sd->pvp_won = 0;
sd->pvp_lost = 0;
}
return 0;
}
ACMD_FUNC(pvpon)
{
nullpo_retr(-1, sd);
if (map[sd->bl.m].flag.pvp) {
clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
return -1;
}
map[sd->bl.m].flag.pvp = 1;
if (!battle_config.pk_mode)
{// display pvp circle and rank
clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
}
clif_displaymessage(fd, msg_txt(32)); // PvP: On.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(gvgoff)
{
nullpo_retr(-1, sd);
if (!map[sd->bl.m].flag.gvg) {
clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
return -1;
}
map[sd->bl.m].flag.gvg = 0;
clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(gvgon)
{
nullpo_retr(-1, sd);
if (map[sd->bl.m].flag.gvg) {
clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
return -1;
}
map[sd->bl.m].flag.gvg = 1;
clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
clif_displaymessage(fd, msg_txt(34)); // GvG: On.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(model)
{
int hair_style = 0, hair_color = 0, cloth_color = 0;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
clif_displaymessage(fd, atcmd_output);
return -1;
}
if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
pc_changelook(sd, LOOK_HAIR, hair_style);
pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
} else {
clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
return -1;
}
return 0;
}
/*==========================================
* @dye && @ccolor
*------------------------------------------*/
ACMD_FUNC(dye)
{
int cloth_color = 0;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
clif_displaymessage(fd, atcmd_output);
return -1;
}
if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
} else {
clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
return -1;
}
return 0;
}
/*==========================================
* @hairstyle && @hstyle
*------------------------------------------*/
ACMD_FUNC(hair_style)
{
int hair_style = 0;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
clif_displaymessage(fd, atcmd_output);
return -1;
}
if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
pc_changelook(sd, LOOK_HAIR, hair_style);
clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
} else {
clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
return -1;
}
return 0;
}
/*==========================================
* @haircolor && @hcolor
*------------------------------------------*/
ACMD_FUNC(hair_color)
{
int hair_color = 0;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
clif_displaymessage(fd, atcmd_output);
return -1;
}
if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
} else {
clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
return -1;
}
return 0;
}
/*==========================================
* @go [city_number or city_name] - Updated by Harbin
*------------------------------------------*/
ACMD_FUNC(go)
{
int i;
int town;
char map_name[MAP_NAME_LENGTH];
int m;
const struct {
char map[MAP_NAME_LENGTH];
int x, y;
} data[] = {
{ MAP_PRONTERA, 156, 180 }, // 0=Prontera
{ MAP_MORROC, 156, 93 }, // 1=Morroc
{ MAP_GEFFEN, 119, 59 }, // 2=Geffen
{ MAP_PAYON, 162, 233 }, // 3=Payon
{ MAP_ALBERTA, 192, 147 }, // 4=Alberta
{ MAP_IZLUDE, 128, 114 }, // 5=Izlude
{ MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
{ MAP_LUTIE, 147, 134 }, // 7=Lutie
{ MAP_COMODO, 209, 143 }, // 8=Comodo
{ MAP_YUNO, 157, 51 }, // 9=Yuno
{ MAP_AMATSU, 198, 84 }, // 10=Amatsu
{ MAP_GONRYUN, 160, 120 }, // 11=Gonryun
{ MAP_UMBALA, 89, 157 }, // 12=Umbala
{ MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
{ MAP_LOUYANG, 217, 40 }, // 14=Louyang
{ MAP_NOVICE, 53, 111 }, // 15=Training Grounds
{ MAP_JAIL, 23, 61 }, // 16=Prison
{ MAP_JAWAII, 249, 127 }, // 17=Jawaii
{ MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
{ MAP_EINBROCH, 64, 200 }, // 19=Einbroch
{ MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
{ MAP_EINBECH, 70, 95 }, // 21=Einbech
{ MAP_HUGEL, 96, 145 }, // 22=Hugel
{ MAP_RACHEL, 130, 110 }, // 23=Rachel
{ MAP_VEINS, 216, 123 }, // 24=Veins
{ MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
};
nullpo_retr(-1, sd);
if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
clif_displaymessage(sd->fd,"You can not use @go on this map.");
return 0;
}
if( battle_config.pvpmode_nowarp_cmd && sd->state.pvpmode )
{
clif_displaymessage(sd->fd,"You can not use @go while on PVP Mode.");
return -1;
}
memset(map_name, '\0', sizeof(map_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
// get the number
town = atoi(message);
// if no value, display all value
if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
clif_displaymessage(fd, msg_txt(82)); // Please provide a name or number from the list provided:
clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
clif_displaymessage(fd, " 24=Veins 25=Moscovia");
return -1;
}
// get possible name of the city
map_name[MAP_NAME_LENGTH-1] = '\0';
for (i = 0; map_name[i]; i++)
map_name[i] = TOLOWER(map_name[i]);
// try to identify the map name
if (strncmp(map_name, "prontera", 3) == 0) {
town = 0;
} else if (strncmp(map_name, "morocc", 3) == 0) {
town = 1;
} else if (strncmp(map_name, "geffen", 3) == 0) {
town = 2;
} else if (strncmp(map_name, "payon", 3) == 0 ||
strncmp(map_name, "paion", 3) == 0) {
town = 3;
} else if (strncmp(map_name, "alberta", 3) == 0) {
town = 4;
} else if (strncmp(map_name, "izlude", 3) == 0 ||
strncmp(map_name, "islude", 3) == 0) {
town = 5;
} else if (strncmp(map_name, "aldebaran", 3) == 0 ||
strcmp(map_name, "al") == 0) {
town = 6;
} else if (strncmp(map_name, "lutie", 3) == 0 ||
strcmp(map_name, "christmas") == 0 ||
strncmp(map_name, "xmas", 3) == 0 ||
strncmp(map_name, "x-mas", 3) == 0) {
town = 7;
} else if (strncmp(map_name, "comodo", 3) == 0) {
town = 8;
} else if (strncmp(map_name, "yuno", 3) == 0) {
town = 9;
} else if (strncmp(map_name, "amatsu", 3) == 0) {
town = 10;
} else if (strncmp(map_name, "gonryun", 3) == 0) {
town = 11;
} else if (strncmp(map_name, "umbala", 3) == 0) {
town = 12;
} else if (strncmp(map_name, "niflheim", 3) == 0) {
town = 13;
} else if (strncmp(map_name, "louyang", 3) == 0) {
town = 14;
} else if (strncmp(map_name, "new_1-1", 3) == 0 ||
strncmp(map_name, "startpoint", 3) == 0 ||
strncmp(map_name, "begining", 3) == 0) {
town = 15;
} else if (strncmp(map_name, "sec_pri", 3) == 0 ||
strncmp(map_name, "prison", 3) == 0 ||
strncmp(map_name, "jails", 3) == 0) {
town = 16;
} else if (strncmp(map_name, "jawaii", 3) == 0 ||
strncmp(map_name, "jawai", 3) == 0) {
town = 17;
} else if (strncmp(map_name, "ayothaya", 3) == 0 ||
strncmp(map_name, "ayotaya", 3) == 0) {
town = 18;
} else if (strncmp(map_name, "einbroch", 5) == 0 ||
strncmp(map_name, "ainbroch", 5) == 0) {
town = 19;
} else if (strncmp(map_name, "lighthalzen", 3) == 0) {
town = 20;
} else if (strncmp(map_name, "einbech", 3) == 0) {
town = 21;
} else if (strncmp(map_name, "hugel", 3) == 0) {
town = 22;
} else if (strncmp(map_name, "rachel", 3) == 0) {
town = 23;
} else if (strncmp(map_name, "veins", 3) == 0) {
town = 24;
} else if (strncmp(map_name, "moscovia", 3) == 0) {
town = 25;
}
if (town >= 0 && town < ARRAYLENGTH(data))
{
m = map_mapname2mapid(data[town].map);
if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, msg_txt(247));
return -1;
}
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, msg_txt(248));
return -1;
}
if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
clif_displaymessage(fd, msg_txt(0)); // Warped.
} else {
clif_displaymessage(fd, msg_txt(1)); // Map not found.
return -1;
}
} else { // if you arrive here, you have an error in town variable when reading of names
clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
return -1;
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(monster)
{
char name[NAME_LENGTH];
char monster[NAME_LENGTH];
int mob_id;
int number = 0;
int count;
int i, k, range;
short mx, my;
nullpo_retr(-1, sd);
memset(name, '\0', sizeof(name));
memset(monster, '\0', sizeof(monster));
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message) {
clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
return -1;
}
if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
//All data can be left as it is.
} else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
//Here, it is possible name was not given and we are using monster for it.
if (count < 3) //Blank mob's name.
name[0] = '\0';
} else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
//All data can be left as it is.
} else if (sscanf(message, "%23s", monster) > 0) {
//As before, name may be already filled.
name[0] = '\0';
} else {
clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
return -1;
}
if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
mob_id = mobdb_checkid(atoi(monster));
if (mob_id == 0) {
clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
return -1;
}
if (mob_id == MOBID_EMPERIUM) {
clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
return -1;
}
if (number <= 0)
number = 1;
if( !name[0] )
strcpy(name, "--ja--");
// If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
number = battle_config.atc_spawn_quantity_limit;
if (battle_config.etc_log)
ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
count = 0;
range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
for (i = 0; i < number; i++) {
map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
count += (k != 0) ? 1 : 0;
}
if (count != 0)
if (number == count)
clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
else {
sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
clif_displaymessage(fd, atcmd_output);
}
else {
clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
return -1;
}
return 0;
}
// small monster spawning [Valaris]
ACMD_FUNC(monstersmall)
{
char name[NAME_LENGTH] = "";
char monster[NAME_LENGTH] = "";
int mob_id = 0;
int number = 0;
int x = 0;
int y = 0;
int count;
int i;
nullpo_retr(-1, sd);
if (!message || !*message) {
clif_displaymessage(fd, "Give a monster name/id please.");
return -1;
}
if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
clif_displaymessage(fd, "Give a monster name/id please.");
return -1;
}
// If monster identifier/name argument is a name
if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
mob_id = atoi(monster);
if (mob_id == 0) {
clif_displaymessage(fd, msg_txt(40));
return -1;
}
if (mob_id == MOBID_EMPERIUM) {
clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
return -1;
}
if (mobdb_checkid(mob_id) == 0) {
clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
return -1;
}
if (number <= 0)
number = 1;
if( !name[0] )
strcpy(name, "--ja--");
// If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
number = battle_config.atc_spawn_quantity_limit;
count = 0;
for (i = 0; i < number; i++) {
int mx, my;
if (x <= 0)
mx = sd->bl.x + (rand() % 11 - 5);
else
mx = x;
if (y <= 0)
my = sd->bl.y + (rand() % 11 - 5);
else
my = y;
count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
}
if (count != 0)
clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
else
clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
return 0;
}
// big monster spawning [Valaris]
ACMD_FUNC(monsterbig)
{
char name[NAME_LENGTH] = "";
char monster[NAME_LENGTH] = "";
int mob_id = 0;
int number = 0;
int x = 0;
int y = 0;
int count;
int i;
nullpo_retr(-1, sd);
if (!message || !*message) {
clif_displaymessage(fd, "Give a monster name/id please.");
return -1;
}
if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
clif_displaymessage(fd, "Give a monster name/id please.");
return -1;
}
// If monster identifier/name argument is a name
if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
mob_id = atoi(monster);
if (mob_id == 0) {
clif_displaymessage(fd, msg_txt(40));
return -1;
}
if (mob_id == MOBID_EMPERIUM) {
clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
return -1;
}
if (mobdb_checkid(mob_id) == 0) {
clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
return -1;
}
if (number <= 0)
number = 1;
if( !name[0] )
strcpy(name, "--ja--");
// If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
number = battle_config.atc_spawn_quantity_limit;
count = 0;
for (i = 0; i < number; i++) {
int mx, my;
if (x <= 0)
mx = sd->bl.x + (rand() % 11 - 5);
else
mx = x;
if (y <= 0)
my = sd->bl.y + (rand() % 11 - 5);
else
my = y;
count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
}
if (count != 0)
clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
else
clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
return 0;
}
/*==========================================
*
*------------------------------------------*/
static int atkillmonster_sub(struct block_list *bl, va_list ap)
{
struct mob_data *md;
int flag;
nullpo_ret(md=(struct mob_data *)bl);
flag = va_arg(ap, int);
if (md->guardian_data)
return 0; //Do not touch WoE mobs!
if (flag)
status_zap(bl,md->status.hp, 0);
else
status_kill(bl);
return 1;
}
void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
{
int map_id;
char map_name[MAP_NAME_LENGTH_EXT];
if (!sd) return;
memset(map_name, '\0', sizeof(map_name));
if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
map_id = sd->bl.m;
else {
if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
return;
}
ACMD_FUNC(killmonster)
{
atcommand_killmonster_sub(fd, sd, message, 1);
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(killmonster2)
{
atcommand_killmonster_sub(fd, sd, message, 0);
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(refine)
{
int i,j, position = 0, refine = 0, current_position, final_refine;
int count;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
clif_displaymessage(fd, atcmd_output);
return -1;
}
refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
count = 0;
for (j = 0; j < EQI_MAX_BONUS; j++) {
if ((i = sd->equip_index[j]) < 0)
continue;
if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
continue;
if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
continue;
if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
continue;
if(position && !(sd->status.inventory[i].equip & position))
continue;
final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
if (sd->status.inventory[i].refine != final_refine) {
sd->status.inventory[i].refine = final_refine;
current_position = sd->status.inventory[i].equip;
pc_unequipitem(sd, i, 3);
clif_refine(fd, 0, i, sd->status.inventory[i].refine);
clif_delitem(sd, i, 1, 3);
clif_additem(sd, i, 1, 0);
pc_equipitem(sd, i, current_position);
clif_misceffect(&sd->bl, 3);
count++;
}
}
if (count == 0)
clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
else if (count == 1)
clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
else {
sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
clif_displaymessage(fd, atcmd_output);
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(produce)
{
char item_name[100];
int item_id, attribute = 0, star = 0;
int flag = 0;
struct item_data *item_data;
struct item tmp_item;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(item_name, '\0', sizeof(item_name));
if (!message || !*message || (
sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
)) {
clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
return -1;
}
item_id = 0;
if ((item_data = itemdb_searchname(item_name)) == NULL &&
(item_data = itemdb_exists(atoi(item_name))) == NULL)
{
clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
return -1;
}
item_id = item_data->nameid;
if (itemdb_isequip2(item_data)) {
if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
attribute = ATTRIBUTE_NORMAL;
if (star < MIN_STAR || star > MAX_STAR)
star = 0;
memset(&tmp_item, 0, sizeof tmp_item);
tmp_item.nameid = item_id;
tmp_item.amount = 1;
tmp_item.identify = 1;
tmp_item.card[0] = CARD0_FORGE;
tmp_item.card[1] = item_data->type==IT_WEAPON?
((star*5) << 8) + attribute:0;
tmp_item.card[2] = GetWord(sd->status.char_id, 0);
tmp_item.card[3] = GetWord(sd->status.char_id, 1);
clif_produceeffect(sd, 0, item_id);
clif_misceffect(&sd->bl, 3);
if ((flag = pc_additem(sd, &tmp_item, 1)))
clif_additem(sd, 0, 0, flag);
//Logs (A)dmins items [Lupus]
log_pick_pc(sd, LOG_TYPE_COMMAND, tmp_item.nameid, 1, &tmp_item, tmp_item.serial);
} else {
sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
clif_displaymessage(fd, atcmd_output);
return -1;
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(memo)
{
int position = 0;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
if( !message || !*message || sscanf(message, "%d", &position) < 1 )
{
int i;
clif_displaymessage(sd->fd, "Your actual memo positions are:");
for( i = 0; i < MAX_MEMOPOINTS; i++ )
{
if( sd->status.memo_point[i].map )
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);
else
sprintf(atcmd_output, msg_txt(171), i); // %d - void
clif_displaymessage(sd->fd, atcmd_output);
}
return 0;
}
if( position < 0 || position >= MAX_MEMOPOINTS )
{
sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
clif_displaymessage(fd, atcmd_output);
return -1;
}
pc_memo(sd, position);
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(gat)
{
int y;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
for (y = 2; y >= -2; y--) {
sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
clif_displaymessage(fd, atcmd_output);
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(displaystatus)
{
int i, type, flag, tick, val1, val2, val3;
nullpo_retr(-1, sd);
if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> <val1> <val2> <val3>).");
return -1;
}
if (i < 2) flag = 1;
if (i < 3) tick = 0;
clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
return 0;
}
/*==========================================
* @stpoint (Rewritten by [Yor])
*------------------------------------------*/
ACMD_FUNC(statuspoint)
{
int point;
unsigned int new_status_point;
if (!message || !*message || (point = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
return -1;
}
if(point < 0)
{
if(sd->status.status_point < (unsigned int)(-point))
{
new_status_point = 0;
}
else
{
new_status_point = sd->status.status_point + point;
}
}
else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
{
new_status_point = UINT_MAX;
}
else
{
new_status_point = sd->status.status_point + point;
}
if (new_status_point != sd->status.status_point) {
sd->status.status_point = new_status_point;
clif_updatestatus(sd, SP_STATUSPOINT);
clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
} else {
if (point < 0)
clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
else
clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
return -1;
}
return 0;
}
/*==========================================
* @skpoint (Rewritten by [Yor])
*------------------------------------------*/
ACMD_FUNC(skillpoint)
{
int point;
unsigned int new_skill_point;
nullpo_retr(-1, sd);
if (!message || !*message || (point = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
return -1;
}
if(point < 0)
{
if(sd->status.skill_point < (unsigned int)(-point))
{
new_skill_point = 0;
}
else
{
new_skill_point = sd->status.skill_point + point;
}
}
else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
{
new_skill_point = UINT_MAX;
}
else
{
new_skill_point = sd->status.skill_point + point;
}
if (new_skill_point != sd->status.skill_point) {
sd->status.skill_point = new_skill_point;
clif_updatestatus(sd, SP_SKILLPOINT);
clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
} else {
if (point < 0)
clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
else
clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
return -1;
}
return 0;
}
/*==========================================
* @zeny (Rewritten by [Yor])
*------------------------------------------*/
ACMD_FUNC(zeny)
{
int zeny, new_zeny;
nullpo_retr(-1, sd);
if (!message || !*message || (zeny = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
return -1;
}
new_zeny = sd->status.zeny + zeny;
if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
new_zeny = MAX_ZENY;
else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
new_zeny = 0;
if (new_zeny != sd->status.zeny) {
sd->status.zeny = new_zeny;
clif_updatestatus(sd, SP_ZENY);
clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
} else {
if (zeny < 0)
clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
else
clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
return -1;
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(param)
{
int i, value = 0, new_value;
const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
short* status[6];
//we don't use direct initialization because it isn't part of the c standard.
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
clif_displaymessage(fd, atcmd_output);
return -1;
}
ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
clif_displaymessage(fd, atcmd_output);
return -1;
}
status[0] = &sd->status.str;
status[1] = &sd->status.agi;
status[2] = &sd->status.vit;
status[3] = &sd->status.int_;
status[4] = &sd->status.dex;
status[5] = &sd->status.luk;
if(value < 0 && *status[i] <= -value)
{
new_value = 1;
}
else if(SHRT_MAX - *status[i] < value)
{
new_value = SHRT_MAX;
}
else
{
new_value = *status[i] + value;
}
if (new_value != *status[i]) {
*status[i] = new_value;
clif_updatestatus(sd, SP_STR + i);
clif_updatestatus(sd, SP_USTR + i);
status_calc_pc(sd, 0);
clif_displaymessage(fd, msg_txt(42)); // Stat changed.
} else {
if (value < 0)
clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
else
clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
return -1;
}
return 0;
}
/*==========================================
* Stat all by fritz (rewritten by [Yor])
*------------------------------------------*/
ACMD_FUNC(stat_all)
{
int index, count, value, max, new_value;
short* status[6];
//we don't use direct initialization because it isn't part of the c standard.
nullpo_retr(-1, sd);
status[0] = &sd->status.str;
status[1] = &sd->status.agi;
status[2] = &sd->status.vit;
status[3] = &sd->status.int_;
status[4] = &sd->status.dex;
status[5] = &sd->status.luk;
if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
value = pc_maxparameter(sd);
max = pc_maxparameter(sd);
} else {
max = SHRT_MAX;
}
count = 0;
for (index = 0; index < ARRAYLENGTH(status); index++) {
if (value > 0 && *status[index] > max - value)
new_value = max;
else if (value < 0 && *status[index] <= -value)
new_value = 1;
else
new_value = *status[index] +value;
if (new_value != (int)*status[index]) {
*status[index] = new_value;
clif_updatestatus(sd, SP_STR + index);
clif_updatestatus(sd, SP_USTR + index);
count++;
}
}
if (count > 0) { // if at least 1 stat modified
status_calc_pc(sd, 0);
clif_displaymessage(fd, msg_txt(84)); // All stats changed!
} else {
if (value < 0)
clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
else
clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
return -1;
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(guildlevelup)
{
int level = 0;
short added_level;
struct guild *guild_info;
nullpo_retr(-1, sd);
if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
return -1;
}
if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
return -1;
}
//if (strcmp(sd->status.name, guild_info->master) != 0) {
// clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
// return -1;
//}
added_level = (short)level;
if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
added_level = 1 - guild_info->guild_lv;
if (added_level != 0) {
intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
} else {
clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
return -1;
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(makeegg)
{
struct item_data *item_data;
int id, pet_id;
nullpo_retr(-1, sd);
if (!message || !*message) {
clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
return -1;
}
if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
id = item_data->nameid;
else
if ((id = mobdb_searchname(message)) != 0) // for monster name
;
else
id = atoi(message);
pet_id = search_petDB_index(id, PET_CLASS);
if (pet_id < 0)
pet_id = search_petDB_index(id, PET_EGG);
if (pet_id >= 0) {
sd->catch_target_class = pet_db[pet_id].class_;
intif_create_pet(
sd->status.account_id, sd->status.char_id,
(short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
(short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
100, 0, 1, pet_db[pet_id].jname);
} else {
clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
return -1;
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(hatch)
{
nullpo_retr(-1, sd);
if (sd->status.pet_id <= 0)
clif_sendegg(sd);
else {
clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
return -1;
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(petfriendly)
{
int friendly;
struct pet_data *pd;
nullpo_retr(-1, sd);
if (!message || !*message || (friendly = atoi(message)) < 0) {
clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
return -1;
}
pd = sd->pd;
if (!pd) {
clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
return -1;
}
if (friendly < 0 || friendly > 1000)
{
clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
return -1;
}
if (friendly == pd->pet.intimate) {
clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
return -1;
}
pet_set_intimate(pd, friendly);
clif_send_petstatus(sd);
clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(pethungry)
{
int hungry;
struct pet_data *pd;
nullpo_retr(-1, sd);
if (!message || !*message || (hungry = atoi(message)) < 0) {
clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
return -1;
}
pd = sd->pd;
if (!sd->status.pet_id || !pd) {
clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
return -1;
}
if (hungry < 0 || hungry > 100) {
clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
return -1;
}
if (hungry == pd->pet.hungry) {
clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
return -1;
}
pd->pet.hungry = hungry;
clif_send_petstatus(sd);
clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(petrename)
{
struct pet_data *pd;
nullpo_retr(-1, sd);
if (!sd->status.pet_id || !sd->pd) {
clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
return -1;
}
pd = sd->pd;
if (!pd->pet.rename_flag) {
clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
return -1;
}
pd->pet.rename_flag = 0;
intif_save_petdata(sd->status.account_id, &pd->pet);
clif_send_petstatus(sd);
clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(recall)
{
struct map_session_data *pl_sd = NULL;
nullpo_retr(-1, sd);
if (!message || !*message) {
clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
return -1;
}
if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
{
clif_displaymessage(fd, msg_txt(3)); // Character not found.
return -1;
}
if (pl_sd == sd)
{
clif_displaymessage(fd, "You are already where you are...");
return -1;
}
if ( pc_isGM(sd) < pc_isGM(pl_sd) )
{
clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
return -1;
}
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
return -1;
}
if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
return -1;
}
pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
clif_displaymessage(fd, atcmd_output);
return 0;
}
/*==========================================
* charblock command (usage: charblock <player_name>)
* This command do a definitiv ban on a player
*------------------------------------------*/
ACMD_FUNC(char_block)
{
nullpo_retr(-1, sd);
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
return -1;
}
chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
return 0;
}
/*==========================================
* charban command (usage: charban <time> <player_name>)
* This command do a limited ban on a player
* Time is done as follows:
* Adjustment value (-1, 1, +1, etc...)
* Modified element:
* a or y: year
* m: month
* j or d: day
* h: hour
* mn: minute
* s: second
* <example> @ban +1m-2mn1s-6y test_player
* this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
*------------------------------------------*/
ACMD_FUNC(char_ban)
{
char * modif_p;
int year, month, day, hour, minute, second, value;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
return -1;
}
atcmd_output[sizeof(atcmd_output)-1] = '\0';
modif_p = atcmd_output;
year = month = day = hour = minute = second = 0;
while (modif_p[0] != '\0') {
value = atoi(modif_p);
if (value == 0)
modif_p++;
else {
if (modif_p[0] == '-' || modif_p[0] == '+')
modif_p++;
while (modif_p[0] >= '0' && modif_p[0] <= '9')
modif_p++;
if (modif_p[0] == 's') {
second = value;
modif_p++;
} else if (modif_p[0] == 'n') {
minute = value;
modif_p++;
} else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
minute = value;
modif_p = modif_p + 2;
} else if (modif_p[0] == 'h') {
hour = value;
modif_p++;
} else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
day = value;
modif_p++;
} else if (modif_p[0] == 'm') {
month = value;
modif_p++;
} else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
year = value;
modif_p++;
} else if (modif_p[0] != '\0') {
modif_p++;
}
}
}
if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
return -1;
}
chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
return 0;
}
/*==========================================
* charunblock command (usage: charunblock <player_name>)
*------------------------------------------*/
ACMD_FUNC(char_unblock)
{
nullpo_retr(-1, sd);
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
return -1;
}
// send answer to login server via char-server
chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
return 0;
}
/*==========================================
* charunban command (usage: charunban <player_name>)
*------------------------------------------*/
ACMD_FUNC(char_unban)
{
nullpo_retr(-1, sd);
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
return -1;
}
// send answer to login server via char-server
chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(night)
{
nullpo_retr(-1, sd);
if (night_flag != 1) {
map_night_timer(night_timer_tid, 0, 0, 1);
} else {
clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
return -1;
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(day)
{
nullpo_retr(-1, sd);
if (night_flag != 0) {
map_day_timer(day_timer_tid, 0, 0, 1);
} else {
clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
return -1;
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(doom)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
nullpo_retr(-1, sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
{
status_kill(&pl_sd->bl);
clif_specialeffect(&pl_sd->bl,450,AREA);
clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
}
}
mapit_free(iter);
clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(doommap)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
nullpo_retr(-1, sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
{
status_kill(&pl_sd->bl);
clif_specialeffect(&pl_sd->bl,450,AREA);
clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
}
}
mapit_free(iter);
clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
return 0;
}
/*==========================================
*
*------------------------------------------*/
static void atcommand_raise_sub(struct map_session_data* sd)
{
if (!status_isdead(&sd->bl))
return;
if(!status_revive(&sd->bl, 100, 100))
return;
clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(raise)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
nullpo_retr(-1, sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
atcommand_raise_sub(pl_sd);
mapit_free(iter);
clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(raisemap)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
nullpo_retr(-1, sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
if (sd->bl.m == pl_sd->bl.m)
atcommand_raise_sub(pl_sd);
mapit_free(iter);
clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(kick)
{
struct map_session_data *pl_sd;
nullpo_retr(-1, sd);
memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
if (!message || !*message) {
clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
return -1;
}
if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
{
clif_displaymessage(fd, msg_txt(3)); // Character not found.
return -1;
}
if ( pc_isGM(sd) < pc_isGM(pl_sd) )
{
clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
return -1;
}
clif_GM_kick(sd, pl_sd);
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(kickall)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
nullpo_retr(-1, sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
if (sd->status.account_id != pl_sd->status.account_id)
clif_GM_kick(NULL, pl_sd);
}
}
mapit_free(iter);
clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(allskill)
{
nullpo_retr(-1, sd);
pc_allskillup(sd); // all skills
sd->status.skill_point = 0; // 0 skill points
clif_updatestatus(sd, SP_SKILLPOINT); // update
clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(questskill)
{
int skill_id;
nullpo_retr(-1, sd);
if (!message || !*message || (skill_id = atoi(message)) < 0) {
clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
return -1;
}
if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
return -1;
}
if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
return -1;
}
if (pc_checkskill(sd, skill_id) > 0) {
clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
return -1;
}
pc_skill(sd, skill_id, 1, 0);
clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(lostskill)
{
int skill_id;
nullpo_retr(-1, sd);
if (!message || !*message || (skill_id = atoi(message)) < 0) {
clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
return -1;
}
if (skill_id < 0 && skill_id >= MAX_SKILL) {
clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
return -1;
}
if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
return -1;
}
if (pc_checkskill(sd, skill_id) == 0) {
clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
return -1;
}
sd->status.skill[skill_id].lv = 0;
sd->status.skill[skill_id].flag = 0;
clif_deleteskill(sd,skill_id);
clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(spiritball)
{
int max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
int number;
nullpo_retr(-1, sd);
if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
{
char msg[CHAT_SIZE_MAX];
safesnprintf(msg, sizeof(msg), "Usage: @spiritball <number: 0-%d>", max_spiritballs);
clif_displaymessage(fd, msg);
return -1;
}
if( sd->spiritball > 0 )
pc_delspiritball(sd, sd->spiritball, 1);
sd->spiritball = number;
clif_spiritball(sd);
// no message, player can look the difference
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(party)
{
char party[NAME_LENGTH];
nullpo_retr(-1, sd);
memset(party, '\0', sizeof(party));
if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
return -1;
}
party_create(sd, party, 0, 0);
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(guild)
{
char guild[NAME_LENGTH];
int prev;
nullpo_retr(-1, sd);
memset(guild, '\0', sizeof(guild));
if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
return -1;
}
prev = battle_config.guild_emperium_check;
battle_config.guild_emperium_check = 0;
guild_create(sd, guild);
battle_config.guild_emperium_check = prev;
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(agitstart)
{
int i;
nullpo_retr(-1, sd);
if( agit_flag != 0 )
{
clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
return -1;
}
if( (i = atoi(message)) > 0 )
woe_set = i;
agit_flag = 1;
guild_agit_start();
clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(agitend)
{
nullpo_retr(-1, sd);
if (agit_flag == 0) {
clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
return -1;
}
guild_agit_end();
agit_flag = 0;
woe_set = 0;
clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
return 0;
}
/*==========================================
* @mapexit - shuts down the map server
*------------------------------------------*/
ACMD_FUNC(mapexit)
{
nullpo_retr(-1, sd);
do_shutdown();
return 0;
}
/*==========================================
* idsearch <part_of_name>: revrited by [Yor]
*------------------------------------------*/
ACMD_FUNC(idsearch)
{
char item_name[100];
unsigned int i, match;
struct item_data *item_array[MAX_SEARCH];
nullpo_retr(-1, sd);
memset(item_name, '\0', sizeof(item_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
return -1;
}
sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
clif_displaymessage(fd, atcmd_output);
match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
if (match > MAX_SEARCH) {
sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
clif_displaymessage(fd, atcmd_output);
match = MAX_SEARCH;
}
for(i = 0; i < match; i++) {
sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
clif_displaymessage(fd, atcmd_output);
}
sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
clif_displaymessage(fd, atcmd_output);
return 0;
}
/*==========================================
* Recall All Characters Online To Your Location
*------------------------------------------*/
ACMD_FUNC(recallall)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
int count;
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
return -1;
}
count = 0;
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
if (sd->status.account_id != pl_sd->status.account_id && pc_isGM(sd) >= pc_isGM(pl_sd))
{
if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
count++;
else {
if (pc_isdead(pl_sd)) { //Wake them up
pc_setstand(pl_sd);
pc_setrestartvalue(pl_sd,1);
}
pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
}
}
}
mapit_free(iter);
clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
if (count) {
sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
clif_displaymessage(fd, atcmd_output);
}
return 0;
}
/*==========================================
* Recall online characters of a guild to your location
*------------------------------------------*/
ACMD_FUNC(guildrecall)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
int count;
char guild_name[NAME_LENGTH];
struct guild *g;
nullpo_retr(-1, sd);
memset(guild_name, '\0', sizeof(guild_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
return -1;
}
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
return -1;
}
if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
(g = guild_search(atoi(message))) == NULL)
{
clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
return -1;
}
count = 0;
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
{
if (pc_isGM(pl_sd) > pc_isGM(sd))
continue; //Skip GMs greater than you.
if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
count++;
else
pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
}
}
mapit_free(iter);
sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
clif_displaymessage(fd, atcmd_output);
if (count) {
sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
clif_displaymessage(fd, atcmd_output);
}
return 0;
}
/*==========================================
* Recall online characters of a party to your location
*------------------------------------------*/
ACMD_FUNC(partyrecall)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
char party_name[NAME_LENGTH];
struct party_data *p;
int count;
nullpo_retr(-1, sd);
memset(party_name, '\0', sizeof(party_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
return -1;
}
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
return -1;
}
if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
(p = party_search(atoi(message))) == NULL)
{
clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
return -1;
}
count = 0;
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
{
if (pc_isGM(pl_sd) > pc_isGM(sd))
continue; //Skip GMs greater than you.
if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
count++;
else
pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
}
}
mapit_free(iter);
sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
clif_displaymessage(fd, atcmd_output);
if (count) {
sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
clif_displaymessage(fd, atcmd_output);
}
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(reloaditemdb)
{
nullpo_retr(-1, sd);
itemdb_reload();
clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(reloadmobdb)
{
nullpo_retr(-1, sd);
mob_reload();
read_petdb();
merc_reload();
reload_elementaldb();
clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
return 0;
}
/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(reloadskilldb)
{
nullpo_retr(-1, sd);
skill_reload();
merc_skill_reload();
reload_elemental_skilldb();
clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
return 0;
}
/*==========================================
* @reloadatcommand - reloads atcommand_athena.conf
*------------------------------------------*/
ACMD_FUNC(reloadatcommand)
{
atcommand_config_read(ATCOMMAND_CONF_FILENAME);
clif_displaymessage(fd, msg_txt(254));
return 0;
}
/*==========================================
* @reloadbattleconf - reloads battle_athena.conf
*------------------------------------------*/
ACMD_FUNC(reloadbattleconf)
{
struct Battle_Config prev_config;
memcpy(&prev_config, &battle_config, sizeof(prev_config));
battle_config_read(BATTLE_CONF_FILENAME);
// It can cause serius problems if we change this setting while server is UP.
battle_config.renewal_system_enable = prev_config.renewal_system_enable;
battle_config.anti_mayapurple_hack = prev_config.anti_mayapurple_hack;
if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
|| prev_config.item_rate_common != battle_config.item_rate_common
|| prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
|| prev_config.item_rate_card != battle_config.item_rate_card
|| prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
|| prev_config.item_rate_equip != battle_config.item_rate_equip
|| prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
|| prev_config.item_rate_heal != battle_config.item_rate_heal
|| prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
|| prev_config.item_rate_use != battle_config.item_rate_use
|| prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
|| prev_config.item_rate_treasure != battle_config.item_rate_treasure
|| prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
|| prev_config.logarithmic_drops != battle_config.logarithmic_drops
|| prev_config.item_drop_common_min != battle_config.item_drop_common_min
|| prev_config.item_drop_common_max != battle_config.item_drop_common_max
|| prev_config.item_drop_card_min != battle_config.item_drop_card_min
|| prev_config.item_drop_card_max != battle_config.item_drop_card_max
|| prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
|| prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
|| prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
|| prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
|| prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
|| prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
|| prev_config.item_drop_use_min != battle_config.item_drop_use_min
|| prev_config.item_drop_use_max != battle_config.item_drop_use_max
|| prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
|| prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
|| prev_config.base_exp_rate != battle_config.base_exp_rate
|| prev_config.job_exp_rate != battle_config.job_exp_rate
)
{ // Exp or Drop rates changed.
mob_reload(); //Needed as well so rate changes take effect.
#ifndef TXT_ONLY
chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
#endif
}
clif_displaymessage(fd, msg_txt(255));
return 0;
}
/*==========================================
* @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
*------------------------------------------*/
ACMD_FUNC(reloadstatusdb)
{
status_readdb();
clif_displaymessage(fd, msg_txt(256));
return 0;
}
/*==========================================
* @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
*------------------------------------------*/
ACMD_FUNC(reloadpcdb)
{
pc_readdb();
clif_displaymessage(fd, msg_txt(257));
return 0;
}
/*==========================================
* @reloadmotd - reloads motd.txt
*------------------------------------------*/
ACMD_FUNC(reloadmotd)
{
pc_read_motd();
clif_displaymessage(fd, msg_txt(268));
return 0;
}
/*==========================================
* @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
*------------------------------------------*/
ACMD_FUNC(reloadscript)
{
nullpo_retr(-1, sd);
//atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
//atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
//atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
flush_fifos();
script_reload();
npc_reload();
clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
return 0;
}
/*==========================================
* @mapinfo [0-3] <map name> by MC_Cameri
* => Shows information about the map [map name]
* 0 = no additional information
* 1 = Show users in that map and their location
* 2 = Shows NPCs in that map
* 3 = Shows the shops/chats in that map (not implemented)
*------------------------------------------*/
ACMD_FUNC(mapinfo)
{
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
struct npc_data *nd = NULL;
struct chat_data *cd = NULL;
char direction[12];
int i, m_id, chat_num, list = 0;
unsigned short m_index;
char mapname[24];
nullpo_retr(-1, sd);
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(mapname, '\0', sizeof(mapname));
memset(direction, '\0', sizeof(direction));
sscanf(message, "%d %23[^\n]", &list, mapname);
if (list < 0 || list > 3) {
clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
return -1;
}
if (mapname[0] == '\0') {
safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
m_id = map_mapindex2mapid(sd->mapindex);
} else {
m_id = map_mapname2mapid(mapname);
}
if (m_id < 0) {
clif_displaymessage(fd, msg_txt(1)); // Map not found.
return -1;
}
m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
clif_displaymessage(fd, "------ Map Info ------");
// count chats (for initial message)
chat_num = 0;
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
chat_num++;
mapit_free(iter);
sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", mapname, map[m_id].users, map[m_id].npc_num, chat_num);
clif_displaymessage(fd, atcmd_output);
clif_displaymessage(fd, "------ Map Flags ------");
if (map[m_id].flag.town)
clif_displaymessage(fd, "Town Map");
if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
clif_displaymessage(fd, "Autotrade Enabled");
else
clif_displaymessage(fd, "Autotrade Disabled");
if (map[m_id].flag.battleground)
clif_displaymessage(fd, "Battlegrounds ON");
strcpy(atcmd_output,"PvP Flags: ");
if (map[m_id].flag.pvp)
strcat(atcmd_output, "Pvp ON | ");
if (map[m_id].flag.pvp_noguild)
strcat(atcmd_output, "NoGuild | ");
if (map[m_id].flag.pvp_noparty)
strcat(atcmd_output, "NoParty | ");
if (map[m_id].flag.pvp_nightmaredrop)
strcat(atcmd_output, "NightmareDrop | ");
if (map[m_id].flag.pvp_nocalcrank)
strcat(atcmd_output, "NoCalcRank | ");
clif_displaymessage(fd, atcmd_output);
if (map[m_id].flag.pvp_event)
{
sprintf(atcmd_output,"PVP Event Flag: x1 %d | x2 %d | y1 %d | y2 %d", map[m_id].pvpe_x1, map[m_id].pvpe_x2, map[m_id].pvpe_y1, map[m_id].pvpe_y2);
clif_displaymessage(fd, atcmd_output);
}
strcpy(atcmd_output,"GvG Flags: ");
if (map[m_id].flag.gvg)
strcat(atcmd_output, "GvG ON | ");
if (map[m_id].flag.gvg_dungeon)
strcat(atcmd_output, "GvG Dungeon | ");
if (map[m_id].flag.gvg_castle)
strcat(atcmd_output, "GvG Castle | ");
if (map[m_id].flag.gvg_noparty)
strcat(atcmd_output, "NoParty | ");
if (map[m_id].flag.woe_set)
{
char output[64];
sprintf(output,"WoE Set %d | ", map[m_id].flag.woe_set);
strcat(atcmd_output, output);
}
clif_displaymessage(fd, atcmd_output);
strcpy(atcmd_output,"Teleport Flags: ");
if (map[m_id].flag.noteleport)
strcat(atcmd_output, "NoTeleport | ");
if (map[m_id].flag.monster_noteleport)
strcat(atcmd_output, "Monster NoTeleport | ");
if (map[m_id].flag.nowarp)
strcat(atcmd_output, "NoWarp | ");
if (map[m_id].flag.nowarpto)
strcat(atcmd_output, "NoWarpTo | ");
if (map[m_id].flag.noreturn)
strcat(atcmd_output, "NoReturn | ");
if (map[m_id].flag.nogo)
strcat(atcmd_output, "NoGo | ");
if (map[m_id].flag.nomemo)
strcat(atcmd_output, "NoMemo | ");
if (map[m_id].flag.blocked)
strcat(atcmd_output, "Blocked | ");
clif_displaymessage(fd, atcmd_output);
sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
clif_displaymessage(fd, atcmd_output);
if (map[m_id].flag.nosave) {
if (!map[m_id].save.map)
sprintf(atcmd_output, "No Save (Return to last Save Point)");
else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
else
sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
clif_displaymessage(fd, atcmd_output);
}
strcpy(atcmd_output,"Weather Flags: ");
if (map[m_id].flag.snow)
strcat(atcmd_output, "Snow | ");
if (map[m_id].flag.fog)
strcat(atcmd_output, "Fog | ");
if (map[m_id].flag.sakura)
strcat(atcmd_output, "Sakura | ");
if (map[m_id].flag.clouds)
strcat(atcmd_output, "Clouds | ");
if (map[m_id].flag.clouds2)
strcat(atcmd_output, "Clouds2 | ");
if (map[m_id].flag.fireworks)
strcat(atcmd_output, "Fireworks | ");
if (map[m_id].flag.leaves)
strcat(atcmd_output, "Leaves | ");
if (map[m_id].flag.rain)
strcat(atcmd_output, "Rain | ");
if (map[m_id].flag.nightenabled)
strcat(atcmd_output, "Displays Night | ");
clif_displaymessage(fd, atcmd_output);
strcpy(atcmd_output,"Other Flags: ");
if (map[m_id].flag.nobranch)
strcat(atcmd_output, "NoBranch | ");
if (map[m_id].flag.notrade)
strcat(atcmd_output, "NoTrade | ");
if (map[m_id].flag.novending)
strcat(atcmd_output, "NoVending | ");
if (map[m_id].flag.nodrop)
strcat(atcmd_output, "NoDrop | ");
if (map[m_id].flag.noskill)
strcat(atcmd_output, "NoSkill | ");
if (map[m_id].flag.noicewall)
strcat(atcmd_output, "NoIcewall | ");
if (map[m_id].flag.allowks)
strcat(atcmd_output, "AllowKS | ");
if (map[m_id].flag.reset)
strcat(atcmd_output, "Reset | ");
clif_displaymessage(fd, atcmd_output);
strcpy(atcmd_output,"Other Flags: ");
if (map[m_id].nocommand)
strcat(atcmd_output, "NoCommand | ");
if (map[m_id].flag.nobaseexp)
strcat(atcmd_output, "NoBaseEXP | ");
if (map[m_id].flag.nojobexp)
strcat(atcmd_output, "NoJobEXP | ");
if (map[m_id].flag.nomobloot)
strcat(atcmd_output, "NoMobLoot | ");
if (map[m_id].flag.nomvploot)
strcat(atcmd_output, "NoMVPLoot | ");
if (map[m_id].flag.partylock)
strcat(atcmd_output, "PartyLock | ");
if (map[m_id].flag.guildlock)
strcat(atcmd_output, "GuildLock | ");
clif_displaymessage(fd, atcmd_output);
switch (list) {
case 0:
// Do nothing. It's list 0, no additional display.
break;
case 1:
clif_displaymessage(fd, "----- Players in Map -----");
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
if (pl_sd->mapindex == m_index) {
sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
clif_displaymessage(fd, atcmd_output);
}
}
mapit_free(iter);
break;
case 2:
clif_displaymessage(fd, "----- NPCs in Map -----");
for (i = 0; i < map[m_id].npc_num;)
{
nd = map[m_id].npc[i];
switch(nd->ud.dir) {
case 0: strcpy(direction, "North"); break;
case 1: strcpy(direction, "North West"); break;
case 2: strcpy(direction, "West"); break;
case 3: strcpy(direction, "South West"); break;
case 4: strcpy(direction, "South"); break;
case 5: strcpy(direction, "South East"); break;
case 6: strcpy(direction, "East"); break;
case 7: strcpy(direction, "North East"); break;
case 9: strcpy(direction, "North"); break;
default: strcpy(direction, "Unknown"); break;
}
sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
clif_displaymessage(fd, atcmd_output);
}
break;
case 3:
clif_displaymessage(fd, "----- Chats in Map -----");
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
pl_sd->mapindex == m_index &&
cd->usersd[0] == pl_sd)
{
sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
cd->title, pl_sd->status.name, cd->bl.x, cd->bl.