Compare commits
20 Commits
devtest-20
...
devtest-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24459c29ae | ||
|
|
6347049e1c | ||
|
|
45bc278647 | ||
|
|
7ab35bf127 | ||
|
|
01044f12d1 | ||
|
|
d0ec33758b | ||
|
|
7dec826591 | ||
|
|
c6eec76af9 | ||
|
|
2e1c1f1305 | ||
|
|
7abde1cc5f | ||
|
|
2f67fc64de | ||
|
|
880a584bd5 | ||
|
|
756188b0d0 | ||
|
|
f1b0ef20c7 | ||
|
|
e014795c25 | ||
|
|
a8d3d5c79a | ||
|
|
7c852d90fb | ||
|
|
269ce9c406 | ||
|
|
53d98ec255 | ||
|
|
7a7cd21578 |
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user