Skip to content

Commit

Permalink
Merge remote-tracking branch 'darkademic/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Inq8 committed Sep 7, 2024
2 parents 9d2ac0a + 6c8c89c commit d0e0c32
Show file tree
Hide file tree
Showing 35 changed files with 404 additions and 272 deletions.
16 changes: 12 additions & 4 deletions OpenRA.Mods.CA/Traits/CloneProducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class CloneProducerInfo : TraitInfo
[Desc("List of actors that cannot be cloned.")]
public readonly string[] InvalidActors = Array.Empty<string>();

[Desc("Actors to use instead of specific source actors.")]
public readonly Dictionary<string, string> CloneActors = new Dictionary<string, string>();

[CursorReference]
[Desc("Cursor to display when selecting a clone source.")]
public readonly string Cursor = "chrono-target";
Expand Down Expand Up @@ -87,9 +90,13 @@ void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)

public void UnitProduced(Actor unit)
{
if (self.IsDead || Info.InvalidActors.Contains(unit.Info.Name))
var actorName = unit.Info.Name.ToLowerInvariant();

if (self.IsDead || Info.InvalidActors.Contains(actorName))
return;

var cloneActor = self.World.Map.Rules.Actors[Info.CloneActors.ContainsKey(actorName) ? Info.CloneActors[actorName] : actorName];

var sp = self.TraitsImplementing<Production>()
.FirstOrDefault(p => !p.IsTraitDisabled && !p.IsTraitPaused && p.Info.Produces.Where(p => Info.CloneType.Contains(p)).Any());

Expand All @@ -101,7 +108,7 @@ public void UnitProduced(Actor unit)
new FactionInit(sp.Faction)
};

sp.Produce(self, self.World.Map.Rules.Actors[unit.Info.Name.ToLowerInvariant()], sp.Info.Produces.First(), inits, 0);
sp.Produce(self, cloneActor, sp.Info.Produces.First(), inits, 0);
}
}

Expand All @@ -114,16 +121,17 @@ public void PrimaryUpdated()
private void SetSourceToPreferred()
{
var producer = self.World.ActorsWithTrait<CloneSource>()
.Where(a => !a.Actor.IsDead && a.Actor.Owner == self.Owner && a.Trait.ProductionTypes.Where(t => Info.Types.Contains(t)).Any())
.Where(a => !a.Actor.IsDead && a.Actor.IsInWorld && a.Actor.Owner == self.Owner && a.Trait.ProductionTypes.Where(t => Info.Types.Contains(t)).Any())
.OrderByDescending(p => p.Actor.TraitOrDefault<PrimaryBuilding>()?.IsPrimary)
.ThenByDescending(p => p.Actor.ActorID)
.FirstOrDefault();

LinkNodes.Clear();

if (producer.Actor != null)
{
cloneSource = producer.Trait;
cloneSource.AddCloneProducer(this);
LinkNodes.Clear();
LinkNodes.Add(producer.Actor.CenterPosition);
}
}
Expand Down
9 changes: 4 additions & 5 deletions OpenRA.Mods.CA/Traits/CloneSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CloneSourceInfo : TraitInfo, Requires<ProductionInfo>
public override object Create(ActorInitializer init) { return new CloneSource(init.Self, this); }
}

public class CloneSource : INotifyProduction, INotifyOwnerChanged, INotifyKilled, INotifySold, IResolveOrder, INotifyCreated
public class CloneSource : INotifyProduction, INotifyOwnerChanged, INotifyKilled, INotifyActorDisposing, IResolveOrder, INotifyCreated
{
HashSet<CloneProducer> cloneProducers = new HashSet<CloneProducer>();
public IEnumerable<string> ProductionTypes { get; private set; }
Expand Down Expand Up @@ -51,13 +51,12 @@ void INotifyKilled.Killed(Actor self, AttackInfo e)
SeverConnections();
}

void INotifySold.Selling(Actor self)
void INotifyActorDisposing.Disposing(Actor self)
{
SeverConnections();
if (!self.IsDead)
SeverConnections();
}

void INotifySold.Sold(Actor self) {}

void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
{
SeverConnections();
Expand Down
Binary file modified mods/ca/maps/Marigold_Town_CA.oramap
Binary file not shown.
Binary file modified mods/ca/maps/Nomad_CA.oramap
Binary file not shown.
116 changes: 116 additions & 0 deletions mods/ca/maps/ca-composition-tester/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,129 @@ PATR:
AttackOrderPowerCA@EMPMISSILE:
ChargeInterval: 1

FACT:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

WEAP:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

TENT:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

AFLD:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

DOME:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None
GpsRadarProvider:
RequiresCondition: gps-active
GrantDelayedCondition@GPS:
Condition: gps-active
Delay: 1

FIX:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
-GrantConditionOnResupplying@Resupplying:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

NUK2:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

SYRD:
DamageMultiplier@1:
Modifier: 0
-Sellable:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

INDP:
Valued:
Cost: 0
Expand Down
118 changes: 118 additions & 0 deletions mods/ca/maps/ca-composition-tournament/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,124 @@ AGUN.AI:
Armament:
Weapon: ZSU-23-AI

FACT:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

WEAP:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

TENT:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

AFLD:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

DOME:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

FIX:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
-GrantConditionOnResupplying@Resupplying:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

NUK2:
DamageMultiplier@1:
Modifier: 0
-Sellable:
-SpawnActorsOnSell:
-SpawnActorOnDeath:
-SpawnRandomActorOnDeath:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

SYRD:
DamageMultiplier@1:
Modifier: 0
-Sellable:
Capturable:
Types: None
RequiresCondition: being-captured
Targetable@TEMPORAL:
TargetTypes: None
Targetable@HACKABLE:
TargetTypes: None

CTNK:
PortableChronoCA:
MaxDistance: 10
Expand Down
9 changes: 9 additions & 0 deletions mods/ca/maps/ca-testing-grounds/map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5406,6 +5406,15 @@ Actors:
Actor1436: spen
Owner: Multi0
Location: 168,160
Actor1437: camera
Owner: Multi0
Location: 42,106
Actor1438: camera
Owner: Multi0
Location: 27,106
Actor1439: camera
Owner: Multi0
Location: 12,106

Rules: ca|rules/custom/composition-tester.yaml, ca|rules/custom/composition-tester-powers.yaml, rules.yaml

Expand Down
24 changes: 0 additions & 24 deletions mods/ca/maps/ca-testing-grounds/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,6 @@ Player:
-ModularBot@EasyAI:
-ModularBot@NavalAI:

FACT:
-DamageMultiplier@1:

WEAP:
-DamageMultiplier@1:

TENT:
-DamageMultiplier@1:

AFLD:
-DamageMultiplier@1:

DOME:
-DamageMultiplier@1:

FIX:
-DamageMultiplier@1:

NUK2:
-DamageMultiplier@1:

SYRD:
-DamageMultiplier@1:

^Vehicle-NOUPG:
GrantConditionOnBotOwner@immobile:
Condition: notmobile
Expand Down
6 changes: 6 additions & 0 deletions mods/ca/maps/ca-testing-grounds/weapons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,9 @@ BlackEagleMissiles:
BlackEagleMissilesAA:
Warhead@VeiledCondition: GrantExternalConditionCA
ValidRelationships: Enemy, Neutral, Ally

TitanRailgun:
Warhead@1Dam: SpreadDamage
ValidRelationships: Enemy, Neutral, Ally
Warhead@2Dam: SpreadDamage
Damage: 0
Loading

0 comments on commit d0e0c32

Please sign in to comment.