Forums

Need help making AI enemy


Subscribe to Need help making AI enemy 10 posts, 4 voices

 

Aug 5, 2007 1:56am

kearel kearel 217 posts

I need help making a AI enemy

Like Petter Griffen said, "Cant touch me"
here is a signiture that ropes27 made me! THX man!

 

Aug 5, 2007 2:37am

gatz827 gatz827 415 posts

umm... many wuestions come to mind, people need to know more about the following:-
What sort of game is it
What do you want the enemy to do
is it 2D or 3D (not so important really)
and I can't really think of any others at the moment

 

Aug 5, 2007 9:24am

Trollsplatterer Trollspla... 2943 posts

Some more questions or clarifications of Gatz's:
- is it a platform-game or do they move up and down as well as left and right?
- do they move when they attack? Do they shoot?
- Do they start to move when you're close?
- Do they react to your movement, for example: do they duck when you shoot?
- How much do you know about programming in GM? Are you familiar with code, or do you only work with the buttons (D&D)? AI requires code...

If you know code, you could try some things for yourself, using the function "random(maxnumber)". This function returns a random number between 0 and maxnumber. You can make your enemy inpredictable with this function, making his speed, direction and time between attacks random.

Visit www.trollsplatterer.be for some files I made to help people out.

 

Aug 5, 2007 1:37pm

gatz827 gatz827 415 posts

thank you trollsplatterer, I didn't realise how vague my wuestions were untill now... must... not... ..sleep...

 

Aug 5, 2007 2:50pm

ConnMon ConnMon 33 posts

tollsplatterer is right. we need to know how your enemies attack, how you want them to move, how fast, and at who? c/b cuz i want to help.

 

Aug 5, 2007 3:52pm

kearel kearel 217 posts

well... its a platform game, and they shoot forward, and at a downward angle and they are very slow and it jumps
and at hte main character

Like Petter Griffen said, "Cant touch me"
here is a signiture that ropes27 made me! THX man!

 

Aug 5, 2007 9:00pm

Trollsplatterer Trollspla... 2943 posts

Do you know code?

I'd hate spending my time explaining all this to you in code, if your answer would be:
"Thank you, but I don't know anything about code, so I'll try something else."
I could give you some help in D&D, too, but it'd restrict the AI-capabilities of the boogies.

Visit www.trollsplatterer.be for some files I made to help people out.

 

Aug 5, 2007 9:14pm

kearel kearel 217 posts

Thank you, but I don't know anything about code, so I'll try something else
there....
and i really dont care if it restricts the AI capabilities... i REALLY dont care

Like Petter Griffen said, "Cant touch me"
here is a signiture that ropes27 made me! THX man!

 

Aug 6, 2007 8:26pm

Trollsplatterer Trollspla... 2943 posts

They move towards the main character when you come within 250 pixels and start shooting at a 20 degrees downward angle.
I name the main character-object 'hero', but you have to replace this with the name of the object of your own hero.
These events are to be placed in the enemies:

in the create-event:
- "set variable"-action: variable name: shoot, value: 0


in the step-event:
//test if the hero is closer than 250px, if so, make him move
- "test statement"-action: expression: abs(x - hero.x) < 250
- "start block"-action

//move towards the hero (-1 is left, +1 is right), with a speed between 2 and 5
- "set horizontal speed"-action: hor. speed: (hero.x - x)/abs(hero.x - x) * (2 + random(3))
//enable shooting
- "set variable"-action: variable name: shoot, value: 1

- "end block"-action
- "else"-action
- "start block"-action

// make the enemy stand still and stop the shooting
- "set horizontal speed": 0
- "set variable"-action: variable name: shoot value: 0

- "end block"-action

//if "shoot" is 1, shoot a bullet within 5 seconds, but it can be faster, shoot 20 degrees downwards
- "check expression"-action: expression:
shoot == 1 && random(room_speed*5) == 1
- "create moving"-action: object: badbullet, x:x, y:y, speed: (hero.x - x)/abs(hero.x - x) * 8, direction: -(hero.x - x)/abs(hero.x - x) * 20

Visit www.trollsplatterer.be for some files I made to help people out.

 

Aug 6, 2007 8:50pm

Trollsplatterer Trollspla... 2943 posts

I haven't tried it and I hope you understand enough of it to get the bugs out yourself, if there are.
I haven't done the jumping yet.

Visit www.trollsplatterer.be for some files I made to help people out.