From 07d1c8c3fe601f019d5a448fc568d4dfc5987f33 Mon Sep 17 00:00:00 2001 From: Dinkledork <118951051+Day36512@users.noreply.github.com> Date: Thu, 2 Feb 2023 17:57:15 -0700 Subject: [PATCH] Update SetnpclevelScourgeTrash.lua --- SetnpclevelScourgeTrash.lua | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/SetnpclevelScourgeTrash.lua b/SetnpclevelScourgeTrash.lua index 352e771..c0ac202 100644 --- a/SetnpclevelScourgeTrash.lua +++ b/SetnpclevelScourgeTrash.lua @@ -14,18 +14,26 @@ local npcIds = { 10407 } --- Function to cast spell ID 28234 on the creature and mask the level up spawning visual. this was really just for an event and can be removed + +-- Function to cast spell ID 41236 on the creature and mask the level up spawning visual. this was really just for an event and can be removed local function CastSpellOnSpawn(event, creature) - -- Set the creature's level to a random value between whatever, in this case 25-30 - local level = math.random(25, 30) - creature:SetLevel(level) - - creature:SetMaxHealth(creature:GetMaxHealth() * level / creature:GetLevel()) - creature:SetHealth(creature:GetMaxHealth()) - creature:CastSpell(creature, 28234, true) +-- Set the creature's level to a random value between 25-30 +local level = math.random(25, 30) +local originalLevel = creature:GetLevel() +creature:SetLevel(level) + +if level < originalLevel then --modifies health of affected npcs by 3% per level. Adjust it to your liking. +creature:SetMaxHealth(creature:GetMaxHealth() * (1 - (originalLevel - level) * 0.03)) +creature:SetHealth(creature:GetMaxHealth()) +else +creature:SetMaxHealth(creature:GetMaxHealth() * (1 + (level - originalLevel) * 0.03)) +creature:SetHealth(creature:GetMaxHealth()) +end + +creature:CastSpell(creature, 41236, true) --teleport visual end -- Register the function to be called on creature spawn event for each NPC ID -for _, npcId in ipairs(npcIds) do - RegisterCreatureEvent(npcId, 5, CastSpellOnSpawn) +for i = 1, #npcIds do +RegisterCreatureEvent(npcIds[i], 5, CastSpellOnSpawn) end