otland / forgottenserver

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

[Feature]: Force ITEM to DECAY to specific ID with specific DURATION (min, max) #4727

Closed Coldensjo closed 3 months ago

Coldensjo commented 4 months ago

By submitting this feature issue, you agree to the following.

Pull Requests or Links to add this feature

No response

Request

Currently you cannot change what an item should decay to. I want to be able to do something like this.

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    item:decayTo(10176) --decays to this id
    item:decayDuration(30,60) --30 to 60 seconds
    item:decay()
    return true
end

Let's say I have a specific id, a vial. I want to transform this item into broken glass when clicked on, but I want it to transform back to the vial after a certain period, without having to make a completely new item.

It could be used to create some complex things.

Possible Solutions

No response

ArturKnopik commented 4 months ago

It's can be done via items.xml, 1) in script remove item 2) then create new one with broken glass id

<item id="123123" article="a" name="Some Broken Vial">
   <attribute key="weight" value="TONES" />
   <attribute key="decayTo" value="123122" /> << not broken vial
   <attribute key="duration" value="AGES" />
</item>
Coldensjo commented 4 months ago

It's can be done via items.xml,

  1. in script remove item
  2. then create new one with broken glass id
<item id="123123" article="a" name="Some Broken Vial">
   <attribute key="weight" value="TONES" />
   <attribute key="decayTo" value="123122" /> << not broken vial
   <attribute key="duration" value="AGES" />
</item>

Yes it's possible using items.xml but this means its fixed to 1 type of item and cannot be changed. I want to be able to turn 1 item into different items.

ArturKnopik commented 3 months ago

can you try use something like that?

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
        item:setAttribute(ITEM_ATTRIBUTE_DECAYTO, 10176)
        item:setAttribute(ITEM_ATTRIBUTE_DURATION, 30) 
    item:decay()
    return true
end

PS: not tested, just checked implementations

Coldensjo commented 3 months ago

ironcore_dx_QhGjFSz5Vk Yea, it seems to work, can close this.