i have add part of the code CreatureEvent - [TFS 1.2] Conditions: Resist, Absorb, Reflect, Deflect (https://otland.net/threads/tfs-1-2-conditions-resist-absorb-reflect-deflect.233406/) in my custom system, but i have this error after a time
LUA:
local refs = {
[COMBAT_PHYSICALDAMAGE] = CONST_ME_DRAWBLOOD,
[COMBAT_ENERGYDAMAGE] = CONST_ME_ENERGYAREA,
[COMBAT_EARTHDAMAGE] = CONST_ME_POISONAREA,
[COMBAT_FIREDAMAGE] = CONST_ME_FIREAREA,
[COMBAT_ICEDAMAGE] = CONST_ME_ICEAREA,
[COMBAT_HOLYDAMAGE] = CONST_ME_HOLYAREA,
[COMBAT_DROWNDAMAGE] = CONST_ME_LOSEENERGY,
[COMBAT_DEATHDAMAGE] = CONST_ME_MORTAREA
}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if isInArray({ORIGIN_MELEE, ORIGIN_RANGED, ORIGIN_SPELL}, origin) and primaryType ~= COMBAT_HEALING then
local attr = SlotSystem.getPlayerAttributes(creature)
local protect = 0
local reflect = 0
for k, v in pairs(attr) do
protect = SlotSystem.Attributes[k].ElementProtect[primaryType] and protect+(SlotSystem.Attributes[k].ElementProtect[primaryType]*v) or protect
if attacker then
reflect = SlotSystem.Attributes[k].ElementReflect[primaryType] and reflect+(SlotSystem.Attributes[k].ElementReflect[primaryType]*v) or reflect
-- local a = primaryDamage * (reflect / 100)
local a = ((primaryDamage*reflect)/100)
--local m = MonsterType(attacker:getName())
if attacker:isMonster() then
local m = MonsterType(attacker:getName())
local e = m:getElementList()
local f = m:getCombatImmunities()
if type(f) == "number" then
if f == primaryType then
a = 0
end
else
for i, j in pairs(f) do
if i == primaryType then
a = 0
end
end
end
if type(e) == "number" then
if e == primaryType then
if e > 0 then
a = (a - (a * (e / 100)))
else
a = (a + (a * ((e * -1) / 100)))
end
end
else
for i, j in pairs(e) do
if i == primaryType then
if j > 0 then
a = (a - (a * (j / 100)))
else
a = (a + (a * ((j * -1) / 100)))
end
end
end
end
end
doTargetCombatHealth(creature, attacker, primaryType, a, a)
if m ~= nil then
else
local position = creature:getPosition()
print(position.x, position.y, position.z)
end
end
end
primaryDamage = primaryDamage-((protect*primaryDamage)/100)
end
if primaryDamage == 0 and secondaryDamage == 0 and creature:isPlayer() then
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
LUA:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/custom/slot system.lua:onHealthChange
data/creaturescripts/scripts/custom/slot system.lua:26: attempt to index local 'm' (a nil value)
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/custom/slot system.lua:26: in function <data/creaturescripts/scripts/custom/slot system.lua:13>
Last edited: