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

Lua Spells with charges

demon088

#088 in the Horde
Joined
Jun 17, 2009
Messages
249
Solutions
3
Reaction score
30
Location
Hell
Hello again OtLand!
I need some assistance making a new series of spells for my OTS, and if someone would like to use it, I'm glad to explain how it works or help to insert or edit the spell.
My team had the idea to make a spell which could get one charge each time you use it. So, if you have casted the spell until you get 10 charges, you might inflict adittional damage while spending all the charges, then you would need to use it 10 times again to get the boost. Then, I mixed scripts from spells and actions like this:
Code:
local combat = createCombatObject()
                setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
                setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
                setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
                setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EXPLOSION)


function onCastSpell(cid, var)
        
        charges = getPlayerStorageValue(cid,10076)
        if charges == 1 then
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Discharge!")
            setPlayerStorageValue(cid,10076,0)   
            function onGetFormulaValues(player, skill, attack, factor)
            local fistSkill = player:getEffectiveSkillLevel(SKILL_FIST)
            local min = (player:getLevel() + 105) + (fistSkill * 0.38 + attack)
            local max = (player:getLevel() + 150) + (fistSkill * 0.5 + attack)
            return -min, -max           
            end
    setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")           
            else
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Charge!")
            setPlayerStorageValue(cid,10076,1)   
                        function onGetFormulaValues(player, skill, attack, factor)
            local fistSkill = player:getEffectiveSkillLevel(SKILL_FIST)
            local min = (player:getLevel() + 5) + (fistSkill * 0.38 + attack)
            local max = (player:getLevel() + 15) + (fistSkill * 0.5 + attack)
            return -min, -max           
            end
    setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
        end
            
            return doCombat(cid, combat, var)
        end
This script is currently working like this:
spell.png

The problem that I have right now, is that I don't know how to set this line into the script:
Code:
From this:
  setPlayerStorageValue(cid,10076,1)   
            
To this:
  increasePlayerStorageValue(cid,10076,1)
or
  addPlayerStorageValue(cid,10076,1)

I would like this to increase 1 charge instead of fixing the value to one. Do anybody know the correct line that I'm looking for?
I'd be glad to share this script to anybody that would like to have such kind of spells. I've thinking on a spell that could be only casted once you have X amount of charges from different spells. I'm already working on the script, but this is issue is my first obstacle.
Thank you all for your help!
 
5. Incomplete Problem Description:
- Post as much useful information as possible. If the problem is about something on your server, post the server version and client version. Also always post the errors you get and the scripts with the problems.
 
Yes, I tried also like this
Code:
 setPlayerStorageValue(cid,10076,+1)
and
setPlayerStorageValue(cid,10076, +1)
Nice try, however thanks!
 
Lua:
setPlayerStorageValue(cid,10076, getPlayerStorageValue(cid, 10076) + 1)
This is working exactly as I wanted to, thank you @Evil Puncker. Until 5 charges it inflicts more damage and it's showing not aggresive messages about the charges. Here's the script working (NOTE: I have updated the script, so it might be slightly different, but improved):
Code:
local combat = createCombatObject()
                setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
                setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
                setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
                setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EXPLOSION)
function onCastSpell(cid, var)
        
        charges = getPlayerStorageValue(cid,10076)
        if charges > 4 then
            setPlayerStorageValue(cid,10076, getPlayerStorageValue(cid, 10076) - 5)
            doPlayerSendCancel(cid,"5 charges were spent! You have " .. getPlayerStorageValue(cid, 10076) .. " charges.")            
            function onGetFormulaValues(player, skill, attack, factor)
            local fistSkill = player:getEffectiveSkillLevel(SKILL_FIST)
            local min = (player:getLevel() + 105) + (fistSkill * 0.38 + attack)
            local max = (player:getLevel() + 150) + (fistSkill * 0.5 + attack)
            return -min, -max            
            end
    setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")            
            else
            setPlayerStorageValue(cid,10076, getPlayerStorageValue(cid, 10076) + 1)    
            doPlayerSendCancel(cid,"Charging: You have " .. getPlayerStorageValue(cid, 10076) .. " charges.")
            function onGetFormulaValues(player, skill, attack, factor)
            local fistSkill = player:getEffectiveSkillLevel(SKILL_FIST)
            local min = (player:getLevel() + 5) + (fistSkill * 0.38 + attack)
            local max = (player:getLevel() + 15) + (fistSkill * 0.5 + attack)
            return -min, -max            
            end
    setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
        end
            
            return doCombat(cid, combat, var)
        end
Spell Working:
spell.png

I apologize, I'm using TFS 1.2, Tibia Client 10.98 and I was not getting error on prompt, I was just missing the correct logic in the script. But the previous quote solved my issue.
 
Last edited:
Back
Top