Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved atCommand(mobinfo) #3328

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading