Advertisement
Guest User

onHealthChangeandSkills

a guest
Aug 15th, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.97 KB | Gaming | 0 0
  1. -- WAZNE rejstracja skryptu w onSpawn w creature scripts WAZNE!!!!!
  2. --[[
  3.     []= {mele_dmg_absorb= , ene_dmg_absorb= , atk_ki_dmg = , atk_ki_dmg = },
  4.     []= {mele_dmg_absorb= , ene_dmg_absorb= ,}
  5.     []= {mele_dmg_absorb= , ene_dmg_absorb= ,}
  6.     []= {mele_dmg_absorb= , ene_dmg_absorb= ,}
  7.     []= {mele_dmg_absorb= , ene_dmg_absorb= ,}
  8.     []= {mele_dmg_absorb= , ene_dmg_absorb= ,}
  9. --]]
  10. local bonus_transform_dmg_absorb={
  11.     [1]= {mele_dmg_absorb= 0, ene_dmg_absorb= 0, atk_mele_dmg = 0 , atk_ki_dmg = 0},
  12.     [2]= {mele_dmg_absorb= 4, ene_dmg_absorb= 4, atk_mele_dmg = 2, atk_ki_dmg = 2},
  13.     [3]= {mele_dmg_absorb= 6, ene_dmg_absorb= 6, atk_mele_dmg = 4, atk_ki_dmg = 4},
  14.     [4]= {mele_dmg_absorb= 8, ene_dmg_absorb= 8, atk_mele_dmg = 6, atk_ki_dmg = 6},
  15.     [5]= {mele_dmg_absorb= 10, ene_dmg_absorb= 10, atk_mele_dmg = 8, atk_ki_dmg = 8},
  16.     [6]= {mele_dmg_absorb= 12, ene_dmg_absorb= 12, atk_mele_dmg = 12, atk_ki_dmg = 12},
  17. }
  18.  
  19. local function modifyDamage(attacker, primaryDamage, primaryType, cid, item, fromPosition, itemEx, toPosition, ItemType)
  20.     if not attacker then
  21.         return primaryDamage, primaryType
  22.     end
  23.  
  24.     local Vocation = attacker:isPlayer() and attacker:getVocation():getId()
  25.     local bonus_data = bonus_transform_dmg_absorb[Vocation]
  26.    
  27.     if attacker and attacker:isPlayer() then
  28.     if primaryType == COMBAT_PHYSICALDAMAGE then
  29.         local atk_mele = primaryDamage
  30.         local dmgmelebonus = atk_mele * (bonus_data.atk_mele_dmg / 100)
  31.         primaryDamage = atk_mele + dmgmelebonus
  32.         print("wartosc  atk_mele razy procenty:" .. dmgmelebonus)
  33.             print("wartosc atk_mele wczesniej:" .. atk_mele)
  34.             print("wartosc atk_mele suma:" .. primaryDamage)
  35.            
  36.                
  37.                
  38. ---======================================================================================-------------------
  39. ---===================SYSTEM , PUNCH, SLASH========================================--------------------
  40. --==========================================================================================
  41. local LVLSKILL = 0
  42. local CHANCE = 0
  43.  
  44. local WEAPON = attacker:getWeaponType()
  45. local DMGMULTIPLIER = 1.25
  46. print(WEAPON)
  47.                
  48.                     ---WEPON TYPE  CHYBA ,9 WEAPON_GLOVER ,10WEAPON_KI_BLASTING,11WEAPON_MIECZ
  49.                     if WEAPON == 9 then --Glover
  50.                         LVLSKILL = attacker:getSkillLevel(SKILL_SILA) --- 11 sKILL STRENGHT
  51.                     elseif WEAPON == 11 then --MIECZ
  52.                         LVLSKILL = attacker:getSkillLevel(SKILL_MIECZ) ---12 SKILL SWORD FIGHTING
  53.                     elseif WEAPON == 0 then --REKA
  54.                         LVLSKILL = attacker:getSkillLevel(SKILL_SILA)---
  55.                     end
  56.            
  57.                     print(LVLSKILL)
  58.                 if LVLSKILL >= 10 and LVLSKILL < 110 then
  59.                     CHANCE = 100
  60.                 elseif LVLSKILL >= 110 and LVLSKILL < 120 then
  61.                     CHANCE = 15
  62.                 elseif LVLSKILL >= 120 and LVLSKILL < 130 then
  63.                     CHANCE = 20
  64.                 elseif LVLSKILL >= 130 then
  65.                     CHANCE = 25
  66.                 end
  67.                
  68.                 if math.random(100) <= CHANCE then
  69.                     primaryDamage = primaryDamage * DMGMULTIPLIER
  70.  
  71.                     print("wartosc atk_mele po critic sytemie suma:" .. primaryDamage)
  72.                     if WEAPON == 9 then
  73.                        
  74.                        
  75.                         ---------------------------------------
  76.                         ---???????????????????????????????????---
  77.                     --?????LOAD ATTACK ATTRIBUTE ITEM???????????---
  78.                     --???????????????????????????????????????????--
  79.                     ---------------------------------------
  80.                        
  81.                        
  82.                        
  83.                        
  84.                         if attackAttribute >= 10 then
  85.                             attacker:addSkillTries(9, 1)
  86.                             if attackAttribute >= 20 then
  87.                                 attacker:addSkillTries(9, 1)
  88.                                 if attackAttribute >= 30 then
  89.                                     attacker:addSkillTries(9, 1)
  90.                                     if attackAttribute >= 40 then
  91.                                         attacker:addSkillTries(9, 1)
  92.                                         if attackAttribute >= 50 then
  93.                                             attacker:addSkillTries(9, 1)
  94.                                             if attackAttribute >= 60 then
  95.                                                 attacker:addSkillTries(9, 1)
  96.                                                 if attackAttribute >= 70 then
  97.                                                     attacker:addSkillTries(9, 1)
  98.                                                     if attackAttribute >= 80 then
  99.                                                         attacker:addSkillTries(9, 1)
  100.                                                         if attackAttribute >= 90 then
  101.                                                             attacker:addSkillTries(9, 1)
  102.                                                         end
  103.                                                     end
  104.                                                 end
  105.                                             end
  106.                                         end
  107.                                     end
  108.                                 end
  109.                             end
  110.                         end
  111.                    
  112.                             attacker:say("Punch!")
  113.                     elseif WEAPON == 11 then
  114.                         attacker:say("Slash!")
  115.                     elseif WEAPON == 0  then
  116.                         attacker:say("Punch!")
  117.                     end
  118.                 end
  119.  
  120.            
  121. ---======================================================================================-------------------           
  122. ---======================KONIEC SYTSTEMU===================================================-------------------
  123. ---======================================================================================-------------------
  124.     elseif primaryType == COMBAT_DROWNDAMAGE then
  125.         local atk_ene = primaryDamage
  126.         local dmgenebonus = atk_ene * (bonus_data.atk_ki_dmg / 100)
  127.         primaryDamage = atk_ene + dmgenebonus
  128.         print("wartosc  atk_eneKI razy procenty:" .. dmgenebonus)
  129.             print("wartosc atk_eneKI wczesniej:" .. atk_ene)
  130.             print("wartosc atk_eneKI suma:" .. primaryDamage)
  131.  
  132. ---======================================================================================-------------------           
  133. ---======================kod SYTSTEMU STRIKE===================================================-------------------
  134. ---======================================================================================-------------------
  135.     local LVLS = 0
  136.     local CHNSE = 0
  137.     local WEAPONE = attacker:getWeaponType()
  138.     local DMGMULTIPLIERY = 1.25
  139.     print(WEAPON)
  140.  
  141.             if WEAPONE == 10 then --ball
  142.                 LVLS = attacker:getSkillLevel(SKILL_KI_BLASTING)
  143.             end
  144.             if LVLS >= 10 and LVLS < 110 then
  145.                 CHNSE = 100
  146.             elseif LVLS >= 110 and LVLS < 120 then
  147.                 CHNSE = 15
  148.             elseif LVLS >= 120 and LVLS < 130 then
  149.                 CHNSE = 20
  150.             elseif LVLS >= 130 then
  151.                 CHNSE = 25
  152.             end
  153.             if math.random(100) <= CHNSE then
  154.                 primaryDamage = primaryDamage * DMGMULTIPLIERY
  155.  
  156.                 print("wartosc atk_ki po critic sytemie suma:" .. primaryDamage)
  157.                 if WEAPONE == 10 then
  158.                     attacker:say("Strike!")
  159.                
  160.                 end
  161.             end
  162.             ---======================================================================================-------------------           
  163. ---======================KONIEC SYTSTEMU===================================================-------------------
  164. ---======================================================================================-------------------
  165.     end
  166. end
  167.     return primaryDamage, primaryType
  168. end
  169. -- WAZNE rejstracja skryptu w onSpawn w creature scripts WAZNE!!!!!
  170.     local cEvent = CreatureEvent("HpChange")
  171. function cEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
  172.     if attacker then
  173.         local playerId = attacker:getId()
  174.        
  175.         primaryDamage, primaryType = modifyDamage(attacker, primaryDamage, primaryType)
  176.         if creature and creature:isPlayer() then
  177.         local totalDamage = primaryDamage
  178.         local getVocationId = creature:getVocation():getId()
  179.         local bonus_data = bonus_transform_dmg_absorb[getVocationId]
  180.        
  181.         --absorb mele z transformacji i z skilli
  182.         if primaryType == COMBAT_PHYSICALDAMAGE then
  183.             local meledmg = totalDamage
  184.             if creature:getSkillLevel(8) <= 130 then --- 8 oznzcza skill defence
  185.                 creature:addSkillTries(8, 1)  --- 8 oznzcza skill defence
  186.             end
  187.             if creature:getStorageValue(9998) == -1 or creature:getStorageValue(9998) == nil then
  188.                 creature:setStorageValue(9998,2)
  189.             end
  190.                 local procentdefabsorbu = creature:getSkillLevel(8)/5
  191.                 print("wartosc def skill/5:" .. procentdefabsorbu)
  192.                 print("wartosc procentowa absorbu mele z transformacji:" .. bonus_data.mele_dmg_absorb)
  193.                 local transform_and_def_absorb_bonus = procentdefabsorbu + bonus_data.mele_dmg_absorb
  194.                 print("wartosc procentowa bonusu absorb mele z transformacji dodana do z skilla, czyli suma procentowa absorb:" .. transform_and_def_absorb_bonus)
  195.             if creature:getStorageValue(9998) ~= transform_and_def_absorb_bonus then
  196.  
  197.                 creature:setStorageValue(9998, transform_and_def_absorb_bonus)
  198.             end
  199.                 print("wartosc procentowa absorb z storage:" .. creature:getStorageValue(9998))
  200.                 print("wartosc ataku mele przed obliczeniami:" .. primaryDamage)
  201.                 local absorbdefValue = creature:getStorageValue(9998)
  202.                 local damagedefReduction = meledmg * (absorbdefValue / 100)
  203.                 primaryDamage = meledmg - damagedefReduction
  204.                 secondaryDamage = meledmg - damagedefReduction
  205.                 print("wartosc ataku mele po obnizeniu o absorb def:" .. primaryDamage)
  206.                
  207.  
  208. --------------------------------------------------------------------------------------------------------------------
  209.                 ---SYSTEM DODGE NA OBRAZENIA MELE---------
  210. ---------------------------------------------------------------------------------------------------------------------
  211.  
  212.                 local skillLevel = creature:getSkillLevel(8)
  213.                 local dodgechance = 0
  214.                 if skillLevel >= 10 and skillLevel < 110 then  
  215.                         dodgechance = 100
  216.                     elseif skillLevel >= 110 and skillLevel < 120 then
  217.                         dodgechance = 15
  218.                     elseif skillLevel >= 120 and skillLevel < 130 then
  219.                         dodgechance = 20
  220.                     elseif skillLevel >= 130 then
  221.                         dodgechance = 25
  222.                 end
  223.                 -- Wylosuj czy unik występuje
  224.                 if math.random(100) <= dodgechance then
  225.                     creature:say("Dodge!") -- Wyświetl komunikat
  226.                     primaryDamage = 0 -- Ustaw obrażenia na 0
  227.                     secondaryDamage = 0
  228.                 end
  229. ---------------------------------------------------------------------------------------------------------------------
  230. ---------------------------------------------------------------------------------------------------------------------
  231.  
  232.  
  233.  
  234.                 --absorb ki i balla z transformacji i skilli
  235.         elseif primaryType == COMBAT_DROWNDAMAGE then
  236.             local kidmg = totalDamage
  237.             if creature:getSkillLevel(7) <= 130 then --- 7 oznzcza skill energy
  238.                 creature:addSkillTries(7, 1)
  239.             end
  240.              
  241.             if creature:getStorageValue(9999) == -1 or creature:getStorageValue(9999) == nil then
  242.                 creature:setStorageValue(9999,2)
  243.             end
  244.             local procentabsorbu=creature:getSkillLevel(7)/5
  245.             print("wartosc ene skill/5:" .. procentabsorbu)
  246.             print("wartosc procentowa absorbu ene z transformacji:" .. bonus_data.ene_dmg_absorb)
  247.             local transform_and_ene_absorb_bonus = procentabsorbu + bonus_data.ene_dmg_absorb
  248.             print("wartosc procentowa bonusu absorb ene z transformacji dodana do z skilla, czyli suma procentowa absorb:" .. transform_and_ene_absorb_bonus)
  249.             if creature:getStorageValue(9999) ~= transform_and_ene_absorb_bonus then
  250.                 creature:setStorageValue(9999,transform_and_ene_absorb_bonus)  
  251.             end
  252.             print("wartosc procentowa absorb z storage:" .. creature:getStorageValue(9999))
  253.             print("wartosc ataku ene przed obliczeniami:" .. primaryDamage)
  254.             local absorbValue = creature:getStorageValue(9999)
  255.             local damageReduction = kidmg * (absorbValue / 100)
  256.             primaryDamage = kidmg - damageReduction
  257.             secondaryDamage = kidmg - damageReduction
  258.             print("wartosc ataku ki po obnizeniu o absorb ene:" .. primaryDamage)
  259.  
  260.  
  261.  
  262. --------------------------------------------------------------------------------------------------------------------
  263.                 ---SYSTEM MISS NA OBRAZENIA KI---------
  264. ---------------------------------------------------------------------------------------------------------------------
  265.  
  266.             local skillLevel = creature:getSkillLevel(7) ----Skill 7 to energy
  267.             local dodgechance = 0
  268.             if skillLevel >= 10 and skillLevel < 110 then  
  269.             dodgechance = 100
  270.             elseif skillLevel >= 110 and skillLevel < 120 then
  271.             dodgechance = 15
  272.             elseif skillLevel >= 120 and skillLevel < 130 then
  273.             dodgechance = 20
  274.             elseif skillLevel >= 130 then
  275.             dodgechance = 25
  276.             end
  277.             -- Wylosuj czy unik występuje
  278.             if math.random(100) <= dodgechance then
  279.             creature:say("Miss!") -- Wyświetl komunikat
  280.             primaryDamage = 0 -- Ustaw obrażenia na 0
  281.             secondaryDamage = 0
  282.             end
  283. ---------------------------------------------------------------------------------------------------------------------
  284. ---------------------------------------------------------------------------------------------------------------------
  285.         end
  286.         end
  287.     end
  288.     return primaryDamage, primaryType, secondaryDamage, secondaryType, origin  
  289. end
  290.  
  291. cEvent:register()
  292.  
  293. local lEvent = CreatureEvent("HpLogin")
  294.  
  295. function lEvent.onLogin(player)
  296.     -- WAZNE rejstracja skryptu w onSpawn w creature scripts WAZNE!!!!!
  297.     player:registerEvent("HpChange")
  298. --[[    local vocationId = 1 -- Identyfikator klasy (zmień na właściwy identyfikator swojej klasy)
  299. local skillType = 5 -- Identyfikator umiejętności (zmień na właściwy identyfikator swojej umiejętności)
  300.  
  301. local vocation = Vocation(vocationId) -- Tworzymy obiekt reprezentujący klasę o danym identyfikatorze
  302.  
  303. print("Wymagane próby dla umiejętności " .. skillType .. " w klasie " .. vocation:getName() .. ":")
  304. for skillLevel = 10, 130 do
  305.     local requiredTries = vocation:getRequiredSkillTries(skillType, skillLevel)
  306.     print("Poziom " .. skillLevel .. ": " .. requiredTries .. " prób")
  307. end--]]
  308.     return true
  309. end
  310.  
  311. lEvent:register()
  312.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement