Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for dropping Cargo with Parachute from an Aircraft #14276

wants to merge 2 commits into from
Changes from 1 commit
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now


Add UnloadWithParachute to Cargo

  • Loading branch information
MustaphaTR committed Oct 30, 2017
commit fdafabf5b1527e99d10a3b7d213df8fab3f9ff39
@@ -0,0 +1,69 @@
#region Copyright & License Information
* Copyright 2007-2017 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, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.

using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Activities;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;

namespace OpenRA.Mods.Common.Activities
public class ParadropCargo : Activity
readonly bool unloadAll;

public ParadropCargo(bool unloadAll)
this.unloadAll = unloadAll;

public override Activity Tick(Actor self)
var cargo = self.Trait<Cargo>();

This comment has been minimized.

Copy link

pchote Nov 15, 2017


Please assign these from the constructor (passing Actor self as a parameter to query from) instead of looking it up ever tick.

var notifiers = self.TraitsImplementing<INotifyUnload>().ToArray();

cargo.Unloading = false;
if (IsCanceled || cargo.IsEmpty(self))
return NextActivity;

foreach (var inu in notifiers)

var actor = cargo.Peek(self);
var spawn = self.CenterPosition;

This comment has been minimized.

Copy link

pchote Nov 15, 2017


This doesn't appear to check for suitable drop cells...?

This comment has been minimized.

Copy link

MustaphaTR Nov 16, 2017

Author Member

Current checks indeed doesn't seem right, but i'm not sure what exactly to do either, it makes more sense that Cargo -> CanUnload checks this, rather than ParadropCargo activity.

CanUnload already still checking for LandableTerrainTypes. I think this shouldn't be checked for them.

self.World.AddFrameEndTask(w =>
if (actor.Disposed)

var pos = actor.Trait<IPositionable>();

pos.SetVisualPosition(actor, spawn);

actor.QueueActivity(new Parachute(actor, spawn));
Game.Sound.Play(SoundType.World, self.Info.TraitInfo<ParaDropInfo>().ChuteSound, spawn);

if (!unloadAll || cargo.IsEmpty(self))
return NextActivity;

cargo.Unloading = true;
return this;
@@ -107,6 +107,7 @@
<Compile Include="Activities\Move\MoveAdjacentTo.cs" />
<Compile Include="Activities\Move\MoveWithinRange.cs" />
<Compile Include="Activities\Parachute.cs" />
<Compile Include="Activities\ParadropCargo.cs" />
<Compile Include="Activities\Rearm.cs" />
<Compile Include="Activities\RemoveSelf.cs" />
<Compile Include="Activities\Repair.cs" />
@@ -40,6 +40,10 @@ public class CargoInfo : ITraitInfo, Requires<IOccupySpaceInfo>
[Desc("When this actor dies should all of its passengers be unloaded?")]
public readonly bool EjectOnDeath = false;

[Desc("If the actor is on air, drop passengers with parachute instead of landing.",
"This requires `ParaDrop` and `Aircraft` traits on actor to work.")]
public readonly bool UnloadWithParachute = false;

[Desc("Terrain types that this actor is allowed to eject actors onto. Leave empty for all terrain types.")]
public readonly HashSet<string> UnloadTerrainTypes = new HashSet<string>();

@@ -88,6 +92,7 @@ public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyCrea
int totalWeight = 0;
int reservedWeight = 0;
Aircraft aircraft;
ParaDrop paradrop;
ConditionManager conditionManager;
int loadingToken = ConditionManager.InvalidConditionToken;
Stack<int> loadedTokens = new Stack<int>();
@@ -141,6 +146,7 @@ public Cargo(ActorInitializer init, CargoInfo info)
void INotifyCreated.Created(Actor self)
aircraft = self.TraitOrDefault<Aircraft>();
paradrop = self.TraitOrDefault<ParaDrop>();
conditionManager = self.TraitOrDefault<ConditionManager>();

@@ -172,11 +178,23 @@ public void ResolveOrder(Actor self, Order order)
if (!CanUnload())

var inAir = !self.IsAtGroundLevel();

Unloading = true;
if (aircraft != null)
if (paradrop != null && aircraft != null && Info.UnloadWithParachute && inAir)
self.QueueActivity(new ParadropCargo(false));
if (!aircraft.Info.CanHover)
self.QueueActivity(new FlyCircle(self));
else if (aircraft != null)
self.QueueActivity(new HeliLand(self, true));
self.QueueActivity(new UnloadCargo(self, true));
self.QueueActivity(new UnloadCargo(self, true));
self.QueueActivity(new UnloadCargo(self, true));

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.