Apoccalypse
New Member
- Joined
- Apr 15, 2017
- Messages
- 114
- Solutions
- 2
- Reaction score
- 4
Hello guys,
Thanks to Static_ and Xikini it was finally possible to create the script which increase damge dealt by the item at tfs 0.3.6.
I wanted to make it work for x declared items ,not only for one, so I was trying to create a table.
Unfortunately it des not work but I am sure that the mistake is here:
t.up[getItemById]- this line is bad declared ,so script can not work ,because item can not be found.
If anyone would help me to solve it that would be great
Thanks to Static_ and Xikini it was finally possible to create the script which increase damge dealt by the item at tfs 0.3.6.
I wanted to make it work for x declared items ,not only for one, so I was trying to create a table.
Lua:
local config = {
item_id = 2518, -- right or left hand
more_dmg = 7, -- percent
more_dmg_spell = 7, -- percent
storage = 5011
}
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)
local correct = value * 2 + ((value * 2) * config.more_dmg/100)
local correct2 = value * 2 + ((value * 2) * config.more_dmg_spell/100)
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
return false,
doTargetCombatHealth(attacker, cid, combat, -correct, -correct, 255)
else
return false,
doTargetCombatHealth(attacker, cid, combat, -correct2, -correct2, 255)
end
else
doPlayerSetStorageValue(cid, storage, -1)
end
end
end
return true
end
Lua:
local t = {
storage = 5011,
up = {
[2518] = {more_dmg = 7, more_dmg_spell = 5},
[9778] = {more_dmg = 4, more_dmg_spell = 3}}
}
local function checkDamageIncrease(cid)
local item = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
if item and item.itemid == t.up[getItemById] then
return true
end
item = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
if item and item.itemid == t.up[getItemById] then
return true
end
return false
end
local storage = 815500 -- make sure stack overflow doesn't happen
function onStatsChange(cid, attacker, type, combat, value)
local k = t.up[getItemById]
local correct = value * 2 + ((value * 2) * k.more_dmg/100)
local correct2 = value * 2 + ((value * 2) * k.more_dmg_spell/100)
if isPlayer(attacker) and getPlayerStorageValue(attacker, t.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
return false,
doTargetCombatHealth(attacker, cid, combat, -correct, -correct, 255)
else
return false,
doTargetCombatHealth(attacker, cid, combat, -correct2, -correct2, 255)
end
else
doPlayerSetStorageValue(cid, storage, -1)
end
end
end
return true
end
Unfortunately it des not work but I am sure that the mistake is here:
Lua:
if item and item.itemid == t.up[getItemById] then
t.up[getItemById]- this line is bad declared ,so script can not work ,because item can not be found.
If anyone would help me to solve it that would be great