When I originally started writing the game, I was planning to use the standard one key – one action control scheme, which would have used most of the keyboard. This is pretty standard way how roguelikes do it anyway, especially the ones with lots and lots of different actions.
Then at somepoint I started wondering if the game would be more fun if it had less actions the player can perform and they would all be accessible with standard XBox controller. I did some restructuring and got the game working pretty well. The problem with this scheme was that Qt doesn’t have support for controllers straight out of the box, so I had to resort to third party solutions.
Recently I started thinking that if the game will be played on PC most of the time anyway, I could just add proper mouse support and maybe even drop the controller completely (not 100% of this yet, but I’m thinking it). I would have to restructure code and inputs and some of the UI once again, but I was sort of going to clean up that at somepoint anyway.
So, starting from the clean slate and thinking only the actions that I currently have (but sort of guessing what I might want to do in the future), I’ll need following:
- moving around
- fighting enemies, both melee and ranged
- taking and leaving items
- using items (wearing armour, wielding weapons, drinking potions)
- combining items? (nothing concrete, just pondering about this)
- examining items (seeing their description and stats at least)
- using various skills (jumping, dashing, throwing fire)
That’s quite a lot already and might not even cover everything. Tricky part in deconstructing controls into separate groups is that they aren’t independent. Choices made for one group will affect other groups and vice versa. So there will be going back and forth, while making finer adjustments to the system.
Taking and leaving items
Such a simple sounding actions, yet so many different possibilities and choices to make: can player pick items around them or only from same location? Can player take or drop multiple items in one go, or do they have to do it one by one? Does taking and dropping items take time or are they instant actions? If taking multiple items, is time added to player’s counter after taking the whole stack of items or after each and every item? I originally started thinking about movement first and then later on realized that taking items is very meshed with it, so in the end I had to tackle them together, going back and forth between items and movement.
Since I want to have the UI as efficient and easy to use as possible, I want player to be able to pick up multiple items. In the same train of though, it should be able to pick up items from adjacent positions. This will open a can of worms though, since suddenly traps will have to take account case where character is taking items from trap, while standing next to it. Sometimes it might trigger the trap, sometimes not. I won’t be allowing characters to pick items that are in same square as some other creature.
What about the time, how should it work when picking up multiple items? In case there is a big pile of loot and two characters are competing on it, it wouldn’t make sense that the first character to go would be able to snatch the whole stack. Time should move after each item that is picked up or dropped down. And if a hostile character comes too close, character picking up multiple items should stop and react to the new treath.
The scheme I came up with that satisfies all this is following:
- clicking a square with a single item and nothing else than the character will pick up the item automatically
- clicking a square with multiple items will show a list of items where player can click a single item to pick it up or pick up all of them with a single click
- while picking up multiple items, arrival of a character next to player will stop the action (this makes sneaking around and looting items next to creatures chore though)
- dropping of items is done from inventory screen by right clicking them
- dropping of multiple items isn’t possible
- moving mouse over an item will display tooltip showing details of item
Two immediate options here: keyboard and mouse. With keyboard, character would move everytime player presses a button or keeps it pressed down.
With mouse there are even more options: character could move the direction of mouse cursor when clicked or the character could take multiple steps, trying to reach location where player clicked. If a trap is spotted or a monster comes too close, character could automatically stop and give player chance to react the new situation. To have precise control on what path the character actually takes, a path from character to current mouse location is always shown.
This one took quite a long time to nail down and I’m still not 100% sure that this is the correct choice. For now I’m going to have keyboard controls for moving: both WASD and cursor keys move the character around. Entering the same location with stairs will automatically descent/ascent them (this will require some fine tuning on the level generation code, to make sure there’s always enough space around the stairs to characters walk around them). After trying out the scheme outlined here for a while, I might do a test with mouse movements too to see how it compares in this specific case. I might even end up supporting both methods of moving if they mesh well.
Because clicking a square that has items on it will make character to pick those items, it is not possible to move into the square without explicitly specifying “yes, I want to move, not to pick up items”. This is done by holding ctrl-key while clicking the square. It could have been other way too, but then picking items would have always required pressing the ctrl-key. So I opted with the option that needs less using of ctrl-key.
Roguelikes have the age old tradition of bump to fight. Every time player tries to enter to same location with a monster, they automatically perform a melee attack. This is also the way I’m having it in the game. System is simple, well tested and works equally well with both mouse and keyboard.
For ranged combat there are more options: right click, left click + some button or even click the direction + some keyboard button to perform attack to that direction.
Here’s another tricky choice. Current codebase is written to allow characters to shoot at eight directions. If I wanted to use mouse aiming, it would feel natural to allow characters to shoot at all directions. This would require quite a bit of work on the engine side (not that it’s a reason not to support this) and line of sight calculations would need to be added to the system too.
In the long run, I would like to support shooting at any direction, which would mean that target selection with mouse is natural (there are ways of doing this with keyboard only, but I never got warmed up for them). Essentially this means that if player left clicks a monster, they are trying to attack it. If monster is next to them, attack will be melee one. If the monster is further away and player has a ranged weapon, they’re trying to do a ranged attack.
Using items and combining them
Items generally have a single specific action character can do to them. You can’t eat amulets or wear underpants on your head. This streamlines the game and makes writing UI quite a bit easier.
Items are used from a separate inventory screen. To perform primary action, player just left clicks the item. This will wear or take off armour, wield or unwield weapon and drink a potion. Currently equipped items are shown at a separate region on inventory screen. Since player can have rather large amount of items in their backpack, only icons are shown. Name and other details are shown in a tool tip.
To combine two items, player simply drags them on top of each other in inventory. If items can be combined, the icons are shown in normal colour. If the can’t be combined, icons will be gray. Combining multiple items isn’t possible with this system, so building contraptions and more complicated things must be done in stages, creating items that represent partial build of that specific contraptions. Players can now try to combine items, without specific goal, just trying to figure out what parts can go together.
I don’t currently have many skills ready in game or plans for that many skills, making designing UI for them a challenge. My guess is that most of them will be performed on main screen of the game and target either player character, general location on a level or a specific creature. Since right mouse button hasn’t been used for anything else on this view, I’ll be using it for skills. Target is selected with a mouse pointer and skill triggered with the right mouse button.
The big guestion with this approach is how to select the skill and display currently selected skill. I’m imagining a little drop down with an icon next to it, located somewhere at the top of the screen with rest of the status icons. Icon serves as a quick visual representation of the skill, with a name of the skill next to it. As always, tool tip will be used to show the details. Skill can be selected either by clicking the dropdown with mouse or using a scroll wheel. I’m considering adding a keyboard support in form of go up / go down in the list type of thing.
But, what about if I wanted to use a skill on an item that is currently in my inventory? That is not possible with the planned system. I could do that by dragging an item from inventory on top of the skill icon. Or I could do that by holding ctrl-key, while left clicking the item. In both cases, selecting the used skill must be possible while the inventory dialog is open. I would like to keep dragging at minimum, since slightly erratically functioning mouse can ruin it.
Control or no control?
One, slightly different approach from the one outlined above, would be to use context menus. Left clicking would still perform the default action, but right clicking something would pop up a quick menu, where different actions are listed and selecting one will perform it. This would remove need of using ctrl-key to select some of the actions, there wouldn’t have to be a separate control for selecting which skill is active and so on. Neverwinter Nights uses this kind of system very succesfully.