From 64ff93e51f3f1cbeabc3ac6ec204ce830d041248 Mon Sep 17 00:00:00 2001 From: LeoTK <41605307+LeoTKBR@users.noreply.github.com> Date: Fri, 22 Nov 2024 14:20:01 -0300 Subject: [PATCH 1/4] soul war - taints exp passive - Exp bonus for the amount of taints you have from soul war --- data/events/scripts/player.lua | 53 +++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index c526553132d..86f45ac69e9 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -575,12 +575,63 @@ function Player:onGainExperience(target, exp, rawExp) end end + -- Soul War XP Boost Taints + local taints = { + "taints-teleport", -- Taint 1 + "taints-spawn", -- Taint 2 + "taints-damage", -- Taint 3 + "taints-heal", -- Taint 4 + "taints-loss", -- Taint 5 + xpboost = { + [1] = 5, + [2] = 10, + [3] = 15, + [4] = 20, + [5] = 25 + }, + monsters = { + "Aspect of Power", "Dreadful Harvester", "Goshnar's Cruelty", "Goshnar's Greed","Goshnar's Hatred", + "Goshnar's Malice","Goshnar's Megalomania Blue", "Goshnar's Megalomania Green","Goshnar's Megalomania Purple", + "Goshnar's Spite","Malicious Soul","Mean Maw","Mirror Image","Soul Cage","Spiteful Spitter", + "Bony Sea Devil", "Brachiodemon", "Branchy Crawler","Capricious Phantom","Distorted Phantom", + "Druid's Apparition", "Hateful Soul", "Infernal Demon", "Infernal Phantom", "Knight's Apparition", + "Many Faces", "Mould Phantom", "Paladin's Apparition", "Rotten Golem", "Sorcerer's Apparition", + "Turbulent Elemental", "Cloak of Terror", "Courage Leech", "Vibrant Phantom", + } + } + local function contains(table, element) + for _, value in ipairs(table) do + if value == element then + return true + end + end + return false + end + + local monsterName = target:getName() + local taintLevel = self:getTaintLevel() + local taints_xpboost = 0 + + if contains(taints.monsters, monsterName) and taintLevel and taintLevel > 0 then + local count = 0 + for index = 1, taintLevel do + local taintName = taints[index] + if taintName then + count = count + 1 + end + end + + if count > 0 then + taints_xpboost = taints.xpboost[count] + end + end + -- Final Adjustments: Low Level Bonus and Base Rate local lowLevelBonusExp = self:getFinalLowLevelBonus() local baseRateExp = self:getFinalBaseRateExperience() -- Return final experience value - return (exp * (1 + xpBoostPercent / 100 + lowLevelBonusExp / 100)) * staminaBonusXp * baseRateExp + return (exp * (1 + xpBoostPercent / 100 + lowLevelBonusExp / 100)) + (exp * (taints_xpboost / 100)) * staminaBonusXp * baseRateExp end function Player:onLoseExperience(exp) From 2ba9642deac2da54d9374e8ed13b3d6d5de5c9ab Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 22 Nov 2024 17:21:24 +0000 Subject: [PATCH 2/4] Lua code format - (Stylua) --- data/events/scripts/player.lua | 53 +++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index 86f45ac69e9..6df789dbf55 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -575,7 +575,7 @@ function Player:onGainExperience(target, exp, rawExp) end end - -- Soul War XP Boost Taints + -- Soul War XP Boost Taints local taints = { "taints-teleport", -- Taint 1 "taints-spawn", -- Taint 2 @@ -587,17 +587,44 @@ function Player:onGainExperience(target, exp, rawExp) [2] = 10, [3] = 15, [4] = 20, - [5] = 25 + [5] = 25, }, monsters = { - "Aspect of Power", "Dreadful Harvester", "Goshnar's Cruelty", "Goshnar's Greed","Goshnar's Hatred", - "Goshnar's Malice","Goshnar's Megalomania Blue", "Goshnar's Megalomania Green","Goshnar's Megalomania Purple", - "Goshnar's Spite","Malicious Soul","Mean Maw","Mirror Image","Soul Cage","Spiteful Spitter", - "Bony Sea Devil", "Brachiodemon", "Branchy Crawler","Capricious Phantom","Distorted Phantom", - "Druid's Apparition", "Hateful Soul", "Infernal Demon", "Infernal Phantom", "Knight's Apparition", - "Many Faces", "Mould Phantom", "Paladin's Apparition", "Rotten Golem", "Sorcerer's Apparition", - "Turbulent Elemental", "Cloak of Terror", "Courage Leech", "Vibrant Phantom", - } + "Aspect of Power", + "Dreadful Harvester", + "Goshnar's Cruelty", + "Goshnar's Greed", + "Goshnar's Hatred", + "Goshnar's Malice", + "Goshnar's Megalomania Blue", + "Goshnar's Megalomania Green", + "Goshnar's Megalomania Purple", + "Goshnar's Spite", + "Malicious Soul", + "Mean Maw", + "Mirror Image", + "Soul Cage", + "Spiteful Spitter", + "Bony Sea Devil", + "Brachiodemon", + "Branchy Crawler", + "Capricious Phantom", + "Distorted Phantom", + "Druid's Apparition", + "Hateful Soul", + "Infernal Demon", + "Infernal Phantom", + "Knight's Apparition", + "Many Faces", + "Mould Phantom", + "Paladin's Apparition", + "Rotten Golem", + "Sorcerer's Apparition", + "Turbulent Elemental", + "Cloak of Terror", + "Courage Leech", + "Vibrant Phantom", + }, } local function contains(table, element) for _, value in ipairs(table) do @@ -607,11 +634,11 @@ function Player:onGainExperience(target, exp, rawExp) end return false end - + local monsterName = target:getName() local taintLevel = self:getTaintLevel() local taints_xpboost = 0 - + if contains(taints.monsters, monsterName) and taintLevel and taintLevel > 0 then local count = 0 for index = 1, taintLevel do @@ -620,7 +647,7 @@ function Player:onGainExperience(target, exp, rawExp) count = count + 1 end end - + if count > 0 then taints_xpboost = taints.xpboost[count] end From b67665d1568b68c4b4ca32278b54cf26c79c3e1c Mon Sep 17 00:00:00 2001 From: LeoTK Date: Fri, 22 Nov 2024 14:40:03 -0300 Subject: [PATCH 3/4] Code optimization I noticed that as it will be executed several times for each monster killed, I made this optimization. --- data/events/scripts/player.lua | 90 ++++++++++++++-------------------- 1 file changed, 37 insertions(+), 53 deletions(-) diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index 6df789dbf55..d298ee7b0a2 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -590,64 +590,48 @@ function Player:onGainExperience(target, exp, rawExp) [5] = 25, }, monsters = { - "Aspect of Power", - "Dreadful Harvester", - "Goshnar's Cruelty", - "Goshnar's Greed", - "Goshnar's Hatred", - "Goshnar's Malice", - "Goshnar's Megalomania Blue", - "Goshnar's Megalomania Green", - "Goshnar's Megalomania Purple", - "Goshnar's Spite", - "Malicious Soul", - "Mean Maw", - "Mirror Image", - "Soul Cage", - "Spiteful Spitter", - "Bony Sea Devil", - "Brachiodemon", - "Branchy Crawler", - "Capricious Phantom", - "Distorted Phantom", - "Druid's Apparition", - "Hateful Soul", - "Infernal Demon", - "Infernal Phantom", - "Knight's Apparition", - "Many Faces", - "Mould Phantom", - "Paladin's Apparition", - "Rotten Golem", - "Sorcerer's Apparition", - "Turbulent Elemental", - "Cloak of Terror", - "Courage Leech", - "Vibrant Phantom", - }, + ["Aspect of Power"] = true, + ["Dreadful Harvester"] = true, + ["Goshnar's Cruelty"] = true, + ["Goshnar's Greed"] = true, + ["Goshnar's Hatred"] = true, + ["Goshnar's Malice"] = true, + ["Goshnar's Megalomania Blue"] = true, + ["Goshnar's Megalomania Green"] = true, + ["Goshnar's Megalomania Purple"] = true, + ["Goshnar's Spite"] = true, + ["Malicious Soul"] = true, + ["Mean Maw"] = true, + ["Mirror Image"] = true, + ["Soul Cage"] = true, + ["Spiteful Spitter"] = true, + ["Bony Sea Devil"] = true, + ["Brachiodemon"] = true, + ["Branchy Crawler"] = true, + ["Capricious Phantom"] = true, + ["Distorted Phantom"] = true, + ["Druid's Apparition"] = true, + ["Hateful Soul"] = true, + ["Infernal Demon"] = true, + ["Infernal Phantom"] = true, + ["Knight's Apparition"] = true, + ["Many Faces"] = true, + ["Mould Phantom"] = true, + ["Paladin's Apparition"] = true, + ["Rotten Golem"] = true, + ["Sorcerer's Apparition"] = true, + ["Turbulent Elemental"] = true, + ["Cloak of Terror"] = true, + ["Courage Leech"] = true, + ["Vibrant Phantom"] = true, + } } - local function contains(table, element) - for _, value in ipairs(table) do - if value == element then - return true - end - end - return false - end local monsterName = target:getName() local taintLevel = self:getTaintLevel() local taints_xpboost = 0 - - if contains(taints.monsters, monsterName) and taintLevel and taintLevel > 0 then - local count = 0 - for index = 1, taintLevel do - local taintName = taints[index] - if taintName then - count = count + 1 - end - end - + if taints.monsters[monsterName] and taintLevel and taintLevel > 0 then + local count = math.min(taintLevel, #taints) if count > 0 then taints_xpboost = taints.xpboost[count] end From 11205248dc2e89bf792436eccb7a9c5b35a3b966 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 22 Nov 2024 17:40:09 +0000 Subject: [PATCH 4/4] Lua code format - (Stylua) --- data/events/scripts/player.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index d298ee7b0a2..964bea2b570 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -624,7 +624,7 @@ function Player:onGainExperience(target, exp, rawExp) ["Cloak of Terror"] = true, ["Courage Leech"] = true, ["Vibrant Phantom"] = true, - } + }, } local monsterName = target:getName()