Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static function X2AbilityTemplate SparkRocketLauncher()
- {
- local X2AbilityTemplate AbilityTemplate;
- local X2Condition_UnitProperty ShooterPropertyCondition;
- AbilityTemplate = class'X2Ability_HeavyWeapons'.static.RocketLauncherAbility('SparkRocketLauncher');
- AbilityTemplate.RemoveTemplateAvailablility(AbilityTemplate.BITFIELD_GAMEAREA_Multiplayer);
- X2AbilityMultiTarget_Radius(AbilityTemplate.AbilityMultiTargetStyle).AddAbilityBonusRadius('Rainmaker', default.RAINMAKER_RADIUS_ROCKETLAUNCHER);
- ShooterPropertyCondition = new class'X2Condition_UnitProperty';
- ShooterPropertyCondition.RequireSoldierClasses.AddItem('Spark');
- AbilityTemplate.AbilityShooterConditions.AddItem(ShooterPropertyCondition);
- AbilityTemplate.BuildVisualizationFn = SparkHeavyWeaponVisualization;
- AbilityTemplate.bDisplayInUITacticalText = false;
- //BEGIN AUTOGENERATED CODE: Template Overrides 'SparkRocketLauncher'
- AbilityTemplate.bFrameEvenWhenUnitIsHidden = true;
- //END AUTOGENERATED CODE: Template Overrides 'SparkRocketLauncher'
- return AbilityTemplate;
- }
- function SparkHeavyWeaponVisualization(XComGameState VisualizeGameState)
- {
- local XComGameStateHistory History;
- local XComGameStateContext_Ability Context;
- local XComGameState_Unit SourceUnitState;
- local array<XComGameState_Unit> AttachedUnitStates;
- local XComGameState_Unit CosmeticUnit;
- local VisualizationActionMetadata EmptyMetadata;
- local VisualizationActionMetadata ActionMetadata;
- local X2AbilityTemplate AbilityTemplate;
- local XComGameState_Item CosmeticHeavyWeapon;
- local X2Action_ExitCover ExitCoverAction;
- local X2Action_ExitCover SourceExitCoverAction;
- local X2Action_EnterCover EnterCoverAction;
- local X2Action_Fire FireAction;
- local X2Action_Fire NewFireAction;
- local XComGameStateVisualizationMgr VisMgr;
- local Actor SourceVisualizer;
- local Array<X2Action> ParentArray;
- local Array<X2Action> TempDamageNodes;
- local Array<X2Action> DamageNodes;
- local int ScanNodes;
- VisMgr = `XCOMVISUALIZATIONMGR;
- // Jwats: Build the standard visualization
- TypicalAbility_BuildVisualization(VisualizeGameState);
- // Jwats: Now handle the cosmetic unit
- History = `XCOMHISTORY;
- Context = XComGameStateContext_Ability(VisualizeGameState.GetContext());
- AbilityTemplate = class'XComGameState_Ability'.static.GetMyTemplateManager().FindAbilityTemplate(Context.InputContext.AbilityTemplateName);
- SourceUnitState = XComGameState_Unit(History.GetGameStateForObjectID(Context.InputContext.SourceObject.ObjectID));
- SourceVisualizer = History.GetVisualizer(SourceUnitState.ObjectID);
- SourceUnitState.GetAttachedUnits(AttachedUnitStates, VisualizeGameState);
- `assert(AttachedUnitStates.Length > 0);
- CosmeticUnit = AttachedUnitStates[0];
- CosmeticHeavyWeapon = CosmeticUnit.GetItemInSlot(eInvSlot_HeavyWeapon);
- // Jwats: Because the shooter might be using a unique fire action we'll replace it with the standard fire action to just
- // command the cosmetic unit
- SourceExitCoverAction = X2Action_ExitCover(VisMgr.GetNodeOfType(VisMgr.BuildVisTree, class'X2Action_ExitCover', SourceVisualizer));
- FireAction = X2Action_Fire(VisMgr.GetNodeOfType(VisMgr.BuildVisTree, AbilityTemplate.ActionFireClass, SourceVisualizer));
- // Jwats: Replace the current fire action with this fire action
- NewFireAction = X2Action_Fire(class'X2Action_Fire'.static.CreateVisualizationAction(Context, SourceVisualizer));
- NewFireAction.SetFireParameters(Context.IsResultContextHit());
- VisMgr.ReplaceNode(NewFireAction, FireAction);
- // Jwats: Have the bit do an exit cover/fire/enter cover
- ActionMetadata = EmptyMetadata;
- ActionMetadata.StateObject_OldState = History.GetGameStateForObjectID(CosmeticUnit.ObjectID, eReturnType_Reference, VisualizeGameState.HistoryIndex - 1);
- ActionMetadata.StateObject_NewState = VisualizeGameState.GetGameStateForObjectID(CosmeticUnit.ObjectID);
- if( ActionMetadata.StateObject_NewState == none )
- ActionMetadata.StateObject_NewState = ActionMetadata.StateObject_OldState;
- ActionMetadata.VisualizeActor = History.GetVisualizer(CosmeticUnit.ObjectID);
- // Jwats: Wait to exit cover until the main guy is ready
- ExitCoverAction = X2Action_ExitCover(class'X2Action_ExitCover'.static.AddToVisualizationTree(ActionMetadata, Context, false, , SourceExitCoverAction.ParentActions));
- FireAction = X2Action_Fire(AbilityTemplate.ActionFireClass.static.AddToVisualizationTree(ActionMetadata, Context, false));
- EnterCoverAction = X2Action_EnterCover(class'X2Action_EnterCover'.static.AddToVisualizationTree(ActionMetadata, Context, false, FireAction));
- ExitCoverAction.UseWeapon = XGWeapon(History.GetVisualizer(CosmeticHeavyWeapon.ObjectID));
- FireAction.SetFireParameters(Context.IsResultContextHit());
- // Jwats: Make sure that the fire actions are in sync! Wait until both have completed their exit cover
- ParentArray.Length = 0;
- ParentArray.AddItem(ExitCoverAction);
- ParentArray.AddItem(SourceExitCoverAction);
- VisMgr.ConnectAction(FireAction, VisMgr.BuildVisTree, false, , ParentArray);
- VisMgr.ConnectAction(NewFireAction, VisMgr.BuildVisTree, false, , ParentArray);
- // Jwats: Update the apply weapon damage nodes to have the bit's fire flamethrower as their parent instead of the spark's fire node
- VisMgr.GetNodesOfType(VisMgr.BuildVisTree, class'X2Action_ApplyWeaponDamageToUnit', TempDamageNodes);
- DamageNodes = TempDamageNodes;
- VisMgr.GetNodesOfType(VisMgr.BuildVisTree, class'X2Action_ApplyWeaponDamageToTerrain', TempDamageNodes);
- for( ScanNodes = 0; ScanNodes < TempDamageNodes.Length; ++ScanNodes )
- {
- DamageNodes.AddItem(TempDamageNodes[ScanNodes]);
- }
- for( ScanNodes = 0; ScanNodes < DamageNodes.Length; ++ScanNodes )
- {
- if( DamageNodes[ScanNodes].ParentActions[0] == NewFireAction )
- {
- VisMgr.DisconnectAction(DamageNodes[ScanNodes]);
- VisMgr.ConnectAction(DamageNodes[ScanNodes], VisMgr.BuildVisTree, false, FireAction);
- }
- }
- // Jwats: Now make sure the enter cover of the bit is a child of all the apply weapon damage nodes
- VisMgr.ConnectAction(EnterCoverAction, VisMgr.BuildVisTree, false, , DamageNodes);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement