Compare commits

..

20 Commits

Author SHA1 Message Date
Paul Chote
24459c29ae Merge branch 'gh-actions' into devtest-integration 2020-12-09 22:06:34 +00:00
Paul Chote
6347049e1c 18892 (pchote edition) 2020-12-09 22:06:30 +00:00
Paul Chote
45bc278647 Merge remote-tracking branch 'upstream/pr/18913' into devtest-integration 2020-12-09 22:05:58 +00:00
Paul Chote
7ab35bf127 Merge remote-tracking branch 'upstream/pr/18912' into devtest-integration 2020-12-09 22:05:51 +00:00
Paul Chote
01044f12d1 Merge remote-tracking branch 'upstream/pr/18894' into devtest-integration 2020-12-09 22:05:42 +00:00
Paul Chote
d0ec33758b Merge remote-tracking branch 'upstream/pr/18695' into devtest-integration 2020-12-09 22:05:32 +00:00
Paul Chote
7dec826591 Merge remote-tracking branch 'upstream/pr/18678' into devtest-integration 2020-12-09 22:05:24 +00:00
Paul Chote
c6eec76af9 Merge remote-tracking branch 'upstream/pr/18430' into devtest-integration 2020-12-09 22:05:17 +00:00
Paul Chote
2e1c1f1305 Merge remote-tracking branch 'upstream/pr/18874' into devtest-integration 2020-12-09 22:05:10 +00:00
Paul Chote
7abde1cc5f Merge remote-tracking branch 'upstream/pr/18902' into devtest-integration 2020-12-09 22:04:59 +00:00
Paul Chote
2f67fc64de Fix infantry move animations overriding attack animations in the same tick. 2020-12-09 21:56:17 +00:00
Paul Chote
880a584bd5 Revert "Fix WithInfantryBody wrongly overwriting attack animations"
This reverts commit 1a63cc4a41.
2020-12-09 21:53:39 +00:00
Paul Chote
756188b0d0 Prevent Civilians from wandering onto Tiberium. 2020-12-09 21:49:57 +00:00
Paul Chote
f1b0ef20c7 Add AvoidTerrainTypes to ScaredyCat. 2020-12-09 19:43:22 +00:00
Paul Chote
e014795c25 Add AvoidTerrainTypes to Wanders. 2020-12-09 19:42:14 +00:00
Paul Chote
a8d3d5c79a Fix Neutral crushing checks. 2020-12-08 20:17:11 +01:00
Paul Chote
7c852d90fb Ignore aircraft when searching for enemy targets. 2020-12-07 23:39:22 +01:00
Paul Chote
269ce9c406 Exclude carryalls from AI squads. 2020-12-07 23:39:22 +01:00
Paul Chote
53d98ec255 Abort squad states that are not able to move. 2020-12-07 23:39:22 +01:00
Paul Chote
7a7cd21578 Fix TD SAM Site facings being reset when damaged while closed. 2020-12-07 01:44:04 +01:00
6 changed files with 42 additions and 15 deletions

View File

@@ -9,6 +9,8 @@
*/
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
@@ -28,6 +30,9 @@ 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-";
@@ -39,6 +44,7 @@ namespace OpenRA.Mods.Common.Traits
readonly ScaredyCatInfo info;
readonly Mobile mobile;
readonly Actor self;
readonly Func<CPos, bool> avoidTerrainFilter;
[Sync]
int panicStartedTick;
@@ -52,6 +58,9 @@ 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()
@@ -79,7 +88,10 @@ namespace OpenRA.Mods.Common.Traits
if (!Panicking)
return;
mobile.Nudge(self);
// 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));
}
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)
public CPos? GetAdjacentCell(CPos nextCell, Func<CPos, bool> preferToAvoid = null)
{
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))
if (CanEnterCell(p) && CanStayInCell(p) && (preferToAvoid == null || !preferToAvoid(p)))
availCells.Add(p);
else if (p != nextCell && p != ToCell)
notStupidCells.Add(p);

View File

@@ -148,7 +148,12 @@ namespace OpenRA.Mods.Common.Traits.Render
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
{
Attacking(self, target, a);
// 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));
}
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel) { }
@@ -160,10 +165,6 @@ 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,6 +9,8 @@
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
@@ -27,6 +29,9 @@ 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); }
}
@@ -75,8 +80,8 @@ namespace OpenRA.Mods.Common.Traits
return;
var targetCell = PickTargetLocation();
if (targetCell != CPos.Zero)
DoAction(self, targetCell);
if (targetCell.HasValue)
DoAction(self, targetCell.Value);
}
void INotifyIdle.TickIdle(Actor self)
@@ -84,7 +89,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);
@@ -95,7 +100,14 @@ namespace OpenRA.Mods.Common.Traits
if (++ticksIdle % info.ReduceMoveRadiusDelay == 0)
effectiveMoveRadius--;
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
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;
}
ticksIdle = 0;

View File

@@ -468,6 +468,7 @@
Notification: CivilianKilled
NotifyAll: true
ScaredyCat:
AvoidTerrainTypes: Tiberium, BlueTiberium
Crushable:
CrushSound: squish2.aud
Voiced:
@@ -475,6 +476,7 @@
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
ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce
ConstructionYardTypes: construction_yard
IgnoredEnemyTargetTypes: Creep
UnitBuilderBotModule@omnius:
@@ -263,7 +263,7 @@ Player:
RequiresCondition: enable-vidious-ai
SquadSize: 6
MaxBaseRadius: 40
ExcludeFromSquadsTypes: harvester, mcv
ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce
ConstructionYardTypes: construction_yard
IgnoredEnemyTargetTypes: Creep
UnitBuilderBotModule@vidious:
@@ -302,7 +302,7 @@ Player:
RequiresCondition: enable-gladius-ai
SquadSize: 10
MaxBaseRadius: 40
ExcludeFromSquadsTypes: harvester, mcv
ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce
ConstructionYardTypes: construction_yard
IgnoredEnemyTargetTypes: Creep
UnitBuilderBotModule@gladius: