Henrybk

onMonsterKill 3.0

Jun 30th, 2015
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.01 KB | None | 0 0
  1. #######
  2. #Plugin onMonsterKill by Henrybk
  3. #######
  4. package onMonsterKill;
  5.  
  6. use strict;
  7. use Globals;
  8. use Utils;
  9. use Misc;
  10. use AI;
  11. use Log qw(debug message warning error);
  12.  
  13. Plugins::register('onMonsterKill', 'Check killed monsters', \&on_unload, \&on_unload);
  14.  
  15. my $hooks = Plugins::addHooks(
  16.     ['target_died', \&on_Hash, undef]
  17. );
  18.  
  19. sub on_unload {
  20.     Plugins::delHooks($hooks);
  21. }
  22.  
  23. sub on_Hash {
  24.     my ($self, $args) = @_;
  25.     my $monster = $args->{monster};
  26.     my $i = 0;
  27.     while (exists $config{"onMonsterKill_$i"}) {
  28.         if ($config{"onMonsterKill_$i"} && checkSelfCondition("onMonsterKill_$i") && checkMonster("onMonsterKill_$i", $monster)) {
  29.             if ($config{"onMonsterKill_".$i."_quant_Killed"}) {
  30.                 if ($config{"onMonsterKill_".$i."_counter"}) { $config{"onMonsterKill_".$i."_counter"}++ } else { $config{"onMonsterKill_".$i."_counter"} = 1; }
  31.                 if ($config{"onMonsterKill_".$i."_counter"} >= $config{"onMonsterKill_".$i."_quant_Killed"}) {
  32.                     $config{"onMonsterKill_".$i."_counter"} = 0;
  33.                     Commands::run($config{"onMonsterKill_$i"});
  34.                     last;
  35.                 } else {
  36.                     next;
  37.                 }
  38.             } else {
  39.                 Commands::run($config{"onMonsterKill_$i"});
  40.                 last;
  41.             }
  42.         }
  43.     } continue {
  44.         $i++;
  45.     }
  46. }
  47.    
  48. sub checkMonster {
  49.     my ($prefix, $monster) = @_;
  50.     return 0 if (!$prefix);
  51.     return 0 if ($config{$prefix . "_disabled"});
  52.     if ($config{$prefix."_name"}) {
  53.         return 0 if ($monster->{name} ne $config{$prefix."_name"});
  54.     }
  55.     if ($config{$prefix."_name_given"}) {
  56.         return 0 if ($monster->{name_given} ne $config{$prefix."_name_given"});
  57.     }
  58.     if ($config{$prefix."_nameID"}) {
  59.         return 0 if ($monster->{nameID} ne $config{$prefix."_nameID"});
  60.     }
  61.     if ($config{$prefix."_dmgFromYou"}) {
  62.         return 0 if (!inRange($monster->{dmgFromYou}, $config{$prefix."_dmgFromYou"}));
  63.     }
  64.     if ($config{$prefix."_numAtkFromYou"}) {
  65.         return 0 if (!inRange($monster->{numAtkFromYou}, $config{$prefix."_numAtkFromYou"}));
  66.     }
  67.     if ($config{$prefix."_moblv"}) {
  68.         return 0 if ($monster->{lv} != $config{$prefix."_moblv"});
  69.     }
  70.     return 1;
  71. }
  72.  
  73. 1;
Advertisement
Add Comment
Please, Sign In to add comment