Summary
NPC’s do not do damage to Fort Character/Player if they are listed as the instigator in damage_args
Please select what you are reporting on:
Verse
What Type of Bug are you experiencing?
Verse
Steps to Reproduce
slime_behavior_basic := class(npc_behavior):
@editable var Attack1 : animation_sequence = Animations.Green_Slime_Attack_Anim
@editable NPCDamage : float = 10.0
@editable var CheckTargetRange : float = 1000.0
@editable var AttackDistance : float = 200.0
var NPCEntity : entity = entity{}
# This function runs when the NPC is spawned in the world and ready to follow a behavior.
OnBegin< override>()< suspends>:void=
# TODO: Replace this with your code
Playspace := GetGlobalPlayspace()
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[]
then:
loop:
Sleep(0.1)
if (not NPCChar.IsActive[]):
break
if (NewTarget := FindNearestTargetFromPos[NPCChar], NewAgent := NewTarget.GetAgent[]):
NavTarget := MakeNavigationTarget(NewAgent)
DistanceDifference := Distance(NPCChar.GetTransform().Translation, NewTarget.GetTransform().Translation)
TeamCollection := FortPlayspace.GetTeamCollection()
if ( TeamAttitude := TeamCollection.GetTeamAttitude[NewAgent, NPCAgent]):
if(TeamAttitude = team_attitude.Hostile):
Print("is Hostile")
if (DistanceDifference < AttackDistance):
DamageArgs := damage_args{Instigator := option{NPCChar}, Source := option{NPCChar}, Amount := NPCDamage}
NewTarget.Damage(DamageArgs)
Sleep(0.5)
Expected Result
Damage the player the npc is targeting
Observed Result
No damage occurs
Platform(s)
windows
Island Code
5741-7998-5590
Video
Additional Notes
If you remove the Instigiator it will damage the player. The issue is I use the damage amplifier device for players and the amount of damage taken is based off of the damage amplifier if I cannot make the NPC the instigator. So currently if I have a 4x amplifier applied to a player and the NPC damage is 10 the NPC will do 40 damage in the fort_character.Damage() function. This is why I would like to pass in the Instigator as the NPC so the damage amplifier is ignored. Thank you!