Page 1 of 3

Smart shooting Bad Guys

PostPosted: Sat Apr 14, 2007 8:12 pm
by d-soldier
SEE ATTATCHED PIC:
Heres my problem, the floating drone-bot (see pic) needs to only shoot if the player is in his firing sector (instead of randomly shooting at intervals).. I've thought of serveral ways to do this including having collision zones parented(because the drone floats around on a path[see blue arrows] to the drone that cause it to fire if the player walks into it... But if I do that, wouldn't I have to remake the zones and re-rig them to every single clone of the drone throughout the level? Is there a script function that can be made to accomplish this? And if anyone would take a moment to show specifics, I would greatly appreciate it!

PostPosted: Sat Apr 14, 2007 9:56 pm
by Fuzzy
The angles would always be the same? have the drone actor create the collision zones in its own create actor event. At that time, it can se the collision actor to have itsself as parent.

read in the help...documentation..scripting on create actor. Reply if you have questions as always.

PostPosted: Tue Apr 17, 2007 5:12 pm
by Sgt. Sparky
no seperate collision actors are needed,
use this
Code: Select all
if(distance(x, 0, player.x, 0) < 100)//or what other number you want.
{
 make em' shoot;
}

that code is for your badie.
:)

PostPosted: Tue Apr 17, 2007 11:35 pm
by Game A Gogo
sgt.sparky, that code doesn't calculate the angle, so if the player would be on the top, it would still shoot, try this:

Code: Select all
if((distance(x, 0, player.x, 0) < 25) && (direction(x, 0, player.x, 0)>=220) && (direction(x, 0, player.x, 0)<=230))
{
    //Shotting script goes here
}

That should check if the direction is at lest 10 degree close from 225 (Which is the sud-west position) and it should check also if the player is at least 25 pixel close from the probe.

great!

PostPosted: Tue Apr 17, 2007 11:48 pm
by d-soldier
That will come in handy for a different enemy for sure, I re-rendered the probe already so he's attacking from all angles now... But Like I said, this will come in handy for sure with another bad guy. Thanks!

PostPosted: Wed Apr 18, 2007 1:10 am
by Game A Gogo
if it can move in any direction Add this:

Code: Select all
animpos=angle/360*nframes;
angle=direction(x,y,player.x,player.y);


And use the code of sgt.sparky then :3

PostPosted: Wed Apr 18, 2007 1:41 am
by Sgt. Sparky
Game A Gogo wrote:if it can move in any direction Add this:

Code: Select all
animpos=angle/360*nframes;
angle=direction(x,y,player.x,player.y);


And use the code of sgt.sparky then :3

Code: Select all
angle=direction(x,y,player.x,player.y);
animpos=angle/360*nframes;

that will work. :D
(you must set the angle before you change the animpos)

PostPosted: Wed Apr 18, 2007 11:51 pm
by Game A Gogo
Sgt. Sparky wrote:
Game A Gogo wrote:if it can move in any direction Add this:

Code: Select all
animpos=angle/360*nframes;
angle=direction(x,y,player.x,player.y);


And use the code of sgt.sparky then :3

Code: Select all
angle=direction(x,y,player.x,player.y);
animpos=angle/360*nframes;

that will work. :D
(you must set the angle before you change the animpos)

works both way sgt.!

PostPosted: Sat Apr 21, 2007 12:08 am
by Sgt. Sparky
it works but it is a 1/30th of a second delay you're way,
the animation change will be delayed that much every time it goes through you're code. :P


:D

PostPosted: Sat Apr 21, 2007 12:42 am
by Game A Gogo
its a 1/X, remember that the frame rate might be higher then 30, which I highly recommended to be 60!

PostPosted: Sat Apr 21, 2007 1:57 am
by Sgt. Sparky
yeah, only when a game is running if you have ever done an fps display you will not it hangs about in to 15-20's or less :P
(unless it is all just text :))

PostPosted: Sat Apr 21, 2007 2:32 am
by Game A Gogo
ummm, when i run a game, it goes up to 120 or more so its pretty stable for me.

PostPosted: Sat Apr 21, 2007 2:43 am
by Sgt. Sparky
:(
my comp runs slow :(

PostPosted: Sun Apr 22, 2007 12:40 am
by Game A Gogo
get more ram!

...

PostPosted: Sun Apr 22, 2007 1:17 am
by d-soldier
.. So if I wanted my bad guy to shoot only if:
He is facing/walking right & the player is on his right, and
if he is facing/walking left & the player is on his left?
... Basically I'm trying to eliminate rockets coming out of the bad guy's back... forget the whole angle thing.