Thread

Making a Bot Join a Person (Sdk)

Making a Bot Join a Person // Sdk

1  |  

trekkerx

Apr 14, 2001, 1:39am
> Ive been working on my bot, and Ive added a thing that when you say
> "(bot name) Join me" The bot will move and apper in front of you. Ive
> got it to work preatty good so far, but some times it joins another
> person, other than the owner. I used this to make the bot join.
>
> If message1 = botname & " join me" Then
> avloc1 = (Sdk.AwAvatarZ + 100)
> avloc2 = (Sdk.AwAvatarX + 100)
> avloc3 = Sdk.AwAvatarY
> avloc4 = (Sdk.AwAvatarYaw - 900)
> name = Sdk.AwAvatarName
> Sdk.AwCitizenAttributesByNumber (txtOwner.Text)
> If Sdk.AwCitizenName = name Then
> Sdk.AwMyZ = avloc1
> Sdk.AwMyX = avloc2
> Sdk.AwMyY = avloc3
> Sdk.AwMyYaw = avloc4
> Sdk.AwStateChange
> Sdk.AwSay "Joining you " & name
> Message "[" & txtBotName.Text & "] : Joining you " & name
> Else
> Sdk.AwSay name & " you are not my boss."
> Exit Sub
> End If
> End If
>
> and all the varibles are Defined. And message, isnt a msgbox, ( M a K
> a
> V e L i) Its used to add a line to a certan text box. I also can not
> get
> it to apper in fromt of the person. So if anyone can, please help me.
> Thanxs :-)

the derek

Apr 14, 2001, 2:13am
sometimes for some reason the bot will see the avatar as the last person
who moved-not talked.. so this is not a god way to do it
what you want to do is save (memory or file) the locations of everone in
reference to their session# then when someone moves
have the bot look up the location of that avatarsession

[View Quote]

baron

Apr 14, 2001, 7:03am
It wouldn't happen to work only if the owner is the last person to enter the scene, would it? :) Anyway it's kinda more complicated than that. The attributes you want to use are available during AW_EVENT_AVATAR_ADD and AW_EVENT_AVATAR_CHANGE so you have to store them during these events in order to use them later. You can use a file or even better an array for that. Store the atributes you want there and when you want to use them search the array based on the session#, citname or citnum or any other unique value you have stored. Also why would you want to query for the owner citname while citnum is already available on avatar_add? You could do something like If sdk.AwAvatarCitizen=Val(txtOwner.Text) Then ...

Baron


[View Quote]

grimble

Apr 14, 2001, 11:58am
This ALWAYS the case. The only attributes that are populated as part of the
AW_EVENT_CHAT message are AW_AVATAR_NAME, AW_CHAT_MESSAGE, AW_CHAT_TYPE and
AW_CHAT_SESSION. There's no "for some reason" about it ... as documented on
http://www.activeworlds.com/sdk/AW_EVENT_CHAT.htm.

If you want to do anything beyond the basic coverage of the AW events you
have to remember all the settings from the AW_EVENT_AVATAR_CHANGE messages.
I don't have time right now to knock up a sample application for you
unfortunately, but basically you need to do manage a session table ...
something like this:

On an AW_EVENT AVATAR_ADD, you take all the attributes supplied by the SDK
and create a new entry in some form of list. How you implement this list is
vvery much dependant on your programming style, preferences and how you want
to use the list afterwards ... it could be a (large) fixed array (not
recommended), a dynamic array, a collection, a linked list, etc. The
important thing is that you store the avatar's location information against
its session number. Personally, I always use a class called CAWAvatar that
holds the avatar's information and the owning citizen information once its
resolved from the AW_CALLBACK_CITIZEN_ATTRIBUTES ... but it can be simple
Session Number plus the X, Y, Z and Yaw coordinates if you want.

On an AW_EVENT_AVATAR_CHANGE, you need to look up the session number in your
list and adjust the location information held against it (X, Y, Z and Yaw).

On an AW_EVENT_AVATAR_DELETE, you can throw the entry relating to that
session away.

When you get your AW_EVENT_CHAT message, you can lookup the avatar's
location from the list to establish where the avatar really is ... NOT the
leftovers of the previous event that updated the avatar's X, Y, Z and Yaw
attributes in the SDK stores.

As far as getting the bot to go in front of the avatar, you need to apply
some simple maths. Simply adding 100 to the coordinates will always put the
bot at 100 further north and 100 further west. You need to use circle
formula to get it 1m away from the avatar in the directionthe avatar is
LOOKING.

0 Yaw is looking North, 900 is looking West, so to find the X offset, you do
the radius of the circle (the distance away fromt he avatar ... 100 in this
case) and multiply it by Sine(Yaw/10). For the Z offset, you use Cosine
instead. Therefore:

botPosX = avatarPosX + (JOIN_DISTANCE * Sin(avatarPosYaw/10)
botPosZ = avatarPosX + (JOIN_DISTANCE * Cos(avatarPosYaw/10)

To make the bot "look at" the avatar ... you simply reverse the avatar's Yaw
with simething like ((avatarPosYaw + 180) Mod 360).

"The Derek" ... you amaze me ... I have only just removed you from my filter
list (which you originally earned membership of because I was tired of your
continual crap responses) and you immediately demonstrate the same old
inability to read the documentation and insistance on making uninformed
assumptions instead of finding things out. Back on the list for you.

Hope this helps TrekkerX. As I said, I'm a bit puched for time right now so
I can't make up a sample application for you. After Easter is over, if
you're still stuck, let me know and I'll put something together for you
quickly to demonstrate how to handle session tables. This post is using the
event names in the actual SDK as documented (for C) but the names in the
AwSdkOcx2 and 3 are close enough for you to make the connection.

Grims




[View Quote]

grimble

Apr 14, 2001, 12:11pm
Sorry ... typing is crap today ... formulas should read as follows:

botPosX = avatarPosX + (JOIN_DISTANCE * Sin(avatarPosYaw/10))
botPosZ = avatarPosZ + (JOIN_DISTANCE * Cos(avatarPosYaw/10))

Just a quick note ... it might be crap maths in this machine, but I use
Visual Studio 6 with Service Pack and COS(90) ... I think ... is never
calculated correctly, so watch for that. I seem to remember from my school
days that Cos(x) = 1/Sin(x) so you can use that if you get this problem.

Grims/


[View Quote]

grimble

Apr 14, 2001, 12:16pm
CitNum will be returned as -1 in worlds that are not running 3.1 or above
.... so then you need to do it the old way. :o)

"baron" <pk39srt at hotmail.com>
Also why would you want to query for the owner citname while citnum is
already available on avatar_add? You could do something like If
sdk.AwAvatarCitizen=Val(txtOwner.Text) Then ...

andras

Apr 14, 2001, 12:27pm
[View Quote] kkhhmmmm kkhhmmmm rather use cos(x)=sin(x+90)

>
> Grims/
<snip>

grimble

Apr 14, 2001, 1:09pm
Hmmm yeah ... 1/Sin(x) doesn't work does it :o( ... Thanks.

BTW TrekkerX ... don't forget to convertdecrees to Radians before using the
VB Cos/Sin functions.

Grims


[View Quote]

trekkerx

Apr 14, 2001, 7:52pm
Thank you Grimble, I got it to work, and it works good i didnt have anyproblems
with the sin formulas. Thanxs

[View Quote] > This ALWAYS the case. The only attributes that are populated as part of the
> AW_EVENT_CHAT message are AW_AVATAR_NAME, AW_CHAT_MESSAGE, AW_CHAT_TYPE and
> AW_CHAT_SESSION. There's no "for some reason" about it ... as documented on
> http://www.activeworlds.com/sdk/AW_EVENT_CHAT.htm.
>
> If you want to do anything beyond the basic coverage of the AW events you
> have to remember all the settings from the AW_EVENT_AVATAR_CHANGE messages.
> I don't have time right now to knock up a sample application for you
> unfortunately, but basically you need to do manage a session table ...
> something like this:
>
> On an AW_EVENT AVATAR_ADD, you take all the attributes supplied by the SDK
> and create a new entry in some form of list. How you implement this list is
> vvery much dependant on your programming style, preferences and how you want
> to use the list afterwards ... it could be a (large) fixed array (not
> recommended), a dynamic array, a collection, a linked list, etc. The
> important thing is that you store the avatar's location information against
> its session number. Personally, I always use a class called CAWAvatar that
> holds the avatar's information and the owning citizen information once its
> resolved from the AW_CALLBACK_CITIZEN_ATTRIBUTES ... but it can be simple
> Session Number plus the X, Y, Z and Yaw coordinates if you want.
>
> On an AW_EVENT_AVATAR_CHANGE, you need to look up the session number in your
> list and adjust the location information held against it (X, Y, Z and Yaw).
>
> On an AW_EVENT_AVATAR_DELETE, you can throw the entry relating to that
> session away.
>
> When you get your AW_EVENT_CHAT message, you can lookup the avatar's
> location from the list to establish where the avatar really is ... NOT the
> leftovers of the previous event that updated the avatar's X, Y, Z and Yaw
> attributes in the SDK stores.
>
> As far as getting the bot to go in front of the avatar, you need to apply
> some simple maths. Simply adding 100 to the coordinates will always put the
> bot at 100 further north and 100 further west. You need to use circle
> formula to get it 1m away from the avatar in the directionthe avatar is
> LOOKING.
>
> 0 Yaw is looking North, 900 is looking West, so to find the X offset, you do
> the radius of the circle (the distance away fromt he avatar ... 100 in this
> case) and multiply it by Sine(Yaw/10). For the Z offset, you use Cosine
> instead. Therefore:
>
> botPosX = avatarPosX + (JOIN_DISTANCE * Sin(avatarPosYaw/10)
> botPosZ = avatarPosX + (JOIN_DISTANCE * Cos(avatarPosYaw/10)
>
> To make the bot "look at" the avatar ... you simply reverse the avatar's Yaw
> with simething like ((avatarPosYaw + 180) Mod 360).
>
> "The Derek" ... you amaze me ... I have only just removed you from my filter
> list (which you originally earned membership of because I was tired of your
> continual crap responses) and you immediately demonstrate the same old
> inability to read the documentation and insistance on making uninformed
> assumptions instead of finding things out. Back on the list for you.
>
> Hope this helps TrekkerX. As I said, I'm a bit puched for time right now so
> I can't make up a sample application for you. After Easter is over, if
> you're still stuck, let me know and I'll put something together for you
> quickly to demonstrate how to handle session tables. This post is using the
> event names in the actual SDK as documented (for C) but the names in the
> AwSdkOcx2 and 3 are close enough for you to make the connection.
>
> Grims
>
[View Quote]

baron

Apr 15, 2001, 12:49pm
You are right, that's an exception that has to be handled with an elseif :)

Baron


[View Quote]

the derek

Apr 16, 2001, 1:02am
meant to say CHAT session not avatar session! itl just make a workaround
towards the same probalem if you do lol

[View Quote] > sometimes for some reason the bot will see the avatar as the last person
> who moved-not talked.. so this is not a god way to do it
> what you want to do is save (memory or file) the locations of everone in
> reference to their session# then when someone moves
> have the bot look up the location of that avatarsession
>
[View Quote]

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