Merge pull request #3666 from Mailaender/c4-bridges
Allow bridges to be demolished with C4
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
NEW:
|
||||
Dune 2000:
|
||||
Added the Atreides grenadier from the 1.06 patch.
|
||||
Red Alert:
|
||||
Tanya can now plant C4 on bridges.
|
||||
Tiberian Dawn:
|
||||
Commando can now plant C4 on bridges.
|
||||
Engine:
|
||||
Converted Aircraft CruiseAltitude to world coordinates.
|
||||
Converted Health Radius to world coordinates.
|
||||
@@ -9,8 +15,7 @@ NEW:
|
||||
Altitude is no longer parsed from actor templates in maps. Specify CenterPosition instead.
|
||||
Run `OpenRA.Utility.exe --upgrade-mod <mod> 20131223` to automatically upgrade mod rules.
|
||||
Run `OpenRA.Utility.exe --upgrade-map <map path> 20131223` to automatically upgrade custom map rules.
|
||||
Dune 2000:
|
||||
Added the Atreides grenadier from the 1.06 patch.
|
||||
Added a new trait Demolishable for buildings to handle the C4 demolition.
|
||||
|
||||
20131223:
|
||||
All mods:
|
||||
|
||||
@@ -77,6 +77,11 @@ namespace OpenRA.Traits
|
||||
public interface INotifyHarvest { void Harvested(Actor self, ResourceType resource); }
|
||||
|
||||
public interface IAcceptInfiltrator { void OnInfiltrate(Actor self, Actor infiltrator); }
|
||||
public interface IDemolishable
|
||||
{
|
||||
void Demolish(Actor self, Actor saboteur);
|
||||
bool IsValidTarget(Actor self, Actor saboteur);
|
||||
}
|
||||
public interface IStoreOre { int Capacity { get; } }
|
||||
public interface IToolTip
|
||||
{
|
||||
|
||||
@@ -41,8 +41,12 @@ namespace OpenRA.Mods.RA.Activities
|
||||
.Concat(self.Owner.PlayerActor.TraitsImplementing<IDamageModifier>())
|
||||
.Select(t => t.GetDamageModifier(self, null)).Product();
|
||||
|
||||
var demolishable = target.Actor.TraitOrDefault<IDemolishable>();
|
||||
if (demolishable == null || !demolishable.IsValidTarget(target.Actor, self))
|
||||
return;
|
||||
|
||||
if (modifier > 0)
|
||||
target.Actor.Kill(self);
|
||||
demolishable.Demolish(target.Actor, self);
|
||||
})));
|
||||
|
||||
return NextActivity;
|
||||
|
||||
@@ -288,5 +288,35 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void Demolish(Actor saboteur, bool continueNorth, bool continueSouth)
|
||||
{
|
||||
var initialDamage = Health.DamageState;
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
Combat.DoExplosion(saboteur, "Demolish", self.CenterPosition);
|
||||
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(15, self.CenterPosition, 6);
|
||||
self.Kill(saboteur);
|
||||
});
|
||||
|
||||
// Destroy adjacent spans (long bridges)
|
||||
if (continueNorth && northNeighbour != null)
|
||||
{
|
||||
var delay = initialDamage == DamageState.Dead || NeighbourIsDeadShore(northNeighbour) ?
|
||||
0 : Info.RepairPropagationDelay;
|
||||
|
||||
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, () =>
|
||||
northNeighbour.Demolish(saboteur, true, false))));
|
||||
}
|
||||
|
||||
if (continueSouth && southNeighbour != null)
|
||||
{
|
||||
var delay = initialDamage == DamageState.Dead || NeighbourIsDeadShore(southNeighbour) ?
|
||||
0 : Info.RepairPropagationDelay;
|
||||
|
||||
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, () =>
|
||||
southNeighbour.Demolish(saboteur, false, true))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA
|
||||
public object Create(ActorInitializer init) { return new BridgeHut(init); }
|
||||
}
|
||||
|
||||
class BridgeHut
|
||||
class BridgeHut : IDemolishable
|
||||
{
|
||||
public Bridge bridge;
|
||||
|
||||
@@ -31,6 +31,16 @@ namespace OpenRA.Mods.RA
|
||||
bridge.Repair(repairer, true, true);
|
||||
}
|
||||
|
||||
public void Demolish(Actor self, Actor saboteur)
|
||||
{
|
||||
bridge.Demolish(saboteur, true, true);
|
||||
}
|
||||
|
||||
public bool IsValidTarget(Actor self, Actor saboteur)
|
||||
{
|
||||
return BridgeDamageState == DamageState.Undamaged;
|
||||
}
|
||||
|
||||
public DamageState BridgeDamageState { get { return bridge.AggregateDamageState(); } }
|
||||
}
|
||||
}
|
||||
|
||||
34
OpenRA.Mods.RA/Buildings/Demolishable.cs
Normal file
34
OpenRA.Mods.RA/Buildings/Demolishable.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
#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 OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Desc("Handle demolitions from C4 explosives.")]
|
||||
public class DemolishableInfo : TraitInfo<Demolishable> { }
|
||||
|
||||
public class Demolishable : IDemolishable
|
||||
{
|
||||
public Demolishable() { }
|
||||
|
||||
public void Demolish(Actor self, Actor saboteur)
|
||||
{
|
||||
self.Kill(saboteur);
|
||||
}
|
||||
|
||||
public bool IsValidTarget(Actor self, Actor saboteur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public IEnumerable<IOrderTargeter> Orders
|
||||
{
|
||||
get { yield return new TargetTypeOrderTargeter("C4", "C4", 6, "c4", true, false); }
|
||||
get { yield return new C4DemolitionOrderTargeter(); }
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
@@ -56,6 +56,10 @@ namespace OpenRA.Mods.RA
|
||||
if (target.Type != TargetType.Actor)
|
||||
return;
|
||||
|
||||
var demolishable = order.TargetActor.TraitOrDefault<IDemolishable>();
|
||||
if (demolishable == null || !demolishable.IsValidTarget(target.Actor, self))
|
||||
return;
|
||||
|
||||
if (!order.Queued)
|
||||
self.CancelActivity();
|
||||
|
||||
@@ -67,5 +71,33 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
return order.OrderString == "C4" ? "Attack" : null;
|
||||
}
|
||||
|
||||
class C4DemolitionOrderTargeter : UnitOrderTargeter
|
||||
{
|
||||
public C4DemolitionOrderTargeter()
|
||||
: base("C4", 6, "c4", true, false) { }
|
||||
|
||||
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
// Obey force moving onto bridges
|
||||
if (modifiers.HasModifier(TargetModifiers.ForceMove))
|
||||
return false;
|
||||
|
||||
var demolishable = target.TraitOrDefault<IDemolishable>();
|
||||
if (demolishable == null || !demolishable.IsValidTarget(target, self))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
// TODO: Bridges don't yet support FrozenUnderFog.
|
||||
if (target.Actor.HasTrait<BridgeHut>())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,12 +125,8 @@ namespace OpenRA.Mods.RA.Missions
|
||||
startJeep.QueueActivity(new Turn(128));
|
||||
startJeep.QueueActivity(new CallFunc(() =>
|
||||
{
|
||||
var bridge = world.Actors
|
||||
.Where(a => a.HasTrait<Bridge>() && !a.IsDead())
|
||||
.ClosestTo(startJeep);
|
||||
Combat.DoExplosion(bridge, "Demolish", bridge.CenterPosition);
|
||||
world.WorldActor.Trait<ScreenShaker>().AddEffect(15, bridge.CenterPosition, 6);
|
||||
bridge.Kill(bridge);
|
||||
var bridge = world.Actors.Where(a => a.HasTrait<BridgeHut>()).ClosestTo(startJeep);
|
||||
bridge.Trait<BridgeHut>().Demolish(bridge, startJeep);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -484,6 +484,7 @@
|
||||
<Compile Include="Effects\Rank.cs" />
|
||||
<Compile Include="ShroudRenderer.cs" />
|
||||
<Compile Include="Render\WithCrateBody.cs" />
|
||||
<Compile Include="Buildings\Demolishable.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -79,6 +79,10 @@ namespace OpenRA.Mods.RA
|
||||
if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && damage != DamageState.Dead)
|
||||
return false;
|
||||
|
||||
// Obey force moving onto bridges
|
||||
if (modifiers.HasModifier(TargetModifiers.ForceMove))
|
||||
return false;
|
||||
|
||||
// Can't repair an undamaged bridge
|
||||
if (damage == DamageState.Undamaged)
|
||||
cursor = "goldwrench-blocked";
|
||||
|
||||
@@ -363,7 +363,7 @@ BRIDGEHUT:
|
||||
Bounds: 48,48
|
||||
BridgeHut:
|
||||
TargetableBuilding:
|
||||
TargetTypes: BridgeHut
|
||||
TargetTypes: BridgeHut, C4
|
||||
|
||||
C1:
|
||||
Inherits: ^CivInfantry
|
||||
@@ -455,4 +455,3 @@ VICE:
|
||||
QuantizedFacings: 8
|
||||
PoisonedByTiberium:
|
||||
Weapon: Heal
|
||||
|
||||
|
||||
@@ -353,6 +353,7 @@
|
||||
EngineerRepairable:
|
||||
Huntable:
|
||||
LuaScriptEvents:
|
||||
Demolishable:
|
||||
|
||||
^CivBuilding:
|
||||
Inherits: ^Building
|
||||
@@ -404,6 +405,8 @@
|
||||
Tooltip:
|
||||
Name: Field
|
||||
-WithBuildingExplosion:
|
||||
-TargetableBuilding:
|
||||
-Demolishable:
|
||||
RenderBuilding:
|
||||
Palette: terrain
|
||||
EditorAppearance:
|
||||
@@ -456,6 +459,7 @@
|
||||
BodyOrientation:
|
||||
FrozenUnderFog:
|
||||
LuaScriptEvents:
|
||||
Demolishable:
|
||||
|
||||
^Tree:
|
||||
Tooltip:
|
||||
|
||||
@@ -1027,3 +1027,7 @@ Claw:
|
||||
InfDeath: 1
|
||||
Damage: 60
|
||||
|
||||
Demolish:
|
||||
Warhead:
|
||||
ImpactSound: xplobig6.aud
|
||||
Explosion: building
|
||||
@@ -249,4 +249,4 @@
|
||||
WithCrumbleOverlay:
|
||||
Huntable:
|
||||
LuaScriptEvents:
|
||||
|
||||
Demolishable:
|
||||
|
||||
@@ -384,6 +384,7 @@
|
||||
Sellable:
|
||||
Guardable:
|
||||
BodyOrientation:
|
||||
Demolishable:
|
||||
|
||||
WALL:
|
||||
Inherits: ^WALL
|
||||
|
||||
@@ -488,7 +488,7 @@ BRIDGEHUT:
|
||||
Bounds: 48,48
|
||||
BridgeHut:
|
||||
TargetableBuilding:
|
||||
TargetTypes: BridgeHut
|
||||
TargetTypes: BridgeHut, C4
|
||||
|
||||
BRIDGEHUT.small:
|
||||
Building:
|
||||
@@ -499,7 +499,7 @@ BRIDGEHUT.small:
|
||||
Bounds: 24,24
|
||||
BridgeHut:
|
||||
TargetableBuilding:
|
||||
TargetTypes: BridgeHut
|
||||
TargetTypes: BridgeHut, C4
|
||||
|
||||
V20:
|
||||
Inherits: ^DesertCivBuilding
|
||||
|
||||
@@ -264,6 +264,7 @@
|
||||
String: Structure
|
||||
Huntable:
|
||||
LuaScriptEvents:
|
||||
Demolishable:
|
||||
|
||||
^Wall:
|
||||
AppearsOnRadar:
|
||||
@@ -300,6 +301,7 @@
|
||||
BodyOrientation:
|
||||
FrozenUnderFog:
|
||||
LuaScriptEvents:
|
||||
Demolishable:
|
||||
|
||||
^TechBuilding:
|
||||
Inherits: ^Building
|
||||
@@ -375,6 +377,8 @@
|
||||
-Selectable:
|
||||
Tooltip:
|
||||
Name: Field
|
||||
-TargetableBuilding:
|
||||
-Demolishable:
|
||||
-ProximityCaptor:
|
||||
ProximityCaptor:
|
||||
Types: CivilianField
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
BodyOrientation:
|
||||
Huntable:
|
||||
LuaScriptEvents:
|
||||
Demolishable:
|
||||
|
||||
^Infantry:
|
||||
AppearsOnRadar:
|
||||
@@ -176,6 +177,7 @@
|
||||
UpdatesPlayerStatistics:
|
||||
BodyOrientation:
|
||||
LuaScriptEvents:
|
||||
Demolishable:
|
||||
|
||||
^Helicopter:
|
||||
AppearsOnRadar:
|
||||
|
||||
Reference in New Issue
Block a user