PDA

View Full Version : perl quest EMU simulator


smogo
02-25-2004, 12:37 PM
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').

http://perso.wanadoo.fr/afou/khalzed-dur/tools/quests/itest.jpg

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 (http://perso.wanadoo.fr/afou/khalzed-dur/tools/quests/itest.tar.gz)

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 !perl $ulevel=23

Below are a few scripts that should work with ~std~ DB (i think it's MW_052 or ...)

for example

!verbose 1
!echo on
#zone freporte
!target 5482
!attack
#kill
!target 1221
Hail
Howdy, today ?
!give 18745


will produce :

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 :

; 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]

Scorpious2k
02-25-2004, 02:13 PM
This looks really great!!

I mentioned it to Tark (our quest writer) and he just ran to his computer to get it :-)

smogo
02-25-2004, 02:31 PM
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


; 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



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

samandhi
02-25-2004, 05:56 PM
WOW! havent tested, but if it works as says, this will be a great tool.... Thanks smogo.

smogo
02-26-2004, 02:34 AM
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 :

!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 :


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.

smogo
02-28-2004, 12:44 PM
updated :

- added internal mysql() function. You can call from prompt using :
!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 :
!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::xxxx() 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.

smogo
02-29-2004, 03:05 AM
no bumping, just wrong manip :lol:.
Sry.

Rogean
02-29-2004, 04:53 AM
[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]#

smogo
02-29-2004, 06:14 AM
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 :
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.

[Database]
host=localhost
user=test
password=test
database=test
compression=off


I'll try to improve parsing of db.ini if you get results.

smogo
03-05-2004, 01:34 PM
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.

ryder911
03-23-2004, 03:11 PM
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=)

smogo
03-23-2004, 10:05 PM
the link is in the first post. It's there :
http://perso.wanadoo.fr/afou/khalzed-dur/tools/quests/itest.tar.gz

ryder911
03-24-2004, 12:01 AM
Thanks smogo! I didnt see it last night i was tired and sick=( Your a big help and thanks for making the tool

smogo
04-02-2004, 06:35 AM
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 :

#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 :

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 ;)

KhaN
04-02-2004, 12:19 PM
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
open(DBINI,$dbinifile);
while(<DBINI>){
chomp;
s/\#.*$//;
if(m/(\w+)=(.+)/){
print "setting $1 to $2\n";
$dbvars{"db".$1}=$2;
}
}
close(DBINI);

Sorry ...

smogo
04-02-2004, 12:29 PM
the code quote is fix, because the simulator wasn't working under windows. it means you have to edit the EQ\dbaccess.pl file and modify it as described.

post your errors (first few lines if it's big).

KhaN
04-02-2004, 12:39 PM
Im trying to run it under WinXP SP1.

Errors :
[quote]K:\Everquest\Tools\PERL Script>perl -w itest.pl
Name "main::key" used only once: possible typo at itest.pl line 259.
Name "main::uguildid" used only once: possible typo at itest.pl line 63.
Name "main::mobid" used only once: possible typo at itest.pl line 71.
Name "main::fullanme" used only once: possible typo at itest.pl line 684.
Name "main::target_pet" used only once: possible typo at itest.pl line 78.
Name "main::uguildrank" used only once: possible typo at itest.pl line 64.
Name "main::userid" used only once: possible typo at itest.pl line 60.
reading user
'cat' n'est pas reconnu en tant que commande interne
ou externe, un programme ex

smogo
04-02-2004, 12:54 PM
it seems you didn't make all the changes correctly. The old code was not commented out. Sry if the post was not too explicit.

Anyway, i updated the link, with new fixed code. Download the files again and run the simulator

KhaN
04-02-2004, 01:07 PM
Your comment were ok, but my english is as good as your russian, but its always better to fix your code instead of letting newbies like me doing it by themselves :D

With your new code :
K:\Everquest\Tools\PERL Script>perl -w itest.pl
Name "main::key" used only once: possible typo at itest.pl line 259.
Name "main::uguildid" used only once: possible typo at itest.pl line 63.
Name "main::mobid" used only once: possible typo at itest.pl line 71.
Name "main::fullanme" used only once: possible typo at itest.pl line 684.
Name "main::target_pet" used only once: possible typo at itest.pl line 78.
Name "main::uguildrank" used only once: possible typo at itest.pl line 64.
Name "main::userid" used only once: possible typo at itest.pl line 60.
setting host to localhost
setting user to KhaN
setting password to keshik
setting database to eq
setting compression to off
user : >>>KhaN<<<
host : >>>localhost<<<
database : >>>eq<<<
password : >>>keshik<<<
in quest library
done with quest library
connected to database.
261 zones set
loading plugins
open './plugin.pl' No such file or directory at itest.pl line 566.
closing database connection...
connection closed

Problem is because of the top errors, or plugin.pl missing (searching info on it atm) or both !?

smogo
04-02-2004, 01:27 PM
The first errors are perl warnings. You can ignore them.

the simulator runs from a base directory similar to EQEMu, (or preferably same directory). The error you get is the same error as EQEMu error when it can't find the plugin.pl file

You need to have this file (it can be empty) in the directory you use the simulator from, just like db.ini, the plugin directory (possibly empty), a quests directory , ... i think that's all :)

KhaN
04-02-2004, 01:38 PM
As usual Smogo /bow, thanks a lots for help.
All look like to work well :D

KhaN
04-02-2004, 08:39 PM
DBD::mysql::st execute failed: Table 'eq.quest_globals' doesn't exist at EQ/dbac
cess.pl line 113, <> line 2.
DBD::mysql::st execute failed: Table 'eq.quest_globals' doesn't exist at EQ/dbac
cess.pl line 113, <> line 2.
closing database connection...
connection closed

I got this error when trying to target some NPC, possible imcompobility with my DB ? (Using MW55 Alpha2 modified for loot/drop).

Monrezz
04-03-2004, 01:02 AM
You haven't updated your database to use quest globals, checkout Sorcp2k's site and run the DB update (the binaries are trying to find the quest globals tables, but you don't have them in).