-
Notifications
You must be signed in to change notification settings - Fork 760
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
base: master
Are you sure you want to change the base?
Conversation
1e0462d
to
06bcc68
Compare
I think don't need,
... this is not an official feature ...
I am sure well, just my 2 cents PS: when you say mass refiner script, I was thinking about using delitem2/getitem2 |
i not sure probably better create command |
erm ... but if the item already refined, it went from knife 0 into knife 10 |
if get list non refined items before start refining, item with this it cant be refined in this loop two times. I mean one item refine do remove/add item, and it reusing existing item index or adding item in new index, it not affect other items in one loop iteration |
Another option for refine without add/remove item is abusing packet ZC_ENCHANT_EQUIPMENT script command enchantitem. |
that sounds AWESOME ... but wait, can it change the ItemID as well ?
enlighten me, but I didn't see the refine flag there, nor the random option ... |
item id i think can be changed too. But i not sure is client update all things if change id. |
After successrefitem(), it seems the item doesn't change index and I can continue to loop through all them in my inventory. Here's a video of me using the mass refiner with this new equip function: https://www.youtube.com/watch?v=J8C3DxtlhN4 equipidx() is a good suggestion (@4144). Maybe that is a better way to go. |
a525f09
to
f03ab26
Compare
f03ab26
to
2fb233e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea of having *equipidx
looks fine, but your refiner script still can be improve (based on the video)
can just loop the percentage with *getequiprefinerycnt
, then just successrefitem EQI_HAND_R, N;
where N is the number of times it refines
2fb233e
to
e84f52c
Compare
I added a check so index isn't out of range. Is this correct or unnecessary?
|
e84f52c
to
00d5314
Compare
check is correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just about to review, 4144 is faster than me XD
anyway I have tested this in-game and made some changes
/**
* equipidx(<index>)
*/
static BUILDIN(equipidx)
{
int nameid = 0, i = script_getnum(st, 2);
struct item_data *item_data;
struct map_session_data *sd = script->rid2sd(st);
if (sd == NULL) {
script_pushint(st, 0);
return true;
}
if (i < 0 || i >= sd->status.inventorySize) {
ShowError("buildin_equipidx: Index (%d) should be from 0-%d.\n", i, sd->status.inventorySize - 1);
script_pushint(st, 0);
return false;
}
if (sd->status.inventory[i].equip != 0) { // item already equipped, run silently
script_pushint(st, 1);
return true;
}
nameid = sd->status.inventory[i].nameid;
if ((item_data = itemdb->exists(nameid)) == NULL) {
ShowError("buildin_equipidx: Invalid Item ID (%d).\n", nameid);
script_pushint(st, 0);
return false;
}
if (pc->equipitem(sd, i, item_data->equip) == 0) {
ShowWarning("buildin_equipidx: Item ID (%d) at index (%d) cannot be equipped.\n", nameid, i);
script_pushint(st, 0);
return false;
}
script_pushint(st, 1);
return true;
}
honestly I don't see the point having {, } optional field there
after all, this is run by *getinventorylist
,
and it already can be check by @inventorylist_id[.@i]
already isn't it ?
another things concern me is assassin class can equip weapons in both hands, hmm ... if you couldn't do it, can leave at it is, after all nobody actually complain about this issue
|
Thanks for the input guys. I am busy for a few days I will update once I'm free. Also, thanks for your tips on the refiner script, AnnieRuru. Was able to streamline it so script is cleaner and effects are only displaying once for better feel for the player. |
dca185b
to
698dd34
Compare
Updated based on comments from Annie and 4144. Though I made this bit |
698dd34
to
63c2de9
Compare
63c2de9
to
273dd94
Compare
Okay done. Let me know if anything else is needed. |
273dd94
to
221191e
Compare
221191e
to
29af737
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok wait 4144 again
return true; | ||
} | ||
|
||
nameid = script_getnum(st, 2); |
There was a problem hiding this comment.
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);
try introduce a new script command |
getinventorylist(); | ||
for (.@i = 0; .@i < @inventorylist_count; .@i) { | ||
if (@inventorylist_id[.@i] == Knife && @inventorylist_expire[.@i]) { | ||
equipidx(.@i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks to dastgir idea, that just push another array of the index,
that means this example has to change accordingly
equipidx(.@i); | |
equipidx(@inventorylist_idx[.@i]); |
@@ -5622,6 5625,30 @@ Examples: | |||
|
|||
--------------------------------------- | |||
|
|||
*equipidx(<index>) | |||
|
|||
The equipidx function will attempt to equip the item at the given inventory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The equipidx function will attempt to equip the item at the given inventory | |
This function will attempt to equip the item at the given |
inventory index. This feature is only really useful when multiple instances | ||
of an Item ID exist in the player's inventory. | ||
|
||
Returns 1 if the item was successfully equipped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns 1 if the item was successfully equipped. | |
Return true if successful, otherwise it will return false. |
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
equip() returns 1 if the item was successfully equipped and 0 if the | |
Return equipment's position if successful, otherwise it will return false. |
@@ -25491,6 25540,7 @@ static void script_parse_builtin(void) | |||
BUILDIN_DEF(equip,"i"), | |||
BUILDIN_DEF(autoequip,"ii"), | |||
BUILDIN_DEF(equip2,"iiiiiii"), | |||
BUILDIN_DEF(equipidx, "i?"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BUILDIN_DEF(equipidx, "i?"), | |
BUILDIN_DEF(equipidx, "i"), |
didnt have optional parameter.
Pull Request Prelude
Changes Proposed
i.e.
equipidx(<index>{, <item id>})
The reason for this change is it allows you the option to choose the specific inventory index to equip. Of course, you need to know the inventory index.
Currently I am using this in a mass refiner script. Since you need to equip an item to refine it, I was having trouble due to the equip() command always equipping the lowest index (I believe that's what it was doing).
Here is a sample in which all the different versions of 'Knife' are cycled through and equipped every 1 second.
Issues addressed:
N/A