Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local bonus_transform_dmg_absorb={
- [1]= {mele_dmg_absorb= 0, ene_dmg_absorb= 0, atk_mele_dmg = 0 , atk_ki_dmg = 0},
- [2]= {mele_dmg_absorb= 4, ene_dmg_absorb= 4, atk_mele_dmg = 2, atk_ki_dmg = 2},
- [3]= {mele_dmg_absorb= 6, ene_dmg_absorb= 6, atk_mele_dmg = 4, atk_ki_dmg = 4},
- [4]= {mele_dmg_absorb= 8, ene_dmg_absorb= 8, atk_mele_dmg = 6, atk_ki_dmg = 6},
- [5]= {mele_dmg_absorb= 10, ene_dmg_absorb= 10, atk_mele_dmg = 8, atk_ki_dmg = 8},
- [6]= {mele_dmg_absorb= 12, ene_dmg_absorb= 12, atk_mele_dmg = 99, atk_ki_dmg = 99},
- }
- local function modifyDamage(attacker, primaryDamage, primaryType)
- if not attacker then
- return primaryDamage, primaryType
- end
- local Vocation = attacker:isPlayer() and attacker:getVocation():getId()
- local bonus_data = bonus_transform_dmg_absorb[Vocation]
- if attacker:isPlayer() then
- if primaryType == COMBAT_PHYSICALDAMAGE then
- local atk_mele = primaryDamage
- local dmgmelebonus = atk_mele * (bonus_data.atk_mele_dmg / 100)
- primaryDamage = atk_mele + dmgmelebonus
- print("wartosc atk_mele razy procenty:" .. dmgmelebonus)
- print("wartosc atk_mele wczesniej:" .. atk_mele)
- print("wartosc atk_mele suma:" .. primaryDamage)
- elseif primaryType == COMBAT_DROWNDAMAGE then
- local atk_ene = primaryDamage
- local dmgenebonus = atk_ene * (bonus_data.atk_ki_dmg / 100)
- primaryDamage = atk_ene + dmgenebonus
- print("wartosc atk_eneKI razy procenty:" .. dmgenebonus)
- print("wartosc atk_eneKI wczesniej:" .. atk_ene)
- print("wartosc atk_eneKI suma:" .. primaryDamage)
- end
- end
- return primaryDamage, primaryType
- end
- local cEvent = CreatureEvent("HpChange")
- function cEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
- if attacker then
- local playerId = attacker:getId()
- primaryDamage, primaryType = modifyDamage(attacker, primaryDamage, primaryType)
- local totalDamage = primaryDamage
- local getVocationId = creature:getVocation():getId()
- local bonus_data = bonus_transform_dmg_absorb[getVocationId]
- --absorb mele z transformacji i z skilli
- if primaryType == COMBAT_PHYSICALDAMAGE then
- local meledmg = totalDamage
- if creature:getSkillLevel(5) <= 130 then
- creature:addSkillTries(5, 1)
- end
- if creature:getStorageValue(9998) == -1 or creature:getStorageValue(9998) == nil then
- creature:setStorageValue(9998,2)
- end
- local procentdefabsorbu = creature:getSkillLevel(5)/5
- print("wartosc def skill/5:" .. procentdefabsorbu)
- print("wartosc procentowa absorbu mele z transformacji:" .. bonus_data.mele_dmg_absorb)
- local transform_and_def_absorb_bonus = procentdefabsorbu + bonus_data.mele_dmg_absorb
- print("wartosc procentowa bonusu absorb mele z transformacji dodana do z skilla, czyli suma procentowa absorb:" .. transform_and_def_absorb_bonus)
- if creature:getStorageValue(9998) ~= transform_and_def_absorb_bonus then
- creature:setStorageValue(9998, transform_and_def_absorb_bonus)
- end
- print("wartosc procentowa absorb z storage:" .. creature:getStorageValue(9998))
- print("wartosc ataku mele przed obliczeniami:" .. primaryDamage)
- local absorbdefValue = creature:getStorageValue(9998)
- local damagedefReduction = meledmg * (absorbdefValue / 100)
- primaryDamage = meledmg - damagedefReduction
- secondaryDamage = meledmg - damagedefReduction
- print("wartosc ataku mele po obnizeniu o absorb def:" .. primaryDamage)
- --absorb ki i balla z transformacji i skilli
- elseif primaryType == COMBAT_DROWNDAMAGE then
- local kidmg = totalDamage
- if creature:getSkillLevel(7) <= 130 then
- creature:addSkillTries(7, 1)
- end
- if creature:getStorageValue(9999) == -1 or creature:getStorageValue(9999) == nil then
- creature:setStorageValue(9999,2)
- end
- local procentabsorbu=creature:getSkillLevel(7)/5
- print("wartosc ene skill/5:" .. procentabsorbu)
- print("wartosc procentowa absorbu ene z transformacji:" .. bonus_data.ene_dmg_absorb)
- local transform_and_ene_absorb_bonus = procentabsorbu + bonus_data.ene_dmg_absorb
- print("wartosc procentowa bonusu absorb ene z transformacji dodana do z skilla, czyli suma procentowa absorb:" .. transform_and_ene_absorb_bonus)
- if creature:getStorageValue(9999) ~= transform_and_ene_absorb_bonus then
- creature:setStorageValue(9999,transform_and_ene_absorb_bonus)
- end
- print("wartosc procentowa absorb z storage:" .. creature:getStorageValue(9999))
- print("wartosc ataku ene przed obliczeniami:" .. primaryDamage)
- local absorbValue = creature:getStorageValue(9999)
- local damageReduction = kidmg * (absorbValue / 100)
- primaryDamage = kidmg - damageReduction
- secondaryDamage = kidmg - damageReduction
- print("wartosc ataku ki po obnizeniu o absorb ene:" .. primaryDamage)
- end
- end
- return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
- end
- cEvent:register()
- local lEvent = CreatureEvent("HpLogin")
- function lEvent.onLogin(player)
- player:registerEvent("HpChange")
- return true
- end
- lEvent:register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement