E ae galera, eu estava pensando aqui pro War. E acabei fazendo por que uma magia iria dar 5 Reflect para uma pessoa.
Entao o script funciona assim, ele reflete qualquer tipo de dano de acordo com a porcentagem que voce colocou, e se voce quiser colocar veses que ele vai refletir, eh muito facil colocar.
Vamos la. O script principal:
data/creaturescripts/scripts/damageReflector.lua
local config = { author = Uissu, reflectHeal = false, -- '[true/false]' reflectMana = true, -- '[true/false]' onlyMonsters = false, -- '[true/false]' storage = 63941, -- 'dont change this' storageCount = storage+1 } function getPlayerReflectPercent(cid) return getPlayerStorageValue(cid, config.storage) end local reflectValue = value/getPlayerReflectPercent(cid) function onStatsChange(cid, attacker, enps, combatee, value) if not(config.reflectHeal) and enps == STATSCHANGE_HEALTHGAIN then return TRUE end if config.onlyMonsters and not isMonster(attacker) then return TRUE end if not(config.reflectMana) and enps == STATSCHANGE_MANALOSS then return TRUE end if enps == STATSCHANGE_MANAGAIN then return TRUE end if attacker == nil then return TRUE end if getPlayerStorageValue(cid, config.storageCount) > 0 then setPlayerStorageValue(cid, config.storageCount, getPlayerStorageValue(cid, config.storageCount)-1) end if getPlayerStorageValue(cid, config.storageCount) == 0 then setPlayerStorageValue(cid, config.storageCount, -1) setPlayerStorageValue(cid, config.storage, -1) end doTargetCombatHealth(cid, attacker, combatee, -reflectValue, -reflectValue, CONST_ME_NONE) doSendAnimatedText(getThingPos(cid), "REFLECT!", TEXTCOLOR_WHITE) value = value - reflectValue return TRUE end
data/creaturescripts/creaturescripts.xml
<event type="statschange" name="damageReflector" script="damageReflector.lua"/>
data/creaturescripts/scripts/login.lua
Logo abaixo de
registerCreatureEvent(cid, "ReportBug")coloque:
registerCreatureEvent(cid, "damageReflector")
Como utilizar?
Primeiro precisamos de uma funçao que seta se vai refletir e quantas veses, ou nao:
function setPlayerReflectPercent(cid, percent, count) setPlayerStorageValue(cid, 63941, percent < 101 and percent or 100) setPlayerStorageValue(cid, 63942, count ~= false and count or -1) return true end
Mas como usar essa funçao?
setPlayerReflectPercent(cid, PORCENTAGEM, NUMERODEVESES OU FALSE)
PORCENTAGEM = um valor numerico entre 0 e 100 (ex: 57 para refletir 57% do dano)
NUMERODEVESES = um valor numerico para o numero de veses que ele vai reflect (ex: 5 para refletir 5 veses) ou false, para refletir ilimitadamente.