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 06-13-2007, 04:34 AM
sfisque
Hill Giant
 
Join Date: Oct 2006
Posts: 248
Default

assuming rand/srand dont work, you can do something like create "global variables" in the perl script of the
quest, something like:

Code:
$SEED = int( $npc->GetX() );
$NUMBER_OF_PHRASES = 7;
and then have a method like:

Code:
sub
generateRandom
{
    $SEED += int( $npc->GetX() );
    $SEED %= $NUMBER_OF_PHRASES;
    return $SEED;
}
and then you can do:

Code:
sub
EVENT_AGGRO
{
    quest::say( $PHRASE[ &generateRandom ] );
}
its not a perfect random number generator, but it should offer you a bootstrap until you can wire up a better random generator. you can try using srand/rand, but i do not know if they are exposed to the quest engine. you will have to redefine the phrases as an array for this (in either case) to work:

Code:
@PHRASE = 
(
    "phrase 1",
    "phrase 2", 
   # etc.
);
== sfisque

Last edited by sfisque; 06-13-2007 at 12:39 PM..
Reply With Quote
  #2  
Old 06-13-2007, 05:31 AM
So_1337
Dragon
 
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
Default

Thank you for the idea. I'll see what I can do with it.
Reply With Quote
  #3  
Old 06-13-2007, 05:56 AM
sfisque
Hill Giant
 
Join Date: Oct 2006
Posts: 248
Default

NPNP

keep us posted on what you find (if srand/rand work or not) and stuff. i'm always eager to learn more about what the quest engine can handle.

== sfisque
Reply With Quote
  #4  
Old 06-13-2007, 01:57 PM
GeorgeS
Forum Guide
 
Join Date: Sep 2003
Location: California
Posts: 1,474
Default

In my quest editor there's an example where an npc walks around the zone randomly and returns to original spot. This is like a patrol, but is generated in a random manner. See the script example


GeorgeS

__________________
Your source for EQ database tools
Toolshop is open for business


http://www.georgestools.chrsschb.com//
Reply With Quote
  #5  
Old 06-14-2007, 03:52 AM
So_1337
Dragon
 
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
Default

Thank you GeorgeS I wound up looking through most of the quest files included with that, and came across one (#2 that gave me an idea. I realized that I was perhaps putting too much thought into this.

I used a ChooseRandom with numbers 1-10, and just wrote ifs for each number. I stored the chosen value in the $a variable (since I wanted to test it with one that I knew would be recognized).

Well, I went a little further than that, and found that it will in fact let me use variables that I create myself (and thus aren't in the list here). I'm still new to writing in PERL, so I thought there were limitations from somewhere on what variables you could work with.

Anyway, here's what I wound up with, and it works pretty well. I'll be using this for every mob that I have aggro /say for, and it will have them give their standard aggro message along with a second one roughly 2/3 of the time. If they have a standard one that goes off each time (Frrroooaaakkk!), I'll just drop that at the top. Thank you so much for the help, both of you

Code:
sub EVENT_AGGRO{
 my $Phrase = quest::ChooseRandom(1,2,3,4,5,6,7,8,9,10,0,0,0,0,0);
 quest::say('Frrroooaaakkk!');

if ($Phrase =~/1/) {
 quest::say("Your faithless devotion to a false god leaves me no choice.");
  }
if ($Phrase =~/2/) {
 quest::say("I shall rid the land of another infamous villain.");
  }
if ($Phrase =~/3/) {
 quest::say("Your foul deeds have earned my contempt.");
  }
if ($Phrase =~/4/) {
 quest::say("Your beliefs are an insult to us all!");
  }
if ($Phrase =~/5/) {
 quest::say("Your actions and history are a personal affront to all I stand for.");
  }
if ($Phrase =~/6/) {
 quest::say("${race}s like you are better left dead than alive.");
  }
if ($Phrase =~/7/) {
 quest::say("It's ${race}s like you who have ruined your own lands, You'll not ruin mine!");
  }
if ($Phrase =~/8/) {
 quest::say("It's time for you to take your blasphemy into the next realm.");
  }
if ($Phrase =~/9/) {
 quest::say("Your intolerable reputation insults all in this realm.");
  }
if ($Phrase =~/10/) {
 quest::say("${class}s like you are better left dead than alive.");
 }
}

#Submitted by: Jim Mills
(Note: Again, the board seems to be adding an extra space where it doesn't really belong inside of my code block. There are no spaces after the string of zeroes in the ChooseRandom when I enter this in, but they appear each time I preview my post. Quirky.)
Reply With Quote
  #6  
Old 06-14-2007, 10:13 PM
Budaworm
Fire Beetle
 
Join Date: Oct 2003
Posts: 20
Default

The way you had it written first works fine. You need to declare your variables first though. So if you write it like this:
Code:
sub EVENT_AGGRO {
my $Phrase1 = "Your faithless devotion to a false god leaves me no choice.";
my $Phrase2 = "I shall rid the land of another infamous villain.";
my $Phrase3 = "Your foul deeds have earned my contempt.";
my $Phrase4 = "${race}s like you are better left dead than alive.";
my $Phrase5 = "It's ${class}s like you who have ruined your own lands, You'll not ruin mine!";
my $Phrase6 = "Heathen! Unbeliever! Norrath must be cleansed!";
my $Phrase = quest::ChooseRandom($Phrase1, $Phrase2, $Phrase3, $Phrase4, $Phrase5, $Phrase6);
quest::say("Frrroooaaakkk!");
quest::say("$Phrase");
}
The mob will say the first message then say the randomly picked message. Looks much nicer and cleaner in your quest script.

Last edited by Budaworm; 06-15-2007 at 06:15 AM.. Reason: typos
Reply With Quote
  #7  
Old 06-15-2007, 12:55 AM
So_1337
Dragon
 
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
Default

Haha, F. I didn't think about that =) No wonder all the /says were coming up as empty, it's because the variables were empty with the order it was executing. Doh =X

Okay, I think I'll go back to the way I was trying it originally, just because it's more compact. Thanks so much for all the help and ideas, all of you =)
Reply With Quote
  #8  
Old 06-15-2007, 08:36 AM
EmanonCow
Sarnak
 
Join Date: Aug 2006
Posts: 35
Default

Quote:
Originally Posted by Budaworm
The way you had it written first works fine. You need to declare your variables first though. So if you write it like this:
Code:

The mob will say the first message then say the randomly picked message. Looks much nicer and cleaner in your quest script.
Cleaner solution:
Code:
sub EVENT_AGGRO {
	my @Phrases = (
		"Your faithless devotion to a false god leaves me no choice.",
		"I shall rid the land of another infamous villain.",
		"Your foul deeds have earned my contempt.",
		"${race}s like you are better left dead than alive.",
		"It's ${class}s like you who have ruined your own lands, You'll not ruin mine!",
		"Heathen! Unbeliever! Norrath must be cleansed!"
	);

	my $Phrase = quest::ChooseRandom(@Phrases);
	quest::say("Frrroooaaakkk!");
	quest::say("$Phrase");
}
I think that'll work, and you can add phrases to the list, and it automatically includes it in the random phrase pick.
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:35 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