summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c203
1 files changed, 110 insertions, 93 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index d48dda0db..95b3dc33e 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -452,7 +452,7 @@ ACMD_FUNC(mapmove)
clif_displaymessage(fd, msg_txt(248));
return -1;
}
- if (pc_setpos(sd, mapindex, x, y, 3) != 0) {
+ if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
clif_displaymessage(fd, msg_txt(1)); // Map not found.
return -1;
}
@@ -535,7 +535,7 @@ ACMD_FUNC(jumpto)
return -1;
}
- pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
+ 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);
@@ -572,7 +572,7 @@ ACMD_FUNC(jump)
x = y = 0; //Invalid cell, use random spot.
}
- pc_setpos(sd, sd->mapindex, x, y, 3);
+ 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;
@@ -1114,7 +1114,7 @@ ACMD_FUNC(load)
return -1;
}
- pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
+ 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;
@@ -1663,15 +1663,15 @@ ACMD_FUNC(item2)
if (item_id > 500) {
loop = 1;
get_count = number;
- if (item_data->type == 4 || item_data->type == 5 ||
- item_data->type == 7 || item_data->type == 8) {
+ if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
+ item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
loop = number;
get_count = 1;
- if (item_data->type == 7) {
+ if (item_data->type == IT_PETEGG) {
identify = 1;
refine = 0;
}
- if (item_data->type == 8)
+ if (item_data->type == IT_PETARMOR)
refine = 0;
if (refine > 10)
refine = 10;
@@ -1777,8 +1777,10 @@ ACMD_FUNC(baselevelup)
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)
@@ -1808,11 +1810,7 @@ ACMD_FUNC(joblevelup)
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;
- clif_updatestatus(sd, SP_JOBLEVEL);
- clif_updatestatus(sd, SP_NEXTJOBEXP);
sd->status.skill_point += level;
- clif_updatestatus(sd, SP_SKILLPOINT);
- status_calc_pc(sd, 0);
clif_misceffect(&sd->bl, 1);
clif_displaymessage(fd, msg_txt(24)); // Job level raised.
} else {
@@ -1824,18 +1822,20 @@ ACMD_FUNC(joblevelup)
if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
level = sd->status.job_level-1;
sd->status.job_level -= (unsigned int)level;
- clif_updatestatus(sd, SP_JOBLEVEL);
- clif_updatestatus(sd, SP_NEXTJOBEXP);
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_updatestatus(sd, SP_SKILLPOINT);
- status_calc_pc(sd, 0);
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;
}
@@ -2308,7 +2308,7 @@ ACMD_FUNC(go)
clif_displaymessage(fd, msg_txt(248));
return -1;
}
- if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, 3) == 0) {
+ 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.
@@ -3329,7 +3329,7 @@ ACMD_FUNC(recall)
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, 2);
+ 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);
@@ -3988,7 +3988,7 @@ ACMD_FUNC(recallall)
pc_setstand(pl_sd);
pc_setrestartvalue(pl_sd,1);
}
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
+ pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
}
}
}
@@ -4047,7 +4047,7 @@ ACMD_FUNC(guildrecall)
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, 2);
+ pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
}
}
mapit_free(iter);
@@ -4106,7 +4106,7 @@ ACMD_FUNC(partyrecall)
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, 2);
+ pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
}
}
mapit_free(iter);
@@ -4704,7 +4704,7 @@ ACMD_FUNC(tonpc)
}
if ((nd = npc_name2id(npcname)) != NULL) {
- if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, 3) == 0)
+ if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
clif_displaymessage(fd, msg_txt(0)); // Warped.
else
return -1;
@@ -5786,7 +5786,7 @@ ACMD_FUNC(skilltree)
ent = &skill_tree[c][j];
meets = 1;
- for(j=0;j<5;j++)
+ for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
{
if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
{
@@ -6352,7 +6352,7 @@ ACMD_FUNC(mobsearch)
clif_displaymessage(fd, atcmd_output);
it = mapit_geteachmob();
- while( true )
+ for(;;)
{
TBL_MOB* md = (TBL_MOB*)mapit_next(it);
if( md == NULL )
@@ -6502,7 +6502,7 @@ ACMD_FUNC(users)
// count users on each map
iter = mapit_getallusers();
- while( true )
+ for(;;)
{
struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
if( sd2 == NULL )
@@ -6585,7 +6585,7 @@ ACMD_FUNC(summon)
md->master_id=sd->bl.id;
md->special_state.ai=1;
md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
- clif_misceffect2(&md->bl,344);
+ clif_specialeffect(&md->bl,344,AREA);
mob_spawn(md);
sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
@@ -6862,26 +6862,36 @@ ACMD_FUNC(identify)
*------------------------------------------*/
ACMD_FUNC(gmotd)
{
- char buf[CHAT_SIZE_MAX];
- FILE *fp;
- nullpo_retr(-1, sd);
- if((fp = fopen(motd_txt, "r"))!=NULL){
- while(fgets(buf, sizeof(buf), fp) != NULL)
+ char buf[CHAT_SIZE_MAX];
+ size_t len;
+ FILE* fp;
+
+ if( ( fp = fopen(motd_txt, "r") ) != NULL )
+ {
+ while( fgets(buf, sizeof(buf), fp) )
+ {
+ if( buf[0] == '/' && buf[1] == '/' )
{
- int i;
- if (buf[0] == '/' && buf[1] == '/')
- continue;
- for(i=0; buf[i]; i++){
- if(buf[i]=='\r' || buf[i]=='\n'){
- buf[i]=0;
- break;
- }
- }
- intif_broadcast(buf, strlen(buf)+1, 0);
+ continue;
+ }
+
+ len = strlen(buf);
+
+ while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
+ {// strip trailing EOL characters
+ len--;
+ }
+
+ if( len )
+ {
+ buf[len] = 0;
+
+ intif_broadcast(buf, len+1, 0);
}
- fclose(fp);
}
- return 0;
+ fclose(fp);
+ }
+ return 0;
}
ACMD_FUNC(misceffect)
@@ -7071,7 +7081,7 @@ ACMD_FUNC(showmobs)
clif_displaymessage(fd, atcmd_output);
it = mapit_geteachmob();
- while( true )
+ for(;;)
{
TBL_MOB* md = (TBL_MOB*)mapit_next(it);
if( md == NULL )
@@ -7124,7 +7134,7 @@ ACMD_FUNC(homlevel)
}
status_calc_homunculus(hd,0);
status_percent_heal(&hd->bl, 100, 100);
- clif_misceffect2(&hd->bl,568);
+ clif_specialeffect(&hd->bl,568,AREA);
return 0;
}
@@ -7390,9 +7400,6 @@ ACMD_FUNC(homshuffle)
*------------------------------------------*/
ACMD_FUNC(iteminfo)
{
- char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
- //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
-
struct item_data *item_data, *item_array[MAX_SEARCH];
int i, count = 1;
@@ -7417,20 +7424,20 @@ ACMD_FUNC(iteminfo)
item_data = item_array[i];
sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
item_data->name,item_data->jname,item_data->slot,item_data->nameid,
- item_data->type < 12 ? itype[item_data->type] : "BUG!",
+ itemdb_typename(item_data->type),
(item_data->script==NULL)? "None" : "With script"
);
clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %.1f ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight/10. );
+ sprintf(atcmd_output, "NPC Buy:%dz, Sell:%dz | Weight: %.1f ", item_data->value_buy, item_data->value_sell, item_data->weight/10. );
clif_displaymessage(fd, atcmd_output);
- if (item_data->maxchance == 10000)
- strcpy(atcmd_output, " - Available in the shops only");
+ if (item_data->maxchance == -1)
+ strcpy(atcmd_output, " - Available in the shops only.");
else if (item_data->maxchance)
sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
else
- strcpy(atcmd_output, " - Monsters don't drop this item");
+ strcpy(atcmd_output, " - Monsters don't drop this item.");
clif_displaymessage(fd, atcmd_output);
}
@@ -7700,7 +7707,7 @@ ACMD_FUNC(size)
size = atoi(message);
if(sd->state.size) {
sd->state.size=0;
- pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
+ pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
}
if(size==1) {
@@ -8499,58 +8506,68 @@ ACMD_FUNC(stats)
ACMD_FUNC(delitem)
{
char item_name[100];
- int i, number = 0, item_id, item_position, count;
- struct item_data *item_data;
- char output[CHAT_SIZE_MAX];
+ int nameid, amount = 0, total, idx;
+ struct item_data* id;
nullpo_retr(-1, sd);
- memset(item_name, '\0', sizeof(item_name));
- memset(output, '\0', sizeof(output));
+ if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
+ {
+ clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).");
+ return -1;
+ }
- if (!message || !*message || (
- sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 2 &&
- sscanf(message, "%s %d", item_name, &number) < 2
- ) || number < 1) {
- clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <item_name_or_ID> <quantity> <player>).");
+ if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
+ {
+ nameid = id->nameid;
+ }
+ else
+ {
+ clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
return -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) {
- item_position = pc_search_inventory(sd, item_id);
- if (item_position >= 0) {
- count = 0;
- for(i = 0; i < number && item_position >= 0; i++) {
+ total = amount;
- //Logs (A)dmins items [Lupus]
- if(log_config.enable_logs&0x400)
- log_pick_pc(sd, "A", sd->status.inventory[item_position].nameid, -1, &sd->status.inventory[item_position]);
+ // delete items
+ while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
+ {
+ int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
- pc_delitem(sd, item_position, 1, 0, 0);
- count++;
- item_position = pc_search_inventory(sd, item_id); // for next loop
- }
- sprintf(output, msg_txt(113), count); // %d item(s) removed by a GM.
- clif_displaymessage(sd->fd, output);
- if (number == count)
- sprintf(output, msg_txt(114), count); // %d item(s) removed from the player.
- else
- sprintf(output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
- clif_displaymessage(fd, output);
- } else {
- clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
- return -1;
+ if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
+ {// delete pet
+ intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
+ }
+
+ //Logs (A)dmins items [Lupus]
+ if( log_config.enable_logs&0x400 )
+ {
+ log_pick_pc(sd, "A", nameid, -delamount, &sd->status.inventory[idx]);
}
+
+ pc_delitem(sd, idx, delamount, 0, 0);
+
+ amount-= delamount;
+ }
+
+ // notify target
+ sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
+ clif_displaymessage(sd->fd, atcmd_output);
+
+ // notify source
+ if( amount == total )
+ {
+ clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
+ }
+ else if( amount )
+ {
+ sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
+ clif_displaymessage(fd, atcmd_output);
}
else
{
- clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
- return -1;
+ sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
+ clif_displaymessage(fd, atcmd_output);
}
return 0;