Turn on friendly fire in Lyra

I just downloaded Lyra and made a weapon but, I’ve been trying to turn off the protection for friendly fire. I want friendly fire to be active.

I’ve been looking through the blueprints and C++ files and nothing I change seems to allow for friendly fire. Can someone tell me what line to change or what blueprint this team comparision for friendly fire is happening and preventing it? Is there a tutorial? I couldn’t find anything in the documentation either. Where can I disable this check?

Also, if these are the correct files, is it possible I’m using a wrong compiler? I’m currently using VSCode as I tried it with unreal 4 and it worked quite well.

Hello, I recently came across the same problem. But I found the right place to handle friendly fire: the solution was not to search for friendly fire in particular, but rather for team-handling stuff.
Open the C++ file “LyraDamageExecution.cpp” and go to line “103”. There you just need to change the last value, which should be “0.0” to “1.0”, right before the “;” at the end of the line.
Recompile and then you should have friendly fire (at least that worked for me). Good luck!

3 Likes

The team check happens in the Gameplay ability blueprints. It stores an array of hit actors and checks for their team there.

1 Like

Thank you for this quick fix. Very helpful. But I noticed this is affecting all experiences and I wanted to make friendly fire experience dependent. So, can you share how to expose this variable to blueprints? I was thinking about creating a Custom Application Requirement, but I haven’t found clear instructions about how to actually do it. Maybe there is an easier way. GitHub - tranek/GASDocumentation: My understanding of Unreal Engine 4's GameplayAbilitySystem plugin with a simple multiplayer sample project.

Any help is appreciated.

Hi there, can you please give me an example? I found this check only at GA_Grenade (hit event).
Thanks.

Yes that’s the one. You can add that anywhere using the same setup in blueprints. I have that check in my abilities and just change the logic depending on the ability. What exactly are you trying to do otherwise?

Hi there, once I activated friendly fire using that small code, this custom damage calculation is affecting all experiences. I wanted to create a logic switching for certain types of missions or even specific damage sources, damage can be registered within same team, for instance explosions from grenades, abilities, vehicles etc, while keeping weapons with normal damage execution, or vice versa. But I wanted to keep control of this settings via blueprint. Another way that would work for me is adding a gameplay tag to the Ability bp and set friend fire ON/OFF.

Any ideas?

I feel like you are overcomplicating it, but you answered your own question. Use a tag.

The tag is something that is not clear to me for this particular case. Imagine I have only 2 teams and two scenarios:
Player Instigator - Tag Team 1
Player Target - Tag Team 1

Player Instigator - Tag Team 2
Player Target - Tag Team 2

How a gameplay tag setup inside a GA should look like to switching friendly fire on/off?

Another examples:
For playing Elimination, friendly fire is ON. Control Point is OFF
Heavy explosions: Friendly fire is ON. Weapons are OFF

Something like that

1 Like

Just as an update @Balive @BattLe_SCVs, I figured out a way to selectively turn friendly-fire on and off using tags. After editing the LyraDamageExecution.cpp line 103 (thanks @hevn3), I added tags Enemy and Player based off team IDs (for testing only, my prototype will have team ID ignored). To disable friendly-fire for Pistol and Rifle, GE_Damage_Pistol and GE_Damage_RifleAuto, in the Calculation Modifiers section, I added two array elements, one for enemy as source, and the second having player as source. That said, I kept GE_Damage_Shotgun with default calculation modifier, thus with friendly fire enabled. This logic can be expanded for certain experiences, level areas, etc. using tags (ignore/require) adding as much array elements as we see fit. Now I can finally get back to work with my prototype as I have the solution for friendly-fire, give abilities in runtime, and saving character settings.

This solution was a follow up to my previous comment:

Awesome! I still just use the Lyra Team Subsystem in all of my abilities. It allows me to add booleans to control team/enemy damage.

Interesting, how do you setup this logic?

Look at the B_Grenade file

Hi, thanks for the info. I know what you mean, you are talking about the hit event, right? I needed something more customizable with tags.

1 Like

Ah! Sorry then!

1 Like

no worries, keep up the good work.

1 Like

I think, correct way is the add a replicated boolean (bAllowFriendlyFire) into LyraGameState class. Than you can check this variable in CanCauseDamage function in LyraTeamSubsystem class. Get game state and check this variable in the line 343. By this way you can define different FriendlyFire modes for different game modes.