local chance = math.random(0, 100)
local chancePercent = 5
local healthDamageBonus = CreatureEvent("healthDamageBonus")
function healthDamageBonus.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if attacker and attacker:isPlayer() then
local berserkerWeapon = attacker:getSlotItem(CONST_SLOT_LEFT):getId() == 2400
local base = attacker:getVocation():getId()
if creature:isMonster() or creature:isPlayer() then
if origin == ORIGIN_MELEE then
if base == 4 and berserkerWeapon then
primaryDamage = primaryDamage * 1.1
end
elseif origin == ORIGIN_RANGED then
local spearmanWeapon = attacker:getSlotItem(CONST_SLOT_LEFT):getId() == 2389
local playerLevel = attacker:getLevel()
local playerDistance = attacker:getSkillLevel(SKILL_DISTANCE)
local condition = Condition(CONDITION_BLEEDING)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(10, 1000, -(playerLevel / playerDistance) * 25)
if base == 3 and spearmanWeapon then
if chance <= chancePercent then
primaryDamage = primaryDamage
creature:addCondition(condition)
end
end
end
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end
healthDamageBonus:register()
local manaDamageBonus = CreatureEvent("manaDamageBonus")
function manaDamageBonus.onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if attacker and attacker:isPlayer() then
local berserkerWeapon = attacker:getSlotItem(CONST_SLOT_LEFT):getId() == 2400
local base = attacker:getVocation():getId()
if creature:isPlayer() then
if origin == ORIGIN_MELEE then
if base == 4 and berserkerWeapon then
primaryDamage = primaryDamage * 1.1
end
elseif origin == ORIGIN_RANGED then
local spearmanWeapon = attacker:getSlotItem(CONST_SLOT_LEFT):getId() == 2389
local playerLevel = attacker:getLevel()
local playerDistance = attacker:getSkillLevel(SKILL_DISTANCE)
local condition = Condition(CONDITION_BLEEDING)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(10, ((playerLevel / playerDistance) * 25), -1)
if base == 3 and spearmanWeapon then
if chance <= chancePercent then
primaryDamage = primaryDamage
creature:addCondition(condition)
end
end
end
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end
manaDamageBonus:register()
local creatureEvent = CreatureEvent("loginBonus")
function creatureEvent.onLogin(player)
player:registerEvent("healthDamageBonus")
player:registerEvent("manaDamageBonus")
return true
end
creatureEvent:register()
local ec = EventCallback
function ec.onSpawn(monster, position, startup, artificial)
monster:registerEvent("healthDamageBonus")
return true
end
ec:register(-666)