Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pet #1345

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Pet #1345

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/AI/CoreLogic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3297,8 +3297,8 @@ sub processRepairAuto {
}

sub processFeed {
if ($config{pet_autoFeed} && timeOut($timeout{ai_petFeed}) && %pet && $pet{hungry} && ($pet{hungry} <= $config{pet_hunger} || $pet{hungry} <= $config{pet_return})) {
if ($pet{hungry} <= $config{pet_return} && %pet && $pet{hungry}) {
if ($config{pet_autoFeed} && timeOut($timeout{ai_petFeed}) && $pet{ID} && $pet{hungry} && ($pet{hungry} <= $config{pet_hunger} || $pet{hungry} <= $config{pet_return})) {
if ($pet{hungry} <= $config{pet_return} && $pet{ID} && $pet{hungry}) {
message TF("Pet hunger reaches the return value.\n");
$messageSender->sendPetMenu(3);
undef %pet; # todo: instead undef %pet when the actor (our pet) dissapears, this is safer (xkore)
Expand Down
13 changes: 8 additions & 5 deletions src/Network/Receive/ServerType0.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,7 @@ sub item_skill {
sub map_changed {
my ($self, $args) = @_;
$net->setState(4);
%pet = ();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, i might saying nonsense...

but why this needs to stay here? i mean, is already declared at Globals.pm isn't?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh now i understand, is to clear old values right? sorry for misunderstanding

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this should be in functions.pl, not here

Copy link
Contributor Author

@c4c1n6kr3m1 c4c1n6kr3m1 Sep 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lututui , the pet ID changed every map server , iRO

i put the code on functions.pl at november last year, work at that time
but not working with our bot date august with xkore 1 /3, so i need to put it on map_changed,looks like something is changed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But when map changes the method on functions.pl is always called... Or am I wrong?


my $oldMap = $field ? $field->baseName : undef; # Get old Map name without InstanceID
my ($map) = $args->{map} =~ /([\s\S]*)\./;
Expand Down Expand Up @@ -2663,10 +2664,15 @@ sub pet_info2 {
#}

if ($type == 0) {
# You own pet with this ID
$pet{ID} = $ID;
message("Pet ID: ".unpack("V1", $ID)."\n");
} elsif ($type == 5) {
# You own no pet.
undef $pet{ID};
return;# unless ($pet{ID} && ($pet{ID} eq $ID));
}

} elsif ($type == 1) {
if ($type == 1) {
$pet{friendly} = $value;
debug "Pet friendly: $value\n";

Expand All @@ -2683,9 +2689,6 @@ sub pet_info2 {
# performance info for any pet in range
#debug "Pet performance info: $value\n";

} elsif ($type == 5) {
# You own pet with this ID
$pet{ID} = $ID;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Network/XKore2/MapServer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ sub send_pet {
my $data = undef;
if (defined $pet{ID}) {
$data = pack('C2 C a4 V', 0xA4, 0x01, 0, $pet{ID}, 0);
$data .= pack('C2 C a4 V', 0xA4, 0x01, 5, $pet{ID}, 0x64);
$data .= pack('C2 C a4 V', 0xA4, 0x01, 5, $pet{ID}, 0x64);#<20171102>on iRO, this one only happen when hatch
$data .= pack('C2 Z24 C v4', 0xA2, 0x01,
stringToBytes($pet{name}), $pet{renameflag}, $pet{level},
$pet{hungry}, $pet{friendly}, $pet{accessory});
$pet{hungry}, $pet{friendly}, $pet{accessory}, $pet{type});
$client->send($data);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/functions.pl
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ sub initConnectVars {
undef @skillsID;
undef @partyUsersID;
undef %cashShop;
%pet = ();
}

# Initialize variables when you change map (after a teleport or after you walked into a portal)
Expand Down