• 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 Need help with wand script

sharpy

New Member
Joined
Jan 4, 2010
Messages
77
Reaction score
0
I am trying to make a new wand script using this code:

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLHOLY)

function onGetFormulaValues(cid, level, maglevel)
min = -(level * 1 + maglevel * 1) * 1
max = -(level * 2 + maglevel * 2) * 2
	return min, max
end
 
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
return doCombat(cid, combat, var)
end


what I need to know is, if there is a way to set a maximum amount that min and max could be?

I tried making the script like this:

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLHOLY)

function onGetFormulaValues(cid, level, maglevel)
low = -(level * 1 + maglevel * 1) * 1
high = -(level * 2 + maglevel * 2) * 2
	if low > -100 then
		min = -100
	elseif low <= -100 then
		min = low
	end
	if high > -300 then
		max = -300
	elseif high <= -300 then
		max = high
	end
	return min, max
end
 
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
return doCombat(cid, combat, var)
end

it doesn't return any errors however it only returns low and high for min and max and ignores the max limits I set..

does anyone know if this is possible or what i am doing wrong?
 
Last edited:
Let me know if this works, I have not tested and I can't guarantee it will work, but it is my morning guess.
This is also assuming that you want the max to be 300 and min to be 100.

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLHOLY)
 
function onGetFormulaValues(cid, level, maglevel)
min = -(level * 1 + maglevel * 1) * 1
max = -(level * 2 + maglevel * 2) * 2
	return (min < 100 ? 100 : min), (max > 300 ? 300 : max)
end
 
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
return doCombat(cid, combat, var)
end

EDIT: No, that won't work, give me a few minutes.
 
Last edited:
Let me know if this works, I have not tested and I can't guarantee it will work, but it is my morning guess.
This is also assuming that you want the max to be 300 and min to be 100.

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLHOLY)
 
function onGetFormulaValues(cid, level, maglevel)
min = -(level * 1 + maglevel * 1) * 1
max = -(level * 2 + maglevel * 2) * 2
	return (min < 100 ? 100 : min), (max > 300 ? 300 : max)
end
 
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
return doCombat(cid, combat, var)
end

EDIT: No, that won't work, give me a few minutes.

Your code is good, just your values must be negative.

Lua:
return (min < -100 ? -100 : min), (max < -300 ? -300 : max)
 
I figured it out :p

here is what the new script looks like:

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLHOLY)

function onGetFormulaValues(cid, level, maglevel)
local config = {
	minimum = -(level * 1 + maglevel * 1) * 1,
	maximum = -(level * 2 + maglevel * 2) * 2
}
	if config.minimum < -100 or config.maximum < -300 then
		return -100, -300
	elseif config.minimum >= -100 and config.maximum >= -300 then
		return config.minimum, config.maximum
	end
end
 
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
return doCombat(cid, combat, var)
end

it could be fixed better I am sure but I'm still learning Lua :p
 
Last edited:
Lol, you might be able to do that if you change the item attributes in items.xml from <attribute key="weaponType" value="club"/> to <attribute key="weaponType" value="wand"/>
 
Back
Top