Merge pull request #4803 from reaperrr/obelisk-fix2

Building charge improvements
This commit is contained in:
Matthias Mailänder
2014-03-07 18:54:17 +01:00
9 changed files with 152 additions and 112 deletions

View File

@@ -76,6 +76,7 @@ NEW:
Decreased Visceroid health by 25% and removed their ability to gain experience. Decreased Visceroid health by 25% and removed their ability to gain experience.
Increased the chance of Tiberium or chemical deaths spawning a Visceroid from 2% to 10%. Increased the chance of Tiberium or chemical deaths spawning a Visceroid from 2% to 10%.
Increased Obelisk of Light laser damage from 200 to 360. Increased Obelisk of Light laser damage from 200 to 360.
Fixed Obelisk of Light charge animation and sound not playing.
Engine: Engine:
Converted Aircraft CruiseAltitude to world coordinates. Converted Aircraft CruiseAltitude to world coordinates.
Converted Health Radius to world coordinates. Converted Health Radius to world coordinates.
@@ -95,6 +96,8 @@ NEW:
Fixed performance issues with units pathing to naval transports. Fixed performance issues with units pathing to naval transports.
Fixed unit moving to transports that have moved. Fixed unit moving to transports that have moved.
Updated shroud-based traits to use world units. Updated shroud-based traits to use world units.
Renamed AttackTesla into AttackCharge and un-hardcoded initial charge delay and delay for additional charges.
Updated RenderBuildingCharge so you can set a custom charge sequence name (default is active).
Server: Server:
Message of the day is now shared between all mods and a default motd.txt gets created in the user directory. Message of the day is now shared between all mods and a default motd.txt gets created in the user directory.
Asset Browser: Asset Browser:

View File

@@ -0,0 +1,118 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using OpenRA.Mods.RA.Activities;
using OpenRA.FileFormats;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class AttackChargeInfo : AttackOmniInfo
{
public readonly int MaxCharges = 1;
[Desc("Reload time (for all charges).")]
public readonly int ReloadTime = 120;
[Desc("Delay for first charge. Needs to match FireDelay for Obelisk.")]
public readonly int InitialChargeDelay = 22;
[Desc("Delay for additional charges if MaxCharge is larger than 1.")]
public readonly int ChargeDelay = 3;
public override object Create(ActorInitializer init) { return new AttackCharge(init.self); }
}
class AttackCharge : AttackOmni, ITick, INotifyAttack, ISync
{
[Sync] int charges;
[Sync] int timeToRecharge;
public AttackCharge(Actor self)
: base(self)
{
charges = self.Info.Traits.Get<AttackChargeInfo>().MaxCharges;
}
public override void Tick( Actor self )
{
if( --timeToRecharge <= 0 )
charges = self.Info.Traits.Get<AttackChargeInfo>().MaxCharges;
base.Tick( self );
}
public void Attacking(Actor self, Target target, Armament a, Barrel barrel)
{
--charges;
timeToRecharge = self.Info.Traits.Get<AttackChargeInfo>().ReloadTime;
}
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
{
return new ChargeAttack(newTarget);
}
public override void ResolveOrder(Actor self, Order order)
{
base.ResolveOrder(self, order);
if (order.OrderString == "Stop")
self.CancelActivity();
}
class ChargeAttack : Activity
{
readonly Target target;
public ChargeAttack(Target target)
{
this.target = target;
}
public override Activity Tick(Actor self)
{
if (IsCanceled || !target.IsValidFor(self))
return NextActivity;
var initDelay = self.Info.Traits.Get<AttackChargeInfo>().InitialChargeDelay;
var attack = self.Trait<AttackCharge>();
if(attack.charges == 0 || !attack.CanAttack(self, target))
return this;
self.Trait<RenderBuildingCharge>().PlayCharge(self);
return Util.SequenceActivities(new Wait(initDelay), new ChargeFire(target), this);
}
}
class ChargeFire : Activity
{
readonly Target target;
public ChargeFire(Target target)
{
this.target = target;
}
public override Activity Tick(Actor self)
{
if (IsCanceled || !target.IsValidFor(self))
return NextActivity;
var chargeDelay = self.Info.Traits.Get<AttackChargeInfo>().ChargeDelay;
var attack = self.Trait<AttackCharge>();
if(attack.charges == 0)
return NextActivity;
attack.DoAttack(self, target);
return Util.SequenceActivities(new Wait(chargeDelay), this);
}
}
}
}

View File

@@ -1,101 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class AttackTeslaInfo : AttackOmniInfo
{
public readonly int MaxCharges = 3;
public readonly int ReloadTime = 120;
public override object Create(ActorInitializer init) { return new AttackTesla(init.self); }
}
class AttackTesla : AttackOmni, ITick, INotifyAttack, ISync
{
[Sync] int charges;
[Sync] int timeToRecharge;
public AttackTesla( Actor self )
: base( self )
{
charges = self.Info.Traits.Get<AttackTeslaInfo>().MaxCharges;
}
public override void Tick( Actor self )
{
if( --timeToRecharge <= 0 )
charges = self.Info.Traits.Get<AttackTeslaInfo>().MaxCharges;
base.Tick( self );
}
public void Attacking(Actor self, Target target, Armament a, Barrel barrel)
{
--charges;
timeToRecharge = self.Info.Traits.Get<AttackTeslaInfo>().ReloadTime;
}
public override Activity GetAttackActivity( Actor self, Target newTarget, bool allowMove )
{
return new TeslaAttack( newTarget );
}
public override void ResolveOrder(Actor self, Order order)
{
base.ResolveOrder(self, order);
if (order.OrderString == "Stop")
self.CancelActivity();
}
class TeslaAttack : Activity
{
readonly Target target;
public TeslaAttack( Target target ) { this.target = target; }
public override Activity Tick( Actor self )
{
if (IsCanceled || !target.IsValidFor(self))
return NextActivity;
var attack = self.Trait<AttackTesla>();
if( attack.charges == 0 || !attack.CanAttack( self, target ) )
return this;
self.Trait<RenderBuildingCharge>().PlayCharge(self);
return Util.SequenceActivities( new Wait( 22 ), new TeslaZap( target ), this );
}
}
class TeslaZap : Activity
{
readonly Target target;
public TeslaZap( Target target ) { this.target = target; }
public override Activity Tick( Actor self )
{
if (IsCanceled || !target.IsValidFor(self))
return NextActivity;
var attack = self.Trait<AttackTesla>();
if( attack.charges == 0 ) return NextActivity;
attack.DoAttack( self, target );
return Util.SequenceActivities( new Wait( 3 ), this );
}
}
}
}

View File

@@ -156,7 +156,7 @@
<Compile Include="Attack\AttackMedic.cs" /> <Compile Include="Attack\AttackMedic.cs" />
<Compile Include="Attack\AttackOmni.cs" /> <Compile Include="Attack\AttackOmni.cs" />
<Compile Include="Attack\AttackPopupTurreted.cs" /> <Compile Include="Attack\AttackPopupTurreted.cs" />
<Compile Include="Attack\AttackTesla.cs" /> <Compile Include="Attack\AttackCharge.cs" />
<Compile Include="Attack\AttackTurreted.cs" /> <Compile Include="Attack\AttackTurreted.cs" />
<Compile Include="Attack\AttackWander.cs" /> <Compile Include="Attack\AttackWander.cs" />
<Compile Include="AutoHeal.cs" /> <Compile Include="AutoHeal.cs" />

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information #region Copyright & License Information
/* /*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made * This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
@@ -8,15 +8,20 @@
*/ */
#endregion #endregion
using OpenRA.FileFormats;
namespace OpenRA.Mods.RA.Render namespace OpenRA.Mods.RA.Render
{ {
public class RenderBuildingChargeInfo : RenderBuildingInfo public class RenderBuildingChargeInfo : RenderBuildingInfo
{ {
public readonly string ChargeAudio = "tslachg2.aud"; [Desc("Sound to play when building charges.")]
public readonly string ChargeAudio = null;
[Desc("Sequence to use for building charge animation.")]
public readonly string ChargeSequence = "active";
public override object Create(ActorInitializer init) { return new RenderBuildingCharge(init, this); } public override object Create(ActorInitializer init) { return new RenderBuildingCharge(init, this); }
} }
/* used for tesla */ /* used for tesla and obelisk */
public class RenderBuildingCharge : RenderBuilding public class RenderBuildingCharge : RenderBuilding
{ {
RenderBuildingChargeInfo info; RenderBuildingChargeInfo info;
@@ -30,7 +35,7 @@ namespace OpenRA.Mods.RA.Render
public void PlayCharge(Actor self) public void PlayCharge(Actor self)
{ {
Sound.Play(info.ChargeAudio, self.CenterPosition); Sound.Play(info.ChargeAudio, self.CenterPosition);
anim.PlayThen(NormalizeSequence(self, "active"), anim.PlayThen(NormalizeSequence(self, info.ChargeSequence),
() => anim.PlayRepeating(NormalizeSequence(self, "idle"))); () => anim.PlayRepeating(NormalizeSequence(self, "idle")));
} }
} }

View File

@@ -106,6 +106,19 @@ namespace OpenRA.Utility
} }
} }
// AttackTesla was replaced with AttackCharge
if (engineVersion < 20140307)
{
if (depth == 1 && parentKey == "World")
{
if (node.Key == "AttackTesla")
node.Key = "AttackCharge";
if (node.Key == "-AttackTesla")
node.Key = "-AttackCharge";
}
}
// AttackMove was generalized to support all moveable actor types // AttackMove was generalized to support all moveable actor types
if (engineVersion < 20140116) if (engineVersion < 20140116)
{ {

View File

@@ -600,10 +600,10 @@ OBLI:
Armament: Armament:
Weapon: Laser Weapon: Laser
LocalOffset: 0,0,725 LocalOffset: 0,0,725
FireDelay: 8 FireDelay: 25
AttackTesla: AttackCharge:
MaxCharge: 1
ReloadTime: 90 ReloadTime: 90
InitialChargeDelay: 25
AutoTarget: AutoTarget:
-RenderBuilding: -RenderBuilding:
RenderRangeCircle: RenderRangeCircle:

View File

@@ -340,11 +340,11 @@ obli:
active: active:
Start: 0 Start: 0
Length: 4 Length: 4
Tick: 400 Tick: 680
damaged-active: damaged-active:
Start: 4 Start: 4
Length: 4 Length: 4
Tick: 400 Tick: 680
dead: dead:
Start: 8 Start: 8
make: oblimake make: oblimake

View File

@@ -303,10 +303,12 @@ TSLA:
RevealsShroud: RevealsShroud:
Range: 8c0 Range: 8c0
RenderBuildingCharge: RenderBuildingCharge:
ChargeAudio: tslachg2.aud
Armament: Armament:
Weapon: TeslaZap Weapon: TeslaZap
LocalOffset: 0,0,427 LocalOffset: 0,0,427
AttackTesla: AttackCharge:
MaxCharges: 3
ReloadTime: 120 ReloadTime: 120
AutoTarget: AutoTarget:
IronCurtainable: IronCurtainable: