The Daily Click ::. Forums ::. Klik Coding Help ::. Grid Movement enemy AI
 

Post Reply  Post Oekaki 
 

Posted By Message

Windybeard Games



Registered
  14/04/2005
Points
  219

You've Been Circy'd!VIP MemberCandy Cane
13th November, 2007 at 05:04:16 -

I was talking about an issue i was having with this in another thread "Spread value" i just want to continue the questioning but in a more appropriate thread. Basicly i cant make one. I have tried everything i know apart from one idea i just had and i was hoping i could get some feed back on its efficancy.
Due to the fact that alot of the tiles in the game are animated, they are active objects and are grouped by a qualifier (neutral). This causes me some nasty problems cause you cannot code using qualifiers in object behaviours. (if i could then i wouldnt have a problem).
i have the engine to point where all enemies on screen are given 4 collision detectors (via a spread value code), i have also implemented a movement system which works correctly. This all works correctly when there is only one on screen, as soon as there is more than one only the first enemy will move, the otheres will just look in the direction they are supposed to move. I imagine this issue os to do with fast looping but i just cant seem to figure it out.

The idea i had was to have some sort of invisible collision map that will be one background object, this way the enemies will collide with this and i will be able to code in the object behaviour.

If you could let me know what you think of my idea and if anyone can fix the mentioned issue with my original movement, that would be better. Any examples would be much appreciated.

Thx

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
13th November, 2007 at 10:19:34 -

It's so very funny that you mentioned that invisible collision map because that's EXACTLY what I'm dong for Equin Legacy's overworld map. Now bear with me because I'm not using tiles or anything but maybe you can figure out something with this below:

Okay, now the enemy A.I. is basically non-existant for the overworld map but it doesn't need to be smart for this part, just the real time battles that take place if one of them hits your character on it.

What I did is I drew the outlines of each continent in black. There are my borders. Then once I was done I used a paint fill to fill up all the ocean areas and other water that I knew my guy wasn't going to be able to cross. So what's left is a big black picture with white continent shapes on it. These white areas I made the transparent part of my "mask" active object.

Now the cool part is that I went back to my outlined world (I saved a backup copy) and drew the actual world map on top of it so that instead of black outlines and crap there's grass, trees, desert, etc. For the water I made 3 or 4 copies of this map to make the water look animated and good. Lastly I took the "mask" active object and put it down on the frame, and the animated "show" map and put it directly on top of the mask so that everything lines up nice.

When you move the guy around, the movement checks collision against the mask and not the actual showing map because it's just black & white and very easy to make the decision. And the best part is that it works perfectly like how I wanted it to. There may be better ways (and I'm sure there are) but maybe you could do something like this? Personally I've never done tiles with MMF because it seems like a giant pain, which I'm sure you've already discovered yourself. In the past in VB I'd use some big array and a lot of needless code but it seemed to get the job done (eventually.)

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Windybeard Games



Registered
  14/04/2005
Points
  219

You've Been Circy'd!VIP MemberCandy Cane
13th November, 2007 at 17:16:43 -

nice, ill give it a try later, i have already made the collision map, just gotta plumb it in!

 
n/a

Windybeard Games



Registered
  14/04/2005
Points
  219

You've Been Circy'd!VIP MemberCandy Cane
13th November, 2007 at 18:41:32 -

Damnit, just tried it and still only one of my enemies will move, I just cant figure it out, Please i am begging somone to do me a quick example file so i can move past this point. Please....

 
n/a

Windybeard Games



Registered
  14/04/2005
Points
  219

You've Been Circy'd!VIP MemberCandy Cane
13th November, 2007 at 19:52:45 -

Please somone help me, heres the problem, please take a look and help, im at breaking point!

http://www.mediafire.com/?ecax2dykmgq

Any fix is good, i just want all my enemies to move on the 20x20 grid and collide with the red.

Image Edited by the Author.

 
n/a

Windybeard Games



Registered
  14/04/2005
Points
  219

You've Been Circy'd!VIP MemberCandy Cane
14th November, 2007 at 12:55:29 -

anyone? or am i forced to sit quitely, alone with a failed project filling my many coffee mugs with salty tears of failure. Please people, this is childs play to some of you but its project ending for me. im almost begging here.

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
14th November, 2007 at 13:38:41 -

Well, all I'll say is back when I had no internet and couldn't figure out how to make a certain part of my game work I just figured out other ways to do it myself or change it into something that I COULD do. I know this sounds like crap advice, and probably is, but does your game REALLY need to have your enemies act and work this way? Can it be done some other way? If you're going to have the battle be turn-based surely you can think of another way to move the enemies from place to place?

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Windybeard Games



Registered
  14/04/2005
Points
  219

You've Been Circy'd!VIP MemberCandy Cane
14th November, 2007 at 14:00:34 -

im only tryinh to get them to randomly move on a grid movement, but somthing happens to my code when there is more than one. ive been told its a fast loop problem but thats like throwing a book at a monkey and expecting an essay.

 
n/a

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
14th November, 2007 at 17:24:01 -

http://www.create-games.com/article.asp?id=1798

 
Craps, I'm an old man!

Windybeard Games



Registered
  14/04/2005
Points
  219

You've Been Circy'd!VIP MemberCandy Cane
14th November, 2007 at 17:38:08 -

thx shab, i hope this will ease my suffering.

i just had a go.....

- Always
--- Start Loop 'My Loop' 'nObjects(Enemy)' times

That literally means start a loop for every Enemy.
Then, in the loop conditions, do this:

- On Loop 'My Loop'
+ ID of Enemy = Loopindex(My Loop)
--- Do whatever actions you had in mind

The +ID of enemy = loopindex isnt possible, it doesnt give me that option, all i get is
"Get loop step" and "get number of loop steps" what do i do now?

Image Edited by the Author.

 
n/a

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
15th November, 2007 at 00:30:13 -

Can't you go: ID("Enemy") = Loopindex("EnemyLoopName")

That should be acceptable by MMF2 It's under the special header.

 
Image
http://bfollington.tumblr.com
   

Post Reply



 



Advertisement

Worth A Click