pj47 // User Search

pj47 // User Search

1  |  

bot avatars

Dec 4, 1999, 5:22pm
Is there some way to choose an avatar for a bot that is not available to all
users? I wanted to choose one of the "Special" bots in my world for some
unique bots I plan to program, but when I tested this ability with Hambot, I
couldn't get this to work.

If you can do this, how do you call the right avatar using the SDK?

bot avatars

Dec 5, 1999, 3:46pm
Thanks for the info.


[View Quote]

Totally confused about object query

Mar 30, 2000, 12:25am
Hi-

Can someone who knows about object querying tell me what I am doing wrong?
I am trying to get a bot to change an object into a teleport (and, of
course, eventually change it back). I tried to modify the SDK Sample 2
DJBot program and it works fine at ground zero (with the object at 1N 1W)
when I leave the querying commands as in the sample program.

The problem is when I try to translate it to an object that my world reports
as being at 17N 9W and that Buildbot says is at 17600NS 9700WE 10110A.
(Note: it is at about 101.1 altitude, although I don't think that matters).

It seems to me that I need to make the following changes to the querying
code to find this object:
1) Change first query command to aw_query (1, 2, sequence)
2) Also change the query command in void handle_query (int rc) to aw_query
(1, 2, sequence)
3) Change to cell_x == 9 && cell_x==17 in void handle_cell_object (void)

However, this just goes into a continual loop looking for x number of bytes
over and over (query never seems to end). What am I missing? It appears
that the query is not being updated at 16N 8W.

[Also, out of curiosity, how does the SDK get away with things like:
if (rc = aw_query (0, 0, sequence))

I'm a novice but it seems I was trained that you need double equal signs for
Boolean expressions]

FYI. The code I am using is below:

#include "stdafx.h"
#include "aw.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define FIVE_MINUTES (5 * 60 * 1000)
#define CHANGE_OBJECT "dreser01.rwx"
#define WORLD "hitchhke"

void handle_cell_begin (void);
void handle_cell_object (void);
void handle_query (int rc);
void change_object (void);

int owner;
int sequence[3][3];
int obj_x;
int obj_y;
int obj_z;
int obj_yaw;
int obj_number = 0;
int cell_x;
int cell_z;


main (int argc, char *argv[])
{

int rc;

/* check command line */
if (argc < 3) {
printf ("Usage: %s number password\n", argv[0]);
exit (1);
}

/* initialize Active Worlds API */
if (rc = aw_init (AW_BUILD)) {
printf ("Unable to initialize API (reason %d)\n", rc);
exit (1);
}

/* install cell update event handlers */
aw_event_set (AW_EVENT_CELL_BEGIN, handle_cell_begin);
aw_event_set (AW_EVENT_CELL_OBJECT, handle_cell_object);

/* install query callback */
aw_callback_set (AW_CALLBACK_QUERY, handle_query);

/* create bot instance */
if (rc = aw_create (0, 0, 0)) {
printf ("Unable to create bot instance (reason %d)\n", rc);
exit (1);
}

/* log bot into the universe */
owner = atoi (argv[1]);
aw_int_set (AW_LOGIN_OWNER, owner);
aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, argv[2]);
aw_string_set (AW_LOGIN_NAME, "Jed");
if (rc = aw_login ()) {
printf ("Unable to login (reason %d)\n", rc);
exit (1);
}

/* log bot into the world */
if (rc = aw_enter (WORLD, 0)) {
printf ("Unable to enter world (reason %d)\n", rc);
exit (1);
}

/* issue first property query for the ground zero area so that we can
locate
the SPEAKER_OBJECT */
printf ("Looking for object...\n");
if (rc = aw_query (1, 2, sequence)) {
printf ("Unable to query property (reason %d)\n", rc);
exit (1);
}

/* wait for query to complete and then change music every five minutes */
while (!(rc = aw_wait (FIVE_MINUTES)))
if (obj_number)
change_object();

/* close everything down */
aw_destroy ();
aw_term ();
return 0;

}

void change_object (void)
{

int rc;
char action[100];

aw_int_set (AW_OBJECT_OLD_NUMBER, obj_number);
aw_int_set (AW_OBJECT_OLD_X, obj_x);
aw_int_set (AW_OBJECT_OLD_Z, obj_z);
aw_int_set (AW_OBJECT_X, obj_x);
aw_int_set (AW_OBJECT_Y, obj_y);
aw_int_set (AW_OBJECT_Z, obj_z);
aw_int_set (AW_OBJECT_YAW, obj_yaw);
aw_int_set (AW_OBJECT_OWNER, owner);
aw_string_set (AW_OBJECT_MODEL, CHANGE_OBJECT);
aw_string_set (AW_OBJECT_DESCRIPTION, "");
sprintf (action, "create solid off, visible off;bump teleport 5N 5W
102a");
aw_string_set (AW_OBJECT_ACTION, action);
if (rc = aw_object_change ())
printf ("Unable to change object (reason %d)\n", rc);
else {
printf ("Object changed.\n");
obj_number = aw_int (AW_OBJECT_NUMBER);
}

}

void handle_cell_begin (void)
{

int sector_x;
int sector_z;

/* This is called to indicate we are receiving the contents of a new cell.
All
we need to do here is update the sequence number array for the next
call to
aw_query (). */
cell_x = aw_int (AW_CELL_X);
cell_z = aw_int (AW_CELL_Z);
sector_x = aw_sector_from_cell (cell_x);
sector_z = aw_sector_from_cell (cell_z);
sequence[sector_z + 1][sector_x + 1] = aw_int (AW_CELL_SEQUENCE);

}

void handle_cell_object (void)
{

/* This is called once for each object in each cell that we are querying.
We
check to see if the object is the OBJECT we are looking for, by
checking the name of the object and the cell it is located in. */
if (cell_x == 9 && cell_z == 17 &&
!strcmp (aw_string (AW_OBJECT_MODEL), CHANGE_OBJECT)) {
obj_x = aw_int (AW_OBJECT_X);
obj_y = aw_int (AW_OBJECT_Y);
obj_z = aw_int (AW_OBJECT_Z);
obj_yaw = aw_int (AW_OBJECT_YAW);
obj_number = aw_int (AW_OBJECT_NUMBER);
printf ("Object located!\n");
change_object();
}

}

void handle_query (int rc)
{

/* This is called when the server has stopped sending property data. If
we haven't
found the speaker yet, then we check if the query is complete, and if
not,
issue a new query with the updated sequence numbers to continue the
update. */
if(!obj_number)
if (!aw_bool (AW_QUERY_COMPLETE))
aw_query (1, 2, sequence);
else
/* the query is complete but we didn't find the speaker! :( */
printf ("Couldn't find object.\n");

}

bot avatars

Dec 4, 1999, 5:22pm
Is there some way to choose an avatar for a bot that is not available to all
users? I wanted to choose one of the "Special" bots in my world for some
unique bots I plan to program, but when I tested this ability with Hambot, I
couldn't get this to work.

If you can do this, how do you call the right avatar using the SDK?

bot avatars

Dec 5, 1999, 3:46pm
Thanks for the info.


[View Quote]

Oh Roland.....

Jan 11, 2000, 11:22pm
Can you tell me more about this? Will this allow a bot to teleport an
avatar somewhere within a world? I am writing a bot to do that, but plan to
use the technique of the bot building an object nearby that will teleport
the avatar. If I can get around having to do that, I would be VERY
grateful. Anyone have an idea when this version will be out?


[View Quote]

Totally confused about object query

Mar 30, 2000, 12:21am
Hi-

Can someone who knows about object querying tell me what I am doing wrong?
I am trying to get a bot to change an object into a teleport (and, of
course, eventually change it back). I tried to modify the SDK Sample 2
DJBot program and it works fine at ground zero (with the object at 1N 1W)
when I leave the querying commands as in the sample program.

The problem is when I try to translate it to an object that my world reports
as being at 17N 9W and that Buildbot says is at 17600NS 9700WE 10110A.
(Note: it is at about 101.1 altitude, although I don't think that matters).

It seems to me that I need to make the following changes to the querying
code to find this object:
1) Change first query command to aw_query (1, 2, sequence)
2) Also change the query command in void handle_query (int rc) to aw_query
(1, 2, sequence)
3) Change to cell_x == 9 && cell_x==17 in void handle_cell_object (void)

However, this just goes into a continual loop looking for x number of bytes
over and over (query never seems to end). What am I missing? It appears
that the query is not being updated at 16N 8W.

[Also, out of curiosity, how does the SDK get away with things like:
if (rc = aw_query (0, 0, sequence))

I'm a novice but it seems I was trained that you need double equal signs for
Boolean expressions]

FYI. The code I am using is below:

#include "stdafx.h"
#include "aw.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define FIVE_MINUTES (5 * 60 * 1000)
#define CHANGE_OBJECT "dreser01.rwx"
#define WORLD "hitchhke"

void handle_cell_begin (void);
void handle_cell_object (void);
void handle_query (int rc);
void change_object (void);

int owner;
int sequence[3][3];
int obj_x;
int obj_y;
int obj_z;
int obj_yaw;
int obj_number = 0;
int cell_x;
int cell_z;


main (int argc, char *argv[])
{

int rc;

/* check command line */
if (argc < 3) {
printf ("Usage: %s number password\n", argv[0]);
exit (1);
}

/* initialize Active Worlds API */
if (rc = aw_init (AW_BUILD)) {
printf ("Unable to initialize API (reason %d)\n", rc);
exit (1);
}

/* install cell update event handlers */
aw_event_set (AW_EVENT_CELL_BEGIN, handle_cell_begin);
aw_event_set (AW_EVENT_CELL_OBJECT, handle_cell_object);

/* install query callback */
aw_callback_set (AW_CALLBACK_QUERY, handle_query);

/* create bot instance */
if (rc = aw_create (0, 0, 0)) {
printf ("Unable to create bot instance (reason %d)\n", rc);
exit (1);
}

/* log bot into the universe */
owner = atoi (argv[1]);
aw_int_set (AW_LOGIN_OWNER, owner);
aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, argv[2]);
aw_string_set (AW_LOGIN_NAME, "Jed");
if (rc = aw_login ()) {
printf ("Unable to login (reason %d)\n", rc);
exit (1);
}

/* log bot into the world */
if (rc = aw_enter (WORLD, 0)) {
printf ("Unable to enter world (reason %d)\n", rc);
exit (1);
}

/* issue first property query for the ground zero area so that we can
locate
the SPEAKER_OBJECT */
printf ("Looking for object...\n");
if (rc = aw_query (1, 2, sequence)) {
printf ("Unable to query property (reason %d)\n", rc);
exit (1);
}

/* wait for query to complete and then change music every five minutes */
while (!(rc = aw_wait (FIVE_MINUTES)))
if (obj_number)
change_object();

/* close everything down */
aw_destroy ();
aw_term ();
return 0;

}

void change_object (void)
{

int rc;
char action[100];

aw_int_set (AW_OBJECT_OLD_NUMBER, obj_number);
aw_int_set (AW_OBJECT_OLD_X, obj_x);
aw_int_set (AW_OBJECT_OLD_Z, obj_z);
aw_int_set (AW_OBJECT_X, obj_x);
aw_int_set (AW_OBJECT_Y, obj_y);
aw_int_set (AW_OBJECT_Z, obj_z);
aw_int_set (AW_OBJECT_YAW, obj_yaw);
aw_int_set (AW_OBJECT_OWNER, owner);
aw_string_set (AW_OBJECT_MODEL, CHANGE_OBJECT);
aw_string_set (AW_OBJECT_DESCRIPTION, "");
sprintf (action, "create solid off, visible off;bump teleport 5N 5W
102a");
aw_string_set (AW_OBJECT_ACTION, action);
if (rc = aw_object_change ())
printf ("Unable to change object (reason %d)\n", rc);
else {
printf ("Object changed.\n");
obj_number = aw_int (AW_OBJECT_NUMBER);
}

}

void handle_cell_begin (void)
{

int sector_x;
int sector_z;

/* This is called to indicate we are receiving the contents of a new cell.
All
we need to do here is update the sequence number array for the next
call to
aw_query (). */
cell_x = aw_int (AW_CELL_X);
cell_z = aw_int (AW_CELL_Z);
sector_x = aw_sector_from_cell (cell_x);
sector_z = aw_sector_from_cell (cell_z);
sequence[sector_z + 1][sector_x + 1] = aw_int (AW_CELL_SEQUENCE);

}

void handle_cell_object (void)
{

/* This is called once for each object in each cell that we are querying.
We
check to see if the object is the OBJECT we are looking for, by
checking the name of the object and the cell it is located in. */
if (cell_x == 9 && cell_z == 17 &&
!strcmp (aw_string (AW_OBJECT_MODEL), CHANGE_OBJECT)) {
obj_x = aw_int (AW_OBJECT_X);
obj_y = aw_int (AW_OBJECT_Y);
obj_z = aw_int (AW_OBJECT_Z);
obj_yaw = aw_int (AW_OBJECT_YAW);
obj_number = aw_int (AW_OBJECT_NUMBER);
printf ("Object located!\n");
change_object();
}

}

void handle_query (int rc)
{

/* This is called when the server has stopped sending property data. If
we haven't
found the speaker yet, then we check if the query is complete, and if
not,
issue a new query with the updated sequence numbers to continue the
update. */
if(!obj_number)
if (!aw_bool (AW_QUERY_COMPLETE))
aw_query (1, 2, sequence);
else
/* the query is complete but we didn't find the speaker! :( */
printf ("Couldn't find object.\n");

}

Totally confused about object query

Mar 30, 2000, 11:16pm
I understand that the functions are returning an int (i.e., rc), and I know
that 0 is false and anything else is true. But, it seems to me that you get
the same thing by:

if (aw_query (0, 0, sequence)) ...

and you save on the "rc =" in front and you avoid the possible confusion of
= vs. ==.



[View Quote] [View Quote] If (rc) /* Actually equates to : If (rc == true), but you do not need to do
this in C++ . . . If you wanted the code to execute if rc was false, you'd
do : If (!rc), where '!' is the C++ symbol for NOT (In C it was '~', that's
why Class Destructors are always ClassName::~ClassName(void);, but that's
another story :)) */

Totally confused about object query

Mar 30, 2000, 11:31pm
Thanks so much for the help!!! That the sequence array has the format:

sequence[sector_z + constant][sector_x + constant]

and that it must end up as sequence[1][1] is about as clear as mud. Now
that I consider it, it makes sense. Someone should make this clear in the
sample program because it appears that I am not the only person who didn't
get this point.

Wish I could buy you a beer. Have a virtual one on me.

PJ47

[View Quote]

SDK docs

Apr 22, 2000, 6:02pm
Thanks, renes. I remember Roland saying he had posted a Zip file for the
documentation, but was unaware how to find it. It would be good if the was
listed on the SDK web site because I have looked for it before without luck.


[View Quote]

Announcing Hitchhke- The Time Travel World

Sep 22, 2001, 4:47pm
http://home.cox.rr.com/pjohnston1/announce.htm

1  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn