otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.59k stars 1.06k forks source link

Request: Feature: Item Abilities in Lua functions #1076

Open Codinablack opened 9 years ago

Codinablack commented 9 years ago

I was looking in the source, and it doesn't seem like there needs to be anything altered to implement this, the only thing I think would be to add the functions in luascript

Item:hasAbility("ability", "sub-type") -- returns true or false Item:getAbility("ability", "sub-type") -- returns value Item:setAbility("ability", "sub-type", value) -- sets value for ability and specific sub-type.

ItemType:getAbility("ability", "sub-type")

Example use:

local fireAbsorption if Item:hasAbility("absorb", "fire") then fireAbsorption = Item:getAbility("absorb", "fire") else fireAbsorption = ItemType(Item:getId()):getAbility("absorb", "fire") end

Could be used for skills, absorbpercent, fieldabsorbpercent, stats, statspercent, speed, health gain, mana gain, regeneration, anything you can already put in items.xml

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Zbizu commented 9 years ago

has/getAbility should be easy to add. With "set" this is needed:

andersonfaaria commented 4 years ago

About this, I have a very strong opinion that we should completely rewrite ItemType structure. Most of the tfs checks things in itemtype instead of item and it makes several attributes only be read if they are declared in items.xml.

I do understand the facilities that the class-object format gives for instanciating an item with their attributes from XML, but this becomes a huge problem when you consider making custom items.

IMO we could use portions of the edits done by @infernumx here https://github.com/infernumx/forgottenserver/compare/master...infernumx:abilities-remove