Michcol94
Member
- Joined
- Sep 2, 2021
- Messages
- 108
- Reaction score
- 24
The code works as follows if the player attacks the player to add melee and ranged dmg bonuses and drowning damage, but I don't know how to add dmg absorption bonuses to work at the same time. And if the monster attacks the player, the dmg absorb bonus is added, but I don't know how to add the melee, ranged and drowning dmg bonuses when the player attacks the monster. And I'm adding some defensive skills. Please help, I've tried many solutions and it's probably simple, I'm just learning. TFS 1.5 By Nekiro downgrade 8.6LUA: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 cEvent = CreatureEvent("HpChange") function cEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) if attacker~= nil and attacker:isPlayer() then local Vocation = attacker:getVocation():getId() elseif primaryType == COMBAT_PHYSICALDAMAGE then local atk_mele = primaryDamage local meledata = bonus_transform_dmg_absorb[Vocation] local dmgmelebonus = atk_mele * (meledata.atk_mele_dmg / 100) primaryDamage = atk_mele + dmgmelebonus secondaryDamage = atk_mele + dmgmelebonus --obrazenia ki z transformacji elseif primaryType == COMBAT_DROWNDAMAGE then local atk_ene =primaryDamage local enedata = bonus_transform_dmg_absorb[Vocation] local dmgenebonus =atk_ene * (enedata.atk_ki_dmg / 100) primaryDamage = atk_ene + dmgenebonus secondaryDamage = atk_ene + dmgenebonus --obrazenia balla z transformacji elseif primaryType == COMBAT_DISTANCE then local atk_ball =primaryDamage local balldata = bonus_transform_dmg_absorb[Vocation] local dmgballbonus =atk_ball * (balldata.atk_ki_dmg / 100) primaryDamage = atk_ball + dmgballbonus secondaryDamage = atk_ball + dmgballbonus end else local totalDamage = primaryDamage local getVocationId = creature:getVocation():getId() local bonus_data = bonus_transform_dmg_absorb[getVocationId] playerId = creature:getId() --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 local transform_and_def_absorb_bonus = procentdefabsorbu + bonus_data.mele_dmg_absorb if creature:getStorageValue(9998) ~= transform_and_def_absorb_bonus then creature:setStorageValue(9998, transform_and_def_absorb_bonus) end local absorbdefValue = creature:getStorageValue(9998) local damagedefReduction = meledmg * (absorbdefValue / 100) primaryDamage = meledmg - damagedefReduction secondaryDamage = meledmg - damagedefReduction --absorb ki i balla z transformacji i skilli elseif primaryType == COMBAT_DROWNDAMAGE or primaryType == COMBAT_DISTANCE 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 local transform_and_ene_absorb_bonus = procentabsorbu + bonus_data.ene_dmg_absorb if creature:getStorageValue(9999) ~= transform_and_ene_absorb_bonus then creature:setStorageValue(9999,transform_and_ene_absorb_bonus) end local absorbValue = creature:getStorageValue(9999) local damageReduction = kidmg * (absorbValue / 100) primaryDamage = kidmg - damageReduction secondaryDamage = kidmg - damageReduction 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()
Post automatically merged:
I created a separate file even and it doesn't work.
New edit:LUA: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 cEvent = CreatureEvent("2HpChange") function cEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) if creature==isMonster() and attacker==isPlayer() then attacker:getVocation():getId() local atk_mele = primaryDamage local meledata = bonus_transform_dmg_absorb[Vocation] local dmgmelebonus = atk_mele * (meledata.atk_mele_dmg / 100) primaryDamage = atk_mele + dmgmelebonus secondaryDamage = atk_mele + dmgmelebonus print("wartosc primary razy procenty:" .. dmgmelebonus) print("wartosc primary wczesniej:" .. atk_mele) print("wartosc primary suma:" .. primaryDamage) print("wartosc secondaryDamage suma:" .. secondaryDamage) --obrazenia ki z transformacji elseif primaryType == COMBAT_DROWNDAMAGE then local atk_ene =primaryDamage local enedata = bonus_transform_dmg_absorb[Vocation] local dmgenebonus =atk_ene * (enedata.atk_ki_dmg / 100) primaryDamage = atk_ene + dmgenebonus secondaryDamage = atk_ene + dmgenebonus print("wartosc primary razy procenty:" .. dmgenebonus) print("wartosc primary wczesniej:" .. atk_ene) print("wartosc primary suma:" .. primaryDamage) print("wartosc secondaryDamage suma:" .. secondaryDamage) --obrazenia balla z transformacji elseif primaryType == COMBAT_DISTANCE then local atk_ball =primaryDamage local balldata = bonus_transform_dmg_absorb[Vocation] local dmgballbonus =atk_ball * (balldata.atk_ki_dmg / 100) primaryDamage = atk_ball + dmgballbonus print("wartosc primary razy procenty:" .. dmgballbonus) print("wartosc primary wczesniej:" .. atk_ball) print("wartosc primary suma:" .. primaryDamage) secondaryDamage = atk_ball + dmgballbonus print("wartosc secondaryDamage suma:" .. secondaryDamage) end return primaryDamage, primaryType, secondaryDamage, secondaryType, origin end local qEvent = CreatureEvent("2HpLogin") function qEvent.onLogin(player) player:registerEvent("2HpChange") return true end qEvent:register()
I edited the code and it just doesn't change player damage to monsters, can anyone help?
LUA: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() or 1 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_ene razy procenty:" .. dmgenebonus) print("wartosc atk_ene wczesniej:" .. atk_ene) print("wartosc atk_ene suma:" .. primaryDamage) elseif primaryType == COMBAT_DISTANCE then local atk_ball = primaryDamage local dmgballbonus = atk_ball * (bonus_data.atk_ki_dmg / 100) primaryDamage = atk_ball + dmgballbonus print("wartosc atk_ball razy procenty:" .. dmgballbonus) print("wartosc atk_ball wczesniej:" .. atk_ball) print("wartosc atk_ball 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) if secondaryType == COMBAT_PHYSICALDAMAGE then print("SECONDARY TYP PHYSICALDAMAGE!:" .. secondaryType) elseif secondaryType == COMBAT_DROWNDAMAGE then print("SECONDARY TYP COMBAT_DROWNDAMAGE!:" .. secondaryType) elseif secondaryType == COMBAT_DISTANCE then print("SECONDARY TYP COMBAT_DISTANCE!:" .. secondaryType) --obrazenia mele z transformacji end -- możliwa zmiana warunku w tym miejscu 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 or primaryType == COMBAT_DISTANCE 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") --[[ local vocationId = 1 -- Identyfikator klasy (zmień na właściwy identyfikator swojej klasy) local skillType = 5 -- Identyfikator umiejętności (zmień na właściwy identyfikator swojej umiejętności) local vocation = Vocation(vocationId) -- Tworzymy obiekt reprezentujący klasę o danym identyfikatorze print("Wymagane próby dla umiejętności " .. skillType .. " w klasie " .. vocation:getName() .. ":") for skillLevel = 10, 130 do local requiredTries = vocation:getRequiredSkillTries(skillType, skillLevel) print("Poziom " .. skillLevel .. ": " .. requiredTries .. " prób") end--]] return true end lEvent:register()
Last edited: