Advertisement
Guest User

Untitled

a guest
Oct 17th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 4.69 KB | None | 0 0
  1. ###################################################################
  2. ### Global NPC Script                                           ###
  3. ###################################################################
  4. ##
  5. ###################################################################
  6.  
  7. sub EVENT_SPAWN{
  8. #Prevent pets or charmed NPCs from loading the default.pl
  9.     if (!$npc || $npc->GetOwnerID() || $npc->GetSwarmOwner())
  10.     {
  11.         return;
  12.     }
  13.    
  14.     if($entity_list->GetNPCByNPCTypeID(50) && $npc->GetEntityVariable("Scaled") != 1){ #:::  If not flagged as scaled, then scale the NPC
  15.         quest::signalwith(50, 21, 0);
  16.     }
  17. }
  18.  
  19. sub EVENT_KILLED_MERIT {
  20. #Prevent pets or charmed NPCs from loading the default.pl
  21.     if (!$npc || $npc->GetOwnerID() || $npc->GetSwarmOwner())
  22.     {
  23.         return;
  24.     }
  25.  
  26.     if ($mlevel <= 19)
  27.     {
  28.         my $concolor = $client->GetLevelCon($mlevel);
  29.         if ($concolor == 4 || $concolor == 13 || $concolor == 15 || $concolor == 18 || $concolor == 20) #If player gained xp - no farming grey's for credits.
  30.         {
  31.             #Adding 1 point/credit to the reborn_credits global
  32.             my $total = $client->GetGlobal("reborn_credits");
  33.             $total += 1;
  34.             $client->SetGlobal("reborn_credits", $total, 5, "F");
  35.             $client->Message(5, "You have gained a Reborn armor credit! You currently have $total.");
  36.         }
  37.     }
  38.    
  39.     if ($mlevel <= 34 && $mlevel > 19)
  40.     {
  41.         my $concolor = $client->GetLevelCon($mlevel);
  42.         if ($concolor == 4 || $concolor == 13 || $concolor == 15 || $concolor == 18 || $concolor == 20) #If player gained xp - no farming grey's for credits.
  43.         {
  44.             #Adding 1 point/credit to the redeemed_credits global
  45.             my $total = $client->GetGlobal("redeemed_credits");
  46.             $total += 1;
  47.             $client->SetGlobal("redeemed_credits", $total, 5, "F");
  48.             $client->Message(5, "You have gained a Redeemed armor credit! You currently have $total.");
  49.         }
  50.     }
  51.    
  52.     if ($mlevel <= 49 && $mlevel > 34)
  53.     {
  54.         my $concolor = $client->GetLevelCon($mlevel);
  55.         if ($concolor == 4 || $concolor == 13 || $concolor == 15 || $concolor == 18 || $concolor == 20) #If player gained xp - no farming grey's for credits.
  56.         {
  57.             #Adding 1 point/credit to the ascended_credits global
  58.             my $total = $client->GetGlobal("ascended_credits");
  59.             $total += 1;
  60.             $client->SetGlobal("ascended_credits", $total, 5, "F");
  61.             $client->Message(5, "You have gained an Ascended armor credit! You currently have $total.");
  62.         }
  63.     }
  64.    
  65.     ## Global plat script - each mob killed automatically gives the player x platinum.
  66.     my $money = 0;
  67.    
  68.     if ($client->GetLevelCon($mlevel) == 18) { ##CON_LIGHTBLUE
  69.         $money = int($mlevel * ($mlevel / $ulevel));
  70.     }
  71.     elsif ($client->GetLevelCon($mlevel) == 4) { ##CON_BLUE
  72.         $money = int($mlevel * ($mlevel / $ulevel));
  73.     }
  74.     elsif ($client->GetLevelCon($mlevel) == 20) { ##CON_WHITE
  75.         $money = int($mlevel * ($mlevel / $ulevel));
  76.     }
  77.     elsif ($client->GetLevelCon($mlevel) == 15) { ##CON_YELLOW
  78.         $money = int($mlevel * ($mlevel / $ulevel));
  79.     }
  80.     elsif ($client->GetLevelCon($mlevel) == 13) { ##CON_RED
  81.         if (($mlevel - $ulevel) >= 9) { ## Client 9 levels lower than mob - exploiting money drops.
  82.             $money = 0;
  83.         } else {
  84.             $money = int($mlevel * ($mlevel / $ulevel));
  85.         }
  86.     }
  87.     else { ##CON_GREY
  88.         $money = 0;
  89.     }
  90.        
  91.     my $ingroup = $client->GetGroup();
  92.  
  93.     if ($ingroup && $money > 0)
  94.     {
  95.         my $groupcount = $ingroup->GroupCount();
  96.        
  97.         $money /= $groupcount;
  98.         $client->AddMoneyToPP(0, 0, 0, $money, 1);
  99.         $client->Message(315,  "You receive " . $money . " Platinum as a reward for killing this NPC.");
  100.     }
  101.     elsif (!$ingroup && $money > 0)
  102.     {
  103.         $client->AddMoneyToPP(0, 0, 0, $money, 1);
  104.         $client->Message(315,  "You receive " . $money . " Platinum as a reward for killing this NPC.");   
  105.     }
  106. }
  107.  
  108. sub EVENT_DEATH {
  109. #Prevent pets or charmed NPCs from loading the default.pl
  110.     if (!$npc || $npc->GetOwnerID() || $npc->GetSwarmOwner())
  111.     {
  112.         return;
  113.     }
  114.        
  115. #10% Chance of getting a reborn weapon token if mob gave xp.
  116.     if ($mlevel <= 21)
  117.     {
  118.         my $concolor = $client->GetLevelCon($mlevel);
  119.         if ($concolor == 4 || $concolor == 13 || $concolor == 15 || $concolor == 18 || $concolor == 20) {
  120.             my $token = int(rand(99))+1;
  121.             if ($token <= 10) {
  122.                 $npc->AddItem(200084, 1); #reborn weapon token
  123.             }
  124.         }
  125.     }  
  126. }
  127.  
  128. sub EVENT_COMBAT {
  129. ## We only want pet's loading this script  
  130.     if ($npc->GetOwnerID())
  131.     {
  132.         if ($combat_state == 0) ## end combat - start heal timer
  133.         {
  134.             quest::settimer("pet_heal", 6);
  135.         }
  136.         elsif ($combat_state == 1) ## enter combat - stop heal timer if it is running
  137.         {
  138.             quest::stoptimer("pet_heal");
  139.         }
  140.     }
  141. }
  142.  
  143. sub EVENT_TIMER {
  144. ## We only want pet's loading this script  
  145.     if ($npc->GetOwnerID())
  146.     {
  147.         if ($timer eq "pet_heal")
  148.         {
  149.             $npc->SetHP($npc->GetMaxHP());
  150.             quest::stoptimer("pet_heal");
  151.         }
  152.     }
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement