• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

CreatureEvent [TFS 1.3 / 1.4] Upgrade System

Anyone know how to show item rarity on a item that dont have rarity? (items that are not equipment like 10305, 7368 )
before i upgraded my ot to 1.4 8.6 (was before 1.3) items like assassin star showed rarity but now they dont.

On assassin star i can give item level when taking a chest with this code but i cant make any rarity on it
Lua:
reward:setItemLevel((math.random(85, 95)))
reward:setRarity((math.random(2, 3)))

And some other custom items dont show item level nether rarity anymore. (same code as above to get the item)
Code:
18:45 You see a [Tier 1] Oblivion Trinket (Arm:1).
It weighs 18.00 oz.
Right Click to see stats.
Item ID: 10305
 
Last edited:
I am using otservbr, I have the callback functions installed, all system works perfectly.

the only change I made:
Original Line:
MoveItemEvent.onMoveItem = function(player, item, fromPosition, toPosition)

Change to:
MoveItemEvent.onMoveItem = function(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)


because with the original line: I can't unequip any part of the set on players xD

and have this error in console:
attempt to index local 'fromPosition' (a number value)

I have been analyzing in detail, the problem is in fromPosition.

In line:
if fromPosition.y >= 64 or fromPosition.x ~= CONTAINER_POSITION then
When I remove that line, now it doesn't put the attributes, it just removes them.
How do you manage to work on OTServBr?
 
Last edited:
This system is awsome, can do so many things with it for my server.

But im curious about your Client HUD as well, showing the items stats only by passing the mouse above it and those health/mana bars are sick

is there anywhere I can find a client like this? or anywhere I can start learning how to do it?
 
This system is awsome, can do so many things with it for my server.

But im curious about your Client HUD as well, showing the items stats only by passing the mouse above it and those health/mana bars are sick

is there anywhere I can find a client like this? or anywhere I can start learning how to do it?
Thank you!
About that item info on mouse hover. This is my old tooltips system, which is now way better and really popular on many servers.
You can learn coding and make it yourself. I'll leave you a private message for 2nd option cause rules of this forum are preventing me to talk about it publicly.
 
Hello, system is working great but I'm running into the issue where if Equip/Unequip the item through Hotkeys the attributes are not applied/removed, did I do something wrong?

*Noticed equipping the item through hotkey also lets me equip an unidentified item
 
Hello, system is working great but I'm running into the issue where if Equip/Unequip the item through Hotkeys the attributes are not applied/removed, did I do something wrong?

*Noticed equipping the item through hotkey also lets me equip an unidentified item
If you have installed everything correctly then it's TFS fault. Lack of global Equip/Unequip event is killing this system already.
 
Im trying to remove some of the attributes, can I remove them by only removing them in the Array at upgrade_system_const.lua or its more complicated than that?

another change im trying to make, is to do the crystals drop, instrad of dropping only the crystal fossil, im trying to make other crystals drop as well with different chances

i searched a little, and found this at the core.lua

Code:
    local iLvl = monsterType:calculateItemLevel()
    if iLvl >= US_CONFIG.CRYSTAL_FOSSIL_DROP_LEVEL then
      if math.random(US_CONFIG.CRYSTAL_FOSSIL_DROP_CHANCE) == 1 then
        corpse:addItem(US_CONFIG.CRYSTAL_FOSSIL, 1)
        local specs = Game.getSpectators(corpsePosition, false, true, 9, 9, 8, 8)
        if #specs > 0 then
          for i = 1, #specs do
            local player = specs
            player:say("Crystal Fossil!", TALKTYPE_MONSTER_SAY, false, player, corpsePosition)
          end
        end
      end
    end

all i would need to do change this part to add the other crystals drops, and add the variables at const.lua as well?

or is more pieces of code that would be needed to change?
 
Last edited by a moderator:
I Think 55 different attributes are a little too much, can I remove attributes by only removing them in the Array at upgrade_system_const.lua?
Yup. Just make sure to keep indexes in numerical order.

another change im trying to make, is to do the crystals drop, instrad of dropping only the crystal fossil, im trying to make other crystals drop as well with different chances
Replace fossil drop with fossil extractor code and adjust so it works.
 
Yup. Just make sure to keep indexes in numerical order.


Replace fossil drop with fossil extractor code and adjust so it works.
not sure i undestood well the last part about replacing the fossil drop with fossil extractor code, not sure if i explained well as well

im planning to make other crystals like upgrade crystal and enchantment crystal drop as loot from monsters as well, same as the fossil
 
not sure i undestood well the last part about replacing the fossil drop with fossil extractor code, not sure if i explained well as well

im planning to make other crystals like upgrade crystal and enchantment crystal drop as loot from monsters as well, same as the fossil
Ahh, I thought you wanted crystals drop instead of fossils. In that case, you have 2 options. Edit fossil drop code to use table with drops or copy that code and change chances and item id.
 
Ahh, I thought you wanted crystals drop instead of fossils. In that case, you have 2 options. Edit fossil drop code to use table with drops or copy that code and change chances and item id.
yes, that's what i thought, my doubt is if im at the right part of the code

I found this on the core.lua, is that it? now i just have to change the code to add the other items, or copy this part and edit for other items right?

also add the drop chance, and drop level for each item as well in the config file

1642303002370.png
 
NEW UPDATES -> GitHub
Upgrade System
Tibia has flat, dull, boring and not fun items system, time to change it. Expand your server with a lot of possibilities to make grinding more satisfying. No more useless items laying around and being ignored by others, now every item can be powerful. Using special crystals, items can be upgraded with new stats and powerful attributes. New property - Item Level - which determines how powerful given item is. A lot of crystals to upgrade items even further.


New items

NameDescriptionHow to obtain
Upgrade CrystalCan be used on a piece of equipment for a chance to upgrade it.Crystal Fossil
Enchantment CrystalCan be used on a piece of equipment to add random attribute.Crystal Fossil
Alteration CrystalCan be used on a piece of equipment to remove last attribute.Crystal Fossil
Cleansing CrystalCan be used on a piece of equipment to remove all attributes.Crystal Fossil
Fortune CrystalCan be used on a piece of equipment to change value of last attribute.Crystal Fossil
Faith CrystalCan be used on a piece of equipment to change values of all attributes.Crystal Fossil
Mind CrystalUsed to extract all attributes and values and store in that crystal. Can be used again to place these attributes to a new item. Lower item rarity will remove exceeded attributes.Custom - NPC, Quests etc.
Limitless CrystalUsed to remove Item Level requirement to equip given item.Custom - NPC, Quests etc.
Mirrored CrystalUsed to make a copy of any item. Copies can't be modified and mirrored again.Custom - NPC, Quests etc.
Void CrystalUsed to transform item into random Unique type.Custom - NPC, Quests etc.
Upgrade CatalystPrevents item destroy on upgrade. Consumed on item upgrade.Custom - NPC, Quests etc.
Crystal FossilThere is unknown crystal inside, try to use crystal extractor.Randomly drops from monsters
Crystal ExtractorUsed to extract rare crystals from crystal fossil.Custom - NPC, Quests etc.
Scroll of IdentificationCan be used on unidentified item to reveal hidden attributes.Custom - NPC, Quests etc.

Attributes

  1. Max HP
  2. Max MP
  3. Magic Level
  4. Melee Skills (all in one)
  5. Fist Fighting
  6. Sword Fighting
  7. Axe Fighting
  8. Club Fighting
  9. Distance Fighting
  10. Shielding
  11. Mana Shield
  12. Life Steal
  13. Experience
  14. Physical Damage
  15. Physical Protection
  16. Energy Damage
  17. Energy Protection
  18. Earth Damage
  19. Earth Protection
  20. Fire Damage
  21. Fire Protection
  22. Ice Damage
  23. Ice Protection
  24. Holy Damage
  25. Holy Protection
  26. Death Damage
  27. Death Protection
  28. Elemental Damage (every element in one except physical)
  29. Elemental Protection (every element in one except physical)
  30. Cast Flame Strike on Attack
  31. Cast Flame Strike on Hit
  32. Cast Ice Strike on Attack
  33. Cast Ice Strike on Hit
  34. Cast Terra Strike on Attack
  35. Cast Terra Strike on Hit
  36. Cast Death Strike on Attack
  37. Cast Death Strike on Hit
  38. Cast Energy Strike on Attack
  39. Cast Energy Strike on Hit
  40. Cast Divine Missile on Attack
  41. Cast Divine Missile on Hit
  42. Explosion on Kill
  43. Regenerate Health on Kill
  44. Regenerate Mana on Kill
  45. Mana Steal
  46. Chance to regenerate full HP on Kill
  47. Chance to regenerate full MP on Kill
  48. Chance to cast Mass Healing on Attack
  49. Increased healing from all sources
  50. Additional gold from monsters loot
  51. Chance to deal double damage
  52. Chance to be revived with 100% HP and MP upon death
  53. Chance to get Bonus Damage buff on Kill
  54. Chance to get Bonus Max HP buff on Kill
  55. Chance to get Bonus Max MP buff on Kill

Item Level
Item Level (iLvl) is set for every wearable item (excluding Stackable [spears, assassins stars, ammunition etc.] and Transformable [special rings or boots]) when dropped by a monster.
Default iLvl is calculated using special algorithm that determines monster level/power based on its Max HP and Experience.
Then additional iLvl value is given based on base item stats (Atk, Def, Armor, Hit Chance). After all of that, additional stats are calculated based on item iLvl.
Upgrading item level increases iLvl in addition to bonus stats and values for bonus attributes are based on iLvl of the item.
Given all of that I have made every item different. If you drop a Giant Sword from a Behemoth and a Giant Sword from a Ferumbras they will be different in stats.
You may ask "What if someone loots Sword from high level monster and a new player gets it? That's unbalanced." but don't be afraid.
If player level is lower than iLvl of given items, they can't equip them!

Unique Items
Items with predefined attributes that can't be altered, only their values can be changed. Unidentified items can become Unique.

Installation

  1. Open data/global.lua.
  2. Add somewhere on top
    Lua:
    dofile('data/upgrade_system_core.lua')
  3. Open data/events/events.xml.
  4. Make sure you have enabled
    XML:
    <event class="Creature" method="onTargetCombat" enabled="1" />
    
    <event class="Player" method="onLook" enabled="1" />
    <event class="Player" method="onMoveItem" enabled="1" />
    <event class="Player" method="onItemMoved" enabled="1" />
    <event class="Player" method="onGainExperience" enabled="1" />
  5. Open data/events/scripts/player.lua.
  6. Find Player:onLook.
  7. Add after local description = "You see " .. thing:getDescription(distance)
    Lua:
    description = onItemUpgradeLook(self, thing, position, distance, description)
  8. Find Player:onMoveItem.
  9. Change return true from last line to
    Lua:
    return us_onMoveItem(self, item, fromPosition, toPosition)
  10. Find Player:onItemMoved.
  11. Add inside
    Lua:
    onUpgradeMoved(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
  12. Find Player:onGainExperience.
  13. Add at the end before return exp
    Lua:
    exp = us_onGainExperience(self, source, exp, rawExp)
  14. Open data/events/scripts/creature.lua.
  15. Find Creature:onTargetCombat.
  16. Add somewhere (the best place is after all events, before any event that calculates damage, like DPS Counter)
    Lua:
    target:registerEvent("UpgradeSystemHealth")
    target:registerEvent("UpgradeSystemDeath")
  17. Open data/actions/actions.xml.
  18. This is important part, you have to specify items ID for crystals, scroll of identification and crystal extractor. I have created custom items for myself and IDs are one after another so I'm using fromid and toid. I hope you can handle it.
    XML:
    <action fromid="26383" toid="26389" script="upgrade_system_actions.lua" /> <!-- Crystals and Scroll -->
    <action fromid="26393" toid="26396" script="upgrade_system_actions.lua" /> <!-- Crystals -->
    <action itemid="26391" script="upgrade_system_tool.lua" /> <!-- Crystal Extractor -->
  19. Open data/creaturescripts/creaturescripts.xml.
  20. Add
    XML:
    <event type="login" name="UpgradeSystemLogin" script="upgrade_system_cs.lua" />
    <event type="death" name="UpgradeSystemDeath" script="upgrade_system_cs.lua" />
    <event type="kill" name="UpgradeSystemKill" script="upgrade_system_cs.lua" />
    <event type="healthchange" name="UpgradeSystemHealth" script="upgrade_system_cs.lua" />
    <event type="manachange" name="UpgradeSystemMana" script="upgrade_system_cs.lua" />
    <event type="preparedeath" name="UpgradeSystemPD" script="upgrade_system_cs.lua" />
  21. Download upgrade_system.rar from attachment at the bottom of this post.
  22. Extract and copy data into your data.

Configuration
Every configuration is inside data/upgrade_system_const.lua.
I have added some comments that should explain each property. There are however few special properties for attributes.
VALUES_PER_LEVEL - this indicates max value that can be rolled for given attribute, based on item level. For example if set to 3 then every Item Level adds +3 value, at Item Level 100, max value for this attribute can be 300 (still rolled from 1 to max value).
minLevel - this indicates what Item Level is required for this attribute to be rolled. Use it to balance some early and late game attributes.
chance - chance in % that this attribute will be rolled. If you want 100% then remove that property or just set to 100.

Changelog
[2.0.0] - 2019-06-02
  • Reworked refreshing attributes when changing items
  • Reworked Item Level functionality
  • Monsters Level is now calculated using special algorithm
  • Item Level for dropped items from monsters is assigned based on Monster Level (min 1, random from monsterLevel - 5 to monsterLevel)
  • Item Level is now increased for every upgrade level
  • Item Level is now increased for every base stat of an item
  • Item Level now increases base stats for an item
  • Equipping items require player level to be equal or higher than Item Level
  • Equipping unidentified items is not possible anymore
  • Added Items Rarity - Common, max 1 slot; Rare, max 2 slots; Epic, max 3 slots; Legendary, max 4 slots
  • Rewritten onLook function. Cleaner description for items, additionally showing Total Item Level for a player that we look at.
  • Added Mind Crystal - extracts attributes from selected item and stores them in the crystal, can be then used on a different item to apply these attributes, very rare, not possible to obtain through loot
  • Added Limitless Crystal - adds special attribute (doesn't take attribute slot) "Removed Item Level Requirement" allowing item to be equipped by player with less level than Item Level, very rare, not possible to obtain through loot
  • Added Mirrored Crystal - after using on a item, makes a copy of that item with every value being the same, mirrored items can't be modified, extremely rare, not possible to obtain through loot
  • Added Void Crystal - transforms item into random Unique type, very rare, not possible to obtain through loot
  • Added new attributes:
    • Mana Steal
    • More gold from loot
    • Chance to gain full HP / MP on kill
    • Chance to deal double damage
    • Chance to cast Mass Healing on Attack
    • Chance to be revived on death
    • Chance to get buff (more damage, hp, mp) on kill for 8 seconds
    • Increased healing from all sources
  • Reworked some attributes to be more dynamic rather than fixed (Cast on Attack/Hit)
  • Added % chance (optional) property to attributes, making them harder to roll
  • Removed attributes limit for Unique items
  • New config values
  • Big thanks to @Aeronx for cool ideas and help with testing
[1.1.2] - 2019-05-26
  • Rewritten attributes refreshing when removing items
  • Removed onMoveItem event usage
[1.1.1] - 2019-05-25
  • Fixed property naming
[1.1.0] - 2019-05-24
  • Added Unique type items, predefined attributes that can't be altered, only their values can be changed. Unidentified items can become Unique.
  • Corrected onLook for plural names
[1.0.0] - 2019-05-24
  • Release version

hi bro i install it on my server but these throw errors.
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/upgrade_system_cs.lua:eek:nDeath
data/upgrade_system_core.lua:652: attempt to call method 'isContainer' (a nil va
lue)
stack traceback:
[C]: in function 'isContainer'
data/upgrade_system_core.lua:652: in function <data/upgrade_system_core.
lua:651>
 
Use Github version.
Lua Script Error: [Scripts Interface]
C:\Users\Administrator\Desktop\VagosClub\data\scripts\UpgradeSystem\core.lua
LuaScriptInterface::luaDebugPrint(). [Warning - EventCallback::register] is need
to set up a callback before register.
stack traceback:
[C]: in function 'debugPrint'
...r\Desktop\VagosClub\data\scripts/lib\event_callbacks.lua:97: in funct
ion 'register'
...or\Desktop\VagosClub\data\scripts\UpgradeSystem\core.lua:1367: in mai
n chunk

It works fine but it throws me this error when starting in the console
 
After a few days using the system,

I noticed the Explosion on Kill trigger the effect but doesn't do any dmg in the area its supposed to hit, also the double dmg doesn't work

is it just for me or its not working for everyone as well? im using tfs 1.3
 
I used a mirrored crystal in an item that were in the floor, it said "Item mirrored and placed in your backpack!" but as you would imagine, it disappeared 🤔 seems like there is a need to add a check to allow crystal usage only to items placed on player backpack

ps: the only bonus I missed was a critical damage chance/amount, other than that, great system, wonder if it could be improved if we added onInventoryUpdate to tfs?
 
I used a mirrored crystal in an item that were in the floor, it said "Item mirrored and placed in your backpack!" but as you would imagine, it disappeared 🤔 seems like there is a need to add a check to allow crystal usage only to items placed on player backpack
Hah, didn't even think about testing that. Will add check when I get few minutes to spare.

ps: the only bonus I missed was a critical damage chance/amount, other than that, great system, wonder if it could be improved if we added onInventoryUpdate to tfs?
Everytime I work on a server that uses this system I add global player event onEquip and onUnEquip. I always wondered why isn't this a thing by default in TFS. I hate this hack I had to do to make these events in pure Lua.
 
Hi @oen432 , I've been testing for a couple of hours thoroughly, Everything works according to your information.

I just wanted to comment, in protection when equipped more than 100%, for Example:
protected Ice 130%, the system recognizes only 30%, since a maximum limit of 100% is not established in the protections.

It occurs to me that it would be a good idea to set limits for each attribute, taking into account the items equipped, if you have 4 items with 20 skills sword, and the limit skill sword is 50 skills, it will only grant 50 skills swords. EXAMPLE:
in config.lua
Limit Max HP = 1000
Limit Melee Skills = 50
Limit Energy Damage = 50
etc

greetings friend.
 
Back
Top