PDA

View Full Version : Simulated AE Rampage Script


chrsschb
02-11-2012, 09:34 PM
I know there's now a special attack code for Wild Rampage, but I liked using this on an old NPC of mine because of the customizable damage and delivery messages. This is the exact same script I used before, however now it doesn't work. I'm assuming some thing has changed to break this script as it fires all the way up to the if ($client_search) part and stops. Any help is appreciated.

my $x;
my $y;
my $z;
my $h;


sub EVENT_COMBAT
{

if ($combat_state == 1)
{
quest::settimer("rampage",15);
}

if ($combat_state == 0)
{
$npc->WipeHateList();
quest::stoptimer("rampage");
quest::stoptimer("getclients");
#$npc->SetHP($npc->GetMaxHP() * 1);
}
}


sub EVENT_TIMER
{

if ($timer eq "rampage")
{
quest::stoptimer("rampage");
my $TimeRA = quest::ChooseRandom(15);
quest::settimer("getclients", $TimeRA);
}

if ($timer eq "getclients")
{
$cmname = $npc->GetCleanName();
my $MaxDam = $npc->GetMaxDMG();
my $ShieldMaxDam = ($MaxDam * .80);
my $ShieldMinDam = $ShieldMaxDam / 2;
my $DamageVar = ($ShieldMaxDam - $ShieldMinDam);
$entity_list->MessageClose($npc, 1, 2000, 13, "$cmname SLAMS his hammer into the ground!");
my $list_check = 0;
for ($list_check = 0; $list_check < 2000; $list_check++)
{
$client_search = $entity_list->GetClientByID($list_check);
if ($client_search)
{
###The script stops here
my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
my $distanceCHK = $client_search->CalculateDistance($x, $y, $z);
my $PLTarget = $npc->GetTarget();
my $TargID = $PLTarget->GetID();
my $ClID = $client_search->GetID();
my $RampDamageVar = (int(rand($DamageVar ))) + (int($ShieldMinDam));
if (($distanceCHK <= 2000) && ($TargID != $ClID))
{
$client_search->Damage($npc, $RampDamageVar, 7477, 1, true, -1, false);
$client_search->Message(13, "$cmname hits YOU for $RampDamageVar points of damage!");
}
}
}
}
}


sub EVENT_DEATH
{
quest::stoptimer("rampage");
quest::stoptimer("getclients");
}

joligario
02-11-2012, 09:53 PM
Just a quick glance, but I would assume it has something to do with hardcoding 0 and 2000 rather than getting a true client count. Haven't done it in a while, but is there truly a client with ID of 0? Another thing to think of is what happens when you get beyond the actual list of clients.

chrsschb
02-11-2012, 10:00 PM
Just a quick glance, but I would assume it has something to do with hardcoding 0 and 2000 rather than getting a true client count. Haven't done it in a while, but is there truly a client with ID of 0? Another thing to think of is what happens when you get beyond the actual list of clients.

Not sure why that would cause any issue, it never did before (and is how it was written by Kayen).

lerxst2112
02-11-2012, 10:28 PM
Something like this might work, and it'd be more efficient since it's not going to try and retrieve 2000 clients.


my @clientlist = $entity_list->GetClientList();
foreach $ent (@clientlist)
{
my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
my $distanceCHK = $ent->CalculateDistance($x, $y, $z);
my $PLTarget = $npc->GetTarget();
my $TargID = $PLTarget->GetID();
my $ClID = $ent->GetID();
my $RampDamageVar = (int(rand($DamageVar ))) + (int($ShieldMinDam));
if (($distanceCHK <= 2000) && ($TargID != $ClID))
{
$ent->Damage($npc, $RampDamageVar, 7477, 1, true, -1, false);
$ent->Message(13, "$cmname hits YOU for $RampDamageVar points of damage!");
}
}

chrsschb
02-11-2012, 10:37 PM
Something like this might work, and it'd be more efficient since it's not going to try and retrieve 2000 clients.


my @clientlist = $entity_list->GetClientList();
foreach $ent (@clientlist)
{
my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
my $distanceCHK = $ent->CalculateDistance($x, $y, $z);
my $PLTarget = $npc->GetTarget();
my $TargID = $PLTarget->GetID();
my $ClID = $ent->GetID();
my $RampDamageVar = (int(rand($DamageVar ))) + (int($ShieldMinDam));
if (($distanceCHK <= 2000) && ($TargID != $ClID))
{
$ent->Damage($npc, $RampDamageVar, 7477, 1, true, -1, false);
$ent->Message(13, "$cmname hits YOU for $RampDamageVar points of damage!");
}
}


Like this? (still doesn't get to the damage portion)

sub EVENT_TIMER
{

if ($timer eq "rampage")
{
quest::stoptimer("rampage");
my $TimeRA = quest::ChooseRandom(15);
quest::settimer("getclients", $TimeRA);
}

if ($timer eq "getclients")
{
$cmname = $npc->GetCleanName();
my $MaxDam = $npc->GetMaxDMG();
my $ShieldMaxDam = ($MaxDam * .80);
my $ShieldMinDam = $ShieldMaxDam / 2;
my $DamageVar = ($ShieldMaxDam - $ShieldMinDam);
$entity_list->MessageClose($npc, 1, 2000, 13, "$cmname SLAMS his hammer into the ground!");
my @clientlist = $entity_list->GetClientList();
foreach $ent (@clientlist)
{
my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
my $distanceCHK = $ent->CalculateDistance($x, $y, $z);
my $PLTarget = $npc->GetTarget();
my $TargID = $PLTarget->GetID();
my $ClID = $ent->GetID();
my $RampDamageVar = (int(rand($DamageVar ))) + (int($ShieldMinDam));
if (($distanceCHK <= 2000) && ($TargID != $ClID))
{
$ent->Damage($npc, $RampDamageVar, 7477, 1, true, -1, false);
$ent->Message(13, "$cmname hits YOU for $RampDamageVar points of damage!");
}
}
}
}

lerxst2112
02-12-2012, 01:00 AM
You have:

my $x;
my $y;
my $z;
my $h;

at the top of the script and then you have

my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();

inside the loop, where it stops working. I'm not a perl expert, but that may be the problem. I would remove the ones at the top.

chrsschb
02-12-2012, 12:31 PM
Doesn't change anything, I tried that before.

chrsschb
02-12-2012, 12:44 PM
Using this version 1-7 fires, 8 never fires:
sub EVENT_TIMER
{

if ($timer eq "rampage")
{
quest::stoptimer("rampage");
my $TimeRA = quest::ChooseRandom(15);
quest::settimer("getclients", $TimeRA);
}

if ($timer eq "getclients")
{
$cmname = $npc->GetCleanName();
my $MaxDam = $npc->GetMaxDMG();
my $ShieldMaxDam = ($MaxDam * .80);
my $ShieldMinDam = $ShieldMaxDam / 2;
my $DamageVar = ($ShieldMaxDam - $ShieldMinDam);
$entity_list->MessageClose($npc, 1, 2000, 13, "$cmname SLAMS his hammer into the ground!");
my $list_check = 0;
for ($list_check = 0; $list_check < 2000; $list_check++)
{
$client_search = $entity_list->GetClientByID($list_check);
if ($client_search)
{
quest::shout("1");
my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
quest::shout("2");
my $distanceCHK = $client_search->CalculateDistance($x, $y, $z);
quest::shout("3");
my $PLTarget = $npc->GetTarget();
quest::shout("4");
my $TargID = $PLTarget->GetID();
quest::shout("5");
my $ClID = $client_search->GetID();
quest::shout("6");
my $RampDamageVar = (int(rand($DamageVar ))) + (int($ShieldMinDam));
quest::shout("7");
if (($distanceCHK <= 2000) && ($TargID != $ClID))
{
quest::shout("8");
$client_search->Damage($npc, $RampDamageVar, 7477, 1, true, -1, false);
$client_search->Message(13, "$cmname hits YOU for $RampDamageVar points of damage!");
}
}
}
}
}

Using this version 1-7 fires, 8 never fires:
sub EVENT_TIMER
{

if ($timer eq "rampage")
{
quest::stoptimer("rampage");
my $TimeRA = quest::ChooseRandom(15);
quest::settimer("getclients", $TimeRA);
}

if ($timer eq "getclients")
{
$cmname = $npc->GetCleanName();
my $MaxDam = $npc->GetMaxDMG();
my $ShieldMaxDam = ($MaxDam * .80);
my $ShieldMinDam = $ShieldMaxDam / 2;
my $DamageVar = ($ShieldMaxDam - $ShieldMinDam);
$entity_list->MessageClose($npc, 1, 2000, 13, "$cmname SLAMS his hammer into the ground!");
my @clientlist = $entity_list->GetClientList();
foreach $ent (@clientlist)
{
quest::shout("1");
my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
quest::shout("2");
my $distanceCHK = $ent->CalculateDistance($x, $y, $z);
quest::shout("3");
my $PLTarget = $npc->GetTarget();
quest::shout("4");
my $TargID = $PLTarget->GetID();
quest::shout("5");
my $ClID = $ent->GetID();
quest::shout("6");
my $RampDamageVar = (int(rand($DamageVar ))) + (int($ShieldMinDam));
quest::shout("7");
if (($distanceCHK <= 2000) && ($TargID != $ClID))
{
quest::shout("8");
$ent->Damage($npc, $RampDamageVar, 7477, 1, true, -1, false);
$ent->Message(13, "$cmname hits YOU for $RampDamageVar points of damage!");
}
}
}
}

joligario
02-12-2012, 02:19 PM
I would debug the value in distanceCHK and target/client ids to see if it is value problem.

chrsschb
02-12-2012, 08:31 PM
How would I do that?

lerxst2112
02-13-2012, 12:10 AM
Consider what would happen if both IDs were the same.

Change your 7th shout to this:

quest::shout("7 $TargID, $ClID");


The reason I mention this is that when testing the script alone, the IDs are the same and the if fails.

chrsschb
02-13-2012, 01:37 AM
Consider what would happen if both IDs were the same.

Change your 7th shout to this:

quest::shout("7 $TargID, $ClID");


The reason I mention this is that when testing the script alone, the IDs are the same and the if fails.

I see what you're saying. I brought another char out to help with this. Any time the TargID and ClID were the same, the script failed, any time they were different, it worked. I removed the && ($TargID != $ClID)) part of the script and now it fires all the time.

Issue resolved. Thanks for the help!