Hello everyone!
I want to do reverse damage if you hit your teammate, but so that your teammate doesn’t take damage.
I found something in LyraDamageExecution.cpp , but it doesn’t works.
I try change HitActor, if i hit my teammate, but my teammate still gets damage and damage it’s not reversed to me.
But I did find something else interesting.
Your team member likely has a different team id, you can debug to verify:
TeamSubsystem->CanCauseDamage(EffectCauser, HitActor)
That last line you refer to will apply those attributes against the target character. This execution is targeting the hit character so their ability system and attributes.
Open GA_Weapon_Fire and you’ll see where the info for the execution comes from:
Okay, didn’t quite understand the reverse you mentioned. You could change the GA_Weapon_Fire, before applying the GameplayEffect check the targets team, if on the same team then change the targetdata to the current player.
You might have to tweak the logic around TeamSubsystem->CanCauseDamage in that case.
Given it some more thought, you could leave the ApplyGamplayEffectToTarget as is and after it fires in the GA add a check as to whether you are on the same team then fire off another GE but with the current character as the target. You might want to then create a new Execution for TeamDamage and use that with whatever changes it might need.
Even better would be to check the team first then do a branch to the existing ApplyGamplayEffectToTarget and have the else run the TeamDamage execution, since you won’t need to have both GE run.