playMaker

Author Topic: AI Issue  (Read 1164 times)

Athin

  • Full Member
  • ***
  • Posts: 163
AI Issue
« on: March 20, 2018, 07:17:34 AM »
Hey all,

I've been playing around with Playmaker a lot lately and was hoping someone can help me with this problem.  I've made a small RTS Medieval game that has AI control peasants.  What I'm looking for is a way to have those peasants find the location of a farm the player places and start walking to it and farming it but only if it has an opening (5 Max farmers per farm). 

I'm currently thinking the way to do this is through an array by placing the available/not available ones on and off the list for them to check against.  Not sure if this is the correct path for this?  Any advice?

Thanks!

Doh

  • Full Member
  • ***
  • Posts: 124
Re: AI Issue
« Reply #1 on: March 20, 2018, 08:52:17 AM »
Sounds a good start to me.

You could have one array for each npc game object, then you could have a bool array that reflects the employment status of each npc using the same indexes as the game object array.

Id be tempted to experiment with an array on each building too that stores the npc index numbers from the main employee array, so locating your workers would be something simple like checking the index numbers on file, 0,7,16,18,24, if you wanted to look at the fourth one for example, you could then query the main npc object array, asking it to get game object at index 18, store it as the current npc of interest, then say get position of current npc of interest, you can then move the camera to that location and expect to see them.

So yes I think you're starting in a good position, it should provide a good foundation.