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

Creating new SKILLS or player basic stats.

samco

4x4 Developer.
Joined
Jul 3, 2007
Messages
1,077
Solutions
9
Reaction score
260
Location
Spain
Hi, im trying to develop some new features on the combat system that Tibia offers. I started trying to add 2 new attributes to the players, LIFESTEAL and CRITCHANCE. As they are described by their names, the first one will make you gain X% hp from every physical attack, and the crit chance is a % to hit with a 1.5X damage, on physical too.

Well, im kinda new to the OT codes, so im trying not to miss anywhere to place this new changes:

What it should do:
->Add new attributes in Vocations.xml. I want player to gain some % on every lvl advance. It should be low values.
-> Add new attributes in Items.xml. The items should have tags like skilldist, etc... So items will improve the % of lifesteal or crit.

Can anyone help me trying to get this? I'll obvs release when its 100% .

(I've searched for this, but nothing found)

Working on last TFS source.

PD: I'm now at work, will post what i have coded so far (not much, im still kinda lost on OT code)
 
If you do it in LUA then I execute my custom combat skills in creaturescripts onHealthChange

To keep track of player "imaginery skills" use storage values
To display skills, use Modal window (also in creaturescripts) or text messages. (if you use otc, then somehow its possible to add it as part of UI)
To give extra bonus when leveling up, either use onAdvance function to give storage values or use player level in the formula where you calculate the chance
onEquip and onDeEquip in movements, can be used to add and remove storage values
 
So do you really think its worth to do it LUA way instead of sources? I already though on that possibility, but wasnt 100% sure.

Edit:
The pain on lua way is about adding all extra parameters to the items :/
 
Last edited:
So do you really think its worth to do it LUA way instead of sources? I already though on that possibility, but wasnt 100% sure.

Edit:
The pain on lua way is about adding all extra parameters to the items :/
If changing armor value on item iis hard and annoying then idd, that method is not good for you.
 
If changing armor value on item iis hard and annoying then idd, that method is not good for you.
Its not hard, just boring to add every item with their particular extra attr. I have to set the lifesteal and critchance and set the setStorageValue(STORAGEVALUE_LIFESTEAL, getStorageValue(STORAGEVALUE_LIFESTEAL) + itemarray['itemid'])).
 
Make a weapon table (in lua) containing the itemid and the amount of crit and lifesteal that you want for each one, I think is almost the same or even easier than editing the items.xml.

whitevo already told you everything you need to edit/add.
 
Make a weapon table (in lua) containing the itemid and the amount of crit and lifesteal that you want for each one, I think is almost the same or even easier than editing the items.xml.

whitevo already told you everything you need to edit/add.
Yes, thats what i though.

Im now having problems with the creaturescript:

lifesteal.lua
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)  
    if origin == ORIGIN_MELEE or origin == ORIGIN_RANGED then
        local lf = attacker:getStorageValue(STORAGEVALUE_LIFESTEAL)
        local cc = attacker:getStorageValue(STORAGEVALUE_CRITCHANCE)
        local life = 0
       if math.random(100) <= cc then
           primaryDamage = primaryDamage * 1.5
           creature:say("Critical!", TALKTYPE_MONSTER_SAY)
       end  
       life = primaryDamage + (lf/100)
          attacker:addHealth(life)
          attacker:sendTextMessage(MESSAGE_EVENT_ORANGE, "LifeDrain: " .. life .. "hp.\n")
       return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
end

Its not doing anything. No errors on console neither.

PD: Yes, its registered OnLogin and its on creaturescript.xml as
Code:
    <event type="healthchange" name="LifeSteal" script="lifesteal.lua"/>
 
You need to register the monster (creature) in that case, not the player (attacker). If you PvP, the script should be working.
 
You need to register the monster (creature) in that case, not the player (attacker). If you PvP, the script should be working.
correct. Either registrate directly on monster.XML or on combat damage register the script on target.

On items all you have a tto add is: cc = 3
Your receiver should understand it means 3% crit chance
 
I thought it was for all kind of creatures. So if i need this to work on both, creatures and monsters, i need to do the same script on monsters, rigth?. Well, ill try it tomorrow (I tested on monsters only, thats why it wasnt working)

Thank you both. Will post tomorrow about results.
 
Search the resources, there is a release on how to create "custom skills" using metatables in libraries sub-section. It's outdated, but can easily be made for 1.x as it is written for lua not for server type, only a few changes to be made and then its very easy to create a hundred custom skills if you want
 
Hi again. I might be missing something, but i dont get about registering the monster(creature) instead of attacker. The onHealthChange function, has two params, creature and attacker. Creature is the Creature who is being hurt, and attacker is the player performing the attack, or im wrong?. I followed up the guide from [TFS 1.0] Critical Hit % - Permanent, about that function, and hes using it vs a monster creature, and it does work.

How im supposed to add this kind of event to work on monster too then?
 
Hi again. I might be missing something, but i dont get about registering the monster(creature) instead of attacker. The onHealthChange function, has two params, creature and attacker. Creature is the Creature who is being hurt, and attacker is the player performing the attack, or im wrong?. I followed up the guide from [TFS 1.0] Critical Hit % - Permanent, about that function, and hes using it vs a monster creature, and it does work.

How im supposed to add this kind of event to work on monster too then?
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Big Daddy" nameDescription="a Big Daddy" race="blood" experience="0" speed="150" manacost="695">
    <health now="30000" max="30000"/>
    <look type="277" corpse="7740"/>
    <targetchange interval="10000" chance="25"/>
   
    <flags>
        <flag summonable="0"/>
        <flag attackable="1"/>
        <flag hostile="1"/>
        <flag illusionable="0"/>
        <flag convinceable="1"/>
        <flag pushable="0"/>
        <flag canpushitems="1"/>
        <flag canpushcreatures="1"/>
        <flag targetdistance="1"/>
        <flag runonhealth="0"/>
    </flags>
   
    <attacks>
        <attack name="physical"     interval="2000"     min="-90"   max="-45"   range="2"/>
    </attacks>
   
    <elements>
        <element physicalPercent="5"/>
        <element icePercent="10"/>
        <element poisonPercent="30"/>
        <element firePercent="40"/>
        <element energyPercent="10"/>
        <element holyPercent="30"/>
        <element deathPercent="-10"/>
        <element drownPercent="30"/>
        <element lifedrainPercent="30"/>
        <element manadrainPercent="30"/>   
    </elements>
   
    <voices interval="5000" chance="10">
        <voice sentence="Time to Squish Scrubz!!"/>
    </voices>
    <script>
        <event name="DeBuffs"/>
        <event name="bossKill"/>
        <event name="monsterAI"/>
    </script>

you see the <event name="creaturescript name" />

This is how you registrate directly on monster.

next method is: Creature(cid):refgisterEvent("creaturescript name")
 
Oh, i see thank you, no i have the script working perfectly on monsters. So there isnt a way to register the event for all the creatures, without writting it down on their xml? I though about onThink, but it would be executed just too many times. There no onSpawn or smthing like that, i guess.

Ima start working on the equip / deequip items. I appreciate all your help guys.
 
You can register the creatures via onTargetCombat and onAreaCombat (events).
And if the weapons are the only itemtype that give you crit/lifesteal bonus then you don't really need a movement script.
 
You can register the creatures via onTargetCombat and onAreaCombat (events).
And if the weapons are the only itemtype that give you crit/lifesteal bonus then you don't really need a movement script.
All kind of items will be able to give you those kind of stats, armors, helmets, boots, shields etc. So i think ill need that. But the onTargetCombat will cause too many times the server try to register the event right?
 
All kind of items will be able to give you those kind of stats, armors, helmets, boots, shields etc. So i think ill need that. But the onTargetCombat will cause too many times the server try to register the event right?
on each hit idd, but not only i dont think nothing happens when you reregister event you could also create a boolean value does this CID already have it registered.
 
Back
Top