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-23-2018, 04:36 PM
Aardil
Fire Beetle
 
Join Date: Jan 2018
Location: Mississippi
Posts: 27
Default Player.pl question

I an working on an event that covers several zones.
I am using Player.pl to detect the player level.

Through signals (determined by the player level)
A signal is sent to a zone controller.

Zone controller depops a few NPC's and spawns NPC's of the correct level.

All the above works as it should.

Now he question.

Since this happens in several zones, I am unsure of what to do with the player .pl

Should I take all signals from every zone and place them all in a single player.pl? ( it would end up being about 5000 lines of code ( 100 lines of code per zone and there are 50 effected zones).

If it all needs to go in one player.pl is there a way to sub devide the code by zone so it wont be looking through 5000 lines to find a match?
Maybe something like this?
Code:
sub EVENT_ZONE {
  if(zonen == "butcher"){
     if($ulevel <= 5 && $ulevel >= 1) {
    quest::signalwith(51,22,0);
	quest::signalwith(51,12,10);
	}
	elsif($ulevel <= 10 && $ulevel >= 6) {
	quest::signalwith(51,22,0);
	quest::signalwith(51,13,10);
	}
	elsif($ulevel <= 15 && $ulevel >= 11) {
	quest::signalwith(51,22,0);
	quest::signalwith(51,14,10);
	}
	elsif($ulevel <= 20 && $ulevel >= 16) {
	quest::signalwith(51,22,0);
	quest::signalwith(51,15,10);
	}
	elsif($ulevel <= 25 && $ulevel >= 21) {
	quest::signalwith(51,22,0);
	quest::signalwith(51,16,10);
	}
	elsif($ulevel <= 30 && $ulevel >= 26) {
	quest::signalwith(51,22,0);
	quest::signalwith(51,17,10);
	}
	elsif($ulevel <= 35 && $ulevel >= 31) {
	quest::signalwith(51,22,0);
	quest::signalwith(51,18,10);
	}
	elsif($ulevel <= 40 && $ulevel >= 36) {
	quest::signalwith(51,22,0);
	quest::signalwith(51,19,10);
	}
	elsif($ulevel <= 45 && $ulevel >= 41) {
	quest::signalwith(51,22,0);
	quest::signalwith(51,20,10);
	}
	elsif($ulevel <= 49 && $ulevel >= 46) {
	quest::signalwith(51,22,0);
	quest::signalwith(51,21,10);
	}
	else {
	quest::signalwith(50,22,0);
	}
	}
	}
The above code is not tested as written. It does what it should without the
if (zonen == "butcher") { line

Or can each zone have a specific player.pl that only effects that zone?
Reply With Quote
  #2  
Old 02-23-2018, 05:45 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

you can have a player.pl for each zone, yes.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #3  
Old 02-23-2018, 06:02 PM
Aardil
Fire Beetle
 
Join Date: Jan 2018
Location: Mississippi
Posts: 27
Default

ok that idea got shot to hell.
There is a player.pl in templates that is rather important in the newbie zones.
Some of this takes place in newbie zones so I can not write a specific player.pl for those zones.

Looking through commands (perl reference)
I see that there is a sub EVENT_ENTERZONE
and a sub EVENT_ZONE

Could I use both of these in the same player.pl?
sub EVENT_ENTERZONE is already being used and I dont want to break anything in that section.
If so I could use sub_EVENTZONE for what I need in the templet for the newbie zones and use a separate player.pl for the other zones.
Reply With Quote
  #4  
Old 02-23-2018, 06:42 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

Yes, you can use both in the same script, but they do different things. ZONE fires any time any player zones (via Client::Handle_OP_ZoneChange()). ENTERZONE only fires on entering a zone (via Client::CompleteConnect()).

It should be simple enough to put a conditional in any EVENT that you are worried about adding to, and then have it call an external, custom subroutine or collection of them.

Also, you are able to call external files from your scripts via perl's 'do', that way you can keep all of your individual zone files separate, even if they're all in the same folder.

Code:
# current full working directory
( my $cwd = $0 ) =~ s/(?:(?!\\|\/)\S)+$//;

# hash with zonesn as keys and external scripts to run for the zone
my %signal_zone = {
	butcher => "singal_butcher.pl",
	cauldron => "signal_cauldron.pl"
};

# you'll want to add some sanity checks to make sure you have valid data here
sub EVENT_ENTERZONE
{
	do "${cwd}$signal_zone$zonesn";
}
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #5  
Old 02-23-2018, 07:46 PM
Aardil
Fire Beetle
 
Join Date: Jan 2018
Location: Mississippi
Posts: 27
Default

ok that might work as far as the player.pl issue.

I have one further question.
The whole purpose for using player.pl is so I can determine the player level.

Lets say I add Event_Zone in the original player.pl (the one in templates).
From your snippet, it signals the individual zone controller and it carries out the functions.

How do I pass along the user level info to the zone controller?

Am I back to 1000 lines because every 5 levels is a different signal?

For sake of argument.

I would prefere the player .pl (in templates using EVENT_ZONE)
to sense what zone and player level then pass both of those on to the zone controller.

Is it possible?

Aardil
Reply With Quote
  #6  
Old 02-23-2018, 08:15 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

You can pass any information on to the external script via the use of @ARGV, as shown below.

Code:
my $player = "YoMomma";
my $zonesn = "butcher";

# current full working directory
( my $cwd = $0 ) =~ s/(?:(?!\\|\/)\S)+$//;

# you'll want to add some sanity checks to make sure you have valid data here
sub EVENT_ENTERZONE
{

	# hash with zonesn as keys and external scripts to run for the zone
	my %signal_zone = (
		butcher => "signal_butcher.pl",
		cauldron => "signal_cauldron.pl"
	);

	{
		local @ARGV = ($player);
		do "$cwd$signal_zone{$zonesn}";
	}
}

EVENT_ENTERZONE();
Above code calls the following (signal_butcher.pl located in the same folder):
Code:
print $ARGV[0];
Printed result:
Code:
YoMomma
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;

Last edited by c0ncrete; 02-23-2018 at 08:15 PM.. Reason: typo
Reply With Quote
Reply

Thread Tools
Display Modes

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 07:58 PM.


 

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