<commit_before>-- Player death
-- deadPlayer - The player (character) whose hitpoints have just been set to zero

require("base.common")
module("server.playerdeath", package.seeall)

function playerDeath(deadPlayer)

    world:makeSound(25,deadPlayer.pos);
    showDeathDialog(deadPlayer);
	
    --vilarion: Please insert the death consequences here.
	
end

function showDeathDialog(deadPlayer)

	local callback = function(nothing) end; --empty callback
		
	if deadPlayer:getPlayerLanguage() == 0 then		
		dialog = MessageDialog("Tod", "Du bist gestorben. Die Welt um dich herum verblasst und du bereitest dich darauf vor, den Gttern in Chergas Reich der Toten gegenberzutreten.", callback);
	else		<commit_msg>Reduce item durability upon player death<commit_after>-- Player death
-- deadPlayer - The player (character) whose hitpoints have just been set to zero

require("base.common")
module("server.playerdeath", package.seeall)

DURABILITY_LOSS = 10
BLOCKED_ITEM = 228

function playerDeath(deadPlayer)
    for i=Character.head,Character.coat do
        local item = deadPlayer:getItemAt(i)
        local common = world:getItemStats(item)

        if item.id > 0 and item.id ~= BLOCKEDITEM and item.quality > 100 and not common.isStackable then
            local durability = item.quality % 100

            if durability <= DURABILITY_LOSS then
                deadPlayer:increaseAtPos(i, -1)
            else
                item.quality = item.quality - DURABILITY_LOSS
                world:changeItem(item)
            end
        end
    end

    world:makeSound(25,deadPlayer.pos);
    showDeathDialog(deadPlayer);
end

function showDeathDialog(deadPlayer)

	local callback = function(nothing) end; --empty callback
		
	if deadPlayer:getPlayerLanguage() == 0 then		
		dialog = MessageDialog("Tod", "Du bist gestorben. Die Welt um dich herum verblasst und du bereitest dich darauf vor, den Gttern in Chergas Reich der Toten gegenberzutreten.", callback);
	else		
{'fraction_non_alphanumeric': 0.08164300202839757, 'fraction_numerical': 0.009634888438133874, 'mean_word_length': 3.5045662100456623, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5966218', 'n_tokens_mistral': 607, 'n_tokens_neox': 556, 'n_words': 180}