Server Help

Bot Questions - Getting a player's position?

tansey - Wed Nov 03, 2004 1:03 pm
Post subject: Getting a player's position?
In mervbot, how do I get a player's current coords. I.e. I'm trying to make it so that when player A dies, he's instantly warped to player B's location.

--tansey
CypherJF - Wed Nov 03, 2004 1:41 pm
Post subject:
Assuming p is a Player object.

p.tile->x
p.tile->y

isn't it?
50% Packetloss - Wed Nov 03, 2004 7:21 pm
Post subject:
yah, the tile location is kept in the Vector p->tile then you index into it with .x and .y. If you want the lvz coord (or pixel location) of the player its p->pos with .x and .y at the end if you want to get those values from the Vector class. So if you want to warp someone to a tile you use p->tile.x and p->tile.y
Cyan~Fire - Wed Nov 03, 2004 8:01 pm
Post subject:
That was kinda confusing, 50%.
50% Packetloss - Wed Nov 03, 2004 11:59 pm
Post subject:
my bad

char buffer[100];
_snprintf(buffer,100,"*warpto %i %i",p->tile.x,p->tile.y);

then send it, you wont need a 100 char buffer though. I havent written code in a few months so I cant remember function names
Bak - Fri Nov 05, 2004 1:19 am
Post subject:
sendPrivate(p,"*warpto " + (String)otherP->tile.x + " " + (String)otherP->tile.y);
Cyan~Fire - Fri Nov 05, 2004 6:30 am
Post subject:
Your code is like, ew.
CypherJF - Fri Nov 05, 2004 8:51 am
Post subject:
lol
tansey - Mon Nov 08, 2004 3:28 pm
Post subject:
For some reason, it's not working. This is my playermove:
Quote:

case EVENT_PlayerMove:
{
Player *p = (Player*)event.p[0];
if( gameInProgress && (p->name == capts[0].captain->name || p->name == capts[1].captain->name))
{
sendPublic( (String)p->name + " at " + (String)(p->tile.x) + " " + (String)(p->tile.y ));
/*if( p->tile.y > 427 )
{
sendPublic( "*arena You are not allowed to leave the castle " + (String)p->name );
}*/

}
}
break;


I noticed that the commented part didn't seem to work, and tried having the bot just output players' coords when they moved, and it appears to output really strange numbers. Does anyone have an idea of what's going wrong here?

EDIT:

Update-- I think the coords are a little lagged somehow. If the player sits there, it will initially output coords that are 50-100 lower than the actual, but if he hovers there it will slowly catch up and stabilize at the actual coords. Any ideas?
Mr Ekted - Mon Nov 08, 2004 5:08 pm
Post subject:
Player position packets are only send every 100ms. The client extrapolates each player's "actual" position using the time synchornization, the x/y, and the dx,dy. The raw position you get in each packet will always be player->server + server->bot milliseconds behind the actual position.
Cyan~Fire - Mon Nov 08, 2004 7:08 pm
Post subject:
Try using a char array as a string and sprintf(). Look it up in the MSDN library.

Also, as a recommendation, just compare the player pointers instead of their names. Player pointers remain the same as long as the play stays in the arena.
50% Packetloss - Mon Nov 08, 2004 8:01 pm
Post subject:
Inorder to recieve position packets from all the players, the bot spectates them 1 by 1 according to the last position that it recorded them at. You can reproduce the same thing with continuum by pressing the arrow keys and following a person, any person outside your radar range you will not receive position packets from. So the bot must move every position-delay (its in the settings .cfg) to hover over the player to get thier new coords. If you want the bot to just look at 1 positon then the best method is to tell(makeFlying(true)); i believe, id have to check the source code, then you can change me->pos to set the bot in a new position. If you look at the mervbot source code you can see how catid keeps track of the player the bot is spectating over and records the last time the bot recieved position packets from that player.

And yah, because data is stored in a linklist which's address is passed to the DLL, you can just store data with a pointer. But remember to set that pointer to NULL when the player leaves the arena or youll be pointing to deleted memory.

I strongly frown upon the use of the String class. It works but its slow compared to just doing it by hand or using sprintf().


BTW, did any of you see Tara Reid's breast-slip? The doctor that works on those things needs to die, just awful. Huge pancake nipples icon_sad.gif. I can link you if you want.
D1st0rt - Tue Nov 09, 2004 4:40 pm
Post subject:
From what I've heard, the scars will go away in around 6 months
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group