AntiMob Plugin (for Valkyrie/Valhala)macro

Other plugins for extending OpenKore's functionality. This forum is only for posting new plugins and commenting on existing plugins. For support, use the Support forum.

Moderator: Moderators

n00b
Human
Human
Posts: 33
Joined: 09 Dec 2009, 01:18
Noob?: No

AntiMob Plugin (for Valkyrie/Valhala)macro

#1 Post by n00b »

hi this is not my work.. i just want help on how to improve this macro

*This plugin will either use Insurance or Relog you for 60 seconds if ever get mobbed.

"Mob" on this plugin means, you have less than 50% HP and have (ceil(HP/10)-1) monsters attacking you. (e.g. 40% HP and 3 aggressives will trigger the plugin)

*antiMob (1|0) --> I set this to 1.
antiMob_useInsu (1|0) --> I set this to 1 as well.

i want to know if this macro can modify to move to another route? becoz it just reconnect if it got mob. and it bases its antimob to its HP...

Code: Select all

#-------------------------------------------------------------------------------
# AntiMob
# *  for servers that have their teleport skill disabled (pRO Valkyrie/Valhala)
# coded by RJ (vmkjwan)
#
# This source code is licensed under the
# GNU General Public License, Version 2.
# See http://www.gnu.org/licenses/gpl.html
# -----------------------------------------------------------------------------
# Change Log:
# v0.1 (05/17/08) - Initial
# v0.2 (05/18/08) - Added computation based on HP:Aggro ratio
# v0.3 (06/04/08) - Added Life Insurance option
# -----------------------------------------------------------------------------
# How to use this plugin:
#
# in control\config.txt, put:
#
# antiMob (1|0)            
# antiMob_useInsu (1|0)   
#
#------------------------------------------------------------------------------

package antiMob;

use strict;
use Plugins;
use Globals;
use Utils;
use Misc;
use Settings;

Plugins::register("antiMob", "Relog when getting Mobbed", \&unload);

my $hooks = Plugins::addHooks(
   ['packet_attack', \&onAttack, undef]
);

sub unload {
   Plugins::delHooks($hooks);
}

# default relogTime
my $relogTime = 60;

sub onAttack {
   return unless ($config{'antiMob'});
   my ($self, $args) = @_;
   my $aggros = scalar AI::ai_getAggressives();

   if ($args->{'targetID'} eq $accountID) {
      return if($args->{'dmg'} == 0);
      my $hp = $char->hp_percent();

      # I havent really tweaked the HP:Aggro ratio.. But it did saved me a lot of times
      if( $hp < 50 && ((ceil($hp/10)-1) >= $aggros) ) {
         Log::message(sprintf("Too many aggressives. HP: %s Aggro: %s\n", $hp, $aggros));

         # Should we use insu?
         if($config{'antiMob_useInsu'}) {
            # Check if theres an active Life Insurance status
            if(!$char->{statuses}{'Life Insurance'}) {
               my $insu = Actor::Item::get('Life Insurance', undef, 1);
               # Check if you really have the Life Insurance item
               if(defined $insu) {
                  Log::message("Using Life Insurance..\n");
                  $insu->use();
                  return;
               # You dont have it.. Relog
               } else {
                  Log::message("We dont have any Life Insurance item left.\n");
               }

            } else {         
               Log::message("Good thing we still have Life Insurance status.\n");
               return;
            }
         }
         Log::message("Relogging..\n");
         relog($relogTime);
      }
   }

}

sub ceil {
   my $r = shift;
   my $frac = $r - int($r);
   if($frac<=0) {
      return int($r);
   } else {
      return 1+int($r);
   }
}

1;
Last edited by n00b on 04 Feb 2010, 10:13, edited 1 time in total.
Mushroom
Perl Monk
Perl Monk
Posts: 427
Joined: 04 Apr 2008, 14:04
Noob?: No
Location: Brazil

Re: [Plugin] AntiMob Plugin (for Valkyrie/Valhala)

#2 Post by Mushroom »

Moved from Macro plugin to Plugin sections... :roll:
Quit.
n00b
Human
Human
Posts: 33
Joined: 09 Dec 2009, 01:18
Noob?: No

Re: [Plugin] AntiMob Plugin (for Valkyrie/Valhala)

#3 Post by n00b »

Mushroom wrote:Moved from Macro plugin to Plugin sections... :roll:
hehe hope that someone can help me :)

and modify this to a better anti mob :D

btw this is a macro :P
Mushroom
Perl Monk
Perl Monk
Posts: 427
Joined: 04 Apr 2008, 14:04
Noob?: No
Location: Brazil

Re: AntiMob Plugin (for Valkyrie/Valhala)macro

#4 Post by Mushroom »

No, this is a plugin and not the macro plugin.
Quit.
n00b
Human
Human
Posts: 33
Joined: 09 Dec 2009, 01:18
Noob?: No

Re: AntiMob Plugin (for Valkyrie/Valhala)macro

#5 Post by n00b »

oh... sorry im kinda newbie at this :(

thank you for correcting me xD

hope someone can help to improve this xD
niko123
Plain Yogurt
Plain Yogurt
Posts: 88
Joined: 11 Sep 2010, 19:00
Noob?: Yes

Re: AntiMob Plugin (for Valkyrie/Valhala)macro

#6 Post by niko123 »

where in my the control folder should i put this?
Image
niko123
Plain Yogurt
Plain Yogurt
Posts: 88
Joined: 11 Sep 2010, 19:00
Noob?: Yes

Re: AntiMob Plugin (for Valkyrie/Valhala)macro

#7 Post by niko123 »

do i have to edit some codes about dc and less than HP?? or naka setup na ?
Image
Mushroom
Perl Monk
Perl Monk
Posts: 427
Joined: 04 Apr 2008, 14:04
Noob?: No
Location: Brazil

Re: AntiMob Plugin (for Valkyrie/Valhala)macro

#8 Post by Mushroom »

The plugin should be places on plugins folder in your openkore root folder, if it doesn't exist create one.
Quit.
niko123
Plain Yogurt
Plain Yogurt
Posts: 88
Joined: 11 Sep 2010, 19:00
Noob?: Yes

Re: AntiMob Plugin (for Valkyrie/Valhala)macro

#9 Post by niko123 »

alright so my plug in is working..but it takes time to disconnect?? my character is still dying when its disconnected from the server
Image
benj1320
Moderators
Moderators
Posts: 403
Joined: 25 Aug 2008, 14:56
Noob?: No
Location: CyberOne Building , Eastwood

Re: AntiMob Plugin (for Valkyrie/Valhala)macro

#10 Post by benj1320 »

yup.. and the reason that your character dies is LAG ... there is a time interval when you logout from both the client and server....you'll notice that when you are actually playing, "You cannot logout in 10 seconds" something like that....

unless you have a stable internet connection or the server doesn't experience severe lag at the moment your character won't die...
“The moon shines to both guilty and innocent alike..”
The Openkore Manual---Global Forum Rules--The Template