mirror of
https://github.com/araxiaonline/RandomScriptsforAzerothCore.git
synced 2026-06-13 02:22:19 -04:00
Add files via upload
This commit is contained in:
65
RandomScourgeAttack.lua
Normal file
65
RandomScourgeAttack.lua
Normal file
@@ -0,0 +1,65 @@
|
||||
local GAME_EVENT_ID = 17 -- Set the game event ID
|
||||
local MAX_NPC_SPAWN = 3 -- Set the maximum number of NPCs to spawn simultaneously. Extremely high numbers will hurt performance
|
||||
local ATTACK_CHANCE = 15 -- Set the likelihood of an attack here, in percent
|
||||
local DAZE_SPELL_ID = 100201 -- Set the spell ID for daze
|
||||
|
||||
local creatureEntries = {
|
||||
16423,
|
||||
16422,
|
||||
400011
|
||||
} -- Add NPC entries above (CHANGE THESE OR IT WON'T WORK! I'M USING CUSTOM IDs)
|
||||
|
||||
local npcdialogue = {
|
||||
"Grrrr...",
|
||||
"Rrrrr...",
|
||||
"Grraaargh...",
|
||||
"Raaargh...",
|
||||
"Hssss..."
|
||||
} -- Add dialogue above
|
||||
|
||||
local function IsGameEventActive(eventId)
|
||||
local activeEvents = GetActiveGameEvents()
|
||||
for _, event in ipairs(activeEvents) do
|
||||
if event == eventId then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function SpawnAttacker(event, player)
|
||||
if IsGameEventActive(GAME_EVENT_ID) then
|
||||
local chance = math.random(100)
|
||||
|
||||
if chance <= ATTACK_CHANCE then
|
||||
local mapId = player:GetMapId()
|
||||
local x, y, z, o = player:GetLocation()
|
||||
local level = player:GetLevel()
|
||||
local health = player:GetHealth() * 1.65
|
||||
local npcCount = math.random(1, MAX_NPC_SPAWN)
|
||||
|
||||
-- Check if the player is mounted and not flying
|
||||
if player:IsMounted() and not player:IsFlying() then
|
||||
player:Dismount()
|
||||
player:CastSpell(player, DAZE_SPELL_ID, true)
|
||||
player:SendBroadcastMessage("You have been knocked off your mount!")
|
||||
end
|
||||
|
||||
for i = 1, npcCount do
|
||||
local selectedCreature = creatureEntries[math.random(#creatureEntries)]
|
||||
local randomX = x + math.random(-18, 18)
|
||||
local randomY = y + math.random(-18, 18)
|
||||
local spawnedCreature = player:SpawnCreature(selectedCreature, randomX, randomY, z, o, 7, 130000)
|
||||
spawnedCreature:SetLevel(level)
|
||||
spawnedCreature:SetMaxHealth(health)
|
||||
spawnedCreature:SetHealth(health)
|
||||
spawnedCreature:AttackStart(player)
|
||||
|
||||
local selectedDialogue = npcdialogue[math.random(#npcdialogue)]
|
||||
spawnedCreature:SendUnitYell(selectedDialogue, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RegisterPlayerEvent(27, SpawnAttacker)
|
||||
Reference in New Issue
Block a user