EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Custom (https://www.eqemulator.org/forums/forumdisplay.php?f=671)
-   -   Need NPC to trigger iff it's in melee range (https://www.eqemulator.org/forums/showthread.php?t=42121)

greyfox8888 10-11-2018 03:30 AM

Need NPC to trigger iff it's in melee range
 
EDIT: Sorry I meant to post this in Quest: Q&A ...

I am working on an encounter in which the boss picks a random target from its hate list and summons an add which immediately begins to path/attack that target.

Now for the part that I am unsure about. I would like the add to cast an AOE spell and then depop the moment it gets into melee range of its target. You can think of the add acting like a homing missile which detonates on impact. The goal being that the players must kite the adds and never get within melee range or they go boom.

Is there someway to trigger an event only when the mob is in melee range of its target?

EVENT_AGGRO, and EVENT_COMBAT trigger right when the add is assigned a target on the hate list. I have tried using IF ($npc->IsEngaged()), but that triggers the same time EVENT_COMBAT triggers. I have also tried setting up a timer that would update a proximity around the add. That method kind of worked but was really inconsistent. I figure the 1 second delay to check proximity just isn't the best option for checking melee range of 2 moving mobs (add, and target).

Any ideas on how to implement this would be greatly appreciated. I am new to this so it wouldn't surprise me if there is a plugin or something of the likes
that I have totally over looked. Anything that can help me trigger an event once a mob is within melee range, or has dealt X amount of damage to an NPC would be perfect.

demonstar55 10-11-2018 03:32 PM

on a timer check distance to target they're chasing?

greyfox8888 10-11-2018 08:21 PM

Thanks so much! That did the trick. I completely missed the plugins:

plugin::CheckDist(entity, distance);
plugin::CheckDistBetween2Ents(entity1, entity2, distance);

The code for the spawned adds now works as intended:

Code:

sub EVENT_AGGRO {
  quest::shout("$name!!!");    #Shouts the name of the player that better start running
  quest::settimer("distance", 1);
}

sub EVENT_TIMER {

  if ($timer eq "distance") {

    my $target = $npc->GetTarget();

    if(plugin::CheckDist($target, 21)) {
          $npc->SpellFinished(732, $target,0); #cast Ice Comet on target if it is within 21 units of distance
          quest::depop();
    }
  }
}


demonstar55 10-11-2018 10:38 PM

I would recommend increasing the timer a bit, I think perl is in seconds, but 1 second is pretty often :P

NatedogEZ 10-12-2018 02:17 PM

Could maybe try EVENT_ENTER .. but make sure to set a proximity first for it to trigger :)

demonstar55 10-12-2018 02:29 PM

Quote:

Originally Posted by NatedogEZ (Post 260427)
Could maybe try EVENT_ENTER .. but make sure to set a proximity first for it to trigger :)

The NPC is moving, so they would have to constantly change the proximity ... Probably better to just check distance :P

ChaosSlayerZ 10-12-2018 09:57 PM

Sorry for hijacking a the tread - I have similar question
Suppose I have npc roaming around the zone.
I want NPC to do something when it passes near a player - like emote.
In the case above, npc already have player target, in my case it can be any player anywhere or multiple of them, so I need npc to continuously check around for valid target.

I was thinking - how does exactly aggro works - isn't npc continuously checking if player is in its range? Can't same principle be used?

Thanks!


All times are GMT -4. The time now is 11:06 AM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.