CreatureEvent [TFS 1.3] Upgrade System

Aeronx

Active Member
Joined
Dec 17, 2015
Messages
708
Best answers
9
Reaction score
91
About monster levels, even if you dont want to create one (we talked about this before, since its needs C++ changes its now worth it at the moment), you could set an invisible level to monsters, there are no levels, but there are monsters way stronger that others.
(My monster level is 95% based on lua, only code i needed to add to source is the name change, which sets the level. Based on monster level from name, the monster will have more loot, exp, hp, dmg, etc)

You could use their max hp and the experience they give to the player to set a value (level) to that monster. (Normally on tibia, higher HP pool and higher exp, the stronger the monster is, meaning higher "level")
 
OP
oen432

oen432

Intermediate OT User
Joined
Oct 3, 2014
Messages
392
Best answers
7
Reaction score
360
Location
Poland
Monster levels are already done here Feature - [TFS 1.3] Monster Levels (https://otland.net/threads/tfs-1-3-monster-levels.260470/)
Now the question is... should I go with it and add Lua support for that feature and then update Upgrade System based on Monster Levels?

You could use their max hp and the experience they give to the player to set a value (level) to that monster. (Normally on tibia, higher HP pool and higher exp, the stronger the monster is, meaning higher "level")
Oh, yeah, I did that once to make custom drop rate based on how strong the monster is.
 

Aeronx

Active Member
Joined
Dec 17, 2015
Messages
708
Best answers
9
Reaction score
91
Me! personaly and ONLY ME: i dont think you should make your system based on that code (i think that code its a bit limited when we talk about monster levels customization) and also, not everybody know how to compile a server, etc etc.

If you already did something like using max hp/exp to set a monster "value", i'd like to think its the way to go. An average programmer will sure have the skills to change that piece of code to make the item level based on their liking, customization is key.
 
OP
oen432

oen432

Intermediate OT User
Joined
Oct 3, 2014
Messages
392
Best answers
7
Reaction score
360
Location
Poland
Me! personaly and ONLY ME: i dont think you should make your system based on that code (i think that code its a bit limited when we talk about monster levels customization) and also, not everybody know how to compile a server, etc etc.

If you already did something like using max hp/exp to set a monster "value", i'd like to think its the way to go. An average programmer will sure have the skills to change that piece of code to make the item level based on their liking, customization is key.
Ok then, I'll try with HP and EXP to determine monster power level and if that fails, I'll go with Monsters Level. I really like the idea of how iLvl can be used and finding the best (and easiest not just for me) way to make it as good as possible will be my priority right now.
 

Aeronx

Active Member
Joined
Dec 17, 2015
Messages
708
Best answers
9
Reaction score
91
Im glad you like the idea! Let us know how the idea goes! Keep it up!
 

jel

Well-Known Member
Joined
Mar 22, 2014
Messages
60
Best answers
0
Reaction score
2
help me error:
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:p[email protected]
data/events/scripts/player.lua:300: attempt to call global 'onUpgradeMove' (a ni
l value)
stack traceback:
[C]: in function 'onUpgradeMove'
data/events/scripts/player.lua:300: in function <data/events/scripts/pla
yer.lua:299>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:p[email protected]
data/events/scripts/player.lua:300: attempt to call global 'onUpgradeMove' (a ni
l value)
stack traceback:
[C]: in function 'onUpgradeMove'
data/events/scripts/player.lua:300: in function <data/events/scripts/pla
yer.lua:299>
 
OP
oen432

oen432

Intermediate OT User
Joined
Oct 3, 2014
Messages
392
Best answers
7
Reaction score
360
Location
Poland
help me error:
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:p[email protected]
data/events/scripts/player.lua:300: attempt to call global 'onUpgradeMove' (a ni
l value)
stack traceback:
[C]: in function 'onUpgradeMove'
data/events/scripts/player.lua:300: in function <data/events/scripts/pla
yer.lua:299>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:p[email protected]
data/events/scripts/player.lua:300: attempt to call global 'onUpgradeMove' (a ni
l value)
stack traceback:
[C]: in function 'onUpgradeMove'
data/events/scripts/player.lua:300: in function <data/events/scripts/pla
yer.lua:299>
Looks like you didn't add dofile('data/upgrade_system_core.lua') properly to data/global.lua.
 

jel

Well-Known Member
Joined
Mar 22, 2014
Messages
60
Best answers
0
Reaction score
2
does not have this function in upgrade_system_core.lua

onUpgradeMove(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
 
OP
oen432

oen432

Intermediate OT User
Joined
Oct 3, 2014
Messages
392
Best answers
7
Reaction score
360
Location
Poland
does not have this function in upgrade_system_core.lua

onUpgradeMove(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
Oh yeah, download latest version

Moderators here are sleeping and can't update posts that were reported 5 days ago.
 

jel

Well-Known Member
Joined
Mar 22, 2014
Messages
60
Best answers
0
Reaction score
2
Oh yeah, download latest version

Moderators here are sleeping and can't update posts that were reported 5 days ago.
error continues
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:p[email protected]
data/events/scripts/player.lua:300: attempt to call global 'onUpgradeMove' (a ni
l value)
stack traceback:
[C]: in function 'onUpgradeMove'
data/events/scripts/player.lua:300: in function <data/events/scripts/pla
yer.lua:299>

onUpgradeMove(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
 
OP
oen432

oen432

Intermediate OT User
Joined
Oct 3, 2014
Messages
392
Best answers
7
Reaction score
360
Location
Poland
error continues
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:p[email protected]
data/events/scripts/player.lua:300: attempt to call global 'onUpgradeMove' (a ni
l value)
stack traceback:
[C]: in function 'onUpgradeMove'
data/events/scripts/player.lua:300: in function <data/events/scripts/pla
yer.lua:299>

onUpgradeMove(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
There is no onUpgradeMove function anymore. Read this post
 

jel

Well-Known Member
Joined
Mar 22, 2014
Messages
60
Best answers
0
Reaction score
2
There is no onUpgradeMove function anymore. Read this post
fix error
Code:
function onUpgradeMove(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
  local oldItem = player:getSlotItem(toPosition.y)
  if fromPosition.y >= 64 and toPosition.y >= 64 or fromPosition.x ~= 65535 and toPosition.x ~= 65535 then
    return
  end
  if fromPosition.y >= 64 and toPosition.x ~= 65535 or fromPosition.x ~= 65535 and toPosition.y >= 64 then
    return
  end

  local bonuses = nil

  if not oldItem then
    bonuses = item:getBonusAttributes()
  else
    bonuses = oldItem:getBonusAttributes()
  end

  if not bonuses then
    return
  end

  if bonuses then
    for k, value in pairs(bonuses) do
      value[1] = value[1]
      value[2] = value[2]
      local attr = US_ENCHANTMENTS[value[1]]
      if attr then
        if attr.combatType == US_TYPES.CONDITION then
          if US_CONDITIONS[attr.name] and US_CONDITIONS[attr.name][value[2]] then
            if attr.condition ~= CONDITION_MANASHIELD then
              player:removeCondition(attr.condition, CONDITIONID_COMBAT, 1000 + math.ceil(value[1] ^ 2) + value[2])
            else
              player:removeCondition(attr.condition, CONDITIONID_COMBAT)
            end
          end
        end
      end
    end
  end
end
 
OP
oen432

oen432

Intermediate OT User
Joined
Oct 3, 2014
Messages
392
Best answers
7
Reaction score
360
Location
Poland
fix error
Code:
function onUpgradeMove(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
  local oldItem = player:getSlotItem(toPosition.y)
  if fromPosition.y >= 64 and toPosition.y >= 64 or fromPosition.x ~= 65535 and toPosition.x ~= 65535 then
    return
  end
  if fromPosition.y >= 64 and toPosition.x ~= 65535 or fromPosition.x ~= 65535 and toPosition.y >= 64 then
    return
  end

  local bonuses = nil

  if not oldItem then
    bonuses = item:getBonusAttributes()
  else
    bonuses = oldItem:getBonusAttributes()
  end

  if not bonuses then
    return
  end

  if bonuses then
    for k, value in pairs(bonuses) do
      value[1] = value[1]
      value[2] = value[2]
      local attr = US_ENCHANTMENTS[value[1]]
      if attr then
        if attr.combatType == US_TYPES.CONDITION then
          if US_CONDITIONS[attr.name] and US_CONDITIONS[attr.name][value[2]] then
            if attr.condition ~= CONDITION_MANASHIELD then
              player:removeCondition(attr.condition, CONDITIONID_COMBAT, 1000 + math.ceil(value[1] ^ 2) + value[2])
            else
              player:removeCondition(attr.condition, CONDITIONID_COMBAT)
            end
          end
        end
      end
    end
  end
end
No! Read this post!
onUpgradeMove and onMoveItem event are no longer supported by this feature.
 

Ahilphino

Veteran OT User
Joined
Jun 5, 2013
Messages
1,395
Best answers
1
Reaction score
408
nice men, must be fun being tech support for these guys that cant read :O
thats kinda what i mean men! u are creating sick systems for people that can't read. we will see these awesome sistems in awful servers and no good servers wanna use such sistens when they have been seen many times already!

But im still excited to see what new stuff u can do for the cummunity even if u post them like this
 

Aeronx

Active Member
Joined
Dec 17, 2015
Messages
708
Best answers
9
Reaction score
91
@Ahilphino You are are right just in part. While people like that, that cant not even read properly shouldnt have too much attention, others will use this system and make it their own, customizing it at maximum. He's just giving us a tool with good coding, after that is up to you to make it shine to make a difference from those guys who cant even read (which wouldnt be hard at all lol xD)..
 

Pedrook

Excellent OT User
Joined
May 24, 2009
Messages
351
Best answers
3
Reaction score
75
man, I had a hard time putting it to work on my server, because it was not compatible with N things, but I did, I did, and I did it. It's nice to see, I had to take some damages, balance for the server to be low exp rpg, but then, it's brilliant, and the ideas I see on the topic are headed for something even better.
Thank you.
 
OP
oen432

oen432

Intermediate OT User
Joined
Oct 3, 2014
Messages
392
Best answers
7
Reaction score
360
Location
Poland
Few days of work, A LOT of changes, reworked functionalities and new features. Everything is in the change log below.
There are new configuration steps.

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.

[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
 

Attachments

Last edited:

Pedrook

Excellent OT User
Joined
May 24, 2009
Messages
351
Best answers
3
Reaction score
75
my god, what a fucking update, great ideas, I'll be updating soon, thanks for that.
 
OP
oen432

oen432

Intermediate OT User
Joined
Oct 3, 2014
Messages
392
Best answers
7
Reaction score
360
Location
Poland
Hey guys,
I really thought about it and came to conclusion that it's not worth posting files and updates here on Otland. Waiting 3-4 days for your post to be edited after reporting it is just annoying.
From now on I'll be making updates to my stuff on my GitHub. Every new update will be there with everything updated, including installation and all.
I'll post here if there are any new updates, but files and stuff will be on my Github.

GitHub repository: TFS-Upgrade-System
Download: Releases
 
Top