Skip to content

Commit

Permalink
Merge pull request #3328 from Venseer/improved-atcommand-mobinfo
Browse files Browse the repository at this point in the history
Improved atCommand(mobinfo)
  • Loading branch information
MishimaHaruna authored Oct 31, 2024
2 parents 3056bce + 45004f9 commit 2615a40
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/map/atcommand.c
Original file line number Diff line number Diff line change
Expand Up @@ -7156,14 +7156,14 @@ ACMD(mobinfo)
unsigned char msize[3][7] = {"Small", "Medium", "Large"};
unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
char atcmd_output2[CHAT_SIZE_MAX];
StringBuf buf;
struct item_data *item_data;
struct mob_db *monster, *mob_array[MAX_SEARCH];
int count;
int i, k;

memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(atcmd_output2, '\0', sizeof(atcmd_output2));
StrBuf->Init(&buf);

if (!*message) {
clif->message(fd, msg_fd(fd, MSGTBL_MOBINFO_USAGE)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
Expand Down Expand Up @@ -7253,23 +7253,22 @@ ACMD(mobinfo)
}
#endif

if (item_data->slot)
snprintf(atcmd_output2, sizeof(atcmd_output2), " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
else
snprintf(atcmd_output2, sizeof(atcmd_output2), " - %s %02.02f%%", item_data->jname, (float)droprate / 100);

strcat(atcmd_output, atcmd_output2);

struct item link_item = { 0 };
link_item.nameid = monster->dropitem[i].nameid;
StrBuf->AppendStr(&buf, " - ");
clif->format_itemlink(&buf, &link_item);
StrBuf->Printf(&buf, " %02.02f%%", (float)droprate / 100);
if (++j % 3 == 0) {
clif->message(fd, atcmd_output);
strcpy(atcmd_output, " ");
clif->message(fd, StrBuf->Value(&buf));
StrBuf->Clear(&buf);
}
}

if (j == 0)
clif->message(fd, msg_fd(fd, MSGTBL_MOBINFO_NO_DROPS)); // This monster has no drops.
else if (j % 3 != 0)
clif->message(fd, atcmd_output);
clif->message(fd, StrBuf->Value(&buf));
StrBuf->Clear(&buf);
// mvp
if (monster->mexp) {
snprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, MSGTBL_MOBINFO_MVP_BONUS_EXP), monster->mexp); // MVP Bonus EXP:%u
Expand All @@ -7282,19 +7281,21 @@ ACMD(mobinfo)
continue;
if (monster->mvpitem[i].p > 0) {
j++;
if(item_data->slot)
snprintf(atcmd_output2, sizeof(atcmd_output2), " %s%s[%d] %02.02f%%", j != 1 ? "- " : "", item_data->jname, item_data->slot, (float)monster->mvpitem[i].p / 100);
else
snprintf(atcmd_output2, sizeof(atcmd_output2), " %s%s %02.02f%%", j != 1 ? "- " : "", item_data->jname, (float)monster->mvpitem[i].p / 100);
strcat(atcmd_output, atcmd_output2);
struct item link_item = { 0 };
link_item.nameid = monster->mvpitem[i].nameid;
StrBuf->AppendStr(&buf, j != 1 ? " - " : "");
clif->format_itemlink(&buf, &link_item);
StrBuf->Printf(&buf, " %02.02f%%", (float)monster->mvpitem[i].p / 100);
}
}

if (j == 0)
clif->message(fd, msg_fd(fd, MSGTBL_MOBINFO_NO_MVP_PRIZES)); // This monster has no MVP prizes.
else
clif->message(fd, atcmd_output);
clif->message(fd, StrBuf->Value(&buf));
}
}
StrBuf->Destroy(&buf);
return true;
}

Expand Down

0 comments on commit 2615a40

Please sign in to comment.