Plotscripting turn-based AI

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Plotscripting turn-based AI

Post by Foxley »

Okay, I feel kind of ridiculous and terrible for even posting about this on the forums, but here we go.

I've developed an idea for a game that would require some basic AI for monster behavior in a turn-based, grid-based (OHR's 20x20 grid) movement scheme. Problem is, I have no idea how to even begin approaching this using Hamsterspeak. I've never programmed AI before in my life.

Does anyone have any basic enemy AI scripts I could analyze and try to get an idea of how I'd approach this? Or if this is the worst engine to do this in, then by all means, give me the reality check I need so I go back to working on my actual RPG project like I should be doing!
User avatar
BMR
Metal King Slime
Posts: 3310
Joined: Mon Feb 27, 2012 2:46 pm
Location: The Philippines
Contact:

Post by BMR »

So, something like Fallout where you're free to move around a grid, and the AI figures out where to move on the grid and what actions to take?

If so, then here are a couple of things that you may want to look at. I believe Mogri has a game that uses Dijkstra's for figuring out where the AI wants to go, not sure what he uses to get the AI to figure out it wants to do though. I use a different method, and I'd offer to send you my script but it's a complete mess and might be more confusing than helpful if I'm being honest, hehe.
Last edited by BMR on Tue May 10, 2016 3:48 am, edited 3 times in total.
Being from the third world, I reserve the right to speak in the third person.

Using Editor version wip 20170527 gfx_sdl+fb music_sdl
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

You didn't provide any hint what you want the NPCs to actually do...
Do you want something similar to the 'wander' NPC movetype?
Do you want the monsters to walk along fixed paths?
Do you want them to wander randomly until they see the hero, and then chase? Until they tire and go back to wandering?

Probably the most basic game AI concept is a state machine: each actor is in a certain state (e.g. "chase the hero", "wander"), and there are various conditions that cause it to transition to a different state (e.g. the hero comes nearby).

You won't need pathfinding (what bmr described) unless you want the monster to walk to a specific spot (e.g. walk to the hero if they might be far out of sight; just walking in the direction of the hero is easy).
Last edited by TMC on Tue May 10, 2016 9:11 am, edited 3 times in total.
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

@BMR
Thanks for the links! And it'll be like most Rogue games where it's turn based and moving a space allows other creatures to also move a space, tit-for-tat.

@TMC
Sorry, I didn't even know what questions to start asking, that's how clueless I am on AI. I think I'd generally want monsters to spawn on the map somewhere and stay still until the heroes are spotted. Maybe I'd make some of them roving and some of them stay still to block off level progress/treasure/etc.

So with states, for example, every step/move I could do a check on a X,Y range of vision around each monster and if a hero is at that spot then set the state to 'chase', and move them toward that hero?
User avatar
BMR
Metal King Slime
Posts: 3310
Joined: Mon Feb 27, 2012 2:46 pm
Location: The Philippines
Contact:

Post by BMR »

Yup, that sounds about right. Would also depend on how complex you want your combat. Here are a few things you might want to consider:

Do enemies always attack with melee (moving up next to the player) only? Or can they do ranged (finding a good spot to stand that has line of sight to the player) as well?
Do enemies only ever have one attack? Or can they use multiple? And if so, how will they decide which attacks to use?
How many states can enemies have? Only Idle/Chase? Or will they have other states such as Fleeing?
How complex do you want their range of vision? Is it a simple IF distance_to_player <= cutoff THEN enemy.state := CHASE? Or are you going to take into consideration whether there are walls between the player and the enemy?
Being from the third world, I reserve the right to speak in the third person.

Using Editor version wip 20170527 gfx_sdl+fb music_sdl
User avatar
Spoonweaver
Liquid Metal King Slime
Posts: 6462
Joined: Mon Dec 08, 2008 7:07 am
Contact:

Post by Spoonweaver »

Can be done with tags and invisible npcs.
No scripting needed
Post Reply