Convert AttackSwallow to conditions.
This commit is contained in:
@@ -637,6 +637,13 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
if (!node.Value.Nodes.Any(n => n.Key == "Condition"))
|
if (!node.Value.Nodes.Any(n => n.Key == "Condition"))
|
||||||
node.Value.Nodes.Add(new MiniYamlNode("Condition", "terrain"));
|
node.Value.Nodes.Add(new MiniYamlNode("Condition", "terrain"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node.Key == "AttackSwallow")
|
||||||
|
{
|
||||||
|
ConvertUpgradesToCondition(parent, node, "AttackingUpgrades", "AttackingCondition");
|
||||||
|
if (!node.Value.Nodes.Any(n => n.Key == "AttackingCondition"))
|
||||||
|
node.Value.Nodes.Add(new MiniYamlNode("AttackingCondition", "attacking"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
int countdown;
|
int countdown;
|
||||||
CPos burrowLocation;
|
CPos burrowLocation;
|
||||||
AttackState stance;
|
AttackState stance;
|
||||||
|
int attackingToken = UpgradeManager.InvalidConditionToken;
|
||||||
|
|
||||||
public SwallowActor(Actor self, Target target, WeaponInfo weapon)
|
public SwallowActor(Actor self, Target target, WeaponInfo weapon)
|
||||||
{
|
{
|
||||||
@@ -45,7 +46,7 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
sandworm = self.Trait<Sandworm>();
|
sandworm = self.Trait<Sandworm>();
|
||||||
positionable = self.Trait<Mobile>();
|
positionable = self.Trait<Mobile>();
|
||||||
swallow = self.Trait<AttackSwallow>();
|
swallow = self.Trait<AttackSwallow>();
|
||||||
manager = self.Trait<UpgradeManager>();
|
manager = self.TraitOrDefault<UpgradeManager>();
|
||||||
radarPings = self.World.WorldActor.TraitOrDefault<RadarPings>();
|
radarPings = self.World.WorldActor.TraitOrDefault<RadarPings>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,10 +106,12 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
switch (stance)
|
switch (stance)
|
||||||
{
|
{
|
||||||
case AttackState.Uninitialized:
|
case AttackState.Uninitialized:
|
||||||
GrantUpgrades(self);
|
|
||||||
stance = AttackState.Burrowed;
|
stance = AttackState.Burrowed;
|
||||||
countdown = swallow.Info.AttackDelay;
|
countdown = swallow.Info.AttackDelay;
|
||||||
burrowLocation = self.Location;
|
burrowLocation = self.Location;
|
||||||
|
if (manager != null && attackingToken == UpgradeManager.InvalidConditionToken &&
|
||||||
|
!string.IsNullOrEmpty(swallow.Info.AttackingCondition))
|
||||||
|
attackingToken = manager.GrantCondition(self, swallow.Info.AttackingCondition);
|
||||||
break;
|
break;
|
||||||
case AttackState.Burrowed:
|
case AttackState.Burrowed:
|
||||||
if (--countdown > 0)
|
if (--countdown > 0)
|
||||||
@@ -119,14 +122,14 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
// The target has moved too far away
|
// The target has moved too far away
|
||||||
if ((burrowLocation - targetLocation).Length > NearEnough)
|
if ((burrowLocation - targetLocation).Length > NearEnough)
|
||||||
{
|
{
|
||||||
RevokeUpgrades(self);
|
RevokeCondition(self);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The target reached solid ground
|
// The target reached solid ground
|
||||||
if (!positionable.CanEnterCell(targetLocation, null, false))
|
if (!positionable.CanEnterCell(targetLocation, null, false))
|
||||||
{
|
{
|
||||||
RevokeUpgrades(self);
|
RevokeCondition(self);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +138,7 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
|
|
||||||
if (!targets.Any())
|
if (!targets.Any())
|
||||||
{
|
{
|
||||||
RevokeUpgrades(self);
|
RevokeCondition(self);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,23 +161,17 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
self.World.AddFrameEndTask(w => self.Dispose());
|
self.World.AddFrameEndTask(w => self.Dispose());
|
||||||
}
|
}
|
||||||
|
|
||||||
RevokeUpgrades(self);
|
RevokeCondition(self);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrantUpgrades(Actor self)
|
void RevokeCondition(Actor self)
|
||||||
{
|
{
|
||||||
foreach (var up in swallow.Info.AttackingUpgrades)
|
if (attackingToken != UpgradeManager.InvalidConditionToken)
|
||||||
manager.GrantUpgrade(self, up, this);
|
attackingToken = manager.RevokeCondition(self, attackingToken);
|
||||||
}
|
|
||||||
|
|
||||||
void RevokeUpgrades(Actor self)
|
|
||||||
{
|
|
||||||
foreach (var up in swallow.Info.AttackingUpgrades)
|
|
||||||
manager.RevokeUpgrade(self, up, this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
public readonly int AttackDelay = 30;
|
public readonly int AttackDelay = 30;
|
||||||
|
|
||||||
[UpgradeGrantedReference]
|
[UpgradeGrantedReference]
|
||||||
[Desc("The upgrades to grant while attacking.")]
|
[Desc("The condition to grant to self while attacking.")]
|
||||||
public readonly string[] AttackingUpgrades = { "attacking" };
|
public readonly string AttackingCondition = null;
|
||||||
|
|
||||||
public readonly string WormAttackSound = "WORM.WAV";
|
public readonly string WormAttackSound = "WORM.WAV";
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ sandworm:
|
|||||||
AttackSwallow:
|
AttackSwallow:
|
||||||
AttackRequiresEnteringCell: true
|
AttackRequiresEnteringCell: true
|
||||||
IgnoresVisibility: true
|
IgnoresVisibility: true
|
||||||
|
AttackingCondition: attacking
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: WormJaw
|
Weapon: WormJaw
|
||||||
Sandworm:
|
Sandworm:
|
||||||
|
|||||||
Reference in New Issue
Block a user