View Full Version : Tacvi type quest
Maze_EQ
02-13-2013, 08:16 PM
Alrighty, I'm stumped as to how to get multiple npc's to be able to balance within +|- 10%. I
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? 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
Alrighty, I'm stumped as to how to get multiple npc's to be able to balance within +|- 10%. I
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? 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.
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.
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
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");
}
}
}
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.