tesla works better now.
This commit is contained in:
3
OpenRA.Game/OpenRA.Game.csproj
Normal file → Executable file
3
OpenRA.Game/OpenRA.Game.csproj
Normal file → Executable file
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@@ -113,6 +113,7 @@
|
|||||||
<Compile Include="Support\PerfHistory.cs" />
|
<Compile Include="Support\PerfHistory.cs" />
|
||||||
<Compile Include="Sync.cs" />
|
<Compile Include="Sync.cs" />
|
||||||
<Compile Include="Traits\Attack\AttackOmni.cs" />
|
<Compile Include="Traits\Attack\AttackOmni.cs" />
|
||||||
|
<Compile Include="Traits\Attack\AttackTesla.cs" />
|
||||||
<Compile Include="Traits\Chrome\PowerDownButton.cs" />
|
<Compile Include="Traits\Chrome\PowerDownButton.cs" />
|
||||||
<Compile Include="Traits\CustomSellValue.cs" />
|
<Compile Include="Traits\CustomSellValue.cs" />
|
||||||
<Compile Include="Traits\World\SpawnDefaultUnits.cs" />
|
<Compile Include="Traits\World\SpawnDefaultUnits.cs" />
|
||||||
|
|||||||
16
OpenRA.Game/Traits/Attack/AttackBase.cs
Normal file → Executable file
16
OpenRA.Game/Traits/Attack/AttackBase.cs
Normal file → Executable file
@@ -66,9 +66,12 @@ namespace OpenRA.Traits
|
|||||||
secondaryBurst = secondaryWeapon != null ? secondaryWeapon.Burst : 1;
|
secondaryBurst = secondaryWeapon != null ? secondaryWeapon.Burst : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool CanAttack(Actor self)
|
protected virtual bool CanAttack(Actor self)
|
||||||
{
|
{
|
||||||
return target != null;
|
if( target == null ) return false;
|
||||||
|
if( ( primaryFireDelay > 0 ) && ( secondaryFireDelay > 0 ) ) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsReloading()
|
public bool IsReloading()
|
||||||
@@ -108,6 +111,8 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public void DoAttack(Actor self)
|
public void DoAttack(Actor self)
|
||||||
{
|
{
|
||||||
|
if( !CanAttack( self ) ) return;
|
||||||
|
|
||||||
var unit = self.traits.GetOrDefault<Unit>();
|
var unit = self.traits.GetOrDefault<Unit>();
|
||||||
var info = self.Info.Traits.Get<AttackBaseInfo>();
|
var info = self.Info.Traits.Get<AttackBaseInfo>();
|
||||||
|
|
||||||
@@ -165,7 +170,7 @@ namespace OpenRA.Traits
|
|||||||
var destUnit = thisTarget.traits.GetOrDefault<Unit>();
|
var destUnit = thisTarget.traits.GetOrDefault<Unit>();
|
||||||
var info = self.Info.Traits.Get<AttackBaseInfo>();
|
var info = self.Info.Traits.Get<AttackBaseInfo>();
|
||||||
|
|
||||||
ScheduleDelayedAction(info.FireDelay, () =>
|
ScheduleDelayedAction( FireDelay( self, info ), () =>
|
||||||
{
|
{
|
||||||
var srcAltitude = unit != null ? unit.Altitude : 0;
|
var srcAltitude = unit != null ? unit.Altitude : 0;
|
||||||
var destAltitude = destUnit != null ? destUnit.Altitude : 0;
|
var destAltitude = destUnit != null ? destUnit.Altitude : 0;
|
||||||
@@ -202,6 +207,11 @@ namespace OpenRA.Traits
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual int FireDelay( Actor self, AttackBaseInfo info )
|
||||||
|
{
|
||||||
|
return info.FireDelay;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Left || underCursor == null || underCursor.Owner == null) return null;
|
if (mi.Button == MouseButton.Left || underCursor == null || underCursor.Owner == null) return null;
|
||||||
|
|||||||
10
OpenRA.Game/Traits/Attack/AttackOmni.cs
Normal file → Executable file
10
OpenRA.Game/Traits/Attack/AttackOmni.cs
Normal file → Executable file
@@ -32,13 +32,15 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public AttackOmni(Actor self) : base(self) { }
|
public AttackOmni(Actor self) : base(self) { }
|
||||||
|
|
||||||
|
protected override bool CanAttack( Actor self )
|
||||||
|
{
|
||||||
|
var isBuilding = ( self.traits.Contains<Building>() && !buildComplete );
|
||||||
|
return base.CanAttack( self ) && !isBuilding;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Tick(Actor self)
|
public override void Tick(Actor self)
|
||||||
{
|
{
|
||||||
base.Tick(self);
|
base.Tick(self);
|
||||||
|
|
||||||
if (!CanAttack(self)) return;
|
|
||||||
if (self.traits.Contains<Building>() && !buildComplete) return;
|
|
||||||
|
|
||||||
DoAttack(self);
|
DoAttack(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
64
OpenRA.Game/Traits/Attack/AttackTesla.cs
Executable file
64
OpenRA.Game/Traits/Attack/AttackTesla.cs
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenRA.Traits
|
||||||
|
{
|
||||||
|
class AttackTeslaInfo : AttackOmniInfo
|
||||||
|
{
|
||||||
|
public readonly int MaxCharges = 3;
|
||||||
|
|
||||||
|
public override object Create( Actor self )
|
||||||
|
{
|
||||||
|
return new AttackTesla( self );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AttackTesla : AttackOmni, ITick
|
||||||
|
{
|
||||||
|
int charges;
|
||||||
|
int timeToRecharge;
|
||||||
|
|
||||||
|
public AttackTesla( Actor self )
|
||||||
|
: base( self )
|
||||||
|
{
|
||||||
|
charges = self.Info.Traits.Get<AttackTeslaInfo>().MaxCharges;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool CanAttack( Actor self )
|
||||||
|
{
|
||||||
|
return base.CanAttack( self ) && ( charges > 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Tick( Actor self )
|
||||||
|
{
|
||||||
|
if( --timeToRecharge <= 0 )
|
||||||
|
charges = self.Info.Traits.Get<AttackTeslaInfo>().MaxCharges;
|
||||||
|
if( charges <= 0 )
|
||||||
|
{
|
||||||
|
primaryFireDelay = Math.Max( primaryFireDelay, timeToRecharge );
|
||||||
|
secondaryFireDelay = Math.Max( secondaryFireDelay, timeToRecharge );
|
||||||
|
sameTarget = null;
|
||||||
|
}
|
||||||
|
base.Tick( self );
|
||||||
|
}
|
||||||
|
|
||||||
|
Actor sameTarget;
|
||||||
|
public override int FireDelay( Actor self, AttackBaseInfo info )
|
||||||
|
{
|
||||||
|
primaryFireDelay = 8;
|
||||||
|
timeToRecharge = Rules.WeaponInfo[ info.PrimaryWeapon ].ROF;
|
||||||
|
--charges;
|
||||||
|
|
||||||
|
if( target != sameTarget )
|
||||||
|
{
|
||||||
|
sameTarget = target;
|
||||||
|
self.traits.Get<RenderBuildingCharge>().PlayCharge( self );
|
||||||
|
return base.FireDelay( self, info );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
OpenRA.Game/Traits/Attack/AttackTurreted.cs
Normal file → Executable file
18
OpenRA.Game/Traits/Attack/AttackTurreted.cs
Normal file → Executable file
@@ -31,20 +31,22 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
public AttackTurreted(Actor self) : base(self) { }
|
public AttackTurreted(Actor self) : base(self) { }
|
||||||
|
|
||||||
public override void Tick(Actor self)
|
protected override bool CanAttack( Actor self )
|
||||||
{
|
{
|
||||||
base.Tick(self);
|
if( self.traits.Contains<Building>() && !buildComplete )
|
||||||
|
return false;
|
||||||
if( !CanAttack( self ) ) return;
|
|
||||||
|
|
||||||
if (self.traits.Contains<Building>() && !buildComplete)
|
|
||||||
return; /* base defenses can't do anything until they finish building !*/
|
|
||||||
|
|
||||||
var turreted = self.traits.Get<Turreted>();
|
var turreted = self.traits.Get<Turreted>();
|
||||||
turreted.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turreted.turretFacing );
|
turreted.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turreted.turretFacing );
|
||||||
if( turreted.desiredFacing != turreted.turretFacing )
|
if( turreted.desiredFacing != turreted.turretFacing )
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
|
return base.CanAttack( self );
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Tick(Actor self)
|
||||||
|
{
|
||||||
|
base.Tick(self);
|
||||||
DoAttack( self );
|
DoAttack( self );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
OpenRA.Game/Traits/Render/RenderBuildingCharge.cs
Normal file → Executable file
4
OpenRA.Game/Traits/Render/RenderBuildingCharge.cs
Normal file → Executable file
@@ -27,14 +27,14 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* used for tesla */
|
/* used for tesla */
|
||||||
class RenderBuildingCharge : RenderBuilding, INotifyAttack
|
class RenderBuildingCharge : RenderBuilding
|
||||||
{
|
{
|
||||||
public RenderBuildingCharge(Actor self)
|
public RenderBuildingCharge(Actor self)
|
||||||
: base(self)
|
: base(self)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Attacking(Actor self)
|
public void PlayCharge(Actor self)
|
||||||
{
|
{
|
||||||
Sound.Play(self.Info.Traits.Get<RenderBuildingChargeInfo>().ChargeAudio);
|
Sound.Play(self.Info.Traits.Get<RenderBuildingChargeInfo>().ChargeAudio);
|
||||||
anim.PlayThen(GetPrefix(self) + "active",
|
anim.PlayThen(GetPrefix(self) + "active",
|
||||||
|
|||||||
2
mods/ra/rules.yaml
Normal file → Executable file
2
mods/ra/rules.yaml
Normal file → Executable file
@@ -570,7 +570,7 @@ TSLA:
|
|||||||
Crewed: yes
|
Crewed: yes
|
||||||
Sight: 8
|
Sight: 8
|
||||||
RenderBuildingCharge:
|
RenderBuildingCharge:
|
||||||
AttackOmni:
|
AttackTesla:
|
||||||
PrimaryWeapon: TeslaZap
|
PrimaryWeapon: TeslaZap
|
||||||
FireDelay: 8
|
FireDelay: 8
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
|
|||||||
Reference in New Issue
Block a user