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 08-14-2017, 07:26 PM
The_Beast's Avatar
The_Beast
Discordant
 
Join Date: May 2016
Location: Under a rock
Posts: 290
Default ENTERZONE Global Script

Just an idea i have up in the air in at the moment. Obviously an ENTERZONE sub in the global player would apply to
all zones. But there's a little glitch in my plan, because there is some zones I don't want the script to run in.
I could put the script in every zone player file, but global would be more practical. What I am looking at
is running it in every "cancombat" zone only. (I am working with perl, not lua). Any ideas ? lol
Reply With Quote
  #2  
Old 08-15-2017, 10:59 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Several ways, varying in complexity and/or "work".

1. Likely the easiest unless you want to go at the source to add a new export, is:
Code:
sub EVENT_ENTERZONE {
    my @noncombatzones = ("freeportn", "runnyeye", "nexus");
    if ($zonesn ~~ @noncombatzones) {
          ## do nothing
    } else {
          ## do something
    }
}
Or some variance of the above. I chose non-combat zones in case there are fewer of them than combat zones.

2. Read from the DB using DBI (though this would of course create a potential for many calls to the DB):

Code:
sub readcombat {
    my $read_zone = $_[0];
    $connect = plugin::MySQL_Connect();
    $query = "
        SELECT `cancombat`
        FROM zone
        WHERE `short_name` = ? LIMIT 1
    ";
    $qh = $connect->prepare($query);
    $qh->execute($read_zone);
    while (@row = $qh->fetchrow_array()){
        return $row[0];
    }
    return;
}

return 1;
Tossing the above in either an existing plugin file or creating its own. Using it:

Code:
sub EVENT_ENTERZONE {
    if (plugin::readcombat($zonesn)) {
       ## do this when combat is 1 (aka true)
    } else {
       ## do this when combat is 0 (aka false)
    }
}
3. Edit the source to add an LUA/Perl export and, I've been away again too long from C++ to do this on the spot and I wasn't nearly as proficient at it as some others (Akka, Kingly, demon, hell any of the dev team)

So there's a start I hope.
Reply With Quote
  #3  
Old 08-16-2017, 01:53 AM
The_Beast's Avatar
The_Beast
Discordant
 
Join Date: May 2016
Location: Under a rock
Posts: 290
Default

Quote:
Originally Posted by ghanja View Post
Several ways, varying in complexity and/or "work".

1. Likely the easiest unless you want to go at the source to add a new export, is:
Code:
sub EVENT_ENTERZONE {
    my @noncombatzones = ("freeportn", "runnyeye", "nexus");
    if ($zonesn ~~ @noncombatzones) {
          ## do nothing
    } else {
          ## do something
    }
}
Or some variance of the above. I chose non-combat zones in case there are fewer of them than combat zones.
Wow, thank you so much. This number 1. looks like an easy work, if it can work. There is definately not many
non-combat zones. Just the regular common ones, GH, GL, PoK, Nexus, etc., so this would make it more simplified.
I will check it tomorrow and let you know
Reply With Quote
  #4  
Old 08-16-2017, 06:34 AM
The_Beast's Avatar
The_Beast
Discordant
 
Join Date: May 2016
Location: Under a rock
Posts: 290
Default

Well tried it out ghanja and it works great. I tested it out with just a simple little "movepc" for the #do something, lol
But had to change your ~~ to == (took me a few minutes to realize it) :P
But thanks a million for your help. It opens up some options for me.
EDIT : Sorry, not completely working right, I just let it do the movepc once and figured it was working great.
It's not recognizing the nocombatzones. I set it to punt me to the nexus, but it does that even when in one of the
zones specified. But I'll keep working on it.
Reply With Quote
  #5  
Old 08-16-2017, 12:05 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Please provide the code you're using. Smart matching should very much work.
Reply With Quote
  #6  
Old 08-16-2017, 03:27 PM
The_Beast's Avatar
The_Beast
Discordant
 
Join Date: May 2016
Location: Under a rock
Posts: 290
Default

I just used what you had to test the function of it with a movepc.

Code:
sub EVENT_ENTERZONE {
    my @noncombatzones = ("freeportn", "runnyeye", "nexus");
    if ($zonesn = @noncombatzones) {
          ## do nothing
    }
    else {
        quest::movepc(152,0,0,-31);
    }
}
Reply With Quote
  #7  
Old 08-16-2017, 04:54 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

Thats broke.. a single "=" just sets a variable to a value.
Reply With Quote
  #8  
Old 08-16-2017, 05:22 PM
The_Beast's Avatar
The_Beast
Discordant
 
Join Date: May 2016
Location: Under a rock
Posts: 290
Default

Quote:
Originally Posted by NatedogEZ View Post
Thats broke.. a single "=" just sets a variable to a value.
Oh sorry, that's a lazy typo in the post, lol The one I was testing has ==
which I changed over from ghanja's ~~ cause it wasn't doing anything
Reply With Quote
  #9  
Old 08-16-2017, 08:58 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Code:
sub EVENT_ENTERZONE {
	my @noncombatzones = ("freportn", "runnyeye", "nexus");  ## type the zonesn of the non-combat zones (thus cancombat = 0)
	if ($zonesn ~~ @noncombatzones) {
		## this will happen if the zone they are in is one of the noncombatzones listed in the above array
	} else {
		## this will happen if the zone they are in is NOT one of the noncombatzones listed in the above array
		$client->Message(15, "You are being moved now");
		quest::movepc(152,0,0,-31);
	}
}
I had an extra E, the zonesn should be freportn not freeportn, there should be no issues with using the smart matching (i.e. ~~)

Yeah, Perl will throw a fit if you are doing a Perl -c script.pl on it, but, its syntax is fine.

I'm under the assumption you're putting this code in your /quests/global/global_player.pl so ensure to target your test toon, issue a #reloadquest and then zone somewhere other than the test zones (which will be every zone not listed in the @noncombatzones array).

That said, I would just use the plugin method, if you have the DBI ppm installed.
Reply With Quote
  #10  
Old 08-16-2017, 10:03 PM
The_Beast's Avatar
The_Beast
Discordant
 
Join Date: May 2016
Location: Under a rock
Posts: 290
Default

Yes, I caught that freportn spelling the first time, but I never tested with that zone anyway. I was zoning into cancombat zones,
such as butcher, misty, etc., but nothing was happening until I changed the ~~ to == (as I mentioned in my post above) Then it
would punt me to nexus, even zoning into a noncombat zone, (like runnyeye) or any zone, for that matter.
This time I copied and pasted your last one into global_player.pl (I have #reloadquest hotkey) I use all the time.
I've used the DBI for few things in the past, successfully, so I will look at using that instead. Thank You muchly
Reply With Quote
  #11  
Old 08-17-2017, 09:23 AM
The_Beast's Avatar
The_Beast
Discordant
 
Join Date: May 2016
Location: Under a rock
Posts: 290
Default

This problem was solved by the way. It was too much human error and not enough human air. :P Seems I had a little
extra curly } hiding in the global player file before I pasted ghanja's script in there to test. But it works great now.
Many Thanks to ghanja
Reply With Quote
  #12  
Old 08-17-2017, 03:33 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

I do believe this may fly (I always doubt things when it seems all too easy):

embparser.cpp

Replace line 1099 (as of current build) with:
Code:
	ExportVar(package_name.c_str(), "zonecancombat", zone->CanDoCombat());
}
Which, if I'm looking at everything right, should allow for a new exported variable of $zonecancombat

To use:
Code:
if ($zonecancombat) {
    ## do stuff for zones you CAN combat in
} else {
    ## do stuff for zones you can NOT combat in
}
Hopefully someone more intimately familiar with the source will come behind me and let us know otherwise or verify the above, either or.
Reply With Quote
  #13  
Old 08-18-2017, 11:24 AM
The_Beast's Avatar
The_Beast
Discordant
 
Join Date: May 2016
Location: Under a rock
Posts: 290
Default

Quote:
Originally Posted by ghanja View Post
I do believe this may fly (I always doubt things when it seems all too easy):

embparser.cpp

Replace line 1099 (as of current build) with:
Code:
	ExportVar(package_name.c_str(), "zonecancombat", zone->CanDoCombat());
}
Which, if I'm looking at everything right, should allow for a new exported variable of $zonecancombat

To use:
Code:
if ($zonecancombat) {
    ## do stuff for zones you CAN combat in
} else {
    ## do stuff for zones you can NOT combat in
}
Hopefully someone more intimately familiar with the source will come behind me and let us know otherwise or verify the above, either or.
This compiled fine with no errors, I'll let you know if it works, lol
Reply With Quote
  #14  
Old 08-18-2017, 12:00 PM
The_Beast's Avatar
The_Beast
Discordant
 
Join Date: May 2016
Location: Under a rock
Posts: 290
Default

No go on that, but, this is what I did to compile.(as per the code posted)
Code:
void PerlembParser::ExportZoneVariables(std::string &package_name) {
	if (zone) {
		ExportVar(package_name.c_str(), "zoneid", zone->GetZoneID());
		ExportVar(package_name.c_str(), "zoneln", zone->GetLongName());
		ExportVar(package_name.c_str(), "zonesn", zone->GetShortName());
		ExportVar(package_name.c_str(), "instanceid", zone->GetInstanceID());
		ExportVar(package_name.c_str(), "instanceversion", zone->GetInstanceVersion());
		TimeOfDay_Struct eqTime;
		zone->zone_time.GetCurrentEQTimeOfDay( time(0), &eqTime);
		ExportVar(package_name.c_str(), "zonehour", eqTime.hour - 1);
		ExportVar(package_name.c_str(), "zonemin", eqTime.minute);
		ExportVar(package_name.c_str(), "zonetime", (eqTime.hour - 1) * 100 + eqTime.minute);
		ExportVar(package_name.c_str(), "zoneweather", zone->zone_weather);
		ExportVar(package_name.c_str(), "zonecancombat", zone->CanDoCombat());
	}
}
Then added to global_player :
Code:
sub EVENT_ENTERZONE

  if ($zonecancombat) {
  quest::movepc(152,0,0,-31);
  } else {
    ## do stuff for zones you can NOT combat in
}
Reply With Quote
  #15  
Old 08-18-2017, 09:40 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Bah, figured it was just too easy. I'll have another look at the source. Havent had eyes in it for awhile, so is a re-re-relearn type of deal for me.
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 03:10 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