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

Solved creature:getMana and doTargetCombatMana()

lukatxd

Active Member
Joined
Dec 9, 2010
Messages
85
Solutions
1
Reaction score
39
I'm using the TFS 1.3 downgraded by Nekiro to work on Tibia 8.6. This is what happens when I try to use potions:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/potions.lua:onUse
data/actions/scripts/other/potions.lua:56: attempt to call global 'doTargetCombatHealth' (a nil value)
stack traceback:
        [C]: in function 'doTargetCombatHealth'
        data/actions/scripts/other/potions.lua:56: in function <data/actions/scripts/other/potions.lua:35>

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/potions.lua:onUse
data/actions/scripts/other/potions.lua:56: attempt to call global 'doTargetCombatHealth' (a nil value)
stack traceback:
        [C]: in function 'doTargetCombatHealth'
        data/actions/scripts/other/potions.lua:56: in function <data/actions/scripts/other/potions.lua:35>


I can see the doTargetCombatMana in this file in the sources (original TFS, not the one I'm actually using)

In the downgraded version I can't find any of these functions

Plus, I'm also testing an item stat upgrade system, that invokes creature:getMana() which also happens to end in a 'nil value' and if any item has a mana drain attribute, the player owning the item can't even attack. What can I do to resolve this?
 
Solution
E
@Evil Puncker:

first issue: the difference from compat.lua only?
yes add these to your compat.lua

Lua:
function doTargetCombatHealth(...) return doTargetCombat(...) end
function doAreaCombatHealth(...) return doAreaCombat(...) end
function doTargetCombatMana(cid, target, min, max, effect) return doTargetCombat(cid, target, COMBAT_MANADRAIN, min, max, effect) end
function doAreaCombatMana(cid, pos, area, min, max, effect) return doAreaCombat(cid, COMBAT_MANADRAIN, pos, area, min, max, effect) end
first issue: add these changes to your compat.lua


second issue: I need a print of the error and the code part that invokes creature:getMana()
 
@Xikini
These are on the master branch.. I'm using the downagraded version that is in another repository. So I'm not sure if it would work well if I just compared the differences since I'm not versed in the tfs sources.


@Evil Puncker:

first issue: the difference from compat.lua only?

second issue:
I tried switching the creature:getMana() to creature:getHealth(), but then I eventually got into the doTargetCombatMana issue.
stats.lua
creture:getMana()
1597064976627.png
1597065028701.png


I eventually found this list of available functions where it does contain creature:getMana(), but i'm not entirely sure for what version it is, I found it laying around in the forum.
 
Last edited:
@Evil Puncker:

first issue: the difference from compat.lua only?
yes add these to your compat.lua

Lua:
function doTargetCombatHealth(...) return doTargetCombat(...) end
function doAreaCombatHealth(...) return doAreaCombat(...) end
function doTargetCombatMana(cid, target, min, max, effect) return doTargetCombat(cid, target, COMBAT_MANADRAIN, min, max, effect) end
function doAreaCombatMana(cid, pos, area, min, max, effect) return doAreaCombat(cid, COMBAT_MANADRAIN, pos, area, min, max, effect) end
 
Solution
yes add these to your compat.lua

Lua:
function doTargetCombatHealth(...) return doTargetCombat(...) end
function doAreaCombatHealth(...) return doAreaCombat(...) end
function doTargetCombatMana(cid, target, min, max, effect) return doTargetCombat(cid, target, COMBAT_MANADRAIN, min, max, effect) end
function doAreaCombatMana(cid, pos, area, min, max, effect) return doAreaCombat(cid, COMBAT_MANADRAIN, pos, area, min, max, effect) end
So far so good, it resolved the situation about potions. Now for the creature:getMana()
 
try changing the if to this:

Lua:
if Player(cid):getMana() > 0 then
Nope, didnt work:

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/stats.lua:onHealthChange
data/stats.lua:1576: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/stats.lua:1576: in function <data/stats.lua:1509>


But since it is used only in this single line of code. I'll remove it for simplicity's sake. I don't need to do the actual drain of mana, just restore some based on the damage (which is like global does).
I thank you once more for the time spent helping me.
 

Attachments

Back
Top