Jump to content


Photo

Introducing the Item Options System

Release New Feature

  • Please log in to reply
18 replies to this topic

#1 Smoke

Smoke

    Advanced Member

  • Core Developers
  • 161 posts
  • IRC Nickname:smoke
  • Emulator:Hercules
  • Github:smokexyz

Posted 10 April 2017 - 06:29 AM

Introducing the Item Options System!

 

k3TrEvc.png

 

Commit

https://github.com/H...30de04a43226ad3

 

Feature Information

The Item Option System is a feature that was implemented in 2015-02-26 clients, allowing equipments to have up to 5 additional effects similar to cards or enchants. Each equipment is capable of having 5 information bars above the card slot/enchant bar that describes the effect of the option it is infused with.

 

New Script Commands (The following snippet is available in doc/script_commands.txt.)

*getequipisenableopt(<equipment slot>)

This function checks if the equipped item allows the use of bonus options.

Returns 1 if allowed, 0 if not.

---------------------------------------

*getequippedoptioninfo(<info_type>);

This function is to be used with the scripts of contents listed in
db/item_options.conf only.

Returns the value of the current equipment being parsed.
If the equip was not found or the type is invalid, -1 is returned.

---------------------------------------

*getequipoptioninfo(<equip_index>,<slot>,<type>);

Gets the option information of an equipment.

<equipment_index> For a list of equipment indexes see getequipid().
<option_slot> can range from 1 to MAX_ITEM_OPTIONS
<type> can be IT_OPT_INDEX (the ID of the option bonus, @see "Id" or "Name" in db/item_options.conf)       or IT_OPT_VALUE (the value of the bonus script of the equipment, @see "Script" in db_item_options.conf).

returns the value of the slot if exists or -1 for invalid slot, type or slots.

---------------------------------------

*setequipoption(<equip_index>,<slot>,<opt_index>,<value>);

Set an equipment's option index or value for the specified option slot.

<equipment_index> For a list of equipment indexes see getequipid().
<option_slot> can range from 1 to MAX_ITEM_OPTIONS
<type> can be IT_OPT_INDEX (the ID of the option bonus, @see "Id" or "Name" in db/item_options.conf)
<value> The value of the type to be set.

returns 0 if value couldn't be set, 1 on success.

 

 

Release Notes

  • This system allows the infusing of equipments with bonus item options.
  • This feature is constrained to clients of packet versions greater than or equal to 20150226.
  • Item Options and their effects are defined server-side in db/item_options.conf and client side in data/luafiles514/lua files/datainfo/addrandomoptionnametable.lub
  • The ID of the option must tally with the correct index of the description provided in the client side file.
  • IT_OPT_* keys and MAX_ITEM_OPTIONS macro are also exported from the source as constants.
  • If you wish to disable item options for certain (equipment) items, an additional flag `disable_options` has been added to the item sql tables, and as `DisableOptions: true/false (boolean, defaults to false !!for equipments only!!)` to the item_db.conf files.
  • Documentation is provided for script commands.
  • If upgrading, don't forget to run the sql upgrade files!


Credits

A big thanks to all the reviewers that helped make the code closer to perfection. -

EmistrydastgirMishimaHarunaJedzkieRidley8819Asheraf4144.

 

Style and Script Fixes by Asheraf (https://github.com/Asheraf)
Initial design Idea in rAthena commit.



#2 melv0

melv0

    Advanced Member

  • Members
  • PipPipPip
  • 92 posts
  • LocationIndonesia
  • Emulator:Hercules

Posted 10 April 2017 - 06:33 AM

awasome



#3 Klutz

Klutz

    Advanced Member

  • Members
  • PipPipPip
  • 77 posts

Posted 10 April 2017 - 02:00 PM

Amazing! 



#4 Legend

Legend

    Advanced Member

  • Members
  • PipPipPip
  • 334 posts
  • LocationHeaven ♥
  • Emulator:Hercules
  • Github:Legend95

Posted 10 April 2017 - 03:14 PM

Thank you so much Herc devs

You can use some of my *crappy* request scripts. It may somehow help you.

 

my ♥ belongs here


#5 fiction

fiction

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts
  • LocationSantiago, Chile
  • Emulator:Hercules

Posted 10 April 2017 - 03:30 PM

Thank you :D !



#6 tedexx

tedexx

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 10 April 2017 - 05:15 PM

Awesome! Great work.



#7 tedexx

tedexx

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts

Posted 11 April 2017 - 06:15 AM

Wouldn't be

 

setequipoption(<equip_index>,<opt_index>,<slot>,<value>);

 

Instead of

 

setequipoption(<equip_index>,<slot>,<opt_index>,<value>);

 

?

 

The Item Option NPC released has the variables inverted in the method call too.

 

 

Also, I found a possible exploit:

Using the NPC to put options on an item, if you put an option the NPC will unequip the item, but if the item has options values already, the bonuses will stay with the character even without the equipment.

Removing the equipment manually removes the bonus, its just the "autoremove" from setequipoption that doesn't.


Edited by tedexx, 11 April 2017 - 07:00 AM.


#8 Smoke

Smoke

    Advanced Member

  • Core Developers
  • 161 posts
  • IRC Nickname:smoke
  • Emulator:Hercules
  • Github:smokexyz

Posted 11 April 2017 - 07:10 AM

Wouldn't be

 

setequipoption(<equip_index>,<opt_index>,<slot>,<value>);

 

Instead of

 

setequipoption(<equip_index>,<slot>,<opt_index>,<value>);

 

?

 

The Item Option NPC released has the variables inverted in the method call too.

Yes, this will be fixed soon. The correct order is setequipoption(<equip_index>,<slot>,<opt_index>,<value>);

 

Edit: Fixed in the latest commit.

 

 

Also, I found a possible exploit:

Using the NPC to put options on an item, if you put an option the NPC will unequip the item, but if the item has options values already, the bonuses will stay with the character even without the equipment.

Removing the equipment manually removes the bonus, its just the "autoremove" from setequipoption that doesn't.

Addressed in PR#1673 Thank you for the report.



#9 GmOcean

GmOcean

    Advanced Member

  • Community Contributors
  • 366 posts
  • Emulator:Hercules

Posted 14 April 2017 - 05:14 AM

OMG!! Finally an official system to do what I've created through script. Hmm, may pop back in just to release something using this in the future.


Posted Image

#10 jupeto

jupeto

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts
  • Github:jupeto

Posted 15 April 2017 - 08:06 PM

AWESOME ADDITION!!!
 
 
I'm trying to add a custom option
 
[EnumVAR.VAR_CUSTOMMAXHP[1]] = "Custom MaxHP +%d"
 
but an error comes up after starting the client
 
attempt to index field '?' (a nil value)
 
 
    [EnumVAR.MDAMAGE_SIZE_SMALL_TARGET[1]] = "Magical damage against Small size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_MIDIUM_TARGET[1]] = "Magical damage against Medium size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_LARGE_TARGET[1]] = "Magical damage against Large size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_SMALL_USER[1]] = "Magical resistance Small size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_MIDIUM_USER[1]] = "Magical resistance Medium size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_LARGE_USER[1]] = "Magical resistance Large size monster +%d%%",    [EnumVAR.VAR_CUSTOMMAXHP[1]] = "Custom MaxHP +%d",    [EnumVAR.EnumVAR_LAST[1]] = "END"}

 

Also, I don't see any command to remove specific item option.


Edited by jupeto, 15 April 2017 - 08:50 PM.


#11 Smoke

Smoke

    Advanced Member

  • Core Developers
  • 161 posts
  • IRC Nickname:smoke
  • Emulator:Hercules
  • Github:smokexyz

Posted 16 April 2017 - 05:48 AM


    [EnumVAR.MDAMAGE_SIZE_SMALL_TARGET[1]] = "Magical damage against Small size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_MIDIUM_TARGET[1]] = "Magical damage against Medium size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_LARGE_TARGET[1]] = "Magical damage against Large size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_SMALL_USER[1]] = "Magical resistance Small size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_MIDIUM_USER[1]] = "Magical resistance Medium size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_LARGE_USER[1]] = "Magical resistance Large size monster +%d%%",    [EnumVAR.VAR_CUSTOMMAXHP[1]] = "Custom MaxHP +%d",    [EnumVAR.EnumVAR_LAST[1]] = "END"}
 
Also, I don't see any command to remove specific item option.


This would be *setequipoption(<equip_index>,<slot>,0,0);

#12 jupeto

jupeto

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts
  • Github:jupeto

Posted 16 April 2017 - 10:23 AM

 

    [EnumVAR.MDAMAGE_SIZE_SMALL_TARGET[1]] = "Magical damage against Small size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_MIDIUM_TARGET[1]] = "Magical damage against Medium size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_LARGE_TARGET[1]] = "Magical damage against Large size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_SMALL_USER[1]] = "Magical resistance Small size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_MIDIUM_USER[1]] = "Magical resistance Medium size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_LARGE_USER[1]] = "Magical resistance Large size monster +%d%%",    [EnumVAR.VAR_CUSTOMMAXHP[1]] = "Custom MaxHP +%d",    [EnumVAR.EnumVAR_LAST[1]] = "END"}
 
Also, I don't see any command to remove specific item option.

 

This would be *setequipoption(<equip_index>,<slot>,0,0);

 

Already tried that but the console says

 

[Error]: buildin_setequipoption: Option index 0 does not exist!


#13 Smoke

Smoke

    Advanced Member

  • Core Developers
  • 161 posts
  • IRC Nickname:smoke
  • Emulator:Hercules
  • Github:smokexyz

Posted 16 April 2017 - 12:18 PM

 

 

    [EnumVAR.MDAMAGE_SIZE_SMALL_TARGET[1]] = "Magical damage against Small size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_MIDIUM_TARGET[1]] = "Magical damage against Medium size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_LARGE_TARGET[1]] = "Magical damage against Large size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_SMALL_USER[1]] = "Magical resistance Small size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_MIDIUM_USER[1]] = "Magical resistance Medium size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_LARGE_USER[1]] = "Magical resistance Large size monster +%d%%",    [EnumVAR.VAR_CUSTOMMAXHP[1]] = "Custom MaxHP +%d",    [EnumVAR.EnumVAR_LAST[1]] = "END"}
 
Also, I don't see any command to remove specific item option.

 

This would be *setequipoption(<equip_index>,<slot>,0,0);

 

Already tried that but the console says

 

[Error]: buildin_setequipoption: Option index 0 does not exist!

Ah right, then there needs to be a script command for its removal.



#14 jupeto

jupeto

    Advanced Member

  • Members
  • PipPipPip
  • 30 posts
  • Github:jupeto

Posted 16 April 2017 - 02:02 PM

 

 

 

    [EnumVAR.MDAMAGE_SIZE_SMALL_TARGET[1]] = "Magical damage against Small size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_MIDIUM_TARGET[1]] = "Magical damage against Medium size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_LARGE_TARGET[1]] = "Magical damage against Large size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_SMALL_USER[1]] = "Magical resistance Small size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_MIDIUM_USER[1]] = "Magical resistance Medium size monster +%d%%",    [EnumVAR.MDAMAGE_SIZE_LARGE_USER[1]] = "Magical resistance Large size monster +%d%%",    [EnumVAR.VAR_CUSTOMMAXHP[1]] = "Custom MaxHP +%d",    [EnumVAR.EnumVAR_LAST[1]] = "END"}
 
Also, I don't see any command to remove specific item option.

 

This would be *setequipoption(<equip_index>,<slot>,0,0);

 

Already tried that but the console says

 

[Error]: buildin_setequipoption: Option index 0 does not exist!

Ah right, then there needs to be a script command for its removal.

Yah, hopefully :D I'm trying to create a new script command for that...

 

Also, can you please help me create a new set of options, both client and server side

 

[EDIT]

 

I successfully added a remove option command, still not sure if it's the best way to do it LOL... I managed to add, remove option with this...

 

ALSO... fixed the (I think a bug) where the equipment is not forcefully equipped to the character after calculating the new stats by storing the current equipped item id of the user in a variable (eid) and use that variable to force equip (pc->equipitem(sd, i, eid);) the item

 

/**
 * Remove an equipment's option value.
 * *removeequipoption(<equip_index>,<slot>);
 *
 * @param equip_index     as the inventory index of the equipment.
 * @param slot            as the slot of the item option (1 to MAX_ITEM_OPTIONS)
 * @return 0 on failure, 1 on success.
 */
BUILDIN(removeequipoption)
{
    int equip_index = script_getnum(st, 2);
    int slot = script_getnum(st, 3);
    int i = -1;
    int eid = 0;

    struct map_session_data *sd = script->rid2sd(st);

    if (sd == NULL) {
        script_pushint(st, 0);
        ShowError("buildin_removeequipoption: Player not attached!\n");
        return false;
    }

    if (slot <= 0 || slot > MAX_ITEM_OPTIONS) {
        script_pushint(st, 0);
        ShowError("buildin_removeequipoption: Invalid option index %d (Min: 1, Max: %d) provided.\n", slot, MAX_ITEM_OPTIONS);
        return false;
    }

    if (equip_index > 0 && equip_index <= ARRAYLENGTH(script->equip)) {
        if ((i = pc->checkequip(sd, script->equip[equip_index - 1])) == -1) {
            ShowError("buildin_setequipoptioninfo: No equipment is equipped in the given index %d.\n", equip_index);
            script_pushint(st, 0);
            return false;
        }
    } else {
        ShowError("buildin_removeequipoptioninfo: Invalid equipment index %d provided.\n", equip_index);
        script_pushint(st, 0);
        return false;
    }

    if (sd->status.inventory[i].nameid != 0) {
        
        eid = sd->status.inventory[i].equip; // Store the current equipped item id to a variable to use for equiping again after calculating new stats
        
        /* Add Option Index */
        sd->status.inventory[i].option[slot-1].index = 0;
        /* Add Option Value */
        sd->status.inventory[i].option[slot-1].value = 0;

        /* Unequip and simulate deletion of the item. */
        pc->unequipitem(sd, i, PCUNEQUIPITEM_FORCE); // status calc will happen in pc->equipitem() below
        clif->refine(sd->fd, 0, i, sd->status.inventory[i].refine); // notify client of a refine.
        clif->delitem(sd, i, 1, DELITEM_MATERIALCHANGE); // notify client to simulate item deletion.
        /* Log deletion of the item. */
        logs->pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i],sd->inventory_data[i]);
        /* Equip and simulate addition of the item. */
        clif->additem(sd, i, 1, 0); // notify client to simulate item addition.
        /* Log addition of the item. */
        logs->pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i], sd->inventory_data[i]);
        pc->equipitem(sd, i, eid); // force equip the item at the original position.
        clif->misceffect(&sd->bl, 2); // show effect
    }

    script_pushint(st, 1);

    return true;

}


BUILDIN_DEF(removeequipoption, "ii"),

Edited by jupeto, 16 April 2017 - 05:51 PM.


#15 Like it~*

Like it~*

    Advanced Member

  • Members
  • PipPipPip
  • 98 posts

Posted 24 April 2017 - 02:43 AM

As you might imagine, Smoke is always involved in big, cool projects. I would like to congratulate you and thank you on behalf of the whole community.
 
However, I do not see so many great utilities in this ... I do not know if it is due to the difficulty of understanding the language, or because the text has not been clarified, but I have not really seen it. (Please do not get me wrong, I'm just curious)
 
Is this system official?
Is there any utility besides not having to create custom cards to give players bonuses?
 
I'm sorry I looked ignorant, but I'm just curious.


#16 raPalooza~

raPalooza~

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts
  • LocationInnovation
  • Emulator:Hercules

Posted 24 April 2017 - 03:56 AM

Are we also getting an 
"getitem3"/"makeitem3" ? This would be awesome to have too. ;D


Edited by raPalooza~, 24 April 2017 - 03:58 AM.

sig2.png
MHFMF87.png


#17 True Zeal

True Zeal

    Advanced Member

  • Members
  • PipPipPip
  • 411 posts
  • LocationAlberta
  • Emulator:Hercules

Posted 24 April 2017 - 04:54 AM

As you might imagine, Smoke is always involved in big, cool projects. I would like to congratulate you and thank you on behalf of the whole community.
 
However, I do not see so many great utilities in this ... I do not know if it is due to the difficulty of understanding the language, or because the text has not been clarified, but I have not really seen it. (Please do not get me wrong, I'm just curious)
 
Is this system official?
Is there any utility besides not having to create custom cards to give players bonuses?
 
I'm sorry I looked ignorant, but I'm just curious.

 

i guess it is a different way of displaying flavor text and equipment bonuses


I ask a lot of questions. Prepare to be frustrated.


#18 Smoke

Smoke

    Advanced Member

  • Core Developers
  • 161 posts
  • IRC Nickname:smoke
  • Emulator:Hercules
  • Github:smokexyz

Posted 24 April 2017 - 07:03 AM

As you might imagine, Smoke is always involved in big, cool projects. I would like to congratulate you and thank you on behalf of the whole community.
 
However, I do not see so many great utilities in this ... I do not know if it is due to the difficulty of understanding the language, or because the text has not been clarified, but I have not really seen it. (Please do not get me wrong, I'm just curious)
 
Is this system official?
Is there any utility besides not having to create custom cards to give players bonuses?
 
I'm sorry I looked ignorant, but I'm just curious.

 

This is an official system yes.

This doesn't have anything to do with creating custom cards.

 

This system makes it possible to do things such as -

  1. creating unique equipments in the game with unique stats.
  2. creating dynamic equipments with options. (possibly with an equipment levelling system)
  3. if one is lazy, not having to put a description in the item and providing it with desired stats through an npc?

 

The use of it ultimately depends on one's creative capabilities.



#19 Like it~*

Like it~*

    Advanced Member

  • Members
  • PipPipPip
  • 98 posts

Posted 24 April 2017 - 10:16 PM

 

As you might imagine, Smoke is always involved in big, cool projects. I would like to congratulate you and thank you on behalf of the whole community.
 
However, I do not see so many great utilities in this ... I do not know if it is due to the difficulty of understanding the language, or because the text has not been clarified, but I have not really seen it. (Please do not get me wrong, I'm just curious)
 
Is this system official?
Is there any utility besides not having to create custom cards to give players bonuses?
 
I'm sorry I looked ignorant, but I'm just curious.

 

i guess it is a different way of displaying flavor text and equipment bonuses

 

 

 

As you might imagine, Smoke is always involved in big, cool projects. I would like to congratulate you and thank you on behalf of the whole community.
 
However, I do not see so many great utilities in this ... I do not know if it is due to the difficulty of understanding the language, or because the text has not been clarified, but I have not really seen it. (Please do not get me wrong, I'm just curious)
 
Is this system official?
Is there any utility besides not having to create custom cards to give players bonuses?
 
I'm sorry I looked ignorant, but I'm just curious.

 

This is an official system yes.

This doesn't have anything to do with creating custom cards.

 

This system makes it possible to do things such as -

  1. creating unique equipments in the game with unique stats.
  2. creating dynamic equipments with options. (possibly with an equipment levelling system)
  3. if one is lazy, not having to put a description in the item and providing it with desired stats through an npc?

 

The use of it ultimately depends on one's creative capabilities.

 

Thank you very much for clarifying my doubts. What I meant by custom cards is that bonuses could be given by creating custom cards too, you know?







Also tagged with one or more of these keywords: Release, New Feature

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users


This topic has been visited by 99 user(s)