hello guys, I have a MOD of Reflect System in my Server.
The MOD is: When a player buy an Item on the Shop, the player receive that item with some % of Reflect. The problem of the MOD is, when a player attack another player that uses this item with some % of Reflect, the Reflect don't works. I really need help on this.
I use TFS 0.4 r.3777.
The MOD is: When a player buy an Item on the Shop, the player receive that item with some % of Reflect. The problem of the MOD is, when a player attack another player that uses this item with some % of Reflect, the Reflect don't works. I really need help on this.
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Reflect System" version="0.1" author="Aluccard" contact="" enabled="yes">
<event type="login" name="regReflectDamage" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid,"ReflectDamage")
return true
end
]]></event>
<event type="statschange" name="ReflectDamage" event="script"><![CDATA[
local slotPos = {CONST_SLOT_NECKLACE, CONST_SLOT_FEET, CONST_SLOT_RING}
function onStatsChange(cid, attacker, type, combat, value)
if isCreature(cid) == true and isCreature(attacker) == true then
if (type == STATSCHANGE_HEALTHLOSS or (getCreatureCondition(cid, CONDITION_MANASHIELD) and type == STATSCHANGE_MANALOSS)) then
if combat ~= COMBAT_HEALING then
local reflectPercent = 0
local dmg = value
local playerPos = getCreaturePosition(cid)
local attackerPos = getCreaturePosition(attacker)
for i = 1, #slotPos do
if getPlayerSlotItem(cid, slotPos).uid > 1 then
if getItemReflectPercent(getPlayerSlotItem(cid, slotPos).uid) then
reflectPercent = reflectPercent + getItemReflectPercent(getPlayerSlotItem(cid, slotPos).uid)
end
end
end
if reflectPercent > 0 then
dmg = math.ceil(-value*((100-reflectPercent)/100))
if (dmg < 0) then
doCreatureAddHealth(cid, dmg)
doSendAnimatedText(playerPos, -dmg, COLOR_RED)
doSendMagicEffect(playerPos, 0)
else
doSendMagicEffect(playerPos, 3)
end
dmg = math.ceil(-value*(reflectPercent/100))
if (dmg < 0) then
doCreatureAddHealth(attacker, dmg)
doSendAnimatedText(attackerPos, -dmg, COLOR_RED)
doSendDistanceShoot(playerPos, attackerPos, CONST_ANI_SMALLHOLY)
end
else
return true
end
end
end
end
return true
end
]]>
</event>
</mod>
I use TFS 0.4 r.3777.