EjectOnDeath works with air & ground vehicles, updated defaults.yaml
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Mods.RA.Effects;
|
using OpenRA.Mods.RA.Effects;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -20,33 +21,45 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly string PilotActor = "E1";
|
public readonly string PilotActor = "E1";
|
||||||
public readonly int SuccessRate = 50;
|
public readonly int SuccessRate = 50;
|
||||||
public readonly string ChuteSound = "chute1.aud";
|
public readonly string ChuteSound = "chute1.aud";
|
||||||
public readonly WRange MinimumEjectHeight = new WRange(427);
|
public readonly bool EjectInAir = false;
|
||||||
|
public readonly bool EjectOnGround = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EjectOnDeath : INotifyKilled
|
public class EjectOnDeath : INotifyKilled
|
||||||
{
|
{
|
||||||
public void Killed(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
var info = self.Info.Traits.Get<EjectOnDeathInfo>();
|
|
||||||
var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(),
|
|
||||||
new TypeDictionary { new OwnerInit(self.Owner) });
|
|
||||||
|
|
||||||
var r = self.World.SharedRandom.Next(1, 100);
|
|
||||||
var cp = self.CenterPosition;
|
var cp = self.CenterPosition;
|
||||||
|
var info = self.Info.Traits.Get<EjectOnDeathInfo>();
|
||||||
|
var r = self.World.SharedRandom.Next(1, 100);
|
||||||
|
|
||||||
if (IsSuitableCell(pilot, self.Location) && r > 100 - info.SuccessRate && cp.Z > info.MinimumEjectHeight.Range
|
if (r <= 100 - info.SuccessRate || self.Owner.WinState == WinState.Lost)
|
||||||
&& self.Owner.WinState != WinState.Lost)
|
return;
|
||||||
|
|
||||||
|
if ((!info.EjectInAir && cp.Z > 0) || (!info.EjectOnGround && cp.Z == 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(),
|
||||||
|
new TypeDictionary { new OwnerInit(self.Owner), new LocationInit(self.Location) });
|
||||||
|
|
||||||
|
|
||||||
|
if (IsSuitableCell(self, pilot, self.Location))
|
||||||
{
|
{
|
||||||
self.World.AddFrameEndTask(w => w.Add(new Parachute(pilot, cp)));
|
if (cp.Z > 0 && info.EjectInAir)
|
||||||
Sound.Play(info.ChuteSound, cp);
|
{
|
||||||
|
self.World.AddFrameEndTask(w => w.Add(new Parachute(pilot, cp)));
|
||||||
|
Sound.Play(info.ChuteSound, cp);
|
||||||
|
}
|
||||||
|
else if (cp.Z == 0 && info.EjectOnGround)
|
||||||
|
self.World.AddFrameEndTask(w => w.Add(pilot));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pilot.Destroy();
|
pilot.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsSuitableCell(Actor actorToDrop, CPos p)
|
bool IsSuitableCell(Actor self, Actor actorToDrop, CPos p)
|
||||||
{
|
{
|
||||||
return actorToDrop.Trait<IPositionable>().CanEnterCell(p);
|
return actorToDrop.Trait<IPositionable>().CanEnterCell(self.Location, self, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,11 @@
|
|||||||
Guard:
|
Guard:
|
||||||
Guardable:
|
Guardable:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
EjectOnDeath:
|
||||||
|
PilotActor: e1
|
||||||
|
SuccessRate: 20
|
||||||
|
EjectOnGround: yes
|
||||||
|
EjectInAir: no
|
||||||
|
|
||||||
^Tank:
|
^Tank:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -77,6 +82,11 @@
|
|||||||
Guard:
|
Guard:
|
||||||
Guardable:
|
Guardable:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
EjectOnDeath:
|
||||||
|
PilotActor: e1
|
||||||
|
SuccessRate: 20
|
||||||
|
EjectOnGround: yes
|
||||||
|
EjectInAir: no
|
||||||
|
|
||||||
^Infantry:
|
^Infantry:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -185,6 +195,8 @@
|
|||||||
EjectOnDeath:
|
EjectOnDeath:
|
||||||
PilotActor: E1
|
PilotActor: E1
|
||||||
SuccessRate: 50
|
SuccessRate: 50
|
||||||
|
EjectOnDeath: no
|
||||||
|
EjectInAir: yes
|
||||||
GivesBounty:
|
GivesBounty:
|
||||||
GpsDot:
|
GpsDot:
|
||||||
String:Plane
|
String:Plane
|
||||||
|
|||||||
Reference in New Issue
Block a user