ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
Making a Bot Join a Person (Bots)
Making a Bot Join a Person // BotstrekkerxApr 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 derekApr 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] grimbleApr 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] grimbleApr 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] andrasApr 14, 2001, 12:27pm
grimbleApr 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] trekkerxApr 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] the derekApr 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] |