from mirey: pilot parachutes from shot down plane, sometimes
This commit is contained in:
61
OpenRA.Mods.RA/Air/EjectOnDeath.cs
Normal file
61
OpenRA.Mods.RA/Air/EjectOnDeath.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProductVersion>9.0.30729</ProductVersion>
|
<ProductVersion>9.0.21022</ProductVersion>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
<ProjectGuid>{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}</ProjectGuid>
|
<ProjectGuid>{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
@@ -63,6 +63,7 @@
|
|||||||
<Compile Include="Activities\Enter.cs" />
|
<Compile Include="Activities\Enter.cs" />
|
||||||
<Compile Include="Activities\EnterTransport.cs" />
|
<Compile Include="Activities\EnterTransport.cs" />
|
||||||
<Compile Include="Air\FlyCircle.cs" />
|
<Compile Include="Air\FlyCircle.cs" />
|
||||||
|
<Compile Include="Air\EjectOnDeath.cs" />
|
||||||
<Compile Include="Buildings\Sellable.cs" />
|
<Compile Include="Buildings\Sellable.cs" />
|
||||||
<Compile Include="Effects\CashTick.cs" />
|
<Compile Include="Effects\CashTick.cs" />
|
||||||
<Compile Include="Lint\LintBuildablePrerequisites.cs" />
|
<Compile Include="Lint\LintBuildablePrerequisites.cs" />
|
||||||
|
|||||||
@@ -136,6 +136,9 @@
|
|||||||
DebugAircraftAltitude:
|
DebugAircraftAltitude:
|
||||||
ProximityCaptor:
|
ProximityCaptor:
|
||||||
Types:Plane
|
Types:Plane
|
||||||
|
EjectOnDeath:
|
||||||
|
PilotActor: E1
|
||||||
|
SuccessRate: 50
|
||||||
|
|
||||||
^Building:
|
^Building:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ BADR:
|
|||||||
SmokeTrailWhenDamaged@1:
|
SmokeTrailWhenDamaged@1:
|
||||||
Offset: -11, -11
|
Offset: -11, -11
|
||||||
Interval: 2
|
Interval: 2
|
||||||
|
-EjectOnDeath:
|
||||||
|
|
||||||
BADR.bomber:
|
BADR.bomber:
|
||||||
CarpetBomb:
|
CarpetBomb:
|
||||||
@@ -72,6 +73,7 @@ BADR.bomber:
|
|||||||
SmokeTrailWhenDamaged@1:
|
SmokeTrailWhenDamaged@1:
|
||||||
Offset: -11, -11
|
Offset: -11, -11
|
||||||
Interval: 2
|
Interval: 2
|
||||||
|
-EjectOnDeath:
|
||||||
|
|
||||||
V2RL:
|
V2RL:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Vehicle
|
||||||
|
|||||||
Reference in New Issue
Block a user