PDA

View Full Version : target random player and port there group?


spider661
01-14-2009, 03:47 PM
i need to target a random player in the zone and port here group out to anther zone. how would i do this? i cant get any of the quest objects for group working. i does not matter what player it ports i just need to find a player in the zone and port there whole group out because the zone can only have 1 group at a time anyways.

any ideas?

trevius
01-14-2009, 05:58 PM
The only way I have found to be able to check all clients in the zone is using a script that checks all entities in the whole zone and checks if they are clients or not. The custom script I posted for my Thanksgiving event would work just fine for this if you can figure out how to use it. Here is a quick edit that would find each client:

sub EVENT_SPAWN {

quest::settimer("runaway",5);

}


sub EVENT_TIMER {

if ($timer eq "runaway") {
quest::stoptimer("runaway");

my $list_check = 0;

#Variable to check if more than 1 player is in zone
my $multiple_clients = undef;

#You may need to increase 2000 below if you have alot of mobs in the zone
for ($list_check = 0; $list_check < 2000; $list_check++) {

$client_search = $entity_list->GetClientByID($list_check);

if ($client_search) {
# quest::say("I found client $client_search");
$multiple_clients = $multiple_clients + 1;

if($multiple_clients <= 6) { #Full group or less in the zone
quest::settimer("runaway",60); #run this check every minute
}

if($multiple_clients > 6) { #more than a full group
#Run this check every 5 seconds until someone is picked

my $clientpick = quest::ChooseRandom(1,2,3,4,5,6,7,8,9,10);
if($clientpick == 1) { #we got a winner!
quest::settimer("runaway",60);
$client->MoveGroup(152,0,0,-31)
}
if($clientpick > 1) {
#More than 6 players are in zone. Need to keep running this check until a player is picked and removed
quest::settimer("runaway",5);
}
}

}
}

}
}

I haven't tested this yet, but it should be close to something that would do what you are wanting to do.

spider661
01-14-2009, 07:29 PM
ok i have it telling me it found me as a client in shout.. but its not porting.

i looked up on the quest objects list and there is no $client->MoveGroup or anything MoveGroup so i looked around and there is a MovePC so i tried that and still nothing so i look and there is nothing assigned to client so it don't know who to port.. i tried setting it to $list_check-> bu thats not doing anything either any suggestions?

spider661
01-14-2009, 08:21 PM
according to this, this should be working but its not the shout works but the port does nothing



my $list_check = 0;
#You may need to increase 2000 below if you have alot of mobs in the zone
for ($list_check = 0; $list_check < 2000; $list_check++)
{
$client_search = $entity_list->GetClientByID($list_check);
if ($client_search)
{
quest::say("I found client $client_search");
$client_search->MoveGroup(152,0,0,-31);

}

}

trevius
01-14-2009, 08:45 PM
LOL, apparently I was making the MoveGroup quest object up. I don't see it in the list of quest objects. Try MovePC(152,0,0,-31) and verify that it works to move single characters with that script.

I thought that there was a quest object to move groups, but it looks like there are only normal quest:: commands for it. You could try quest::movegrp(152,0,0,-31), but I am not sure that will work if you are using quest objects to get the client. Worth a shot though.

Edit: After looking at the quest objects some more, maybe this one will work:

$client_search->TeleportGroup($npc, 152, 0, 0, -31);

I haven't messed with the group quest objects much, so you probably need to get the client's group first. If so, maybe something like this would work:

my $clientgroup = $client_search->GetGroup();
quest::say("I found that client $client_search is in group $clientgroup");
$clientgroup->TeleportGroup($npc, 152, 0, 0, -31);

If that works, let me know, because I have been wanting to figure out how to do that group stuff for a while lol. I just haven't had much time to look into it and didn't really think about doing it this way before. If the above doesn't work for players who aren't in a group, maybe you could do something like this:

my $clientgroup = $client_search->GetGroup();
if($clientgroup) {
quest::say("I found that client $client_search is in group $clientgroup");
$clientgroup->TeleportGroup($npc, 152, 0, 0, -31);
}
else {
quest::say("I found client $client_search, but they are not grouped");
$client_search->MovePC(152,0,0,-31);
}


And, if none of the above works, you may need to cast it to client first. So, maybe something like this would work:


my $gotclient = $client_search->CastToClient();
quest::say("I found client $client_search and cast them to client, which outputs this: $gotclient");

my $clientgroup = $gotclient->GetGroup();
if($clientgroup) {
quest::say("I found that client $client_search is in group $clientgroup");
$clientgroup->TeleportGroup($npc, 152, 0, 0, -31);
}
else {
quest::say("I found client $client_search, but they are not grouped");
$gotclient->MovePC(152,0,0,-31);
}

AndMetal
01-14-2009, 08:55 PM
I'm not sure MoveGroup is an actual function in the Client class. However, there is a TeleportGroup function in the Group class. I would think you could do something like this:



my $list_check = 0;
#You may need to increase 2000 below if you have alot of mobs in the zone
for ($list_check = 0; $list_check < 2000; $list_check++)
{
$client_search = $entity_list->GetClientByID($list_check);
if ($client_search)
{
quest::say("I found client $client_search");
$client_search->GetGroup()->TeleportGroup($mob,152,0,0,-31);
}
}


Hope this helps.

spider661
01-15-2009, 12:38 AM
ok this really sucks none of the above worked

i found client Client=SCALAR(0x4ac3008 ) and cast them to client, witch outputs this: Client=SCALAR(0x4ac2ce4)

i found client Client=SCALAR(0x4ac3008 ), but he are not grouped.

that's what he said from the last one in Tevs post.. all of them said something close to that but none moved me.

space after 8 ) o keep from 8) face

MNWatchdog
01-15-2009, 12:57 AM
Couldnt you just have the script have the group member cast a custom group teleport spell with a huge AE range?

trevius
01-15-2009, 01:00 AM
Well, I use a similar script for one of my events, but it didn't actually do anything with the character, it just got information about them (locs). I don't see why it wouldn't work to move them though, unless MovePC is broken. To verify, you should be able to try something like this:

sub EVENT_SAY {

if ($text =~/hail/i) {
quest::say("I am going to try to move you to Nexus with MovePC.");
$client->MovePC(152, 0, 0, -31);
}

}

If that doesn't work, then MovePC is the issue. If it does work, then I don't understand why it isn't working in the other script. It obviously has the client already, so it should be able to do stuff to them.

Also, just to mention it, we have some similar stuff setup on Storm Haven already. It is a bit tricky, but we do it using qglobals. You just set a time length for each member of the group via a qglobal with an expire time on it. Then, you have an NPC that runs the client check above and have it check their qglobals to see if they still have the global. If not, it just does a $client_search->Gate(); and sends them home :P

spider661
01-15-2009, 01:14 AM
prob with that is gae would keep them in the zone.. here going to be bound there so if they die the will not leave the zone.. so i have to send them back and rebind them in the right place.

let me try just moving npc and see if that works.

spider661
01-15-2009, 01:25 AM
if ($text =~/port/i)
{
$client->MovePC(3,-4.8,8.4,0.9);
}

does nothing that really sucks

spider661
01-15-2009, 01:29 AM
sad day even

if ($text =~/port/i)
{
$client->GetGroup()->TeleportGroup($mob,3,-4.8,8.4,0.9);
}


does nothing

trevius
01-15-2009, 01:39 AM
It wouldn't hurt to try these in the script:

quest::movepc(zoneid,x,y,z) - Moves the user that triggered the Event to the provided zone and loc.
quest::movegrp(zoneid,x,y,z) - Moves the user's Group that triggered the Event to the provided zone and loc.

I don't know if they can work right from quest objects getting the client, but it may be worth a shot just to see.

spider661
01-15-2009, 02:07 AM
ya i already tryed them i cant get them though a client object like that but jsut tested making the player cast a spell does work so im just going to make a custom port spell instant cast and then let it go.

VallonTallonZek
01-22-2009, 10:50 PM
I wrote a function that returns a random client in a radius around another client, but it would need to be added to the Perl interface to solve your problem. If someone wants to make them accessible to Perl I can post it here when I get home.