-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
new method itemType:getDecayTime() #2991
Conversation
if (itemType) { | ||
uint32_t decayTime = itemType->decayTime; | ||
if (decayTime == 0 && itemType->showDuration) { | ||
const ItemType& equipItemType = Item::items[itemType->transformEquipTo]; |
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.
this wont work for items that are not transformed on equip to anything else right?
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.
good catch
16:08 > print(ItemType(2050):getDecayTime()) -> 0
16:08 > print(ItemType(2051):getDecayTime()) -> 600
16:09 > print(ItemType(2052):getDecayTime()) -> 0
16:09 > print(ItemType(2053):getDecayTime()) -> 300
what other flag could be used to return correct duration for just bought torch?
this is quite problematic because the transform happens in lua now and items.xml doesn't mention it anywhere
<item id="2050" article="a" name="torch">
<attribute key="slotType" value="ammo" />
<attribute key="weight" value="500" />
<attribute key="stopduration" value="1" />
</item>
<item id="2051" article="a" name="lit torch">
<attribute key="slotType" value="ammo" />
<attribute key="weight" value="500" />
<attribute key="decayTo" value="2053" />
<attribute key="duration" value="600" />
</item>
edit: alright I think I found a solution, but it would be a weird override (not sure if suitable with tfs code style standards)
- moving
decayItems
table fromactions/scripts/other/decayTo.lua
to libs - this
if not overrided then -- prevent loop disaster on reload
function ItemType:getDecayTime()
-- if original function gives 0 then search this global table and check the transformed item end
end
overrided = true
end
what do you think?
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.
eventually we can do two different functions, like
:getDecayTime()
would work as current getDecayTime():getBaseDecayTime()
would be written in lua and check lua libs as well
otherwise it's probably not the greatest idea to hardcode a variable from some random lua file
@Zbizu I want to make you aware of https://github.com/gesior/forgottenserver/commit/395e6955a31fda12c1a48a37fbc017e2a373fc7b by @gesior. It adds support for decay by timestamp using a new
|
I was aware of his PR, but thought that it covers slightly different area than mine. I will watch his thread. Will reopen if his changes don't go through. |
fixed version of #1229 (added missing & symbol)
closes #1212
test results:
didn't had a single crash