• 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!

Make EQ increase all damage dealt

Heroid

Active Member
Joined
Mar 7, 2011
Messages
332
Solutions
11
Reaction score
34
How can I make an item increase all damage dealt by % when equipped? (Both weapon damage and spell damage)
 
Lua:
function onStatsChange(cid, attacker, type, combat, value)
   local config = {
       item_id = 2222, -- right or left hand
       more_dmg = 20, -- percent
       more_dmg_spell = 20 -- percent
   }
   
   if isPlayer(cid) 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:
function onStatsChange(cid, attacker, type, combat, value)
   local config = {
       item_id = 2222, -- right or left hand
       more_dmg = 20, -- percent
       more_dmg_spell = 20 -- percent
   }
 
   if isPlayer(cid) 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
have fun with stack overflow
use a storage value to return true since the event will execute after it gets called again due to doTargetCombatHealth
if you don't stop it you'll get a stack overflow
 
I am very intrested in the script too.
I used a storage value and the stack overflow is gone.
function onStatsChange(cid, attacker, type, combat, value)
local config = {
item_id = 2400, -- right or left hand
more_dmg = 75, -- percent
more_dmg_spell = 75 -- percent
local storage = 815869 --the storage value used
}

if isPlayer(cid) 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
if getPlayerStorageValue(target,storage) ~= 1 then
return true,
setPlayerStorageValue(target,storage,1),
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
end

<event type="statschange" name="MoreDMG" event="script" value="MoreDMG.lua"/>
registerCreatureEvent(cid, "MoreDMG")

I know that i should place a line " setPlayerStorageValue(target,storage,0)" when an item is unequiped but I don't know how to put it in into the script.
Unfortunately the script itself isn't working for me. I don't get any errors.
I am using theforgottenserver tfs 0.4 client 8.6.
If anyone could take a look at it that would be great :)
 
I am very intrested in the script too.
I used a storage value and the stack overflow is gone.
function onStatsChange(cid, attacker, type, combat, value)
local config = {
item_id = 2400, -- right or left hand
more_dmg = 75, -- percent
more_dmg_spell = 75 -- percent
local storage = 815869 --the storage value used
}

if isPlayer(cid) 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
if getPlayerStorageValue(target,storage) ~= 1 then
return true,
setPlayerStorageValue(target,storage,1),
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
end

<event type="statschange" name="MoreDMG" event="script" value="MoreDMG.lua"/>
registerCreatureEvent(cid, "MoreDMG")

I know that i should place a line " setPlayerStorageValue(target,storage,0)" when an item is unequiped but I don't know how to put it in into the script.
Unfortunately the script itself isn't working for me. I don't get any errors.
I am using theforgottenserver tfs 0.4 client 8.6.
If anyone could take a look at it that would be great :)
onEquip / onDeEquip in movments handles equipment (the slots you equip things to even arrow slot) you can set the storage value there.
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

HTML:
<movevent event="Equip" itemid="itemid of item" slot=" slot name of item" script="path to script" />
<movevent event="DeEquip" itemid="itemid of item" slot=" slot name of item" script="path to script" />
 
The storage value is no more the problem thanks to you.
Although the script is no working for me.
  1. function onStatsChange(cid, attacker, type, combat, value)
  2. local config = {
  3. item_id = 2222, -- right or left hand
  4. more_dmg = 20, -- percent
  5. more_dmg_spell = 20 -- percent
  6. }
  7. if isPlayer(cid) then
  8. 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
  9. if(combat == COMBAT_PHYSICALDAMAGE) then
  10. local correct = value + (value * config.more_dmg)
  11. doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
  12. else
  13. local correct = value + (value * config.more_dmg_spell)
  14. doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
  15. end
  16. return false
  17. end
  18. end
  19. end

The help would be very appreciated to make it working at theforgottenserver tfs 0.3.6 :)
 
Last edited:
Back
Top