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 02-02-2012, 09:59 PM
Luccian
Sarnak
 
Join Date: Sep 2009
Posts: 32
Default Randomly Choose a quest::say()

Hello again. After getting a problem solved yesterday involving randomly choosing pauses between actions in a loop I decided to try using that same idea with phrases said upon hail.
This semi works, in the sense that when a player hails the NPC, they emote and say things, however it says all the options given.
I'm not sure how it should be scripted, but basically I'm looking to have a player be able to Hail this NPC, or group of NPCs sharing the same name, and have the NPC randomly choose a response based on what is put in the $randomphrase values rolled by the RandomRange plugin.

Code:
sub EVENT_SAY 
{
	if($text=~/Hail/)
	{
		quest::emote("appears to be one of Zimora's chosen elite. Light glistens off the shined plate armor.");
		# Random choice of phrases to be said
		my $randomphrase=plugin::RandomRange(1,3);
			if($randomphrase=1)
			{
				quest::say(Hello);
			}
			if($randomphrase=2)
			{
				quest::say(Hi);
			}
			if($randomphrase=3)
			{
				quest::say(Heya);
			}
	}
}
I used easy basic responses til I can get it to work out correctly. Appreciate the help in advance.
Reply With Quote
  #2  
Old 02-02-2012, 10:13 PM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,742
Default

if(x = y) means assign y to x and proceed if x is not 0.
if(x == y) means proceed if x is equal to y.
Reply With Quote
  #3  
Old 02-02-2012, 10:17 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Also, remember to always quote strings. You have it like this:

Code:
quest::say(Hello);
It should be like this:

Code:
quest::say("Hello");
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 02-02-2012, 10:52 PM
Luccian
Sarnak
 
Join Date: Sep 2009
Posts: 32
Default

So it should look something like this?

Code:
sub EVENT_SAY 
{
	if($text=~/Hail/)
	{
		quest::emote("appears to be one of Zimora's chosen elite. Light glistens off the shined plate armor.");
		# Random choice of phrases to be said
		my $randomphrase=plugin::RandomRange(1,3);
			if($randomphrase==1)
			{
				quest::say("Hello");
			}
			if($randomphrase==2)
			{
				quest::say("Hi");
			}
			if($randomphrase==3)
			{
				quest::say("Heya");
			}
	}
}
I'll try and see if it works, just wanted to make sure I understood what you meant leerxst2112
Reply With Quote
  #5  
Old 02-02-2012, 10:56 PM
Luccian
Sarnak
 
Join Date: Sep 2009
Posts: 32
Default

Works as intended now! Thanks again for the help. Much appreciated =)
I may have questions about your formation_tools.pl sometime as well Trev. Had a pretty nifty idea, and will try to execute before asking to much
Reply With Quote
  #6  
Old 02-03-2012, 01:16 AM
sorvani
Dragon
 
Join Date: May 2010
Posts: 965
Default

You should also think about using if and elsif statements so the server doesn't have to check each if statement even after it hit the right one and fired.
Reply With Quote
  #7  
Old 02-03-2012, 11:25 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Or, you can always use plugin::RandomSay() to make it really easy. Here is the plugin if you don't already have it. I keep it in a file named messages.pl, but not sure what it is on the plugin SVN offhand.

Code:
###Usage: plugin::RandomSay(chance(1-100), "message1","message2", etc..);
# Example: plugin::RandomSay(50, "I'll get you!", "Get over here!", "That's it!");
sub RandomSay {
	my $chance = $_[0];

	# First roll to see if a message will be sent or not depending on chance
	my $RandomNum = plugin::RandomRange(1, 100);
	
	# Choose the random message to send and send it
	if ($RandomNum <= $chance)
	{
		$MessageCount = @_;
		my $RandMessage = plugin::RandomRange(1, $MessageCount - 1);
		quest::say($_[$RandMessage]);
	}
}
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #8  
Old 02-03-2012, 04:13 PM
Luccian
Sarnak
 
Join Date: Sep 2009
Posts: 32
Default

Thanks for the additional support. I didn't know how to really properly use the elseif commands, thought I felt like it was the right way to go. So I tried to use the same type of script I used for the random animations I was using.

I like the random say plugin, I definitely will use that!
Reply With Quote
  #9  
Old 02-03-2012, 08:18 PM
sorvani
Dragon
 
Join Date: May 2010
Posts: 965
Default

Quote:
Originally Posted by Luccian View Post
Thanks for the additional support. I didn't know how to really properly use the elseif commands, thought I felt like it was the right way to go. So I tried to use the same type of script I used for the random animations I was using.

I like the random say plugin, I definitely will use that!
The plugin is the way to go, but for your reference:

Code:
sub EVENT_SAY 
{
	if($text=~/Hail/)
	{
		quest::emote("appears to be one of Zimora's chosen elite. Light glistens off the shined plate armor.");
		# Random choice of phrases to be said
		my $randomphrase=plugin::RandomRange(1,3);
			if($randomphrase==1) {
				quest::say("Hello");
			} elsif($randomphrase==2) {
				quest::say("Hi");
			} elsif($randomphrase==3) {
				quest::say("Heya");
			}
	}
}
Reply With Quote
  #10  
Old 02-04-2012, 12:43 PM
Luccian
Sarnak
 
Join Date: Sep 2009
Posts: 32
Default

Quote:
Originally Posted by sorvani View Post
The plugin is the way to go, but for your reference:

Code:
sub EVENT_SAY 
{
	if($text=~/Hail/)
	{
		quest::emote("appears to be one of Zimora's chosen elite. Light glistens off the shined plate armor.");
		# Random choice of phrases to be said
		my $randomphrase=plugin::RandomRange(1,3);
			if($randomphrase==1) {
				quest::say("Hello");
			} elsif($randomphrase==2) {
				quest::say("Hi");
			} elsif($randomphrase==3) {
				quest::say("Heya");
			}
	}
}

Ah ok, yeah I figured it would look kinda like that, however the formatting wasn't clear to me. Thanks for clarifying =) I can use this kinda knowledge for future ventures as well. Appreciate it.
Reply With Quote
Reply

Thread Tools
Display Modes

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 07:10 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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3