local config = {
amuletID = 15687,
storageKey = 100371
}
function onPrepareDeath(creature, killer)
local player = Player(creature)
if not player then
return true
end
local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
local storage = player:getStorageValue(config.storageKey)
if amulet and amulet:getId() == config.amuletID then
if storage <= 5 then
player:setDropLoot(false)
for i = 1, 5 do
player:addBlessing(i)
end
player:setStorageValue(config.storageKey, storage == -1 and 1 or storage + 1)
else
amulet:remove()
end
end
return true
end
It does work but you still lose experience. And after 5death it removes the amulet and you lose a lot even when you have a amulet on you, it should have removed the amulet and didnt removed the loot which is weird why it lost loot when there still was a amuletThis should work:
LUA:local config = { amuletID = 15687, storageKey = 100371 } function onPrepareDeath(creature, killer) local player = Player(creature) if not player then return true end local amulet = player:getSlotItem(CONST_SLOT_NECKLACE) local storage = player:getStorageValue(config.storageKey) if amulet and amulet:getId() == config.amuletID then if storage <= 5 then player:setDropLoot(false) for i = 1, 5 do player:addBlessing(i) end player:setStorageValue(config.storageKey, storage == -1 and 1 or storage + 1) else amulet:remove() end end return true end
I guess blessings only work up to a reduction of 40% (70% if promoted), if you want 100% xp reduction loss it requires a source edit.It does work but you still lose experience
local config = {
amuletID = 15687
}
function onPrepareDeath(creature, killer)
local player = Player(creature)
if not player then
return true
end
local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
local charges = item:getAttribute(ITEM_ATTRIBUTE_CHARGES) or 5
if amulet and amulet:getId() == config.amuletID then
if charges > 0 then
player:setDropLoot(false)
for i = 1, 5 do
player:addBlessing(i)
end
item:setAttribute(ITEM_ATTRIBUTES_CHARGES, charges - 1)
else
amulet:remove()
end
end
return true
end
So what happens by addingI guess blessings only work up to a reduction of 40% (70% if promoted), if you want 100% xp reduction loss it requires a source edit.
If you're willing to do a source edit and recompile, let me know.
Either way what I just realized what I gave you is bugged, the amulet will have to use charges:
LUA:local config = { amuletID = 15687 } function onPrepareDeath(creature, killer) local player = Player(creature) if not player then return true end local amulet = player:getSlotItem(CONST_SLOT_NECKLACE) local charges = item:getAttribute(ITEM_ATTRIBUTE_CHARGES) or 5 if amulet and amulet:getId() == config.amuletID then if charges > 0 then player:setDropLoot(false) for i = 1, 5 do player:addBlessing(i) end item:setAttribute(ITEM_ATTRIBUTES_CHARGES, charges - 1) else amulet:remove() end end return true end
Add charges="5" in items.xml as well and showcharges="1".
<attribute key="charges" value="5"/>
<attribute key="showcharges" value="1"/>

local config = {
amuletID = 15687,
LossExpPrecent= 85
}
Any ideas?So what happens by adding
isXML:<attribute key="charges" value="5"/> <attribute key="showcharges" value="1"/>
View attachment 38736
Actually i am down to do source editing its not a problem but it would be dope to have a function in local like
so it could be used in different codes either or could be helpful for a lot of people if its even possible to achieve something like thisLUA:local config = { amuletID = 15687, LossExpPrecent= 85 }
what you mean by onquip and ondeequip or onlogin, as far as i understand it would require extra codes then either or why quipt and dequip is needed when it can be done in creaturescript like nowEXPERIENCE_LOSS = 0 via SQL? on equip? and onDeequip or onlogin?
Its okay maybe someone with this version will come.sorry im thinking more of tfs 0.4i know there is differences
No this sounds really messy giving the same exp as he lose isnt it like over load for entire server, how it will react if a lot of people will die at the same time. Then you lose different exp with each level so its impossible so it sounds really not smart to do that.Why don't you use the exp loss formula as formula of exp the player gets +/- on death?
ondeath script -> give 5k exp
player dies loses 5k exp...
ofc 5k is a example, i would recommend to test it throughly as it may be mess up...
script gives exp -> higher total exp -> higher exp loss?
or just calculate the exp and save it as storage to give exp on login?( i do not think storage can save values as big as exp loss on high lvls....)
Animera
No this sounds really messy giving the same exp as he lose isnt it like over load for entire server, how it will react if a lot of people will die at the same time. Then you lose different exp with each level so its impossible so it sounds really not smart to do that.
local neck = player:getSlotItem(CONST_SLOT_NECKLACE)
local AOL = ITEMID
if neck then
if neck:getId() == AOL then
player:getExperience() * deathLossPercent
end
end