• 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 Diffirent spell effects for diffirent magic level

Gall

Member
Joined
Nov 8, 2007
Messages
78
Reaction score
10
Since i haven't found help on OTFans I'll ask here too. Some time ago I've decided to make light spell on my server less boring. How? When player would achieve some magic level the light color becomes different(green red or other in place of white). I ended in creating this:
Code:
ocal combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, FALSE)

local condition = createConditionObject(CONDITION_LIGHT)
setConditionParam(condition, CONDITION_PARAM_LIGHT_LEVEL, 10)

function onBeginCast(cid, var)
if getPlayerMagLevel > 40 then
setConditionParam(condition, CONDITION_PARAM_LIGHT_COLOR, 195) -- red
elseif getPlayerMagLevel(cid) <= 40 then
setConditionParam(condition, CONDITION_PARAM_LIGHT_COLOR, 176) -- green
elseif getPlayerMagLevel(cid) <= 20 then
setConditionParam(condition, CONDITION_PARAM_LIGHT_COLOR, 267) -- yellow
elseif getPlayerMagLevel(cid) <= 6 then
setConditionParam(condition, CONDITION_PARAM_LIGHT_COLOR, 215) -- white
else 
setConditionParam(condition, CONDITION_PARAM_LIGHT+COLOR, 215) -- white again

end
end

setConditionParam(condition, CONDITION_PARAM_TICKS, (6*60)*1000) --time
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end
and in other attempt this:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, FALSE)
function onBeginCast(cid, var)
if getPlayerMagLevel > 40 then
local color = 195 -- red?
elseif getPlayerMagLevel(cid) <= 40 then
local color = 176 -- green?
elseif getPlayerMagLevel(cid) <= 20 then
local color = 167 -- yellow
elseif getPlayerMagLevel(cid) <= 6 then
local color = 215 -- white
end
end

local condition = createConditionObject(CONDITION_LIGHT)
setConditionParam(condition, CONDITION_PARAM_LIGHT_LEVEL, 6)
setConditionParam(condition, CONDITION_PARAM_LIGHT_COLOR, color)
setConditionParam(condition, CONDITION_PARAM_TICKS, ((6*60)+10)*1000) --3 minutes and 10 seconds(time in ms)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end
I tried also using getPlayerMagicLevel instead of getPlayerMagLevel. However it only wastes mana. I am using Avesta 0.6.1(7.6) compiled at July 31 2010. What i am doing wrong?
 
Back
Top