Guide to the Perl Quest system *updated 16/02/2004*
UPDATED LIST OF FUNCTIONS AVALIABLE HERE:
http://www.arnold11.karoo.net/Perl.htm Updated 16th Feb 2004 by Monrezz WARNING: This guide may or may not be obsolete in some areas. -Cisyouc This is for EQEMu 0.5.3+ With Perl Enabled If you do not see the following in zone.exe when you boot it up you do NOT have Perl Enabled ones. [Status] Loading embedded perl [Status] Loading perlemb plugins. Also, make sure you have installed Perl. [See Below] Saving Quests Save your quests as a .pl This can be done by going into Notepad --> Save As --> All File Types --> "npcid.pl" Quests should be saved in $EQEmuDir$/quests/zonesn/NPCID.pl Server-wide default quest in: $EQEmuDir$/quests/default.pl Zone-wide default quests in: $EQEmuDir$/quests/zonesn/default.pl The NPCID can be found in the database using a tool such as FQAdmin, Quest Editor or Mysql-Front, Default quests are attached to all NPCs that do not already have a quest file associated with it. Commands - Comments - Anything after an # is a comment, and is ignored by the parser. This is useful for leaving notes if you have more than one person working on a quest. Example of a comment: # Monrezz: Next few lines are for the Hail response. - Events - sub EVENT_SAY - Triggered when a mob is targeted and the player types something. sub EVENT_ITEM - Triggered when an item is turned into the mob via trade. sub EVENT_DEATH - Triggered when the NPC dies. sub EVENT_ATTACK - Triggered when the NPC is attacked. sub EVENT_SPAWN - Triggered when the NPC spawns. sub EVENT_TIMER - Triggered by a "quest::starttimer()" sub EVENT_SLAY - Triggered whenever an NPC kills someone. sub EVENT_WAYPOINT - Triggers when the mob reaches a waypoint. - Variables - All speaking responses are included in a $text variable: if ($text=~/Hail/i) Note the /i. This means it is case insensitive. It is always better to include this. $text =~/Hello/ - Would match "Hello", but not "hello". $text =~/hello/ - Would match "hello", but not "Hello". $text =~/hello/i - Would match "Hello" and "hello". $text =~/me/ - Would match the "me" in name. $text =~/\bme\b/ - Would not match the "me" in name. The "\b" means there must not be text next to the match so "me" must be by itself. $text =~/^me$/i - Would only match if me is the only text said. The "^" tells it it must be the first thing said and the "$" tells it it must be the last thing. This uses Perl Regular Expression Matching. See one of the following sites for more info: http://aspn.activestate.com/ASPN/doc...rlrequick.html http://aspn.activestate.com/ASPN/doc...perlretut.html http://www.erudil.com/preqr.pdf - Identifiers - $name - Returns the name of the user that triggered the Event. $race - Returns the race of the user that triggered the Event. $class - Returns the class of the user that triggered the event. $userid - Returns the ID of the user that triggered the Event. $ulevel - Returns the level of the user that triggered the Event. $uguildid - Returns the ID of the guild of the user that triggered the Event. $uguildrank - Returns the guild rank of the user that triggered the Event. $mname - Returns the Mob's name. $mobid - Returns the NPCTypeID of the mob that the user triggered the Event on. $mlevel - Returns the level of the mob that the user triggered the Event on. $faction - Returns the faction level number of the user with the mob. 1: Ally 2: Kindly 3: Warmly 4: Amiably 5: Indifferent 6: Apprehensive $zonesn - Returns the zone short name that the Event occured in. $zoneln - Returns the zone long name that the Event occured in. $status - Returns the account status of the user that triggered the Event. $item1 - The item# in the first slot. $item2 - The item# in the second slot. $item3 - The item# in the third slot. $item4 - The item# in the fourth slot. $itemcount{itemid} - $itemcount{1001} would return 2 if the user turned in 2 1001 items. $copper - returns the number of copper coins given tothe mob. $silver - returns the number of silver coins given tothe mob. $gold - returns the number of gold coins given tothe mob. $platinum - returns the number of platinum coins given to the mob. - Commands - Commands require a semicolon ";" at the end of each one. UPDATED VERSION AVALIABLE HERE: http://www.arnold11.karoo.net/Perl.htm quest::say("Text"); - Mob will say "Text". quest::emote("Text"); - Mob will emote "Text". quest::shout("Text"); - Mob will shout "Text". quest::spawn(npc_type,grid,guildwarset,x,y,z); - Spawn "npc_type" on "grid" with "guildwarset" at "x","y","z". quest::echo("Text"); - Echoes specified text to console. quest::summonitem(itemid); or quest::summonitem(itemid,charges); - Summons "itemid" to user that triggered Event. Charges is the number of charges, or number of items in the stack depending on the item type, it is also optional. quest::castspell(id,spellid); - Casts "spell" on entity with "id". quest::selfcast(spellid); - Forces client to cast spell on themself (useful for self only and group effect spells). quest::depop(); - Mob will de-spawn. quest::cumflag(); - Flag 50 for mob will increase by 1. quest::flagnpc(flag,flag_value); - Sets "flag" to "flag_value" for mob. quest::flagclient(flag,flag_value); - Sets "flag" to "flag_value" for client. quest::exp(amount); - Adds "amount" of exp to user's exp amount. quest::level(newlevel); - Sets user level. quest::safemove(); - Moves user to zone's safe x,y,z. quest::rain(1/0); or quest::snow(1/0); - Makes it rain or snow in zone. quest::givecash (cop.,silv.,gold,plat); - Gives client coin. quest::pvp("on/off"); - Sets pvp on/off for user. quest::doanim(anim_num); - Mob will do animation for "anim_num". quest::addskill(skill,value); - Increases "skill" by "value" for user. quest::me("text"); - Does a name-less emote, me("The ground below you begins to shake"). quest::faction(faction_id,value); - Give player faction "value" with "faction_id". quest::setguild(guild_id,rank); - Add player to "guild_id" with a "rank". quest::rebind(zone id,x,y,z) - Binds the user that triggered the Event to the provided zone and loc. quest::flagcheck - Checks the value of a quest flag. quest::write quest::settime(hour,minute) - Sets zone time of day. Sky/lighting changes acordingly. quest::setsky(0-255) - changes the sky. quest::settimer(timerID,seconds) - Starts timer for use with EVENT_TIMER You can have multiple "timerID"'s that trigger every "seconds". quest::stoptimer(timerID) - stops the timer "timerID". quest::settarget(type,ID) - Quest mob targets "ID" by "type" = npctype or entity. quest::follow(ID) - Mob starts to follow "ID". quest::sfollow() - turns off follow. quest::movepc(zoneid,x,y,z) - Moves the user that triggered the Event to the provided zone and loc. quest::gmmove(x,y,z) - Moves the user that triggered the Event to the provided loc. quest::movegrp(zoneid,x,y,z) - Moves the user's Group that triggered the Event to the provided zone and loc. quest::setallskill(0-252) - Sets all skills to value. quest::attack("name") - Attacks "name". quest::save() - Saves player data? see note quest::setglobal(varname,value,options,duration) - Sets a variable for the current quest mob. See Tark's post quest::targlobal(varname,value,duration,npcid,char id,zoneid) - Set a variable for any mob. See Tark's post quest::delglobal(varname) - delete a variable for the quest mob. See Tark's post - If Statements - Syntax: if($variable1 [operator] $variable2){ quest::commands; } Operators: $1 == $2 : If variable $1 is the same as variable $2, carry on. $1 != $2 : If variable $1 is NOT the same as variable $2, carry on. $1 > $2 : If variable $1 is greater than variable $2, carry on. $1 < $2 : If variable $1 is less than variable $2, carry on. $1 >= $2 : If variable $1 is greater than or equal to variable $2, carry on. $1 <= $2 : If variable $1 is less than or equal to variable $2, carry on. In this example, if the user is a smaller level than the mob the mob says "I'm a higher level than you!" Code:
if($ulevel < $mlevel){ $1 || $2 : If $variable1 or $variable2 are true, carry on. In this example, if the user is a smaller level than the mob the mob and the mob is at least level 10, the mob says "I'm higher than you.". Note: You must put all calculations in brackets "(",")", otherwise they wil be calculated in the wrong order. Code:
if(($ulevel < $mlevel) && ($mlevel >=10)){ Hail script: Code:
Code:
sub EVENT_SAY Code:
sub EVENT_ITEM Code:
sub EVENT_SAY Code:
sub EVENT_DEATH Code:
sub EVENT_SAY Code:
sub EVENT_SAY { Code:
sub EVENT_SAY Test script for testing $variables: Code:
sub EVENT_SAY { Code:
sub EVENT_SAY Installing Perl Download Perl 5.8, Then install using the default settings for everything. Now reboot so path changes take affect. Congratulations, Perl is installed. Installing IO::Scalar If you don't already have it, download nmake.exe (save with .exe extension). Copy it into your perl\bin directory. Then type the following in a DOS window: Code:
perl -MCPAN -e shell Code:
install IO::Scalar Problems If perl isn't installed properly the zone windows will disapear after starting up. If you followed all the above steps correctly, make sure you have a copy of "Perl58.dll" in your "C:\Perl\bin" directory. If there is a copy there, search your computer for all other copies of it and delete them. Also note it is Perl58, not 56. To test if IO::Scalars is installed type the following in a DOS window: Code:
perl -MIO::Scalar -e "print 'Installed'" Scalar.pm Scalar.pm.html ScalarArray.pm Last Edited by Monrezz on 16th February 2004. Note: This is NOT a support thread. Please post help questions in the forum. |
Great Work!!!
|
Thanks :P
|
Perl CPAN.pm bundle file errors
Question re-posted in the support forum. Sorry.
|
aight i thought i should clarify this seeing as some people may (and have) been getting confused by it.
in the example quests: Hail script Multiple responses NPC Shouting and Emoting Bone Chips there is an error this is how they should look: Hail Script: Code:
sub EVENT_SAY Code:
sub EVENT_SAY Code:
sub EVENT_SAY Code:
sub EVENT_SAY it should be written like this Code:
if($text=~/Blah/i) Code:
if($text~=/Blah/i) just thought i should point this out to the people who wish to learn PERL quest writing... |
Quote:
How did that happen! :oops: Fixed it now, hopefully that will reduce some confusion. Thanks x-scythe |
Just another poke for ya, now and again you use:
Code:
quest::spawnitem(x); Thanks for the nice list of everything. :P |
Dave987: Nope, just a mistake. It is fixed in the top post now.
|
Scribespells
Ok, I've been using the heck out of this so great job! Lol I never knew a lick of perl writing before reading this post. Now I have a question. My server (server I'm writing quests for that is) needs the Scribespell NPC fixed (he got the source from another working server's scribespell npc but it wont work for him) so I was going to rewrite it, but I see in your post about setallskill(0-252) etc etc, would it be the same for spells? ie
sub EVENT_SAY { if ($text=~ /Hail/i){quest::say("Hello, would you like your [spells] scribed?");} if ($text=~ /spells/i){quest::say("Scribing your spells $name!");} quest::scribespells(65) } Would that work? Thanks ahead of time :)) Nerakas al`Dragnor |
sub EVENT_SAY
{ if ($text=~/Hail/i) { quest::say("Hello, would you like your [spells] scribed?"); } if ($text=~/spells/i) { quest::say("Scribing your spells $name!"); quest::scribespells(65); } } ^^ |
Woot, thanks Cripp! :D
Lol see? I'm learning quickly =P Just needed a guide to teach me. Thanks for pointing out I forgot the last " ; } " and the spaces. I'll write it out and send it to my server op and hope he impliments it soon :wink: Nerakas |
Could I do it?
I've got a server running (5.9DR2 Perl Enabled) for my friends and I. Would it be at all possible (although a lot of coding) for me to set up an NPC that if you hail him he gives you the correct set of newb armor just to make things simple, rather than all the quests on Live.
*EDIT* Haven't waited for a response haha, but also, could you have something like the following work Code:
sub EVENT_SAY |
yep...
it would be very simple too. Read around there are plenty of posted code snippets for giving out items in quests. I am not sure about a few things you are doing. For instance i have never checked versus race class etc. but i hear EQ is the proper way to do it instead of = Code:
sub EVENT_SAY |
Thanks
Thanks very much. I'll finish up a couple more classes for the Dark Elves and give it a shot
|
for future reference, when you are using '&&' you need to group then using parentheses.
Ex. Code:
if(($race eq 'Dark elf') && ($class eq 'Enchanter')) |
Alright
Well, this isn't entirely about quests, but whenever I use Mysql-Front and edit data for my dbs (wanted everyone to start in FP at these certain zone coords) it seems to revert back to the previous stuff whenever I exit the program. Does anyone know how to fix this? Also, the quests that I associate with a certain mob i made (did the #Npcspawn create and #npcspawn add) do not work. They are saved to C:\Eqemu\Quests\freportw\soandso.pl. Is this correct?
|
I'm having a small problem with this.
I have everything running, I'm testing the soulbinder script, I added it ot the NPC, the NPC respond to the hail, I tell him to bind my soul, he casts the spell on me. But I'm never really bound, the spell just doesnt work. I've tried with other spells and is the same thing. I'm running 0.5.9-DR2. Any ideas ? |
When I was playing with soulbinders, castspell didn't work, as you described, so I used selfcast which, seemed to work OK. (Been a while since I played with this though). IIRC I had the same problem with translocators, I had to use selfcast rather than castspell.
Code:
sub EVENT_SAY { |
Aye we had that issue too. Will probably be looked at and fixed for the WR release.
|
problem installing
when i do install IO::Scalar i get the following:
cpan> install IO::Scalar Going to read \.cpan\sources\authors\01mailrc.txt.gz Going to read \.cpan\sources\modules\02packages.details.txt.gz Warning: Your \.cpan\sources\modules\02packages.details.txt.gz does not contain a Line-Count header. Please check the validity of the index file by comparing it to more than one CPAN mirror. I'll continue but problems seem likely to happen. Warning: Your \.cpan\sources\modules\02packages.details.txt.gz does not contain a Last-Updated header. Please check the validity of the index file by comparing it to more than one CPAN mirror. I'll continue but problems seem likely to happen. Going to read \.cpan\sources\modules\03modlist.data.gz Can't locate object method "data" via package "CPAN::Modulelist" (perhaps you fo rgot to load "CPAN::Modulelist"?) at (eval 19) line 1. CPAN::Index::rd_modlist('CPAN::Index','\.cpan\sour ces\modules\03modlist. data.gz') called at C:/Perl/lib/CPAN.pm line 3129 CPAN::Index::reload('CPAN::Index') called at C:/Perl/lib/CPAN.pm line 67 5 CPAN::exists('CPAN=HASH(0x1cc0634)','CPAN::Module' ,'IO::Scalar') called at C:/Perl/lib/CPAN.pm line 1842 CPAN::Shell::expandany('CPAN::Shell','IO::Scalar') called at C:/Perl/lib /CPAN.pm line 2078 CPAN::Shell::rematein('CPAN::Shell','install','IO: :Scalar') called at C: /Perl/lib/CPAN.pm line 2165 CPAN::Shell::install('CPAN::Shell','IO::Scalar') called at C:/Perl/lib/C PAN.pm line 201 eval {...} called at C:/Perl/lib/CPAN.pm line 201 CPAN::shell() called at -e line 1 cpan> What can be happening???? tks |
Has anyone taken a look at the castspell() function yet?
Still does the same thing, nada. ^.^ |
thats because castspell() isnt a function.
cast() -- npc casts a spell selfcast() -- Player casts spell on self. |
Is there a way to access a loot table instead of just summoning a set item? Or maybe for example, a perl function that rolls a "d20" and bases the quest reward on the result???
-Sarepean |
Curious if anyone knows anything about the new Perl system, the one that implements commands.pl and XS.
I'm wondering what added features are not discussed, and how to do commands. Mainly, what methods and objects are available? I did some source-diving and found things like "Client::<method>", but they give me errors, as does the "$client->Method" way. |
For more information on the updated perl quest system, look for posts by fathernitwit since he is the one currently reworking it:
http://www.eqemulator.net/forums/viewtopic.php?t=18147 http://www.eqemulator.net/forums/viewtopic.php?t=18404 http://www.eqemulator.net/forums/viewtopic.php?t=18432 and also http://www.eqemulator.net/forums/viewtopic.php?t=18480 http://www.eqemulator.net/forums/viewtopic.php?t=18573 |
All times are GMT -4. The time now is 03:25 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.