Lua Function [TFS 1.3] Item abilities via Lua

Discussion in 'C++ Codes' started by Vulcan_, Aug 13, 2018 at 1:36 AM.

Tags:
  1. Vulcan_

    Vulcan_ Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    3,870
    Likes Received:
    1,755
    Best Answers:
    292
    SQL needed to execute in db:
    Code (SQL):
    1. ALTER TABLE `player_items` ADD `abilities` BLOB NOT NULL;
    2. ALTER TABLE `player_depotitems` ADD `abilities` BLOB NOT NULL;
    3. ALTER TABLE `player_inboxitems` ADD `abilities` BLOB NOT NULL;
    C++ Code: Vulcanx/forgottenserver

    New Lua functions:
    • item:setAbility(key, value)
    • item:getAbility(key)
    • item:removeAbility(key)
    Enums (keys):
    Code (Text):
    1. ITEM_ABILITY_HEALTHGAIN
    2. ITEM_ABILITY_HEALTHTICKS
    3. ITEM_ABILITY_MANAGAIN
    4. ITEM_ABILITY_MANATICKS
    5. ITEM_ABILITY_CONDITIONSUPPRESSIONS
    6. ITEM_ABILITY_MAXHITPOINTS
    7. ITEM_ABILITY_MAXMANAPOINTS
    8. ITEM_ABILITY_MAGICPOINTS
    9. ITEM_ABILITY_MAXHITPOINTSPERCENT
    10. ITEM_ABILITY_MAXMANAPOINTSPERCENT
    11. ITEM_ABILITY_MAGICPOINTSPERCENT
    12. ITEM_ABILITY_SKILLFIST
    13. ITEM_ABILITY_SKILLCLUB
    14. ITEM_ABILITY_SKILLSWORD
    15. ITEM_ABILITY_SKILLAXE
    16. ITEM_ABILITY_SKILLDISTANCE
    17. ITEM_ABILITY_SKILLSHIELD
    18. ITEM_ABILITY_SKILLFISHING
    19. ITEM_ABILITY_CRITICALHITCHANCE
    20. ITEM_ABILITY_CRITICALHITAMOUNT
    21. ITEM_ABILITY_LIFELEECHCHANCE
    22. ITEM_ABILITY_LIFELEECHAMOUNT
    23. ITEM_ABILITY_MANALEECHCHANCE
    24. ITEM_ABILITY_MANALEECHAMOUNT
    25. ITEM_ABILITY_SPEED
    26. ITEM_ABILITY_ABSORBPHYSICAL
    27. ITEM_ABILITY_ABSORBENERGY
    28. ITEM_ABILITY_ABSORBEARTH
    29. ITEM_ABILITY_ABSORBFIRE
    30. ITEM_ABILITY_ABSORBWATER
    31. ITEM_ABILITY_ABSORBICE
    32. ITEM_ABILITY_ABSORBHOLY
    33. ITEM_ABILITY_ABSORBDEATH
    34. ITEM_ABILITY_FIELDABSORBPHYSICAL
    35. ITEM_ABILITY_FIELDABSORBENERGY
    36. ITEM_ABILITY_FIELDABSORBEARTH
    37. ITEM_ABILITY_FIELDABSORBFIRE
    38. ITEM_ABILITY_FIELDABSORBWATER
    39. ITEM_ABILITY_FIELDABSORBICE
    40. ITEM_ABILITY_FIELDABSORBHOLY
    41. ITEM_ABILITY_FIELDABSORBDEATH
    42. ITEM_ABILITY_ELEMENTTYPE
    43. ITEM_ABILITY_ELEMENTDAMAGE
    44. ITEM_ABILITY_MANASHIELD
    45. ITEM_ABILITY_INVISIBLE
    46. ITEM_ABILITY_REGENERATION
    Examples:
    Notes:
    • For regeneration to work (HEALTHGAIN, MANAGAIN) you need to also set ITEM_ABILITY_REGENERATION to 1.
    • ITEM_ABILITY_REGENERATION, ITEM_ABILITY_MANASHIELD, and ITEM_ABILITY_INVISIBLE should only be set to 1 to enable the ability.
    • If you want to "set an ability to 0" aka item:setAbility(key, 0) it won't work. Use item:removeAbility(key) instead.
    • Setting an ability while an item is equipped will not automatically update it and apply the stats. For it to update, you must de-equip and re-equip the item.
    • For now, this only works with TFS 1.3. If you use 1.2 and still want to use this code you can apply this commit to your sources for critical and leech skills
    • ITEM_ABILITY_ELEMENTTYPE and ITEM_ABILITY_ELEMENTDAMAGE must be paired together to work properly
    • Items that are not loaded through movements.xml will not register abilities
    • Weapons that are loaded through weapons.xml will not register abilities
    This is basically just item attributes but for abilities (abilities are only loaded through items.xml and before this you were not able to modify them through Lua and create unique items without using workarounds with movement scripts + conditions.
    I figured it was done enough for me to "release" it after a week (although I still have more planned for this, there are a lot of things I need to add, fix, and optimize)
    I didn't thoroughly test everything (especially item descriptions), so if you find a bug let me know on this thread and I will fix it.
    Be sure to keep up to date with this branch to get the latest bugfixes with this code. (further commits will have the prefix Update so you know what to look for)
     
  2. pepsiman

    pepsiman ---

    Joined:
    Nov 17, 2017
    Messages:
    48
    Likes Received:
    13
    Best Answers:
    4
    awesome release! thanks for sharing
     
  3. ScorpionOT

    ScorpionOT uber n00b

    Joined:
    Mar 28, 2015
    Messages:
    216
    Likes Received:
    38
    Best Answers:
    5
    wooow vulcan thanxx see you relly can help ppll in this community!
     
  4. ckripz

    ckripz Member

    Joined:
    May 30, 2013
    Messages:
    54
    Likes Received:
    6
    Best Answers:
    0
  5. Raggaer

    Raggaer Godly Member

    Joined:
    Jul 25, 2012
    Messages:
    1,521
    Likes Received:
    865
    Best Answers:
    8
    Finally BRs contribute to the community
     
    pepsiman, Peonso and eldera like this.
  6. Peonso

    Peonso 1337

    Joined:
    Jan 14, 2008
    Messages:
    1,386
    Likes Received:
    888
    Best Answers:
    20
    I hate you, it took me 7 month to gather the courage to dig in this task, and 5 days after I end my system with tons of workarounds that barely works you release this jewel. What I have and woul be cool for you to add is bonus % damage for elemental damage, like 32% fire damage item that raises all damage from you fires sources.
     
    Vulcan_ likes this.
  7. Vulcan_

    Vulcan_ Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    3,870
    Likes Received:
    1,755
    Best Answers:
    292
    lol barely took me less than a week
    the current goal is to have the core abilities that are already in tfs working 100% properly bug-free with this system before i add custom things to it
     

Share This Page

Loading...