|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quests::Q&A This is the quest support section |
08-14-2017, 07:26 PM
|
|
Discordant
|
|
Join Date: May 2016
Location: Under a rock
Posts: 290
|
|
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
|
|
|
|
08-15-2017, 10:59 PM
|
|
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
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.
|
|
|
|
08-16-2017, 01:53 AM
|
|
Discordant
|
|
Join Date: May 2016
Location: Under a rock
Posts: 290
|
|
Quote:
Originally Posted by ghanja
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
|
08-16-2017, 06:34 AM
|
|
Discordant
|
|
Join Date: May 2016
Location: Under a rock
Posts: 290
|
|
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.
|
08-16-2017, 12:05 PM
|
|
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
Please provide the code you're using. Smart matching should very much work.
|
08-16-2017, 03:27 PM
|
|
Discordant
|
|
Join Date: May 2016
Location: Under a rock
Posts: 290
|
|
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);
}
}
|
08-16-2017, 04:54 PM
|
|
Developer
|
|
Join Date: Dec 2012
Posts: 515
|
|
Thats broke.. a single "=" just sets a variable to a value.
|
08-16-2017, 05:22 PM
|
|
Discordant
|
|
Join Date: May 2016
Location: Under a rock
Posts: 290
|
|
Quote:
Originally Posted by NatedogEZ
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
|
|
|
|
08-16-2017, 08:58 PM
|
|
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
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.
|
|
|
|
08-16-2017, 10:03 PM
|
|
Discordant
|
|
Join Date: May 2016
Location: Under a rock
Posts: 290
|
|
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
|
08-17-2017, 09:23 AM
|
|
Discordant
|
|
Join Date: May 2016
Location: Under a rock
Posts: 290
|
|
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
|
08-17-2017, 03:33 PM
|
|
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
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.
|
08-18-2017, 11:24 AM
|
|
Discordant
|
|
Join Date: May 2016
Location: Under a rock
Posts: 290
|
|
Quote:
Originally Posted by ghanja
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
|
|
|
|
08-18-2017, 12:00 PM
|
|
Discordant
|
|
Join Date: May 2016
Location: Under a rock
Posts: 290
|
|
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
}
|
|
|
|
08-18-2017, 09:40 PM
|
|
Dragon
|
|
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
|
|
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.
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 01:22 PM.
|
|
|
|
|
|
|
|
|
|
|
|
|