diff --git a/src/AI/CoreLogic.pm b/src/AI/CoreLogic.pm index 40801a32a4..cbf7bcff5a 100644 --- a/src/AI/CoreLogic.pm +++ b/src/AI/CoreLogic.pm @@ -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) diff --git a/src/Network/Receive/ServerType0.pm b/src/Network/Receive/ServerType0.pm index 4cbfde1679..7d746f2668 100644 --- a/src/Network/Receive/ServerType0.pm +++ b/src/Network/Receive/ServerType0.pm @@ -2020,6 +2020,7 @@ sub item_skill { sub map_changed { my ($self, $args) = @_; $net->setState(4); + %pet = (); my $oldMap = $field ? $field->baseName : undef; # Get old Map name without InstanceID my ($map) = $args->{map} =~ /([\s\S]*)\./; @@ -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"; @@ -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; } } diff --git a/src/Network/XKore2/MapServer.pm b/src/Network/XKore2/MapServer.pm index 9ad1d640b6..d064bca502 100644 --- a/src/Network/XKore2/MapServer.pm +++ b/src/Network/XKore2/MapServer.pm @@ -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); } } diff --git a/src/functions.pl b/src/functions.pl index eb5990f45b..0984dbf061 100644 --- a/src/functions.pl +++ b/src/functions.pl @@ -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)