• 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 Increase Damage dealt

Apoccalypse

New Member
Joined
Apr 15, 2017
Messages
114
Solutions
2
Reaction score
4
Hello guys,
I am trying to make the specific item to increase all damage dealt.
I have the following script:


Lua:
function onStatsChange(cid, attacker, type, combat, value)
   local config = {
       item_id = 2400, -- right or left hand
       more_dmg = 30, -- percent
       more_dmg_spell = 20, -- percent
       storage = 815869
   }
 
   if isPlayer(cid) and getPlayerStorageValue(cid, 815869) == 1  then
       if((type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and (getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == config.item_id or getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid == config.item_id)) then
           if(combat == COMBAT_PHYSICALDAMAGE) then
               local correct = value + (value * config.more_dmg)
               doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
           else
               local correct = value + (value * config.more_dmg_spell)
               doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
           end
           return false
       end
   end
end

Lua:
registerCreatureEvent(cid, "MoreDMG")

Lua:
<event type="statschange" name="MoreDMG"            event="script" value="MoreDMG.lua"/>

I use the storage ,because I was getting a stack overflow all over again.
The storage is set in movements:


Lua:
function onEquip(cid, item, slot)
    local slots = getPlayerSlotItem(cid, slot)
    if slots then
        if slots.itemid ~= item.itemid then
            return true
        end
        if getPlayerStorageValue(cid, 815869) < 1 then
            setPlayerStorageValue(cid, 815869, 1)
        end
    end
    return  true
end
function onDeEquip(cid, item, slot)
    if getPlayerStorageValue(cid, 815869) > 0 then
        setPlayerStorageValue(cid, 815869, 0)
    end
    return  true
end

The problem is that I get no errors but the script is no working for me.
If anyone would help that would be great :)
 
Solution
It is no necessary to work it against monsters, i was just testing it on it ,because I thought it is no diffrence.
I get now this error and any damage is aplied for the monster.

Code:
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed...
When the script is active whether item is equiped or not the players are unable to use manarune and staff like this.
And still ,no damage increased.
I've checked the script Item 2400 and it doesn't work either.
When I used a storage which is already set to check wheter script increase the damage , still any positive result.
I am thinking ,meaby instead using function onStatsChange by itself ,it would be better to move it all to movements and there in onEquip,
add event with this function onStatsChane but I don't know whether it changes anything.
 
It is not about the manarune.I've just noticed that when script is loaded to the server, monsters make no damage and any potions gives any health or mana.
 
It is not about the manarune.I've just noticed that when script is loaded to the server, monsters make no damage and any potions gives any health or mana.
Try returning whole onStatsChange event with it's default outcome.
You're only returning the case when player has storage value. I guess that's it.
 
If you using movements go like this:
Lua:
function onStatsChange(cid, attacker, type, combat, value)
   local config = {
       more_dmg = 30, -- percent
       more_dmg_spell = 20, -- percent
       storage = 815869
   }
   if isPlayer(cid) and getPlayerStorageValue(cid, config.storage) == 1 and type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS then
       if(combat == COMBAT_PHYSICALDAMAGE) then
           local correct = value + (value * config.more_dmg)
           doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
       else
           local correct = value + (value * config.more_dmg_spell)
           doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
       end
       return false
   end
   return true
end
your movements:
Lua:
function onEquip(cid, item, slot)
    local slots = getPlayerSlotItem(cid, slot)
    if slots then
        if slots.itemid ~= item.itemid then
            return true
        end
       if slot == CONST_SLOT_LEFT or slot == CONST_SLOT_RIGHT then
           setPlayerStorageValue(cid, 815869, 1)
       end
    end
    return true
end
function onDeEquip(cid, item, slot)
    setPlayerStorageValue(cid, 815869, 0)
    return true
end
 
Still the same and in addition:
[15:59:04.108] [Error - CreatureEvent::executeStatsChange] Call stack overflow.

I have another script which can help us to find the problem:
This one is the opposite to main script, it is about reduction:

Lua:
local reduction = 10 --this means that the damage is reduced by 70%
local storage = 815870 --the storage value used
function onStatsChange(target, attacker, type, combat, value)
if isCreature(attacker) and isPlayer(target) and (type == 1 or type == 3) then
    if getPlayerStorageValue(target,storage) ~= 1 then
        return true,
        setPlayerStorageValue(target,storage,1),
        doCreatureAddHealth(target,value*(1-(reduction/100))),
        doPlayerSendTextMessage(target,MESSAGE_EVENT_DEFAULT, getCreatureName(attacker).. " dealt " ..value*(1-(reduction/100)).. " damage to you!")
    else
        setPlayerStorageValue(target,storage,0)
    end
end
return true
end

And what is a problem here,so:
Generally it works but it doesn't,so according to this line:

Lua:
 doPlayerSendTextMessage(target,MESSAGE_EVENT_DEFAULT, getCreatureName(attacker).. " dealt " ..value*(1-(reduction/100)).. " damage to you!")
)

"doPlayerSendTextMessage(target,.....) - script sends the message to the player so it knows who is the target
"getCreatureName(attacker).. " - it gives the name of creature which attacks us ,so the script know who is attacker.
"(...) dealt " ..value*(1-(reduction/100)).. " damage to you!")" and here is the problem. It always says (...) deals 0 damage to you ,just like the script doesn't know what the value is.

I assume that the simillar problem can happen here :(
 
When the script is active whether item is equiped or not the players are unable to use manarune and staff like this.
And still ,no damage increased.
I've checked the script Item 2400 and it doesn't work either.
When I used a storage which is already set to check wheter script increase the damage , still any positive result.
I am thinking ,meaby instead using function onStatsChange by itself ,it would be better to move it all to movements and there in onEquip,
add event with this function onStatsChane but I don't know whether it changes anything.
they aren't able to use manarune because you need to have return true at the bottom of your script
try this
Lua:
local config = {
    item_id = 2400, -- right or left hand
    more_dmg = 30, -- percent
    more_dmg_spell = 20, -- percent
    storage = 815869
}

local function checkDamageIncrease(cid)
    local item = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
    if item and item.itemid == config.item_id then
        return true
    end
    item = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    if item and item.itemid == config.item_id then
        return true
    end
    return false
end

local storage = 815500 -- make sure stack overflow doesn't happen

function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(attacker) and getPlayerStorageValue(attacker, 815869) == 1  then
        if (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and checkDamageIncrease(attacker) then
            if getPlayerStorageValue(cid, storage) == -1 then
                if (combat == COMBAT_PHYSICALDAMAGE) then
                    local correct = value + (value * (config.more_dmg / 100))
                    doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
                else
                    local correct = value + (value * (config.more_dmg_spell / 100))
                    doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
                end
                doPlayerSetStorageValue(cid, storage, 1)
            else
                doPlayerSetStorageValue(cid, storage, -1)
            end
            return false
        end
    end
    return true
end
 
Manarune and potions works normally but the script does not work.

Lua:
local config = {
    item_id = 2400, -- right or left hand
    more_dmg = 30, -- percent
    more_dmg_spell = 20, -- percent
    storage = 815869
}
local function checkDamageIncrease(cid)
    local item = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
    if item and item.itemid == config.item_id then
        return true
    end
    item = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    if item and item.itemid == config.item_id then
        return true
    end
    return false
end
local storage = 815500 -- make sure stack overflow doesn't happen
function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(attacker) and getPlayerStorageValue(attacker, 815869) == 1  then
        if (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and checkDamageIncrease(attacker) then
            if getPlayerStorageValue(cid, storage) == -1 then
                if (combat == COMBAT_PHYSICALDAMAGE) then
                    local correct = value + (value * (config.more_dmg / 100))
                    doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
                    doPlayerSendTextMessage(attacker,MESSAGE_EVENT_DEFAULT, getCreatureName(cid).. " dealt " ..correct.. " damage to the creature.!")
                else
                    local correct = value + (value * (config.more_dmg_spell / 100))
                    doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
                end
                doPlayerSetStorageValue(cid, storage, 1)
            else
                doPlayerSetStorageValue(cid, storage, -1)
            end
            return false
        end
    end
    return true
end

I added this line to find out more but when damage is aplied any message is sent to the player.
Code:
doPlayerSendTextMessage(attacker,MESSAGE_EVENT_DEFAULT, getCreatureName(cid).. " dealt " ..correct.. " damage to the creature.!")
 
Manarune and potions works normally but the script does not work.

Lua:
local config = {
    item_id = 2400, -- right or left hand
    more_dmg = 30, -- percent
    more_dmg_spell = 20, -- percent
    storage = 815869
}
local function checkDamageIncrease(cid)
    local item = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
    if item and item.itemid == config.item_id then
        return true
    end
    item = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    if item and item.itemid == config.item_id then
        return true
    end
    return false
end
local storage = 815500 -- make sure stack overflow doesn't happen
function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(attacker) and getPlayerStorageValue(attacker, 815869) == 1  then
        if (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and checkDamageIncrease(attacker) then
            if getPlayerStorageValue(cid, storage) == -1 then
                if (combat == COMBAT_PHYSICALDAMAGE) then
                    local correct = value + (value * (config.more_dmg / 100))
                    doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
                    doPlayerSendTextMessage(attacker,MESSAGE_EVENT_DEFAULT, getCreatureName(cid).. " dealt " ..correct.. " damage to the creature.!")
                else
                    local correct = value + (value * (config.more_dmg_spell / 100))
                    doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
                end
                doPlayerSetStorageValue(cid, storage, 1)
            else
                doPlayerSetStorageValue(cid, storage, -1)
            end
            return false
        end
    end
    return true
end

I added this line to find out more but when damage is aplied any message is sent to the player.
Code:
doPlayerSendTextMessage(attacker,MESSAGE_EVENT_DEFAULT, getCreatureName(cid).. " dealt " ..correct.. " damage to the creature.!")
i forgot to change it to negative values, my bad
if it still doesn't work tell me exactly what you're doing and what is happening
Lua:
local config = {
    item_id = 2400, -- right or left hand
    more_dmg = 30, -- percent
    more_dmg_spell = 20, -- percent
    storage = 815869
}

local function checkDamageIncrease(cid)
    local item = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
    if item and item.itemid == config.item_id then
        return true
    end
    item = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    if item and item.itemid == config.item_id then
        return true
    end
    return false
end

local storage = 815500 -- make sure stack overflow doesn't happen

function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(attacker) and getPlayerStorageValue(attacker, 815869) == 1  then
        if (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and checkDamageIncrease(attacker) then
            if getPlayerStorageValue(cid, storage) == -1 then
                if (combat == COMBAT_PHYSICALDAMAGE) then
                    local correct = value + (value * (config.more_dmg / 100))
                    doTargetCombatHealth(attacker, cid, combat, -correct, -correct, 255)
                else
                    local correct = value + (value * (config.more_dmg_spell / 100))
                    doTargetCombatHealth(attacker, cid, combat, -correct, -correct, 255)
                end
                doPlayerSetStorageValue(cid, storage, 1)
            else
                doPlayerSetStorageValue(cid, storage, -1)
            end
            return false
        end
    end
    return true
end
 
Still the same,
So instead of storage 815869 I use storage 5011 (just to see if it is working) which is constantly set to 1 for my character, because this function from movements doesn't work for me.

Lua:
function onEquip(cid, item, slot)
    local slots = getPlayerSlotItem(cid, slot)
    if slots then
        if slots.itemid ~= item.itemid then
            return true
        end
       if slot == CONST_SLOT_LEFT or slot == CONST_SLOT_RIGHT then
           setPlayerStorageValue(cid, 815869, 1)
       end
    end
    return true
end
function onDeEquip(cid, item, slot)
    setPlayerStorageValue(cid, 815869, 0)
    return true
end

So I attack a monk with the exori spell (which is physical damage), having in my left character's hand itemid 2400.
An with or without it the damge from the spell is always the same.
 
Still the same,
So instead of storage 815869 I use storage 5011 (just to see if it is working) which is constantly set to 1 for my character, because this function from movements doesn't work for me.

Lua:
function onEquip(cid, item, slot)
    local slots = getPlayerSlotItem(cid, slot)
    if slots then
        if slots.itemid ~= item.itemid then
            return true
        end
       if slot == CONST_SLOT_LEFT or slot == CONST_SLOT_RIGHT then
           setPlayerStorageValue(cid, 815869, 1)
       end
    end
    return true
end
function onDeEquip(cid, item, slot)
    setPlayerStorageValue(cid, 815869, 0)
    return true
end

So I attack a monk with the exori spell (which is physical damage), having in my left character's hand itemid 2400.
An with or without it the damge from the spell is always the same.
can you test this out for me and tell me what it prints?
will be easier to see what error is
i just added a bunch of prints after each if statement to see where it's failing to execute
Lua:
local config = {
    item_id = 2400, -- right or left hand
    more_dmg = 30, -- percent
    more_dmg_spell = 20, -- percent
    storage = 815869
}

local function checkDamageIncrease(cid)
    print("checking damage increase")
    local item = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
    if item and item.itemid == config.item_id then
        return true
    end
    item = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    if item and item.itemid == config.item_id then
        return true
    end
    return false
end

local storage = 815500 -- make sure stack overflow doesn't happen

function onStatsChange(cid, attacker, type, combat, value)
    print("start statschange execution")
    if isPlayer(attacker) and getPlayerStorageValue(attacker, config.storage) == 1 then
        print("statement 1 passed")
        if (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and checkDamageIncrease(attacker) then
            print("statement 2 passed")
            if getPlayerStorageValue(cid, storage) == -1 then
                print("statement 3 passed")
                if (combat == COMBAT_PHYSICALDAMAGE) then
                    print("physical damage")
                    local correct = value + (value * (config.more_dmg / 100))
                    doTargetCombatHealth(attacker, cid, combat, -correct, -correct, 255)
                else
                    print("other damage")
                    local correct = value + (value * (config.more_dmg_spell / 100))
                    doTargetCombatHealth(attacker, cid, combat, -correct, -correct, 255)
                end
                doPlayerSetStorageValue(cid, storage, 1)
            else
                doPlayerSetStorageValue(cid, storage, -1)
            end
            print("end execution // return false")
            return false
        end
    end
    print("end execution // return true")
    return true
end
 
hmm

start statschange execution
end execution // return true
oh you're trying to use it on monsters and stuff
no wonder it doesn't work
you have to register it in the monk's xml file
the function only executes to those that have it registered on them
XML:
<script>
    <event name="MoreDMG"/>
</script>
 
It is no necessary to work it against monsters, i was just testing it on it ,because I thought it is no diffrence.
I get now this error and any damage is aplied for the monster.

Code:
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
[17:33:08.988] [Error - CreatureEvent::executeCombat] Call stack overflow.
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
 
It is no necessary to work it against monsters, i was just testing it on it ,because I thought it is no diffrence.
I get now this error and any damage is aplied for the monster.

Code:
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
end execution // return true
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
start statschange execution
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
[17:33:08.988] [Error - CreatureEvent::executeCombat] Call stack overflow.
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
end execution // return false
now this should work
i forgot i had to set the storage value before the creature takes a hit, otherwise it will stack overflow and the storage will never get set then reset
Lua:
local config = {
    item_id = 2400, -- right or left hand
    more_dmg = 30, -- percent
    more_dmg_spell = 20, -- percent
    storage = 815869
}

local function checkDamageIncrease(cid)
    local item = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
    if item and item.itemid == config.item_id then
        return true
    end
    item = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    if item and item.itemid == config.item_id then
        return true
    end
    return false
end

local storage = 815500 -- make sure stack overflow doesn't happen

function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(attacker) and getPlayerStorageValue(attacker, config.storage) == 1 then
        if (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and checkDamageIncrease(attacker) then
            if getPlayerStorageValue(cid, storage) == -1 then
                doPlayerSetStorageValue(cid, storage, 1) -- set storage value before the creature takes another hit to avoid overflow
                if (combat == COMBAT_PHYSICALDAMAGE) then
                    local correct = value + (value * (config.more_dmg / 100))
                    doTargetCombatHealth(attacker, cid, combat, -correct, -correct, 255)
                else
                    local correct = value + (value * (config.more_dmg_spell / 100))
                    doTargetCombatHealth(attacker, cid, combat, -correct, -correct, 255)
                end
                return false
            else
                doPlayerSetStorageValue(cid, storage, -1)
            end
        end
    end
    return true
end
 
Last edited:
Solution
Still doesn't work :(
I added this print thing:

Lua:
local config = {
    item_id = 2400, -- right or left hand
    more_dmg = 30, -- percent
    more_dmg_spell = 20, -- percent
    storage = 5011
}
local function checkDamageIncrease(cid)
    print("checking damage increase")
    local item = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
    if item and item.itemid == config.item_id then
        return true
    end
    item = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    if item and item.itemid == config.item_id then
        return true
    end
    return false
end
local storage = 815500 -- make sure stack overflow doesn't happen
function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(attacker) and getPlayerStorageValue(attacker, config.storage) == 1 then
     print("statement 1 passed")
        if (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and checkDamageIncrease(attacker) then
         print("statement 2 passed")
            if getPlayerStorageValue(cid, storage) == -1 then
                doPlayerSetStorageValue(cid, storage, 1) -- set storage value before the creature takes another hit to avoid overflow
                print("statement 3 passed")
                if (combat == COMBAT_PHYSICALDAMAGE) then
                print("physical damage")
                    local correct = value + (value * (config.more_dmg / 100))
                    doTargetCombatHealth(attacker, cid, combat, -correct, -correct, 255)
                else
                print("other damage")
                    local correct = value + (value * (config.more_dmg_spell / 100))
                    doTargetCombatHealth(attacker, cid, combat, -correct, -correct, 255)
                end
            else
                doPlayerSetStorageValue(cid, storage, -1)
            end
            print("end execution // return false")
            return false
        end
    end
    print("end execution // return true")
    return true
end

And the console says:

Code:
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
statement 1 passed
checking damage increase
statement 2 passed
end execution // return false
end execution // return false
 
Still doesn't work :(
I added this print thing:

Lua:
local config = {
    item_id = 2400, -- right or left hand
    more_dmg = 30, -- percent
    more_dmg_spell = 20, -- percent
    storage = 5011
}
local function checkDamageIncrease(cid)
    print("checking damage increase")
    local item = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
    if item and item.itemid == config.item_id then
        return true
    end
    item = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    if item and item.itemid == config.item_id then
        return true
    end
    return false
end
local storage = 815500 -- make sure stack overflow doesn't happen
function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(attacker) and getPlayerStorageValue(attacker, config.storage) == 1 then
     print("statement 1 passed")
        if (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and checkDamageIncrease(attacker) then
         print("statement 2 passed")
            if getPlayerStorageValue(cid, storage) == -1 then
                doPlayerSetStorageValue(cid, storage, 1) -- set storage value before the creature takes another hit to avoid overflow
                print("statement 3 passed")
                if (combat == COMBAT_PHYSICALDAMAGE) then
                print("physical damage")
                    local correct = value + (value * (config.more_dmg / 100))
                    doTargetCombatHealth(attacker, cid, combat, -correct, -correct, 255)
                else
                print("other damage")
                    local correct = value + (value * (config.more_dmg_spell / 100))
                    doTargetCombatHealth(attacker, cid, combat, -correct, -correct, 255)
                end
            else
                doPlayerSetStorageValue(cid, storage, -1)
            end
            print("end execution // return false")
            return false
        end
    end
    print("end execution // return true")
    return true
end

And the console says:

Code:
statement 1 passed
checking damage increase
statement 2 passed
statement 3 passed
physical damage
statement 1 passed
checking damage increase
statement 2 passed
end execution // return false
end execution // return false
that's exactly how it should look
maybe swap attacker and cid in doTargetCombatHealth i guess?
doTargetCombatHealth(cid, attacker instead of the other way around
that's the only spot where an error would occur, the rest executes fine, just the damage isn't being output for some reason
 
If I change doTargetCombatHealth(cid, attacker instead of the other way around, then the player which is attacking receives the dmg by otself but only the damage from the weapon like sword ,wand etc., spells does no dmg in any way.
 
Back
Top