Merge pull request #9509 from penev92/upgradeTickTank
Convert Tick Tank to use DeployToUpgrade + some fixes
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
@@ -19,8 +20,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
/* non-turreted attack */
|
/* non-turreted attack */
|
||||||
public class Attack : Activity
|
public class Attack : Activity
|
||||||
{
|
{
|
||||||
|
[Flags]
|
||||||
|
enum AttackStatus { UnableToAttack, NeedsToTurn, NeedsToMove, Attacking }
|
||||||
|
|
||||||
protected readonly Target Target;
|
protected readonly Target Target;
|
||||||
readonly AttackBase attack;
|
readonly AttackBase[] attackTraits;
|
||||||
readonly IMove move;
|
readonly IMove move;
|
||||||
readonly IFacing facing;
|
readonly IFacing facing;
|
||||||
readonly IPositionable positionable;
|
readonly IPositionable positionable;
|
||||||
@@ -28,6 +32,9 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
WDist minRange;
|
WDist minRange;
|
||||||
WDist maxRange;
|
WDist maxRange;
|
||||||
|
Activity turnActivity;
|
||||||
|
Activity moveActivity;
|
||||||
|
AttackStatus attackStatus = AttackStatus.UnableToAttack;
|
||||||
|
|
||||||
public Attack(Actor self, Target target, bool allowMovement, bool forceAttack)
|
public Attack(Actor self, Target target, bool allowMovement, bool forceAttack)
|
||||||
{
|
{
|
||||||
@@ -35,7 +42,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
this.forceAttack = forceAttack;
|
this.forceAttack = forceAttack;
|
||||||
|
|
||||||
attack = self.Trait<AttackBase>();
|
attackTraits = self.TraitsImplementing<AttackBase>().ToArray();
|
||||||
facing = self.Trait<IFacing>();
|
facing = self.Trait<IFacing>();
|
||||||
positionable = self.Trait<IPositionable>();
|
positionable = self.Trait<IPositionable>();
|
||||||
|
|
||||||
@@ -44,9 +51,25 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
var ret = InnerTick(self, attack);
|
turnActivity = moveActivity = null;
|
||||||
attack.IsAttacking = ret == this;
|
attackStatus = AttackStatus.UnableToAttack;
|
||||||
return ret;
|
|
||||||
|
foreach (var attack in attackTraits.Where(x => !x.IsTraitDisabled))
|
||||||
|
{
|
||||||
|
var activity = InnerTick(self, attack);
|
||||||
|
attack.IsAttacking = activity == this;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attackStatus.HasFlag(AttackStatus.Attacking))
|
||||||
|
return this;
|
||||||
|
|
||||||
|
if (attackStatus.HasFlag(AttackStatus.NeedsToTurn))
|
||||||
|
return turnActivity;
|
||||||
|
|
||||||
|
if (attackStatus.HasFlag(AttackStatus.NeedsToMove))
|
||||||
|
return moveActivity;
|
||||||
|
|
||||||
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Activity InnerTick(Actor self, AttackBase attack)
|
protected virtual Activity InnerTick(Actor self, AttackBase attack)
|
||||||
@@ -82,13 +105,21 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
// Try to move within range, drop the target otherwise
|
// Try to move within range, drop the target otherwise
|
||||||
if (move == null)
|
if (move == null)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
return ActivityUtils.SequenceActivities(move.MoveWithinRange(Target, minRange, maxRange), this);
|
|
||||||
|
attackStatus |= AttackStatus.NeedsToMove;
|
||||||
|
moveActivity = ActivityUtils.SequenceActivities(move.MoveWithinRange(Target, minRange, maxRange), this);
|
||||||
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
var desiredFacing = (Target.CenterPosition - self.CenterPosition).Yaw.Facing;
|
var desiredFacing = (Target.CenterPosition - self.CenterPosition).Yaw.Facing;
|
||||||
if (facing.Facing != desiredFacing)
|
if (facing.Facing != desiredFacing)
|
||||||
return ActivityUtils.SequenceActivities(new Turn(self, desiredFacing), this);
|
{
|
||||||
|
attackStatus |= AttackStatus.NeedsToTurn;
|
||||||
|
turnActivity = ActivityUtils.SequenceActivities(new Turn(self, desiredFacing), this);
|
||||||
|
return NextActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
attackStatus |= AttackStatus.Attacking;
|
||||||
attack.DoAttack(self, Target, armaments);
|
attack.DoAttack(self, Target, armaments);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public virtual void Tick(Actor self)
|
public virtual void Tick(Actor self)
|
||||||
{
|
{
|
||||||
|
if (IsTraitDisabled)
|
||||||
|
{
|
||||||
|
Target = Target.Invalid;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DoAttack(self, Target);
|
DoAttack(self, Target);
|
||||||
IsAttacking = Target.IsValidFor(self);
|
IsAttacking = Target.IsValidFor(self);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,17 +28,15 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public class CombatDebugOverlay : IPostRender, INotifyDamage, INotifyCreated
|
public class CombatDebugOverlay : IPostRender, INotifyDamage, INotifyCreated
|
||||||
{
|
{
|
||||||
readonly DeveloperMode devMode;
|
readonly DeveloperMode devMode;
|
||||||
|
|
||||||
readonly HealthInfo healthInfo;
|
readonly HealthInfo healthInfo;
|
||||||
|
readonly Lazy<BodyOrientation> coords;
|
||||||
|
|
||||||
IBlocksProjectiles[] allBlockers;
|
IBlocksProjectiles[] allBlockers;
|
||||||
Lazy<AttackBase> attack;
|
|
||||||
Lazy<BodyOrientation> coords;
|
|
||||||
|
|
||||||
public CombatDebugOverlay(Actor self)
|
public CombatDebugOverlay(Actor self)
|
||||||
{
|
{
|
||||||
healthInfo = self.Info.TraitInfoOrDefault<HealthInfo>();
|
healthInfo = self.Info.TraitInfoOrDefault<HealthInfo>();
|
||||||
attack = Exts.Lazy(() => self.TraitOrDefault<AttackBase>());
|
coords = Exts.Lazy(self.Trait<BodyOrientation>);
|
||||||
coords = Exts.Lazy(() => self.Trait<BodyOrientation>());
|
|
||||||
|
|
||||||
var localPlayer = self.World.LocalPlayer;
|
var localPlayer = self.World.LocalPlayer;
|
||||||
devMode = localPlayer != null ? localPlayer.PlayerActor.Trait<DeveloperMode>() : null;
|
devMode = localPlayer != null ? localPlayer.PlayerActor.Trait<DeveloperMode>() : null;
|
||||||
@@ -72,14 +70,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
TargetLineRenderable.DrawTargetMarker(wr, hc, hb);
|
TargetLineRenderable.DrawTargetMarker(wr, hc, hb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No armaments to draw
|
foreach (var attack in self.TraitsImplementing<AttackBase>().Where(x => !x.IsTraitDisabled))
|
||||||
if (attack.Value == null)
|
DrawArmaments(self, attack, wr, wcr, iz);
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
void DrawArmaments(Actor self, AttackBase attack, WorldRenderer wr, RgbaColorRenderer wcr, float iz)
|
||||||
|
{
|
||||||
var c = Color.White;
|
var c = Color.White;
|
||||||
|
|
||||||
// Fire ports on garrisonable structures
|
// Fire ports on garrisonable structures
|
||||||
var garrison = attack.Value as AttackGarrisoned;
|
var garrison = attack as AttackGarrisoned;
|
||||||
if (garrison != null)
|
if (garrison != null)
|
||||||
{
|
{
|
||||||
var bodyOrientation = coords.Value.QuantizeOrientation(self, self.Orientation);
|
var bodyOrientation = coords.Value.QuantizeOrientation(self, self.Orientation);
|
||||||
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var a in attack.Value.Armaments)
|
foreach (var a in attack.Armaments)
|
||||||
{
|
{
|
||||||
foreach (var b in a.Barrels)
|
foreach (var b in a.Barrels)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -150,6 +150,12 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
{ 0x03, new byte[] { 0x7E } }
|
{ 0x03, new byte[] { 0x7E } }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static readonly Dictionary<string, string> DeployableActors = new Dictionary<string, string>()
|
||||||
|
{
|
||||||
|
{ "gadpsa", "lpst" },
|
||||||
|
{ "gatick", "ttnk" }
|
||||||
|
};
|
||||||
|
|
||||||
[Desc("FILENAME", "Convert a Tiberian Sun map to the OpenRA format.")]
|
[Desc("FILENAME", "Convert a Tiberian Sun map to the OpenRA format.")]
|
||||||
public void Run(ModData modData, string[] args)
|
public void Run(ModData modData, string[] args)
|
||||||
{
|
{
|
||||||
@@ -388,9 +394,17 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
var structuresSection = file.GetSection(type, true);
|
var structuresSection = file.GetSection(type, true);
|
||||||
foreach (var kv in structuresSection)
|
foreach (var kv in structuresSection)
|
||||||
{
|
{
|
||||||
|
var isDeployed = false;
|
||||||
var entries = kv.Value.Split(',');
|
var entries = kv.Value.Split(',');
|
||||||
|
|
||||||
var name = entries[1].ToLowerInvariant();
|
var name = entries[1].ToLowerInvariant();
|
||||||
|
|
||||||
|
if (DeployableActors.ContainsKey(name))
|
||||||
|
{
|
||||||
|
name = DeployableActors[name];
|
||||||
|
isDeployed = true;
|
||||||
|
}
|
||||||
|
|
||||||
var health = short.Parse(entries[2]);
|
var health = short.Parse(entries[2]);
|
||||||
var rx = int.Parse(entries[3]);
|
var rx = int.Parse(entries[3]);
|
||||||
var ry = int.Parse(entries[4]);
|
var ry = int.Parse(entries[4]);
|
||||||
@@ -408,6 +422,9 @@ namespace OpenRA.Mods.TS.UtilityCommands
|
|||||||
new FacingInit(facing),
|
new FacingInit(facing),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (isDeployed)
|
||||||
|
ar.Add(new DeployStateInit(DeployState.Deployed));
|
||||||
|
|
||||||
if (!map.Rules.Actors.ContainsKey(name))
|
if (!map.Rules.Actors.ContainsKey(name))
|
||||||
Console.WriteLine("Ignoring unknown actor type: `{0}`".F(name));
|
Console.WriteLine("Ignoring unknown actor type: `{0}`".F(name));
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -163,49 +163,6 @@ NASAM:
|
|||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
VisualBounds: 40, 36, -3, -8
|
VisualBounds: 40, 36, -3, -8
|
||||||
|
|
||||||
GATICK:
|
|
||||||
Inherits: ^DeployedVehicle
|
|
||||||
Valued:
|
|
||||||
Cost: 800
|
|
||||||
Tooltip:
|
|
||||||
Name: Tick Tank
|
|
||||||
Health:
|
|
||||||
HP: 350
|
|
||||||
Armor:
|
|
||||||
Type: Concrete
|
|
||||||
RevealsShroud:
|
|
||||||
Range: 5c0
|
|
||||||
Turreted:
|
|
||||||
ROT: 6
|
|
||||||
InitialFacing: 224
|
|
||||||
Offset: 0,96,224
|
|
||||||
Armament@PRIMARY:
|
|
||||||
Weapon: 90mm
|
|
||||||
LocalOffset: 448,0,348
|
|
||||||
UpgradeTypes: eliteweapon
|
|
||||||
UpgradeMaxEnabledLevel: 0
|
|
||||||
UpgradeMaxAcceptedLevel: 1
|
|
||||||
MuzzleSequence: muzzle
|
|
||||||
Armament@ELITE:
|
|
||||||
Weapon: 120mmx
|
|
||||||
LocalOffset: 448,0,348
|
|
||||||
UpgradeTypes: eliteweapon
|
|
||||||
UpgradeMinEnabledLevel: 1
|
|
||||||
MuzzleSequence: muzzle
|
|
||||||
BodyOrientation:
|
|
||||||
QuantizedFacings: 32
|
|
||||||
RenderVoxels:
|
|
||||||
WithVoxelBarrel:
|
|
||||||
LocalOffset: 128,0,348
|
|
||||||
WithVoxelTurret:
|
|
||||||
Transforms:
|
|
||||||
IntoActor: ttnk
|
|
||||||
Facing: 159
|
|
||||||
TransformSounds: place2.aud
|
|
||||||
NoTransformSounds:
|
|
||||||
Voice: Move
|
|
||||||
WithMuzzleOverlay:
|
|
||||||
|
|
||||||
GAARTY:
|
GAARTY:
|
||||||
Inherits@1: ^DeployedVehicle
|
Inherits@1: ^DeployedVehicle
|
||||||
Valued:
|
Valued:
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ TTNK:
|
|||||||
HP: 350
|
HP: 350
|
||||||
Armor:
|
Armor:
|
||||||
Type: Light
|
Type: Light
|
||||||
AttackFrontal:
|
UpgradeTypes: undeployed
|
||||||
Voice: Attack
|
UpgradeMinEnabledLevel: 1
|
||||||
Armament@PRIMARY:
|
Armament@PRIMARY:
|
||||||
Weapon: 90mm
|
Weapon: 90mm
|
||||||
LocalOffset: 256,0,256
|
LocalOffset: 256,0,256
|
||||||
@@ -100,12 +100,67 @@ TTNK:
|
|||||||
WithMuzzleOverlay:
|
WithMuzzleOverlay:
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 5c0
|
Range: 5c0
|
||||||
Transforms:
|
RenderSprites:
|
||||||
IntoActor: gatick
|
Image: ttnk
|
||||||
Facing: 159
|
DeployToUpgrade:
|
||||||
TransformSounds: place2.aud
|
DeployedUpgrades: deployed, notmobile
|
||||||
NoTransformSounds:
|
UndeployedUpgrades: undeployed
|
||||||
Voice: Move
|
DeployAnimation: make
|
||||||
|
Facing: 160
|
||||||
|
AllowedTerrainTypes: Clear, Road, DirtRoad, Rough
|
||||||
|
DeploySound: place2.aud
|
||||||
|
UndeploySound: clicky1.aud
|
||||||
|
WithVoxelBody:
|
||||||
|
UpgradeTypes: undeployed
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
WithSpriteBody@deployed:
|
||||||
|
UpgradeTypes: undeployed
|
||||||
|
UpgradeMaxEnabledLevel: 0
|
||||||
|
AttackFrontal:
|
||||||
|
Voice: Attack
|
||||||
|
UpgradeTypes: undeployed
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
UpgradeMaxAcceptedLevel: 1
|
||||||
|
Turreted:
|
||||||
|
ROT: 6
|
||||||
|
Turret: deployed
|
||||||
|
InitialFacing: 128
|
||||||
|
Offset: -20, -130, 180
|
||||||
|
WithVoxelBarrel:
|
||||||
|
Armament: deployed
|
||||||
|
LocalOffset: 128, 0, 256
|
||||||
|
UpgradeTypes: deployed
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
WithVoxelTurret@deployed:
|
||||||
|
Turret: deployed
|
||||||
|
UpgradeTypes: deployed
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
AttackTurreted@deployed:
|
||||||
|
Voice: Attack
|
||||||
|
Armaments: deployed
|
||||||
|
UpgradeTypes: deployed
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
Armament@deployed:
|
||||||
|
Name: deployed
|
||||||
|
Turret: deployed
|
||||||
|
Weapon: 90mm
|
||||||
|
LocalOffset: 384,0,256
|
||||||
|
UpgradeTypes: eliteweapon
|
||||||
|
UpgradeMaxEnabledLevel: 0
|
||||||
|
UpgradeMaxAcceptedLevel: 1
|
||||||
|
MuzzleSequence: muzzle
|
||||||
|
Armament@deployedElite:
|
||||||
|
Name: deployed
|
||||||
|
Turret: deployed
|
||||||
|
Weapon: 120mmx
|
||||||
|
LocalOffset: 384,0,256
|
||||||
|
UpgradeTypes: eliteweapon
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
MuzzleSequence: muzzle
|
||||||
|
Armor@deployed:
|
||||||
|
Type: Concrete
|
||||||
|
UpgradeTypes: deployed
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
|
||||||
ART2:
|
ART2:
|
||||||
Inherits: ^VoxelTank
|
Inherits: ^VoxelTank
|
||||||
|
|||||||
@@ -735,29 +735,6 @@ nawall:
|
|||||||
Offset: 0, 0
|
Offset: 0, 0
|
||||||
UseTilesetCode: false
|
UseTilesetCode: false
|
||||||
|
|
||||||
gatick:
|
|
||||||
Defaults:
|
|
||||||
Offset: 0, -13
|
|
||||||
UseTilesetCode: true
|
|
||||||
idle:
|
|
||||||
ShadowStart: 3
|
|
||||||
damaged-idle:
|
|
||||||
Start: 1
|
|
||||||
ShadowStart: 4
|
|
||||||
muzzle: gunfire
|
|
||||||
Length: *
|
|
||||||
Offset: 0, 0
|
|
||||||
UseTilesetCode: false
|
|
||||||
emp-overlay: emp_fx01
|
|
||||||
Length: *
|
|
||||||
Offset: 0, 0
|
|
||||||
UseTilesetCode: false
|
|
||||||
ZOffset: 512
|
|
||||||
BlendMode: Additive
|
|
||||||
make: gatickmk
|
|
||||||
Length: 24
|
|
||||||
ShadowStart: 24
|
|
||||||
|
|
||||||
gaicbm:
|
gaicbm:
|
||||||
Defaults:
|
Defaults:
|
||||||
Offset: 0, -12
|
Offset: 0, -12
|
||||||
|
|||||||
@@ -135,6 +135,17 @@ sonic:
|
|||||||
icon: soniicon
|
icon: soniicon
|
||||||
|
|
||||||
ttnk:
|
ttnk:
|
||||||
|
idle: gatick
|
||||||
|
ShadowStart: 3
|
||||||
|
Offset: 0, -12
|
||||||
|
damaged-idle: gatick
|
||||||
|
Start: 1
|
||||||
|
ShadowStart: 4
|
||||||
|
Offset: 0, -12
|
||||||
|
make: gatickmk
|
||||||
|
Length: 24
|
||||||
|
ShadowStart: 24
|
||||||
|
Offset: 0, -12
|
||||||
muzzle: gunfire
|
muzzle: gunfire
|
||||||
Length: *
|
Length: *
|
||||||
emp-overlay: emp_fx01
|
emp-overlay: emp_fx01
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ bike:
|
|||||||
|
|
||||||
ttnk:
|
ttnk:
|
||||||
idle:
|
idle:
|
||||||
|
|
||||||
gatick:
|
|
||||||
turret: ttnktur
|
turret: ttnktur
|
||||||
barrel: ttnkbarl
|
barrel: ttnkbarl
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user