Add MergeCaptureTraits update rule.

This commit is contained in:
Paul Chote
2018-10-06 21:41:10 +00:00
committed by abcdefg30
parent a4405009c8
commit ccad3bd185
27 changed files with 308 additions and 55 deletions

View File

@@ -590,6 +590,7 @@
<Compile Include="Traits\World\WeatherOverlay.cs" />
<Compile Include="Traits\World\ActorSpawnManager.cs" />
<Compile Include="Traits\ActorSpawner.cs" />
<Compile Include="UpdateRules\Rules\20180923\MergeCaptureTraits.cs" />
<Compile Include="UtilityCommands\CheckYaml.cs" />
<Compile Include="UtilityCommands\ConvertPngToShpCommand.cs" />
<Compile Include="UtilityCommands\ConvertSpriteToPngCommand.cs" />

View File

@@ -0,0 +1,154 @@
#region Copyright & License Information
/*
* Copyright 2007-2018 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 System;
using System.Collections.Generic;
using System.Linq;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class MergeCaptureTraits : UpdateRule
{
public override string Name { get { return "Merge and overhaul Captures traits"; } }
public override string Description
{
get
{
return "The internal and external capturing traits have been merged, and a new\n" +
"CaptureManager trait has been added to help manage interactions between\n" +
"actors and multiple trait instances. The Sabotage logic has also\n" +
"moved from the Capturable trait to the Captures trait.\n" +
"The External* traits are renamed, and the CaptureManager added wherever\n" +
"the Capturable or Captures trait is used. The locations modified are\n" +
"listed for inspection and manual cleanup";
}
}
readonly List<string> captureManagerLocations = new List<string>();
readonly List<string> externalDelayLocations = new List<string>();
readonly List<string> sabotageLocations = new List<string>();
public override IEnumerable<string> AfterUpdate(ModData modData)
{
if (captureManagerLocations.Any())
yield return "The Captures and Capturable traits now depend on the\n" +
"new CaptureManager trait. This trait has automatically been added\n" +
"in the following definitions:\n" + UpdateUtils.FormatMessageList(captureManagerLocations) +
"\nYou may wish to review these definitions and delete any redundant\n" +
"instances that have already been inherited from a parent template.";
if (sabotageLocations.Any())
yield return "The sabotage logic has been disabled by default, which affects\n" +
"the following definitions:\n" + UpdateUtils.FormatMessageList(sabotageLocations) +
"\nThe sabotage logic is now defined on the Captures trait, via the \n" +
"SabotageThreshold field. You may need to define additional capture types\n" +
"and Capturable traits if you wish to use multiple capture thresholds.";
if (externalDelayLocations.Any())
yield return "The following actors have had their capture delays reset to 15 seconds:\n" +
UpdateUtils.FormatMessageList(sabotageLocations) +
"\nThe capture delay is now defined on the Captures trait, via the\n" +
"CaptureDelay field. You may need to define additional capture types\n" +
"and Capturable traits if you wish to use multiple capture delays.";
captureManagerLocations.Clear();
sabotageLocations.Clear();
externalDelayLocations.Clear();
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
var reportLocation = "{0} ({1})".F(actorNode.Key, actorNode.Location.Filename);
var captureManager = actorNode.LastChildMatching("CaptureManager") ?? new MiniYamlNode("CaptureManager", "");
var usesCaptureManager = false;
// Migrate External*
foreach (var c in actorNode.ChildrenMatching("ExternalCapturable"))
{
c.RenameKey("Capturable");
if (c.RemoveNodes("CaptureCompleteTime") > 0)
externalDelayLocations.Add(reportLocation);
}
foreach (var c in actorNode.ChildrenMatching("ExternalCaptures"))
{
c.RenameKey("Captures");
if (c.Key.StartsWith("-"))
continue;
c.AddNode("CaptureDelay", 375);
var consumeNode = c.LastChildMatching("ConsumeActor");
if (consumeNode != null)
consumeNode.RenameKey("ConsumedByCapture");
else
c.AddNode("ConsumedByCapture", false);
var conditionNode = c.LastChildMatching("CapturingCondition");
if (conditionNode != null)
conditionNode.MoveNode(c, captureManager);
var cursorNode = c.LastChildMatching("CaptureCursor");
if (cursorNode != null)
cursorNode.RenameKey("EnterCursor");
else
c.AddNode("EnterCursor", "ability");
var cursorBlockedNode = c.LastChildMatching("CaptureBlockedCursor");
if (cursorBlockedNode != null)
cursorBlockedNode.RenameKey("EnterBlockedCursor");
else
c.AddNode("EnterBlockedCursor", "move-blocked");
}
var addBlinker = false;
foreach (var c in actorNode.ChildrenMatching("ExternalCapturableBar"))
{
c.RenameKey("CapturableProgressBar");
addBlinker = true;
}
if (addBlinker)
actorNode.AddNode("CapturableProgressBlink", "");
// Remove any CaptureThreshold nodes and restore the "building" default
// These run on converted External* traits too
foreach (var traitNode in actorNode.ChildrenMatching("Capturable"))
{
if (!traitNode.Key.StartsWith("-"))
usesCaptureManager = true;
if (traitNode.RemoveNodes("CaptureThreshold") + traitNode.RemoveNodes("Sabotage") > 0)
sabotageLocations.Add(reportLocation);
if (!traitNode.Key.StartsWith("-") && traitNode.LastChildMatching("Types") == null)
traitNode.AddNode("Types", "building");
}
foreach (var traitNode in actorNode.ChildrenMatching("Captures"))
{
if (!traitNode.Key.StartsWith("-"))
usesCaptureManager = true;
if (traitNode.LastChildMatching("CaptureTypes") == null)
traitNode.AddNode("CaptureTypes", "building");
}
if (usesCaptureManager && actorNode.LastChildMatching("CaptureManager") == null)
{
actorNode.AddNode(captureManager);
captureManagerLocations.Add(reportLocation);
}
yield break;
}
}
}

View File

@@ -92,6 +92,7 @@ namespace OpenRA.Mods.Common.UpdateRules
new RenameEditorTilesetFilter(),
new DefineNotificationDefaults(),
new MergeRearmAndRepairAnimation(),
new MergeCaptureTraits(),
})
};

View File

@@ -97,5 +97,6 @@ RMBO:
MISS:
Tooltip:
Name: Prison
CaptureManager:
Capturable:
CaptureThreshold: 100
Types: building

View File

@@ -96,5 +96,6 @@ RMBO:
MISS:
Tooltip:
Name: Prison
CaptureManager:
Capturable:
CaptureThreshold: 100
Types: building

View File

@@ -138,7 +138,7 @@ HPAD.IN:
ProvidesPrerequisite:
Prerequisite: hpad
Capturable:
CaptureThreshold: 100
Types: building
Building:
Footprint: x_ xx
BuildSounds: placbldg.aud, build5.aud

View File

@@ -158,7 +158,7 @@ FACTOUT.IN:
ProvidesPrerequisite:
Prerequisite: fact
Capturable:
CaptureThreshold: 100
Types: building
MoneyCrate:
Inherits: ^Crate
@@ -175,7 +175,7 @@ NUKEOUT.IN:
ProvidesPrerequisite:
Prerequisite: anypower
Capturable:
CaptureThreshold: 100
Types: building
PROCOUT.IN:
Inherits: PROC
@@ -186,7 +186,7 @@ PROCOUT.IN:
ProvidesPrerequisite:
Prerequisite: proc
Capturable:
CaptureThreshold: 100
Types: building
TRAN.IN:
Inherits: TRAN

View File

@@ -186,7 +186,7 @@ FACTOUT.IN:
ProvidesPrerequisite:
Prerequisite: fact
Capturable:
CaptureThreshold: 100
Types: building
MoneyCrate:
Inherits: ^Crate
@@ -203,7 +203,7 @@ NUKEOUT.IN:
ProvidesPrerequisite:
Prerequisite: anypower
Capturable:
CaptureThreshold: 100
Types: building
PROCOUT.IN:
Inherits: PROC
@@ -214,7 +214,7 @@ PROCOUT.IN:
ProvidesPrerequisite:
Prerequisite: proc
Capturable:
CaptureThreshold: 100
Types: building
TRAN.IN:
Inherits: TRAN

View File

@@ -162,7 +162,7 @@ NUKEOUT.IN:
ProvidesPrerequisite:
Prerequisite: anypower
Capturable:
CaptureThreshold: 100
Types: building
PROCOUT.IN:
Inherits: PROC
@@ -173,7 +173,7 @@ PROCOUT.IN:
ProvidesPrerequisite:
Prerequisite: proc
Capturable:
CaptureThreshold: 100
Types: building
RMBO.easy:
Inherits: RMBO

View File

@@ -745,8 +745,9 @@
EngineerRepairable:
Sellable:
SellSounds: cashturn.aud
CaptureManager:
Capturable:
CaptureThreshold: 55
Types: building-sabotage
WithMakeAnimation:
WithBuildingRepairDecoration:
Image: allyrepair
@@ -787,7 +788,9 @@
Inherits: ^CivBuilding
OwnerLostAction:
Action: ChangeOwner
CaptureManager:
Capturable:
Types: building
CaptureNotification:
Notification: CivilianBuildingCaptured
RepairableBuilding:
@@ -1008,9 +1011,9 @@
Targetable:
RequiresForceFire: yes
TargetTypes: Ground, Husk
CaptureManager:
Capturable:
Types: husk
CaptureThreshold: 100
ValidStances: Enemy, Neutral, Ally
TransformOnCapture:
ForceHealthPercentage: 25

View File

@@ -174,7 +174,12 @@ E6:
PipType: Yellow
EngineerRepair:
RepairsBridges:
Captures:
CaptureManager:
Captures@SABOTAGE:
CaptureTypes: building-sabotage
SabotageThreshold: 55
PlayerExperience: 50
Captures@CAPTURES:
CaptureTypes: building, husk
PlayerExperience: 50
Selectable:

View File

@@ -386,8 +386,9 @@
Adjacent: 3
GivesBuildableArea:
AreaTypes: building
CaptureManager:
Capturable:
CaptureThreshold: 100
Types: building
SoundOnDamageTransition:
DamagedSounds: EXPLSML1.WAV
DestroyedSounds: EXPLHG1.WAV

View File

@@ -41,8 +41,9 @@ engineer:
Mobile:
Speed: 31
EngineerRepair:
CaptureManager:
Captures:
CaptureTypes: building, husk
CaptureTypes: building
PlayerExperience: 50
-RevealOnFire:
Voiced:

View File

@@ -14,11 +14,27 @@ World:
normal: Normal
Default: easy
^Building:
FCOM:
Capturable:
CaptureThreshold: 25
Types: ~disabled
^TechBuilding:
HOSP:
Capturable:
Types: ~disabled
MISS:
Capturable:
Types: ~disabled
FCOM:
Capturable:
Types: ~disabled
BIO:
Capturable:
Types: ~disabled
OILB:
Capturable:
Types: ~disabled
@@ -29,9 +45,10 @@ powerproxy.paratroopers:
HACKE6:
Inherits: E6
-RepairsBridges:
-ExternalCaptures:
Captures:
CaptureTypes: building
-ConsumedByCapture:
-EnterCursor:
-EnterBlockedCursor:
Targetable:
RequiresCondition: !jail
Targetable@PRISONER:

View File

@@ -14,11 +14,27 @@ World:
normal: Normal
Default: easy
^Building:
FCOM:
Capturable:
CaptureThreshold: 25
Types: ~disabled
^TechBuilding:
HOSP:
Capturable:
Types: ~disabled
MISS:
Capturable:
Types: ~disabled
FCOM:
Capturable:
Types: ~disabled
BIO:
Capturable:
Types: ~disabled
OILB:
Capturable:
Types: ~disabled
@@ -29,9 +45,10 @@ powerproxy.paratroopers:
HACKE6:
Inherits: E6
-RepairsBridges:
-ExternalCaptures:
Captures:
CaptureTypes: building
-ConsumedByCapture:
-EnterCursor:
-EnterBlockedCursor:
WithInfantryBody:
Targetable:
RequiresCondition: !jail

View File

@@ -59,8 +59,12 @@ SPY.Strong:
Range: 6c0
Infiltrates:
Types: MissionObjective
ExternalCaptures:
CaptureManager:
Captures:
CaptureTypes: MissionObjective
ConsumedByCapture: False
EnterCursor: ability
EnterBlockedCursor: move-blocked
Passenger:
DOG.Patrol:
@@ -87,9 +91,8 @@ TRUK.Hijackable:
Targetable:
TargetTypes: Ground, Repair, Vehicle, NoAutoTarget
-Huntable:
ExternalCapturable:
Capturable:
Types: MissionObjective
CaptureCompleteTime: 1
-DeliversCash:
RenderSprites:
Image: TRUK

View File

@@ -32,8 +32,8 @@ MISS:
Name: Soviet Air Force HQ
Capturable:
Types: building
CaptureThreshold: 100
ValidStances: Enemy
CaptureManager:
E6.MOD:
Inherits: E6
@@ -41,9 +41,9 @@ E6.MOD:
Prerequisites: ~barracks
Captures:
CaptureTypes: building
Sabotage: False
RenderSprites:
Image: e6
CaptureManager:
E6:
Buildable:

View File

@@ -101,8 +101,8 @@ AFAC:
GenericStancePrefix: false
-TooltipDescription@ally:
-TooltipDescription@other:
-ExternalCapturable:
-ExternalCapturableBar:
Capturable:
Types: ~disabled
-EngineerRepairable:
-GpsDot:
RenderSprites:
@@ -117,8 +117,8 @@ CCEN:
GenericName: Control Center
GenericVisibility: Enemy, Ally, Neutral
GenericStancePrefix: false
-ExternalCapturable:
-ExternalCapturableBar:
Capturable:
Types: ~disabled
-EngineerRepairable:
GpsPower:
Prerequisites: ~disabled

View File

@@ -91,9 +91,11 @@ FCOM:
RevealsShroud@GAPGEN:
Range: 4c0
WithBuildingBib:
ExternalCapturable:
CaptureCompleteTime: 30
ExternalCapturableBar:
CaptureManager:
Capturable:
Types: building
CapturableProgressBar:
CapturableProgressBlink:
GivesBuildableArea:
AreaTypes: building
BaseProvider:
@@ -118,8 +120,11 @@ HOSP:
Dimensions: 2,2
Health:
HP: 80000
ExternalCapturable:
ExternalCapturableBar:
CaptureManager:
Capturable:
Types: building
CapturableProgressBar:
CapturableProgressBlink:
EngineerRepairable:
Tooltip:
Name: Hospital
@@ -407,8 +412,11 @@ MISS:
Description: Capture to give visual range.
ValidStances: Neutral, Enemy
WithBuildingBib:
ExternalCapturable:
ExternalCapturableBar:
CaptureManager:
Capturable:
Types: building
CapturableProgressBar:
CapturableProgressBlink:
EngineerRepairable:
WithDeathAnimation:
DeathSequence: dead
@@ -429,8 +437,11 @@ BIO:
Dimensions: 2,2
RevealsShroud:
Range: 4c0
ExternalCapturable:
ExternalCapturableBar:
CaptureManager:
CapturableProgressBlink:
Capturable:
Types: building
CapturableProgressBar:
EngineerRepairable:
Tooltip:
Name: Biological Lab
@@ -465,8 +476,11 @@ OILB:
HP: 80000
RevealsShroud:
Range: 4c0
ExternalCapturable:
ExternalCapturableBar:
CaptureManager:
Capturable:
Types: building
CapturableProgressBar:
CapturableProgressBlink:
EngineerRepairable:
CashTrickler:
Interval: 375

View File

@@ -266,9 +266,9 @@
Guardable:
Tooltip:
GenericName: Vehicle
CaptureManager:
Capturable:
Types: vehicle
CaptureThreshold: 100
CancelActivity: True
CaptureNotification:
Notification: UnitStolen
@@ -648,8 +648,12 @@
EngineerRepairable:
AcceptsDeliveredCash:
WithMakeAnimation:
ExternalCapturable:
ExternalCapturableBar:
CaptureManager:
BeingCapturedCondition: being-captured
Capturable:
Types: building
CapturableProgressBar:
CapturableProgressBlink:
SpawnActorsOnSell:
ActorTypes: e1,e1,e1,tecn,tecn
MustBeDestroyed:
@@ -657,6 +661,7 @@
GpsDot:
String: Structure
Sellable:
RequiresCondition: !being-captured
SellSounds: cashturn.aud
WithBuildingRepairDecoration:
Image: allyrepair
@@ -922,9 +927,9 @@
AllowedTerrain: Clear, Rough, Road, Ore, Gems, Beach
Burns:
Damage: 200
CaptureManager:
Capturable:
Types: husk
CaptureThreshold: 100
ValidStances: Enemy, Neutral, Ally
TransformOnCapture:
ForceHealthPercentage: 25

View File

@@ -240,9 +240,14 @@ E6:
PipType: Yellow
EngineerRepair:
RepairsBridges:
ExternalCaptures:
CaptureManager:
Captures:
CaptureTypes: building
PlayerExperience: 25
CaptureDelay: 375
ConsumedByCapture: False
EnterCursor: ability
EnterBlockedCursor: move-blocked
Voiced:
VoiceSet: EngineerVoice
Selectable:
@@ -430,6 +435,7 @@ MECH:
ForceTargetStances: None
AttackFrontal:
Voice: Move
CaptureManager:
Captures:
CaptureTypes: husk
PlayerExperience: 25
@@ -536,6 +542,7 @@ HIJACKER:
Range: 5c0
Passenger:
PipType: Blue
CaptureManager:
Captures:
CaptureTypes: vehicle
PlayerExperience: 50

View File

@@ -184,6 +184,7 @@ SPEN:
ExitCell: 2,0
ProductionTypes: Ship
Production:
PauseOnCondition: being-captured
Produces: Ship, Submarine
PrimaryBuilding:
PrimaryCondition: primary
@@ -301,6 +302,7 @@ SYRD:
ExitCell: 2,0
ProductionTypes: Ship, Boat
Production:
PauseOnCondition: being-captured
Produces: Ship, Boat
PrimaryBuilding:
PrimaryCondition: primary
@@ -974,6 +976,7 @@ WEAP:
SpawnOffset: 213,-128,0
ExitCell: 1,2
Production:
PauseOnCondition: being-captured
Produces: Vehicle
ProvidesPrerequisite@allies:
Factions: allies, england, france, germany
@@ -1100,7 +1103,8 @@ FACT:
Range: 4c0
WithBuildingBib:
Production:
Produces: Building,Defense
PauseOnCondition: being-captured
Produces: Building, Defense
Valued:
Cost: 2500
Tooltip:
@@ -1109,13 +1113,13 @@ FACT:
ActorTypes: e1,e1,e1,tecn,tecn,e6
BaseBuilding:
Transforms:
PauseOnCondition: chrono-vortex
PauseOnCondition: chrono-vortex || being-captured
IntoActor: mcv
Offset: 1,1
Facing: 96
RequiresCondition: factundeploy
Sellable:
RequiresCondition: !chrono-vortex
RequiresCondition: !chrono-vortex && !being-captured
GrantConditionOnPrerequisite@GLOBALFACTUNDEPLOY:
Condition: factundeploy
Prerequisites: global-factundeploy
@@ -1125,6 +1129,7 @@ FACT:
ProductionType: Defense
Color: 8A8A8A
BaseProvider:
PauseOnCondition: being-captured
Range: 16c0
WithBuildingPlacedAnimation:
RequiresCondition: !chrono-vortex
@@ -1288,6 +1293,7 @@ HPAD:
Facing: 224
RallyPoint:
Production:
PauseOnCondition: being-captured
Produces: Aircraft, Helicopter
Reservable:
ProductionBar:
@@ -1377,6 +1383,7 @@ AFLD:
MoveIntoWorld: false
RallyPoint:
Production:
PauseOnCondition: being-captured
Produces: Aircraft, Plane
Reservable:
ProvidesPrerequisite@soviet:
@@ -1647,6 +1654,7 @@ BARR:
ExitCell: 0,2
ProductionTypes: Soldier, Infantry
Production:
PauseOnCondition: being-captured
Produces: Infantry, Soldier
PrimaryBuilding:
PrimaryCondition: primary
@@ -1727,6 +1735,7 @@ KENN:
ExitCell: -1,0
ProductionTypes: Dog, Infantry
Production:
PauseOnCondition: being-captured
Produces: Infantry, Dog
PrimaryBuilding:
PrimaryCondition: primary
@@ -1785,6 +1794,7 @@ TENT:
ExitCell: 0,2
ProductionTypes: Soldier, Infantry
Production:
PauseOnCondition: being-captured
Produces: Infantry, Soldier
PrimaryBuilding:
PrimaryCondition: primary

View File

@@ -19,11 +19,15 @@ World:
Scripts: sunstroke.lua
GAOLDCC2:
CaptureManager:
Capturable:
Types: building
ProvidesPrerequisite@BuildingName:
GAOLDCC3:
CaptureManager:
Capturable:
Types: building
ProvidesPrerequisite@BuildingName:
4TNK:

View File

@@ -751,7 +751,9 @@ CAARMR:
Palette: player
ProvidesPrerequisite:
Prerequisite: barracks.upgraded
CaptureManager:
Capturable:
Types: building
ThrowsShrapnel@SMALL:
Pieces: 6, 9
ThrowsShrapnel@LARGE:
@@ -794,7 +796,9 @@ CAHOSP:
HP: 80000
RenderSprites:
Palette: player
CaptureManager:
Capturable:
Types: building
CaptureNotification:
ProvidesPrerequisite@BuildingName:
ThrowsShrapnel@SMALL:

View File

@@ -350,7 +350,9 @@
Inherits@2: ^EmpDisable
GivesBuildableArea:
AreaTypes: building
CaptureManager:
Capturable:
Types: building
RepairableBuilding:
RepairStep: 700
PlayerExperience: 25
@@ -737,9 +739,9 @@
Voice: Move
HiddenUnderFog:
ActorLostNotification:
CaptureManager:
Capturable:
Types: Vehicle
CaptureThreshold: 100
CancelActivity: True
Guard:
Voice: Move

View File

@@ -126,6 +126,7 @@ MHIJACK:
Mobile:
Speed: 99
-Crushable:
CaptureManager:
Captures:
CaptureTypes: Vehicle
PlayerExperience: 50

View File

@@ -58,6 +58,7 @@ ENGINEER:
EngineerRepair:
RepairsBridges:
RepairNotification: BridgeRepaired
CaptureManager:
Captures:
CaptureTypes: building
PlayerExperience: 50