Update SetnpclevelScourgeTrash.lua

This commit is contained in:
Dinkledork
2023-02-02 18:14:12 -07:00
committed by GitHub
parent 07d1c8c3fe
commit 5fe8649ed2

View File

@@ -8,31 +8,32 @@ local npcIds = {
8531,
11551,
10488,
10487,
10487,
1788,
10414,
10407
}
-- 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 25-30
local level = math.random(25, 30)
local originalLevel = creature:GetLevel()
creature:SetLevel(level)
if not creature then
print("Error: creature was not set!")
return
end
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())
local originalLevel = creature:GetLevel()
local randomLevel = math.random(25, 30)
local levelDiff = originalLevel - randomLevel
creature:SetLevel(randomLevel)
creature:SetMaxHealth(creature:GetMaxHealth() * (1 - levelDiff * 0.03))
creature:SetHealth(creature:GetMaxHealth())
creature:CastSpell(creature, 41236, true) --teleport visual
end
creature:CastSpell(creature, 41236, true) --teleport visual
for _, npcId in ipairs(npcIds) do
RegisterCreatureEvent(npcId, 5, CastSpellOnSpawn)
end
-- Register the function to be called on creature spawn event for each NPC ID
for i = 1, #npcIds do
RegisterCreatureEvent(npcIds[i], 5, CastSpellOnSpawn)