• 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!

[TFS 1.3] Item Abilities via Lua V2

Infernum

Senator
Joined
Feb 14, 2015
Messages
5,629
Solutions
559
Reaction score
3,818
Utilizes revscripts and custom attributes unlike my last one, way less source code involved. Somewhat tested.

Functions:
  • item:setAbility(key, value)
  • item:getAbility(key)
  • item:getAbilities()
  • item:getRawAbilities()
  • player:getAbilities()

Enums:
Code:
ITEM_ABILITY_HEALTHGAIN
ITEM_ABILITY_HEALTHTICKS
ITEM_ABILITY_MANAGAIN
ITEM_ABILITY_MANATICKS
ITEM_ABILITY_STAT_MAXHITPOINTS
ITEM_ABILITY_STAT_MAXMANAPOINTS
ITEM_ABILITY_STAT_MAGICPOINTS
ITEM_ABILITY_STAT_MAXHITPOINTSPERCENT
ITEM_ABILITY_STAT_MAXMANAPOINTSPERCENT
ITEM_ABILITY_STAT_MAGICPOINTSPERCENT
ITEM_ABILITY_SKILL_FIST
ITEM_ABILITY_SKILL_CLUB
ITEM_ABILITY_SKILL_SWORD
ITEM_ABILITY_SKILL_AXE
ITEM_ABILITY_SKILL_DISTANCE
ITEM_ABILITY_SKILL_SHIELD
ITEM_ABILITY_SKILL_FISHING
ITEM_ABILITY_CRITICALHITCHANCE
ITEM_ABILITY_CRITICALHITAMOUNT
ITEM_ABILITY_LIFELEECHCHANCE
ITEM_ABILITY_LIFELEECHAMOUNT
ITEM_ABILITY_MANALEECHCHANCE
ITEM_ABILITY_MANALEECHAMOUNT
ITEM_ABILITY_SPEED
ITEM_ABILITY_ABSORBPHYSICAL
ITEM_ABILITY_ABSORBENERGY
ITEM_ABILITY_ABSORBEARTH
ITEM_ABILITY_ABSORBFIRE
ITEM_ABILITY_ABSORBWATER
ITEM_ABILITY_ABSORBICE
ITEM_ABILITY_ABSORBHOLY
ITEM_ABILITY_ABSORBDEATH
ITEM_ABILITY_MANASHIELD
ITEM_ABILITY_INVISIBLE
 

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,487
Solutions
112
Reaction score
1,721
Solid release, thanks for the contribution my dude
 

Pox

Intermediate OT User
Joined
Apr 28, 2020
Messages
149
Solutions
8
Reaction score
134
Amazing, did you solve issue with items in house?
Abilities moving to the last item in a stack.
 
OP
Infernum

Infernum

Senator
Joined
Feb 14, 2015
Messages
5,629
Solutions
559
Reaction score
3,818
Amazing, did you solve issue with items in house?
Abilities moving to the last item in a stack.
This utilizes custom attributes, I did not write my own class & serialization for these new item abilities, so serialization should be fine just like normal attributes.
 

Pox

Intermediate OT User
Joined
Apr 28, 2020
Messages
149
Solutions
8
Reaction score
134
This utilizes custom attributes, I did not write my own class & serialization for these new item abilities, so serialization should be fine just like normal attributes.

I will test tonight and see if it works the same as V1 did with items in houses, I’ll get back to you later with result!
 

MagicWall

Veteran OT User
Joined
Oct 12, 2008
Messages
111
Solutions
5
Reaction score
297
Is this system or similar interesting and popular systems (not based on official 10.98) in today's OTS, will be merge to official TFS repo? Because as we know, TFS still work on old protocol, so we need something new in OT world.
 
OP
Infernum

Infernum

Senator
Joined
Feb 14, 2015
Messages
5,629
Solutions
559
Reaction score
3,818
Is this system or similar interesting and popular systems (not based on official 10.98) in today's OTS, will be merge to official TFS repo? Because as we know, TFS still work on old protocol, so we need something new in OT world.
Not sure, it seems like we're moving in a direction which could welcome customized things like this, we'll see if my Lua item descriptions even gets merged since I made a PR last night when I finished the code.
 

God Aries

New Member
Joined
Jun 24, 2018
Messages
33
Reaction score
0
I saw a theme from a user using ITEM_ABILITY_ATTACKSPEED but I don't see that ability in this Enums list.
 

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
7,915
Solutions
197
Reaction score
3,733

God Aries

New Member
Joined
Jun 24, 2018
Messages
33
Reaction score
0

one more question, and the steps to install these item abilities v2? I get a little lost on github.

I know how to compile, don't worry, I just want to know what to add and that. 😁
 

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
7,915
Solutions
197
Reaction score
3,733
one more question, and the steps to install these item abilities v2? I get a little lost on github.

I know how to compile, don't worry, I just want to know what to add and that. 😁
click on files changed:
9Ahdslb.png


and scroll down to see the changes
 
Joined
Jun 22, 2010
Messages
267
Solutions
1
Reaction score
5
Location
Usa, Utah
Thank you for the contribution!

I compiled this on the latest TFS 1.3. It isn't showing any descriptions. I also couldn't get any of the following to work:
ITEM_ABILITY_HEALTHGAIN
ITEM_ABILITY_HEALTHTICKS
ITEM_ABILITY_MANAGAIN
ITEM_ABILITY_MANATICKS
ITEM_ABILITY_MANASHIELD

The other attributes appear to work. Any ideas?
 

nefinoo

Carnage.flv
Joined
Sep 11, 2010
Messages
423
Solutions
1
Reaction score
34
Location
Lo Mochis, Sinaloa
No i have this

Lua:
do
    local map = {
        [COMBAT_PHYSICALDAMAGE] = ITEM_ABILITY_ABSORBPHYSICAL,
        [COMBAT_ENERGYDAMAGE] = ITEM_ABILITY_ABSORBENERGY,
        [COMBAT_EARTHDAMAGE] = ITEM_ABILITY_ABSORBEARTH,
        [COMBAT_FIREDAMAGE] = ITEM_ABILITY_ABSORBFIRE,
        [COMBAT_DROWNDAMAGE] = ITEM_ABILITY_ABSORBWATER,
        [COMBAT_ICEDAMAGE] = ITEM_ABILITY_ABSORBICE,
        [COMBAT_HOLYDAMAGE] = ITEM_ABILITY_ABSORBHOLY,
        [COMBAT_DEATHDAMAGE] = ITEM_ABILITY_ABSORBDEATH,
    }

    function combatToAbilityType(combat)
        return map[combat]
    end
end

local function damageFunc(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    local player = creature:getPlayer()
    local abilities = player:getAbilities()
    local primaryKey = combatToAbilityType(primaryType)
    local secondaryKey = combatToAbilityType(secondaryType)
    local dodge = player:getAbilityValue(ITEM_ABILITY_DODGE)
    if math.random(100) <= dodge then
        player:getPosition():sendMagicEffect(CONST_ME_ASSASSIN)
        return 0, primaryType, 0, secondaryType
    end
    for id, ability in ipairs(abilities) do
        local changed = false
        if primaryKey and ability.key == primaryKey then
            primaryDamage = primaryDamage - (primaryDamage * (ability.value / 100))
            changed = true
        end
        if secondaryKey and ability.key == secondaryKey then
            secondaryDamage = secondaryDamage - (secondaryDamage * (ability.value / 100))
            changed = true
        end
        if changed then
            break
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

local healthChange = CreatureEvent('IA_healthChange')
healthChange:type('healthchange')

function healthChange.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    return damageFunc(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
end

healthChange:register()

local manaChange = CreatureEvent('IA_manaChange')
manaChange:type('manachange')

function manaChange.onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    return damageFunc(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
end

manaChange:register()

----------------------------------------------------------------------------------------------------------------------------
--                                                   REGISTRATION
----------------------------------------------------------------------------------------------------------------------------

local login = CreatureEvent('IA_login')
login:type('login')

function login.onLogin(player)
    for i = 1, 10 do
        local item = player:getSlotItem(i)
        if item then
            ItemAbilities.internalInventoryUpdate(player, item, i, true)
        end
    end
    player:registerEvent('IA_logout')
    player:registerEvent('IA_death')
    player:registerEvent('IA_healthChange')
    player:registerEvent('IA_manaChange')
    return true
end

login:register()

local logout = CreatureEvent('IA_logout')
logout:type('logout')

function logout.onLogout(player)
    for i = 1, 10 do
        local item = player:getSlotItem(i)
        if item then
            ItemAbilities.internalInventoryUpdate(player, item, i, false)
        end
    end
    return true
end

logout:register()

local death = CreatureEvent('IA_death')
death:type('death')

function death.onDeath(player)
    for i = 1, 10 do
        local item = player:getSlotItem(i)
        if item then
            ItemAbilities.internalInventoryUpdate(player, item, i, false)
        end
    end
    return true
end

death:register()
Post automatically merged:

Already edit the extensions.lua and i no longer have an error.

Code:
    <item id="2182" article="a" name="snakebite rod">
        <attribute key="description" value="It seems to twitch and quiver as if trying to escape your grip." />
        <attribute key="weight" value="1900" />
        <attribute key="weaponType" value="wand" />
        <attribute key="shootType" value="smallearth" />   
        <attribute key="criticalhitchance" value="50" />   
        <attribute key="criticalhitamount" value="25" />
        <attribute key="range" value="3" />
    </item>

But when i open the server and put the rod to attack, the critical chance is not reflected in the client's skills and the damage is not affected either.
 
Last edited:
Top