Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Mage makes a Game


DaMage
 Share

Recommended Posts

So let’s see, my calendar says it's been about a month, so it's time for an update.

I'm back at university at the moment, so game dev always comes second to assignments. For my second assignment this semester I want to use my game as an example of trying different ways to play games with one handed controls. But in order to do this, I needed to polish up some things and add some 'game' to my game.

First off, I needed a user interface, things like health bars and menus. Now I could have gone and found a c++ library to do this....but where is the fun in that. I have worked with many different drawing APIs over the years, so I know the basics of how you should structure and encapsulate different elements. So I've programmed a couple of UI elements that can be put into different menus that display on screen, but I'm not going to go into depth about how I structured everything to work together, cause that would be boring software engineering stuff.

DMEval 2016-10-06 13-55-07-71.jpgDMEval 2016-10-06 13-55-05-77.jpg

Important part is that now I have an escape and options menu, along with some other controls like reloading the game and exiting. The options menu is pretty sparse and just contains a page for remapping controls, which is sort of required for this assignment about control schemes.

Now for the game part. Last I left off I could move around the level and have animations play, but you couldn't really 'do' anything. So first I added some UI items for health bars that appear for you in the top left, and for enemies, over their heads. Then added a system so that when an attack animation plays, it will trigger a hit at the right moment of the animation (and do all the checks to make sure it does hit). Blocking an attack also causes the attacking creature to stagger, allowing for some very simple block-attack strategies.

DMEval 2016-10-06 13-54-53-92.jpg

Now there was some combat, but the AI was bone stupid, it would just run up and spam attack. To fix this, I booted up Morrowind to see how it’s AI in that game acts....since it is the most similar game in style that I could think of. In that, an enemy will run up and attack, then either pause in place, or move around to attack from a different angle. That isn't too hard to do, so I added that to my wolves. The combat feels bad, but it does work enough for now. Definitely something I'll come back to later.

The last thing I wanted to add was some sort of points system to make up for the lack of any looting at the moment. My level generation has a section marked 'treasure' so I made it so that chests were placed into levels at these places. When a chest is 'activated', or a wolf is killed the player receives points, in order to have 'completed' the level for my assignment, a playthrough will need to kill all the wolves and find all the chests. The points are shown in the top right of the screen.

DMEval 2016-10-06 14-22-00-19.jpg

That’s it for now, hopefully I'll get another post up sooner than a month next time...but probably not.


As an aside, I've just finished organising what I'm going to be doing for the next few years now that I'm graduating. I've put in application to start a PHD with a living expenses scholarship, where I'll be working with VR technologies in one of the university labs. With any luck I'll get it and be able to continue this game dev while I'm doing research.

  • Upvote 3
Link to comment
Share on other sites

  • 3 months later...

Woah, it’s been a while since I did one of these, now is as good a time as any then.

Obviously I didn’t get much done on this project over the holidays, mainly due to a combination of graduating my degree at university and then getting another software job to work on. But as January and that other job was winding up, I have had some time to work on my game again. Also good news is I am into my PHD program with a scholarship, so I'm set for the next few years as far as a job goes and will hopefully have time to work on this still.

After adding some ‘gameplay’ in the last post, it was really obvious that the basic AI I had was no longer going to cut it, and I needed to get that going in order to figure out if my idea for combat would work. Now the combat in my game is based around managing your fatigue while avoiding getting hit, pretty generic, but if you (or an NPC) lose all your stamina, you fall into a ‘recovery mode’ where you are very vulnerable to attacks. This allows you to either work down your enemy’s health by hitting them, or instead working their fatigue so you can knock them down. 

In order to fight, there are a few things you can do, attack, block or break. Attacking will cost some stamina, and will reduce the enemy health if you hit. Blocking drains stamina, but prevents attacks from doing damage, and breaking costs stamina, but will stagger your opponent regardless if they are blocking or not. Doing combinations of these actions and using recoil times and whatnot is where the skill comes into the combat.
But now the real question, how do I explain this kinda complicated system to the computer?


There are a few ways to do AI for this, for example the robotics lab at my university uses state machines for their AI, but for this I’ve decided to use simple flowcharts. Every AI cycle (which is every 100ms), the AI goes through a flowchart to determine what it should do next, these decisions are based on what it’s opponent is doing, what it was doing before and a bunch of random dice rolls to make it less perfect. To help design this, I actually planned out some diagrams that show the order of decisions and results of each outcome, so I’m going to put them here and explain them a bit.

p1.png

This is the start point for the AI. If it can see an enemy, it jumps into combat mode, otherwise it goes into a ‘wander’ state where it just moves around the level randomly. The wander states involves a bunch of pathfinding and checking where it’s at in relation to its goals and targets. Sometimes after reaching a goal, the AI will also just decide to stand there for a bit, that’s what the ‘Do Nothing’ step is about. Most of this is to do with pathfinding though, so let’s jump to combat.

p2.png

The decisions in combat are ordered from most important to least important, so obviously if the AI has low stamina the first and only thing it should do is try to retreat. If that’s not the case, the AI need to move towards it’s opponent, if it’s too far away pathfinding goals are generated, but if it’s close enough to attack, then we need to take action. First we check is the enemy is attacking, and roll a dice if we should block, if not, then we also check if we are currently blocking as the defend section also deals with dropping our block. Assuming nothing was chosen, we then roll a dice to see if we should attack, and then if we didn’t attack, we roll a dice to see if we start to defend. Finally, if we chose to do nothing, then nothing happens and the AI idles for a cycle. This lets the AI look like it’s thinking and allows for a player to attack.

Each of these decisions breaks off to a another section of the flowchart, these are all small sections in the next diagram.

p3.png

First off we have defending, if we have chosen to defend and the enemy is attacking…well we really should defend, but if our enemy wasn’t attacking, we can choose to not defend anymore. This decision ‘loop’ works with the combat section and may change in the future if it gets more complex. Next we have retreating, which basically asks if we are close to the enemy, we move away, repeat until we have stamina again or we are far enough away. 
For attacking we check if the enemy is blocking, if they are we roll a dice to see if we will do a break on them. If they weren’t blocking, or we decided not to break, than we roll another dice to see if we attack.

Now you may be wondering, why do we have so many dice rolls and why would you allow the AI to do stupid things, such as attacking into a block or deciding not to block an attack. The reason is simple, you need the AI to make mistakes otherwise it wouldn’t be fun to play with. In an earlier build I had the AI always block incoming attacks, but it made the AI nearly impossible to beat. You’d stagger them and if you didn’t time the attack perfectly, they’ve be up blocking the attack straight away. By adding some random chance in, the AI will only sometimes do that, other times it’ll try to do something else and get hit.
Anyways, that’s the AI I’ve been working on, still got a bit of work to do, for example stamina isn’t implemented yet, so you can break and block as much as you like, but for this post, that’ll do!

Here is a video of me fighting the AI.

  • Upvote 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...