Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Knights Discussion / Re: Dagger hotkey
« Last post by d.healey on August 13, 2017, 03:39:17 PM »
Thanks for the detailed info. I shall spend some time now getting to grips with the code.
22
Knights Discussion / Re: Dagger hotkey
« Last post by Stephen on August 13, 2017, 03:17:58 PM »
Well, there is the Controller base class and an implementation for KeyboardController. (There was originally going to be other implementations for things like joysticks or gamepads, I never got around to that though.) This basically just gives you up/down/left/right and "fire button" functionality and mostly relates to the old style (original Amiga knights) controls.

The mouse controls (the "action bar" thing that you click on using the mouse) got added later, and this is partly implemented in the ActionBar class and partly in LocalDisplay::readControl.

The main logic for controls is in LocalDisplay::readControl so that's probably what you need to read if you want to understand how controls work.

There is also a UserControl class -- a UserControl represents something you can do in the game, like moving, or swinging a weapon, or picking up an item. (Or throwing a dagger.) Each UserControl has various pieces of information attached to it:
 - the id number, which (I think) is used by the game engine to match the UserControl up to the actual code that executes the action.
 - the "menu graphic" which is the icon that appears on the action bar (or the menu if using old style controls)
 - the "menu direction" which controls where it appears on the old style 4-way menu
 - the "tap priority" which I think controls what happens when you just tap the fire button (this is context sensitive so the highest priority action is selected)
 - the action bar slot and priority, which controls where it appears on the action bar
 - whether it is continuous (like lock picking) or not (like opening a door)
 - the name (which acts as a "tool tip" if using the action bar)
 - a couple of other things which I can't remember what they do now.

The UserControl instances are configured in Lua scripts, have a look at controls.lua and items.lua (they are hidden somewhere under the knights_data/server directory).

The responsibility of LocalDisplay::readControl is to look at the player's control inputs (keyboard, mouse etc) and work out which UserControl (if any) should be activated as a result.

The actual UserControl that LocalDisplay::readControl selects from are set up in two places:
- LocalDisplay::setAvailableControls is called by the game engine to notify it of which context-sensitive controls (such as opening a chest) are currently available.
- There is also a set of "standard_controls" (such as movement) that are always available.


Anyway, I guess that's some info about how the code works...


Note that the current Controller interface assumes there is only one fire button. An idea I had a long time ago was to have a "two fire button" system. The first button would be for "melee attack" (so swing your sword, axe or hammer) and the second would be "missile attack" (so either throw an axe, shoot a crossbow, or throw daggers depending on what the player has available). Maybe now is the time to look at implementing that...
23
Knights Discussion / Re: Linux issues
« Last post by Stephen on August 13, 2017, 02:09:11 PM »
That is indeed interesting. I'm not sure why the old version crashes -- maybe your boost library was built using the newer g++ and that caused an incompatibility somehow?

Oh well, I'm glad that you got it working at least.

Also, this means that there is no bug on my side, which is a good result :)
24
Knights Discussion / Re: Dagger hotkey
« Last post by d.healey on August 13, 2017, 12:36:24 PM »
Yeah that's fair enough. Well I don't mind having a tinker with it, it's been a long time since I worked in C++ though and never on a largish project like Knights so a few pointers are appreciated.

I can see there are a number of a keyboard controller files in the main folder - I guess this is where I should be looking?
25
Knights Discussion / Re: Linux issues
« Last post by d.healey on August 13, 2017, 11:53:51 AM »
g++ --version
Aha this is interesting my version is 4.8.5. I'll see if I can update it

Update: I uninstalled g++, updated my repos, reinstalled and got version 5.4.1. Did make clean, sudo make install, and now it works :)

Thanks for your patience and help.
26
Knights Discussion / Re: Dagger hotkey
« Last post by Stephen on August 13, 2017, 09:41:36 AM »
I guess, but the problem is, I don't really have much time to develop the game nowadays. I will fix any major bugs or crashes if they come up, but I'm not really adding new features at the moment.

I would like to get back into development at some point but right now I don't have a lot of spare time unfortunately.

In the meantime the game is open source so if anyone wants to have a go at adding new stuff then they are more than welcome to do so, and I will assist in whatever way I can.
27
Knights Discussion / Re: Linux issues
« Last post by Stephen on August 13, 2017, 09:30:49 AM »
g++ --version
28
Knights Discussion / Dagger hotkey
« Last post by d.healey on August 13, 2017, 01:31:27 AM »
If you take requests could we have a hot key for throwing daggers?
29
Knights Discussion / Re: Linux issues
« Last post by d.healey on August 12, 2017, 11:53:51 PM »
How do I check my compiler version?
30
Knights Discussion / Re: Linux issues
« Last post by Stephen on August 12, 2017, 10:27:34 PM »
Also, here is a screenshot from gdb of the disassembly of the RStream::Initialize function.

http://www.knightsgame.org.uk/disassembly.png

Dave's executable is on the left and mine is on the right.

I'm not sure why, but there are some differences... for example, my version reserves more stack space (0x58 bytes as opposed to 0x30) and mine is doing something with the %fs register which I don't quite understand.

I think most of the code that we're seeing here has actually been inlined from bfs::canonical so it is possible that Dave is picking up a rogue boost header file from somewhere. Alternatively, it might be some difference in compiler version or compiler flags perhaps?

It's a bit of a mystery at the moment!

My compiler version is g++ 5.4.0.
Pages: 1 2 [3] 4 5 ... 10