Skip to content

Commit

Permalink
implements flashing on healing units
Browse files Browse the repository at this point in the history
  • Loading branch information
CDVoidwalker authored and PunkPun committed Dec 31, 2023
1 parent d83a871 commit da638a4
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 4 deletions.
60 changes: 60 additions & 0 deletions OpenRA.Mods.Common/Warheads/FlashTargetsInRadiusWarhead.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion

using OpenRA.GameRules;
using OpenRA.Mods.Common.Effects;
using OpenRA.Primitives;
using OpenRA.Traits;

namespace OpenRA.Mods.Common.Warheads
{
[Desc("Trigger a flash effect on the targeted actor, or actors within a circle.")]
public class FlashTargetsInRadiusWarhead : Warhead
{
[Desc("The overlay color to display when ActorFlashType is Overlay.")]
public readonly Color ActorFlashOverlayColor = Color.White;

[Desc("The overlay transparency to display when ActorFlashType is Overlay.")]
public readonly float ActorFlashOverlayAlpha = 0.5f;

[Desc("The tint to apply when ActorFlashType is Tint.")]
public readonly float3 ActorFlashTint = new(1.4f, 1.4f, 1.4f);

[Desc("Number of times to flash actors.")]
public readonly int ActorFlashCount = 2;

[Desc("Number of ticks between actor flashes.")]
public readonly int ActorFlashInterval = 2;

[Desc("Radius of an area at which effect will be applied. If left default effect applies only to target actor.")]
public readonly WDist Radius = new(0);

[Desc("Controls the way damage is calculated. Possible values are 'HitShape', 'ClosestTargetablePosition' and 'CenterPosition'.")]
public readonly DamageCalculationType DamageCalculationType = DamageCalculationType.HitShape;

public override void DoImpact(in Target target, WarheadArgs args)
{
var targetActor = target.Actor;
var firedBy = args.SourceActor;
var victims = Radius == WDist.Zero && targetActor != null ? new Actor[] { targetActor } : firedBy.World.FindActorsInCircle(target.CenterPosition, Radius);

foreach (var victim in victims)
{
if (!IsValidAgainst(victim, firedBy))
continue;

victim.World.AddFrameEndTask(w => w.Add(new FlashTarget(
victim, ActorFlashOverlayColor, ActorFlashOverlayAlpha,
ActorFlashCount, ActorFlashInterval)));
}
}
}
}
10 changes: 8 additions & 2 deletions mods/ra/weapons/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ Heal:
ValidTargets: Heal
Projectile: Bullet
Speed: 1c682
Warhead@1Dam: SpreadDamage
Warhead@1Eff: FlashTargetsInRadius
Radius: 1065
ValidRelationships: Ally
ValidTargets: Heal
Warhead@2Dam: SpreadDamage
Spread: 213
Damage: -5000
ValidRelationships: Ally
Expand All @@ -139,7 +143,9 @@ Repair:
Inherits: Heal
Report: fixit1.aud
ValidTargets: Repair
Warhead@1Dam: SpreadDamage
Warhead@1Eff: FlashTargetsInRadius
ValidTargets: Repair
Warhead@2Dam: SpreadDamage
Damage: -2000
ValidTargets: Repair

Expand Down
10 changes: 8 additions & 2 deletions mods/ts/weapons/healweapons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
ValidTargets: Heal
TargetActorCenter: true
Projectile: InstantHit
Warhead@1Dam: TargetDamage
Warhead@1Eff: FlashTargetsInRadius
ValidTargets: Heal
ValidRelationships: Ally
Warhead@2Dam: TargetDamage
DebugOverlayColor: 00FF00
Damage: -5000
ValidTargets: Heal
ValidRelationships: Ally

Heal:
Inherits: ^HealWeapon
Expand All @@ -18,5 +22,7 @@ Repair:
Range: 1c819
Report: repair11.aud
ValidTargets: Repair
Warhead@1Dam: TargetDamage
Warhead@1Eff: FlashTargetsInRadius
ValidTargets: Repair
Warhead@2Dam: TargetDamage
ValidTargets: Repair

0 comments on commit da638a4

Please sign in to comment.