Infantry on parachutes makes idle actions in the air. #2988

Closed
Mailaender opened this Issue Apr 7, 2013 · 10 comments

Projects

None yet

5 participants

@Mailaender Mailaender was assigned Apr 21, 2013
Contributor

What about doing a similar check as in #3144, but checking for self.IsInWorld instead of self.HasTrait()? Has there been any further thought on how to address this? I see that there is no possibility to check the existence of a coupling between an effect and an actor...

Member
Phrohdoh commented May 4, 2014

Why not just if (self.Location.Z > 0) animate single frame?
But I have never observed this in game.

Owner
pchote commented May 4, 2014

@matija-hustic: An IsInWorld check should work. Would you like to put together a pull request fixing this?

Contributor

Sure, altho the self.CenterPosition.Z > 0 check works as well, as suggested by Phrohdoh.
With the IsInWorld approach, I am guessing that in order to be able to make paratroopers shootable later on (like in RA2), they will have to be in world, so this condition would again need to be revised.
With the CenterPosition.Z approach, adding support for flying infantry (e.g. RA2 rocketeer) might also require revision of the condition...

Contributor

Ah this is not true. It doesn't work with CenterPosition. I haven't checked carefully enough last night.
I'll add the IsInWorld check to #5257.

@Mailaender Mailaender self-assigned this Jun 22, 2014
@Mailaender Mailaender added a commit to Mailaender/OpenRA that referenced this issue Jun 22, 2014
@Mailaender Mailaender disallow idle animations while in the air paradropping
fixes #2988
c2cff59
@Mailaender Mailaender added a commit to Mailaender/OpenRA that referenced this issue Jun 23, 2014
@Mailaender Mailaender disallow idle animations while in the air paradropping
fixes #2988
a57d7b0
@Mailaender Mailaender added a commit to Mailaender/OpenRA that referenced this issue Jun 27, 2014
@Mailaender Mailaender disallow idle animations while in the air paradropping
fixes #2988
7f910f6
@Mailaender Mailaender added a commit to Mailaender/OpenRA that referenced this issue Jun 28, 2014
@Mailaender Mailaender disallow idle animations while in the air paradropping
fixes #2988
9bdc2e0
@Mailaender Mailaender added a commit to Mailaender/OpenRA that referenced this issue Jun 28, 2014
@Mailaender Mailaender disallow idle animations while in the air paradropping
fixes #2988
06ddc0e
@Mailaender Mailaender added a commit to Mailaender/OpenRA that referenced this issue Jul 1, 2014
@Mailaender Mailaender disallow idle animations while in the air paradropping
fixes #2988
fec126d
@Mailaender Mailaender removed their assignment Jul 16, 2014
Owner

Why not just if (self.Location.Z > 0) animate single frame?

For some reason we could not get that working.

Member
Phrohdoh commented Mar 5, 2015

I just tried to do this and could not accomplish it either.

diff --git a/OpenRA.Mods.Common/Traits/Cargo.cs b/OpenRA.Mods.Common/Traits/Cargo.cs
index b48ed4334054..74399623ff7e 100644
--- a/OpenRA.Mods.Common/Traits/Cargo.cs
+++ b/OpenRA.Mods.Common/Traits/Cargo.cs
@@ -198,6 +198,9 @@ public Actor Unload(Actor self)
            foreach (var npe in self.TraitsImplementing<INotifyPassengerExited>())
                npe.PassengerExited(self, a);

+           foreach (var notify in a.TraitsImplementing<INotifyCargoEvents>())
+               notify.OnExitCargo(a, self);
+
            var p = a.Trait<Passenger>();
            p.Transport = null;

diff --git a/OpenRA.Mods.Common/Traits/Passenger.cs b/OpenRA.Mods.Common/Traits/Passenger.cs
index a829b7df92e2..668b8dbacacb 100644
--- a/OpenRA.Mods.Common/Traits/Passenger.cs
+++ b/OpenRA.Mods.Common/Traits/Passenger.cs
@@ -15,6 +15,7 @@
 using OpenRA.Mods.Common.Activities;
 using OpenRA.Mods.Common.Orders;
 using OpenRA.Traits;
+using OpenRA.Graphics;

 namespace OpenRA.Mods.Common.Traits
 {
@@ -103,16 +104,54 @@ public class PassengerInfo : ITraitInfo
        [Desc("Upgrade types to grant to transport.")]
        public readonly string[] GrantUpgrades = { };

-       public object Create(ActorInitializer init) { return new Passenger(this); }
+       [Desc("Animation to play if this actor exits its transport in-air.")]
+       public readonly string ExitSequenceInAir = null;
+
+       [Desc("Animation to play if this actor exits its transport on the ground.")]
+       public readonly string ExitSequenceOnGround = null;
+
+       public object Create(ActorInitializer init) { return new Passenger(init.Self, this); }
    }

-   public class Passenger : IIssueOrder, IResolveOrder, IOrderVoice, INotifyRemovedFromWorld
+   public interface INotifyCargoEvents
+   {
+       void OnEnterCargo(Actor self, Actor transport);
+       void OnExitCargo(Actor self, Actor transport);
+   }
+
+   public class Passenger : IIssueOrder, IResolveOrder, IOrderVoice, INotifyRemovedFromWorld, INotifyCargoEvents
    {
        public readonly PassengerInfo Info;
-       public Passenger(PassengerInfo info) { Info = info; }
        public Actor Transport;
        public Cargo ReservedCargo { get; private set; }

+       readonly Animation exitAnim;
+
+       public Passenger(Actor self, PassengerInfo info)
+       {
+           Info = info;
+           exitAnim = new Animation(self.World, self.Info.Name);
+       }
+
+       public void OnEnterCargo(Actor self, Actor transport) { }
+
+       public void OnExitCargo(Actor self, Actor transport)
+       {
+           var pos = transport.CenterPosition;
+
+           // TODO: use cell at (x, y) to get ground's proper Z position
+           var targetCell = self.World.Map.CellContaining(new WPos(pos.X, pos.Y, 0));
+           var targetPos = self.World.Map.CenterOfCell(targetCell);
+           var isInAir = pos.Z > targetPos.Z;
+           var playInAir = isInAir && Info.ExitSequenceInAir != null;
+           var playOnGround = !isInAir && Info.ExitSequenceOnGround != null;
+
+           if (playInAir)
+               exitAnim.PlayRepeating(Info.ExitSequenceInAir);
+           else if (playOnGround)
+               exitAnim.PlayRepeating(Info.ExitSequenceOnGround);
+       }
+
        public IEnumerable<IOrderTargeter> Orders
        {
            get
diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml
index 3cdefbd12a35..8c8ceeee4816 100644
--- a/mods/ra/rules/defaults.yaml
+++ b/mods/ra/rules/defaults.yaml
@@ -188,6 +188,7 @@
    AttackMove:
    Passenger:
        CargoType: Infantry
+       ExitSequenceInAir: paradrop
    HiddenUnderFog:
    GainsExperience:
    GivesExperience:
diff --git a/mods/ra/sequences/infantry.yaml b/mods/ra/sequences/infantry.yaml
index 99c8b450a8ce..ec4affbe67b5 100644
--- a/mods/ra/sequences/infantry.yaml
+++ b/mods/ra/sequences/infantry.yaml
@@ -2,6 +2,8 @@ e1:
    stand:
        Start: 0
        Facings: 8
+   paradrop:
+       Start: 0
    stand2:
        Start: 8
        Facings: 8
Owner
cjshmyr commented Mar 6, 2015

I'm guessing you might be able to use the same render sequence modifier logic that takecover uses.

Member
Phrohdoh commented Mar 6, 2015

@cjshmyr Good idea, I'll try that in the future.

Owner

That won't work, either:

image

@obrakmann obrakmann closed this in #8339 Jul 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment