• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Spells - damage depending from skill problem

Anoph

New Member
Joined
Mar 20, 2011
Messages
14
Reaction score
0
Hello. I wanted to make a simple spell, just like exori con in real Tibia, but it would make much more damage (damage depending on dist skill), also wanted it's damage to be more constant.

I want it to hit for example, on 50 distance skill for like 180-220 damage.

My problem is that no matter what I type in formula, my spell hits for example - 80, then 360, then 200, then 400.

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, TRUE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 1.6, 0, 1.8, 0)

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

Help and explanation, please.
 
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)

function onGetFormulaValues(cid, level, skill, attack, factor)
	skill = getPlayerSkill(cid, SKILL_DISTANCE)
	return
		- (skill * 3.6),
		- (skill * 4.4)
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, 'onGetFormulaValues')
function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end
 
my server only listen to fist values, no mather i i write SKILL_AXE it goes by the fist skill.. if i write skill it goes by fist what ever i type its fist.. something i could edit in the sources to make this function work? i get no errors in my console.
 
i tried to write
skill = getPlayerSkill(cid, SKILL_1)
and all these numbers i tried all kind of things.. i think i miss some in my sources or something..

i tried skill = getPlayerSkill(cid, 1)
and it worked ! thank you for helping me!
 
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
 
function onGetFormulaValues(cid, level, skill, attack, factor)
	skill1 = getPlayerSkill(cid, SKILL_CLUB)
	skill2 = getPlayerSkill(cid, SKILL_SWORD)
	skill3 = getPlayerSkill(cid, SKILL_AXE)

	return
		- ((skill1 + skill2 + skill3)/3 * 3.6),
		- ((skill1 + skill2 + skill3)/3 * 4.4)
end
 
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, 'onGetFormulaValues')
function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end
something like this?
 
Well Cykotitan. I want this script it's (explosion rune) to be based on your skill value. and if its possible if you have a AXE in hand it will get axe skill + wep atk as max hit.
If you have Sword it will get sword skill + wepon atk as max hit and same for Club. And if you dont have any of these wepons it will go by fist fight.
 
ach :D
now:

LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
 
function onGetFormulaValues(cid, level, skill, attack, factor)
	local wafe = getPlayerSlotItem(cid, CONST_SLOT_RIGHT).weaponType
	if wafe = WEAPON_SWORD then
		skill = getPlayerSkill(cid, SKILL_SWORD)
	elseif wafe == WEAPON_CLUB then
		skill = getPlayerSkill(cid, SKILL_CLUB)
	elseif wafe == WEAPON_AXE then
		skill = getPlayerSkill(cid, SKILL_AXE)
	end

	return
		- (skill * 3.6),
		- (skill * 4.4)
end
 
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, 'onGetFormulaValues')
function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end
or
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
 
function onGetFormulaValues(cid, level, skill, attack, factor)
	local wafe = getPlayerSlotItem(cid, CONST_SLOT_RIGHT).weaponType
	if wafe = WEAPON_SWORD then
		skill = getPlayerSkill(cid, SKILL_SWORD)
		return
			- (skill * 1),
			- (skill * 2)

	elseif wafe == WEAPON_CLUB then
		skill = getPlayerSkill(cid, SKILL_CLUB)
		return
			- (skill * 3),
			- (skill * 4)
	elseif wafe == WEAPON_AXE then
		skill = getPlayerSkill(cid, SKILL_AXE)
		return
			- (skill * 5),
			- (skill * 6)
	end
end
 
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, 'onGetFormulaValues')
function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end

that is?
 
looks like its what im looking for but i get error
Code:
Warning: [Event::loadScript] Can not load script. data/spells/scripts/attack/exp
losion.lua
data/spells/scripts/attack/explosion.lua:8: 'then' expected near '='
 
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
 
 
function onGetFormulaValues(cid, skill, attack, factor)
	local wafe = getPlayerSlotItem(cid, CONST_SLOT_RIGHT) .weaponType
	if wafe == WEAPON_SWORD then
		skill = getPlayerSkill(cid, 2)
	elseif wafe == WEAPON_CLUB then
		skill = getPlayerSkill(cid, 1)
	elseif wafe == WEAPON_AXE then
		skill = getPlayerSkill(cid, 3)
	end
 
	return
		- (skill * 1),
		- (skill * 1)
end

local arr = {
{0, 1, 0},
{1, 3, 1},
{0, 1, 0}
}
 
local area = createCombatArea(arr)
setCombatArea(combat, area)

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, 'onGetFormulaValues')
function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end

Only goes by the first skill value i have, and make dmg after it. Means it doesnt check for what wepon i have. so either the script doesnt work or i need sources eddit.
 
use [LUA /LUA]

in ~8 was space
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
 
 
function onGetFormulaValues(cid, skill, attack, factor)
	local wafe = getItemWeaponType(getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid)
	local skill = 1
	if wafe == WEAPON_SWORD then
		skill = getPlayerSkill(cid, 2)
	elseif wafe == WEAPON_CLUB then
		skill = getPlayerSkill(cid, 1)
	elseif wafe == WEAPON_AXE then
		skill = getPlayerSkill(cid, 3)
	end
 
	return
		- (skill * 1),
		- (skill * 1)
end

local arr = {
{0, 1, 0},
{1, 3, 1},
{0, 1, 0}
}
 
local area = createCombatArea(arr)
setCombatArea(combat, area)

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, 'onGetFormulaValues')
function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end

-- edit
now! even tested :)
~8 was wrong
 
Last edited:
For my server
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
 
 
function onGetFormulaValues(cid, skill, attack, factor)
	local wafe = getPlayerSlotItem(cid, CONST_SLOT_RIGHT).weaponType
	if skill == WEAPON_AXE then
		wafe = getPlayerSkill(cid, 2)
	elseif skill == WEAPON_CLUB then
		wafe = getPlayerSkill(cid, 1)
	elseif skill == WEAPON_AXE then
		wafe = getPlayerSkill(cid, 3)
	end
 
	return
		- (3.1344 * 6 / 3 + skill * 1.3),
		- (3.1344 * 5 / 2 + skill * 2.6)
end
 
local arr = {
{0, 1, 0},
{1, 3, 1},
{0, 1, 0}
}
 
local area = createCombatArea(arr)
setCombatArea(combat, area)
 
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, 'onGetFormulaValues')
function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end

this works. i use it now. testet and it works great.
 
Back
Top