Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.53 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. sub EVENT_TIMER {
  60.     if ($timer eq "getclientsRAMPAGE") {
  61.         $MaxDam = $npc->GetMaxDMG();
  62.         $ShieldMaxDam = ($MaxDam * 0.35);
  63.         $ShieldMinDam = $ShieldMaxDam / 2;
  64.         $DamageVar = ($npc->GetMaxDMG() * .35) - (($npc->GetMaxDMG() * .35) / 2);
  65.         $entity_list->MessageClose($npc, 1, 200, 13, "".$npc->GetCleanName()." goes on a WILD KMRA RAMPAGE");
  66.         @client_list = $entity_list->GetClientList();
  67.         foreach $single_client (@client_list) {
  68.             if ($single_client->CalculateDistance ($x, $y, $z) <= 57) {
  69.                 $RampDamageVar = (int ( rand($DamageVar) + $ShieldMinDam));
  70.                 $single_client->Damage($npc, $RampDamageVar, 7477, 1, true, -1, false);
  71.                 $single_client->Message(13,  "".$npc->GetCleanName()." hits YOU for $RampDamageVar points of damage");
  72.                 if ($single_client->GetPetID()) {
  73.                     $pet_to_dmg = $entity_list->GetMobByID($single_client->GetPetID());
  74.                     $pet_to_dmg->Damage($npc, $RampDamageVar, 7477, 1, true, -1, false);
  75.                 }
  76.             }
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement