Socketable Weapons

Today, I created a new model in Blender which will represent a collectible socket.  The model is basically a sphere with objects rotating around it.  The rotating objects were created with a circle, which was extruded out.  Then the edges for every other segment were removed.  Then I added four bones that point outwards from the center.  Next, I set the animation to 20 frames, and I rotated the armature half way at the end of the animation.  Since the model is symmetrical, I didn’t need to do a full 360 degree rotation.  Like the other models, I exported the animation frames and then used Gimp to touch up the images.

43 

Similar to the Weapon and Armor collectibles, I created a CollectableSocket class.  Also in the same way, I added a List of sockets that the player has collected in the Player class.  I added all of the Sockets to the EquipmentCatalog, and added methods for returning a socket and generating a random socket.  On the equipment screen, I now display the list of all sockets the player has collected.

I realized that my existing collectibles had 30 frames in the animation.  This value was set as a constant in my collectible class, so I removed the const declaration and changed the variable to protected.  In the constructor of the CollectibleSocket class, I set the number of frames in the animation to 20.  This was a fairly simplistic change, which would had been much more painful if I hadn’t used good object oriented programming style.

screen058 

The Armor and Weapon classes have been updated to include a List of Sockets and an integer which represents the maximum number of sockets for that item.  To equip a socket, for now I have made it so that pressing the action button (X) will set a boolean to go into select socket mode.  This may need to be extracted into another screen later.  This sets the select socket menu to active.  Pressing the confirm button while in select socket mode will add the selected socket to the socket list of the currently selected weapon.  Currently, no checking is done to determine if the socket is of the right type (body location or gun).

When in socket selection mode, pressing the confirm (A) button will add the socket at the index of the socket menu to the player’s weapon at the index of the weapon menu.  Again as with the weapon menu, I am assuming that the socket menu is aligned with the player’s acquired sockets.  I went ahead and added another property to the Socket class, which is a code string.  This code will used when displaying the socket on a weapon or armor, since printing the name for each socket on the weapon would take up too much space.  For now, I am just listing the socket codes to the right of each weapon, or “X” if the socket location is empty.  Pressing the cancel button (B) will switch the sockect selection flag back to false, otherwise the player will always be in socket selection mode.

screen060

In the player class, I wrote a method that returns if a socket is active.  It takes a socket ID as a parameter, and returns true if it is equipped on a weapon.  In the near future, I will expand this to armor as well.  I also updated all of the code in the Player class which checks for sockets in the EquppedSocket class to use the socket active method.  Now the EquippedSocket class is obsolete, so I went ahead and removed it from the game.

One additional change is that I changed the initial amount of health the player receives to 60 points, which is the same as three bars.  I found that the original amount was way too much, so lowering it should make the game more of a challenge.