EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Tacvi type quest (https://www.eqemulator.org/forums/showthread.php?t=36487)

Maze_EQ 02-13-2013 08:16 PM

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 )

ghanja 02-13-2013 08:47 PM

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.

ghanja 02-13-2013 08:55 PM

Quote:

Originally Posted by Maze_EQ (Post 218166)
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.

c0ncrete 02-13-2013 09:01 PM

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";
}


c0ncrete 02-13-2013 09:06 PM

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

Code:

if ( $mid ~~ [ $min  ..  $max ] ) { say "YAY!"; }
works... duh

Maze_EQ 02-13-2013 09:55 PM

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

        }
}



All times are GMT -4. The time now is 10:35 AM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.