Turn Based Combat

Discussion pertaining to resources, stories/characters and gameplay ideas in this forum dedicated to games that are just a faint glow.
Forum rules
Do not create a topic offering to produce resources. Click here for the reason.

Please use above resources section of site so everyone can have access to the resources you create.
User avatar
priest865
001 Subscriber
 
Joined: Tue Jul 15, 2008 2:00 am
Location: Hiding Underground

Re: Turn Based Combat

Postby priest865 » Fri Dec 16, 2016 4:42 am

I'm curious how you solved the problem of pathfinding Did you implement A* algorithm or are you using a custom one? When adding patfinding I was aware (I think Mike mentioned it once) that 001 also uses A* but it doesn't seem to me that it is possible get to the path the engine calculates for its AI. Or at least I wasn't able to make use of the patfinding of 001. So I had to implement A* myself with tables. It works quite fine with some restrictions which brings me to my second question: Since 500 is the maximum size of a table do you have any restrictions for your maps or the distance you calculate the path?

After all in the worst case scenario (in case the path is blocked) my version of A* has to go through all the (low movement cost and neighbouring) tiles and creates an entry for each tile so the maximum for my mapsize the algorithm calculates is restricted to somewhere between 22x22 and 23x23. Although I don't plan a tactics game with big maps, the limitation of tables prevents me to use my pathfinding in a combat system similar to Fallout 1, 2 or Arcanum where the whole map can be used for a battle. Instead I am using a battlesystem similar to the Heros of Might and Magic or (older)Agarest games where the battlefield is limited in size.
Image

User avatar
Mr.Numbers
001 Support
 
Joined: Wed Feb 28, 2007 1:50 am
Location: Alberta, Canada

Re: Turn Based Combat

Postby Mr.Numbers » Fri Dec 16, 2016 7:43 am

You can actually snag the pathfinding used in 001 ;)

Check out the "Next direction to walk to location" event. This returns the next direction an actor has to walk to get from its current position to a position on the map.
Image
I AM THE ALL MIGHTY SCRIPTING MASTER
Please do not PM me with Engine 001 related questions, rather post on the forums. ;)

User avatar
priest865
001 Subscriber
 
Joined: Tue Jul 15, 2008 2:00 am
Location: Hiding Underground

Re: Turn Based Combat

Postby priest865 » Fri Dec 16, 2016 11:10 am

I was thinking of using that but I wasn't aware that I could calculate a path with it. How does it work if the path is blocked?

Well it is probably already to late for me. My pathfinding is almost completely implemented with player and npc moves.
Image

User avatar
Mike
001 Co-Founder
 
Joined: Sun May 08, 2005 1:29 pm
Location: Ontario, Canada

Re: Turn Based Combat

Postby Mike » Fri Dec 16, 2016 12:20 pm

It just returns nothing if there is no path. I could add a "closest" version of it, similar to how "Walk to Closest Location" works. But yeah, if you already have something setup, it's probably best and gives you plenty of control :).

User avatar
Lucifiend
001 Subscriber
 
Joined: Wed Apr 22, 2009 7:37 am
Location: Layton, UT

Re: Turn Based Combat

Postby Lucifiend » Fri Dec 16, 2016 9:50 pm

True, I use the Next Direction function to find out which cardinal direction my actor would travel to get to a location. Each time your fire the function, it tells you if the next location is Left, Up, RightDown, etc in any of the 8 possible move directions. I use 16 pixel increments. I was using 32 pixel increments but the pathfinding can take some wonky ways to travel a straight line. The 16 pixel increment seems to smooth this out. If I wanted to check a route directly right of the actor, the Next Direction might give you a RightUp first then a RightDown next and then a series of Rights. I'm not sure why it does it but using the shorter increments seems to help out. The tricky part is to increment the actor through the steps. I cheat and create an invisible actor that acts like a ghost version of the AI and invisibly steps through the route. Once it reaches the target, it reports back it's findings for the actual AI to decide if it can follow the path or not. This way, as I step through the path I can do other scans for each increment. I scan for things like line of sight and range to target to determine if I can use ranged weapons.

I'm working out one weird bug where the AI gets too close to other AI and get hung up in their collision area. When this happens, the AI just stands there and locks the script up. It only happens when the battlefield gets congested. I did a 10 on 10 battle and this issue started popping up as AI clustered around enemies to bash on them. One obstacle at a time. I have an idea how to solve it but I have to figure out how I'm going to splice it in.

User avatar
evs
001 Admirer
 
Joined: Tue May 08, 2012 5:27 pm
Location: Perth, Australia

Re: Turn Based Combat

Postby evs » Sat Dec 17, 2016 6:56 am

ive experienced that collision clash in various games, best way around it ive found is to make collisions 4x4 pixels wide and 64 or so high (as high as your sprite/model. they dont seem to get hung up on each other then, but still can be hit

User avatar
Lucifiend
001 Subscriber
 
Joined: Wed Apr 22, 2009 7:37 am
Location: Layton, UT

Re: Turn Based Combat

Postby Lucifiend » Sat Dec 17, 2016 7:26 pm

Nevermind. Ends up it was an even easier fix. My route planning actor had "Pass through Allied Actors" turned off but when I actually moved the real actor it had "Pass through Allied" turned on. This means the actual actor was taking a slightly different route than the planner which was getting the real actor hung up on things. Now that no one can pass through anyone, it all runs smooth. One little check box was causing all the trouble. My 10 on 10 battles run without any problems.

I'm going to take a look at my battle system (the RPG elements) to see if I need to tweak anything before moving forward. I'd like to be happy with the underlying mechanics of the combat before adding more functions to it.

Things on the to-do list:
- Add morale so heavily wounded flee
- Add ability for AI to heal if getting low on HP
- Add combat magic
- Add magic weapons
- Add magic armor
- Increase arsenal of weapons
- Increase armory
- Add sensory to AI so they can see and hear opponents. (Right now they just know EVERYTHING on the battlefield) This will enable sneaking and surprise attacks. I have light levels already being considered, but there are no current rules on first seeing or hearing an opponent before going after them.

Things on the maybe list:
- AI personalities (Like aggressive or meek traits)
- AI tactics (Move as a team or use specific tactics vs. certain types of actors)

User avatar
priest865
001 Subscriber
 
Joined: Tue Jul 15, 2008 2:00 am
Location: Hiding Underground

Re: Turn Based Combat

Postby priest865 » Sun Dec 18, 2016 4:53 am

I think personalities are important after all not every enemy reacts the same way. Personalities also force the player to adjust their strategies. For example slime probably does not have any intelligence and probably will attack until it is destroyed while human enemies will coordinate and maybe even give up/surrender or flee when faced with an overwhelming force. Undead also wouldn't really fear death and will charge head on but will pick a target strategically. But those are only fantasy game scenarios. It probably depends on the game.

Mike wrote:It just returns nothing if there is no path. I could add a "closest" version of it, similar to how "Walk to Closest Location" works. But yeah, if you already have something setup, it's probably best and gives you plenty of control :).


Agreed, pathfinding works fine for me. There was an issues to get actors to walk a path defined with coordinates but that's already solved with a custom event. And my other consideration was the limitation of 500 lines for tables since I use the tables to save coordinates in tables: open, closed and path. However tables have also a z axis so I don't think this will be a problem if I want to expand the whole system in future.
Image

User avatar
Lucifiend
001 Subscriber
 
Joined: Wed Apr 22, 2009 7:37 am
Location: Layton, UT

Re: Turn Based Combat

Postby Lucifiend » Mon Dec 19, 2016 1:49 am

Even though I hadn't put much into it yet, you make a good point, Priest865. I was thinking mostly of sentient personalities. I didn't think about the undead, animals or automated (like golems). I rather doubt a wolf would care much about whether someone was holding a crossbow or a dagger. They would either attack nearest or the last to hurt them. And would probably be more likely to scamper off if overly threatened. I'm not exactly sure how I want to incorporate those sorts of reactions into the AI.

User avatar
evs
001 Admirer
 
Joined: Tue May 08, 2012 5:27 pm
Location: Perth, Australia

Re: Turn Based Combat

Postby evs » Tue Dec 20, 2016 1:36 am

actually a wolf is likely to gang up on the weakest hp dude.. dont they try to pick off the weakest in a pack?

PreviousNext

Return to Resource, Story and Level Design

Who is online

Users browsing this forum: No registered users