CarpetBomb -> AttackBomber.

This commit is contained in:
Paul Chote
2013-10-31 22:13:14 +13:00
parent d7effe71da
commit 47209f5848
13 changed files with 71 additions and 92 deletions

View File

@@ -101,7 +101,8 @@ namespace OpenRA.Mods.RA
// The world coordinate model uses Actor.Orientation
public void CheckFire(Actor self, AttackBase attack, IFacing facing, Target target)
{
if (FireDelay > 0) return;
if (FireDelay > 0)
return;
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
@@ -113,7 +114,7 @@ namespace OpenRA.Mods.RA
if (!target.IsInRange(self.CenterPosition, range))
return;
if (target.IsInRange(self.CenterPosition, minRange))
if (minRange != WRange.Zero && target.IsInRange(self.CenterPosition, minRange))
return;
if (!Weapon.IsValidAgainst(target, self.World))

View 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");
}
}
}

View File

@@ -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);
}
}
}
}

View File

@@ -98,7 +98,7 @@ namespace OpenRA.Mods.RA.Missions
new FacingInit(Util.GetFacing(location - entry, 0)),
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(new FlyOffMap());
badger.QueueActivity(new RemoveSelf());

View File

@@ -179,7 +179,6 @@
<Compile Include="Capturable.cs" />
<Compile Include="ExternalCaptures.cs" />
<Compile Include="Cargo.cs" />
<Compile Include="CarpetBomb.cs" />
<Compile Include="CashTrickler.cs" />
<Compile Include="ChronoshiftDeploy.cs" />
<Compile Include="ChronoshiftPaletteEffect.cs" />
@@ -472,6 +471,7 @@
<Compile Include="World\PathfinderDebugOverlay.cs" />
<Compile Include="Effects\ContrailFader.cs" />
<Compile Include="Widgets\Logic\SettingsLogic.cs" />
<Compile Include="AttackBomber.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA
new FacingInit(attackFacing),
});
a.Trait<CarpetBomb>().SetTarget(target + targetOffset);
a.Trait<AttackBomber>().SetTarget(target + targetOffset);
if (flare != null)
a.QueueActivity(new CallFunc(() => flare.Destroy()));

View File

@@ -187,9 +187,9 @@ A10:
WithShadow:
LimitedAmmo:
Ammo: 10
CarpetBomb:
AttackBomber:
Armament:
Weapon: Napalm
Range: 3
-Selectable:
-GainsExperience:
FlyAwayOnIdle:

View File

@@ -727,6 +727,7 @@ TowerMissle:
Napalm:
ROF: 2
Range: 3
Projectile: GravityBomb
Image: BOMBLET
Warhead:

View File

@@ -94,8 +94,8 @@ ORNI:
HuskActor: ORNI.Husk
ORNI.bomber:
CarpetBomb:
Range: 3
AttackBomber:
Armament:
Weapon: Napalm
Inherits: ^Plane
Health:

View File

@@ -482,6 +482,7 @@ ParaBomb:
Napalm:
ROF: 2
Range: 3
Projectile: GravityBomb
Image: BOMBS
Warhead:

View File

@@ -1002,8 +1002,8 @@ Rules:
Armor:
Type: Concrete
BADR.Bomber:
CarpetBomb:
Range: 3
AttackBomber:
Armament:
Weapon: ParaBomb
Inherits: ^Plane
Health:

View File

@@ -36,8 +36,8 @@ BADR:
RejectsOrders:
BADR.Bomber:
CarpetBomb:
Range: 3
AttackBomber:
Armament:
Weapon: ParaBomb
Inherits: ^Plane
Health:

View File

@@ -898,7 +898,7 @@ DepthCharge:
ParaBomb:
ROF: 10
Range: 4.5
Range: 3
Report: CHUTE1.AUD
Projectile: GravityBomb
Image: PARABOMB