Skip to content

Commit

Permalink
Merge remote-tracking branch 'darkademic/dev' into WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Inq8 committed Jan 7, 2024
2 parents a108756 + b9a9dd7 commit 4a68bb5
Show file tree
Hide file tree
Showing 91 changed files with 2,656 additions and 551 deletions.
14 changes: 8 additions & 6 deletions OpenRA.Mods.CA/Activities/CruiseMissileFly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ public class CruiseMissileFly : Activity
readonly Target target;
WDist maxAltitude;
WDist maxTargetMovement;
bool trackingLost;
bool trackTarget;
bool trackingActive;
int launchAngleDegrees;
double launchAngleRad;

public CruiseMissileFly(Actor self, Target t, CruiseMissile cm, WDist maxAltitude, WDist maxTargetMovement)
public CruiseMissileFly(Actor self, Target t, CruiseMissile cm, WDist maxAltitude, WDist maxTargetMovement, bool trackTarget)
{
this.cm = cm;
launchPos = currentPos = self.CenterPosition;
Expand All @@ -42,9 +43,10 @@ public CruiseMissileFly(Actor self, Target t, CruiseMissile cm, WDist maxAltitud
length = Math.Max((targetPos - launchPos).Length / this.cm.Info.Speed, 1);
facing = (targetPos - launchPos).Yaw;
cm.Facing = GetEffectiveFacing();
trackingLost = false;
trackingActive = !trackTarget;
this.maxAltitude = maxAltitude;
this.maxTargetMovement = maxTargetMovement;
this.trackTarget = trackTarget;
launchAngleDegrees = (int)(cm.Info.LaunchAngle.Angle / (1024f / 360f));
launchAngleRad = Math.PI * launchAngleDegrees / 180.0;
cm.SetState(CruiseMissileState.Ascending);
Expand Down Expand Up @@ -82,10 +84,10 @@ public void FlyToward(Actor self, CruiseMissile cm)

public override bool Tick(Actor self)
{
if (!trackingLost && maxTargetMovement > WDist.Zero && target.Type == TargetType.Actor && (initTargetPos - target.CenterPosition).Length > maxTargetMovement.Length)
trackingLost = true;
if (trackingActive && maxTargetMovement > WDist.Zero && target.Type == TargetType.Actor && (initTargetPos - target.CenterPosition).Length > maxTargetMovement.Length)
trackingActive = false;

if (!trackingLost && ((target.Type == TargetType.Actor && !target.Actor.IsDead) || (target.Type == TargetType.FrozenActor && target.FrozenActor != null)))
if (trackingActive && ((target.Type == TargetType.Actor && !target.Actor.IsDead) || (target.Type == TargetType.FrozenActor && target.FrozenActor != null)))
targetPos = target.CenterPosition;

var d = targetPos - self.CenterPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ float ISelectionBar.GetValue()
: (float)ticks / Info.DeployedTicks;
}

bool ISelectionBar.DisplayWhenEmpty { get { return deployState == TimedDeployState.Ready ? Info.ShowSelectionBarWhenFull : Info.ShowSelectionBarWhenEmpty; } }
bool ISelectionBar.DisplayWhenEmpty { get { return Info.ShowSelectionBar ? (deployState == TimedDeployState.Ready ? Info.ShowSelectionBarWhenFull : Info.ShowSelectionBarWhenEmpty) : false; } }

Color ISelectionBar.GetColor() { return deployState == TimedDeployState.Charging ? Info.ChargingColor : Info.DischargingColor; }
}
Expand Down
7 changes: 5 additions & 2 deletions OpenRA.Mods.CA/Traits/CruiseMissile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class CruiseMissileInfo : MissileBaseInfo
[Desc("Missile will cruise straight at this altitude.")]
public readonly WDist MaxAltitude = WDist.Zero;

[Desc("If a mobile target moves further than this beyond its initial location, the missile will lose tracking.")]
[Desc("If a mobile target moves further than this beyond its initial location, the missile will lose tracking. Zero means infinite tracking.")]
public readonly WDist MaxTargetMovement = WDist.Zero;

[GrantedConditionReference]
Expand All @@ -38,6 +38,9 @@ public class CruiseMissileInfo : MissileBaseInfo
[Desc("The condition to grant when the missile is descending.")]
public readonly string DescendingCondition = null;

[Desc("If true, missile will track target.")]
public readonly bool TrackTarget = true;

public override object Create(ActorInitializer init) { return new CruiseMissile(init, this); }
}

Expand Down Expand Up @@ -85,7 +88,7 @@ public override void SetTarget(Target target)

protected override Activity GetActivity(Actor self, Target target)
{
return new CruiseMissileFly(self, target, this, cruiseMissileInfo.MaxAltitude, cruiseMissileInfo.MaxTargetMovement);
return new CruiseMissileFly(self, target, this, cruiseMissileInfo.MaxAltitude, cruiseMissileInfo.MaxTargetMovement, cruiseMissileInfo.TrackTarget);
}
}
}
26 changes: 20 additions & 6 deletions OpenRA.Mods.CA/Traits/Infiltration/InfiltrateForSupportPowerCA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
*/
#endregion

using System;
using OpenRA.Mods.Common;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;

namespace OpenRA.Mods.CA.Traits
{
[Desc("CA version makes the spawned proxy actor inherit the faction of the infiltrated actor.")]
[Desc("CA version allows the spawned proxy actor to inherit the faction of the infiltrated actor,",
"or to be owned by the target.")]
class InfiltrateForSupportPowerCAInfo : TraitInfo
{
[ActorReference]
Expand All @@ -33,6 +35,12 @@ class InfiltrateForSupportPowerCAInfo : TraitInfo
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;

[Desc("If true, the spawned actor will use the target's faction.")]
public readonly bool UseTargetFaction = false;

[Desc("If true, the spawned actor will be owned by the target.")]
public readonly bool UseTargetOwner = false;

public override object Create(ActorInitializer init) { return new InfiltrateForSupportPowerCA(this); }
}

Expand All @@ -56,11 +64,17 @@ void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet<Target
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);

infiltrator.World.AddFrameEndTask(w => w.CreateActor(info.Proxy, new TypeDictionary
{
new OwnerInit(infiltrator.Owner),
new FactionInit(self.Owner.Faction.InternalName)
}));
var td = new TypeDictionary();

if (info.UseTargetFaction)
td.Add(new FactionInit(self.Owner.Faction.InternalName));

if (info.UseTargetOwner)
td.Add(new OwnerInit(self.Owner));
else
td.Add(new OwnerInit(infiltrator.Owner));

infiltrator.World.AddFrameEndTask(w => w.CreateActor(info.Proxy, td));
}
}
}
93 changes: 93 additions & 0 deletions OpenRA.Mods.CA/Traits/Infiltration/InfiltrateForTimedCondition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#region Copyright & License Information
/**
* Copyright (c) The OpenRA Combined Arms Developers (see CREDITS).
* This file is part of OpenRA Combined Arms, 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 System;
using OpenRA.Mods.Common;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;

namespace OpenRA.Mods.CA.Traits
{
[Desc("The actor gains a timed condition when infiltrated.")]
class InfiltrateForTimedConditionInfo : TraitInfo
{
[GrantedConditionReference]
[FieldLoader.Require]
public readonly string Condition = null;

[Desc("Condition duration. Use zero for infinite duration.")]
public readonly int Duration = 0;

[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default(BitSet<TargetableType>);

[NotificationReference("Speech")]
[Desc("Sound the victim will hear when technology gets stolen.")]
public readonly string InfiltratedNotification = null;

[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;

public readonly bool ShowSelectionBar = false;
public readonly Color SelectionBarColor = Color.Red;

public override object Create(ActorInitializer init) { return new InfiltrateForTimedCondition(this); }
}

class InfiltrateForTimedCondition : INotifyInfiltrated, ITick, ISelectionBar
{
readonly InfiltrateForTimedConditionInfo info;
int conditionToken = Actor.InvalidConditionToken;
int ticks;

public InfiltrateForTimedCondition(InfiltrateForTimedConditionInfo info)
{
this.info = info;
}

void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet<TargetableType> types)
{
if (!info.Types.Overlaps(types))
return;

if (info.InfiltratedNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName);

if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);

ticks = info.Duration;
conditionToken = self.GrantCondition(info.Condition);
}

void ITick.Tick(Actor self)
{
if (conditionToken == Actor.InvalidConditionToken)
return;

if (--ticks < 0)
conditionToken = self.RevokeCondition(conditionToken);
}

float ISelectionBar.GetValue()
{
if (!info.ShowSelectionBar || ticks <= 0)
return 0f;

return (float)ticks / info.Duration;
}

bool ISelectionBar.DisplayWhenEmpty { get { return false; } }

Color ISelectionBar.GetColor() { return info.SelectionBarColor; }
}
}
33 changes: 26 additions & 7 deletions OpenRA.Mods.CA/Traits/Modifiers/WithPalettedOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,31 @@ public class WithPalettedOverlayInfo : ConditionalTraitInfo
[Desc("Palette to use when rendering the overlay")]
public readonly string Palette = "invuln";

public override object Create(ActorInitializer init) { return new WithPalettedOverlay(this); }
[Desc("Player relationships that see the overlay.")]
public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy;

public override object Create(ActorInitializer init) { return new WithPalettedOverlay(init.Self, this); }
}

public class WithPalettedOverlay : ConditionalTrait<WithPalettedOverlayInfo>, IRenderModifier
public class WithPalettedOverlay : ConditionalTrait<WithPalettedOverlayInfo>, IRenderModifier, INotifyOwnerChanged
{
public WithPalettedOverlay(WithPalettedOverlayInfo info)
: base(info) { }
bool validRelationship;

public WithPalettedOverlay(Actor self, WithPalettedOverlayInfo info)
: base(info)
{
Update(self);
}

IEnumerable<IRenderable> IRenderModifier.ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
{
if (IsTraitDisabled)
return r;

return ModifiedRender(self, wr, r);
return ModifiedRender(wr, r);
}

IEnumerable<IRenderable> ModifiedRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
IEnumerable<IRenderable> ModifiedRender(WorldRenderer wr, IEnumerable<IRenderable> r)
{
if (IsTraitDisabled)
yield break;
Expand All @@ -51,7 +59,7 @@ IEnumerable<IRenderable> ModifiedRender(Actor self, WorldRenderer wr, IEnumerabl
{
yield return a;

if (palette != null && !a.IsDecoration && a is IPalettedRenderable)
if (validRelationship && palette != null && !a.IsDecoration && a is IPalettedRenderable)
yield return ((IPalettedRenderable)a).WithPalette(palette)
.WithZOffset(a.ZOffset + 1)
.AsDecoration();
Expand All @@ -62,5 +70,16 @@ IEnumerable<Rectangle> IRenderModifier.ModifyScreenBounds(Actor self, WorldRende
{
return bounds;
}

void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
{
Update(self);
}

void Update(Actor self)
{
var relationship = self.World.RenderPlayer != null ? self.Owner.RelationshipWith(self.World.RenderPlayer) : PlayerRelationship.None;
validRelationship = Info.ValidRelationships.HasRelationship(relationship);
}
}
}
12 changes: 8 additions & 4 deletions OpenRA.Mods.CA/Traits/ReloadAmmoPoolCA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ReloadAmmoPoolCAInfo : PausableConditionalTraitInfo
public readonly bool ShowSelectionBar = true;
public readonly Color SelectionBarColor = Color.FromArgb(128, 200, 255);

public override object Create(ActorInitializer init) { return new ReloadAmmoPoolCA(this); }
public override object Create(ActorInitializer init) { return new ReloadAmmoPoolCA(init.Self, this); }

public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
Expand All @@ -63,13 +63,17 @@ public class ReloadAmmoPoolCA : PausableConditionalTrait<ReloadAmmoPoolCAInfo>,
{
AmmoPool ammoPool;
IReloadAmmoModifier[] modifiers;
Actor self;

[Sync]
int remainingTicks;
int remainingDelay;

public ReloadAmmoPoolCA(ReloadAmmoPoolCAInfo info)
: base(info) { }
public ReloadAmmoPoolCA(Actor self, ReloadAmmoPoolCAInfo info)
: base(info)
{
this.self = self;
}

protected override void Created(Actor self)
{
Expand Down Expand Up @@ -137,7 +141,7 @@ protected virtual void Reload(Actor self, int reloadDelay, int reloadCount, stri

float ISelectionBar.GetValue()
{
if (!Info.ShowSelectionBar || remainingDelay > 0)
if (!Info.ShowSelectionBar || remainingDelay > 0 || !self.Owner.IsAlliedWith(self.World.RenderPlayer))
return 0;
var maxTicks = Util.ApplyPercentageModifiers(Info.Delay, modifiers.Select(m => m.GetReloadAmmoModifier()));
if (remainingTicks == maxTicks)
Expand Down
11 changes: 11 additions & 0 deletions OpenRA.Mods.CA/Warheads/SpawnActorWarhead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Mods.CA.Activities;
using OpenRA.Mods.Common;
using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Traits;
Expand Down Expand Up @@ -63,6 +64,9 @@ public class SpawnActorWarhead : WarheadAS, IRulesetLoaded<WeaponInfo>
[Desc("For non-positionable actors only, whether to avoid spawning on top of existing actors.")]
public readonly bool AvoidActors = false;

[Desc("For actors with facing, match the facing of the source (if the source also has a facing) .")]
public readonly bool MatchSourceFacing = false;

public readonly bool UsePlayerPalette = false;

public void RulesetLoaded(Ruleset rules, WeaponInfo info)
Expand Down Expand Up @@ -189,6 +193,13 @@ TypeDictionary CreateTypeDictionary(Actor firedBy, CPos targetCell)

td.Add(new LocationInit(targetCell));

if (MatchSourceFacing)
{
var facing = firedBy.TraitOrDefault<IFacing>();
if (facing != null)
td.Add(new FacingInit(facing.Facing));
}

return td;
}
}
Expand Down
Binary file added mods/ca/bits/acho.shp
Binary file not shown.
Binary file added mods/ca/bits/achoicon.shp
Binary file not shown.
Binary file added mods/ca/bits/audio/beag-fire1.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/beag-fire2.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/decoydespawn.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/decoyspawn.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/mantis-fire1.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/mantis-fire2.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/mcor-fire1.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/mcor-fire2.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/optics-disable.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/optics-enable.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/pitbull-fire1.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/pitbull-fire2.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/veilblast.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/vert-bomb1.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/vert-bombhit1.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/vert-bombhit2.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/viper-fire1.aud
Binary file not shown.
Binary file added mods/ca/bits/beag.shp
Binary file not shown.
Binary file added mods/ca/bits/beagicon.shp
Binary file not shown.
Binary file modified mods/ca/bits/cdog.shp
Binary file not shown.
Binary file modified mods/ca/bits/hacked.shp
Binary file not shown.
Binary file modified mods/ca/bits/ifvtur.shp
Binary file not shown.
Binary file added mods/ca/bits/mant.shp
Binary file not shown.
Binary file added mods/ca/bits/manticnh.shp
Binary file not shown.
Binary file added mods/ca/bits/mcor.shp
Binary file not shown.
Binary file added mods/ca/bits/mcoricnh.shp
Binary file not shown.
Binary file added mods/ca/bits/opticsactive.shp
Binary file not shown.
Binary file added mods/ca/bits/pbul.shp
Binary file not shown.
Binary file added mods/ca/bits/pbulicnh.shp
Binary file not shown.
Binary file added mods/ca/bits/pmak.shp
Binary file not shown.
Binary file added mods/ca/bits/pmakicon.shp
Binary file not shown.
Binary file added mods/ca/bits/reck.shp
Binary file not shown.
Binary file added mods/ca/bits/reckicon.shp
Binary file not shown.
Binary file added mods/ca/bits/redplasmatorp.shp
Binary file not shown.
Binary file added mods/ca/bits/shde.shp
Binary file not shown.
Binary file added mods/ca/bits/shdeicnh.shp
Binary file not shown.
Binary file added mods/ca/bits/upg-advopticsicon.shp
Binary file not shown.
Binary file added mods/ca/bits/upg-decoyicon.shp
Binary file not shown.
Binary file added mods/ca/bits/veilblast.shp
Binary file not shown.
Binary file added mods/ca/bits/vert.shp
Binary file not shown.
Binary file added mods/ca/bits/verticnh.shp
Binary file not shown.
Binary file added mods/ca/bits/vipr.shp
Binary file not shown.
Binary file added mods/ca/bits/vipricnh.shp
Binary file not shown.
Binary file modified mods/ca/maps/Calming_Lakes_CA.oramap
Binary file not shown.
Binary file modified mods/ca/maps/Utter_Darkness_CA.oramap
Binary file not shown.
10 changes: 5 additions & 5 deletions mods/ca/maps/ca01-crossrip/ca01.lua
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ WorldLoaded = function()
TeslaCoil3.Destroy()
HardOnlyV2.Destroy()
HardOnlyKatyusha.Destroy()
else
Ranger1.Destroy()
end

if Difficulty == "easy" then
Expand All @@ -239,8 +241,6 @@ WorldLoaded = function()
NonEasyHeavyTank3.Destroy()
NonEasyHeavyTank4.Destroy()
NonEasyMammoth1.Destroy()
else
Ranger1.Destroy()
end

Trigger.AfterDelay(1, function()
Expand Down Expand Up @@ -381,16 +381,16 @@ InitUSSR = function()
-- Eastern Halo drops
Trigger.AfterDelay(HaloDropStart[Difficulty], function()
local eastHaloDropEntryPaths = {
{ CPos.New(EastHaloDrop.Location.X + 35, EastHaloDrop.Location.Y - 25), EastHaloDrop.Location },
{ CPos.New(EastHaloDrop.Location.X + 35, EastHaloDrop.Location.Y - 25), EastHaloDropAlt.Location },
{ HaloSpawn1.Location, HaloLanding1.Location },
{ HaloSpawn2.Location, HaloLanding2.Location },
}
DoHaloDrop(eastHaloDropEntryPaths)
end)

-- Western Halo drops (hard only)
if Difficulty == "hard" then
Trigger.AfterDelay(HaloDropStart[Difficulty] + DateTime.Seconds(40), function()
local westHaloDropEntryPaths = { { CPos.New(WestHaloDrop.Location.X - 35, WestHaloDrop.Location.Y - 25), WestHaloDrop.Location } }
local westHaloDropEntryPaths = { { HaloSpawn3.Location, HaloLanding3.Location } }
DoHaloDrop(westHaloDropEntryPaths)
end)
end
Expand Down
Loading

0 comments on commit 4a68bb5

Please sign in to comment.