Postado Julho 27, 2015 9 anos Boa tarde queria um script de spell para healar x porcentagem de vida: por exemplo se o player tive 1000 de vida por uma spell q heale 30% ira healar 300 de hp desse player, eu consigui um de mana mas não consigo mudar ele pra hp ai o de mana local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE) setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, TRUE) setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, FALSE) function onCastSpell(cid, var) local manapercent = 15 * getPlayerMaxMana(cid) / 100 --O 5 é a porcentagem que você quer regenerar doCreatureAddMana(cid, manapercent) return doCombat(cid, combat, var) end
Postado Julho 27, 2015 9 anos Não entendo muito, mas tenta trocar essas linhas local manapercent = 15 * getPlayerMaxMana(cid) / 100 --O 5 é a porcentagem que você quer regenerar doCreatureAddMana(cid, manapercent) Por essa local healthpercent = 15 * getPlayerMaxHealth(cid) / 100 --O 5 é a porcentagem que você quer regenerar doCreatureAddHealth(cid, healthpercent)
Postado Julho 27, 2015 9 anos Vou passar um mais simples: local config = { cooldown = 10, -- tempo entre uma magia e outra time = 10, -- tempo em segundos que ficará healando percent = 5, --- porcentagem da vida que cura storage = 19330, effect = 12, --- efeito que vai sair mana = 40 -- quanto custa de mana } function onCastSpell(cid, var) if getCreatureMana(cid) >= config.mana then if os.time() - getPlayerStorageValue(cid, config.storage) >= config.cooldown then doPlayerSetStorageValue(cid, config.storage, os.time()) local i = 0 doCreatureAddMana(cid, -config.mana, 0) while i < config.time do i = i+1 addEvent(function() if isCreature(cid) then if getCreatureMaxHealth(cid) ~= getCreatureHealth(cid) then local lifedraw = math.ceil(getCreatureMaxHealth(cid) * (config.percent)/100) local pos = getPlayerPosition(cid) doCreatureAddHealth(cid, lifedraw, 1) doSendAnimatedText(pos, "+"..lifedraw , TEXTCOLOR_GREEN) doSendMagicEffect(pos, config.effect) end end end, 1000*i) end else doPlayerSendCancel(cid, "Your Mass Healing is at cooldown, you must wait "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, config.storage))).." seconds.") end else doPlayerSendCancel(cid, 36) end return false end Spells.xml <instant name="NOME DA MAGIA" words="PALAVRAS PRA CONJURAR" lvl="40" mana="0" prem="1" aggressive="0" exhaustion="1500" needlearn="0" event="script" value="especiais/healingtime.lua"> <vocation id="1"/> <vocation id="2"/> <vocation id="4"/> <vocation id="8"/> </instant> By: xWhiteWolf Editado Julho 27, 2015 9 anos por Anuudek (veja o histórico de edições)
Postado Julho 27, 2015 9 anos Autor Vou passar um mais simples: local config = { cooldown = 10, -- tempo entre uma magia e outra time = 10, -- tempo em segundos que ficará healando percent = 5, --- porcentagem da vida que cura storage = 19330, effect = 12, --- efeito que vai sair mana = 40 -- quanto custa de mana } function onCastSpell(cid, var) if getCreatureMana(cid) >= config.mana then if os.time() - getPlayerStorageValue(cid, config.storage) >= config.cooldown then doPlayerSetStorageValue(cid, config.storage, os.time()) local i = 0 doCreatureAddMana(cid, -config.mana, 0) while i < config.time do i = i+1 addEvent(function() if isCreature(cid) then if getCreatureMaxHealth(cid) ~= getCreatureHealth(cid) then local lifedraw = math.ceil(getCreatureMaxHealth(cid) * (config.percent)/100) local pos = getPlayerPosition(cid) doCreatureAddHealth(cid, lifedraw, 1) doSendAnimatedText(pos, "+"..lifedraw , TEXTCOLOR_GREEN) doSendMagicEffect(pos, config.effect) end end end, 1000*i) end else doPlayerSendCancel(cid, "Your Mass Healing is at cooldown, you must wait "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, config.storage))).." seconds.") end else doPlayerSendCancel(cid, 36) end return false end Spells.xml <instant name="NOME DA MAGIA" words="PALAVRAS PRA CONJURAR" lvl="40" mana="0" prem="1" aggressive="0" exhaustion="1500" needlearn="0" event="script" value="especiais/healingtime.lua"> <vocation id="1"/> <vocation id="2"/> <vocation id="4"/> <vocation id="8"/> </instant> By: xWhiteWolf Não funciona, e pior que nem erro na distro da, quamdo falo a magia no tibia não acontece nada Não entendo muito, mas tenta trocar essas linhas local manapercent = 15 * getPlayerMaxMana(cid) / 100 --O 5 é a porcentagem que você quer regenerar doCreatureAddMana(cid, manapercent) Por essa local healthpercent = 15 * getPlayerMaxHealth(cid) / 100 --O 5 é a porcentagem que você quer regenerar doCreatureAddHealth(cid, healthpercent) quamdo tento fazer isso, eu uso a magia no tibia, tambem não acontece nada, e aparece o seguinte erro na distro: [27/07/2015 18:02:55] [Error - Spell Interface] [27/07/2015 18:02:55] data/spells/scripts/curavida.lua:onCastSpell [27/07/2015 18:02:56] Description: [27/07/2015 18:02:56] data/spells/scripts/curavida.lua:6: attempt to call global 'getPlayerMaxHealth' (a nil value) [27/07/2015 18:02:56] stack traceback: [27/07/2015 18:02:56] data/spells/scripts/curavida.lua:6: in function <data/spells/scripts/curavida.lua:5>
Postado Julho 27, 2015 9 anos Não esqueça de mudar o diretório em spells.xml <instant name="NOME DA MAGIA" words="PALAVRAS PRA CONJURAR" lvl="40" mana="0" prem="1" aggressive="0" exhaustion="1500" needlearn="0" event="script" value="especiais/healingtime.lua"> <vocation id="1"/> <vocation id="2"/> <vocation id="4"/> <vocation id="8"/> </instant> Aqui: value="especiais/healingtime.lua"> Mesmo se não da, tente com esse: local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE) setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, TRUE) setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, FALSE) function onCastSpell(cid, var) local healthpercent = 15 * getPlayerMaxHealth(cid) / 100 --O 5 é a porcentagem que você quer regenerar doCreatureAddHealth(cid, healthpercent) return doCombat(cid, combat, var) end Editado Julho 27, 2015 9 anos por Anuudek (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.