How to get information on weapon types, etc. in the UEFN

I am considering creating different events for each weapon that the player uses.

(Executing event A when using weapon A, executing event B when using weapon B, and so on.)

(I would like to execute events that deal damage, etc., to change the strength of the weapon.)

I am struggling to obtain the type of the currently equipped weapon, as players can possess multiple weapons.

Is it possible to use UEFN or similar methods to retrieve information about the weapon currently equipped by the player?

Implementation:

  • As one implementation method, I am considering using an ā€œifā€ statement based on the value of DamageAmount in the DamageEvent to infer the weapon being used from the damage amount.
  • For example, is it possible to obtain information about the weapon from the arguments of DamageEvent? It would be best if I could obtain the weaponā€™s class, but at the very least, being able to get information such as the weaponā€™s rarity or the type of ammunition used would allow me to predict the used weapon and write the desired processing.
  • As another implementation method, is it possible to change the damage amount of the corresponding weapon by registering the weapon in a class manager?

Are there any features that allow me to write code to change the damage amount of a weapon, using other implementation methods?

Really good question!

First off, Iā€™m slightly unsure about the logic that you actually want, but Iā€™ll give you some base ideas that can hopefully get you off the ground.

The key to this is the conditional button and more specifically the IsHoldingItem() function in verse (to check what weapon is equipped). To create a basic example, what I did was to create a sentry in my world, check for the EliminatedEvent, and then checked what item the player is currently holding with the conditional button (which of course needs to be configured first).

Then, I wrote some verse code to check if the sentry had died:

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

register_weapon := class(creative_device):
    @editable AR_Conditional : conditional_button_device = conditional_button_device { }
    @editable SentryTest : sentry_device = sentry_device { }

    OnBegin<override>()<suspends>:void=
        SentryTest.EliminatedEvent.Subscribe(SentryElim)

    SentryElim(MaybeAgent : ?agent):void=
        if (Player := player[MaybeAgent?]):
            if (AR_Conditional.IsHoldingItem[Player]):
                Print("Player is currently holding the AR!")
                # magic

And indeed, it printed. Now, you probably also want it to work with players, which is a pretty similar concept:

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }

register_weapon := class(creative_device):
    @editable AR_Conditional : conditional_button_device = conditional_button_device { }
    @editable SentryTest : sentry_device = sentry_device { }

    OnBegin<override>()<suspends>:void=
        Players := GetPlayspace().GetPlayers();

        for (Player : Players, Char := Player.GetFortCharacter[]):
            Char.DamagedEvent().Subscribe(OnPlayerHit)

    OnPlayerHit(Result : damage_result):void=
        if (InstigatorObj := Result.Instigator?, InstigatorAgent := agent[InstigatorObj]):
                if (AR_Conditional.IsHoldingItem[InstigatorAgent]):
                    Print("Player is currently holding the AR!")
                    # magic

Note: I used DamagedEvent here, but not in the sentry, simply because it didnā€™t immediately seem available in the sentry, and Iā€™m still unsure of your desired outcome.

Extra note: I donā€™t know if it actually works, I havenā€™t tested with other players lol.

Sadly, I donā€™t think itā€™s possible to check for the weapon rarity in verse yet, as Epic havenā€™t implemented the weapon API, but hopefully itā€™ll be available in the near future :slight_smile:

1 Like