PDA

View Full Version : Zone wide quest to add loot


Bohbo
02-09-2015, 12:37 AM
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?



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\ ?

Bohbo
02-09-2015, 09:45 AM
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.

http://i.imgur.com/wUId7sZ.png

NatedogEZ
02-09-2015, 11:16 AM
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!

Bohbo
02-09-2015, 11:18 AM
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

Bohbo
02-09-2015, 11:21 AM
Here is the working quest code if anyone wants to reuse it. This is in the zone directory in the file default.pl

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);
}
}

trevius
02-09-2015, 12:25 PM
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:

# 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.

NatedogEZ
02-09-2015, 01:18 PM
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

Bohbo
02-09-2015, 01:36 PM
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!

trevius
02-10-2015, 11:41 AM
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.

swansona65
05-16-2018, 06:20 PM
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

Kingly_Krab
05-16-2018, 10:46 PM
You can put it in zone/default.pl.

swansona65
05-23-2018, 03:48 PM
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);
}
}

demonstar55
05-23-2018, 03:55 PM
We have global loot system now ...

swansona65
05-23-2018, 04:01 PM
Well... Do explain or give me a link where i can read up on how that works. Clearly I missed something.

atrayas
05-23-2018, 05:51 PM
check the plugins in the wiki, there is an addloot plugin that works wonders.

swansona65
05-23-2018, 06:28 PM
yea i saw that but there was no instructions? can you send me a link to instructions?

swansona65
05-23-2018, 06:29 PM
I saw the wiki but it didn't have instructions on how to use it. Can you send me a link to instructions or give me the basics ?

demonstar55
05-23-2018, 07:20 PM
Just use the PEQ editor. Only issue is that you have to create a loottable attached to an NPC since the editor doesn't currently support creating a loottable that isn't.

There is an optional SQL that will set up defiant loot (flawed+ is disabled in that SQL, can just edit with editor)

swansona65
05-23-2018, 07:52 PM
After i create a loottable for one of the zone npc's how do i make it apply to everything in the zone via PEQ Editor? Thank you

swansona65
05-25-2018, 10:54 AM
Bump. Can someone please explain how to use the peq editor to add a loot table and make the loot zone wide I would appreciate it! Thanks! If there is a wiki somewhere i missed that details this I would be more than happy to read it and figure it out myself but specific information seems to be limited.

swansona65
05-25-2018, 11:28 AM
I believe i have figured this out. I would imagine someone has a custom script or better way to add mass loot to one npc vs having to add them all manually? This is the safe way i know i can do it without messing up my entire DB. But I would be open to other ideas !