Update SetnpclevelScourgeTrash.lua

This commit is contained in:
Dinkledork
2023-02-02 17:57:15 -07:00
committed by GitHub
parent 44294fe112
commit 07d1c8c3fe

View File

@@ -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