fix tesla animations and firing at multiple targets
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using OpenRA.Mods.RA.Render;
|
using OpenRA.Mods.RA.Render;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Mods.RA.Activities;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
@@ -32,44 +33,58 @@ namespace OpenRA.Mods.RA
|
|||||||
charges = self.Info.Traits.Get<AttackTeslaInfo>().MaxCharges;
|
charges = self.Info.Traits.Get<AttackTeslaInfo>().MaxCharges;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool CanAttack( Actor self, Target target )
|
|
||||||
{
|
|
||||||
return base.CanAttack( self, target ) && ( charges > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Tick( Actor self )
|
public override void Tick( Actor self )
|
||||||
{
|
{
|
||||||
if( --timeToRecharge <= 0 )
|
if( --timeToRecharge <= 0 )
|
||||||
charges = self.Info.Traits.Get<AttackTeslaInfo>().MaxCharges;
|
charges = self.Info.Traits.Get<AttackTeslaInfo>().MaxCharges;
|
||||||
if( charges <= 0 )
|
|
||||||
{
|
|
||||||
foreach( var w in Weapons )
|
|
||||||
w.FireDelay = Math.Max( w.FireDelay, timeToRecharge );
|
|
||||||
|
|
||||||
previousTarget = null;
|
|
||||||
}
|
|
||||||
base.Tick( self );
|
base.Tick( self );
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor previousTarget;
|
|
||||||
|
|
||||||
public override int FireDelay( Actor self, Target target, AttackBaseInfo info )
|
|
||||||
{
|
|
||||||
return target.Actor == previousTarget ? 3 : base.FireDelay(self, target, info);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Attacking(Actor self, Target target)
|
public void Attacking(Actor self, Target target)
|
||||||
{
|
{
|
||||||
foreach (var w in Weapons)
|
|
||||||
w.FireDelay = 8;
|
|
||||||
|
|
||||||
timeToRecharge = self.Info.Traits.Get<AttackTeslaInfo>().ReloadTime;
|
|
||||||
--charges;
|
--charges;
|
||||||
|
timeToRecharge = self.Info.Traits.Get<AttackTeslaInfo>().ReloadTime;
|
||||||
|
}
|
||||||
|
|
||||||
if (target.Actor != previousTarget)
|
protected override IActivity GetAttackActivity( Actor self, Target newTarget, bool allowMove )
|
||||||
{
|
{
|
||||||
previousTarget = target.Actor;
|
return new TeslaAttack( newTarget );
|
||||||
|
}
|
||||||
|
|
||||||
|
class TeslaAttack : CancelableActivity
|
||||||
|
{
|
||||||
|
readonly Target target;
|
||||||
|
public TeslaAttack( Target target ) { this.target = target; }
|
||||||
|
|
||||||
|
public override IActivity Tick( Actor self )
|
||||||
|
{
|
||||||
|
if( IsCanceled || !target.IsValid ) return NextActivity;
|
||||||
|
|
||||||
|
var attack = self.Trait<AttackTesla>();
|
||||||
|
if( attack.charges == 0 || !attack.CanAttack( self, target ) )
|
||||||
|
return this;
|
||||||
|
|
||||||
self.Trait<RenderBuildingCharge>().PlayCharge(self);
|
self.Trait<RenderBuildingCharge>().PlayCharge(self);
|
||||||
|
return Util.SequenceActivities( new Wait( 8 ), new TeslaZap( target ), this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TeslaZap : CancelableActivity
|
||||||
|
{
|
||||||
|
readonly Target target;
|
||||||
|
public TeslaZap( Target target ) { this.target = target; }
|
||||||
|
|
||||||
|
public override IActivity Tick( Actor self )
|
||||||
|
{
|
||||||
|
if( IsCanceled || !target.IsValid ) return NextActivity;
|
||||||
|
|
||||||
|
var attack = self.Trait<AttackTesla>();
|
||||||
|
if( attack.charges == 0 ) return NextActivity;
|
||||||
|
|
||||||
|
attack.DoAttack( self, target );
|
||||||
|
|
||||||
|
return Util.SequenceActivities( new Wait( 3 ), this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,7 +253,6 @@ TSLA:
|
|||||||
RenderBuildingCharge:
|
RenderBuildingCharge:
|
||||||
AttackTesla:
|
AttackTesla:
|
||||||
PrimaryWeapon: TeslaZap
|
PrimaryWeapon: TeslaZap
|
||||||
FireDelay: 8
|
|
||||||
ReloadTime: 120
|
ReloadTime: 120
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
|
|||||||
Reference in New Issue
Block a user