View Full Version : Proximities and NPCs
Esildor
05-16-2014, 01:37 AM
I'm wanting to make an event that spawns some adds, the adds will path towards the boss and if they are able to reach him I want them to despawn and cause the boss to heal.
I was originally thinking proximities but it looks like their function is specifically for a client entering the proximity, not an NPC?
I've been looking around on the wiki for the past couple hours without any luck, anyone able to point me in the right direction?
Esildor
05-16-2014, 01:42 AM
Just saw this:
sub EVENT_SAY{
my $npc1 = $entity_list->GetNPCByNPCTypeID(10001);
my $npc2 = $entity_list->GetNPCByNPCTypeID(10002);
#::: Check to See if these NPC's are within distance
if(plugin::CheckDistBetween2Ents($npc1, $npc2, 50)){
quest::say("NPC's are in distance of 50");
quest::say("NPC 1 is " . $npc1->GetCleanName());
quest::say("NPC 2 is " . $npc2->GetCleanName());
} else{
quest::say("These NPC's are not in distance at all");
}
}
Thinking this will work for me. Should be able to spawn the adds on a grid and have them despawn when they get too close to a dumby npc strictly there for this.
Akkadius
05-16-2014, 01:43 AM
I'm wanting to make an event that spawns some adds, the adds will path towards the boss and if they are able to reach him I want them to despawn and cause the boss to heal.
I was originally thinking proximities but it looks like their function is specifically for a client entering the proximity, not an NPC?
I've been looking around on the wiki for the past couple hours without any luck, anyone able to point me in the right direction?
What you want is to use a function that will check the distance between the trash and the boss. You can achieve that with:
plugin::CheckDistBetween2Ents(entity1, entity2, distance);
http://wiki.eqemulator.org/p?Perl_Plugins_Master_Reference&frm=Main#plugincheckdistentity-distance
You will also want to use something simple like quest::follow, which will follow the entity that you specify:
quest::follow(EntityID, [Distance]) # Mob starts to follow "EntityID". The second field, Distance, is optional and can be used to set the distance the Mob will follow it's target at.
Setting the runspeed or walkspeed of the mob if you will, will give players a longer reaction time before the adds get to the main boss.
Hopefully that helps.
Esildor
05-16-2014, 01:45 AM
What you want is to use a function that will check the distance between the trash and the boss. You can achieve that with:
plugin::CheckDistBetween2Ents(entity1, entity2, distance);
http://wiki.eqemulator.org/p?Perl_Plugins_Master_Reference&frm=Main#plugincheckdistentity-distance
You will also want to use something simple like quest::follow, which will follow the entity that you specify:
quest::follow(EntityID, [Distance]) # Mob starts to follow "EntityID". The second field, Distance, is optional and can be used to set the distance the Mob will follow it's target at.
Setting the runspeed or walkspeed of the mob if you will, will give players a longer reaction time before the adds get to the main boss.
Hopefully that helps.
Ha,
Thanks Akkadius.
Don't know why I would want a dumby npc when I can use the boss :l silly me.
The quest::follow you're referring to having the adds I spawn follow my boss, correct? I'm assuming they don't follow any intelligent grid if I do that, in which case I'm fairly certain they would run through walls.
Esildor
05-16-2014, 02:25 AM
Akkadius,
quest::follow(EntityID, [Distance]) # Mob starts to follow "EntityID". The second field, Distance, is optional and can be used to set the distance the Mob will follow it's target at.
The 'EntityID' in the quest::follow code, would that be the same ID I'm using to check distances? for example I'm using this right now to check the distance:
sub EVENT_SPAWN {
quest::settimer("add_boss_dist", 3);
quest::shout("I work");
}
sub EVENT_TIMER {
my $npc1 = $entity_list->GetNPCByNPCTypeID(4770003);
my $npc2 = $entity_list->GetNPCByNPCTypeID(4770004);
if ($timer eq "add_boss_dist"){
if(plugin::CheckDistBetween2Ents($npc1, $npc2, 10)){
quest::shout("I'm in distance.");
}
else{
quest::shout("I'm not in distance.");
}
}
}
}
I had added this to the sub EVENT_SPAWN as well
quest::settimer(1, 1);
and then plugged in the following to try to make the npc follow and it isn't working.
if($timer == 1){
quest::shout("timer works");
quest::follow($npc1, 10);
quest::stopttimer(1);
}
Splose
05-16-2014, 02:28 AM
Akkadius,
The 'EntityID' in the quest::follow code, would that be the same ID I'm using to check distances? for example I'm using this right now to check the distance:
sub EVENT_SPAWN {
quest::settimer("add_boss_dist", 3);
quest::shout("I work");
}
sub EVENT_TIMER {
my $npc1 = $entity_list->GetNPCByNPCTypeID(4770003);
my $npc2 = $entity_list->GetNPCByNPCTypeID(4770004);
if ($timer eq "add_boss_dist"){
if(plugin::CheckDistBetween2Ents($npc1, $npc2, 10)){
quest::shout("I'm in distance.");
}
else{
quest::shout("I'm not in distance.");
}
}
}
}
I had added this to the sub EVENT_SPAWN as well
quest::settimer(1, 1);
and then plugged in the following to try to make the npc follow and it isn't working.
if($timer == 1){
quest::shout("timer works");
quest::follow($npc1, 10);
quest::stopttimer(1);
}
You have an extra t in there. Take that out an see what's going on after =)
Esildor
05-16-2014, 02:31 AM
Good catch Splose.
It stopped him from repeating 'timer works' every second, but, still no follow.
This is exactly what it looks like right now:
sub EVENT_SPAWN {
quest::settimer("add_boss_dist", 3);
quest::shout("I work");
quest::settimer(1, 1);
}
sub EVENT_TIMER {
my $npc1 = $entity_list->GetNPCByNPCTypeID(4770003);
my $npc2 = $entity_list->GetNPCByNPCTypeID(4770004);
if($timer == 1){
quest::shout("timer works");
quest::follow($npc1);
quest::stoptimer(1);
}
if ($timer eq "add_boss_dist"){
if(plugin::CheckDistBetween2Ents($npc1, $npc2, 10)){
quest::shout("I'm in distance.");
}
else{
quest::shout("I'm not in distance.");
}
}
}
}
Splose
05-16-2014, 02:59 AM
If the boss is stationary try this. I made a script really fast trying to use the quest::follow and it didn't work for me either.
What this is going to do is the mob is going to walk/run whatever to the boss, and then you need to make sure you intercept it. If it gets to the boss it's going to walk back to its original spawnpoint.. Another way (and this is my suggestion) is to use a grid and then use the waypoint arrive event to script it.
sub EVENT_SPAWN {
quest::settimer("add_boss_dist", 3);
quest::shout("I work");
quest::settimer(1, 1);
}
sub EVENT_TIMER {
my $npc1 = $entity_list->GetNPCByNPCTypeID(4770003);
my $npc2 = $entity_list->GetNPCByNPCTypeID(4770004);
if($timer == 1){
quest::shout("timer works");
quest::moveto($npc1->GetX(),$npc1->GetY(),$npc1->GetZ());
quest::stoptimer(1);
}
if ($timer eq "add_boss_dist"){
if(plugin::CheckDistBetween2Ents($npc1, $npc2, 10)){
quest::shout("I'm in distance.");
}
else{
quest::shout("I'm not in distance.");
}
}
}
This is what i tried to use in my nexus/default.pl
sub EVENT_SPAWN {
$nn = $npc->GetCleanName();
if($nn eq "a") {
quest::follow($entity_list->GetNPCByNPCTypeID(999334), 1); #::
quest::say("following " . $entity_list->GetNPCByNPCTypeID(999334)->GetCleanName() . " ");
}
}
Esildor
05-16-2014, 03:04 AM
Did that work for you Splose?
I tried the:
quest::follow(" " . $entity_list->GetNPCByNPCTypeID(999334) . "");
quest::say("following " . $entity_list->GetNPCByNPCTypeID(999334)->GetCleanName() . "");
He told me he was following him but didnt :P
Splose
05-16-2014, 03:05 AM
Did that work for you Splose?
I tried the:
quest::follow(" " . $entity_list->GetNPCByNPCTypeID(999334) . "");
quest::say("following " . $entity_list->GetNPCByNPCTypeID(999334)->GetCleanName() . "");
He told me he was following him but didnt :P
Nah.. that's the one that wasn't working for me either.. Try the script above that. Also wasn't paying attention and put quotes in the follow too.. fixed that and edited my original post but still not working properly.
Esildor
05-16-2014, 03:13 AM
Splose,
Thanks!
I removed the stoptimer so it's constantly updating the location, works perfect. It wanting to 'return' to it's spawn point after it reaches isn't an issue because if it does reach the boss it's being 'absorbed' and healing the boss.
Splose
05-16-2014, 03:15 AM
Splose,
Thanks!
I removed the stoptimer so it's constantly updating the location, works perfect. It wanting to 'return' to it's spawn point after it reaches isn't an issue because if it does reach the boss it's being 'absorbed' and healing the boss.
No problem bud.. just be aware that if the boss moves around the NPC is going to move to where the boss is at the time of it spawning. So if that NPC spawns and a player moves the boss to the other side of the room it's easily exploitable.
Esildor
05-16-2014, 03:18 AM
No problem bud.. just be aware that if the boss moves around the NPC is going to move to where the boss is at the time of it spawning. So if that NPC spawns and a player moves the boss to the other side of the room it's easily exploitable.
Nope.
I don't have the stoptimer in, so, it's constantly updating the bosses loc, have tested it and the mobs reroute themselves if the boss moves.
Biggest issue is a b-line puts the mobs through walls, I think I'm going to have to spawn them on a grid, and then once they reach the end of the grid have them grab the npc to move to it.
Using the 'waypoint arrive event' you mentioned I should be able to have the mobs move to the npc once they arrive at that waypoint, correct?
Splose
05-16-2014, 04:24 AM
Nope.
I don't have the stoptimer in, so, it's constantly updating the bosses loc, have tested it and the mobs reroute themselves if the boss moves.
Biggest issue is a b-line puts the mobs through walls, I think I'm going to have to spawn them on a grid, and then once they reach the end of the grid have them grab the npc to move to it.
Using the 'waypoint arrive event' you mentioned I should be able to have the mobs move to the npc once they arrive at that waypoint, correct?
That's correct man
Esildor
05-16-2014, 01:43 PM
Playing with the sub EVENT_WAYPOINT_ARRIVE {
This is what I have currently:
sub EVENT_SPAWN {
$npc->AssignWaypoints(546703);
}
}
sub EVENT_WAYPOINT_ARRIVE {
if ($wp == 3) {
quest::shout("hi");
}
}
Do I need some kind of definition of which grid the waypoint is on before the if statement? like my $wp = ($npc->GetGrid()) ? Found what looked like some examples on older threads but they were just using ($wp == 3) or saw another like ($wp eq 3)
Splose
05-16-2014, 07:11 PM
http://wiki.eqemulator.org/p?Waypoints&frm=Main
check that out.
you'll have to use #grid max.. then #grid add to that number + 1
then you #gassign and repop and wait until the grid gets assigned to the npc (takes a few seconds.. you can check with #wpinfo.. then you just do #wpadd)
Akkadius
05-17-2014, 12:30 AM
In quest::follow there is a difference between using entity and entity ID. You will need to do $entity_list->GetEntityByNPCTypeID(npcid)->GetID()
Ps. Typing on phone sucks
Splose
05-17-2014, 07:01 AM
In quest::follow there is a difference between using entity and entity ID. You will need to do $entity_list->GetEntityByNPCTypeID(npcid)->GetID()
Ps. Typing on phone sucks
I tried that brotato it didn't work
Esildor
05-17-2014, 01:04 PM
Lol @ brotato.
So, if statement for sub event_waypoint_arrive uses grid max? like if ($gridmax) or some shiz?
Esildor
05-17-2014, 02:11 PM
Holy shit I'm so terrible. Just did #wpinfo, they're numbered 0,1,2 etc. What I thought was 3 was 2 all along. if($wp == 2) { works fine.
That's a good thing to note though because on the PEQ Editor it shows the numbering starting at 1, not 0.
fml.
Akkadius
05-17-2014, 02:38 PM
I tried that brotato it didn't work
That's because phone's autocorrect and they suck.
quest::follow($entity_list->GetNPCByNPCTypeID(npc_id)->GetID(), 10);
DOES work
joligario
05-17-2014, 03:05 PM
... on the PEQ Editor it shows the numbering starting at 1, not 0.
Which is part of the old numbering system which was inconsistent. To get grids set properly, it is best to start 0 as the spawn point. In the editor, you can sort the grid points and it will fix the particular spawn.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.