• 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 Spell issue

dchampag

Intermediate OT User
Joined
Jul 15, 2008
Messages
772
Reaction score
102
Location
USA
This spell that I made doesn't do what I want it to...
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_GREEN_RINGS)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISON)

local poison = createConditionObject(CONDITION_POISON)
setConditionParam(poison, CONDITION_PARAM_DELAYED, 1)

function onGetFormulaValues(cid, level, maglevel)
	dotmin = ((maglevel+1)*(level*0.029))
	dotmax = ((maglevel+1)*(level*0.031))
	addDamageCondition(poison, 30, 1000, -math.random(dotmin, dotmax))
	setCombatCondition(combat, combat, poison)
	min = -((maglevel+1)*(level*0.029))
	max = -((maglevel+1)*(level*0.031))
	return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

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

it's actually a really odd issue? when a player uses it, then another player uses it no matter what level or mag level they have the first player who used it's damage is calculated and the damage stays that way untill spells are reloaded...
 
Last edited:
Well I'd try changing min and max to a different name such as "min_dmg" and "max_dmg". I believe min and max are LUA functions. See if that helps
 
The min and max are damage of the spell not damage of the poison effect mindot and maxdot are the damage calculations for the poison condition

- - - Updated - - -

It acts almost as if after the first reload the first person that uses it sets a global damage calculation then any player that uses it after that get same condition damage the spell damage itself works fine...
 
What I think is happening is that the condition object is being created on startup, and every time the spell is executed you are adding a new damage condition to that object. The damage condition should only be added to the object once.
I'm pretty sure to get it to do what you want to do, you need to make an array of condition objects with a certain damage calculation for each level, and then derive which object to use, then calling the object with "doTargetCombatCondition". Its not very practical, but it's the only way I can think of (since nobody else has responded)
 
Back
Top