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)
{
if (IsCanceled) return NextActivity;
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
if (target.Owner == self.Owner) return NextActivity;
var capturesInfo = self.Info.Traits.Get<CapturesInfo>();
var health = target.Trait<Health>();
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
var mobile = self.Trait<Mobile>();
@@ -32,10 +39,14 @@ namespace OpenRA.Mods.RA.Activities
if ((nearest - mobile.toCell).LengthSquared > 2)
return Util.SequenceActivities(new MoveAdjacentTo(Target.FromActor(target)), this);
if (!capturesInfo.Sabotage || (capturesInfo.Sabotage && health.DamageState == DamageState.Heavy))
{
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)
self.World.AddFrameEndTask(w => self.Destroy());

View File

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

View File

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

View File

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

View File

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