From 5832ec76d4ce7c8bbbc8794ccf661009739cf805 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 5 Feb 2021 22:16:31 +0000 Subject: [PATCH] Render integrated muzzle flashes as their own tint-ignoring animations. --- .../WithSplitAttackPaletteInfantryBody.cs | 58 +++++++++++++++++++ .../Traits/Render/WithInfantryBody.cs | 6 +- mods/ts/rules/civilian-infantry.yaml | 28 +++++---- mods/ts/rules/critters.yaml | 4 ++ mods/ts/rules/defaults.yaml | 12 ++-- mods/ts/rules/gdi-infantry.yaml | 15 +++-- mods/ts/rules/gdi-vehicles.yaml | 5 ++ mods/ts/rules/nod-infantry.yaml | 2 +- mods/ts/rules/palettes.yaml | 42 ++++++++++++++ mods/ts/rules/shared-infantry.yaml | 2 +- mods/ts/sequences/critters.yaml | 6 ++ mods/ts/sequences/infantry.yaml | 55 +++++++++++++++++- mods/ts/sequences/vehicles.yaml | 6 ++ 13 files changed, 215 insertions(+), 26 deletions(-) create mode 100644 OpenRA.Mods.Cnc/Traits/Render/WithSplitAttackPaletteInfantryBody.cs diff --git a/OpenRA.Mods.Cnc/Traits/Render/WithSplitAttackPaletteInfantryBody.cs b/OpenRA.Mods.Cnc/Traits/Render/WithSplitAttackPaletteInfantryBody.cs new file mode 100644 index 0000000000..9047daf89a --- /dev/null +++ b/OpenRA.Mods.Cnc/Traits/Render/WithSplitAttackPaletteInfantryBody.cs @@ -0,0 +1,58 @@ +#region Copyright & License Information +/* + * Copyright 2007-2021 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. + */ +#endregion + +using OpenRA.Graphics; +using OpenRA.Mods.Common.Traits; +using OpenRA.Mods.Common.Traits.Render; +using OpenRA.Traits; + +namespace OpenRA.Mods.Cnc.Traits.Render +{ + class WithSplitAttackPaletteInfantryBodyInfo : WithInfantryBodyInfo + { + [PaletteReference] + [Desc("Palette to use for the split attack rendering.")] + public readonly string SplitAttackPalette = null; + + [Desc("Sequence suffix to use.")] + public readonly string SplitAttackSuffix = "muzzle"; + + public override object Create(ActorInitializer init) { return new WithSplitAttackPaletteInfantryBody(init, this); } + } + + class WithSplitAttackPaletteInfantryBody : WithInfantryBody + { + readonly WithSplitAttackPaletteInfantryBodyInfo info; + readonly Animation splitAnimation; + bool visible; + + public WithSplitAttackPaletteInfantryBody(ActorInitializer init, WithSplitAttackPaletteInfantryBodyInfo info) + : base(init, info) + { + this.info = info; + var rs = init.Self.Trait(); + splitAnimation = new Animation(init.World, rs.GetImage(init.Self), RenderSprites.MakeFacingFunc(init.Self)); + rs.Add(new AnimationWithOffset(splitAnimation, null, () => IsTraitDisabled || !visible), info.SplitAttackPalette); + } + + protected override void Attacking(Actor self, Armament a, Barrel barrel) + { + base.Attacking(self, a, barrel); + + var sequence = DefaultAnimation.CurrentSequence.Name + "-" + info.SplitAttackSuffix; + if (state == AnimationState.Attacking && splitAnimation.HasSequence(sequence)) + { + visible = true; + splitAnimation.PlayThen(sequence, () => visible = false); + } + } + } +} diff --git a/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs b/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs index d194f59b22..9d55e70b7c 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs @@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits.Render bool dirty; string idleSequence; int idleDelay; - AnimationState state; + protected AnimationState state; IRenderInfantrySequenceModifier rsm; bool IsModifyingSequence => rsm != null && rsm.IsModifyingSequence; @@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Traits.Render } } - void Attacking(Actor self, Armament a, Barrel barrel) + protected virtual void Attacking(Actor self, Armament a, Barrel barrel) { var info = GetDisplayInfo(); var sequence = info.DefaultAttackSequence; @@ -213,7 +213,7 @@ namespace OpenRA.Mods.Common.Traits.Render } } - enum AnimationState + protected enum AnimationState { Idle, Attacking, diff --git a/mods/ts/rules/civilian-infantry.yaml b/mods/ts/rules/civilian-infantry.yaml index 89176b2044..cc63e2411d 100644 --- a/mods/ts/rules/civilian-infantry.yaml +++ b/mods/ts/rules/civilian-infantry.yaml @@ -48,7 +48,7 @@ UMAGON: Weapon: Sniper AttackFrontal: Voice: Attack - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack ProducibleWithLevel: Prerequisites: barracks.upgraded @@ -80,9 +80,9 @@ CHAMSPY: Infiltrates: Types: SpyInfiltrate Notification: BuildingInfiltrated - -WithInfantryBody: + -WithSplitAttackPaletteInfantryBody: WithDisguisingInfantryBody: - IdleSequences: idle1,idle2 + IdleSequences: idle1, idle2 MUTANT: Inherits: ^Soldier @@ -106,7 +106,7 @@ MUTANT: Weapon: Vulcan AttackFrontal: Voice: Attack - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack ProducibleWithLevel: Prerequisites: barracks.upgraded @@ -133,7 +133,7 @@ MWMN: Weapon: Vulcan AttackFrontal: Voice: Attack - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack ProducibleWithLevel: Prerequisites: barracks.upgraded @@ -160,8 +160,10 @@ MUTANT3: Weapon: Vulcan AttackFrontal: Voice: Attack - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack + Palette: player-nobright + SplitAttackPalette: bright ProducibleWithLevel: Prerequisites: barracks.upgraded @@ -180,8 +182,6 @@ TRATOS: Speed: 71 RevealsShroud: Range: 4c0 - WithInfantryBody: - DefaultAttackSequence: OXANNA: Inherits: ^Soldier @@ -197,7 +197,7 @@ OXANNA: Speed: 56 RevealsShroud: Range: 4c0 - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack SLAV: @@ -214,14 +214,16 @@ SLAV: Speed: 56 RevealsShroud: Range: 4c0 - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack CIV1: Inherits: ^CivilianInfantry Inherits@AUTOTARGET: ^AutoTargetGroundAssaultMove - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack + Palette: player-nomuzzle + SplitAttackPalette: muzzle Armament: Weapon: Pistola AttackFrontal: @@ -244,8 +246,10 @@ CTECH: Inherits@AUTOTARGET: ^AutoTargetGroundAssaultMove RenderSprites: Image: civ3 - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack + Palette: player-nomuzzle + SplitAttackPalette: muzzle Armament: Weapon: Pistola AttackFrontal: diff --git a/mods/ts/rules/critters.yaml b/mods/ts/rules/critters.yaml index 89147ff343..a4468456ab 100644 --- a/mods/ts/rules/critters.yaml +++ b/mods/ts/rules/critters.yaml @@ -131,8 +131,12 @@ JFISH: MaxMoveDelay: 600 WithAttackAnimation: Sequence: attack + WithAttackOverlay@muzzle: + Sequence: attack-shock + Palette: bright RenderSprites: Image: floater + Palette: player-nobright Selectable: Bounds: 32,32,0,-5 AmbientSound: diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index b1d8c7222a..9ce9aee085 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -585,7 +585,7 @@ ValidDamageStates: Light, Medium, Heavy, Critical QuantizeFacingsFromSequence: Sequence: stand - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: AttackMove: Voice: Move Passenger: @@ -705,8 +705,10 @@ Prone350Percent: 350 DamageTriggers: TriggerProne ProneOffset: 300,0,0 - WithInfantryBody: - IdleSequences: idle1,idle2 + WithSplitAttackPaletteInfantryBody: + IdleSequences: idle1, idle2 + Palette: player-nomuzzle + SplitAttackPalette: muzzle ^Cyborg: Inherits@1: ^Infantry @@ -734,9 +736,11 @@ Prone350Percent: 350 ProneOffset: 300,0,0 ProneSequencePrefix: crippled- - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack IdleSequences: idle1, idle2 + Palette: player-nomuzzle + SplitAttackPalette: muzzle GrantConditionOnDamageState@CRITICAL: Condition: critical ValidDamageStates: Critical diff --git a/mods/ts/rules/gdi-infantry.yaml b/mods/ts/rules/gdi-infantry.yaml index 04349d0622..1f272e5553 100644 --- a/mods/ts/rules/gdi-infantry.yaml +++ b/mods/ts/rules/gdi-infantry.yaml @@ -26,7 +26,7 @@ E2: ProneOffset: 160,128,-555 AttackFrontal: Voice: Attack - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack RevealsShroud: Range: 7c0 @@ -77,7 +77,7 @@ MEDIC: AutoTargetPriority@DEFAULT: ValidTargets: Infantry AttackFrontal: - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: heal ChangesHealth: Step: 500 @@ -119,7 +119,7 @@ JUMPJET: -Crushable: AttackFrontal: Voice: Attack - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: RequiresCondition: !airborne DefaultAttackSequence: attack WithInfantryBody@flying: @@ -127,6 +127,13 @@ JUMPJET: DefaultAttackSequence: flying-attack StandSequences: flying MoveSequence: flying + Palette: player-nomuzzle + WithInfantryBody@flying-muzzle: + RequiresCondition: airborne + DefaultAttackSequence: flying-attack-muzzle + StandSequences: flying-muzzle + MoveSequence: flying-muzzle + Palette: muzzle -TakeCover: Hovers: RequiresCondition: airborne @@ -243,7 +250,7 @@ GHOST: Demolition: DetonationDelay: 45 Voice: Attack - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack ProducibleWithLevel: Prerequisites: barracks.upgraded diff --git a/mods/ts/rules/gdi-vehicles.yaml b/mods/ts/rules/gdi-vehicles.yaml index 1291527b72..2a9e4b0017 100644 --- a/mods/ts/rules/gdi-vehicles.yaml +++ b/mods/ts/rules/gdi-vehicles.yaml @@ -142,8 +142,13 @@ SMECH: Sequence: stand WithFacingSpriteBody: Sequence: stand + Palette: player-nomuzzle + IsPlayerPalette: True WithAttackAnimation: Sequence: shoot + WithAttackOverlay@muzzle: + Sequence: shoot-muzzle + Palette: muzzle WithMoveAnimation: MoveSequence: walk ValidMovementTypes: Horizontal, Turn diff --git a/mods/ts/rules/nod-infantry.yaml b/mods/ts/rules/nod-infantry.yaml index e1be4d404d..3da9d94cc0 100644 --- a/mods/ts/rules/nod-infantry.yaml +++ b/mods/ts/rules/nod-infantry.yaml @@ -27,7 +27,7 @@ E3: ProneOffset: 52,64,-652 AttackFrontal: Voice: Attack - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack RevealsShroud: Range: 7c0 diff --git a/mods/ts/rules/palettes.yaml b/mods/ts/rules/palettes.yaml index 4bc640fccd..4f8d380fb9 100644 --- a/mods/ts/rules/palettes.yaml +++ b/mods/ts/rules/palettes.yaml @@ -31,6 +31,40 @@ Tileset: TEMPERATE Filename: unittem.pal ShadowIndex: 1 + PaletteFromFile@playersno-nomuzzle: + Name: player-nomuzzle + Tileset: SNOW + Filename: unitsno.pal + ShadowIndex: 1 + TransparentIndex: 0, 246, 247, 248, 249, 250 + PaletteFromFile@playertem-nomuzzle: + Name: player-nomuzzle + Tileset: TEMPERATE + Filename: unittem.pal + ShadowIndex: 1 + TransparentIndex: 0, 246, 247, 248, 249, 250 + PaletteFromFile@playersno-nobright: + Name: player-nobright + Tileset: SNOW + Filename: unitsno.pal + ShadowIndex: 1 + TransparentIndex: 0, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 + PaletteFromFile@playertem-nobright: + Name: player-nobright + Tileset: TEMPERATE + Filename: unittem.pal + ShadowIndex: 1 + TransparentIndex: 0, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 + PaletteFromFile@muzzle: + Name: muzzle + Filename: unittem.pal + ShadowIndex: 1 + TransparentIndex: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 251, 252, 253, 254, 255 + PaletteFromFile@bright: + Name: bright + Filename: unittem.pal + ShadowIndex: 1 + TransparentIndex: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239 PaletteFromFile@depth: Name: depth Filename: depth.pal @@ -102,6 +136,14 @@ PlayerColorPalette: BasePalette: player RemapIndex: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 + PlayerColorPalette@NOMUZZLE: + BaseName: player-nomuzzle + BasePalette: player-nomuzzle + RemapIndex: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 + PlayerColorPalette@NOBRIGHT: + BaseName: player-nobright + BasePalette: player-nobright + RemapIndex: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 PaletteFromPlayerPaletteWithAlpha@cloak: BaseName: cloak BasePalette: player diff --git a/mods/ts/rules/shared-infantry.yaml b/mods/ts/rules/shared-infantry.yaml index aa55795eff..f8b0a09b70 100644 --- a/mods/ts/rules/shared-infantry.yaml +++ b/mods/ts/rules/shared-infantry.yaml @@ -26,7 +26,7 @@ E1: RequiresCondition: rank-elite AttackFrontal: Voice: Attack - WithInfantryBody: + WithSplitAttackPaletteInfantryBody: DefaultAttackSequence: attack ProducibleWithLevel: Prerequisites: barracks.upgraded diff --git a/mods/ts/sequences/critters.yaml b/mods/ts/sequences/critters.yaml index 3678b2b8b4..2a45693c96 100644 --- a/mods/ts/sequences/critters.yaml +++ b/mods/ts/sequences/critters.yaml @@ -91,3 +91,9 @@ floater: ShadowStart: 48 Tick: 100 Offset: 0, 0, 16 + attack-shock: + Length: 16 + Start: 16 + Tick: 100 + Offset: 0, 0, 16 + IgnoreWorldTint: True diff --git a/mods/ts/sequences/infantry.yaml b/mods/ts/sequences/infantry.yaml index ee8e8a734b..5ea26fdc06 100644 --- a/mods/ts/sequences/infantry.yaml +++ b/mods/ts/sequences/infantry.yaml @@ -59,11 +59,21 @@ Length: 6 Facings: 8 ShadowStart: 456 + attack-muzzle: + Start: 164 + Length: 6 + Facings: 8 + IgnoreWorldTint: True prone-attack: Start: 212 Length: 6 Facings: 8 ShadowStart: 504 + prone-attack-muzzle: + Start: 212 + Length: 6 + Facings: 8 + IgnoreWorldTint: True e1.gdi: Inherits: ^BasicInfantry @@ -149,11 +159,12 @@ civ1: Length: 6 Facings: 8 ShadowStart: 456 - panic-attack: + attack-muzzle: Start: 164 Length: 6 Facings: 8 ShadowStart: 456 + IgnoreWorldTint: True panic-run: Start: 86 Length: 6 @@ -212,11 +223,21 @@ cyborg: Length: 6 Facings: 8 ShadowStart: 534 + attack-muzzle: + Start: 164 + Length: 6 + Facings: 8 + IgnoreWorldTint: True crippled-attack: Start: 212 Length: 6 Facings: 8 ShadowStart: 582 + crippled-attack-muzzle: + Start: 212 + Length: 6 + Facings: 8 + IgnoreWorldTint: True emp-overlay: emp_fx01 Length: * ZOffset: 512 @@ -259,11 +280,23 @@ cyc2: Length: 6 Facings: 8 ShadowStart: 520 + attack-muzzle: + Start: 212 + Length: 6 + Facings: 8 + ShadowStart: 520 + IgnoreWorldTint: True crippled-attack: Start: 260 Length: 6 Facings: 8 ShadowStart: 568 + crippled-attack-muzzle: + Start: 260 + Length: 6 + Facings: 8 + ShadowStart: 568 + IgnoreWorldTint: True emp-overlay: emp_fx01 Length: * ZOffset: 512 @@ -364,6 +397,11 @@ jumpjet: Length: 6 Start: 292 ShadowStart: 743 + flying-muzzle: + Facings: 8 + Length: 6 + Start: 292 + IgnoreWorldTint: True die-twirling: # TODO: animation for falling from sky starts at 436 Start: 445 Length: 6 @@ -389,16 +427,31 @@ jumpjet: Length: 6 Facings: 8 ShadowStart: 615 + attack-muzzle: + Start: 164 + Length: 6 + Facings: 8 + IgnoreWorldTint: True flying-attack: Start: 388 Facings: 8 Length: 6 ShadowStart: 839 + flying-attack-muzzle: + Start: 388 + Facings: 8 + Length: 6 + IgnoreWorldTint: True prone-attack: Start: 212 Length: 6 Facings: 8 ShadowStart: 663 + prone-attack-muzzle: + Start: 212 + Length: 6 + Facings: 8 + IgnoreWorldTint: True standup: Start: 260 Length: 2 diff --git a/mods/ts/sequences/vehicles.yaml b/mods/ts/sequences/vehicles.yaml index 8b0f77229a..7b9bd54d67 100644 --- a/mods/ts/sequences/vehicles.yaml +++ b/mods/ts/sequences/vehicles.yaml @@ -250,6 +250,12 @@ smech: Facings: -8 ShadowStart: 240 Tick: 80 + shoot-muzzle: + Start: 104 + Length: 4 + Facings: -8 + Tick: 80 + IgnoreWorldTint: True icon: smchicon trucka: