• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent [TFS 1.3 / 1.4] Upgrade System

Can someone help me with the following line of code?
LUA:
description = onItemUpgradeLook(self, thing, position, distance, description)
I noticed that if the item's name is too long, the system description does not appear. The code works, but the expected description information is not displayed.
 
Tive problema não entendi muito bem como lidar com os arquivos do revscript , poderia atualizar o tutorial?
 
Hello,
I'm currently testing this amazing script on nekiro 1.5 772.
The most of the script is working well, but I find an issue with my server.
I would like to use classic tibia client (with tibianic dll), but it crashes each time my character is trying to cast an element strike or perform an upgrade operation (use with the crystal to upgrade an item to +1)
For example, when I have an attribute "20% to cast Ice Strike on Attack dealing 1-119 damage" when it goes to the moment when this should be casted - then my client is crashing. I think maybe there are some animations with colours not supported by the classic client?
On OTClient it is working good (there is no animation with strike, but there is a hit with amount colorized by elemental colour).
I have checked in my source and the functions for HOLE, SMALLHOLE are present there.
Maybe I miss some sprites/dat informations in client files?
Maybe someone have similar issue, would be great to solve this :)
 
Thanks, will try to add some to my files. Will post a results if i manage to solve it. It would be great to have such an amazing script on 7.72 engine.
One more thing. On which version should i base? 8.6 effects should work?
Ok I see that 1.x was based on tibia 10.x, so I should look there.
 
Last edited:
With rookie 7.4 (available on download section) sprites and dat works great. Some walls had "stackable" parameter in .dat, but as soon as I changed it everything started working great.
Found that if an item is inside the corpse it drops as unidentified, and it's great, but if item drops inside the bag inside the corpse than it have item level set to 0 and it drops as common weapon already identified.

If we have loot like here:
LUA:
                <item id="2462" chance="1200"/><!-- 1.2% devil helmet -->
                <item id="2470" chance="400"/><!-- 0.4% golden legs -->
                <item id="2472" chance="100"/><!-- 0.1% magic plate armor -->
                <item id="1987" chance="100000"><!-- bag -->
                        <inside>
                                <item id="2432" chance="4000"/><!-- 4% fire axe -->
                                <item id="2393" chance="2000"/><!-- 2% giant sword -->
                                <item id="2387" chance="20000"/><!-- 20% double axe -->
                        </inside>
                </item>

Then every dropped item which is between <inside> and </inside> will drop with item level 0.

It's not a big issue. I can just modify every monster to drop everything inside the corpse istead of dropping in additional bag.

Have the newest release, working on TFS 1.5 Downgraded to 772 by Nekiro.
 
Last edited:
First of all this script is really amazing. This combinations of strike on hit/attack - this works perfectly. Really good job - I can only imagine how much work and effort it took.

After few hours of testing on downgraded tfs 1.5 I have found some bugs.
Propably they are related to this downgraded version, but maybe not.
I have tested it on clean nekiro 1.5 downgraded 772 and on Rookie 7.4 uploaded here on otland. Both use the same core engine.
I'm using the newest 3.0.3 version of the script (maybe older version would work better?)

The behaviour is really complicated but I will try to explain each case.

Case: 1
GameLog:
Start TFS Server
Login to game, Char setup: 100HP/100MP Backpack: | necklace (+100MaxHP, +100MaxMP) |
Equip necklace - 100/200HP, 100/200MP - good
DeEquip necklace - 100/100HP, 100/100MP
Equip necklace - 200/200HP, 200/200MP - bad (In ServerLog: 00:17 You were healed for 100 hitpoints.)
DeEquip necklace - 100/100HP, 100/100MP
Equip necklace - 200/200HP, 200/200MP - bad (the same every time)
DeEquip necklace - 100/100HP, 100/100MP

Case: 2
GameLog:
Start TFS Server
Login to game, Char setup: 100HP/100MP Backpack: | necklace (+100MaxHP, +100MaxMP) |
Equip necklace - 100/200HP, 100/200MP - good
Relog character
Now character have - 200/200HP, 200/200MP - bad (also in ServerLog: 00:17 You were healed for 100 hitpoints.)

Case: 3
GameLog:
Start TFS Server
Login to game, Char setup: 100HP/100MP Backpack: | necklace (+100MaxHP, +100MaxMP) | sword (+100MaxMP) | armor (+100MaxHP) |
Equip necklace -100/200HP, 100/200MP - good
Equip sword - 100/200HP, 100/300MP - good
DeEquip sword - 100/200HP, 100/200MP - good
Equip sword - 100/200HP, 100/300MP - good
DeEquip sword - 100/200HP, 100/200MP - good
Equip armor - 100/200HP, 100/300MP - good
DeEquip armor - 100/200HP, 100/200MP - good
Equip sword - 100/200HP, 100/300MP - good
Equip armor - 100/300HP, 100/300MP - good
DeEquip sword - 100/300HP, 100/200MP - good
DeEquip armor - 100/200HP, 100/200MP - good
Here all is good (I can now equip any item which gives MaxHP or MaxMP or (MaxHP and MaxMP), and it will just increase the MaxHP/MP parameter, not the current HP/MP. It looks like equiping the item with both bonuses at start - somehow prevents from setting the current HP/MP parameter as the MaxHP/MP)

Case: 4
GameLog:
Start TFS Server
Login to game, Char setup: 100HP/100MP Backpack: | necklace (+100MaxHP, +100MaxMP) | sword (+100MaxMP) | armor (+100MaxHP) |
Equip armor - 100/200HP, 100/100MP - good
Equip necklace - 100/300HP, 100/200MP - good
DeEquip necklace - 100/200HP, 100/100MP - good
Equip necklace - 100/300HP, 200/200MP - bad (The current mana regenerates because of swapping item. Now it looks like armor was holding the MaxHP value and it was correct all time, but nothing was holding the MaxMP and it regenerates the current mana)

Case: 5
GameLog:
Start TFS Server
Login to game, Char setup: 100HP/100MP Backpack: | necklace (+100MaxHP, +100MaxMP) | ring (+100MaxHP, +100MaxMP) |
Equip necklace - 100/200HP, 100/200MP - good
Equip ring - 100/300HP, 100/300MP - good
DeEquip necklace - 100/200HP, 100/200MP - good
Equip necklace - 100/300HP, 100/300MP - good
Here the ring tooks a role from necklace (inherit his ability) and now I can equip sword, armor or any item and everything will work good as long as ring stays there or other item which gives both abilitis will be equipped.

Maybe someone have an idea what can be wrong on this release? it would be really great to have it fully working on old release.
Thanks in advance for help.

Update:
With the help of DeepSeek I figured out what can cause the issue.
The AI points to this section of code in us_onEquip and us_onLogin function in core.lua:

LUA:
if attr == BONUS_TYPE_MAXHP then
if player:getHealth() == maxHP then
player:addHealth(player:getMaxHealth())
end
end
if attr == BONUS_TYPE_MAXMP then
if player:getMana() == maxMP then
player:addMana(player:getMaxMana())
end
end

It suggest to remove this conditions from code, and it really improve the behaviour.
The real question is, how big impact it can have for other parts of the script :)
But I will keep testing it.

Another update:
I figured out the root issue.
The problem occurs only when my character's current base health is equal to my character base Max Health (100 Current health and 100 Max Health).
It means - if my character have 100Current Health and 100Max Health, and I wear an item with for example MaxHP bonus- it will change my MaxHP but for the script my MaxHP will be still be equal my current Health. The script still points to the original MaxHealth value not the changed one (changed by the item).

When I set my current health/mana to 99 but keep max health/mana to 100 - everything is working well, including reloggin etc.

Again update:
DeepSeek suggested to refresh the value of current max health/mana after equipping the item, and it looks like it solved all the issues.
Maybe someone will head similiar issue, so I upload the updated fragment of code from core.lua:

LUA:
function us_onEquip(cid, iuid, slot)
    local player = Player(cid)
    if not player:getSlotItem(slot) then
        return
    end
    iuid = iuid + 1
    local slotUid = player:getSlotItem(slot):getUniqueId()
    if iuid ~= slotUid then
        return
    end
    local item = Item(iuid)
    if player and item then
        local maxHP = player:getMaxHealth() -- Get the current max health
        local maxMP = player:getMaxMana()   -- Get the current max mana
        local newBonuses = item:getBonusAttributes()
        if not newBonuses then
            return
        end

        for i = 1, #newBonuses do
            local value = newBonuses[i]
            local bonusId = value[1]
            local bonusValue = value[2]
            local attr = US_ENCHANTMENTS[bonusId]
            if attr then
                if attr.combatType == US_TYPES.CONDITION then
                    if not US_CONDITIONS[bonusId] then
                        US_CONDITIONS[bonusId] = {}
                    end
                    local itemId = item:getId()
                    if not US_CONDITIONS[bonusId][bonusValue] then
                        US_CONDITIONS[bonusId][bonusValue] = {}
                    end
                    if not US_CONDITIONS[bonusId][bonusValue][itemId] then
                        US_CONDITIONS[bonusId][bonusValue][itemId] = Condition(attr.condition)
                        if attr.condition ~= CONDITION_MANASHIELD then
                            US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(CONDITION_PARAM_SUBID, 1000 + player:getNextSubId(slot, i))
                            US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(attr.param, attr.percentage == true and 100 + bonusValue or bonusValue)
                            US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(CONDITION_PARAM_TICKS, -1)
                        else
                            US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(CONDITION_PARAM_TICKS, 86400000)
                        end
                        US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
                        player:addCondition(US_CONDITIONS[bonusId][bonusValue][itemId])

                        -- Update maxHP and maxMP after applying the condition
                        maxHP = player:getMaxHealth()
                        maxMP = player:getMaxMana()

                        -- Remove the healing logic
                        -- if attr == BONUS_TYPE_MAXHP then
                        --     if player:getHealth() == maxHP then
                        --         player:addHealth(player:getMaxHealth())
                        --     end
                        -- end
                        -- if attr == BONUS_TYPE_MAXMP then
                        --     if player:getMana() == maxMP then
                        --         player:addMana(player:getMaxMana())
                        --     end
                        -- end
                    else
                        player:addCondition(US_CONDITIONS[bonusId][bonusValue][itemId])

                        -- Update maxHP and maxMP after applying the condition
                        maxHP = player:getMaxHealth()
                        maxMP = player:getMaxMana()

                        -- Remove the healing logic
                        -- if attr.param == CONDITION_PARAM_STAT_MAXHITPOINTS then
                        --     if player:getHealth() == maxHP then
                        --         player:addHealth(player:getMaxHealth())
                        --     end
                        -- end
                        -- if attr.param == CONDITION_PARAM_STAT_MAXMANAPOINTS then
                        --     if player:getMana() == maxMP then
                        --         player:addMana(player:getMaxMana())
                        --     end
                        -- end
                    end
                end
            end
        end
    end
end

Have a great day!

And I found a posts (I corrected the search string) that everything that I wrote is incorrect, and this script should work that way. I guess the only issue can be with not healing the character when equipping the items for the first time after server booted. Need to rethink this and all possible cases.
 
Last edited:
After adding this system i cant see items with color frames any more, before i saw green and blue depnding on item lvl but cant get solve rarity frame color
 
For those who encounter a problem with items inside a bag inside a corpse:

LUA:
        for i = 0, corpse:getCapacity() do
            local item = corpse:getItem(i)
            if item then
                local itemId = item:getId()
                if itemId == 1987 then --If item inside a corpse is a bag
                    for p = 0, item:getCapacity() do --Loop to check every item inside a bag
                        local itemInBag = item:getItem(p) --Different local, maybe can be also item, idk
                            if itemInBag then
                                local itemType = itemInBag:getType()
                                if itemType then
                                    if itemType:isUpgradable() and itemType:canHaveItemLevel() then
                                        if math.random(US_CONFIG.UNIDENTIFIED_DROP_CHANCE) == 1 then
                                            itemInBag:setItemLevel(math.min(US_CONFIG.MAX_ITEM_LEVEL, math.random(math.max(1, iLvl - 5), iLvl)), true) --itemInBag at start
                                            itemInBag:unidentify()--itemInBag at start
                                        end
                                    end
                                end
                            end
                    end
                end
               
                local itemType = item:getType()
                if itemType then
                    if itemType:isUpgradable() and itemType:canHaveItemLevel() then
                        if math.random(US_CONFIG.UNIDENTIFIED_DROP_CHANCE) == 1 then
                            item:setItemLevel(math.min(US_CONFIG.MAX_ITEM_LEVEL, math.random(math.max(1, iLvl - 5), iLvl)), true)
                            item:unidentify()
                        end
                    end
                end
            end
        end
    end
end

This is the end of the us_CheckCorpse function in core.lua. It is a bit edited to meet my needs (it drops only unidentified items - not the Common/Rare/Legendary ones) but im sure you can restore this lines on your own.

I agree that this is not well written - if someone bother - feel free to edit this one.


Below is the full core.lua with changes:
-Cannot equip Unidentified/itemsWithAttributes on Arrow slot (I found it was bugged, deequipping the item to arrow slot did not removed attributes. I just blocked it entirely)
-Cannot equip items other then weapons/distance to hands (it was possible to move ring into hand and get attributes). Items with ItemLevel<=0 still can be equipped in hands, only items with attributes can't.
-Removed the healing conditions on onequip and onlogin (when player have MAXHP/MAXMP - found it bugged. Players now have to heal when they equip items for the first time - i think it is not a big deal for them. If they do not deequip this items then health/mana will be saved correctly)
-Removed the RARITY items from loot. Only unidentified items can be looted. All other items drops normal, without rarity/itemlevel etc
-Items inside a bag inside a corpse are now correctly picked by the script.

The same as above - I get that it is not correctly written. I'm not a programmer, but maybe someone will find it usefull as a start point. Most of my changes have comments. Feel free to edit this to met your needs.

Have a great day!
 

Attachments

Last edited:
To see item attributes while trading with a player just duplicate the onLook function in core.lua and edit the start and end of this function to look like this:

LUA:
--Player:onLookInTrade(partner, item, distance) or Player.onLookInTrade(self, partner, item, distance)
local LookEventInTrade = EventCallback
LookEventInTrade.onLookInTrade = function(player, partner, thing, distance, description)

--function--

LookEventInTrade:register(10)

Don't know what this (10) value means in this revscripts but it is working this way in my lab.
 
Last edited:
Hi,
I'm testing existing attributes and trying to add new ones.
I'm struggling with the HEALTHGAIN/MANAGAIN in items.
I have it done this way:
This is core.lua, the function us_onEquip(cid, iuid, slot) edited:

LUA:
        for i = 1, #newBonuses do
            local value = newBonuses[i]
            local bonusId = value[1]
            local bonusValue = value[2]
            local attr = US_ENCHANTMENTS[bonusId]
            if attr then
                if attr.combatType == US_TYPES.CONDITION then
                    if not US_CONDITIONS[bonusId] then
                        US_CONDITIONS[bonusId] = {}
                    end
                    local itemId = item:getId()
                    if not US_CONDITIONS[bonusId][bonusValue] then
                        US_CONDITIONS[bonusId][bonusValue] = {}
                    end
                    if not US_CONDITIONS[bonusId][bonusValue][itemId] then
                        US_CONDITIONS[bonusId][bonusValue][itemId] = Condition(attr.condition)
                        if attr.condition == CONDITION_REGENERATION then
                            US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(CONDITION_PARAM_SUBID, 1000 + player:getNextSubId(slot, i))
                            US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(attr.param, bonusValue)
                            US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(attr.ticks, 10000)
                            US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(CONDITION_PARAM_TICKS, -1)
                        elseif attr.condition ~= CONDITION_MANASHIELD and attr.condition ~= CONDITION_REGENERATION then
                                US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(CONDITION_PARAM_SUBID, 1000 + player:getNextSubId(slot, i))
                                US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(attr.param, attr.percentage == true and 100 + bonusValue or bonusValue)
                                US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(CONDITION_PARAM_TICKS, -1)
                        else
                            US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(CONDITION_PARAM_TICKS, 86400000)
                        end
                        US_CONDITIONS[bonusId][bonusValue][itemId]:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
                        player:addCondition(US_CONDITIONS[bonusId][bonusValue][itemId])
                    else
                        player:addCondition(US_CONDITIONS[bonusId][bonusValue][itemId])
                    end
                end
            end
        end

And the config.lua parameters like this:
LUA:
  [45] = {
    name = "Health Regen",
    combatType = US_TYPES.CONDITION,
    condition = CONDITION_REGENERATION,
    param = CONDITION_PARAM_HEALTHGAIN,
    ticks = CONDITION_PARAM_HEALTHTICKS,
    VALUES_PER_LEVEL = 0.5,
    format = function(value)
      return "Health Regen for " .. value .. " at every 10 seconds"
    end,
    itemType = US_ITEM_TYPES.RING + US_ITEM_TYPES.NECKLACE,
    minLevel = 30,
    chance = 10
  },
  [46] = {
    name = "Mana Regen",
    combatType = US_TYPES.CONDITION,
    condition = CONDITION_REGENERATION,
    param = CONDITION_PARAM_MANAGAIN,
    ticks = CONDITION_PARAM_MANATICKS,
    VALUES_PER_LEVEL = 0.5,
    format = function(value)
      return "Mana Regen for " .. value .. " at every 10 seconds"
    end,
    itemType = US_ITEM_TYPES.RING + US_ITEM_TYPES.NECKLACE,
    minLevel = 30,
    chance = 10
  }


Any advice if that is a proper way to handle this? im really newbie in lua scripting, but trying my best :)

I have also added haste bonus for 8 seconds based on Oen examples (if someone is interested):
LUA:
  [44] = {
    name = "Max Speed Buff",
    combatType = US_TYPES.TRIGGER,
    triggerType = US_TRIGGERS.KILL,
    buff = true,
    VALUES_PER_LEVEL = 0.5,
    execute = function(player, value)
      if math.random(100) < 99 then
        local pid = player:getId()
        local buffId = 4
        if not US_BUFFS[pid] then
          US_BUFFS[pid] = {}
        end
        if not US_BUFFS[pid][buffId] then
          US_BUFFS[pid][buffId] = {}
          US_BUFFS[pid][buffId].condition = Condition(CONDITION_HASTE)
          US_BUFFS[pid][buffId].condition:setParameter(CONDITION_PARAM_SPEED, 100 + value)
          US_BUFFS[pid][buffId].condition:setParameter(CONDITION_PARAM_TICKS, 8000)
          player:addCondition(US_BUFFS[pid][buffId].condition)
          player:sendTextMessage(MESSAGE_INFO_DESCR, "Max Speed Buff applied for 8 seconds!")
          US_BUFFS[pid][buffId].event = addEvent(us_RemoveBuff, 8000, pid, buffId, "Max Speed Buff")
        else
          stopEvent(US_BUFFS[pid][buffId].event)
          player:sendTextMessage(MESSAGE_INFO_DESCR, "Max Speed Buff reapplied for 8 seconds!")
          US_BUFFS[pid][buffId].event = addEvent(us_RemoveBuff, 8000, pid, buffId, "Max Speed Buff")
          player:removeCondition(US_BUFFS[pid][buffId].condition)
          player:addCondition(US_BUFFS[pid][buffId].condition)
        end
      end
    end,
    format = function(value)
      return "20%% to get " .. value .. "%% Max Speed Buff for 8 sec. on Kill"
    end,
    itemType = US_ITEM_TYPES.RING + US_ITEM_TYPES.NECKLACE,
    minLevel = 30,
    chance = 10
  },

Have a great day all!
 
Last edited:
Increase mana healing by mana potions:
LUA:
  [47] = {
    name = "Mana Healing",
    combatType = US_TYPES.CONDITION,
    condition = CONDITION_ATTRIBUTES,
    VALUES_PER_LEVEL = 3,
    format = function(value)
      return "[Mana Healing +" .. value .. "%%]"
    end,
    itemType = US_ITEM_TYPES.HELMET + US_ITEM_TYPES.ARMOR + US_ITEM_TYPES.LEGS + US_ITEM_TYPES.BOOTS
  }

fluids.lua, replace target:addMana(math.random(25, 100)) with below:
LUA:
                local healvalue = math.random(25, 100)
                local primaryTotal = 0
                for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
                    local item = player:getSlotItem(slot)
                    if item then
                        if item:getType():usesSlot(slot) then
                            local values = item:getBonusAttributes()
                            if values then
                                for key, value in pairs(values) do
                                    local attr = US_ENCHANTMENTS[value[1]]
                                    if attr then
                                        if attr.name == "Mana Healing" then
                                                primaryTotal = primaryTotal + value[2]
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
  
                healvalue = math.floor(healvalue + (healvalue * primaryTotal / 100))
 
                target:addMana(healvalue)
and copy fluids lua from actions/scripts to data/scripts (few edits on start and end)


Now i'm fighting with Elemental Strike on Hit/Attacks, I would like to set the value[2] of the attribute to 0 when monster have have immunity for specific element type.


Finally got it: (change in config.lua only)

LUA:
  [26] = {
    name = "Terra Strike on Attack",
    combatType = US_TYPES.TRIGGER,
    triggerType = US_TRIGGERS.ATTACK,
    VALUES_PER_LEVEL = 2.5,
    execute = function(attacker, target, damage)
      if math.random(100) < 99 then
        if target.isMonster() then
          local immunity = target:getType():getCombatImmunities()
            if bit.band(immunity, COMBAT_EARTHDAMAGE) == COMBAT_EARTHDAMAGE then
                attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_POISON)
                doTargetCombatHealth(attacker:getId(), target, COMBAT_EARTHDAMAGE, 0, 0, CONST_ME_HITBYPOISON, ORIGIN_CONDITION)
            else
                attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_POISON)
                doTargetCombatHealth(attacker:getId(), target, COMBAT_EARTHDAMAGE, 1, damage, CONST_ME_HITBYPOISON, ORIGIN_CONDITION)
            end
        else
            attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_POISON)
            doTargetCombatHealth(attacker:getId(), target, COMBAT_EARTHDAMAGE, 1, damage, CONST_ME_HITBYPOISON, ORIGIN_CONDITION)
        end
      end
    end,
    format = function(value)
      return "[20%% to cast Terra Strike on Attack dealing 1-" .. value .. " damage]"
    end,
    itemType = US_ITEM_TYPES.WEAPON_ANY
  },

Next thing would be to include elemental protection (fire, energy etc) when stepping on field (fire fields, energy fields etc). But don't have an idea how to get it if not with movement (onStepIn). Wil try tommorow :)
 
Last edited:
Increase mana healing by mana potions:
LUA:
  [47] = {
    name = "Mana Healing",
    combatType = US_TYPES.CONDITION,
    condition = CONDITION_ATTRIBUTES,
    VALUES_PER_LEVEL = 3,
    format = function(value)
      return "[Mana Healing +" .. value .. "%%]"
    end,
    itemType = US_ITEM_TYPES.HELMET + US_ITEM_TYPES.ARMOR + US_ITEM_TYPES.LEGS + US_ITEM_TYPES.BOOTS
  }

fluids.lua, replace target:addMana(math.random(25, 100)) with below:
LUA:
                local healvalue = math.random(25, 100)
                local primaryTotal = 0
                for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
                    local item = player:getSlotItem(slot)
                    if item then
                        if item:getType():usesSlot(slot) then
                            local values = item:getBonusAttributes()
                            if values then
                                for key, value in pairs(values) do
                                    local attr = US_ENCHANTMENTS[value[1]]
                                    if attr then
                                        if attr.name == "Mana Healing" then
                                                primaryTotal = primaryTotal + value[2]
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
 
                healvalue = math.floor(healvalue + (healvalue * primaryTotal / 100))
 
                target:addMana(healvalue)
and copy fluids lua from actions/scripts to data/scripts (few edits on start and end)


Now i'm fighting with Elemental Strike on Hit/Attacks, I would like to set the value[2] of the attribute to 0 when monster have have immunity for specific element type.


Finally got it: (change in config.lua only)

LUA:
  [26] = {
    name = "Terra Strike on Attack",
    combatType = US_TYPES.TRIGGER,
    triggerType = US_TRIGGERS.ATTACK,
    VALUES_PER_LEVEL = 2.5,
    execute = function(attacker, target, damage)
      if math.random(100) < 99 then
        if target.isMonster() then
          local immunity = target:getType():getCombatImmunities()
            if bit.band(immunity, COMBAT_EARTHDAMAGE) == COMBAT_EARTHDAMAGE then
                attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_POISON)
                doTargetCombatHealth(attacker:getId(), target, COMBAT_EARTHDAMAGE, 0, 0, CONST_ME_HITBYPOISON, ORIGIN_CONDITION)
            else
                attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_POISON)
                doTargetCombatHealth(attacker:getId(), target, COMBAT_EARTHDAMAGE, 1, damage, CONST_ME_HITBYPOISON, ORIGIN_CONDITION)
            end
        else
            attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_POISON)
            doTargetCombatHealth(attacker:getId(), target, COMBAT_EARTHDAMAGE, 1, damage, CONST_ME_HITBYPOISON, ORIGIN_CONDITION)
        end
      end
    end,
    format = function(value)
      return "[20%% to cast Terra Strike on Attack dealing 1-" .. value .. " damage]"
    end,
    itemType = US_ITEM_TYPES.WEAPON_ANY
  },

Next thing would be to include elemental protection (fire, energy etc) when stepping on field (fire fields, energy fields etc). But don't have an idea how to get it if not with movement (onStepIn). Wil try tommorow :)
thx for sharing bro :P
 
Increase mana healing by mana potions:
LUA:
  [47] = {
    name = "Mana Healing",
    combatType = US_TYPES.CONDITION,
    condition = CONDITION_ATTRIBUTES,
    VALUES_PER_LEVEL = 3,
    format = function(value)
      return "[Mana Healing +" .. value .. "%%]"
    end,
    itemType = US_ITEM_TYPES.HELMET + US_ITEM_TYPES.ARMOR + US_ITEM_TYPES.LEGS + US_ITEM_TYPES.BOOTS
  }

fluids.lua, replace target:addMana(math.random(25, 100)) with below:
LUA:
                local healvalue = math.random(25, 100)
                local primaryTotal = 0
                for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
                    local item = player:getSlotItem(slot)
                    if item then
                        if item:getType():usesSlot(slot) then
                            local values = item:getBonusAttributes()
                            if values then
                                for key, value in pairs(values) do
                                    local attr = US_ENCHANTMENTS[value[1]]
                                    if attr then
                                        if attr.name == "Mana Healing" then
                                                primaryTotal = primaryTotal + value[2]
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
 
                healvalue = math.floor(healvalue + (healvalue * primaryTotal / 100))
 
                target:addMana(healvalue)
and copy fluids lua from actions/scripts to data/scripts (few edits on start and end)


Now i'm fighting with Elemental Strike on Hit/Attacks, I would like to set the value[2] of the attribute to 0 when monster have have immunity for specific element type.


Finally got it: (change in config.lua only)

LUA:
  [26] = {
    name = "Terra Strike on Attack",
    combatType = US_TYPES.TRIGGER,
    triggerType = US_TRIGGERS.ATTACK,
    VALUES_PER_LEVEL = 2.5,
    execute = function(attacker, target, damage)
      if math.random(100) < 99 then
        if target.isMonster() then
          local immunity = target:getType():getCombatImmunities()
            if bit.band(immunity, COMBAT_EARTHDAMAGE) == COMBAT_EARTHDAMAGE then
                attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_POISON)
                doTargetCombatHealth(attacker:getId(), target, COMBAT_EARTHDAMAGE, 0, 0, CONST_ME_HITBYPOISON, ORIGIN_CONDITION)
            else
                attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_POISON)
                doTargetCombatHealth(attacker:getId(), target, COMBAT_EARTHDAMAGE, 1, damage, CONST_ME_HITBYPOISON, ORIGIN_CONDITION)
            end
        else
            attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_POISON)
            doTargetCombatHealth(attacker:getId(), target, COMBAT_EARTHDAMAGE, 1, damage, CONST_ME_HITBYPOISON, ORIGIN_CONDITION)
        end
      end
    end,
    format = function(value)
      return "[20%% to cast Terra Strike on Attack dealing 1-" .. value .. " damage]"
    end,
    itemType = US_ITEM_TYPES.WEAPON_ANY
  },

Next thing would be to include elemental protection (fire, energy etc) when stepping on field (fire fields, energy fields etc). But don't have an idea how to get it if not with movement (onStepIn). Wil try tommorow :)
yes you will have to edit the movement events for fields

here is poison field script for movement to overload the items.xml work
LUA:
local poisonfield = MoveEvent()

function poisonfield.onStepIn(player, item, position, fromPosition)
    -- Apply initial damage

    if player:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, 102) then
        return true
    end

    doTargetCombat(0, player, COMBAT_EARTHDAMAGE, -5, -5, CONST_ME_NONE, true, false, false)
    
    -- Check if player doesn't have poison condition
    local condition = Condition(CONDITION_POISON)
        condition:setParameter(CONDITION_PARAM_DELAYED, true)
        condition:setParameter(CONDITION_PARAM_MINVALUE, 70) -- Minimum damage
        condition:setParameter(CONDITION_PARAM_MAXVALUE, 100) -- Maximum damage
        condition:setParameter(CONDITION_PARAM_STARTVALUE, 5) -- Starting damage
        condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 5000) -- 5 seconds interval
        condition:setParameter(CONDITION_PARAM_FORCEUPDATE, true)
        condition:setParameter(CONDITION_PARAM_DURATION, 120000) -- 120 seconds (2 minutes)
        
        player:addCondition(condition)
    

    return true
end

poisonfield:id(1503)
poisonfield:register()
 
thx for sharing bro :P
It's pretty much copy paste from oen base, but np :)
Post automatically merged:

yes you will have to edit the movement events for fields

here is poison field script for movement to overload the items.xml work
LUA:
local poisonfield = MoveEvent()

function poisonfield.onStepIn(player, item, position, fromPosition)
    -- Apply initial damage

    if player:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, 102) then
        return true
    end

    doTargetCombat(0, player, COMBAT_EARTHDAMAGE, -5, -5, CONST_ME_NONE, true, false, false)
   
    -- Check if player doesn't have poison condition
    local condition = Condition(CONDITION_POISON)
        condition:setParameter(CONDITION_PARAM_DELAYED, true)
        condition:setParameter(CONDITION_PARAM_MINVALUE, 70) -- Minimum damage
        condition:setParameter(CONDITION_PARAM_MAXVALUE, 100) -- Maximum damage
        condition:setParameter(CONDITION_PARAM_STARTVALUE, 5) -- Starting damage
        condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 5000) -- 5 seconds interval
        condition:setParameter(CONDITION_PARAM_FORCEUPDATE, true)
        condition:setParameter(CONDITION_PARAM_DURATION, 120000) -- 120 seconds (2 minutes)
       
        player:addCondition(condition)
   

    return true
end

poisonfield:id(1503)
poisonfield:register()
Will try to do it after work. But what if Player gets firefield directly below his legs? Will be onstepin registered then? Need to test it, but thanks for help.
 
It's pretty much copy paste from oen base, but np :)
Post automatically merged:


Will try to do it after work. But what if Player gets firefield directly below his legs? Will be onstepin registered then? Need to test it, but thanks for help.
when there is a field created under player it should be bound to onstepin action as far as im concerned.
 
Something like this, but i don't know. I would not trust doing it that way. Too much "if's" in this onStepIn, the server should have huge cpu performance to handle this with many high level (fast walking) players :/
I think I will leave this and focus on different things.

Not efficient at all. Do not recommend to use that one.

Code:
LUA:
local poisonfield = MoveEvent()

function poisonfield.onStepIn(player, item, position, fromPosition)

    if player:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, 102) then
        return true
    end
    
    local primaryDamageTotal = 0
    for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
        local item = player:getSlotItem(slot)
        if item then
            if item:getType():usesSlot(slot) then
                local values = item:getBonusAttributes()
                if values then
                    for key, value in pairs(values) do
                        local attr = US_ENCHANTMENTS[value[1]]
                        if attr then
                            if attr.combatType and attr.combatType ~= US_TYPES.CONDITION then
                                if attr.combatDamage then
                                    local check = player:getCondition(CONDITION_ATTRIBUTES)
                                    if check == CONDITION_POSION then
                                        if attr.combatDamage == COMBAT_EARTHDAMAGE then
                                            if attr.combatType == US_TYPES.DEFENSIVE then
                                                primaryDamageTotal = primaryDamageTotal + value[2]
                                            end
                                        end
                                    end
                                    elseif check == CONDITION_FIRE then
                                        if attr.combatDamage == COMBAT_FIREDAMAGE then
                                            if attr.combatType == US_TYPES.DEFENSIVE then
                                                primaryDamageTotal = primaryDamageTotal + value[2]
                                            end
                                        end
                                    end
                                    elseif check == CONDITION_ENERGY then
                                        if attr.combatDamage == COMBAT_ENERGYDAMAGE then
                                            if attr.combatType == US_TYPES.DEFENSIVE then
                                                primaryDamageTotal = primaryDamageTotal + value[2]
                                            end
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end

    if check == CONDITION_POSION then
        local primaryDamage = 5
    elseif check == CONDITION_FIRE then
        local primaryDamage = 20
    elseif check == CONDITION_ENERGY then
        local primaryDamage = 30
    end
        
    if primaryDamageTotal > 0 then
        primaryDamage = math.ceil(primaryDamage - (primaryDamage * primaryDamageTotal / 100))
    end

    if check == CONDITION_POSION then
    doTargetCombat(0, player, COMBAT_EARTHDAMAGE, -primaryDamage, -primaryDamage, CONST_ME_NONE, true, false, false)
    elseif check == CONDITION_FIRE then
    doTargetCombat(0, player, COMBAT_FIREDAMAGE, -primaryDamage, -primaryDamage, CONST_ME_NONE, true, false, false)
    elseif check == CONDITION_ENERGY then
    doTargetCombat(0, player, COMBAT_ENERGYDAMAGE, -primaryDamage, -primaryDamage, CONST_ME_NONE, true, false, false)
    end

    if check == CONDITION_POSION then
        local ticksDamage = 5
    elseif check == CONDITION_FIRE then
        local ticksDamage = 10
    elseif check == CONDITION_ENERGY then
        local ticksDamage = 30
    end
    
    -- Check if player doesn't have poison condition
    local condition = Condition(CONDITION_POISON)
        condition:setParameter(CONDITION_PARAM_DELAYED, true)
        condition:setParameter(CONDITION_PARAM_MINVALUE, 70) -- Minimum damage
        condition:setParameter(CONDITION_PARAM_MAXVALUE, 100) -- Maximum damage
        condition:setParameter(CONDITION_PARAM_STARTVALUE, ticksDamage) -- Starting damage
        condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 5000) -- 5 seconds interval
        condition:setParameter(CONDITION_PARAM_FORCEUPDATE, true)
        condition:setParameter(CONDITION_PARAM_DURATION, 120000) -- 120 seconds (2 minutes)
        
        player:addCondition(condition)
    
    return true
end

poisonfield:id(1503)
poisonfield:register()

This version not tested. Guests came in and had to leave pc :)
 
Last edited:
Something like this, but i don't know. I would not trust doing it that way. Too much "if's" in this onStepIn, the server should have huge cpu performance to handle this with many high level (fast walking) players :/
I think I will leave this and focus on different things.

Not efficient at all. Do not recommend to use that one.

Code:
LUA:
local poisonfield = MoveEvent()

function poisonfield.onStepIn(player, item, position, fromPosition)

    if player:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, 102) then
        return true
    end
 
    local primaryDamageTotal = 0
    for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
        local item = player:getSlotItem(slot)
        if item then
            if item:getType():usesSlot(slot) then
                local values = item:getBonusAttributes()
                if values then
                    for key, value in pairs(values) do
                        local attr = US_ENCHANTMENTS[value[1]]
                        if attr then
                            if attr.combatType and attr.combatType ~= US_TYPES.CONDITION then
                                if attr.combatDamage then
                                    local check = player:getCondition(CONDITION_ATTRIBUTES)
                                    if check == CONDITION_POSION then
                                        if attr.combatDamage == COMBAT_EARTHDAMAGE then
                                            if attr.combatType == US_TYPES.DEFENSIVE then
                                                primaryDamageTotal = primaryDamageTotal + value[2]
                                            end
                                        end
                                    end
                                    elseif check == CONDITION_FIRE then
                                        if attr.combatDamage == COMBAT_FIREDAMAGE then
                                            if attr.combatType == US_TYPES.DEFENSIVE then
                                                primaryDamageTotal = primaryDamageTotal + value[2]
                                            end
                                        end
                                    end
                                    elseif check == CONDITION_ENERGY then
                                        if attr.combatDamage == COMBAT_ENERGYDAMAGE then
                                            if attr.combatType == US_TYPES.DEFENSIVE then
                                                primaryDamageTotal = primaryDamageTotal + value[2]
                                            end
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end

    if check == CONDITION_POSION then
        local primaryDamage = 5
    elseif check == CONDITION_FIRE then
        local primaryDamage = 20
    elseif check == CONDITION_ENERGY then
        local primaryDamage = 30
    end
   
    if primaryDamageTotal > 0 then
        primaryDamage = math.ceil(primaryDamage - (primaryDamage * primaryDamageTotal / 100))
    end

    doTargetCombat(0, player, COMBAT_EARTHDAMAGE, -primaryDamage, -primaryDamage, CONST_ME_NONE, true, false, false)

    if check == CONDITION_POSION then
        local ticksDamage = 5
    elseif check == CONDITION_FIRE then
        local ticksDamage = 10
    elseif check == CONDITION_ENERGY then
        local ticksDamage = 30
    end
 
    -- Check if player doesn't have poison condition
    local condition = Condition(CONDITION_POISON)
        condition:setParameter(CONDITION_PARAM_DELAYED, true)
        condition:setParameter(CONDITION_PARAM_MINVALUE, 70) -- Minimum damage
        condition:setParameter(CONDITION_PARAM_MAXVALUE, 100) -- Maximum damage
        condition:setParameter(CONDITION_PARAM_STARTVALUE, ticksDamage) -- Starting damage
        condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 5000) -- 5 seconds interval
        condition:setParameter(CONDITION_PARAM_FORCEUPDATE, true)
        condition:setParameter(CONDITION_PARAM_DURATION, 120000) -- 120 seconds (2 minutes)
   
        player:addCondition(condition)
 
    return true
end

poisonfield:id(1503)
poisonfield:register()

This version not tested. Guests came in and had to leave pc :)
how is it gonna have a high cpu usage over few ifs thats ridiculous?
i tested today the equipment checking on each damage dealt and creating 2 extra combat damages virtually no performance loss
this is not 2008
 
Back
Top