• 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...
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
You have the return false set incorrectly.
You want to return false the original damage only, not the second time too.
Move return false to line 33, just after that end.
 
Works prefect , thank you guys, especially you Static_ , all credits for you :D
Have you tested the script while the person receiving damage has mana shield active?
Just wondering if the script bypasses the shield and deals direct damage to their health.

Thanks in advance. :p
 
Back
Top