Forums WoW Modding Support Archives TrinityCore Discord Archives [DiscordArchive] Can anyone give me some pointers on how to achieve this: i want to check all the time if there is an

[DiscordArchive] Can anyone give me some pointers on how to achieve this: i want to check all the time if there is an

[DiscordArchive] Can anyone give me some pointers on how to achieve this: i want to check all the time if there is an

rektbyfaith
Administrator
0
04-09-2024, 12:14 PM
#1
Archived author: Linguster • Posted: 2024-04-09T12:14:01.347000+00:00
Original source

Can anyone give me some pointers on how to achieve this: i want to check all the time if there is any hostile NPCs within 30 yards and if so, cast a spell on them every 10 seconds. Somehow done on ::Update so the spell cast is forced server side. Does that make sense?
rektbyfaith
04-09-2024, 12:14 PM #1

Archived author: Linguster • Posted: 2024-04-09T12:14:01.347000+00:00
Original source

Can anyone give me some pointers on how to achieve this: i want to check all the time if there is any hostile NPCs within 30 yards and if so, cast a spell on them every 10 seconds. Somehow done on ::Update so the spell cast is forced server side. Does that make sense?

rektbyfaith
Administrator
0
04-09-2024, 12:42 PM
#2
Archived author: stoneharry • Posted: 2024-04-09T12:42:45.893000+00:00
Original source

```lua
local function NearbyHostileNpcCheck(_, _, _, pUnit)
-- See doc: https://elunaluaengine.github.io/WorldOb...Range.html
for _,v in pairs(pUnit:GetCreaturesInRange( range, entryId, hostile )) do
pUnit:CastSpell(v, spellId)
end
end

local function OnSpawn(_, pUnit)
pUnit:RegisterEvent(NearbyHostileNpcCheck, 10000, 0)
end

RegisterCreatureEvent(npcid, CREATURE_EVENT_ON_SPAWN, OnSpawn)
```
rektbyfaith
04-09-2024, 12:42 PM #2

Archived author: stoneharry • Posted: 2024-04-09T12:42:45.893000+00:00
Original source

```lua
local function NearbyHostileNpcCheck(_, _, _, pUnit)
-- See doc: https://elunaluaengine.github.io/WorldOb...Range.html
for _,v in pairs(pUnit:GetCreaturesInRange( range, entryId, hostile )) do
pUnit:CastSpell(v, spellId)
end
end

local function OnSpawn(_, pUnit)
pUnit:RegisterEvent(NearbyHostileNpcCheck, 10000, 0)
end

RegisterCreatureEvent(npcid, CREATURE_EVENT_ON_SPAWN, OnSpawn)
```

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)