Object / NPC interaction based on player stats?

I posted this on the other UE4 forum and wanted to see if there were any alternative solutions that people have used.

I’m creating a small single player RPG that is more exploration than combat. There are many items and NPC characters in the game that the player meets and interacts with. Many of these interactions give options based on the player’s current stats.

So on interaction a dialog pops up offering different options (I’ve got this part to work). Then, as an example, if the player selects option A, but his health is below a minimum level, it will warn them they can’t do A. If they choose option B, 30% is added to their current mana score and a player animation is triggered.

So I need the interactions to have access to the player stats. They are currently created on the thirdpersonplayer but I’m wondering if it would be better to store them elsewhere (or a continuously updating copy of them that objects/actors can access)? How do other people get around this?

Consider linking the other forum before someone jumps in to give you the exact same answer, suggesting using a blueprint interface, for example. Ehm. :wink:

Good point! I’d like to see what different methods people use for this, as I’m guessing it’s fairly common pratice in RPGs.

Interface method: Interaction based on player stats? - UI - Unreal Engine Forums

And while you wait, you can check the non-green answer at the bottom here:

Blueprint Interfaces + Inheritance - so exactly the scenario you’ve described above. Lots of examples, animations, and a project download to test it out.

Good luck!

You dont need interfaces, i think that they are a misconception of its authentic use.
The abuse of interfaces that you see everywhere is incredible, for things that are solved by having a minimally thought inheritance.

You only need a itemBase where keep a reference of the player stats when the game start.
Then all items can inherit from that base and all items will have direct access to the player’s stats.
The player will also be able to interact with all the items without having to have duplicate code in each item

Also widgets have inheritance, so you can also have an ItemWigetBase with the logic you need.

Thank you both. I’m still learning my way around UE4, so it’s very useful seeing different methods of doing something, as I learn a lot by experimenting that way.

Everynone, the interface option worked to a point, but wouldn’t let me connect the Query to Get Pawn. Although I’ll continue playing around with it, as it’s likely something else that I’ve set up incorrectly.

DomusLudus, I’ll check out itemBase as another option. When I first started out, I was considering rehashing something like the quest system, and having an object run an automatically resetting ‘quest’ and go through dialog and dish out a specific set of ‘buffs/debuffs’ to the player that trigger animations for that specific ‘buff/debuff’. But I’m probably going down the wrong path there!

This is a basic example of how I do it, this method is very simple and leaves the player character completely isolated.
First we create an input and make it call a even dispacher, we also put the events of buff and debuff

We create a master item, we add a trigger and we bind and unbind when it is inside the trigger
When the player enters the trigger we save its reference in a variable. (cast is 200% fundamental)
We create all the necessary buff events, as we have a reference to the character, we can call any event of the character.
Events could also be created, to send sounds, animations and effects all encapsulated in the item.
We also create a Use function that will be used by your children.

Now we can create all kinds of childs items and call base item functions or do completely different behaviors, such as doors, toilet handles, locks, chests, etc.

You can do exactly the same in a base npc character and create npc children as soldiers or merchants, walkers

I forgot the last thing, as the itemBase has the player’s reference, childs can ask any stat before performing the action.