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

Adds BUILDIN(equipidx); BUILDIN(equip) now returns 0 or 1. #2355

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Changes equip() to return 0 or 1 if item successfully equipped.
  • Loading branch information
bWolfie committed Jan 30, 2019
commit 6ff691f4882fd10695b277b7ccd8c3cdc503f379
3 changes: 3 additions & 0 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5603,6 +5603,9 @@ item in his/her inventory, while the autoequip function will equip the
given item ID when this is looted. The option parameter of the autoequip
is 1 or 0, 1 to turn it on, and 0 to turn it off.

equip() returns 1 if the item was successfully equipped and 0 if the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
equip() returns 1 if the item was successfully equipped and 0 if the
Return equipment's position if successful, otherwise it will return false.

item failed to equip.

Examples:

//This will equip a 1104 (falchion) on the character if this is in the
Expand Down
23 changes: 15 additions & 8 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -16473,21 +16473,28 @@ static BUILDIN(unequip)

static BUILDIN(equip)
{
int nameid=0,i;
int nameid = 0, i;
struct item_data *item_data;
struct map_session_data *sd = script->rid2sd(st);
if (sd == NULL)
return false;

nameid=script_getnum(st,2);
if((item_data = itemdb->exists(nameid)) == NULL)
{
ShowError("wrong item ID : equipitem(%d)\n",nameid);
if (sd == NULL) {
script_pushint(st, 0);
return true;
}

nameid = script_getnum(st, 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nameid can be defined here
int nameid = script_getnum(st, 2);

if ((item_data = itemdb->exists(nameid)) == NULL) {
ShowError("buildin_equip: Invalid Item ID (%d).\n", nameid);
script_pushint(st, 0);
return false;
}

ARR_FIND(0, sd->status.inventorySize, i, sd->status.inventory[i].nameid == nameid && sd->status.inventory[i].equip == 0);

if (i < sd->status.inventorySize)
pc->equipitem(sd, i, item_data->equip);
script_pushint(st, pc->equipitem(sd, i, item_data->equip));
else
script_pushint(st, 0);

return true;
}
Expand Down