Blueprintable delegates with return values

Acren
Sat, 28 Mar 2015 03:34:09 +0000
Blueprint

Is it possible to declare delegates with return values that can be assigned in Blueprint?

I know you can have input only events with BlueprintAssignable, but as far as I know the delegates have to be multicast and thus can’t return anything.

For some context: I have a base class of type Item. Items have different levels, and have different stats depending on the level. For example, item level 1 may give +10 damage, item level 2 may give +20 damage. The scaling is calculated in a function on the specific item subclass which takes the level as a parameter and outputs a float, like “float calculateDamageBonus(int32 itemLevel)” only it’s in Blueprint. The items have descriptions generated from the stats that they give. It’s pretty easy for an item to format a string to describe the stats it gives at a certain level. However I want to describe upgrading between these levels, eg. at level 1 the item says “Gives +10 damage” but when given the option to upgrade from level 1 to 2, I want to be able to generate “Gives +[10 → 20] damage” so that the player can see which stats are being upgraded by how much.

I want Item subclasses to be able to call a helper function somewhere that takes a delegate (which refers to the stat calculator function on the item that takes an integer param and returns a float) as a parameter, and returns a string.
The helper function calls the delegate multiple times with different integers for different levels, and formats the resulting float values into a string such as “[10 → 20]” and returns that.

12 posts - 5 participants