Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Custom

Quests::Custom Custom Quests here

Reply
 
Thread Tools Display Modes
  #1  
Old 03-28-2015, 04:41 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default Proximity check for surrounding NPCs

Hi all,

I am trying to have a NPC do proximity check that will check for any NPC in the proximity.

The purpose of this is, im starting from scratch and im trying to globally do a scripted distance chain aggro so I can bypass factions. Also other uses.

I have read that NPC proximity can only check for PC. If thats the case. there is also the
Code:
 if(plugin::CheckDistBetween2Ents($npc1, $npc2, 50)){
stuff. If this is set to a timer and I want it to check for ANY NPC within the range, would I use an array of all my npcs in the zone or whatever i want it to link to?

Everything I have tried so far has failed, am just looken for direction. Hopefully I can write it when on the path lol

Thank you.
__________________
Reply With Quote
  #2  
Old 03-28-2015, 05:06 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

I've written small tutorials for NPC list iterations in the entity list:

http://wiki.eqemulator.org/p?Entity_...ow_to_Use_Them

Anytime you are using $client or $npc, those are IMPLIED entity objects.

You can create your own entity objects by fetching them selectively in your code.

Code:
$some_boss = $entity_list->GetNPCByNPCTypeID(40005); # Example
$some_boss->Say("hi");
You would use that same object in the distance check
Code:
 if(plugin::CheckDistBetween2Ents($npc, $some_boss, 50)){
If you want to find all NPC's say within 50 units of the NPC you are triggering the code on, you would do something like this:

Code:
my @nlist = $entity_list->GetNPCList(); #::: Use Entity List Object to get this
foreach my $n (@nlist){ #::: Iterate through each NPC in the @nlist array
	if(plugin::CheckDistBetween2Ents($npc, $n, 50)){
		$n->Shout("Hi I am an NPC that is within your distance check");
	}
}
Reply With Quote
  #3  
Old 03-28-2015, 05:23 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Nice! Thank you, reading over it all now
__________________
Reply With Quote
  #4  
Old 03-28-2015, 09:21 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Well I would think this would work, been worken on it and tryen to get it to work but it does not and i am blinded by the reason why.

Its fairly simple, It looks like it would work but it doesnt.

Code:
sub EVENT_SPAWN{
quest::settimer(1, 3);
}
 
sub EVENT_TIMER{
	if($timer == 1) {
		my @nlist = $entity_list->GetNPCList(); #::: Use Entity List Object to get this
		foreach my $n (@nlist){ #::: Iterate through each NPC in the @nlist array
			if(plugin::CheckDistBetween2Ents($mob, $n, 50)){
			#$n->AddToHateList($client,1);
			$n->Shout("Hi I am an NPC that is within your distance check");
			}
		}
	}
}
__________________
Reply With Quote
  #5  
Old 03-28-2015, 10:08 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

How is the script bring initiated and how are you testing
Reply With Quote
  #6  
Old 03-28-2015, 10:09 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

I have the script on 2 npcs in a zone by themselves. I agro one from a distance and run it by the other one to check if they recognize each other to eventually chain aggro.
__________________
Reply With Quote
  #7  
Old 03-28-2015, 10:17 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Quote:
Originally Posted by Figback65 View Post
I have the script on 2 npcs in a zone by themselves. I agro one from a distance and run it by the other one to check if they recognize each other to eventually chain aggro.
Add debug messages to see what conditionals are working versus not
Reply With Quote
  #8  
Old 03-28-2015, 10:28 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Code:
sub EVENT_SPAWN{
quest::settimer(1, 3);
}
 
sub EVENT_TIMER{
	if($timer == 1) {
	quest::say("timer hits");
	my @nlist = $entity_list->GetNPCList(); #::: Use Entity List Object to get this
		foreach my $n (@nlist){ #::: Iterate through each NPC in the @nlist array
		quest::say("got entity list");
			if (plugin::CheckDistBetween2Ents($npc, $n, 50)) {
			#$n->AddToHateList($client,1);
			quest::say("im too close");
			}
		}
	}
}
Included debugging. I get to pulled entity list. So checkdistbetween must not be working. I had noticed early i didnt have your additions for it in the pluggins, so i snagged those and restarted server. But that was a while ago.
__________________
Reply With Quote
  #9  
Old 03-28-2015, 11:58 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Script above works, Thank you

EDIT: Now I just gotta get the agro to share lol
__________________
Reply With Quote
  #10  
Old 04-03-2015, 02:59 AM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Finalized Template to get npc to npc distance checks and add agro, to script agro linking for whatever reason you may want. I will be usen it for many reasons including bypassing faction linking on a wiped custom server.
GetHateRandom can be changed to whatever you like, GetHateTop works as well, depending what you want to happen.

Code:
sub EVENT_TIMER{
	if($timer == 1) {
	my @nlist = $entity_list->GetNPCList(); 
		foreach my $n (@nlist){
			if (plugin::CheckDistBetween2Ents($npc, $n, 20)) {
			$n->AddToHateList($npc->GetHateRandom());
			}
		}
	}
}
__________________
Reply With Quote
  #11  
Old 04-04-2015, 08:28 PM
Asylum
Sarnak
 
Join Date: Jun 2013
Posts: 81
Default

Modified for use as a "guard" without using faction. Basically you can change the target NPCIDs to have the guard attack specific npcs that come close enough.

Code:
#2211 Enclave_Protector in postorms v.1

sub EVENT_SPAWN {
	quest::settimer(1,6);
}

sub EVENT_TIMER {
	if($timer == 1) {
		my @nlist = $entity_list->GetNPCList(); 
		foreach my $n(@nlist) {
			my $typeID = $n->GetNPCTypeID();
			if($typeID >= 2213) {
				if(plugin::CheckDistBetween2Ents($npc,$n,50)) {
					$npc->AddToHateList($n);
				}
			}
		}
	}
}
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 10:03 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3