Jump to content


Photo

Living Dead A.i


  • Please log in to reply
9 replies to this topic

#1 DJ J4KE

DJ J4KE

    GMC Member

  • GMC Member
  • 141 posts

Posted 20 March 2009 - 07:32 PM

Basically, a zombie simulator, but with a person which the player controls and shoots with. I'm terrible with A.I, so if you could give me some code for a zombie object which wanders around, infects civilians and allies, and attacks the player, i'd be very greatful and give credit :) .
  • 0

#2 zachman

zachman

    MagicMan Productions

  • New Member
  • 212 posts

Posted 20 March 2009 - 08:17 PM

It depends on how complicated you want the script(s) to be. the simplest ai could be:
motion_set(point_direction(x,y,player.x,player.y),speed)
but you can also have some pretty complicated ai's with a whole command-stack and personalities and the works. Search through the 'scripts' and 'examples and tutorials' sections. there are plenty of different ai scripts and tutorials to help you out. :)

Edited by zachman, 20 March 2009 - 08:17 PM.

  • 0

#3 Flipbee9

Flipbee9

    The Stinger

  • New Member
  • 1533 posts

Posted 20 March 2009 - 08:19 PM

Yes, it depends on how you want to program your A.I. Also, you can't just ask on the GMC, "Can you please give me a code for an A.I". Most topics that do so get ignored.
  • 0

#4 amibtious

amibtious

    GMC Member

  • New Member
  • 102 posts

Posted 20 March 2009 - 08:42 PM

Yes, it depends on how you want to program your A.I. Also, you can't just ask on the GMC, "Can you please give me a code for an A.I". Most topics that do so get ignored.


Most topics like this won't get much help....but I do happen to have zombies in a game I'm working on right now with very basic AI...or something like AI anyway, it's not strictly speaking an AI...

Most of it only applies to my game, but the movement code I have is possibly useful to you

in alarm[0] I have execute a piece of code...the code is
mp_potential_settings(179,3,10,true)
if  (distance_to_object(player) < 600) {
	mp_potential_step((instance_nearest(x,y,player).x),(instance_nearest(x,y,player).y),1,false)
	speed=S;
}
else
if  (distance_to_object(man) < 600) {
	mp_potential_step((instance_nearest(x,y,man).x),(instance_nearest(x,y,man).y),1,false)
	speed=S;
}
else
if  (distance_to_object(demon) < 600) {
	mp_potential_step((instance_nearest(x,y,demon).x),(instance_nearest(x,y,demon).y),1,false)
	speed=S;
}
else {
	mp_potential_step(random(10240),random(7680),1,false)
	speed=S;
}
alarm[0]=40;


This makes the zombies reevaluate every 40 steps, if there's no target within 600 pixels they'll wander about within an area from 0x,0y to 10240x,7680y, avoiding solid objects; if there is a target they'll move towards it....player first, then man, then demon...you could replace 'man' with ally and 'demon' with civilian and it should work.

You'll also want to replace 10240 and 7680 with however big your room is, and change 600 to however far you want zombies to be able to 'see'

And in the create event of zombies you'll need to set alarm[0] to 40, and create a variable S for how fast you want zombies to move. This will only do movement, not attacking or infecting...you'll have to sort that out yourself cos the attacking system in my game is way to complicated for your purposes.

Edited by amibtious, 20 March 2009 - 08:43 PM.

  • 0

#5 Flipbee9

Flipbee9

    The Stinger

  • New Member
  • 1533 posts

Posted 20 March 2009 - 08:44 PM

Wait, this is a Top-Down game right?
  • 0

#6 Aidiakapi

Aidiakapi

    GMC Member

  • New Member
  • 200 posts

Posted 20 March 2009 - 09:44 PM

The script should work it I look at it right now.
But it's probably for a top-down game.
I think you should tell it when you don't have a top-down game.
Because most people assume it's a top-down unless it says something else. (Or when it's a mario game or something like that, then most people expect platform view.)
  • 0

#7 DJ J4KE

DJ J4KE

    GMC Member

  • GMC Member
  • 141 posts

Posted 21 March 2009 - 12:35 AM

Yes, it depends on how you want to program your A.I. Also, you can't just ask on the GMC, "Can you please give me a code for an A.I". Most topics that do so get ignored.


Most topics like this won't get much help....but I do happen to have zombies in a game I'm working on right now with very basic AI...or something like AI anyway, it's not strictly speaking an AI...

Most of it only applies to my game, but the movement code I have is possibly useful to you

in alarm[0] I have execute a piece of code...the code is
mp_potential_settings(179,3,10,true)
if  (distance_to_object(player) < 600) {
	mp_potential_step((instance_nearest(x,y,player).x),(instance_nearest(x,y,player).y),1,false)
	speed=S;
}
else
if  (distance_to_object(man) < 600) {
	mp_potential_step((instance_nearest(x,y,man).x),(instance_nearest(x,y,man).y),1,false)
	speed=S;
}
else
if  (distance_to_object(demon) < 600) {
	mp_potential_step((instance_nearest(x,y,demon).x),(instance_nearest(x,y,demon).y),1,false)
	speed=S;
}
else {
	mp_potential_step(random(10240),random(7680),1,false)
	speed=S;
}
alarm[0]=40;


This makes the zombies reevaluate every 40 steps, if there's no target within 600 pixels they'll wander about within an area from 0x,0y to 10240x,7680y, avoiding solid objects; if there is a target they'll move towards it....player first, then man, then demon...you could replace 'man' with ally and 'demon' with civilian and it should work.

You'll also want to replace 10240 and 7680 with however big your room is, and change 600 to however far you want zombies to be able to 'see'

And in the create event of zombies you'll need to set alarm[0] to 40, and create a variable S for how fast you want zombies to move. This will only do movement, not attacking or infecting...you'll have to sort that out yourself cos the attacking system in my game is way to complicated for your purposes.


Thanks, I just wanted some help on the wandering, i can figure the rest out myself. :GM072:

Oh, and to the people who were asking if its a TDS, yes it is.
  • 0

#8 Aidiakapi

Aidiakapi

    GMC Member

  • New Member
  • 200 posts

Posted 21 March 2009 - 03:59 PM

I do have to warn you that a script using Motion Planning (mp) can become slow.
Since it's very heavy for game maker to deal with mp.
  • 0

#9 amibtious

amibtious

    GMC Member

  • New Member
  • 102 posts

Posted 21 March 2009 - 04:01 PM

I do have to warn you that a script using Motion Planning (mp) can become slow.
Since it's very heavy for game maker to deal with mp.



What dya suggest instead?
  • 0

#10 chaz13

chaz13

    GMC Member

  • GMC Member
  • 3831 posts
  • Version:Unknown

Posted 21 March 2009 - 05:24 PM

Unless you're running on a steam computer, there's nothing to worry about. I could get up to 400 zombies using a* pathfinding in my last zombie game, so there should be no issue here.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users