Postado Fevereiro 1, 2016 9 anos Estou com algumas spells que estão com erro e queria a ajuda de alguém, na medida que eu por o script, digo também qual o erro dela. Nessa script, não estou conseguindo adicionar a função de cooldown nela, sempre diz que está faltando um 'end' pra fechar a função onCastSpell. Script: local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED) local time = 2 --Tempo de stun. function onCastSpell(cid) local target = getCreatureTarget(cid) if not isCreature(target) then return doPlayerSendCancel(cid, "You do not have a target.") end doCreatureSetNoMove(target, true) addEvent(function() if not isCreature(target) then return true end doCreatureSetNoMove(target, false) end, time * 1000) return true if exhaustion.check(cid, 100019) == false then exhaustion.set(cid, 100019, 60) return doCombat(cid, combat, var) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100019).." second(s) to use this spell again.") end end Essa spell é de ficar healando X porcento de vida em Y segundos. Eu conseguir por cooldown, tudo direitinho, quando usa, ela pega o cooldown e sem aquele bug que alguns tem, que faz o player não castar a magia, mas ainda assim, gasta mana. Até aqui tudo certo, o problema é que mesmo não castando, não gastando mana, depois que usa a primeira vez e ela pega o cooldown, se o player continuar a tentar usar, ela vai adicionando mais 'addEvent' de heal no player. Ex: Ela fica healando 400 de vida no player durante 20s, se eu usar de novo, mesmo em cooldown, ela adiciona esse event de novo, se eu usar 10x, vai adicionar o evento 10x, como se tivesse acumulando a magia no player, dai em vez de healar 400 de life por rodada, heala 400x10 por rodada. Script: local config = { tempo = 20, -- tempo em segundos que ficará healando percent = 30, --- porcentagem da vida que cura effect = 12 --- efeito que vai sair } function onCastSpell(cid, var) for i = 1, config.tempo do addEvent(function() if isCreature(cid) then local lifedraw = math.ceil(getCreatureMaxHealth(cid) * (config.percent)/100) local pos = getPlayerPosition(cid) doCreatureAddHealth(cid, lifedraw, 1) doSendAnimatedText(pos, "+"..lifedraw , TEXTCOLOR_TEAL) doSendMagicEffect(pos, config.effect) end end, 1000*i) end if exhaustion.check(cid, 100100) == false then exhaustion.set(cid, 100100, 30) return doCombat(cid, combat, var) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100101).." second(s) to use this spell again.") end end Essa outra tem o mesmo erro da Spell de cima. Essa não heala por porcentagem, e sim, de acordo com uma formula. Script: local tempo = 10 local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE) setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false) local condition = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(condition, CONDITION_PARAM_TICKS, tempo * 1000) setConditionParam(condition, CONDITION_PARAM_BUFF, true) function onCastSpell(cid, var) heal(cid) if exhaustion.check(cid, 100101) == false then exhaustion.set(cid, 100101, 30) return doCombat(cid, combat, var) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100101).." second(s) to use this spell again.") end end function heal(cid) local formula = 0.5 * getPlayerLevel(cid) for i = 1, tempo do addEvent(doCreatureAddHealth,1000 * i,cid, formula) end end Essa Spell, faz sair um effect em área, e todos que estiverem na área de ação da spell, ficam perdendo life, enquanto o player que usou, fica ganhando esse life que está sendo drenado dos players atingidos. O erro é que não está saindo o efeito, consequentemente, não está realizando as funções da spell. Script: local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE) arr = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0}, {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 3, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0}, {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, } local area = createCombatArea(arr) setCombatArea(combat, area) function spellCallbackLifeDrainArea(param) if (isPlayer(param.cid)) == 1 then if (param.hitmin == nil or param.hitmax == nil or param.healmin == nil or param.healmax == nil) then param.hitmin = math.floor(-getPlayerLevel(param.cid) * 0.1 + -getPlayerMagLevel(param.cid) * 0.1) param.hitmax = math.floor(-getPlayerLevel(param.cid) * 0.2 + -getPlayerMagLevel(param.cid) * 0.15) param.healmin = -param.hitmin param.healmax = -param.hitmax end local onPos = param.pos if param.count > 0 or math.random(0, 1) == 1 then local creatureToHit = getThingfromPos({x=onPos.x,y=onPos.y,z=onPos.z,stackpos=STACKPOS_TOP_CREATURE}) if isCreature(creatureToHit.uid) == 1 and creatureToHit.uid ~= param.cid then doCreatureAddHealth(param.cid, math.random(param.healmin, param.healmax+1)) doAreaCombatHealth(param.cid, COMBAT_LIFEDRAIN, param.pos, 0, param.hitmin, param.hitmax, CONST_ME_NONE) end end if(param.count < 30) then param.count = param.count + 1 addEvent(spellCallbackLifeDrainArea, 500, param) end end end function onTargetTileLifeDrainArea(cid, pos) local param = {} param.cid = cid param.pos = pos param.count = 0 spellCallbackLifeDrainArea(param) end setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTileLifeDrainArea") function onCastSpell(cid, var) if exhaustion.check(cid, 100102) == false then exhaustion.set(cid, 100102, 30) return doCombat(cid, combat, var) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100102).." second(s) to use this spell again.") end end Essa Spell, não estou conseguindo adicionar cooldown. Ela é uma spell de múltiplos attacks. Script: -- SpellCreator generated. -- =============== COMBAT VARS =============== -- Areas/Combat for 0ms local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW) function onGetFormulaValues(cid, level, skill, attack, factor) min = -(level * 1 + skill * 1.5) * 0.3 max = -(level * 1 + skill * 1.5) * 0.7 return min, max end setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues") function onCastSpell(cid, var) return doCombat(cid, combat, var) end -- Areas/Combat for 500ms local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW) function onGetFormulaValues(cid, level, skill, attack, factor) min = -(level * 1 + skill * 1.5) * 0.3 max = -(level * 1 + skill * 1.5) * 0.7 return min, max end setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues") function onCastSpell(cid, var) return doCombat(cid, combat, var) end -- Areas/Combat for 1000ms local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW) function onGetFormulaValues(cid, level, skill, attack, factor) min = -(level * 1 + skill * 1.5) * 0.3 max = -(level * 1 + skill * 1.5) * 0.7 return min, max end setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues") function onCastSpell(cid, var) return doCombat(cid, combat, var) end -- Areas/Combat for 1500ms local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW) function onGetFormulaValues(cid, level, skill, attack, factor) min = -(level * 1 + skill * 1.5) * 0.3 max = -(level * 1 + skill * 1.5) * 0.7 return min, max end setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues") function onCastSpell(cid, var) return doCombat(cid, combat, var) end -- =============== CORE FUNCTIONS =============== local function RunPart(c,cid,var,dirList,dirEmitPos) -- Part if (isCreature(cid)) then doCombat(cid, c, var) if (dirList ~= nil) then -- Emit distance effects local i = 2; while (i < #dirList) do doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x-dirList,y=dirEmitPos.y-dirList[i+1],z=dirEmitPos.z},dirList[1]) i = i + 2 end end end end function onCastSpell(cid, var) local startPos = getCreaturePosition(cid) RunPart(combat,cid,var) addEvent(RunPart,500,combat,cid,var) addEvent(RunPart,1000,combat,cid,var) addEvent(RunPart,1500,combat,cid,var) return true end Se puderem ajudar, agradeço desde já. Editado Fevereiro 1, 2016 9 anos por gabriel28 (veja o histórico de edições)
Postado Fevereiro 1, 2016 9 anos Primeira: Spoiler local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED) local time = 2 --Tempo de stun. function onCastSpell(cid, var) if exhaustion.check(cid, 100019) ~= true then exhaustion.set(cid, 100019, 60) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100019).." second(s) to use this spell again.") return false end local target = getCreatureTarget(cid) if not isCreature(target) then doPlayerSendCancel(cid, "You do not have a target.") return false end doCreatureSetNoMove(target, true) doCombat(cid, combat, var) addEvent(function() if not isCreature(target) then return true end doCreatureSetNoMove(target, false) end, time * 1000) return true end Segunda: Spoiler local config = { tempo = 20, -- tempo em segundos que ficará healando percent = 30, --- porcentagem da vida que cura effect = 12 --- efeito que vai sair } function onCastSpell(cid, var) if exhaustion.check(cid, 100100) ~= true then exhaustion.set(cid, 100100, 30) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100101).." second(s) to use this spell again.") return false end for i = 1, config.tempo do addEvent(function() if isCreature(cid) then local lifedraw = math.ceil(getCreatureMaxHealth(cid) * (config.percent)/100) local pos = getPlayerPosition(cid) doCreatureAddHealth(cid, lifedraw, 1) doSendAnimatedText(pos, "+"..lifedraw , TEXTCOLOR_TEAL) doSendMagicEffect(pos, config.effect) end end, 1000*i) end return true end terceira: Spoiler local tempo = 10 local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE) setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false) local condition = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(condition, CONDITION_PARAM_TICKS, tempo * 1000) setConditionParam(condition, CONDITION_PARAM_BUFF, true) function onCastSpell(cid, var) heal(cid) if exhaustion.check(cid, 100101) == false then exhaustion.set(cid, 100101, 30) return doCombat(cid, combat, var) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100101).." second(s) to use this spell again.") return false end end function heal(cid) local formula = 0.5 * getPlayerLevel(cid) for i = 1, tempo do addEvent(doCreatureAddHealth,1000 * i,cid, formula) end end ultima: Spoiler -- SpellCreator generated. -- =============== COMBAT VARS =============== -- Areas/Combat for 0ms local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW) function onGetFormulaValues(cid, level, skill, attack, factor) min = -(level * 1 + skill * 1.5) * 0.3 max = -(level * 1 + skill * 1.5) * 0.7 return min, max end setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues") function onCastSpell(cid, var) return doCombat(cid, combat, var) end -- Areas/Combat for 500ms local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW) function onGetFormulaValues(cid, level, skill, attack, factor) min = -(level * 1 + skill * 1.5) * 0.3 max = -(level * 1 + skill * 1.5) * 0.7 return min, max end setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues") function onCastSpell(cid, var) return doCombat(cid, combat, var) end -- Areas/Combat for 1000ms local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW) function onGetFormulaValues(cid, level, skill, attack, factor) min = -(level * 1 + skill * 1.5) * 0.3 max = -(level * 1 + skill * 1.5) * 0.7 return min, max end setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues") function onCastSpell(cid, var) return doCombat(cid, combat, var) end -- Areas/Combat for 1500ms local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ARROW) function onGetFormulaValues(cid, level, skill, attack, factor) min = -(level * 1 + skill * 1.5) * 0.3 max = -(level * 1 + skill * 1.5) * 0.7 return min, max end setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues") function onCastSpell(cid, var) return doCombat(cid, combat, var) end -- =============== CORE FUNCTIONS =============== local function RunPart(c,cid,var,dirList,dirEmitPos) -- Part if (isCreature(cid)) then doCombat(cid, c, var) if (dirList ~= nil) then -- Emit distance effects local i = 2; while (i < #dirList) do doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x-dirList,y=dirEmitPos.y-dirList[i+1],z=dirEmitPos.z},dirList[1]) i = i + 2 end end end end function onCastSpell(cid, var) if exhaustion.check(cid, 100103) ~= true then exhaustion.set(cid, 100103, 30) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100103).." second(s) to use this spell again.") return false end local startPos = getCreaturePosition(cid) RunPart(combat,cid,var) addEvent(RunPart,500,combat,cid,var) addEvent(RunPart,1000,combat,cid,var) addEvent(RunPart,1500,combat,cid,var) return true end edit: a segunda tá dentro do spoiler da primeira e não to conseguindo arrumar Editado Fevereiro 1, 2016 9 anos por xWhiteWolf (veja o histórico de edições) Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá! "Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda (obg ao @Beeny por fazer essa linda sign <3)
Postado Fevereiro 1, 2016 9 anos Autor Valeu pela ajuda, ainda tem uns problemas: 1ª O char não casta a spell. Sem erro no Console. 2º O char casta a spell, mas da erro no console: lua:11: attempt to concatenate a boolean value / lua:11: in fuction <data/spells.......const heal:lua:7> 3º Está com o mesmo problema. 4° Funcionando perfeitamente.
Postado Fevereiro 1, 2016 9 anos Primeira: Spoiler local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED) local time = 2 --Tempo de stun. function onCastSpell(cid, var) if exhaustion.check(cid, 100019) ~= true then exhaustion.set(cid, 100019, 60) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100019).." second(s) to use this spell again.") return false end local target = getCreatureTarget(cid) if not isCreature(target) then doPlayerSendCancel(cid, "You do not have a target.") return false end doCreatureSetNoMove(target, true) addEvent(function() if isCreature(target) then doCreatureSetNoMove(target, false) end end, time * 1000) return doCombat(cid, combat, var) end Segunda: Spoiler local config = { tempo = 20, -- tempo em segundos que ficará healando percent = 30, --- porcentagem da vida que cura effect = 12 --- efeito que vai sair } function onCastSpell(cid, var) if exhaustion.check(cid, 100100) ~= true then exhaustion.set(cid, 100100, 30) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100100).." second(s) to use this spell again.") return false end for i = 1, config.tempo do addEvent(function() if isCreature(cid) then local lifedraw = math.ceil(getCreatureMaxHealth(cid) * (config.percent)/100) local pos = getPlayerPosition(cid) doCreatureAddHealth(cid, lifedraw, 1) doSendAnimatedText(pos, "+"..lifedraw , TEXTCOLOR_TEAL) doSendMagicEffect(pos, config.effect) end end, 1000*i) end return true end O erro q tem na terceira é o mesmo da segunda? pq ele tá falando q essa função exhaustion.get(cid, 100100) tá retornando um boolean (true/false). Então a função deve estar errada no seu servidor, pois ela deveria retornar o tempo até poder usar novamente Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá! "Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda (obg ao @Beeny por fazer essa linda sign <3)
Postado Fevereiro 1, 2016 9 anos Autor 53 minutos atrás, xWhiteWolf disse: Primeira: Mostrar conteúdo oculto local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED) local time = 2 --Tempo de stun. function onCastSpell(cid, var) if exhaustion.check(cid, 100019) ~= true then exhaustion.set(cid, 100019, 60) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100019).." second(s) to use this spell again.") return false end local target = getCreatureTarget(cid) if not isCreature(target) then doPlayerSendCancel(cid, "You do not have a target.") return false end doCreatureSetNoMove(target, true) addEvent(function() if isCreature(target) then doCreatureSetNoMove(target, false) end end, time * 1000) return doCombat(cid, combat, var) end Segunda: Mostrar conteúdo oculto local config = { tempo = 20, -- tempo em segundos que ficará healando percent = 30, --- porcentagem da vida que cura effect = 12 --- efeito que vai sair } function onCastSpell(cid, var) if exhaustion.check(cid, 100100) ~= true then exhaustion.set(cid, 100100, 30) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100100).." second(s) to use this spell again.") return false end for i = 1, config.tempo do addEvent(function() if isCreature(cid) then local lifedraw = math.ceil(getCreatureMaxHealth(cid) * (config.percent)/100) local pos = getPlayerPosition(cid) doCreatureAddHealth(cid, lifedraw, 1) doSendAnimatedText(pos, "+"..lifedraw , TEXTCOLOR_TEAL) doSendMagicEffect(pos, config.effect) end end, 1000*i) end return true end O erro q tem na terceira é o mesmo da segunda? pq ele tá falando q essa função exhaustion.get(cid, 100100) tá retornando um boolean (true/false). Então a função deve estar errada no seu servidor, pois ela deveria retornar o tempo até poder usar novamente Eu não coloquei direito, desculpa, a terceira continua com o mesmo erro do post que fiz, ela funciona normal, sem erro no console, mas fica adicionando os eventos de heal mesmo em cooldown. E essa função de por cooldown nas magias, eu uso em várias outras, sem erro algum. Irei testar essas duas que mandasse, e já comento aqui se funcionou. Edit: Creio que o erro da segunda ocorreu porque no script que você mandou, tinha uma storage diferente, e eu não percebi na hora que testei. function onCastSpell(cid, var) if exhaustion.check(cid, 100100) ~= true then exhaustion.set(cid, 100100, 30) else doPlayerSendCancel(cid, "Wait "..exhaustion.get(cid, 100101).." second(s) to use this spell again.") return false end Estava desse jeito. Aqui > ..exhaustion.get(cid, 100101), era pra tá 100100 também, mas esse que você mandou já ta com isso corrigido. Editado Fevereiro 1, 2016 9 anos por gabriel28 (veja o histórico de edições)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.