added classic engineer capture rules

This commit is contained in:
Matthias Mailänder
2013-03-01 23:14:43 +01:00
parent f2703dd65d
commit e3fbd40278
5 changed files with 22 additions and 6 deletions

View File

@@ -22,9 +22,16 @@ namespace OpenRA.Mods.RA.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) return NextActivity; var capturesInfo = self.Info.Traits.Get<CapturesInfo>();
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity; var health = target.Trait<Health>();
if (target.Owner == self.Owner) return NextActivity; int damage = (int)(0.25 * health.MaxHP);
if (IsCanceled)
return NextActivity;
if (target == null || !target.IsInWorld || target.IsDead())
return NextActivity;
if (target.Owner == self.Owner)
return NextActivity;
// Need to be next to building, TODO: stop capture when going away // Need to be next to building, TODO: stop capture when going away
var mobile = self.Trait<Mobile>(); var mobile = self.Trait<Mobile>();
@@ -32,10 +39,14 @@ namespace OpenRA.Mods.RA.Activities
if ((nearest - mobile.toCell).LengthSquared > 2) if ((nearest - mobile.toCell).LengthSquared > 2)
return Util.SequenceActivities(new MoveAdjacentTo(Target.FromActor(target)), this); return Util.SequenceActivities(new MoveAdjacentTo(Target.FromActor(target)), this);
if (!target.Trait<Capturable>().BeginCapture(target, self)) if (!capturesInfo.Sabotage || (capturesInfo.Sabotage && health.DamageState == DamageState.Heavy))
return NextActivity; {
if (!target.Trait<Capturable>().BeginCapture(target, self))
return NextActivity;
}
else
target.InflictDamage(self, damage, null);
var capturesInfo = self.Info.Traits.Get<CapturesInfo>();
if (capturesInfo != null && capturesInfo.WastedAfterwards) if (capturesInfo != null && capturesInfo.WastedAfterwards)
self.World.AddFrameEndTask(w => self.Destroy()); self.World.AddFrameEndTask(w => self.Destroy());

View File

@@ -23,6 +23,7 @@ namespace OpenRA.Mods.RA
{ {
public string[] CaptureTypes = {"building"}; public string[] CaptureTypes = {"building"};
public bool WastedAfterwards = true; public bool WastedAfterwards = true;
public bool Sabotage = false;
public object Create(ActorInitializer init) { return new Captures(init.self, this); } public object Create(ActorInitializer init) { return new Captures(init.self, this); }
} }

View File

@@ -233,6 +233,7 @@
ShakeOnDeath: ShakeOnDeath:
Sellable: Sellable:
Capturable: Capturable:
CaptureCompleteTime: 0
CapturableBar: CapturableBar:
^CivBuilding: ^CivBuilding:
@@ -268,6 +269,7 @@
^TechBuilding: ^TechBuilding:
Inherits: ^CivBuilding Inherits: ^CivBuilding
Capturable: Capturable:
CaptureCompleteTime: 0
CapturableBar: CapturableBar:
RepairableBuilding: RepairableBuilding:
RevealsShroud: RevealsShroud:

View File

@@ -166,6 +166,7 @@
TerrainTypes: Clear,Road TerrainTypes: Clear,Road
GivesBuildableArea: GivesBuildableArea:
Capturable: Capturable:
CaptureCompleteTime: 0
CapturableBar: CapturableBar:
SoundOnDamageTransition: SoundOnDamageTransition:
DamagedSound: kaboom1.aud DamagedSound: kaboom1.aud

View File

@@ -156,6 +156,7 @@ E6:
PipType: Yellow PipType: Yellow
EngineerRepair: EngineerRepair:
Captures: Captures:
Sabotage: yes
TakeCover: TakeCover:
-AutoTarget: -AutoTarget:
AttackMove: AttackMove: