Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Quests

Archive::Quests Archive area for Quests's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #1  
Old 02-25-2004, 12:37 PM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default perl quest EMU simulator

Hello,

here is a small thing that can be used to test and debug perl quests. i hope this can be useful.

It is a perl script that loads and run perl quests. It understands some basic commmands like #zone, #listnpcs, ... and allows to simulate quests much like the server. You can use it interactive (perl -w itest.pl), or batch ('cat myscript.txt | perl -w itest.pl').



There are a few special commmands (to simulate GUI interaction):
!target <id> ; selects a target
!give <item> <item> ; ... is giving an item
!givecash <cp> <sp> <gp> <pp> ; is giving cash
!attack ; make you attack the npc
!echo (on|off) ; allows echo on / off of commands, for batch use
!timer ; triggers the timer. Note there is no real timing, quest::settimer and quest::stoptimer only give you information messages
!whoami give information about the vars you export (charid, uguild, race, name, ...)
!perl <foo bar> execs the perl script 'foo bar'. e.g. !perl $name="my new name" changes your name
!verbose <0-9> ; changes verbose level. Useful for debugging

!edit <filename> edits filename. It uses the EDITOR env variable (or vi if not set) to launch editor. if no filename is given, the quest file for current target is edited. if no such file, edits a new one. If no target, ...
Note : quests are reloaded before each event is triggered. So editing a quest file and triggering an event triggers the new event directly.

#kill, #zone, #level, #viewnpctype, #listnpcs, #npcstats, and
/say, /shout, /emote, /ooc, /gsay /quit, and maybe a few others are already in the simulator.

simple quest::foo functions are done. Look at the quest.pl file if you experience something strange.


To run it, you need :
db.ini, quest directory tree, the various plugin.pl and default.pl files
and the files ./itest.pl, ./EQ/dbaccess.pl and ./quest.pl from the archive there

The simulator is read-only on the DB, EXCEPT for quest_globals, that get affected

if you want color, make sure you have Term::ANSIColor package in your perl INC, else simply uncomment first lines in itest.pl

To change your character's info, alter the variables in the beginning of the itest.pl file,or do a command like
Code:
!perl $ulevel=23
Below are a few scripts that should work with ~std~ DB (i think it's MW_052 or ...)

for example
Code:
!verbose 1
!echo on
#zone freporte
!target 5482
!attack
#kill
!target 1221
Hail
Howdy, today ?
!give 18745
will produce :

Code:
EQEmu test >!verbose 1
verbose level now : 1
EQEmu test >!echo on
EQEmu test >#zone freporte
 changing to zone freporte
Current zone is now : East Freeport
EQEmu test >!target 5482
EQEmu test >!attack
Zamel shouts 'Hey! Brent da Kopy attacked me.'
EQEmu test >#kill
Zamel shouts 'I'll get you back Brent da Kopy!'
EQEmu test >!target 1221
EQEmu test >Hail
Elisi_Nasin says, 'Listen. this is a pretty busy [operation] I run here.  I certainly don't have any spare time to sit around and chit-chat with you all day. got it?'
EQEmu test >Howdy, today ?
EQEmu test >!give 18745
Elisi_Nasin says, 'Welcome to the Coalition of Tradesfolk underground. We like to keep a low profile around here and not draw any unneeded attention to our operations. you following me? I hope so. for your sake. Anyways. Nestral T'Gaza is in charge with helping out our newest members. Go see her as soon as you get a chance.'
you receive 1 items of type 13568, aka Brown Faded Tunic*
You gain experience (100)
other example :
Code:
; testing some system calls

!echo on
!verbose 1
#zone qeynos
!target 205
/say hail
!target 5482
Hail
What aqueducts ?
What beasts ?
!give 13713
/ooc why do NPCs never say goodbye ?
Farewell
#zone 3
/quit
[/code]
Reply With Quote
  #2  
Old 02-25-2004, 02:13 PM
Scorpious2k's Avatar
Scorpious2k
Demi-God
 
Join Date: Mar 2003
Location: USA
Posts: 1,067
Default

This looks really great!!

I mentioned it to Tark (our quest writer) and he just ran to his computer to get it
__________________
Maybe I should try making one of these servers...
Reply With Quote
  #3  
Old 02-25-2004, 02:31 PM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

Glad if it could help. Let me know if it works fine for you (i did not test it under Win, only unix).

There might be (read 'there must be') some issues as i didn't get all knowledge of events. As a start, it was mainly intended to debug perl scripts (i.e. check syntax, and check that everything gets called).

Some updates and fixes :
changed the package scann that was giving confusing messages like "qst1234::EVENT_SAY = <undefined>"
fixed issues with setglobal and delglobal DB calls
setup quest::settimer, quest::stoptimer, quest::setsky,quest::movepc

The above link has been updated

There is the 'beggerprince' quest input

Code:
; this plays a bit with the quest. NB alter the 205 npcid to reflect the id of qeynos2 npc, or vice versa
!perl $name="Kronnuzic the bald";
!perl $race=1;
!perl $class=1;
!perl $userid=6354;
!whoami
!verbose 1
#zone qeynos2
!target 205 ;; that's the beggerprince ID
/say Hail
; give 10 copper
!givecash 10 0 0 0
; give again ... greed is a bad habit
!givecash 0 0 0 10
/ooc damn !
!perl quest::delglobal("beggerprince")
!givecash 0 0 0 10
/ooc that's better, let's move to oasis
#zone oasis
!target 61 ; that's the brothers NPC ID
hail
yes, i'll help you
!givecash 0 0 1 0
/ooc but that's not the type of troll i am, now i kill him
!attack
!verbose
#kill
!verbose 1
/ooc now let's go back to our prince
#zone qeynos2
!target 205 ; back to 205
/hail
#quit
Code:
loading plugins
Subroutine handler redefined at (eval 8) line 1.
[4]plugin::calc = <not a scalar deref>
[4]plugin::handler = <not a scalar deref>
[4]plugin::version = <not a scalar deref>
[4]plugin::SERVER = <not a scalar deref>
EQEmu test >!perl $name="Kronnuzic the bald"
EQEmu test >!perl $race=1
EQEmu test >!perl $class=1
EQEmu test >!perl $userid=6354
EQEmu test >!whoami
Current user :
charid : 5432
uguildid : 0
ulevel : 65
deity : 201
userid : 6354
name : Kronnuzic the bald
uguildrank : 0
race : 1
class : 1
EQEmu test >!verbose 1
verbose level now : 1
EQEmu test >#zone qeynos2
 changing to zone qeynos2
Current zone is now : North Qeynos
EQEmu test >!target 205
EQEmu test >/say Hail
Use of uninitialized value in numeric eq (==) at (eval 29) line 3.
Use of uninitialized value in numeric eq (==) at (eval 29) line 3.
Use of uninitialized value in numeric eq (==) at (eval 29) line 3.
Barthal says, 'Do you have some loose change for a gentleman who has had some bad luck?'
EQEmu test >EQEmu test >
!givecash 10 0 0 0
Use of uninitialized value in numeric eq (==) at (eval 47) line 32.
Use of uninitialized value in numeric eq (==) at (eval 47) line 32.
Use of uninitialized value in numeric eq (==) at (eval 47) line 32.
Argument "" isn't numeric in numeric ne (!=) at (eval 47) line 59.
Argument "" isn't numeric in numeric ne (!=) at (eval 47) line 59.
Argument "" isn't numeric in numeric ne (!=) at (eval 47) line 63.
Argument "" isn't numeric in numeric ne (!=) at (eval 47) line 63.
Argument "" isn't numeric in numeric ne (!=) at (eval 47) line 67.
Argument "" isn't numeric in numeric ne (!=) at (eval 47) line 67.
Argument "" isn't numeric in numeric ne (!=) at (eval 47) line 71.
Argument "" isn't numeric in numeric ne (!=) at (eval 47) line 71.
Barthal says, 'I must confess... I am not a begger. I am a prince.'
Barthal says, 'I have been seeking a generous person. Until now I have failed.'
Barthal says, 'You have restored my faith in the kindness of others.'
Barthal says, 'Let me show you my gratitude.'
you receive 0 plat, 10 gold, 0 silver and 0 copper
Barthal says, 'Here is 100 times the money you gave me'
Barthal says, 'thank you so much for showing me that goodness is not gone'
faction #101 changed by 500.
EQEmu test >EQEmu test >
!givecash 0 0 0 10
Barthal says, 'Ahhhhhhh! More kindness from my friend!'
Barthal says, 'and this time I will accept your gift and pass it on to the poor and needy'
Barthal says, 'just as I know you would want it.'
faction #101 changed by 100.
Barthal says, 'thank you so much for showing me that goodness is not gone'
faction #101 changed by 500.
EQEmu test >/ooc damn !
Kronnuzic the bald says out of character 'damn !'
EQEmu test >!perl quest::delglobal("beggerprince")
EQEmu test >!givecash 0 0 0 10
Use of uninitialized value in numeric eq (==) at (eval 101) line 32.
Use of uninitialized value in numeric eq (==) at (eval 101) line 32.
Use of uninitialized value in numeric eq (==) at (eval 101) line 32.
Argument "" isn't numeric in numeric ne (!=) at (eval 101) line 59.
Argument "" isn't numeric in numeric ne (!=) at (eval 101) line 59.
Argument "" isn't numeric in numeric ne (!=) at (eval 101) line 63.
Argument "" isn't numeric in numeric ne (!=) at (eval 101) line 63.
Argument "" isn't numeric in numeric ne (!=) at (eval 101) line 67.
Argument "" isn't numeric in numeric ne (!=) at (eval 101) line 67.
Argument "" isn't numeric in numeric ne (!=) at (eval 101) line 71.
Argument "" isn't numeric in numeric ne (!=) at (eval 101) line 71.
Barthal says, 'I must confess... I am not a begger. I am a prince.'
Barthal says, 'I have been seeking a generous person. Until now I have failed.'
Barthal says, 'You have restored my faith in the kindness of others.'
Barthal says, 'Let me show you my gratitude.'
you receive 1000 plat, 0 gold, 0 silver and 0 copper
Barthal says, 'Here is 100 times the money you gave me'
Barthal says, 'thank you so much for showing me that goodness is not gone'
faction #101 changed by 500.
EQEmu test >/ooc that's better, let's move to oasis
Kronnuzic the bald says out of character 'that's better, let's move to oasis'
EQEmu test >#zone oasis
 changing to zone oasis
Current zone is now : Oasis of Marr
EQEmu test >!target 61
EQEmu test >hail
Found = in conditional, should be == at (eval 142) line 44.
Found = in conditional, should be == at (eval 142) line 55.
Anehan_Treol says, 'Do you have some loose change for a gentleman who has had some bad luck?'
EQEmu test >yes, i'll help you
Found = in conditional, should be == at (eval 160) line 44.
Found = in conditional, should be == at (eval 160) line 55.
Bareword found where operator expected at (eval 176) line 1, near "'yes, i'll"
        (Missing operator before ll?)
Use of uninitialized value in pattern match (m//) at (eval 160) line 3.
Use of uninitialized value in pattern match (m//) at (eval 160) line 3.
Anehan_Treol says, 'Go away and leave me alone in my misery.'
EQEmu test >!givecash 0 0 1 0
Found = in conditional, should be == at (eval 178) line 44.
Found = in conditional, should be == at (eval 178) line 55.
Argument "" isn't numeric in numeric ne (!=) at (eval 178) line 24.
Argument "" isn't numeric in numeric ne (!=) at (eval 178) line 24.
Argument "" isn't numeric in numeric ne (!=) at (eval 178) line 28.
Argument "" isn't numeric in numeric ne (!=) at (eval 178) line 28.
Argument "" isn't numeric in numeric ne (!=) at (eval 178) line 32.
Argument "" isn't numeric in numeric ne (!=) at (eval 178) line 32.
Argument "" isn't numeric in numeric ne (!=) at (eval 178) line 36.
Argument "" isn't numeric in numeric ne (!=) at (eval 178) line 36.
Anehan_Treol says, 'May the gods bless you as you journey'
EQEmu test >/ooc but that's not the type of troll i am, now i kill him
Kronnuzic the bald says out of character 'but that's not the type of troll i am, now i kill him'
EQEmu test >!attack
Found = in conditional, should be == at (eval 204) line 44.
Found = in conditional, should be == at (eval 204) line 55.
EQEmu test >!verbose
Use of uninitialized value in pattern match (m//) at itest.pl line 172, <> line 26.
usage : verbose <0-9>
EQEmu test >#kill
Found = in conditional, should be == at (eval 221) line 44.
Found = in conditional, should be == at (eval 221) line 55.
Anehan_Treol shouts 'My brother will avenge my death! There will be no mercy for the murderer Kronnuzic the bald!!'
EQEmu test >!verbose 1
verbose level now : 1
EQEmu test >/ooc now let's go back to our prince
Kronnuzic the bald says out of character 'now let's go back to our prince'
EQEmu test >#zone qeynos2
 changing to zone qeynos2
Current zone is now : North Qeynos
EQEmu test >!target 205
EQEmu test >/hail
Barthal says, 'I know you!! You are the one who killed my brother in Oasis!!'
Barthal shouts 'Die murderer!!'
EQEmu test >EQEmu test >
EQEmu test >
#quit
quitting ...
closing database connection...
connection closed
Reply With Quote
  #4  
Old 02-25-2004, 05:56 PM
samandhi's Avatar
samandhi
Demi-God
 
Join Date: Aug 2003
Posts: 1,056
Default

WOW! havent tested, but if it works as says, this will be a great tool.... Thanks smogo.
__________________

Quote:
Analysis paralysis will keep you from failing, but it will also keep you from succeeding.
  • L.L. CoolJ
Reply With Quote
  #5  
Old 02-26-2004, 02:34 AM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

thx for encouragments. This is still very alpha, and not foolproof. But it would do no harm afaik, so anyone who would give a try and report is welcome.

There is a new version avalaible (same link above)

added aliases : the !alias and !unalias allow to substitute in the command line. Usage is !alias <old> <new>, and !unalias <old>. It's better to single quote if you use regular expressions. Below is a sample :

Code:
!echo on
!alias foo bar
/ooc i say foo
!unalias foo
!unalias foo
!alias '\b\w{4}\b' **** ; get rid of 4 letter words. All of them
/ooc abcd is a 4 letter word ?
!alias god dieu
/ooc in french god is a 4LW
!alias short 'much longer this way'
/ooc i'm saying short
!unalias '\b\w{4}\b'
!alias show_variables perl foreach $clef (keys %uvars) { print "$clef => $uvars{$clef}\n"}
/ooc show_variables
!show_variables
gives out :


Code:
EQEmu test >!alias foo bar
[3]setting alias for foo to bar
EQEmu test >/ooc i say foo
Brent da Kopy says out of character 'i say bar'
EQEmu test >!unalias foo
[3]unaliasing foo
EQEmu test >!unalias foo
[3]unaliasing foo
EQEmu test >!alias '\b\w{4}\b' ****
[3]setting alias for \b\w{4}\b to ****
EQEmu test >/ooc abcd is a 4 letter word ?
Brent da Kopy says out of character '**** is a 4 letter **** ?'
EQEmu test >!alias god dieu
[3]setting alias for god to ****
EQEmu test >/ooc in french god is a 4LW
Brent da Kopy says out of character 'in french **** is a 4LW'
EQEmu test >!alias short 'much longer this way'
[3]setting alias for short to **** longer **** way
EQEmu test >/ooc i'm saying short
Brent da Kopy says out of character 'i'm saying **** longer **** way'
EQEmu test >!unalias '\b\w{4}\b'
[3]unaliasing '\b\w{4}\b'
EQEmu test >!alias show_variables perl foreach $clef (keys %uvars) { print "$clef => $uvars{$clef}\n"}
[3]setting alias for show_variables to perl foreach $clef (keys %uvars) { print "$clef => $uvars{$clef}\n"}
EQEmu test >/ooc show_variables
Brent da Kopy says out of character 'perl foreach $clef (keys %uvars) { print "$clef => $uvars{$clef}\n"}'
EQEmu test >!show_variables
charid => 5432
uguildid => 0
ulevel => 65
deity => 201
userid => 6543
name => Brent da Kopy
uguildrank => 0
race => 1
class => 1
As you see, it allows to define commands as aliases to simple perl scripts.

Other (minor) changes :
fixed /ooc color
$npcid and $mobid are now equivalent, as $mobid has no meaning in the simulator.

Todo :
some fixes ...
Also i'm looking for information on EVENT_SLAY, #attack, ... to define procs that trigger / handle them. Any link you know of would be appreciated.
Reply With Quote
  #6  
Old 02-28-2004, 12:44 PM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

updated :

- added internal mysql() function. You can call from prompt using :
Quote:
!perl mysql("select name, race, level from npc_id");
*** edited***
forgot to mention that u can use script variables in your queries (else it wouldnt be any better than plain mysql client). Just don't forget to quote strings :
Code:
!perl mysql("select count(id) from spawn2 where zone=\'$zonesn\'")
- changed default comment char to '##' instead of ';'. Now allows to use multiple perl commands on a single line. Useful for multi-line aliases

- detailled trace of plugin loadin'

todo :
- still different package name of default quest as compared to EQEMu. No impact on regular use of the simulator.
- finish quest:xxx() functions
- define basic combat sequence sub. Sthng like : upon attack/attacked, prompt for (N)PC dies / (P)layer dies / (A)uto / (D)isengage. Then trigger EVENT_DEATH, EVENT_SLAY, ... accordingly
***edited***
- alter $class. It is an id in the sim, should be a word as it is in EQEMu.
Reply With Quote
  #7  
Old 02-29-2004, 03:05 AM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

no bumping, just wrong manip :lol:.
Sry.
Reply With Quote
  #8  
Old 02-29-2004, 04:53 AM
Rogean's Avatar
Rogean
Administrator
 
Join Date: Jul 2003
Location: Massachusetts
Posts: 708
Default

[root@plain rogean]# perl ./itest.pl
reading user
reading host
reading password
reading database
user : ra
host : localhost
### --- be left "localhost" unless mysql is on a differant computer than world.exe.
database : ra
in quest library
done with quest library
:localhostt('ra
### --- be left "localhost" unless mysql is on a differant computer than world.e' (1) at EQ/dbaccess.pl line 25rver Host 'localhost
closing database connection...
Can't call method "disconnect" on an undefined value at EQ/dbaccess.pl line 343.
END failed--call queue aborted.
[root@plain rogean]#
__________________
EQEmulator Developer / Administrator
Reply With Quote
  #9  
Old 02-29-2004, 06:14 AM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

Quote:
done with quest library
:localhostt('ra
### --- be left "localhost" unless mysql is on a differant computer than world.e' (1) at EQ/dbaccess.pl line 25rver Host 'localhost
it has to do with the db.ini.
i could not reproduce the error, but it might extra space, or in the password (a special char, or extrra space, or EOL comment).

try removing leading / trailing space, all comments, or check with another pass.
To get better report, try after changing lines 19-21 in EQ/dbaccess.pl to :
Code:
foreach $var ( "user","host","database","password"){
  print "$var : >>>", $dbvars{"db".$var},"<<<\n";
}
Also try changing your db.ini to access default mysql TEST db. It should still break the simulator, but later in the code.

Code:
[Database]
host=localhost
user=test
password=test
database=test
compression=off
I'll try to improve parsing of db.ini if you get results.
Reply With Quote
  #10  
Old 03-05-2004, 01:34 PM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

There's a new version available, follow the same link above.

- $class now complies to EQEMu value, i.e. "Warrior", where it was "1" in previous version.
- upgraded parsing the db.ini file, #comments should be no problem now.
- preprocessed all say commands, so that quotes and dollar signs don't mess up, and u can use them in say.
Reply With Quote
  #11  
Old 03-23-2004, 03:11 PM
ryder911
Hill Giant
 
Join Date: Jun 2002
Posts: 212
Default

im a noob trying to learn perl lol. Where do i get the program? i didnt see a link or do you have to run it urself im a little confused. Probally cause im tired lol any help would be appreciated, please no flaming=)
__________________
Chris---
Reply With Quote
  #12  
Old 03-23-2004, 10:05 PM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

the link is in the first post. It's there :
http://perso.wanadoo.fr/afou/khalzed...s/itest.tar.gz
Reply With Quote
  #13  
Old 03-24-2004, 12:01 AM
ryder911
Hill Giant
 
Join Date: Jun 2002
Posts: 212
Default

Thanks smogo! I didnt see it last night i was tired and sick=( Your a big help and thanks for making the tool
__________________
Chris---
Reply With Quote
  #14  
Old 04-02-2004, 06:35 AM
smogo
Discordant
 
Join Date: Jan 2004
Location: 47
Posts: 339
Default

there is a quick fix to run the simulator on windows, for those who don't have *nix text utilities installed.

in EQ\dbaccess.pl file, in the first lines, comment out a block and add another, starting line 14 :
Code:
#foreach $var ( "user","host","password","database"){
# print "reading ",$var, "\n";
# #$dbvars{"db".$var}=`cat $dbinifile | egrep $var | sed 's/$var=//'`;
# $dbvars{"db".$var}=`cat $dbinifile | sed 's/#.*//' | egrep $var | sed 's/$var=
# chomp($dbvars{"db".$var});
#}
 
open(DBINI,$dbinifile);
while(<DBINI>){
  chomp;
  s/\#.*$//;
  if(m/(\w+)=(.+)/){
    print "setting $1 to $2\n";
    $dbvars{"db".$1}=$2;
  }
}
close(DBINI);
It should fix db access for win and still work in *nix.

Also, you need the DBI and DBD modules. install them like this :
Code:
C:>ppm
ppm>install DBI
... downloads and installs
ppm>install DBD::mysql
...This will return 2 results so at the prompt just
type 
...install again and it will install the first package
ppm>install
...downloads and installs package 1 DBD-mysql
Thanks StrangeBrew for the help
Reply With Quote
  #15  
Old 04-02-2004, 12:19 PM
KhaN's Avatar
KhaN
Dragon
 
Join Date: Mar 2004
Location: France, Bordeaux.
Posts: 677
Default

I have one problem.
1.Downloaded your file
2.Installed DBI and DBD My SQL
3.Bunch of errors (DB connect)

Should be because i dont understand this
Quote:
open(DBINI,$dbinifile);
while(<DBINI>){
chomp;
s/\#.*$//;
if(m/(\w+)=(.+)/){
print "setting $1 to $2\n";
$dbvars{"db".$1}=$2;
}
}
close(DBINI);
Sorry ...
__________________

Reply With Quote
Reply


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 12:12 AM.


 

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