eluna-scripts-ornfelt/lua/Scripts/Example Scripts/example_creature.lua

25 lines
732 B
Lua
Raw Permalink Normal View History

2023-08-16 00:50:59 +02:00
local npcId = 123
local function CastFrostbolt(eventId, dely, calls, creature)
creature:CastSpell(creature:GetVictim(), 11, true)
end
local function OnEnterCombat(event, creature, target)
creature:RegisterEvent(CastFrostbolt, 5000, 0)
end
local function OnLeaveCombat(event, creature)
creature:SendUnitYell("Haha, I'm out of combat!", 0)
creature:RemoveEvents()
end
local function OnDied(event, creature, killer)
if(killer:GetObjectType() == "Player") then
killer:SendBroadcastMessage("You killed " ..creature:GetName().."!")
end
creature:RemoveEvents()
end
RegisterCreatureEvent(npcId, 1, OnEnterCombat)
RegisterCreatureEvent(npcId, 2, OnLeaveCombat)
RegisterCreatureEvent(npcId, 4, OnDied)