diff --git a/LUA/RandomScourgeAttack.lua b/LUA/RandomScourgeAttack.lua new file mode 100644 index 0000000..5319901 --- /dev/null +++ b/LUA/RandomScourgeAttack.lua @@ -0,0 +1,66 @@ +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, + 16379, + 16380 +} -- 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)