• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Reduction - doComabtHealth - mana shield problem

Apoccalypse

New Member
Joined
Apr 15, 2017
Messages
114
Solutions
2
Reaction score
4
Hi guys,
I created in game two special items which gives some extra protection ONLY from monsters.
Everytihing works perfect but I noticed that when item is equiped and the player has active mana shield and even mana is exhaustion, the script does not damage health points of the player.
An example:
Spell damages 1400
Player has 6k MP and has active mana shield ,so;
First hit dealt to us is 1400,next 1400,next 1400,next 1400 and then when 400 MP left, the script just take damge of this 400 MP instead of taking the normal damge which is 400 damge to MP and remains 1000 to HP.

Lua:
local t = {
       reduction1 = 3, -- poniewaz to sie sumuje z ProtectionAll i w sumie daje 7%
       reduction2 = 10,
       item = 2542,
       item = 10309,
       }


local storage = 815875 --the storage value used
-- value - [(value*(1-(t.reduction1/100)) + (value*(1-(t.reduction2/100)))]
function onStatsChange(target, attacker, type, combat, value)

local damage = value * (1-(t.reduction1/100))
local damage2 = value * ((t.reduction1 + 4)/100) -- +4 ,poniewaz ProtectionAll daje 4 % odpornosci
local Bothdamage = value * (1-((t.reduction1 + t.reduction2)/100))
local Bothdamage2 = value * ((t.reduction1 + t.reduction2 + 4)/100)
local Handdamage = value * (1-(t.reduction2/100))
local Handdamage2 = value

if isMonster(attacker) and isPlayer(target) and (type == 1 or type == 3) then
    print("Statement 1 passed")
 
if getPlayerStorageValue(target, storage) == -1 then
    doPlayerSetStorageValue(target, storage, 1)
 
  if (getPlayerSlotItem(target, CONST_SLOT_LEFT).itemid == 2542 or getPlayerSlotItem(target, CONST_SLOT_RIGHT).itemid == 2542) and getPlayerSlotItem(target, CONST_SLOT_RING).itemid == 10309 then
 
        return false,
        doTargetCombatHealth(cid, target, combat, -Bothdamage, -Bothdamage, 255),
        doPlayerSendTextMessage(target,MESSAGE_EVENT_DEFAULT, "Tempest Shield and Fire Hand absorbed " ..Bothdamage2.. " of the damge taken by you!"),
        doPlayerSetStorageValue(target, storage, -1),
        print("Both")
     
    elseif (getPlayerSlotItem(target, CONST_SLOT_LEFT).itemid == 2542 or getPlayerSlotItem(target, CONST_SLOT_RIGHT).itemid == 2542) then
    print("Statement 2 passed")
        return false,
        doTargetCombatHealth(cid, target, combat, -damage, -damage, 255),
        doPlayerSendTextMessage(target,MESSAGE_EVENT_DEFAULT, "Tempest Shield spared additional " ..damage2.. " Health Points for you!"),
        doPlayerSetStorageValue(target, storage, -1),
        print("Tempest")
 
    elseif getPlayerSlotItem(target, CONST_SLOT_RING).itemid == 10309 then
 
        return false,
        doTargetCombatHealth(cid, target, combat, -Handdamage, -Handdamage, 255),
        doPlayerSendTextMessage(target,MESSAGE_EVENT_DEFAULT, getCreatureName(attacker).. " dealt " ..Handdamage2.. " damage to you!"),
        doPlayerSetStorageValue(target, storage, -1),
        print("Hand")
    end
 
    else
  doPlayerSetStorageValue(target, storage, -1)
         
end
print("true")

end
return true
end

If anyone would take a look on it, that would be great :)
 
Please read the rules; Rules for the Support board
#8

What was the solution?
To be fair, he didn't break any rules.
He never added the content to his posts, so there was never any content for him to remove.

But yeah, it's usually best to post your solution, to help people in the future. :p
 
I've just added the condition that if player max hp is below 5% then script isn't execuded and a player became immortal again :)
 
To be fair, he didn't break any rules.
He never added the content to his posts, so there was never any content for him to remove.

But yeah, it's usually best to post your solution, to help people in the future. :p

Well that rule is pretty strange, but in essence it's to always write a solution to not edit everything and write "solved".
The reason is if people use the serach function (I hope everyone do that insted of opening new threads :p) they will find the solution, insted of getting mad about all the removed or not posted solutions.
 
Back
Top