Thread: Handling AI
View Single Post
Old 02-07-2011, 07:54 PM   #3
Ioncannon
New Member
 
Join Date: Dec 2010
Posts: 2
Ioncannon is on a distinguished road
Re: Handling AI

Hmmm a seperate awake array would actually a great way to reduce the amount of time AI takes. Thanks.

I am doing a UNIX programming course at my university, and we just began talking about signals, however I don't know much about them (yet). The MUD I am building is coded in Java, and I am not sure how you would pause the AI of one mob and go do the next one.

This is how mine works:

I have a hashtable of every entity (thing that is not a player) currently spawned. Extending entities are class types: monster, item, and object. Objects is a miscellaneous entity which can be something the user interacts with. These three types can be extended to define what exactly the monster or item is. I used a getType() function to figure out which of the entities are monsters. All spawned entities are called by an ID.

This part is what I plan (not done yet):

Now for monsters, there is a doAI() function that is overrided with template AIs (Aggressive, Passive, Cowardly, Subtle, etc), or can be customized with a specific AI routine (for example bosses). The AI also has various states it can be in (near death, scared, angry, running) which change the ai. When the ai thread finds a awake monster, it runs this function.

One of the problems I always have is having various parts of the code talk to each other. Currently for testing, I have it setup so when the player walks into a room, all monsters wake up. I guess having all actions get sent to the mob, and then based on AI preferences, ignoring some and activating on others would be a way to do it.

Running AI w/o player interaction I assume is what you used timers for?

Sorry if the message sounds all over the place, getting late, and really tired.
Ioncannon is offline   Reply With Quote