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-13-2013, 08:16 PM
Maze_EQ
Demi-God
 
Join Date: Mar 2012
Posts: 1,106
Default Tacvi type quest

Alrighty, I'm stumped as to how to get multiple npc's to be able to balance within +|- 10%. I

Code:
sub EVENT_SAY
{
	if($text=~/Hail/i)
	{
		my $testmob1 = ($entity_list->GetMobByNpcTypeID(2702460));
		my $testmob2 = ($entity_list->GetMobByNpcTypeID(2702461));
		
		my $hpcheck = $testmob1->GetHP();
		my $hpcheck2 = $testmob2->GetHP();
		
		
		if($hpcheck <= $hpcheck2 + *.10  || $hpcheck >= $hpcheck2 + *.10 )
		{
		quest::shout("Test Completed");
		}
		
			

	
	}
}
Which I know doesn't calculate correctly.

Basically what I am looking for is, how to tell a range between + 10% and -10%...

would something like this work?
Code:
 if($hpcheck <= $hpcheck2 + $hpcheck * .10  && $hpcheck >= $hpcheck2 - $hpcheck2 * .10 )
__________________
"No, thanks, man. I don't want you fucking up my life, too."

Skype:
Comerian1
Reply With Quote
  #2  
Old 02-13-2013, 08:47 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Have a variable to store the actual percentage, then use smart match operator ~~ with range.

I think. I'm not sure of what logic you're looking to use.

What is your ultimate goal? Perhaps you explained it clearly the first time, I'm contending a stuffed up and drugged head atm.

Is it, you wish to check the condition of the hp of one mob being within 10 percent of the comparison mob? If that's the case, the script/logic will need to take into account what the mobs maximum hp is, which I dont currently see referenced.
Reply With Quote
  #3  
Old 02-13-2013, 08:55 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Quote:
Originally Posted by Maze_EQ View Post
Alrighty, I'm stumped as to how to get multiple npc's to be able to balance within +|- 10%. I

Code:
sub EVENT_SAY
{
	if($text=~/Hail/i)
	{
		my $testmob1 = ($entity_list->GetMobByNpcTypeID(2702460));
		my $testmob2 = ($entity_list->GetMobByNpcTypeID(2702461));
		
		my $hpcheck = $testmob1->GetHP();
		my $hpcheck2 = $testmob2->GetHP();
		
		
		if($hpcheck <= $hpcheck2 + *.10  || $hpcheck >= $hpcheck2 + *.10 )
		{
		quest::shout("Test Completed");
		}
		
			

	
	}
}
Which I know doesn't calculate correctly.

Basically what I am looking for is, how to tell a range between + 10% and -10%...

would something like this work?
Code:
 if($hpcheck <= $hpcheck2 + $hpcheck * .10  && $hpcheck >= $hpcheck2 - $hpcheck2 * .10 )
You ninja editing? That second code block looks different from what I remember.
Reply With Quote
  #4  
Old 02-13-2013, 09:01 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

smart match operator with range operator wasn't working for me. i don't know why. this works, however.

Code:
use 5.012;
use warnings;

package NPC;

sub new {
    my ( $class, %param ) = ( shift, @_ );
    $param{_hp} = ( int rand 9 ) + 1;
    return bless \%param, $class;
}

sub GetHP {
    shift->{_hp};
}

package main;

my $npc1 = NPC->new();
my $npc2 = NPC->new();

my $hpcheck1 = $npc1->GetHP();
my $hpcheck2 = $npc2->GetHP();

my $lower = $hpcheck2 - $hpcheck2 * .10;
my $upper = $hpcheck2 + $hpcheck2 * .10;

if ( $hpcheck1 >= $lower && $hpcheck1 <= $upper ) {
    say "$hpcheck1 is within $lower and $upper";
}
else {
    say "$hpcheck1 is NOT within $lower and $upper";
}
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #5  
Old 02-13-2013, 09:06 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

ok, i think i sorted out why. i wasn't enclosing the range in brackets.

Code:
if ( $mid ~~ [ $min  ..  $max ] ) { say "YAY!"; }
works... duh
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote
  #6  
Old 02-13-2013, 09:55 PM
Maze_EQ
Demi-God
 
Join Date: Mar 2012
Posts: 1,106
Default

Damn. yeah I ninja edited, and that's alot cleaner than what I had ultimate wrote out....... which is



Code:
sub EVENT_SAY
{
	if($text=~/Hail/i)
	{
		my $testmob1 = ($entity_list->GetMobByNpcTypeID(2702460));
		my $testmob2 = ($entity_list->GetMobByNpcTypeID(2702461));
		my $testmob3 = ($entity_list->GetMobByNpcTypeID(2702462));
		my $testmob4 = ($entity_list->GetMobByNpcTypeID(2702463));
		
		my $hpcheck = $testmob1->GetHP();
		my $hpcheck2 = $testmob2->GetHP();
		my $hpcheck3 = $testmob3->GetHP();
		my $hpcheck4 = $testmob4->GetHP();
		
		
		
	if($hpcheck <= $hpcheck2 + $hpcheck * .10  && $hpcheck >= $hpcheck2 - $hpcheck * .10 )
		{
		quest::shout("Getting my Obama on");
		}
		else
							{
							quest::shout("We're out the asteroid field now $name");
							}	
			if($hpcheck <= $hpcheck4 + $hpcheck * .10  && $hpcheck >= $hpcheck4 - $hpcheck * .10 )
				{
				quest::shout("Getting my Samuel L Jackson on");	
				}
				else
							{
							quest::shout("We're out the asteroid field now $name");
							}	
					if($hpcheck <= $hpcheck3 + $hpcheck * .10  && $hpcheck >= $hpcheck3 - $hpcheck * .10 )
						{
						quest::shout("Getting my Morgan Freeman on");						
				         }
		         
						else
							{
							quest::shout("We're out the asteroid field now $name");
							}	
			
                        

	}
}
__________________
"No, thanks, man. I don't want you fucking up my life, too."

Skype:
Comerian1
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:38 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