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

Aleada

Unknown Member
Joined
Mar 14, 2013
Messages
231
Reaction score
7
Heya everyone, I'm trying to edit a spell (Made by: kermaxpl) It's supposed to stun the target for 4 seconds (Works) then I'm trying to make it blink the "Sleep Magic Effect" every second until it's unstunned. Here's what I've tried so far:

LUA:
local combat = createCombatObject()
    setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
    setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 1)
    setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_STUN)
    setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)	

local function effect(cid)
	doSendMagicEffect(target, CONST_ME_SLEEP)
end	
	
local paralyze = createConditionObject(CONDITION_PARALYZE)
setConditionParam(paralyze, CONDITION_PARAM_TICKS, 4000)
 
local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 4000)

local pacified = createConditionObject(CONDITION_PACIFIED)
setConditionParam(pacified, CONDITION_PARAM_TICKS, 4000)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 4000)

function onCastSpell(cid, var)
	
	local target = getCreatureTarget(cid)
	local speed = getCreatureSpeed(target)
	doChangeSpeed(target, -speed)	
	addEvent(doChangeSpeed, 4000, target, speed)
	doAddCondition(target, paralyze)
	doAddCondition(target, muted)
	doAddCondition(target, pacified)
	doAddCondition(target, exhaust)
	for j = 0, 4 do
		addEvent(effect, 1000)
	end	
       
    return doCombat(cid, combat, var)
end

But I'm getting this error:

Code:
[25/7/2013 12:40:44] [Error - Spell Interface] 
[25/7/2013 12:40:44] In a timer event called from: 
[25/7/2013 12:40:44] data/spells/scripts/Warrior/attack/Stun.lua:onCastSpell
[25/7/2013 12:40:44] Description: 
[25/7/2013 12:40:44] attempt to index a nil value
[25/7/2013 12:40:44] stack traceback:
[25/7/2013 12:40:44] 	[C]: in function 'doSendMagicEffect'
[25/7/2013 12:40:44] 	data/spells/scripts/Warrior/attack/Stun.lua:9: in function <data/spells/scripts/Warrior/attack/Stun.lua:8>

[25/7/2013 12:40:44] [Error - Spell Interface] 
[25/7/2013 12:40:44] In a timer event called from: 
[25/7/2013 12:40:44] data/spells/scripts/Warrior/attack/Stun.lua:onCastSpell
[25/7/2013 12:40:44] Description: 
[25/7/2013 12:40:44] attempt to index a nil value
[25/7/2013 12:40:44] stack traceback:
[25/7/2013 12:40:44] 	[C]: in function 'doSendMagicEffect'
[25/7/2013 12:40:44] 	data/spells/scripts/Warrior/attack/Stun.lua:9: in function <data/spells/scripts/Warrior/attack/Stun.lua:8>

[25/7/2013 12:40:44] [Error - Spell Interface] 
[25/7/2013 12:40:44] In a timer event called from: 
[25/7/2013 12:40:44] data/spells/scripts/Warrior/attack/Stun.lua:onCastSpell
[25/7/2013 12:40:44] Description: 
[25/7/2013 12:40:44] attempt to index a nil value
[25/7/2013 12:40:44] stack traceback:
[25/7/2013 12:40:44] 	[C]: in function 'doSendMagicEffect'
[25/7/2013 12:40:44] 	data/spells/scripts/Warrior/attack/Stun.lua:9: in function <data/spells/scripts/Warrior/attack/Stun.lua:8>

[25/7/2013 12:40:44] [Error - Spell Interface] 
[25/7/2013 12:40:44] In a timer event called from: 
[25/7/2013 12:40:44] data/spells/scripts/Warrior/attack/Stun.lua:onCastSpell
[25/7/2013 12:40:44] Description: 
[25/7/2013 12:40:44] attempt to index a nil value
[25/7/2013 12:40:44] stack traceback:
[25/7/2013 12:40:44] 	[C]: in function 'doSendMagicEffect'
[25/7/2013 12:40:44] 	data/spells/scripts/Warrior/attack/Stun.lua:9: in function <data/spells/scripts/Warrior/attack/Stun.lua:8>

[25/7/2013 12:40:44] [Error - Spell Interface] 
[25/7/2013 12:40:44] In a timer event called from: 
[25/7/2013 12:40:44] data/spells/scripts/Warrior/attack/Stun.lua:onCastSpell
[25/7/2013 12:40:44] Description: 
[25/7/2013 12:40:44] attempt to index a nil value
[25/7/2013 12:40:44] stack traceback:
[25/7/2013 12:40:44] 	[C]: in function 'doSendMagicEffect'
[25/7/2013 12:40:44] 	data/spells/scripts/Warrior/attack/Stun.lua:9: in function <data/spells/scripts/Warrior/attack/Stun.lua:8>

If anyone can help it'd be greatly appreciated and would be given a REP! :D

Thank you!
 
LUA:
local combat = createCombatObject()
    setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
    setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 1)
    setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_STUN)
    setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)	
 
local function effect(cid)
    if not isPlayer(cid) then return true end
	doSendMagicEffect(getThingPos(cid), CONST_ME_SLEEP)
end	
 
local paralyze = createConditionObject(CONDITION_PARALYZE)
setConditionParam(paralyze, CONDITION_PARAM_TICKS, 4000)
 
local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 4000)
 
local pacified = createConditionObject(CONDITION_PACIFIED)
setConditionParam(pacified, CONDITION_PARAM_TICKS, 4000)
 
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 4000)
 
function onCastSpell(cid, var)
	local target = getCreatureTarget(cid)
	local speed = getCreatureSpeed(target)
	doChangeSpeed(target, -speed)	
	addEvent(doChangeSpeed, 4000, target, speed)
	doAddCondition(target, paralyze)
	doAddCondition(target, muted)
	doAddCondition(target, pacified)
	doAddCondition(target, exhaust)
	for j = 0, 4 do
		addEvent(effect, 1000, cid)
	end	
 
    return doCombat(cid, combat, var)
end
 
Tried that and got this error:

[25/7/2013 15:33:5] [Error - Spell Interface]
[25/7/2013 15:33:5] In a timer event called from:
[25/7/2013 15:33:5] data/spells/scripts/Warrior/attack/Stun.lua:onCastSpell
[25/7/2013 15:33:5] Description:
[25/7/2013 15:33:5] (LuaInterface::luaGetThingPosition) Thing not found

- - - Updated - - -

Well, anyways thank you for helping... I think it's my distro so I'll change it to 0.2 and change all my files to see if that works :O REP for you though man ty :P
 
If you cant get it to work here because you probably did a silly mistake you will not get it to work on 0.2 either lol
 
I got it to work...

LUA:
local function effect(cid)
	local targ = getCreatureTarget(cid)
	doSendMagicEffect(getThingPos(targ), CONST_ME_SLEEP)
end

but btw it's only showing the magic effect only once even though I did "for j = 0,3 do" got any idea?

- - - Updated - - -

Well, took a while... but here's the finished spell!

LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_STUN)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_WEAPONTYPE)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)
	
function onGetFormulaValues(cid, level, skill, attack, factor)
	local skillTotal, levelTotal = skill + attack * 3, level / 5 * 3
	return -(skillTotal / 5 + levelTotal), -(skillTotal / 4 + levelTotal)
end
	
t1 = 2000
t2 = 4000
	
function effect(cid)
	local targ = getCreatureTarget(cid)
	doSendMagicEffect(getThingPos(targ), CONST_ME_SLEEP)
end

local paralyze = createConditionObject(CONDITION_PARALYZE)
setConditionParam(paralyze, CONDITION_PARAM_TICKS, 4000)
 
local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 4000)
 
local pacified = createConditionObject(CONDITION_PACIFIED)
setConditionParam(pacified, CONDITION_PARAM_TICKS, 4000)
 
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 4000)

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
local speed = getCreatureSpeed(target)
	doChangeSpeed(target, -speed)
	doAddCondition(target, paralyze)
	doAddCondition(target, muted)
	doAddCondition(target, pacified)
	doAddCondition(target, exhaust)	
	addEvent(doChangeSpeed, 4000, target, speed)
	addEvent(effect,t1,cid)
	addEvent(effect,t2,cid)
	return doCombat(cid, combat, var)
end
 
Back
Top