Advertisement
Drakten

Untitled

Sep 6th, 2020
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 KB | None | 0 0
  1. static function X2AbilityTemplate SparkRocketLauncher()
  2. {
  3. local X2AbilityTemplate AbilityTemplate;
  4. local X2Condition_UnitProperty ShooterPropertyCondition;
  5.  
  6. AbilityTemplate = class'X2Ability_HeavyWeapons'.static.RocketLauncherAbility('SparkRocketLauncher');
  7. AbilityTemplate.RemoveTemplateAvailablility(AbilityTemplate.BITFIELD_GAMEAREA_Multiplayer);
  8.  
  9. X2AbilityMultiTarget_Radius(AbilityTemplate.AbilityMultiTargetStyle).AddAbilityBonusRadius('Rainmaker', default.RAINMAKER_RADIUS_ROCKETLAUNCHER);
  10.  
  11. ShooterPropertyCondition = new class'X2Condition_UnitProperty';
  12. ShooterPropertyCondition.RequireSoldierClasses.AddItem('Spark');
  13. AbilityTemplate.AbilityShooterConditions.AddItem(ShooterPropertyCondition);
  14. AbilityTemplate.BuildVisualizationFn = SparkHeavyWeaponVisualization;
  15.  
  16. AbilityTemplate.bDisplayInUITacticalText = false;
  17. //BEGIN AUTOGENERATED CODE: Template Overrides 'SparkRocketLauncher'
  18. AbilityTemplate.bFrameEvenWhenUnitIsHidden = true;
  19. //END AUTOGENERATED CODE: Template Overrides 'SparkRocketLauncher'
  20.  
  21. return AbilityTemplate;
  22. }
  23.  
  24. function SparkHeavyWeaponVisualization(XComGameState VisualizeGameState)
  25. {
  26. local XComGameStateHistory History;
  27. local XComGameStateContext_Ability Context;
  28. local XComGameState_Unit SourceUnitState;
  29. local array<XComGameState_Unit> AttachedUnitStates;
  30. local XComGameState_Unit CosmeticUnit;
  31. local VisualizationActionMetadata EmptyMetadata;
  32. local VisualizationActionMetadata ActionMetadata;
  33. local X2AbilityTemplate AbilityTemplate;
  34. local XComGameState_Item CosmeticHeavyWeapon;
  35. local X2Action_ExitCover ExitCoverAction;
  36. local X2Action_ExitCover SourceExitCoverAction;
  37. local X2Action_EnterCover EnterCoverAction;
  38. local X2Action_Fire FireAction;
  39. local X2Action_Fire NewFireAction;
  40. local XComGameStateVisualizationMgr VisMgr;
  41. local Actor SourceVisualizer;
  42. local Array<X2Action> ParentArray;
  43. local Array<X2Action> TempDamageNodes;
  44. local Array<X2Action> DamageNodes;
  45. local int ScanNodes;
  46.  
  47. VisMgr = `XCOMVISUALIZATIONMGR;
  48. // Jwats: Build the standard visualization
  49. TypicalAbility_BuildVisualization(VisualizeGameState);
  50.  
  51. // Jwats: Now handle the cosmetic unit
  52. History = `XCOMHISTORY;
  53. Context = XComGameStateContext_Ability(VisualizeGameState.GetContext());
  54. AbilityTemplate = class'XComGameState_Ability'.static.GetMyTemplateManager().FindAbilityTemplate(Context.InputContext.AbilityTemplateName);
  55.  
  56. SourceUnitState = XComGameState_Unit(History.GetGameStateForObjectID(Context.InputContext.SourceObject.ObjectID));
  57. SourceVisualizer = History.GetVisualizer(SourceUnitState.ObjectID);
  58. SourceUnitState.GetAttachedUnits(AttachedUnitStates, VisualizeGameState);
  59. `assert(AttachedUnitStates.Length > 0);
  60. CosmeticUnit = AttachedUnitStates[0];
  61.  
  62. CosmeticHeavyWeapon = CosmeticUnit.GetItemInSlot(eInvSlot_HeavyWeapon);
  63.  
  64. // Jwats: Because the shooter might be using a unique fire action we'll replace it with the standard fire action to just
  65. // command the cosmetic unit
  66. SourceExitCoverAction = X2Action_ExitCover(VisMgr.GetNodeOfType(VisMgr.BuildVisTree, class'X2Action_ExitCover', SourceVisualizer));
  67. FireAction = X2Action_Fire(VisMgr.GetNodeOfType(VisMgr.BuildVisTree, AbilityTemplate.ActionFireClass, SourceVisualizer));
  68.  
  69. // Jwats: Replace the current fire action with this fire action
  70. NewFireAction = X2Action_Fire(class'X2Action_Fire'.static.CreateVisualizationAction(Context, SourceVisualizer));
  71. NewFireAction.SetFireParameters(Context.IsResultContextHit());
  72. VisMgr.ReplaceNode(NewFireAction, FireAction);
  73.  
  74. // Jwats: Have the bit do an exit cover/fire/enter cover
  75. ActionMetadata = EmptyMetadata;
  76. ActionMetadata.StateObject_OldState = History.GetGameStateForObjectID(CosmeticUnit.ObjectID, eReturnType_Reference, VisualizeGameState.HistoryIndex - 1);
  77. ActionMetadata.StateObject_NewState = VisualizeGameState.GetGameStateForObjectID(CosmeticUnit.ObjectID);
  78. if( ActionMetadata.StateObject_NewState == none )
  79. ActionMetadata.StateObject_NewState = ActionMetadata.StateObject_OldState;
  80. ActionMetadata.VisualizeActor = History.GetVisualizer(CosmeticUnit.ObjectID);
  81.  
  82. // Jwats: Wait to exit cover until the main guy is ready
  83. ExitCoverAction = X2Action_ExitCover(class'X2Action_ExitCover'.static.AddToVisualizationTree(ActionMetadata, Context, false, , SourceExitCoverAction.ParentActions));
  84. FireAction = X2Action_Fire(AbilityTemplate.ActionFireClass.static.AddToVisualizationTree(ActionMetadata, Context, false));
  85. EnterCoverAction = X2Action_EnterCover(class'X2Action_EnterCover'.static.AddToVisualizationTree(ActionMetadata, Context, false, FireAction));
  86. ExitCoverAction.UseWeapon = XGWeapon(History.GetVisualizer(CosmeticHeavyWeapon.ObjectID));
  87. FireAction.SetFireParameters(Context.IsResultContextHit());
  88.  
  89. // Jwats: Make sure that the fire actions are in sync! Wait until both have completed their exit cover
  90. ParentArray.Length = 0;
  91. ParentArray.AddItem(ExitCoverAction);
  92. ParentArray.AddItem(SourceExitCoverAction);
  93. VisMgr.ConnectAction(FireAction, VisMgr.BuildVisTree, false, , ParentArray);
  94. VisMgr.ConnectAction(NewFireAction, VisMgr.BuildVisTree, false, , ParentArray);
  95.  
  96. // Jwats: Update the apply weapon damage nodes to have the bit's fire flamethrower as their parent instead of the spark's fire node
  97. VisMgr.GetNodesOfType(VisMgr.BuildVisTree, class'X2Action_ApplyWeaponDamageToUnit', TempDamageNodes);
  98. DamageNodes = TempDamageNodes;
  99. VisMgr.GetNodesOfType(VisMgr.BuildVisTree, class'X2Action_ApplyWeaponDamageToTerrain', TempDamageNodes);
  100.  
  101. for( ScanNodes = 0; ScanNodes < TempDamageNodes.Length; ++ScanNodes )
  102. {
  103. DamageNodes.AddItem(TempDamageNodes[ScanNodes]);
  104. }
  105.  
  106. for( ScanNodes = 0; ScanNodes < DamageNodes.Length; ++ScanNodes )
  107. {
  108. if( DamageNodes[ScanNodes].ParentActions[0] == NewFireAction )
  109. {
  110. VisMgr.DisconnectAction(DamageNodes[ScanNodes]);
  111. VisMgr.ConnectAction(DamageNodes[ScanNodes], VisMgr.BuildVisTree, false, FireAction);
  112. }
  113. }
  114.  
  115. // Jwats: Now make sure the enter cover of the bit is a child of all the apply weapon damage nodes
  116. VisMgr.ConnectAction(EnterCoverAction, VisMgr.BuildVisTree, false, , DamageNodes);
  117. }
  118.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement