Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2015, 12:37 AM
Bohbo
Hill Giant
 
Join Date: Dec 2012
Posts: 116
Default Default.pl only loading for 1 mob in zone

EDIT::: Problem seems to be with default.pl only loading for 1 mob and not the quest itself. See 2nd post.


Trying to make a zone wide quest to add loot. For testing purposes i have it set to >=1 later will be more like 90. The idea is if a chance is rolled then pick a random item from a set of items and add it to NPC loot.


So i went to the zone folder made a file called default.pl and went on doing normal quest routine. here is where it gets weird.... This quest seems to pick 1 mob each #reloadqst and stick with that through each #repop until I do #reloadqst again. you can see my test line there, which really helped narrow this down. Any ideas what I am doing wrong here?



Code:
my @drops = (6701,6702,6703,6704);
sub EVENT_SPAWN{
quest::shout("test");
	if(quest::ChooseRandom(1..100) >= 1){
		$item = $drops[int(rand @drops)];
		quest::shout($item);#test line remove when working
		$npc->AddItem($item,1);
		 }
		 
}
EDIT:: Is there an issue with the default.pl file beingside inside a zone folder and not just in eqemu\quests\ ?
Reply With Quote
  #2  
Old 02-09-2015, 09:45 AM
Bohbo
Hill Giant
 
Join Date: Dec 2012
Posts: 116
Default

The problem seems to be in the default.pl not loading all mobs in the zone.

I used to get the quest working on a_cracked_skeleton. Now it seems to always trigger on Ariam Depoper, however if i remove a quest npcs file for #Paleontologist then he gets picked up. It seems like its picking up the first npc and not all of them.

So with no other quests in the /befallen directory other than default.pl i get #Paleontologist as the only mob responding to the quest. When I add his quest back into the zone it seems to only work for Ariam Depoper. Another note, #paleontologist is not the first or last mob alphabetically but is is the mob with the highest ID number.

Reply With Quote
  #3  
Old 02-09-2015, 11:16 AM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

You don't want @drops outside of the sub event.. thats never a good idea

zonesn\default.pl -- Will only load on NPCs in that zone who DO NOT have a quest file!!

global\global_npc.pl -- Will load on all NPCs in any zone even if they have a quest!
Reply With Quote
  #4  
Old 02-09-2015, 11:18 AM
Bohbo
Hill Giant
 
Join Date: Dec 2012
Posts: 116
Default

Quote:
Originally Posted by NatedogEZ View Post
You don't want @drops outside of the sub event.. thats never a good idea

zonesn\default.pl -- Will only load on NPCs in that zone who DO NOT have a quest file!!

global\global_npc.pl -- Will load on all NPCs in any zone even if they have a quest!
Moving the @drops into the subroutine fixed it! Thanks Nate
Reply With Quote
  #5  
Old 02-09-2015, 11:21 AM
Bohbo
Hill Giant
 
Join Date: Dec 2012
Posts: 116
Default

Here is the working quest code if anyone wants to reuse it. This is in the zone directory in the file default.pl

Code:
sub EVENT_SPAWN{
my @drops = (6701,6702,6703,6704);#define loot drops here
	if(quest::ChooseRandom(1..100) >= 95){ #probability an item will be added
		$item = $drops[int(rand @drops)];
		$npc->AddItem($item);
	}
}
Reply With Quote
  #6  
Old 02-09-2015, 12:25 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

FYI,

It is OK to define arrays outside of the subs, but you can't use "my" on them or they won't be loaded.

Also, if you are using default.pl, I highly suggest adding something like the below to the top of any subs you have in default.pl:

Code:
	# Prevent pets or charmed NPCs from loading the default.pl
	if (!$npc || $npc->GetOwnerID() || $npc->GetSwarmOwner())
	{
		return;
	}
This will prevent your default.pl script from being applied to pets.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #7  
Old 02-09-2015, 01:18 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

Quote:
Originally Posted by trevius View Post
FYI,
It is OK to define arrays outside of the subs, but you can't use "my" on them or they won't be loaded.

Ah.. weird I always had the problem he did when I did that.. it would just load on 1 NPC and never load on other npcs in the same zone.. so generally I just don't ever place anything outside the subs
Reply With Quote
  #8  
Old 02-09-2015, 01:36 PM
Bohbo
Hill Giant
 
Join Date: Dec 2012
Posts: 116
Default

What exactly does my do, make it a local variable just inside the sub it is placed in? vs no my making is more global to the whole script?

Good call on the swarm pets too, I will add that, that could have been exploit city!
Reply With Quote
  #9  
Old 02-10-2015, 11:41 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Yeah, "my" basically makes the variable only valid within the current block of code. If you remove the "my", then it can global to the whole script. Using "my" outside of a block (such as sub EVENT or anything with brackets) will just not let it work properly by perl design. I am not exactly sure why it even works for a single NPC, but either way it is not recommended.

When you have a static array like that which isn't being altered in the script, it is fine to define it outside of the subs as long as you leave off the "my". However, if you have a variable outside of the subs that does get modified by the script, it can effect all NPCs that use that same script since it is global.

It can sometime be tricky to get the right results when working with stuff like default.pl which will be applied to a large number of NPCs. Understanding the functionality of "my" and global variables can help a lot.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #10  
Old 05-16-2018, 06:20 PM
swansona65
Fire Beetle
 
Join Date: Oct 2013
Posts: 11
Default File

Where do you save this .pl file i cant seem to get it to spawn loot on npcs? I currently have it saved as default.pl in the /quests/crushbone folder
Reply With Quote
  #11  
Old 05-16-2018, 10:46 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,594
Default

You can put it in zone/default.pl.
Reply With Quote
  #12  
Old 05-23-2018, 03:48 PM
swansona65
Fire Beetle
 
Join Date: Oct 2013
Posts: 11
Default

Ok so i put the below in both the zone/default.pl file and i tried adding it to the quests/global folder with the file name global_npc.pl and neither are spawning npcs with loot. I must be doing something wrong. I am trying to figure out an easy way to add a list of item ID's to all the npcs in the zone with a probability of around 90-95%. Let me know if there is a more streamlined method of implementation.

sub EVENT_SPAWN{
my @drops = (50516, 50011, 50518, 50014, 50012, 50015, 50013, 50017, 50016, 50018, 50029, 50027, 50031, 50032, 50028, 50030, 50026, 50507, 50510, 50501, 50512, 50503, 50514, 50515, 50021, 50019, 50022, 50020, 50023, 50024, 50025, 50506, 50007, 50005, 50006, 50010, 50008, 50009, 50513, 50502, 50508, 50511, 50517, 50504, 50505);#define loot drops here
if(quest::ChooseRandom(1..100) >= 95){ #probability an item will be added
$item = $drops[int(rand @drops)];
$npc->AddItem($item);
}
}
Reply With Quote
  #13  
Old 05-23-2018, 03:55 PM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,164
Default

We have global loot system now ...
Reply With Quote
  #14  
Old 05-23-2018, 04:01 PM
swansona65
Fire Beetle
 
Join Date: Oct 2013
Posts: 11
Default

Well... Do explain or give me a link where i can read up on how that works. Clearly I missed something.
Reply With Quote
  #15  
Old 05-23-2018, 05:51 PM
atrayas
Hill Giant
 
Join Date: Jun 2010
Posts: 105
Default

check the plugins in the wiki, there is an addloot plugin that works wonders.
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 12:30 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