NPC as instigator does no damage

Summary

Using this script for NPC’s if you have the NPC as the instigator the npc will not do any damage

OnBegin< override>()< suspends>:void=

    if: 
        NPCAgent := GetAgent[]
        NPCChar := NPCAgent.GetFortCharacter[]
        
        #Allows us to tell npcs to go to different place like the pathfinding service in roblox
        NPCNav := NPCChar.GetNavigatable[]

        #Control where npc is looking
        NPCFocus := NPCChar.GetFocusInterface[]

        #Control the npc's animations
        NPCAnim := NPCChar.GetPlayAnimationController[]
        DamageArgs := damage_args{Instigator := option{NPCChar}, Source := option{NPCChar}, Amount := NPCDamage}

    then:     
        loop:
            Sleep(0.1)
            if (NewTarget := FindNearestTargetFromPos[NPCChar], NewAgent := NewTarget.GetAgent[]):
                spawn{NPCFocus.MaintainFocus(NewAgent)}
                NavTarget := MakeNavigationTarget(NewAgent)
                GoToTarget(NPCChar, NavTarget)
                DistanceDifference := Distance(NPCChar.GetTransform().Translation, NewTarget.GetTransform().Translation)
	    #Set to 500.0 for testing purposes
                if (DistanceDifference < 500.0):
                    NewTarget.Damage(DamageArgs) #34.30 Did not fix
            Sleep(1.0)

GoToTarget(NPC : fort_character, NavTarget : navigation_target)<suspends>:void=
    race:
        Sleep(5.0) 
        if(NPCNav := NPC.GetNavigatable[], NPCAnim := NPC.GetPlayAnimationController[]):
            NPCNav.NavigateTo(NavTarget, ?MovementType := movement_types.Running, ?ReachRadius := 50.0)
            Print("Reached NavTarget")
            NPCAnim.Play(Attack1)
            Sleep(DamageDelay)
    Print("Broke Race")

FindNearestTargetFromPos(FortChar : fort_character)< decides>< transacts> : fort_character =
    var MaybeTarget : ?fort_character = false
    for(Player : GetGlobalPlayspace().GetPlayers(), FC := Player.Player.GetFortCharacter[]):
        DistanceDifference := Distance(FortChar.GetTransform().Translation, FC.GetTransform().Translation)
        if (DistanceDifference < CheckTargetRange and not FC = FortChar):
            set MaybeTarget = option{FC}
    return MaybeTarget?

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

create a NPC_Behavior script, create damage_args to set NPC as the instigator/source, have the NPC damage the player, put behavior script inside a NPC spawner, load in and start game

Expected Result

NPC should damage the player

Observed Result

NPC does not do any damage

Platform(s)

PC

Additional Notes

If you damage the player without an instigator then it counts as self damage and since a lot of maps with NPCs have damage amplifiers the player gets hit with the multiplier. Ex. NPC set to do 10 damage but player has a 4x multiplier if NPC is not the instigator the player will take 40 damage

Thank you for the report @BenPen the team will be working on this.

1 Like

Hello, I just tested your code in UEFN 36.30, and it was working as expected; the NPC was damaging the player.
Is there anything specific that I should test?
Thanks!

FORT-941366’s status has changed to ‘Ready for QA’. A member of the QA department is investigating the issue.

Hello @FrozenInMTL_Epic,
I hope you are having a blessed day and thank you for taking my report seriously!

Have you tested it with a fully custom NPC? I have provided a video at the end of this response, it is my NPC not doing damage when the NPC fort character is passed in as the damage_args instigator.

I show how it does not do damage and that the function is running with the print statement “Damaging From deflect damage” and it should do damage as this is the line that is running. Here is the function (CPlayer being a custom player).

CheckDeflectDamage(CPlayer : c_player, NPC : fort_character, NPCDamage : float):void=
Rand := GetRandomInt(1,100)
if:
CPlayer.PlayerData.RebirthSkills.DeflectChance <> 0
Rand <= CPlayer.PlayerData.RebirthSkills.DeflectChance
then:
#Print(“Ran Deflect {NPCDamage}”)
NPC.Damage(damage_args{ Instigator := option{CPlayer.Player.GetInstigator()}, Amount := ReturnDamageAmnt(NPCDamage, CPlayer)})
#Print(“NPC HP = {NPC.GetHealth()}”)
GetGlobalPlayspace().SFX_Devices.DeflectSFX.Play(CPlayer.Player)
spawn. SpawnVFX(GetGlobalPlayspace().VFX_Devices.DeflectVFX, GetPlayerForward(NPC, 100.0), 1.0)
else:
if(NewTarget := CPlayer.Player.GetFortCharacter):
Print(“{ReturnDamageAmnt(NPCDamage, CPlayer)}, {(CPlayer.PlayerData.Damage * CPlayer.PlayerData.PetBuff * CPlayer.PlayerData.RebirthBuff) * ReturnDamageAmnt(NPCDamage, CPlayer)}”)
Print(“Damaging From deflect damage”)
NewTarget.Damage(damage_args{ Instigator := option{NPC}, Amount := NPCDamage})

I then show the npc is all linked up showing its verse behavior script, its blueprint and its animation controller.

The current workaround function to do damage I am using is the above deflect damage function but instead of using NewTarget.Damage(damage_args{ Instigator := option{NPC}, Amount := NPCDamage}) I am using:

NewTarget.Damage(ReturnDamageAmnt(NPCDamage, CPlayer))

ReturnDamageAmnt(Dmg: float, Player : c_player):float=
X := (Dmg/(Player.PlayerData.Damage * Player.PlayerData.PetBuff * Player.PlayerData.RebirthBuff))
return X

Side note ReturnDamageAmnt() is extremely unreliable as the PlayerData.Damage sometimes does not reflect the actual damage amplifier as I use 2 different damage values during a players combat so if they get hit the frame I change their damage they take around 10x more damage then they should

Please ensure you are using a custom NPC and let me know if you are still not encountering this issue, I tested with the code I sent you and it was not working for me with that code as well