icekis
Member
- Joined
- Jan 18, 2018
- Messages
- 91
- Reaction score
- 5
I use an OTX 3.9 engine and would like to change two situations when the player die.
When a player dies to monster, loses all blessings, even twist of fate
When a player dies for another player, he also loses all blessings, but he should lose only twist of fate.
Could anyone help me change the player die for monsters and keeps the twist of fate, and if die for player only lose the twist of fate?
I believe these changes are made in droploot.lua, so here is my droploot:
Thanks!
When a player dies to monster, loses all blessings, even twist of fate
When a player dies for another player, he also loses all blessings, but he should lose only twist of fate.
Could anyone help me change the player die for monsters and keeps the twist of fate, and if die for player only lose the twist of fate?
I believe these changes are made in droploot.lua, so here is my droploot:
Lua:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) then -- or player:getVocation():getId() == VOCATION_NONE
return true
end
-- This should prevent the player from droping items if he got twist of fate, even whitout any other blessings
local TWIST_OF_FATE = 6
if player:hasBlessing(TWIST_OF_FATE) and not table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
if killer:isPlayer() then
return true
else
local summonKiller = killer:getMaster()
if summonKiller and summonKiller:isPlayer() then
return true
end
end
end
local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
local isPlayer = false
if killer then
if killer:isPlayer() then
isPlayer = true
else
local master = killer:getMaster()
if master and master:isPlayer() then
isPlayer = true
end
end
end
if not isPlayer or not player:hasBlessing(6) then
player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
end
else
for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
local item = player:getSlotItem(i)
if item then
if table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) or math.random(item:isContainer() and 100 or 1000) <= player:getLossPercent() then
if not item:moveTo(corpse) then
item:remove()
end
end
end
end
end
if not player:getSlotItem(CONST_SLOT_BACKPACK) then
player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
end
return true
end
Thanks!