waitForParty -- Don't get separeted! by Chontrad

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

Message
Author
unholysin
Noob
Noob
Posts: 15
Joined: 30 Jul 2012, 09:35
Noob?: No

Re: waitForParty -- Don't get separeted! by Chontrad

#111 Post by unholysin »

################################
# Name of Plugin: follow_wait.pl
# Author: dijedodol@yahoo.com
# Instruction:
# follow_wait 1
# follow_wait_minDistance 5
# follow_wait_maxDistance 20
# follow_wait_preLostTimeOut 1
# follow_wait_timeout 0
# follow_wait_positionTimeOut 2
# follow_wait_searchAttackOnRoute 1
# Description:
# follow_wait = enable / disabled follow_wait
# follow_wait_minDistance = wait until this distance is reached
# follow_wait_maxDistance = distance before follow wait trigger lost check
# follow_wait_preLostTimeOut = when max distance is reached, keep ignoring for x sec before party member is marked as lost
# follow_wait_timeout = when party member is lost, wait x sec (sitting) until party member is arrived
# follow_wait_positionTimeOut = when party member is lost and wait timeout has been triggered, start moving to search for party member and check his latest location every x sec
# follow_wait_searchAttackOnRoute = openkore route AI, allow to attack monster or not while moving to search for party member
################################

package follow_wait;

use Time::HiRes qw(time);
use Plugins;
use Globals;
use Utils::DataStructures qw(existsInList);
use Log qw(message warning error debug);

Plugins::register('follow_wait', 'Wait for party member following you', \&unload, \&reload);
my $hooks = Plugins::addHooks(['mainLoop_pre', \&followWaitMainWrapper, undef]);

my $checkInterval = 500_000 / 1000_000;
my $lastCheckTick = 0;

my $isSearching = 0;
my $lostMemberUserId = 0;
my $preLostTimeOutTick = 0;
my $pauseMovementTimeOutTick = 0;
my $lostMemberPositionLastTick = 0;

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

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

sub followWaitMainWrapper {
return unless ($config{'follow_wait'});
return unless ((time() - $lastCheckTick) > $checkInterval);
followWaitMain();
$lastCheckTick = time();
}

sub followWaitMain {
return if (!$net || $net->getState() != Network::IN_GAME);
return unless ($AI == AI::AUTO);
return unless ($char->{party});
return unless (!AI::inQueue("storageAuto","storageGet","sellAuto","buyAuto"));

if ($isSearching != 1 && $isSearching != 2) {
resumeMovement();
}

if ($isSearching == 0) {
for (my $i = 0; $i < @partyUsersID; $i++) {
my $memberUserId = $partyUsersID[$i];
next if ($memberUserId eq "");
next if ($memberUserId eq $accountID);
next unless ($char->{'party'}{'users'}{$memberUserId}{'online'});
next unless $config{'follow_wait_list'} eq "" || existsInList($config{'follow_wait_list'}, $char->{'party'}{'users'}{$memberUserId}{'name'});

my $isMemberAround = isMemberAround($memberUserId);
if ($isMemberAround == 0) {
warning "Unknown party member User ID: " .$lostMemberUserId ."!\n";
next;
} elsif ($isMemberAround == 1) {
warning "Unexpected follow_wait searching own self!\n";
next;
} elsif ($isMemberAround == 2) {
#ignore offline party member
next;
} elsif ($isMemberAround == 3) {
#ignore unknown party member location
next;
} elsif ($isMemberAround == 4) {
#party member is on the different map, skip directly to party member search
$isSearching = 4;
$lostMemberUserId = $memberUserId;
last;
} elsif ($isMemberAround == 5) {
#party member is on the same map, try pausing movement to wait
$lostMemberUserId = $memberUserId;
if ($config{'follow_wait_timeout'} == 0) {
#skip directly to party member search, waiting has been disabled
$isSearching = 3;
} elsif ($config{'follow_wait_preLostTimeOut'}) {
#ignore until pre-lost timeout occured
warning "Party member pre-lost: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ."!\n";
$isSearching = 5;
$preLostTimeOutTick = time();
} else {
#wait party member until timeout
$isSearching = 1;
}
last;
} elsif ($isMemberAround == 255) {
#party member is currently on sight
next;
} else {
warning "Unexpected isMemberAround result: " .$isMemberAround ."!\n";
next;
}
}
} elsif ($isSearching == 1) {
$pauseMovementTimeOutTick = time();
pauseMovement();
$isSearching = 2;
} elsif ($isSearching == 2) {
my $isMemberAround = isMemberAround($lostMemberUserId);
if ($isMemberAround == 0) {
warning "Unknown party member User ID: " .$lostMemberUserId ."!\n";
$isSearching = 0;
resumeMovement();
} elsif ($isMemberAround == 1) {
warning "Unexpected follow_wait searching own self!\n";
$isSearching = 0;
resumeMovement();
} elsif ($isMemberAround == 2) {
warning "Canceling party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." search due to user offline!\n";
$isSearching = 0;
resumeMovement();
} elsif ($isMemberAround == 3) {
if (Utils::timeOut($pauseMovementTimeOutTick, $config{'follow_wait_timeout'})) {
warning "Canceling party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." wait due to timeout and unknown user location!\n";
$isSearching = 0;
resumeMovement();
}
} elsif ($isMemberAround == 255) {
warning "Party member arrived: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ."!\n";
$isSearching = 0;
resumeMovement();
} elsif ($isMemberAround == 4 || $isMemberAround == 5) {
if (Utils::timeOut($pauseMovementTimeOutTick, $config{'follow_wait_timeout'})) {
#timeout on waiting party member to arrive, initiate party member search
warning "Timeout waiting for party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} .", initiating party member search!\n";
if($isMemberAround == 4) {
#not on the same map
$isSearching = 4;
} else {
#on the same map
$isSearching = 3;
}
resumeMovement();
}
} else {
warning "Unexpected isMemberAround result: " .$isMemberAround ."!\n";
$isSearching = 0;
resumeMovement();
}
} elsif ($isSearching == 3) {
my $isMemberAround = isMemberAround($lostMemberUserId);
if ($isMemberAround == 0) {
warning "Unknown party member User ID: " .$lostMemberUserId ."!\n";
$isSearching = 0;
} elsif ($isMemberAround == 1) {
warning "Unexpected follow_wait searching own self!\n";
$isSearching = 0;
} elsif ($isMemberAround == 2) {
warning "Canceling party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." search due to user offline!\n";
$isSearching = 0;
} elsif ($isMemberAround == 3) {
warning "Canceling party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." search due to unknown user location!\n";
$isSearching = 0;
} elsif ($isMemberAround == 4) {
#not on the same map
$isSearching = 4;
} elsif ($isMemberAround == 5) {
if (Utils::timeOut($lostMemberPositionLastTick, $config{'follow_wait_positionTimeOut'})) {
#warning "Updating search location for party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." too far away!\n";
$lostMemberPositionLastTick = time();
searchPartyMember($lostMemberUserId);
}
} elsif ($isMemberAround == 255) {
warning "Party member found: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ."!\n";
$isSearching = 0;
} else {
warning "Unexpected isMemberAround result: " .$isMemberAround ."!\n";
$isSearching = 0;
}
} elsif ($isSearching == 4) {
my $isMemberAround = isMemberAround($lostMemberUserId);
if ($isMemberAround == 0) {
warning "Unknown party member User ID: " .$lostMemberUserId ."!\n";
$isSearching = 0;
} elsif ($isMemberAround == 1) {
warning "Unexpected follow_wait searching own self!\n";
$isSearching = 0;
} elsif ($isMemberAround == 2) {
warning "Canceling party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." search due to user offline!\n";
$isSearching = 0;
} elsif ($isMemberAround == 3) {
#unknown position on the same map, initiate wait
$isSearching = 1;
} elsif ($isMemberAround == 4) {
if (Utils::timeOut($lostMemberPositionLastTick, $config{'follow_wait_positionTimeOut'})) {
(my $memberMap = $char->{'party'}{'users'}{$memberUserId}{'map'}) =~ s/\.gat//;
if ($memberMap eq $config{'saveMap'} && $config{'follow_wait_saveMapTeleport'}) {
Misc::useTeleport(2);
} else {
#warning "Updating search location for party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." not on the same map!\n";
$lostMemberPositionLastTick = time();
searchPartyMember($lostMemberUserId);
}
}
} elsif ($isMemberAround == 5) {
#on the same map
$isSearching = 3;
} elsif ($isMemberAround == 255) {
warning "Party member found: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ."!\n";
$isSearching = 0;
} else {
warning "Unexpected isMemberAround result: " .$isMemberAround ."!\n";
$isSearching = 0;
}
} elsif ($isSearching == 5) {
if (Utils::timeOut($preLostTimeOutTick, $config{'follow_wait_preLostTimeOut'})) {
my $isMemberAround = isMemberAround($lostMemberUserId);
if ($isMemberAround == 0) {
warning "Unknown party member User ID: " .$lostMemberUserId ."!\n";
$isSearching = 0;
} elsif ($isMemberAround == 1) {
warning "Unexpected follow_wait searching own self!\n";
$isSearching = 0;
} elsif ($isMemberAround == 2) {
warning "Canceling party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." pre-lost due to user offline!\n";
$isSearching = 0;
} elsif ($isMemberAround == 3) {
#unknown position on the same map, initiate wait
$isSearching = 1;
} elsif ($isMemberAround == 4) {
#party member is on the different map
$isSearching = 4;
} elsif ($isMemberAround == 5) {
#party member is on the same map, try pausing movement to wait
if ($config{'follow_wait_timeout'} == 0) {
#skip directly to party member search, waiting has been disabled
$isSearching = 3;
} else {
#wait party member until timeout
$isSearching = 1;
}
} elsif ($isMemberAround == 255) {
#party member is currently on sight
warning "Pre-lost party member arrived: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ."!\n";
$isSearching = 0;
} else {
warning "Unexpected isMemberAround result: " .$isMemberAround ."!\n";
$isSearching = 0;
}
}
} else {
warning "Unexpected isSearching value: " .$isMemberAround ."!\n";
$isSearching = 0;
}
}

sub isMemberAround {
my $memberUserId = @_[0];
if ($memberUserId && $char->{'party'}{'users'}{$memberUserId}) {
if ($memberUserId eq $accountID) {
return 1;
} elsif (!$char->{'party'}{'users'}{$memberUserId}{'online'}) {
return 2;
} else {
(my $masterMap = $field->name) =~ s/\.gat//;
(my $memberMap = $char->{'party'}{'users'}{$memberUserId}{'map'}) =~ s/\.gat//;

if ($char->{'party'}{'users'}{$memberUserId}{'pos'}{'x'} == 0 && $char->{'party'}{'users'}{$memberUserId}{'pos'}{'y'} == 0) {
if ($masterMap eq $memberMap) {
return 3;
} else {
return 4;
}
} elsif ($masterMap ne $memberMap) {
return 4;
} else {
$memberDistance = Utils::distance($char->{'party'}{'users'}{$memberUserId}{'pos'}, $char->{'pos_to'});
if ($isSearching) {
if ($memberDistance <= $config{'follow_wait_minDistance'}) {
return 255;
} else {
return 5;
}
} else {
if ($memberDistance <= $config{'follow_wait_maxDistance'}) {
return 255;
} else {
return 5;
}
}
}
}
} else {
return 0;
}
}

sub searchPartyMember {
my $memberUserId = @_[0];
(my $memberMap = $char->{'party'}{'users'}{$memberUserId}{'map'}) =~ s/\.gat//;
my $memberX = $char->{'party'}{'users'}{$memberUserId}{'pos'}{'x'};
my $memberY = $char->{'party'}{'users'}{$memberUserId}{'pos'}{'y'};

if ($memberX == 0 && $memberY == 0) {
undef $memberX;
undef $memberY;
}

if (!AI::ai_getAggressives()) {
warning "Searching for party member: " .$char->{'party'}{'users'}{$memberUserId}{'name'} ." on map: " .$memberMap ."(" .$memberX .", " .$memberY .")!\n";
AI::clear("move", "route", "mapRoute");
AI::ai_route($memberMap, $memberX, $memberY,
attackOnRoute => $config{'follow_wait_searchAttackOnRoute'},
noSitAuto => 1,
notifyUponArrival => 1);
}
}

sub pauseMovement {
if (!$char->{'sitting'}) {
warning "Pausing AI movement!\n";
Commands::cmdSit();
}
}

sub resumeMovement {
if ($char->{'sitting'}) {
warning "AI movement has been resumed!\n";
Commands::cmdStand();
}
}

return 1;
Thanks for this plugins this works as a charm cheers

Metrorex
Noob
Noob
Posts: 19
Joined: 04 Aug 2010, 05:46
Noob?: Yes

Re: waitForParty -- Don't get separeted! by Chontrad

#112 Post by Metrorex »

Mucilon wrote:This plugin was made and posted at old forum by Chontrad, at this address: http://bibian.ath.cx/openkore/viewtopic.php?t=38379
Originaly it was made upon modifications to openkore base code, so to get this work to the original openkore, I made some changes to this plugin.

What it does:
This great plugin was made to be used at the party's masterbot, checking if the follow bot is around, if not, the masterbot will search for it, walking to followbot's last known position. When they found each other, the masterbot will clear the AI and return to its AI normal sequence...
This plugin can replace the followBot option at config.txt, where the followbot sends pms to masterbot, telling him where to go (the place where the followbot is).
This plugin is better then followBot option at config.txt, cause at this option the masterbot normally pass thru the followbot, walking to the position where the followbot was a few seconds ago and both walk back some steps before the masterbot return to its normal AI sequence. At this plugin as soon as the followbot is insight of the masterbot (based on followDistanceMax of the masterbot) the masterbot returns to its normal AI sequence.
TIP: If you have a buffer and a melee in a party, just use the follow 1 at the buffer bot and the follow_wait 1 at the melee bot. You don't need to use the follow_wait 1 to both. In this case, masterbot = melee bot and followbot = buffer bot.

Changes:
v1.0
- Inserted the AI_pre hook, so the plugin could work, since I don't know where were placed the new hooks made by Chontrad at the mod openkore base code.
- Take off the sit and stand commands, with the new hook (AI_pre), the bot was playing of sit and stand...
- I didn't take off the other hooks, but I think that most of them don't exist!
- Translated the messages.
- Added follow_wait_inLockOnly option, thanks to fco2783. (16/05/2008)

v1.1
- Added follow_wait_noPartyMember option (03/10/2008)
- Added follow_wait_timeOut option (03/10/2008)

How to Install:
1) Download the file waitParty.pl.
2) Place it at plugins folder.

How to Use:
Just use this at config.txt.

Code: Select all

follow_wait 1       #(0|1) Use 1 to enable the plugin to run.
follow_wait_inLockOnly        #(0|1) Use 1 to enable the bot to wait for party only at lock map
follow_wait_timeOut 20       #Number of seconds between each check of distance to the followbot
follow_wait_noPartyMember <partyname>       #Name of a player at the party to do not wait for him (only one name)
File:
waitParty.pl
Author's Version (Chontrad) DON'T USE THIS VERSION, IT'S OUTDATED.
How to install :
The author uses self defined hooks instead of 'AI_pre' to reduce PC usage.
So you must copy the modified <Src\Network\Receive.pm> file.
The author use 'Bahasa' instead of 'English' to promote INDONESIA. :D
But it is already translated.

How to use :
<config.txt>
wait4party (0|1) Wait4Party On or Off
wait4party_sameMapOnly (0|1) Only activate if the party member are in the same map
wait4party_waitBySitting (0|1) Don't search, just sit and wait
wait4party_followSit (0|1) Sitting when party is sitting
ATTENTION! Turn off 'followSitAuto' or they'll sit forever!
waitForParty.pl
Receive.pm
I hope you enjoy it! ;)


LINK UPDATE PLEASE

Metrorex
Noob
Noob
Posts: 19
Joined: 04 Aug 2010, 05:46
Noob?: Yes

Re: waitForParty -- Don't get separeted! by Chontrad

#113 Post by Metrorex »

LINK UPDATE PLEASE FOR LAST VERSION OPENKORE

palancho
Human
Human
Posts: 39
Joined: 28 Mar 2017, 03:08
Noob?: Yes

Re: waitForParty -- Don't get separeted! by Chontrad

#114 Post by palancho »

Would be gr8 to have newest version :)

User avatar
SkylorD
Moderators
Moderators
Posts: 1166
Joined: 16 Dec 2011, 02:53
Noob?: No
Location: Brazil
Contact:

Re: waitForParty -- Don't get separeted! by Chontrad

#115 Post by SkylorD »

3 years my brother ? why !
Learn rules

zexeta
Plain Yogurt
Plain Yogurt
Posts: 54
Joined: 11 Jul 2017, 00:49
Noob?: No

Re: waitForParty -- Don't get separeted! by Chontrad

#116 Post by zexeta »

unholysin wrote:
################################
# Name of Plugin: follow_wait.pl
# Author: dijedodol@yahoo.com
# Instruction:
# follow_wait 1
# follow_wait_minDistance 5
# follow_wait_maxDistance 20
# follow_wait_preLostTimeOut 1
# follow_wait_timeout 0
# follow_wait_positionTimeOut 2
# follow_wait_searchAttackOnRoute 1
# Description:
# follow_wait = enable / disabled follow_wait
# follow_wait_minDistance = wait until this distance is reached
# follow_wait_maxDistance = distance before follow wait trigger lost check
# follow_wait_preLostTimeOut = when max distance is reached, keep ignoring for x sec before party member is marked as lost
# follow_wait_timeout = when party member is lost, wait x sec (sitting) until party member is arrived
# follow_wait_positionTimeOut = when party member is lost and wait timeout has been triggered, start moving to search for party member and check his latest location every x sec
# follow_wait_searchAttackOnRoute = openkore route AI, allow to attack monster or not while moving to search for party member
################################

package follow_wait;

use Time::HiRes qw(time);
use Plugins;
use Globals;
use Utils::DataStructures qw(existsInList);
use Log qw(message warning error debug);

Plugins::register('follow_wait', 'Wait for party member following you', \&unload, \&reload);
my $hooks = Plugins::addHooks(['mainLoop_pre', \&followWaitMainWrapper, undef]);

my $checkInterval = 500_000 / 1000_000;
my $lastCheckTick = 0;

my $isSearching = 0;
my $lostMemberUserId = 0;
my $preLostTimeOutTick = 0;
my $pauseMovementTimeOutTick = 0;
my $lostMemberPositionLastTick = 0;

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

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

sub followWaitMainWrapper {
return unless ($config{'follow_wait'});
return unless ((time() - $lastCheckTick) > $checkInterval);
followWaitMain();
$lastCheckTick = time();
}

sub followWaitMain {
return if (!$net || $net->getState() != Network::IN_GAME);
return unless ($AI == AI::AUTO);
return unless ($char->{party});
return unless (!AI::inQueue("storageAuto","storageGet","sellAuto","buyAuto"));

if ($isSearching != 1 && $isSearching != 2) {
resumeMovement();
}

if ($isSearching == 0) {
for (my $i = 0; $i < @partyUsersID; $i++) {
my $memberUserId = $partyUsersID[$i];
next if ($memberUserId eq "");
next if ($memberUserId eq $accountID);
next unless ($char->{'party'}{'users'}{$memberUserId}{'online'});
next unless $config{'follow_wait_list'} eq "" || existsInList($config{'follow_wait_list'}, $char->{'party'}{'users'}{$memberUserId}{'name'});

my $isMemberAround = isMemberAround($memberUserId);
if ($isMemberAround == 0) {
warning "Unknown party member User ID: " .$lostMemberUserId ."!\n";
next;
} elsif ($isMemberAround == 1) {
warning "Unexpected follow_wait searching own self!\n";
next;
} elsif ($isMemberAround == 2) {
#ignore offline party member
next;
} elsif ($isMemberAround == 3) {
#ignore unknown party member location
next;
} elsif ($isMemberAround == 4) {
#party member is on the different map, skip directly to party member search
$isSearching = 4;
$lostMemberUserId = $memberUserId;
last;
} elsif ($isMemberAround == 5) {
#party member is on the same map, try pausing movement to wait
$lostMemberUserId = $memberUserId;
if ($config{'follow_wait_timeout'} == 0) {
#skip directly to party member search, waiting has been disabled
$isSearching = 3;
} elsif ($config{'follow_wait_preLostTimeOut'}) {
#ignore until pre-lost timeout occured
warning "Party member pre-lost: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ."!\n";
$isSearching = 5;
$preLostTimeOutTick = time();
} else {
#wait party member until timeout
$isSearching = 1;
}
last;
} elsif ($isMemberAround == 255) {
#party member is currently on sight
next;
} else {
warning "Unexpected isMemberAround result: " .$isMemberAround ."!\n";
next;
}
}
} elsif ($isSearching == 1) {
$pauseMovementTimeOutTick = time();
pauseMovement();
$isSearching = 2;
} elsif ($isSearching == 2) {
my $isMemberAround = isMemberAround($lostMemberUserId);
if ($isMemberAround == 0) {
warning "Unknown party member User ID: " .$lostMemberUserId ."!\n";
$isSearching = 0;
resumeMovement();
} elsif ($isMemberAround == 1) {
warning "Unexpected follow_wait searching own self!\n";
$isSearching = 0;
resumeMovement();
} elsif ($isMemberAround == 2) {
warning "Canceling party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." search due to user offline!\n";
$isSearching = 0;
resumeMovement();
} elsif ($isMemberAround == 3) {
if (Utils::timeOut($pauseMovementTimeOutTick, $config{'follow_wait_timeout'})) {
warning "Canceling party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." wait due to timeout and unknown user location!\n";
$isSearching = 0;
resumeMovement();
}
} elsif ($isMemberAround == 255) {
warning "Party member arrived: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ."!\n";
$isSearching = 0;
resumeMovement();
} elsif ($isMemberAround == 4 || $isMemberAround == 5) {
if (Utils::timeOut($pauseMovementTimeOutTick, $config{'follow_wait_timeout'})) {
#timeout on waiting party member to arrive, initiate party member search
warning "Timeout waiting for party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} .", initiating party member search!\n";
if($isMemberAround == 4) {
#not on the same map
$isSearching = 4;
} else {
#on the same map
$isSearching = 3;
}
resumeMovement();
}
} else {
warning "Unexpected isMemberAround result: " .$isMemberAround ."!\n";
$isSearching = 0;
resumeMovement();
}
} elsif ($isSearching == 3) {
my $isMemberAround = isMemberAround($lostMemberUserId);
if ($isMemberAround == 0) {
warning "Unknown party member User ID: " .$lostMemberUserId ."!\n";
$isSearching = 0;
} elsif ($isMemberAround == 1) {
warning "Unexpected follow_wait searching own self!\n";
$isSearching = 0;
} elsif ($isMemberAround == 2) {
warning "Canceling party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." search due to user offline!\n";
$isSearching = 0;
} elsif ($isMemberAround == 3) {
warning "Canceling party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." search due to unknown user location!\n";
$isSearching = 0;
} elsif ($isMemberAround == 4) {
#not on the same map
$isSearching = 4;
} elsif ($isMemberAround == 5) {
if (Utils::timeOut($lostMemberPositionLastTick, $config{'follow_wait_positionTimeOut'})) {
#warning "Updating search location for party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." too far away!\n";
$lostMemberPositionLastTick = time();
searchPartyMember($lostMemberUserId);
}
} elsif ($isMemberAround == 255) {
warning "Party member found: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ."!\n";
$isSearching = 0;
} else {
warning "Unexpected isMemberAround result: " .$isMemberAround ."!\n";
$isSearching = 0;
}
} elsif ($isSearching == 4) {
my $isMemberAround = isMemberAround($lostMemberUserId);
if ($isMemberAround == 0) {
warning "Unknown party member User ID: " .$lostMemberUserId ."!\n";
$isSearching = 0;
} elsif ($isMemberAround == 1) {
warning "Unexpected follow_wait searching own self!\n";
$isSearching = 0;
} elsif ($isMemberAround == 2) {
warning "Canceling party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." search due to user offline!\n";
$isSearching = 0;
} elsif ($isMemberAround == 3) {
#unknown position on the same map, initiate wait
$isSearching = 1;
} elsif ($isMemberAround == 4) {
if (Utils::timeOut($lostMemberPositionLastTick, $config{'follow_wait_positionTimeOut'})) {
(my $memberMap = $char->{'party'}{'users'}{$memberUserId}{'map'}) =~ s/\.gat//;
if ($memberMap eq $config{'saveMap'} && $config{'follow_wait_saveMapTeleport'}) {
Misc::useTeleport(2);
} else {
#warning "Updating search location for party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." not on the same map!\n";
$lostMemberPositionLastTick = time();
searchPartyMember($lostMemberUserId);
}
}
} elsif ($isMemberAround == 5) {
#on the same map
$isSearching = 3;
} elsif ($isMemberAround == 255) {
warning "Party member found: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ."!\n";
$isSearching = 0;
} else {
warning "Unexpected isMemberAround result: " .$isMemberAround ."!\n";
$isSearching = 0;
}
} elsif ($isSearching == 5) {
if (Utils::timeOut($preLostTimeOutTick, $config{'follow_wait_preLostTimeOut'})) {
my $isMemberAround = isMemberAround($lostMemberUserId);
if ($isMemberAround == 0) {
warning "Unknown party member User ID: " .$lostMemberUserId ."!\n";
$isSearching = 0;
} elsif ($isMemberAround == 1) {
warning "Unexpected follow_wait searching own self!\n";
$isSearching = 0;
} elsif ($isMemberAround == 2) {
warning "Canceling party member: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ." pre-lost due to user offline!\n";
$isSearching = 0;
} elsif ($isMemberAround == 3) {
#unknown position on the same map, initiate wait
$isSearching = 1;
} elsif ($isMemberAround == 4) {
#party member is on the different map
$isSearching = 4;
} elsif ($isMemberAround == 5) {
#party member is on the same map, try pausing movement to wait
if ($config{'follow_wait_timeout'} == 0) {
#skip directly to party member search, waiting has been disabled
$isSearching = 3;
} else {
#wait party member until timeout
$isSearching = 1;
}
} elsif ($isMemberAround == 255) {
#party member is currently on sight
warning "Pre-lost party member arrived: " .$char->{'party'}{'users'}{$lostMemberUserId}{'name'} ."!\n";
$isSearching = 0;
} else {
warning "Unexpected isMemberAround result: " .$isMemberAround ."!\n";
$isSearching = 0;
}
}
} else {
warning "Unexpected isSearching value: " .$isMemberAround ."!\n";
$isSearching = 0;
}
}

sub isMemberAround {
my $memberUserId = @_[0];
if ($memberUserId && $char->{'party'}{'users'}{$memberUserId}) {
if ($memberUserId eq $accountID) {
return 1;
} elsif (!$char->{'party'}{'users'}{$memberUserId}{'online'}) {
return 2;
} else {
(my $masterMap = $field->name) =~ s/\.gat//;
(my $memberMap = $char->{'party'}{'users'}{$memberUserId}{'map'}) =~ s/\.gat//;

if ($char->{'party'}{'users'}{$memberUserId}{'pos'}{'x'} == 0 && $char->{'party'}{'users'}{$memberUserId}{'pos'}{'y'} == 0) {
if ($masterMap eq $memberMap) {
return 3;
} else {
return 4;
}
} elsif ($masterMap ne $memberMap) {
return 4;
} else {
$memberDistance = Utils::distance($char->{'party'}{'users'}{$memberUserId}{'pos'}, $char->{'pos_to'});
if ($isSearching) {
if ($memberDistance <= $config{'follow_wait_minDistance'}) {
return 255;
} else {
return 5;
}
} else {
if ($memberDistance <= $config{'follow_wait_maxDistance'}) {
return 255;
} else {
return 5;
}
}
}
}
} else {
return 0;
}
}

sub searchPartyMember {
my $memberUserId = @_[0];
(my $memberMap = $char->{'party'}{'users'}{$memberUserId}{'map'}) =~ s/\.gat//;
my $memberX = $char->{'party'}{'users'}{$memberUserId}{'pos'}{'x'};
my $memberY = $char->{'party'}{'users'}{$memberUserId}{'pos'}{'y'};

if ($memberX == 0 && $memberY == 0) {
undef $memberX;
undef $memberY;
}

if (!AI::ai_getAggressives()) {
warning "Searching for party member: " .$char->{'party'}{'users'}{$memberUserId}{'name'} ." on map: " .$memberMap ."(" .$memberX .", " .$memberY .")!\n";
AI::clear("move", "route", "mapRoute");
AI::ai_route($memberMap, $memberX, $memberY,
attackOnRoute => $config{'follow_wait_searchAttackOnRoute'},
noSitAuto => 1,
notifyUponArrival => 1);
}
}

sub pauseMovement {
if (!$char->{'sitting'}) {
warning "Pausing AI movement!\n";
Commands::cmdSit();
}
}

sub resumeMovement {
if ($char->{'sitting'}) {
warning "AI movement has been resumed!\n";
Commands::cmdStand();
}
}

return 1;
Thanks for this plugins this works as a charm cheers
Anyone have an updated version of this or any idea on how to fix this plugin ignoring the follow_wait_preLostTimeOut setting? It works aside from the fact it instantly tries to search soon as the slave is out of range and ignores the timer i set, or is there some other plugin that actually works?

Akk
Human
Human
Posts: 30
Joined: 24 Oct 2008, 01:12
Noob?: Yes

Re: waitForParty -- Don't get separeted! by Chontrad

#117 Post by Akk »

Has anyone a mirror of the link? It is dead! =X

Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Re: waitForParty -- Don't get separeted! by Chontrad

#118 Post by Mortimal »

Please use pin function for uploading your file contents!

pranavrules2008
Plain Yogurt
Plain Yogurt
Posts: 52
Joined: 10 Jul 2008, 08:20
Noob?: No

Re: waitForParty -- Don't get separeted! by Chontrad

#119 Post by pranavrules2008 »

Why is it in the "needs review" folder? Is it no longer working?

Post Reply