CarpetBomb -> AttackBomber.
This commit is contained in:
@@ -101,7 +101,8 @@ namespace OpenRA.Mods.RA
|
|||||||
// The world coordinate model uses Actor.Orientation
|
// The world coordinate model uses Actor.Orientation
|
||||||
public void CheckFire(Actor self, AttackBase attack, IFacing facing, Target target)
|
public void CheckFire(Actor self, AttackBase attack, IFacing facing, Target target)
|
||||||
{
|
{
|
||||||
if (FireDelay > 0) return;
|
if (FireDelay > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||||
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
||||||
@@ -113,7 +114,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (!target.IsInRange(self.CenterPosition, range))
|
if (!target.IsInRange(self.CenterPosition, range))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (target.IsInRange(self.CenterPosition, minRange))
|
if (minRange != WRange.Zero && target.IsInRange(self.CenterPosition, minRange))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!Weapon.IsValidAgainst(target, self.World))
|
if (!Weapon.IsValidAgainst(target, self.World))
|
||||||
|
|||||||
54
OpenRA.Mods.RA/AttackBomber.cs
Normal file
54
OpenRA.Mods.RA/AttackBomber.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2013 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 System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.GameRules;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA
|
||||||
|
{
|
||||||
|
class AttackBomberInfo : AttackBaseInfo
|
||||||
|
{
|
||||||
|
public override object Create(ActorInitializer init) { return new AttackBomber(init.self); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class AttackBomber : AttackBase, ISync
|
||||||
|
{
|
||||||
|
[Sync] Target target;
|
||||||
|
|
||||||
|
public AttackBomber(Actor self)
|
||||||
|
: base(self) { }
|
||||||
|
|
||||||
|
public override void Tick(Actor self)
|
||||||
|
{
|
||||||
|
base.Tick(self);
|
||||||
|
|
||||||
|
if (!target.IsInRange(self.CenterPosition, GetMaximumRange()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var facing = self.TraitOrDefault<IFacing>();
|
||||||
|
var cp = self.CenterPosition;
|
||||||
|
var t = Target.FromPos(cp - new WVec(0, 0, cp.Z));
|
||||||
|
foreach (var a in Armaments)
|
||||||
|
a.CheckFire(self, this, facing, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTarget(WPos pos) { target = Target.FromPos(pos); }
|
||||||
|
|
||||||
|
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||||
|
{
|
||||||
|
// TODO: Player controlled units want this too!
|
||||||
|
throw new NotImplementedException("CarpetBomb requires a scripted target");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,78 +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 System.Linq;
|
|
||||||
using OpenRA.GameRules;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
|
||||||
{
|
|
||||||
class CarpetBombInfo : ITraitInfo
|
|
||||||
{
|
|
||||||
[WeaponReference]
|
|
||||||
public readonly string Weapon = null;
|
|
||||||
public readonly int Range = 3;
|
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new CarpetBomb(this); }
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: maybe integrate this better with the normal weapons system?
|
|
||||||
class CarpetBomb : ITick, ISync
|
|
||||||
{
|
|
||||||
CarpetBombInfo info;
|
|
||||||
Target target;
|
|
||||||
|
|
||||||
[Sync] int dropDelay;
|
|
||||||
[Sync] WRange range;
|
|
||||||
|
|
||||||
public CarpetBomb(CarpetBombInfo info)
|
|
||||||
{
|
|
||||||
this.info = info;
|
|
||||||
|
|
||||||
// TODO: Push this conversion into the yaml
|
|
||||||
range = WRange.FromCells(info.Range);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetTarget(CPos targetCell) { target = Target.FromCell(targetCell); }
|
|
||||||
public void SetTarget(WPos pos) { target = Target.FromPos(pos); }
|
|
||||||
|
|
||||||
public void Tick(Actor self)
|
|
||||||
{
|
|
||||||
if (!target.IsInRange(self.CenterPosition, range))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
|
||||||
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (--dropDelay <= 0)
|
|
||||||
{
|
|
||||||
var weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()];
|
|
||||||
dropDelay = weapon.ROF;
|
|
||||||
|
|
||||||
var pos = self.CenterPosition;
|
|
||||||
var args = new ProjectileArgs
|
|
||||||
{
|
|
||||||
Weapon = weapon,
|
|
||||||
Facing = self.Trait<IFacing>().Facing,
|
|
||||||
|
|
||||||
Source = pos,
|
|
||||||
SourceActor = self,
|
|
||||||
PassiveTarget = pos - new WVec(0, 0, pos.Z)
|
|
||||||
};
|
|
||||||
|
|
||||||
self.World.Add(args.Weapon.Projectile.Create(args));
|
|
||||||
|
|
||||||
if (args.Weapon.Report != null && args.Weapon.Report.Any())
|
|
||||||
Sound.Play(args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
new FacingInit(Util.GetFacing(location - entry, 0)),
|
new FacingInit(Util.GetFacing(location - entry, 0)),
|
||||||
new AltitudeInit(Rules.Info["badr.bomber"].Traits.Get<PlaneInfo>().CruiseAltitude),
|
new AltitudeInit(Rules.Info["badr.bomber"].Traits.Get<PlaneInfo>().CruiseAltitude),
|
||||||
});
|
});
|
||||||
badger.Trait<CarpetBomb>().SetTarget(location);
|
badger.Trait<AttackBomber>().SetTarget(location.CenterPosition);
|
||||||
badger.QueueActivity(Fly.ToCell(location));
|
badger.QueueActivity(Fly.ToCell(location));
|
||||||
badger.QueueActivity(new FlyOffMap());
|
badger.QueueActivity(new FlyOffMap());
|
||||||
badger.QueueActivity(new RemoveSelf());
|
badger.QueueActivity(new RemoveSelf());
|
||||||
|
|||||||
@@ -179,7 +179,6 @@
|
|||||||
<Compile Include="Capturable.cs" />
|
<Compile Include="Capturable.cs" />
|
||||||
<Compile Include="ExternalCaptures.cs" />
|
<Compile Include="ExternalCaptures.cs" />
|
||||||
<Compile Include="Cargo.cs" />
|
<Compile Include="Cargo.cs" />
|
||||||
<Compile Include="CarpetBomb.cs" />
|
|
||||||
<Compile Include="CashTrickler.cs" />
|
<Compile Include="CashTrickler.cs" />
|
||||||
<Compile Include="ChronoshiftDeploy.cs" />
|
<Compile Include="ChronoshiftDeploy.cs" />
|
||||||
<Compile Include="ChronoshiftPaletteEffect.cs" />
|
<Compile Include="ChronoshiftPaletteEffect.cs" />
|
||||||
@@ -472,6 +471,7 @@
|
|||||||
<Compile Include="World\PathfinderDebugOverlay.cs" />
|
<Compile Include="World\PathfinderDebugOverlay.cs" />
|
||||||
<Compile Include="Effects\ContrailFader.cs" />
|
<Compile Include="Effects\ContrailFader.cs" />
|
||||||
<Compile Include="Widgets\Logic\SettingsLogic.cs" />
|
<Compile Include="Widgets\Logic\SettingsLogic.cs" />
|
||||||
|
<Compile Include="AttackBomber.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA
|
|||||||
new FacingInit(attackFacing),
|
new FacingInit(attackFacing),
|
||||||
});
|
});
|
||||||
|
|
||||||
a.Trait<CarpetBomb>().SetTarget(target + targetOffset);
|
a.Trait<AttackBomber>().SetTarget(target + targetOffset);
|
||||||
|
|
||||||
if (flare != null)
|
if (flare != null)
|
||||||
a.QueueActivity(new CallFunc(() => flare.Destroy()));
|
a.QueueActivity(new CallFunc(() => flare.Destroy()));
|
||||||
|
|||||||
@@ -187,9 +187,9 @@ A10:
|
|||||||
WithShadow:
|
WithShadow:
|
||||||
LimitedAmmo:
|
LimitedAmmo:
|
||||||
Ammo: 10
|
Ammo: 10
|
||||||
CarpetBomb:
|
AttackBomber:
|
||||||
|
Armament:
|
||||||
Weapon: Napalm
|
Weapon: Napalm
|
||||||
Range: 3
|
|
||||||
-Selectable:
|
-Selectable:
|
||||||
-GainsExperience:
|
-GainsExperience:
|
||||||
FlyAwayOnIdle:
|
FlyAwayOnIdle:
|
||||||
|
|||||||
@@ -727,6 +727,7 @@ TowerMissle:
|
|||||||
|
|
||||||
Napalm:
|
Napalm:
|
||||||
ROF: 2
|
ROF: 2
|
||||||
|
Range: 3
|
||||||
Projectile: GravityBomb
|
Projectile: GravityBomb
|
||||||
Image: BOMBLET
|
Image: BOMBLET
|
||||||
Warhead:
|
Warhead:
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ ORNI:
|
|||||||
HuskActor: ORNI.Husk
|
HuskActor: ORNI.Husk
|
||||||
|
|
||||||
ORNI.bomber:
|
ORNI.bomber:
|
||||||
CarpetBomb:
|
AttackBomber:
|
||||||
Range: 3
|
Armament:
|
||||||
Weapon: Napalm
|
Weapon: Napalm
|
||||||
Inherits: ^Plane
|
Inherits: ^Plane
|
||||||
Health:
|
Health:
|
||||||
|
|||||||
@@ -482,6 +482,7 @@ ParaBomb:
|
|||||||
|
|
||||||
Napalm:
|
Napalm:
|
||||||
ROF: 2
|
ROF: 2
|
||||||
|
Range: 3
|
||||||
Projectile: GravityBomb
|
Projectile: GravityBomb
|
||||||
Image: BOMBS
|
Image: BOMBS
|
||||||
Warhead:
|
Warhead:
|
||||||
|
|||||||
@@ -1002,8 +1002,8 @@ Rules:
|
|||||||
Armor:
|
Armor:
|
||||||
Type: Concrete
|
Type: Concrete
|
||||||
BADR.Bomber:
|
BADR.Bomber:
|
||||||
CarpetBomb:
|
AttackBomber:
|
||||||
Range: 3
|
Armament:
|
||||||
Weapon: ParaBomb
|
Weapon: ParaBomb
|
||||||
Inherits: ^Plane
|
Inherits: ^Plane
|
||||||
Health:
|
Health:
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ BADR:
|
|||||||
RejectsOrders:
|
RejectsOrders:
|
||||||
|
|
||||||
BADR.Bomber:
|
BADR.Bomber:
|
||||||
CarpetBomb:
|
AttackBomber:
|
||||||
Range: 3
|
Armament:
|
||||||
Weapon: ParaBomb
|
Weapon: ParaBomb
|
||||||
Inherits: ^Plane
|
Inherits: ^Plane
|
||||||
Health:
|
Health:
|
||||||
|
|||||||
@@ -898,7 +898,7 @@ DepthCharge:
|
|||||||
|
|
||||||
ParaBomb:
|
ParaBomb:
|
||||||
ROF: 10
|
ROF: 10
|
||||||
Range: 4.5
|
Range: 3
|
||||||
Report: CHUTE1.AUD
|
Report: CHUTE1.AUD
|
||||||
Projectile: GravityBomb
|
Projectile: GravityBomb
|
||||||
Image: PARABOMB
|
Image: PARABOMB
|
||||||
|
|||||||
Reference in New Issue
Block a user