Advertisement
Guest User

onHealthChange

a guest
Jul 23rd, 2023
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.16 KB | Gaming | 0 0
  1. local bonus_transform_dmg_absorb={
  2.     [1]= {mele_dmg_absorb= 0, ene_dmg_absorb= 0, atk_mele_dmg = 0 , atk_ki_dmg = 0},
  3.     [2]= {mele_dmg_absorb= 4, ene_dmg_absorb= 4, atk_mele_dmg = 2, atk_ki_dmg = 2},
  4.     [3]= {mele_dmg_absorb= 6, ene_dmg_absorb= 6, atk_mele_dmg = 4, atk_ki_dmg = 4},
  5.     [4]= {mele_dmg_absorb= 8, ene_dmg_absorb= 8, atk_mele_dmg = 6, atk_ki_dmg = 6},
  6.     [5]= {mele_dmg_absorb= 10, ene_dmg_absorb= 10, atk_mele_dmg = 8, atk_ki_dmg = 8},
  7.     [6]= {mele_dmg_absorb= 12, ene_dmg_absorb= 12, atk_mele_dmg = 99, atk_ki_dmg = 99},
  8. }
  9.  
  10. local function modifyDamage(attacker, primaryDamage, primaryType)
  11.     if not attacker then
  12.         return primaryDamage, primaryType
  13.     end
  14.  
  15.     local Vocation = attacker:isPlayer() and attacker:getVocation():getId()
  16.     local bonus_data = bonus_transform_dmg_absorb[Vocation]
  17.  
  18.     if attacker:isPlayer() then
  19.     if primaryType == COMBAT_PHYSICALDAMAGE then
  20.         local atk_mele = primaryDamage
  21.         local dmgmelebonus = atk_mele * (bonus_data.atk_mele_dmg / 100)
  22.         primaryDamage = atk_mele + dmgmelebonus
  23.         print("wartosc  atk_mele razy procenty:" .. dmgmelebonus)
  24.             print("wartosc atk_mele wczesniej:" .. atk_mele)
  25.             print("wartosc atk_mele suma:" .. primaryDamage)
  26.    
  27.     elseif primaryType == COMBAT_DROWNDAMAGE then
  28.         local atk_ene = primaryDamage
  29.         local dmgenebonus = atk_ene * (bonus_data.atk_ki_dmg / 100)
  30.         primaryDamage = atk_ene + dmgenebonus
  31.         print("wartosc  atk_eneKI razy procenty:" .. dmgenebonus)
  32.             print("wartosc atk_eneKI wczesniej:" .. atk_ene)
  33.             print("wartosc atk_eneKI suma:" .. primaryDamage)
  34.            
  35.     end
  36. end
  37.     return primaryDamage, primaryType
  38. end
  39.  
  40.     local cEvent = CreatureEvent("HpChange")
  41. function cEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
  42.     if attacker then
  43.         local playerId = attacker:getId()
  44.        
  45.         primaryDamage, primaryType = modifyDamage(attacker, primaryDamage, primaryType)
  46.    
  47.         local totalDamage = primaryDamage
  48.         local getVocationId = creature:getVocation():getId()
  49.         local bonus_data = bonus_transform_dmg_absorb[getVocationId]
  50.        
  51.         --absorb mele z transformacji i z skilli
  52.         if primaryType == COMBAT_PHYSICALDAMAGE then
  53.             local meledmg = totalDamage
  54.             if creature:getSkillLevel(5) <= 130 then
  55.                 creature:addSkillTries(5, 1)
  56.             end
  57.             if creature:getStorageValue(9998) == -1 or creature:getStorageValue(9998) == nil then
  58.                 creature:setStorageValue(9998,2)
  59.             end
  60.                 local procentdefabsorbu = creature:getSkillLevel(5)/5
  61.                 print("wartosc def skill/5:" .. procentdefabsorbu)
  62.                 print("wartosc procentowa absorbu mele z transformacji:" .. bonus_data.mele_dmg_absorb)
  63.                 local transform_and_def_absorb_bonus = procentdefabsorbu + bonus_data.mele_dmg_absorb
  64.                 print("wartosc procentowa bonusu absorb mele z transformacji dodana do z skilla, czyli suma procentowa absorb:" .. transform_and_def_absorb_bonus)
  65.             if creature:getStorageValue(9998) ~= transform_and_def_absorb_bonus then
  66.  
  67.                 creature:setStorageValue(9998, transform_and_def_absorb_bonus)
  68.             end
  69.                 print("wartosc procentowa absorb z storage:" .. creature:getStorageValue(9998))
  70.                 print("wartosc ataku mele przed obliczeniami:" .. primaryDamage)
  71.                 local absorbdefValue = creature:getStorageValue(9998)
  72.                 local damagedefReduction = meledmg * (absorbdefValue / 100)
  73.                 primaryDamage = meledmg - damagedefReduction
  74.                 secondaryDamage = meledmg - damagedefReduction
  75.                 print("wartosc ataku mele po obnizeniu o absorb def:" .. primaryDamage)
  76.        
  77.                 --absorb ki i balla z transformacji i skilli
  78.         elseif primaryType == COMBAT_DROWNDAMAGE then
  79.             local kidmg = totalDamage
  80.             if creature:getSkillLevel(7) <= 130 then
  81.                 creature:addSkillTries(7, 1)
  82.             end
  83.              
  84.             if creature:getStorageValue(9999) == -1 or creature:getStorageValue(9999) == nil then
  85.                 creature:setStorageValue(9999,2)
  86.             end
  87.             local procentabsorbu=creature:getSkillLevel(7)/5
  88.             print("wartosc ene skill/5:" .. procentabsorbu)
  89.             print("wartosc procentowa absorbu ene z transformacji:" .. bonus_data.ene_dmg_absorb)
  90.             local transform_and_ene_absorb_bonus = procentabsorbu + bonus_data.ene_dmg_absorb
  91.             print("wartosc procentowa bonusu absorb ene z transformacji dodana do z skilla, czyli suma procentowa absorb:" .. transform_and_ene_absorb_bonus)
  92.             if creature:getStorageValue(9999) ~= transform_and_ene_absorb_bonus then
  93.                 creature:setStorageValue(9999,transform_and_ene_absorb_bonus)  
  94.             end
  95.             print("wartosc procentowa absorb z storage:" .. creature:getStorageValue(9999))
  96.             print("wartosc ataku ene przed obliczeniami:" .. primaryDamage)
  97.             local absorbValue = creature:getStorageValue(9999)
  98.             local damageReduction = kidmg * (absorbValue / 100)
  99.             primaryDamage = kidmg - damageReduction
  100.             secondaryDamage = kidmg - damageReduction
  101.             print("wartosc ataku ki po obnizeniu o absorb ene:" .. primaryDamage)
  102.        
  103.         end
  104.     end
  105.     return primaryDamage, primaryType, secondaryDamage, secondaryType, origin  
  106. end
  107.  
  108. cEvent:register()
  109.  
  110. local lEvent = CreatureEvent("HpLogin")
  111.  
  112. function lEvent.onLogin(player)
  113.     player:registerEvent("HpChange")
  114.  
  115.     return true
  116. end
  117.  
  118. lEvent:register()
  119.  
  120.  
Tags: tfs1.5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement