Page 1 of 2

AI question.(small)

PostPosted: Sun May 20, 2007 12:26 am
by pavel329
I am still working on that alliance game.
I just want to know how to make it whee the enemy just follows a path i give him.
And the when i get close enough the path is destroyed and he comes after me and attacks me.

well

PostPosted: Sun May 20, 2007 12:41 am
by d-soldier
There is probably a better way, but it seems that if you setup a variable (actor variable) [call it "alert"] and and setup the badguy is this way:

Create-Actor/Script:

alert=0;

Draw-Actor/Script:

if(alert == 0) {
//insert the whole path thing here;
}
if(alert == 1) {
//insert the whole move-to thing here;
}

and add an activation event (from any actor) with a script that says:

alert=1;

----------
Now the setup is complete, but you will need to add a filled/wireframe region around the bad guy. That region's needs an activation event, so right click on it, and setup an activation event [collision w/ player] and send the event to the badguy....
So basically you make the player enetering the region change the alert variable for the badguy, therby adjusting his behavior.

PostPosted: Sun May 20, 2007 12:46 am
by d-soldier
heres a pic... I work better with visuals when people are helping me...

PostPosted: Sun May 20, 2007 1:52 am
by pavel329
ok i get most of this.

but what do i put for the whole " move to thing here" An "Path thing here"

Do i just put the path the i want him to walk?

PostPosted: Sun May 20, 2007 2:01 am
by pavel329
ok i get what to put in move to.
But what about path?
i checked under functions but found no path.

PostPosted: Sun May 20, 2007 2:03 am
by pavel329
lol ok nm i found that out too.
Well thanx alot for the code that helped alot.

PostPosted: Sun May 20, 2007 4:07 am
by d-soldier
Sounds like you got it figured out before I got back to check on you.. :D

PostPosted: Sun May 20, 2007 1:47 pm
by Sgt. Sparky
yeah. :D
but I would reccomend using a code like this in a draw actor event of that enemy(make alert an actor variable.):
Code: Select all
if(distance(x, y, player.x, player.y) < 175)alert = 1;   
else alert = 0;
//then all your moving ect. here.
:D

PostPosted: Sun May 20, 2007 3:54 pm
by pavel329
thanx alot guys.

Ugh this game is too long.


Oh also i was wondering how to make levels.


I thought maybe when you hit a certain target you do the move to option.
Like to the place where the next level is.
Also a destroy actor option so the level you just finished is destroyed making the game go faster.


Would this work?

PostPosted: Sun May 20, 2007 4:10 pm
by d-soldier
See, Sparky just eliminated the need for the activation events and filled regions... I knew there would be a better way... as far as the levels go, a move-to funtion at very high velocity should do the trick, just make sure the player and the view get moved.

PostPosted: Sun May 20, 2007 4:29 pm
by pavel329
Well in my game you change chaters each l
And what i did was had a character all ready to go and when the first play got to the end,He would be destroyed.And the view would change parents to the new guy.
And the new guy would be stuck in an invvisible box.(to prevent him from movin around when you push butons at the other level)

So when the views parent changed.
You would see text saying push this button to start.
And the box would be destroyed.
There youv are at the new stage.


I hope you get what i mean.


I barely ever use codes.
I try to figure other ways.Lol


But still than for the codes guys.

PostPosted: Sun May 20, 2007 8:26 pm
by pavel329
none of these are working.

PostPosted: Sun May 20, 2007 11:54 pm
by pavel329
plz can someone tell me what to do?

PostPosted: Mon May 21, 2007 12:47 am
by pavel329
Plz?

PostPosted: Mon May 21, 2007 4:56 am
by d-soldier
How about you help us with some information... whats not working? The subject of the post, or the last thing you said regarding levels?