Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.78 KB | None | 0 0
  1. ##This is npc's spawned x, y location and leash length
  2. $leashlength = 200;
  3.  
  4. sub EVENT_SPAWN
  5. {
  6. $startingx = $npc->GetX();
  7. $startingy = $npc->GetY();
  8. $startingz = $npc->GetZ();
  9. $startingh = $npc->GetHeading();
  10. }
  11.  
  12. sub EVENT_COMBAT
  13. {
  14.     if ($combat_state == 1)
  15.         {
  16.             quest::settimer("Rampage", 8);
  17.             quest::settimer("checkleash",5);
  18.         }
  19.     if ($combat_state == 0)
  20.         {
  21.             $npc->SetHP($npc->GetMaxHP());
  22.             $npc->WipeHateList();
  23.             quest::stoptimer("Rampage");
  24.             quest::stoptimer("getclients");
  25.         }
  26. }
  27.  
  28. sub EVENT_TIMER {
  29. $currentx = $npc->GetX();
  30. $currenty = $npc->GetY() ;
  31. $currentz = $npc->GetZ();
  32.  
  33.     if($timer eq "checkleash")
  34.     {
  35.         ###This is just the equation for a sphere
  36.         ###(x - x_0 )^2 + (y - y_0 )^2 + ( z - z_0 )^2 = r^2.
  37.         ###
  38.  
  39.         $leftside = ((($currentx - $startingx)*($currentx-$startingx)) + (($currenty - $startingy)*($currenty -$startingy)) + (($currentz - $startingz)*($currentz - $startingz)));
  40.         $rightside = ($leashlength * $leashlength);
  41.         if($leftside > $rightside)
  42.         {
  43.         $currentx = undef;
  44.         $currenty = undef;
  45.         $currentz = undef;
  46.         $npc->WipeHateList();
  47.         $npc->GMMove($startingx, $startingy, $startingz, $startingh);
  48.         quest::stoptimer("checkleash");
  49.         quest::settimer("checkleash",5);
  50.         }
  51.     }
  52.  
  53. if ($timer eq "Rampage") {
  54. quest::stoptimer("Rampage");
  55. my $TimeRA = quest::ChooseRandom(8);
  56. quest::settimer("getclientsRAMPAGE", $TimeRA);
  57.   }
  58.  
  59. ####################################
  60. ##########AE RAMPAGE##################
  61. #####################################
  62.   if ($timer eq "getclientsRAMPAGE") {
  63.   $cmname = $npc->GetCleanName();
  64.   my $MaxDam = $npc->GetMaxDMG();
  65.   my $ShieldMaxDam = ($MaxDam * .35);
  66.   my $ShieldMinDam = $ShieldMaxDam / 2;
  67.   my $DamageVar = ($ShieldMaxDam - $ShieldMinDam);
  68.  
  69.   $entity_list->MessageClose($npc, 1, 200, 13, "$cmname goes on a WILD KMRA RAMPAGE");
  70.    
  71.   my $list_check = 0;
  72.  
  73.   for ($list_check = 0; $list_check < 2000; $list_check++) {
  74.  
  75.   $client_search = $entity_list->GetClientByID($list_check);
  76.      
  77.     if ($client_search) {
  78.     my $distanceCHK = $client_search->CalculateDistance($x, $y, $z);
  79.     my $PLTarget = $npc->GetTarget();
  80.     my $TargID = $PLTarget->GetID();
  81.     my $ClID = $client_search->GetID();
  82.     my $RampDamageVar = (int(rand($DamageVar ))) + (int($ShieldMinDam));
  83.  
  84.         if (($distanceCHK <= 325) && ($TargID != $ClID)) {
  85.         $client_search->Damage($npc, $RampDamageVar, 7477, 1, true, -1, false);
  86.         $client_search->Message(13, "$cmname hits YOU for $RampDamageVar points of damage" );
  87.                             }
  88.  
  89. }
  90. }
  91. }
  92. ############################################################    
  93. ############################################################    
  94. ############################################################
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement