[RELEASED] [SUPPORT] Moore's RPG Template

Hi IlliciteS,

I think you’re on the ball with the changes to whether an item goes into the left or right hand. With a bit of debugging you will no doubt get it to do what you want. To debug it in the most easy way I like to enable the debug booleans in the blueprints or functions I’m interested in and do a play test, then examine the Output window. Then I pick a node within a function that I suspect needs modifying and toggle the breakpoint on that node. Once its stops on that breakpoint during a play test I then click the Step Over button and follow along with what’s its doing.

  • There are probably several ways to change the hand in which an item goes. You could modify the GetSlotTypeByItemForLeftClick and GetSlotTypeByItemForRightClick functions or you could modify the contents of the AllowedSlotTypesLookupDataTable which is referenced by those functions. If you examine the AllowedSlotTypesLookupDataTable you can see that for ItemType of Shield its got a row for each hand so that means it allows shields to get equipped into either hand.
  • If you remove the row from the datatable for Shield to go into the RightHand, then when in-game , if you press the right mouse button on a shield in the inventory it will do nothing, but if you click the left mouse button it will still make it become equipped into the left hand.
  • The slot that an item is equipped into is stored within the variables EquippedSlot and IsEquipped the CharactersItems array (of data type ItemStruct).
  • The ItemWidget contains an event called On Clicked (Button Item) on the Event Graph that handles left clicks. The function OnMouseButtonUp, which you’ll see in the functions area on the left hand side, handles right clicks.

To get dead NPCs to visually lose their equipped armour you could create a few new functions to handle this:

  • NPCs already have an inventory that is populated at begin play by the 2 functions AddSpecialItemsToNPC and GenerateInventory. You’ll see these in the Event Graph of BP_NPC_Master. You could modify one of these functions or create another function that focuses on adding equipped items to the NPC. Again the item’s EquippedSlot variable will need to be set to something other than Unset for these equipped items. The IsEquipped variable also needs to be set to true if the item is equipped.
  • If you choose to modify AddSpecialItemsToNPC, some of the items added by this functions could be equipped items. The items added to NPCs read from the NPCItemsDataTable. Maybe add a new column to it (to the NPCItemStruct) called EquippedSlot of data type EquipmentSlotTypesEnum and another called IsEquipped (boolean) and read these (use a Branch node or a Switch node) within the AddSpecialItemsToNPC function. If an item is equipped then you could call a new interface function within BP_NPC_Master that visually equips the item/static mesh/skeletal mesh.
  • Then when looting the NPC, the function called TakeHighlightedItem in ItemMainWidget makes a call to the interface function SetInventory (the target is a Container reference) where it passes in the modified Inventory of the NPC. You could call a new interface function that visually removes the armour or weapon from the NPC just before this call to SetInventory.

I hope this helps.