Isso está acontecendo porque a função xReturn está sendo chamada depois da verificação de imunidade do monstro, que, se verdadeira, interrompe a execução do código. Por consequência, xReturn não é chamado nesta condição. Eu não li o código inteiro para ver se a seguinte mudança de eventos pode prejudicar em algum cálculo. Qualquer coisa, basta um backup e veremos o que pode ser feito.
Transfira:
if valor >= getCreatureHealth(cid) then if isInArray(cannotKill, combat) and isPlayer(cid) then valor = getCreatureHealth(cid) - 1 else valor = getCreatureHealth(cid) endendvalor = math.floor(valor) --alterado v1.6
Para abaixo de:
if p.x == 1 and p.y == 1 and p.z == 10 then return false end
Transfira:
-- Return -- xReturn(cid, attacker, valor)-- Return --
Para abaixo da primeira modificação.
O resultado final deve ser:
if p.x == 1 and p.y == 1 and p.z == 10 then return false endif valor >= getCreatureHealth(cid) then if isInArray(cannotKill, combat) and isPlayer(cid) then valor = getCreatureHealth(cid) - 1 else valor = getCreatureHealth(cid) endendvalor = math.floor(valor) -- Return -- xReturn(cid, attacker, math.abs(valor))-- Return -- if getPlayerStorageValue(cid, 9658783) == 1 then return false --imuneend
Assim, a função xReturn será chamada antes da interrupção do código pela verificação de invulnerabilidade.