Smart shooting Bad Guys

Game Editor comments and discussion.

Smart shooting Bad Guys

Postby d-soldier » Sat Apr 14, 2007 8:12 pm

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!
Attachments
game_help1.gif
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby Fuzzy » Sat Apr 14, 2007 9:56 pm

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.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby Sgt. Sparky » Tue Apr 17, 2007 5:12 pm

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.
:)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Game A Gogo » Tue Apr 17, 2007 11:35 pm

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.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

great!

Postby d-soldier » Tue Apr 17, 2007 11:48 pm

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!
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby Game A Gogo » Wed Apr 18, 2007 1:10 am

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
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Sgt. Sparky » Wed Apr 18, 2007 1:41 am

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)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Game A Gogo » Wed Apr 18, 2007 11:51 pm

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.!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Sgt. Sparky » Sat Apr 21, 2007 12:08 am

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
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Game A Gogo » Sat Apr 21, 2007 12:42 am

its a 1/X, remember that the frame rate might be higher then 30, which I highly recommended to be 60!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Sgt. Sparky » Sat Apr 21, 2007 1:57 am

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 :))
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Game A Gogo » Sat Apr 21, 2007 2:32 am

ummm, when i run a game, it goes up to 120 or more so its pretty stable for me.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Sgt. Sparky » Sat Apr 21, 2007 2:43 am

:(
my comp runs slow :(
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Game A Gogo » Sun Apr 22, 2007 12:40 am

get more ram!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

...

Postby d-soldier » Sun Apr 22, 2007 1:17 am

.. 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.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Next

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron