View Single Post
  #11  
Old 03-01-2018, 04:29 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

You may be able to use perl (or lua) to get what you're after if you aren't comfortable modifying and editing source code. Below is a rough example of how you might go about it.

The current plugin::GetGroupMembers() only returns clients, so I made one that should only return a list of bots in your group.

Code:
# USAGE: plugin::GetGroupedBots($client)
sub plugin::GetGroupedBots {

	my @b;
	if (my $g = shift->GetGroup()) {
		for (my $i = 0; $i < 6; $i++) {
			next unless (my $m = $g->GetMember($i));
			next if ($m->IsClient() || $m->IsNPC());
			push(@b, $m);
		}
	}
	return @b;
}
Something like this would go in your global_player.pl and it allows for "commands" that have fallen through to EVENT_SAY to be parsed and used. You likely want to use the Chat, SuppressCommandErrors rule in the database to avoid seeing error messages when you prepend your custom commands with # (and possibly ^). Or you could just match for healme without the hashmark. It's really entirely up to you and your PCRE skills.

Code:
sub EVENT_SAY {

	  $text =~ /#testing/ ? plugin::Debug( "ping" )
	: $text =~ /#healme/  ? HealMe()
	:                       return;
}

sub HealMe {

	foreach my $bot (plugin::GetGroupedBots($client)) {
		plugin::Debug($bot->GetCleanName()." is a bot.");
		# EXAMPLES OF STEPS THAT MIGHT GO HERE
		# 1. verify bot ownership
		# 2. determine best available spell for situation
		# 3. cast selected spell (interrupt any current spell)
	}
}
I mean you could go all kinds of crazy if you really wanted to...
Code:
use strict;
use warnings;
use EQEmu::Client;
use EQEmu::Bot;
use EQEmu::Group;
use EQEmu::constants qw(:races :classes :groups);
use Switch;

my $c = EQEmu::Client->new(
    name  => 'Abracadaver',
    class => NECROMANCER
);

my $g = EQEmu::Group->new(
    $c,
    EQEmu::Bot->new(
        name  => 'Peregrin',
        class => RANGER
    ),
    EQEmu::Bot->new(
        name  => 'Galen',
        class => CLERIC
    )
);

my $hB = undef;    # healer bot
my $hC = 0;        # healer class

# look for a healer
for ( my $i = 0 ; $i < MAX_GROUP_MEMBERS ; $i++ ) {
    next if not my $m = $g->members($i);
    $c->Message( 15,
            $m->GetCleanName() . " the "
          . (CLASS_L)[ $m->GetClass() ]
          . " is at "
          . $m->GetHPRatio()
          . "% health" );

    # only want bots
    next if not $m->IsBot();
    switch ( $m->GetClass() ) {
        case CLERIC {
            $hB = $m;
            $hC = CLERIC;
        }
        case DRUID {
            if ( $hC != CLERIC ) {
                $hB = $m;
                $hC = DRUID;
            }
        }
        case RANGER {
            if ( !$hC ) {
                $hB = $m;
                $hC = RANGER;
            }
        }
        else {
            next;
        }
    }

    # break loop at first cleric bot
    last if $hC == CLERIC;
}

print $hC;
I'm not so sure it's a good idea if you value your sanity...
Code:
package EQEmu::Mob;

use strict;
use warnings::register;
use Carp qw( confess );

# construction
sub new
{
    my $c = shift;
    my $p = length @_ == 1 && ref $_[0] ? shift : {@_};
    # required parameters
    foreach ('name', 'class') {
        exists $p->{$_}
            or confess "$_ is a required attribute";
    }
    # validate and initialize these attributes
    my $_name   = delete $p->{name};
    my $_class  = delete $p->{class};
    my $_health = delete $p->{health} || 100;
    $p->{_name}   = $c->_validateName($_name);
    $p->{_class}  = $c->_validateClass($_class);
    $p->{_health} = $c->_validateHealth($_health);
    # set flags
    $p->{_isClient} = ($c =~ /Client/) || 0;
    $p->{_isBot}    = ($c =~ /Bot/)    || 0;
    $p->{_isNPC}    = ($c =~ /NPC/)    || 0;
    $c->_initDone($p) if $c =~ /Mob/;
    return bless $p, $c;
}
sub _initDone
{
    my ($s, $p) = @_;
    my $c = ref $s || $s;
    foreach my $k (keys %{$p}) {
        next if $k =~ /^_/;
        warnings::warn("unhandled attribute ( $k => ".$p->{$k}." ) in $c");
    }
}

sub _validateName
{
    my ($self, $name) = @_;
    local $Carp::CarpLevel = $Carp::CarpLevel + 1;
    $name =~ /^#?[a-z_]*$/i
        or confess "invalid name ( $name )";
    return $name;
}
sub _validateClass
{
    my ($self, $class) = @_;
    local $Carp::CarpLevel = $Carp::CarpLevel + 1;
    $class ~~ [1..16]  ||
    $class ~~ [20..35] ||
    $class ~~ [40..41] ||
    $class ~~ [59..64] ||
    $class ~~ [67..71]
        or confess "invalid class ( $class )";
    return $class;
}
sub _validateHealth
{
    my ($self, $health) = @_;
    local $Carp::CarpLevel = $Carp::CarpLevel + 1;
    $health ~~ [0..100]
        or confess "invalid health % ( $health )";
    return $health;
}

sub GetClass
{
    shift->{_class};
}
sub GetCleanName
{
    shift->{_name};
}
sub IsBot
{
    shift->{_isBot};
}
sub IsClient
{
    shift->{_isClient};
}
sub IsNPC
{
    shift->{_isNPC};
}
sub GetHPRatio
{
    shift->{_health};
}
sub GetGroup
{
    return 0;
}

1;
But that's completely up to you...
Code:
package EQEmu::constants;

use Exporter qw(import);

# playable class long names
use constant CLASS_L => qw(
    Unknown Warrior Cleric Paladin Ranger Shadowknight Druid Monk Bard Rogue
    Shaman Necromancer Wizard Magician Enchanter Beastlord Berserker
);
# bitmasks for playable class abbreviations
use constant
{
    WAR  =>     1, CLR =>     2, PAL =>     4, RNG =>     8,
    SHD  =>    16, DRU =>    32, MNK =>    64, BRD =>   128,
    ROG  =>   256, SHM =>   512, NEC =>  1024, WIZ =>  2048,
    MAG  =>  4096, ENC =>  8192, BST => 16384, BER => 32768
};
# numeric values for playable class long names
use constant
{
    WARRIOR      =>  1, CLERIC    =>  2, PALADIN     =>  3, RANGER    =>  4,
    SHADOWKNIGHT =>  5, DRUID     =>  6, MONK        =>  7, BARD      =>  8,
    ROGUE        =>  9, SHAMAN    => 10, NECROMANCER => 11, WIZARD    => 12,
    MAGICIAN     => 13, ENCHANTER => 14, BEASTMASTER => 15, BERSERKER => 16
};
# playable race long names
use constant RACE_L =>
    '', # 0
    'Human', 'Barbarian', 'Erudite', 'Wood Elf', 'High Elf', 'Dark Elf',
    'Half-Elf', 'Dwarf', 'Troll', 'Ogre', 'Halfling', 'Gnome',
    '','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','Iksar','','Vah Shir',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','Froglok',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','','','','','','','','','',
    '','Drakkin'
;
# bitmasks for playable race abbreviations
use constant
{
    HUM =>    1, BAR =>    2, ERU =>     4, ELF =>     8,
    HIE =>   16, DEF =>   32, HEL =>    64, DWF =>   128,
    TRL =>  256, OGR =>  512, HLF =>  1024, GNM =>  2048,
    IKS => 4096, VAH => 8192, FRG => 16384, DRK => 32768
};
# numeric values for playable class long names
use constant
{
    HUMAN   =>  1, BARBARIAN =>  2, ERUDITE  =>  3, WOODELF =>  4,
    HIGHELF =>  5, DARKELF   =>  6, HALFELF  =>  7, DWARF   =>  8,
    TROLL   =>  9, OGRE      => 10, HALFLING => 11, GNOME   => 12,
    IKSAR   => 13, VAHSHIR   => 14, FROGLOK  => 15, DRAKKIN => 16
};
# groups stuff
use constant
{
    MAX_GROUP_MEMBERS => 6
};

# every exportable constant must be listed here
our @EXPORT_OK = (qw(
    RACE_L CLASS_L
    WAR CLR PAL RNG SHD DRU MNK BRD ROG SHM NEC WIZ MAG ENC BST BER
    WARRIOR      CLERIC     PALADIN      RANGER
    SHADOWKNIGHT DRUID      MONK         BARD
    ROGUE        SHAMAN     NECROMANCER  WIZARD
    MAGICIAN     ENCHANTER  BEASTMASTER  BERSERKER
    HUM BAR ERU ELF HIE DEF HEL DWF TRL OGR HLF GNM IKS VAH FRG DRK
    HUMAN   BARBARIAN ERUDITE  WOODELF
    HIGHELF DARKELF   HALFELF  DWARF
    TROLL   OGRE      HALFLING GNOME
    IKSAR   VAHSHIR   FROGLOK  DRAKKIN
    MAX_GROUP_MEMBERS
));
# tags for collections of exportable constants
our %EXPORT_TAGS = (
    races => [qw(
        RACE_L
        HUM BAR ERU ELF HIE DEF HEL DWF TRL OGR HLF GNM IKS VAH FRG DRK
        HUMAN   BARBARIAN ERUDITE  WOODELF
        HIGHELF DARKELF   HALFELF  DWARF
        TROLL   OGRE      HALFLING GNOME
        IKSAR   VAHSHIR   FROGLOK  DRAKKIN
    )],
    classes => [qw(
        CLASS_L
        WAR CLR PAL RNG SHD DRU MNK BRD ROG SHM NEC WIZ MAG ENC BST BER
        WARRIOR      CLERIC     PALADIN      RANGER
        SHADOWKNIGHT DRUID      MONK         BARD
        ROGUE        SHAMAN     NECROMANCER  WIZARD
        MAGICIAN     ENCHANTER  BEASTMASTER  BERSERKER
    )],
    groups => [qw(
        MAX_GROUP_MEMBERS
    )]
);

1;
I've played on some servers with the custom heal command. I could have sworn I had some source patches somewhere for it, but I haven't come across it yet.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote