Author |
Message |
tansey Novice
Joined: Nov 03 2004 Posts: 53 Offline
|
Posted: 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 |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Wed Nov 03, 2004 1:41 pm Post subject: |
 |
|
|
|
Assuming p is a Player object.
p.tile->x
p.tile->y
isn't it? _________________ Performance is often the art of cheating carefully. - James Gosling |
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: 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 |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Wed Nov 03, 2004 8:01 pm Post subject: |
 |
|
|
|
That was kinda confusing, 50%. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: 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 |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Fri Nov 05, 2004 1:19 am Post subject: |
 |
|
|
|
sendPrivate(p,"*warpto " + (String)otherP->tile.x + " " + (String)otherP->tile.y); |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Nov 05, 2004 6:30 am Post subject: |
 |
|
|
|
Your code is like, ew. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Fri Nov 05, 2004 8:51 am Post subject: |
 |
|
|
|
lol |
|
Back to top |
|
 |
tansey Novice
Joined: Nov 03 2004 Posts: 53 Offline
|
Posted: 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? |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: 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. _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: 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. |
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: 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 . I can link you if you want. |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Tue Nov 09, 2004 4:40 pm Post subject: |
 |
|
|
|
From what I've heard, the scars will go away in around 6 months _________________
 |
|
Back to top |
|
 |
|