Files
RandomScriptsforAzerothCore/Custom_XP.lua
2023-02-04 03:28:42 -07:00

60 lines
2.0 KiB
Lua

local enabled = true
local spawnslist = {2260,14281,14221,2244,2261} -- npcid's
local hpmultiplier = 0.85 -- Spawned npc hp will be multiplied by players hp.
local despawntime = 25 --seconds before npc despawns
local rnumb = false --output rolled number for testing purposes
local function SpawnEnemy(event, player, killed)
local x = player:GetX()
local y = player:GetY()
local z = player:GetZ()
local o = player:GetO()
local map = player:GetMap()
local mapID = map:GetMapId()
local areaId = map:GetAreaId( x, y, z )
local faction = player:GetFaction()
local Target = player:GetSelection()
local playername = player:GetName()
local isDungeon = map:IsDungeon()
local playerHP = player:GetMaxHealth()
local spawnedCreature
local Taunts = {
"Hey "..playername.." u r so uglaaaay!!!! LMAO",
"Hey "..playername.."! It's game over for you!",
"Hey "..playername.." What's up now!?",
"Hey "..playername.." Ready when you are!",
"Hey "..playername.." You'll get no sympathy from me!",
"Victory or Death!!!",
""..playername.." is about to cry like a baby.",
"Run "..playername.." run!",
"Hey "..playername.." whats that on ur head? oh yea my weapon.",
"Hey "..playername.." why don't apple jacks taste like apples?"
}
local chosen = spawnslist[math.random(1, #spawnslist)]
local healammount = playerHP * hpmultiplier
local r = math.random(1,100)
local level = player:GetLevel()
if r <= 50 and not isDungeon then
local EnemyNear = player:GetNearestCreature( 80, chosen )
if EnemyNear == nil then
spawnedCreature = player:SpawnCreature( chosen, x-5, y, z, o, 3, despawntime )
spawnedCreature:SetLevel(level)
spawnedCreature:SetMaxHealth(playerHP * hpmultiplier)
spawnedCreature:DealHeal( spawnedCreature, 39334, healammount )
spawnedCreature:SendUnitSay(Taunts[math.random(1, #Taunts)], 0)
spawnedCreature:AttackStart(player)
end
end
if rnumb then
player:SendBroadcastMessage("|cff3399FF (Randomly Attacked script) number: |cff00cc00"..r.."|cff3399FF")
end
end
if enabled then
RegisterPlayerEvent(7, SpawnEnemy)
end