Wednesday, 12 June 2013

Evolution of the code #13

Companion
First companion implemented! As expected, the AI class is a subclass of the standard NPC AI, except that it helps you in combat and follows you around when you command him. To make things more interesting, I also added him a conversation file where you can tell him whether to follow you or not, or to use his best weapon or holster it. So far he is really helpful in combat and for the upcoming demo I doubt it needs any improvements.


Menu and HUD improvements
Remember that small menu that popped up when we wanted to do an action on an object? Well its here and currently has the first interaction buttons. The only difference is that it activates when right-clicking on an object (similar to VB) rather then when holding the left button longer. A clock has been added on the HUD so the player can tell the game time as it passes (I used it to tell whenever the player regeneration rate had passed or not).


Two new controls have been added to the base UI controls. The CommandButton is a simple button that triggers a console command. The PlayerPropertyDisplay class is used, as suggested by the name, to display and update any player property on the HUD. This can be either the Name, Health, WorldClock, the item he currently has in the inventory, etc. I found these controls necessary as I felt the need to add windows or controls on the HUD without changing the actual code in the executable.

Skills and SPECIAL
Skills have been implemented and they are partially working. I say partially because the code to apply a certain skill has not been implemented yet. It is surprisingly easy to add a new skill or delete the existing ones without any changes to the code.

I am planning to add every engine calculation that was done in fallout in lua files, for maximum flexibility. This would mean making changes to the game's basic calculations only in script files. Lua files have been added to player classes which contain a few formulas.

For now, a skill is firstly defined by its button name and the function it does is defined in the player lua file by the same name.



Basically, in order to add a skill the steps would be: add a button to the skill panel containing its name (note that the text formatting can be a problem and may cause errors), go to the player lua file and define a new function which is named as the button in the first step. This will make the button trigger the function in the lua file when needed, provided the names are the same. This may be a problem with localizations later but I'm planning to replace all of these with command buttons so that the actual names will no longer be relevant.