Compare commits

..

16 Commits

Author SHA1 Message Date
Paul Chote
b73210f706 Merge branch 'gh-actions' into devtest-integration 2020-12-07 00:14:58 +00:00
Paul Chote
a111f1299c 18892 (pchote edition) 2020-12-07 00:14:53 +00:00
Paul Chote
d21e52b33c Merge remote-tracking branch 'upstream/pr/18900' into devtest-integration 2020-12-07 00:11:51 +00:00
Paul Chote
4e6912a22c Merge remote-tracking branch 'upstream/pr/18894' into devtest-integration 2020-12-07 00:11:43 +00:00
Paul Chote
80c2ac1350 Merge remote-tracking branch 'upstream/pr/18695' into devtest-integration 2020-12-07 00:10:10 +00:00
Paul Chote
776894445b Merge remote-tracking branch 'upstream/pr/18678' into devtest-integration 2020-12-07 00:09:58 +00:00
Paul Chote
a4369dc804 Merge remote-tracking branch 'upstream/pr/18430' into devtest-integration 2020-12-07 00:09:40 +00:00
Paul Chote
ae35880900 Merge remote-tracking branch 'upstream/pr/18903' into devtest-integration 2020-12-07 00:09:27 +00:00
Paul Chote
9900dc47d2 Merge remote-tracking branch 'upstream/pr/18874' into devtest-integration 2020-12-07 00:09:20 +00:00
Paul Chote
4d251d6fc3 Merge remote-tracking branch 'upstream/pr/18902' into devtest-integration 2020-12-07 00:08:53 +00:00
Paul Chote
e226eb2ae5 Merge remote-tracking branch 'upstream/pr/18904' into devtest-integration 2020-12-07 00:08:39 +00:00
Paul Chote
cf2d4b24e2 Fix Neutral crushing checks. 2020-12-07 00:01:35 +00:00
Paul Chote
a160797f71 Fix TD SAM Site facings being reset when damaged while closed. 2020-12-06 22:45:18 +00:00
Paul Chote
7c96b69303 Ignore aircraft when searching for enemy targets. 2020-12-06 18:18:05 +00:00
Paul Chote
2b50d99a62 Exclude carryalls from AI squads. 2020-12-06 18:06:57 +00:00
Paul Chote
f0d910357d Abort squad states that are not able to move. 2020-12-06 18:05:55 +00:00
6 changed files with 15 additions and 42 deletions

View File

@@ -9,8 +9,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
@@ -30,9 +28,6 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Chance (out of 100) the unit has to enter panic mode when attacking.")]
public readonly int AttackPanicChance = 20;
[Desc("The terrain types that this actor should avoid running on to while panicing.")]
public readonly HashSet<string> AvoidTerrainTypes = new HashSet<string>();
[SequenceReference(prefix: true)]
public readonly string PanicSequencePrefix = "panic-";
@@ -44,7 +39,6 @@ namespace OpenRA.Mods.Common.Traits
readonly ScaredyCatInfo info;
readonly Mobile mobile;
readonly Actor self;
readonly Func<CPos, bool> avoidTerrainFilter;
[Sync]
int panicStartedTick;
@@ -58,9 +52,6 @@ namespace OpenRA.Mods.Common.Traits
this.self = self;
this.info = info;
mobile = self.Trait<Mobile>();
if (info.AvoidTerrainTypes.Count > 0)
avoidTerrainFilter = c => info.AvoidTerrainTypes.Contains(self.World.Map.GetTerrainInfo(c).Type);
}
public void Panic()
@@ -88,10 +79,7 @@ namespace OpenRA.Mods.Common.Traits
if (!Panicking)
return;
// Note: This is just a modified copy of Mobile.Nudge
var cell = mobile.GetAdjacentCell(self.Location, avoidTerrainFilter);
if (cell != null)
self.QueueActivity(false, mobile.MoveTo(cell.Value, 0));
mobile.Nudge(self);
}
void INotifyDamage.Damaged(Actor self, AttackInfo e)

View File

@@ -364,14 +364,14 @@ namespace OpenRA.Mods.Common.Traits
self.QueueActivity(false, MoveTo(cell.Value, 0));
}
public CPos? GetAdjacentCell(CPos nextCell, Func<CPos, bool> preferToAvoid = null)
public CPos? GetAdjacentCell(CPos nextCell)
{
var availCells = new List<CPos>();
var notStupidCells = new List<CPos>();
foreach (CVec direction in CVec.Directions)
{
var p = ToCell + direction;
if (CanEnterCell(p) && CanStayInCell(p) && (preferToAvoid == null || !preferToAvoid(p)))
if (CanEnterCell(p) && CanStayInCell(p))
availCells.Add(p);
else if (p != nextCell && p != ToCell)
notStupidCells.Add(p);

View File

@@ -148,12 +148,7 @@ namespace OpenRA.Mods.Common.Traits.Render
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
{
// Lambdas can't use 'in' variables, so capture a copy for later
var attackTarget = target;
// HACK: The FrameEndTask makes sure that this runs after Tick(), preventing that from
// overriding the animation when an infantry unit stops to attack
self.World.AddFrameEndTask(_ => Attacking(self, attackTarget, a));
Attacking(self, target, a);
}
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel) { }
@@ -165,6 +160,10 @@ namespace OpenRA.Mods.Common.Traits.Render
protected virtual void Tick(Actor self)
{
// Attacking takes care of reverting back to PlayStandAnimation
if (state == AnimationState.Attacking)
return;
if (rsm != null)
{
if (wasModifying != rsm.IsModifyingSequence)

View File

@@ -9,8 +9,6 @@
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
@@ -29,9 +27,6 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Maximum amount of ticks the actor will sit idly before starting to wander.")]
public readonly int MaxMoveDelay = 0;
[Desc("The terrain types that this actor should avoid wandering on to.")]
public readonly HashSet<string> AvoidTerrainTypes = new HashSet<string>();
public override object Create(ActorInitializer init) { return new Wanders(init.Self, this); }
}
@@ -80,8 +75,8 @@ namespace OpenRA.Mods.Common.Traits
return;
var targetCell = PickTargetLocation();
if (targetCell.HasValue)
DoAction(self, targetCell.Value);
if (targetCell != CPos.Zero)
DoAction(self, targetCell);
}
void INotifyIdle.TickIdle(Actor self)
@@ -89,7 +84,7 @@ namespace OpenRA.Mods.Common.Traits
TickIdle(self);
}
CPos? PickTargetLocation()
CPos PickTargetLocation()
{
var target = self.CenterPosition + new WVec(0, -1024 * effectiveMoveRadius, 0).Rotate(WRot.FromFacing(self.World.SharedRandom.Next(255)));
var targetCell = self.World.Map.CellContaining(target);
@@ -100,14 +95,7 @@ namespace OpenRA.Mods.Common.Traits
if (++ticksIdle % info.ReduceMoveRadiusDelay == 0)
effectiveMoveRadius--;
return null; // We'll be back the next tick; better to sit idle for a few seconds than prolong this tick indefinitely with a loop
}
if (info.AvoidTerrainTypes.Count > 0)
{
var terrainType = self.World.Map.GetTerrainInfo(targetCell).Type;
if (Info.AvoidTerrainTypes.Contains(terrainType))
return null;
return CPos.Zero; // We'll be back the next tick; better to sit idle for a few seconds than prolong this tick indefinitely with a loop
}
ticksIdle = 0;

View File

@@ -468,7 +468,6 @@
Notification: CivilianKilled
NotifyAll: true
ScaredyCat:
AvoidTerrainTypes: Tiberium, BlueTiberium
Crushable:
CrushSound: squish2.aud
Voiced:
@@ -476,7 +475,6 @@
Wanders:
MinMoveDelay: 150
MaxMoveDelay: 750
AvoidTerrainTypes: Tiberium, BlueTiberium
MapEditorData:
Categories: Civilian infantry

View File

@@ -219,7 +219,7 @@ Player:
RequiresCondition: enable-omnius-ai
SquadSize: 8
MaxBaseRadius: 40
ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce
ExcludeFromSquadsTypes: harvester, mcv, carryall
ConstructionYardTypes: construction_yard
IgnoredEnemyTargetTypes: Creep
UnitBuilderBotModule@omnius:
@@ -263,7 +263,7 @@ Player:
RequiresCondition: enable-vidious-ai
SquadSize: 6
MaxBaseRadius: 40
ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce
ExcludeFromSquadsTypes: harvester, mcv
ConstructionYardTypes: construction_yard
IgnoredEnemyTargetTypes: Creep
UnitBuilderBotModule@vidious:
@@ -302,7 +302,7 @@ Player:
RequiresCondition: enable-gladius-ai
SquadSize: 10
MaxBaseRadius: 40
ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce
ExcludeFromSquadsTypes: harvester, mcv
ConstructionYardTypes: construction_yard
IgnoredEnemyTargetTypes: Creep
UnitBuilderBotModule@gladius: