Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with attack bot...

Drew Peapod
Registered User
Join date: 28 Jan 2009
Posts: 3
11-29-2009 14:08
Hi everyone,

first post so hope you're all well.

I'm making a tank sort of bot to attack an avatar. So far it is going relatively well except for one thing.

I'm trying to make it detect whether an avatar is behind a wall and if so then to ignore it. To do this i have worked out the distance from the wall to the bot and from the avatar to the bot and then working out which is closer.

For the wall i have made it so that it changes the z axis distance so that it is the same as the bot so that it doesn't use the centre of the wall if you get what i mean? BUT, i keep getting strange readings for the distance from the bot to the wall. By this I mean MASSIVE readings (like so far up to 2300 ish. I've set the arc at PI/4 ( so that it detects infront of it) in llSensorRepeat and noticed that it seems to get these strange readings when the bot is looking toward the edges of the walls.

As you can probably tell, this isn't really helping because if the avatar is behind a wall and the wall reading is massive, the bot is still going to try to shoot it.

Does anyone have any ideas on this or thoughts or anything? I'm starting to get a bit frustrated with this.

Also note that I have only really just begun to get into all of this second life scripting stuff so I'm still relatively new to it all.

Thanks in advance
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
11-29-2009 16:23
Rather than all those calculations with sensor(), just use old-fashioned virtual sounding or laser-targeting.

Basically, when you detect a target, don't worry what's between it and your bot. Just fire-off a small, invisible bullet to simulate a sounding or laser pulse. If that pulse-bullet hits a wall, then it reports back to the bot that a wall is between itself and the target. Otherwise, fire-off a round of your main ammunition to kill the target.
Drew Peapod
Registered User
Join date: 28 Jan 2009
Posts: 3
11-29-2009 16:29
Thanks for replying. I am actually trying to implement that now. Hopefully i'll get somewhere soon!

Thanks again
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
11-30-2009 04:43
If you do absolutely need to use sensors, you can try using llGetObjectDetails() to verify any weird really results.
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
Coldfire Nightfire
Registered User
Join date: 25 May 2008
Posts: 48
Just a though
11-30-2009 12:32
Hi
If I remember your post from before . now that your child prim is phantom and I do believe you said a 5 m sensor, you could have a 10 m x 0.1mx 0.1 m object centered on or above your robot or tank ( so 5 m on each side ) that would rotate with a detect collition and a few if and then commands in your script to travel around the object instead of fireing on the AV . there was an old comador 64 game that did AI for tanks you had to preprogram everything , scan, movement, rotation , if this do that and so on .
there is a script here
/54/f3/275057/1.html
called Library: SARSA, the self-learning ball from what I see it learns as it moves around
may be of some help
Coldfire Nightfire
Registered User
Join date: 25 May 2008
Posts: 48
oops mixup
11-30-2009 12:48
From: Coldfire Nightfire
Hi
If I remember your post from before .


so sorry I never noticed the name I thought you posted this before but was someone eles, if you read it you will see how I thought it was you

Patrolling Robot: Questions concerning llSensor & Links

--------------------------------------------------------------------------------

Hi there,

I have to create a simple AI, so I created a robot (a sphere) which is patrolling and looking for intruders.

It's nearly complete. but:

1) I would like to visualize the area of the robots sensor (360°, 5m). So i created a ring (phantom) to indicate the sensor range. But: The ring has to be phantom, the bot to be physical and non-phantom. If i create a Link between both Objects, that doesn't work (because obviously, both have to have the same properties).

Are there any other ideas, how i could indicate the sensor range?

2) The Player of the game should be able to hide behind walls. But llSensor detects the Avatar regardless if he's behind a wall or in the line-of-sight of the robot.
What would be the easiest way to respect the visibility of the avatar?

My idea would be to detect the walls as well as the avatar and to calculate if there is any shorter vector to a wall than the vector to the avatar... that doesn't sound like a handsome solution to me.

Are there any better ways?

3) At first try, i created a robot looking like R2D2 (Star Wars). I googled a lot, but i didn't find a way to move this robot with physics. I tried to move him as phantom as well as with physics, but the movement wasn't acceptable. The Problem was, that the robot tumbled all the time (his foots were 3 boxes). Are there any standard-movements to handle such objects? Now, it's just a sphere with llMoveToTarget()


- Martin

/54/42/348953/1.html
Drew Peapod
Registered User
Join date: 28 Jan 2009
Posts: 3
12-01-2009 06:11
Thanks, yeah, i have been looking at that post too. I still don't understand why i get ridiculous distances from my bot to my wall though. To me, it should work perfectly.

Although I am now using a phantom bullet instead, I would still like to understand what I was doing wrong or whether this is a bug or something similar. Does anyone know or have any ideas?

sensor(integer wallio)
{
vector botPos = llGetPos();
vector wallPos = llDetectedPos(0);
wallPos.z = botPos.z;
float wallDistance = llVecDist(botPos,wallPos);
llShout(0, (string) wallDistance);
llMessageLinked(1,0, (string) wallDistance, NULL_KEY);

}


and using...

llSensorRepeat("Wall", NULL_KEY, PASSIVE, 20, PI/6, 1);

Thanks everyone for your help