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 07-13-2009, 12:46 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default Trying to Create a Summonitem Proxy

I am looking to create a NPC that acts as a #summonitem proxy. I want to keep my players access limited to the default commands, and not give them access to any special commands. Since they have #itemsearch by default I would like to create an NPC that allows them to recieve an item of their choice by saying to him the item ID number. Once I get the basic event down I was thinking of turning it into some sort of quest with a handin and then he gives you the option to have him summon you any item in the game. Or just sticking him in a really hard location to get to. Not sure yet...

Example:

Code:
Player: Hail "NPC"

NPC: What [item] do you seek?

Player: I seek item 12345

NPC: Here is your item
I have searched the wiki quest info and also looked through a bunch of quests on the forums but cannot find anything with an example of a dynamic say event.

How do I make it so the NPC reads the item number that the player says and summons the item for the player?

quest::summonitem("12345") - would be the static way

$say = player text
quest::summonitem("$say") - dynamic way
Reply With Quote
  #2  
Old 07-13-2009, 01:47 PM
pfyon's Avatar
pfyon
Discordant
 
Join Date: Mar 2009
Location: Ottawa
Posts: 495
Default

I should start by saying that I have limited experience with perl or regular expressions.

Something like that, but instead of using quotations:
Code:
$say = player text
quest::summonitem("$say");
It should be:
Code:
quest::summonitem($say);
You could simply enough have it check if the string the player said was an integer and then summon that. I think that would be the following:
Code:
if($text=~/\d{1,6}/) {
quest::summonitem($text);
}
Someone who has more regex experience than me should double check that, but I think that strips everything except for the integer digits (minimum 1 digit, max 6).

edit: not sure what would happen if someone said for example '10061 13001', I think it might call summonitem(10061 13001) which should return an error. Also, you probably want to check the return value of summonitem (if it has one) and see if it found the item or not, if not the npc could say that there was no item found.
Reply With Quote
  #3  
Old 07-13-2009, 01:54 PM
Yeormom
Discordant
 
Join Date: Apr 2004
Location: 127.0.0.1
Posts: 402
Default

It would be 10x easier just to lower the status requirement for summon item instead. You can change the command's status individually to suit your needs, meaning you can give them access to just summon item if you like. I configure mine in command.cpp but I believe if you are using current EQEMU code, you can simply change the status in the database.

It is either in the rules table or there is a table called commands that lists these status levels in your database. The default status level for a player is 10 so change it to 10 and you're good to go.
__________________
Yeorwned
Bane of Life [Custom Classic/PvP]
Reply With Quote
  #4  
Old 07-13-2009, 03:13 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

Thanks pyfon for the reply. I will see what I can do with your suggestion.

Yeormon, I know I can just change the command in the DB but whats the fun in that. At least this way I can give players the ability to summon items but I can control it a bit more than just giving them the command.

I could create this into a quest where they have to do a turn in in order to be able to summon one item of thier choice. Or have the NPC spawn on the death of a very high level raid encounter.

I was trying to get a bit creative with it. This way the players will have to work for it, but it is still obtainable.

Just giving out #summonitem to everyone can ruin the game for someone fast. But if you have a character that you maxed out, and you finally can get to the NPC then you have earned it!
Reply With Quote
  #5  
Old 07-13-2009, 03:30 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

Ok this works but I need to polish the quest a bit since it returns the following after everything you say to the npc even hails. But I just wanted to see if the item summon funtion works before I ironed out the details and it does.

Code:
No such item: 0
Code:
#############
#Written By : Cubber
#Quest Name: #summonitem proxy
#Quest Zone: Cshome
#Quest NPC: Krakskull
#################
sub EVENT_SAY
{
   if($text=~/Hail/i)
      {
         quest::say("Hello there $name,  Need some [items summoned]?");
      }
if ($text=~/items summoned/i)

                        {
                                quest::say("In order for me to summon an item for you I need to know it's ID number.  Please do a #itemsearch itemname and just tell me the number next to the item.");
                        }

                                if ($text=~/\d{0,9}/)
                                        {
                                                quest::summonitem("$text");     
                                        }


}
This successfully summons the item into your players cursor.

Thanks for the help pfyon!
Reply With Quote
  #6  
Old 07-13-2009, 03:35 PM
pfyon's Avatar
pfyon
Discordant
 
Join Date: Mar 2009
Location: Ottawa
Posts: 495
Default

I should also note that someone who says '1some2thing som3et45hing' might get it picked up as id 12345, I suggest you look up perl regular expressions on google and do some testing.
Reply With Quote
  #7  
Old 07-13-2009, 03:39 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

Yup I will have to fix the script to get rid of the errors and to make it a bit cleaner like you say. Just wanted to figure out if it was possible or not first, and ... well ... it looks like it is!
Reply With Quote
  #8  
Old 07-13-2009, 03:43 PM
pfyon's Avatar
pfyon
Discordant
 
Join Date: Mar 2009
Location: Ottawa
Posts: 495
Default

You could replace the if statements after the first one with elsif statements. It's what I do whenever I work on quests unless I need it to check the text more than once separately.

The way I figure, if someone says (for example) "hail items summoned", I only want the hail text, not both the hail and items summoned. It also reduces server load (slightly) by not needing to evaluate every if, it just stops when something evaluates true.

This would keep the number checking code from being executed when they say hail or items summoned, which is a start. Other stuff would still trigger it though.
Reply With Quote
  #9  
Old 07-13-2009, 03:44 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

elsif worked perfectly thanks!
Reply With Quote
  #10  
Old 07-13-2009, 04:13 PM
Dibalamin
Hill Giant
 
Join Date: Dec 2007
Posts: 182
Default

How can you make it store a text string? Been thinking about a bot to do guilds.
__________________
Retired EMarr
Project1999 Developer
Reply With Quote
  #11  
Old 07-13-2009, 04:17 PM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

here is the final quest I came up with that works with no errors. Thanks again to pfyon for the help.

Code:
#############
#Written By : cubber
#Quest Name: #summonitem proxy
#Quest Zone: Cshome
#Quest NPC: Krakskull
#################
sub EVENT_SAY
{
   if($text=~/Hail/i)
      {
         quest::say("Hello there $name,  need some [items summoned]?");
      }
elsif ($text=~/items summoned/i)
			
			{
				quest::say("$race, I have been gifted with the ability to summon any item or spell in this world for you.  However, I am not a mind reader, and in order for me to summon anything for you I need to know it's ID number.  Please use the command: #itemsearch insert_itemname_here , and just tell me the number next to the item you desire.");
			}
			
				elsif ($text=~/\d{0,9}/)
					{
						quest::emote("Krakskull begins to chant...");
						quest::summonitem("$text");      	
						quest::emote("The item you seek apears before your eyes!");
					}
			
				
}
Obviously you could stick this on any NPC or create one and do whatever you want with it. I just stuck it in cshome now with a very basic setup so I could test it and take it from there before I put it in a place where players could access it.

But it works!
Reply With Quote
  #12  
Old 07-13-2009, 04:29 PM
pfyon's Avatar
pfyon
Discordant
 
Join Date: Mar 2009
Location: Ottawa
Posts: 495
Default

Quote:
Originally Posted by Dibalamin View Post
How can you make it store a text string? Been thinking about a bot to do guilds.
Under EVENT_SAY you should be able to just do
Code:
$myString = $text;
That'll just store the current text since it would be overwritten whenever someone said something to the npc with the current text. A better approach would be to put it in an if block with a regex to check for a string like "Guildname: xxxxxx" then store the xxxxxx part with another regex.
Code:
if($text =~/<some regex to check guildname>/i)
{
$text =~/<regex to pull out the guildname>/;
$guildname = $text;
}
Again, no real experience using perl or regular expressions, so I'm not sure exactly how you'd do that. One way would be to store the initial say text in a temporary variable since performing the regex puts the output in the variable that you perform it on (I think, so $text =~ something modifies $text to be the output of the expression).

Kinda getting over my head with regular expressions and perl in this thread, I'm just waiting for someone who actually uses it regularly to come in and say "no, that's all wrong". :p

Also, not sure if it's good programming practice with perl, but you could declare the variable as a global variable (outside EVENT_SAY, like at the top of the script) so it can be accessed from other events.
Reply With Quote
  #13  
Old 07-13-2009, 05:52 PM
Dibalamin
Hill Giant
 
Join Date: Dec 2007
Posts: 182
Default

Yeah, I figure it is possible, but I'm not sure what the expression should be to store the variable, but after reading what you put I think just using a say and storing it should be sufficient, but then it will be slightly more difficult to give instructions on how to use it....

As you said, hopefully someone better at the ins and outs of perl will chime in =p
__________________
Retired EMarr
Project1999 Developer
Reply With Quote
  #14  
Old 07-14-2009, 01:29 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

These should help as references:
Regular expression examples - Wikipedia, the free encyclopedia
Perl regular expressions for the common man

Here's the finished product:

Code:
#############
#Written By : cubber, regexp by AndMetal
#Quest Name: #summonitem proxy
#Quest Zone: Cshome
#Quest NPC: Krakskull
#################
sub EVENT_SAY {
	if($text=~/Hail/i) {
         quest::say("Hello there $name,  need some [items summoned]?");
	} elsif ($text=~/i seek item (\d{1,6})/i) {
		my $itemNum = $1;
		quest::emote("Krakskull begins to chant...");
		quest::summonitem($itemNum);      	
		quest::emote("The item you seek apears before your eyes!");
	}
}
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Reply With Quote
  #15  
Old 07-14-2009, 08:09 AM
cubber
Discordant
 
Join Date: Apr 2006
Posts: 374
Default

Thanks AndMetal for cleaning up the regex stuff.
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 06:56 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