from mirey: pilot parachutes from shot down plane, sometimes

This commit is contained in:
Chris Forbes
2011-04-09 11:01:17 +12:00
parent ca81871b7b
commit 7d29d90338
4 changed files with 68 additions and 1 deletions

View File

@@ -0,0 +1,61 @@
#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.FileFormats;
using OpenRA.Mods.RA.Effects;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public class EjectOnDeathInfo : TraitInfo<EjectOnDeath>
{
public readonly string PilotActor = "E1";
public readonly int SuccessRate = 50;
public readonly string ChuteSound = "chute1.aud";
}
public class EjectOnDeath : INotifyDamage
{
public void Damaged(Actor self, AttackInfo e)
{
if (self.IsDead())
{
var a = self;
var info = self.Info.Traits.Get<EjectOnDeathInfo>();
var pilot = a.World.CreateActor(false, info.PilotActor.ToLowerInvariant(), new TypeDictionary { new OwnerInit(a.Owner) });
var r = self.World.SharedRandom.Next(1, 100);
var aircraft = a.Trait<IMove>();
if (IsSuitableCell(pilot, a.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10)
{
var rs = pilot.Trait<RenderSimple>();
a.World.AddFrameEndTask(w => w.Add(
new Parachute(pilot.Owner, rs.anim.Name,
Util.CenterOfCell(Util.CellContaining(a.CenterLocation)),
aircraft.Altitude, pilot)));
Sound.Play(info.ChuteSound, a.CenterLocation);
}
else
{
pilot.Destroy();
}
}
}
bool IsSuitableCell(Actor actorToDrop, int2 p)
{
return actorToDrop.Trait<ITeleportable>().CanEnterCell(p);
}
}
}

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -63,6 +63,7 @@
<Compile Include="Activities\Enter.cs" />
<Compile Include="Activities\EnterTransport.cs" />
<Compile Include="Air\FlyCircle.cs" />
<Compile Include="Air\EjectOnDeath.cs" />
<Compile Include="Buildings\Sellable.cs" />
<Compile Include="Effects\CashTick.cs" />
<Compile Include="Lint\LintBuildablePrerequisites.cs" />

View File

@@ -136,6 +136,9 @@
DebugAircraftAltitude:
ProximityCaptor:
Types:Plane
EjectOnDeath:
PilotActor: E1
SuccessRate: 50
^Building:
AppearsOnRadar:

View File

@@ -34,6 +34,7 @@ BADR:
SmokeTrailWhenDamaged@1:
Offset: -11, -11
Interval: 2
-EjectOnDeath:
BADR.bomber:
CarpetBomb:
@@ -72,6 +73,7 @@ BADR.bomber:
SmokeTrailWhenDamaged@1:
Offset: -11, -11
Interval: 2
-EjectOnDeath:
V2RL:
Inherits: ^Vehicle