credit punkpudding
config options (add in config.txt):
petFeeder <flag> (new in v1.2)
flag: 1 = on, 0 = off
- enables/disables the plugin. disable the plugin if you have no pet & the plugin is causing problems for you.
petSmartFeed <flag>
flag: 1 = on, 0 = off
- when smart feed is on, the feed rate you specified (petFeedRate) will be ignored. when on, the bot will automatically select which hunger level to use based on the pet's intimacy. when pet is not loyal, the pet will be fed as soon as its hunger reaches neutral. when it's loyal, the pet will only be fed when it's hungry. perfect for quickly raising intimacy levels.
petFeedRate <rate>
- allows you to specify the hunger level to be used in feeding your pet. this option is only used when smart feed is off.
petMinHunger <rate>
- allows you to specify the hunger level to use in determining when to return the pet to egg status. if you (accidentally) set this too low (like 0), your pet will still be returned to egg as soon as its hunger gets close to "very hungry". (so even if you screw up, you won't lose your pet! Wink)
petPerformanceRate <rate> (new in v1.2)
- make your pet perform every <rate> seconds. if you don't set this option, the pet won't be automatically played. don't set the rate too low (lower than 5) - that'll make you look suspicious.
* playing with a pet is purely aesthetic. it won't affect you pet's intimacy. but it does look cool. Smile
petPerformanceRateSeed <rate> (new in v1.3)
- random value that is added to petPerformanceRate to make it look more realistic.
example: if the rate is 30 & the seed is 30, your pet will be automatically played after a random period between 30 and 60 (=30+30) seconds.
petPerformance_onAction <AI sequences> (new in v1.5)
- if this option is set, pet performance will only be used if at least one of the specified comma-separated list of AI sequences is curently active.
petPerformance_notOnAction <AI sequences> (new in v1.4)
- if this option is set, pet performance will only be used if none of the specified comma-separated list of AI sequences is curently active.
console commands:
note: you need to set "petFeeder 1" to enable console commands
pet s[tatus]
- display the pet's hunger & intimacy level.
pet f[eed]
- feed the pet.
pet p[erformance]
- make the pet perform.
pet r[eturn]- return the pet to egg.
pet u[nequip]
- unequip the pet's accessory.
other features:
1. shortened console commands
- you can now type "pet s" instead of "pet status", "pet f" instead of "pet feed", etc. but you can still use the old commands if you wish.
2. over-feeding prevention
- it won't allow you to feed your pet if its hunger status is full (even if you manually typed "pet f" in the console).
3. auto return to egg
- your pet will be automatically returned to egg status when its hunger gets close to "very hungry". this will prevent the pet from lowering its intimacy & running away. useful if you run out of pet food -if you're far from the store, or if your pet's food is rare (honey, shoot, etc).
some clarifications on pet food:
i've been asked about this a lot of times now so i thought i'd clarify it here: you don't need to specify what pet food this plugin has to use.
Usage
petFeeder 1
petFeedRate 50
petMinHunger 20
petPerformanceRate 30
petPerformanceRateSeed 30
petPerformance_notOnAction attack, skill_use
Code: Select all
# petFeeder v1.5
# -by punkpudding
package petFeeder;
use strict;
use Time::HiRes qw(time);
use Globals;
use Plugins;
use Log qw(debug message warning error);
use Utils;
use Commands;
use Network;
use Network::Send;
Plugins::register('petFeeder', 'petFeeder by punkpudding', \&onUnload, \&onReload);
my $hookCommandPost = Plugins::addHook('Command_post', \&onCommandPost);
my $hookAIpre = Plugins::addHook('AI_pre', \&onAIpre);
my $hookParseMsgPre = Plugins::addHook('parseMsg/pre', \&onParseMsgPre);
message "Pet feeding plugin loaded\n", "success";
my %pet;
my $hunger = 72;
my $performanceRate = $config{petPerformanceRate};
sub onUnload {
Plugins::delHook('parseMsg/pre', $hookParseMsgPre);
Plugins::delHook('AI_pre', $hookAIpre);
Plugins::delHook('Command_post', $hookCommandPost);
message "Pet feeding plugin unloaded\n", "success";
}
sub onReload {
&onUnload;
}
sub onCommandPost {
my (undef, $args) = @_;
my ($cmd, $subcmd) = split(' ', $args->{input}, 2);
if ($cmd eq "pet" && $config{petFeeder}) {
if ($subcmd eq "s" || $subcmd eq "status") {
message "Pet status: hungry=$pet{hungry} intimacy=$pet{friendly}\n";
} elsif ($subcmd eq "f" || $subcmd eq "feed") {
if ($pet{hungry} <= 72) {
message "Feeding your pet. [current intimacy : $pet{friendly}]\n";
sendPetFeed($::net);
sendPetGetInfo($::net);
} elsif ($pet{hungry} > 72) {
message "Your pet's not yet hungry. Feeding him now will lower intimacy.\n";
}
} elsif ($subcmd eq "p" || $subcmd eq "performance") {
message "Playing your pet.\n";
sendPetPerformance($::net);
} elsif ($subcmd eq "r" || $subcmd eq "return") {
message "Returning pet to egg status.\n";
sendPetReturnToEgg($::net);
} elsif ($subcmd eq "u" || $subcmd eq "unequip") {
message "Unequipping pet accessory.\n";
sendPetUnequipItem($::net);
} else {
error "Syntax Error in function 'pet' (pet management)\n" .
"Usage: pet < s[tatus] | f[eed] | p[erformance] | r[eturn] | u[nequip] >\n";
}
$args->{return} = 1;
}
}
sub onAIpre {
return unless ($main::conState == 5);
if ($config{petFeeder}) {
# request status
if (timeOut($pet{lastStatusInfo}, 30)) {
if (timeOut($pet{lastStatusRequest}, 10)) {
$pet{lastStatusRequest} = time;
sendPetGetInfo($::net);
if ($pet{friendly} < 990) { $hunger = 72; }
elsif ($pet{friendly} >=990) { $hunger = 30; }
}
}
# pet performance
if ((defined($config{petPerformanceRate}) && timeOut($pet{lastPerformance}, $performanceRate))
&& ((!$config{petPerformance_onAction}) || ($config{petPerformance_onAction} && existsInList($config{petPerformance_notOnAction}, AI::action())))
&& ((!$config{petPerformance_notOnAction}) || ($config{petPerformance_notOnAction} && !existsInList($config{petPerformance_notOnAction}, AI::action())))
) {
sendPetPerformance($::net);
message "Auto-playing your pet\n";
$performanceRate = $config{petPerformanceRate} if !defined($performanceRate);
$performanceRate = $config{petPerformanceRate} + int(rand $config{petPerformanceRateSeed}) if $config{petPerformanceRateSeed};
$pet{lastPerformance} = time;
}
}
}
sub onParseMsgPre {
my (undef, $args) = @_;
my $switch = $args->{switch};
my $msg = $args->{msg};
# process status
if ($switch eq "01A2" && $config{petFeeder}) {
$pet{name} = substr($msg, 2, 24) =~ /([\s\S]*?)\000/;
$pet{nameflag} = unpack("C1", substr($msg, 26, 1));
$pet{level} = unpack("S1", substr($msg, 27, 2));
$pet{hungry} = unpack("S1", substr($msg, 29, 2));
$pet{friendly} = unpack("S1", substr($msg, 31, 2));
$pet{accessory} = unpack("S1", substr($msg, 33, 2));
$pet{lastStatusInfo} = time;
debug "Pet status: level=$pet{level} hungry=$pet{hungry} intimacy=$pet{friendly}\n";
if ($config{petSmartFeed}) {
if ($pet{hungry} < $hunger && timeOut($pet{lastFeed}, 5) && $pet{friendly} > 0) {
$pet{lastFeed} = time;
sendPetFeed($::net);
sendPetGetInfo($::net);
message "Auto-feeding your pet. [current intimacy : $pet{friendly}]\n";
}
if ($pet{hungry} <= $config{petMinHunger} || $pet{hungry} <= 15) {
sendPetReturnToEgg($::net);
message "Critical hunger level reached. Pet returned to egg status.\n";
}
} else {
if ($pet{hungry} < $config{petFeedRate} && timeOut($pet{lastFeed}, 5) && $pet{friendly} > 0) {
$pet{lastFeed} = time;
sendPetFeed($::net);
sendPetGetInfo($::net);
message "Auto-feeding your pet. [current intimacy : $pet{friendly}]\n";
}
if ($pet{hungry} <= $config{petMinHunger} || $pet{hungry} <= 15) {
sendPetReturnToEgg($::net);
message "Critical hunger level reached. Pet returned to egg status.\n";
}
}
}
}
return 1;