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

Buffs doesn't work

Syryniss

Member
Joined
Feb 13, 2014
Messages
206
Reaction score
20
Hi. I'm using custom damage formula for weapons, so hits are based on weapon damage and specific skill. The problem is, that when I cast some spell, that gives bonus attributes like 20 melee percent or for example 20 club and 20 attack speed (which is axe), the damage doesn't change (attack speed is working). However if I get higher skill level by leveling it up, the damage is going up, so it looks like the buff doesn't update with my forumla and when I gain skill in normal way it's updating.

Here is my weapon formula :

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

function getWeaponDamage(cid, skill, att, attackStrength)
    local lvl = getPlayerLevel(cid)
    local sword = getPlayerSkill(cid, 2)

    local min = -(((attackStrength * sword)*0.6) )
    local max = -(((attackStrength * sword)*0.7) )

    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "getWeaponDamage")

function onUseWeapon(cid, var)
    return doCombat(cid, combat, var)
end
And here is my buff script :
Code:
local combat = createCombatObject() 
setCombatParam(combat, COMBAT_PARAM_EFFECT, 123) 
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false) 

local condition = createConditionObject(CONDITION_ATTRIBUTES) 
setConditionParam(condition, CONDITION_PARAM_TICKS, 100000) 
setConditionParam(condition, CONDITION_PARAM_SKILL_MELEEPERCENT, 120) 
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
I'm using TFS 0.3.6, thanks for any help.
 
It should work if you use a buff which adds X amount of skill levels rather than the percentage.
If you want it to work with percentages you have to implement that yourself. Player::getSkill does not consider the percentage buffs, either you have to change that or add a new lua function to get the buffed skill amount.
 
I changed it to

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, 123)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 100000)
setConditionParam(condition, CONDITION_PARAM_SKILL_SWORD, 20)
setConditionParam(condition, CONDITION_PARAM_SKILL_AXE, 20)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
and sword skill is going up 20 points, but damage remains the same. Unfortunately, I'm sure I'm not experienced to write new lua fuction by myself, so that will be a problem :( I don't mind that percent isn't working, if I could somehow make, that function like above will work, that would be perfect for me.
 
Syriniss said:
However if I get higher skill level by leveling it up, the damage is going up
Weapons use this skills for sure, if I lvl up them normal way by "training" the damage is going up, only buff doesnt work (number is going up with buff, but no effect on damage).
 
missing this line

setConditionParam(condition, CONDITION_PARAM_BUFF, true)

oh and with that in there, the percents will work the way you want them to if you would rather use them, no need to make a new function...
 
Thanks for reply and trying to help. Unfortunatlely it still doesn't work. I tested like that: changed my formula ratios to the same "min" and "max" for better accuracy. When I added 1 sword skill to character, damage went up. But when I casted buff, it says correctly on skill bar, that my sword went up by 20 (or 20%), but damage remains the same.
 
Have you tried to see if it works when you use the buff, but on a different weapon? To make sure the buff is working right? Because I am sure now since you see the values change that the buff is working right, but with two different combats declared I don't think it works like that... So if the buff increases damage with another weapon, problem isn't with the buff spell... problem is with the weapon script... let me know if it works...
 
The buff worked earlier and works now with any weapon that uses "default" weapon formula declared in weapons.xml. The problem is I wanted it to work with my formula, because I wanted the damage to be based on one skill and weapon attack. Also in my forumla the minium damage is only a little less than maximum. In default it seems to be from 0 to maximum, which I don't really like.
Is there any way to make buffs work with my custom weapon damage formula?
 
Ok so the formula for the damage the monster will receive from a weapon already includes your skill, weapon attack and level, so really no need for a script, now if you want the buff to work, and still use those variables for the damage, but yet set a higher minimum other than 0 have you tried putting the item in weapons.xml with default, but adding in the tag min="50" or min="XX" what ever you want the minimum to be?
 
Firstly, sorry for very long break, but I couldn't test or even think about it, I had many things to do, no time for it and so on...
From what I understood, I can't put "default" in weapons.xml, because then the damage will not be based on my things (skill, weapon attack). The other thing is, I can't put a constant min value, I want it to be only few percent lower than max damage, like in my formula.
Maybe I should set mine formula damage for weapons in sources, but with that I will need help for sure :(
 
It's on the beginning of this thread.

Weapon formula in weapons/scripts:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

function getWeaponDamage(cid, skill, att, attackStrength)
local lvl = getPlayerLevel(cid)
local sword = getPlayerSkill(cid, 2)

local min = -(((attackStrength * sword)*0.6) )
local max = -(((attackStrength * sword)*0.7) )

return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "getWeaponDamage")

function onUseWeapon(cid, var)
return doCombat(cid, combat, var)
end

Buff spell:
Code:
local combat = createCombatObject() 
setCombatParam(combat, COMBAT_PARAM_EFFECT, 123) 
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false) 

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setConditionParam(condition, CONDITION_PARAM_TICKS, 100000) 
setConditionParam(condition, CONDITION_PARAM_SKILL_MELEEPERCENT, 120) 
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end

Summary: Forumla is working, when I gain skill level(sword) the damage is going up. When I use buff, attack speed is going up, but the damage remains the same (sword in skill window is going up tho). Tested with "meleepercent" and "skill_sword" with same result.
 
I think this "getPlayerSkill(cid, 2)" is the issue. it must be reading players actual skill level, so what we need to do is test with "skill" from "getWeaponDamage(cid, skill, att, attackStrength)" I'm not really sure how it works? maybe skill[2]? would be sword.

to be sure it's an issue with "getPlayerSkill(cid, 2)" simply use this and it will tell you in console window what it's retrieving as the players skill.

print(getPlayerSkill(cid, 2))
 
Last edited:
Yep, it is the issue. Console returns always 49, no matter if I'm buffed or not. I changed sword to skill and my damage jumped from ~2000 to ~19000, so I don't know which value it is connected to. Anyway it still doesn't work, damage is the same with or without buff.
 
Try skill[SKILL_SWORD]

Other than that we are closer so that's good, I will have to check sources when I get home and see how skill works.
 
I tested it even more, by checking damage, adding sword skill to my character and then checking again. The damage remained the same, so it surely doesn't have anything in common with sword skill. With skill[SKILL_SWORD] or skill[2] it doesn't work, it returns an error in console. Thanks for your attention, I hope we will find out how to do it.
 
Back
Top