Advertisement
Guest User

Untitled

a guest
May 16th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static function PipeBomb_Explosion_BuildVisualization(XComGameState VisualizeGameState)
  2. {
  3.     local XComGameStateContext_Ability  AbilityContext;
  4.     local X2Action_PlayEffect           EffectAction;
  5.     local VisualizationActionMetadata   ActionMetadata;
  6.     local X2Action_Delay                DelayAction;
  7.     local X2Action_StartStopSound       SoundAction;
  8.     local XComGameState_Unit            UnitState;
  9.     local XComGameStateVisualizationMgr VisMgr;
  10.     local Array<X2Action>               arrFoundActions;
  11.  
  12.     local X2Action_WaitForAbilityEffect WaitAction;
  13.     local vector                        DukesPos, OppositePos, Diff;
  14.     local X2Action_MoveTurn             MoveTurnAction;
  15.     local int i;
  16.  
  17.     TypicalAbility_BuildVisualization(VisualizeGameState);
  18.  
  19.     //  Duke Unit State
  20.     AbilityContext = XComGameStateContext_Ability(VisualizeGameState.GetContext());
  21.     UnitState = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(AbilityContext.InputContext.SourceObject.ObjectID));
  22.    
  23.     ActionMetadata.StateObject_NewState = UnitState;
  24.     ActionMetadata.VisualizeActor = UnitState.GetVisualizer();
  25.  
  26.     VisMgr = `XCOMVISUALIZATIONMGR;
  27.  
  28.     //  Calculate the opposite looking direction relative to the explosion
  29.     DukesPos = `XWORLD.GetPositionFromTileCoordinates(UnitState.TileLocation);
  30.     Diff = DukesPos - AbilityContext.InputContext.TargetLocations[0];
  31.     OppositePos = DukesPos + Diff;
  32.  
  33.     //  Make duke turn his back to the explosion
  34.     VisMgr.GetNodesOfType(VisMgr.BuildVisTree, class'X2Action_ExitCover', arrFoundActions);
  35.     if (arrFoundActions.Length > 0)
  36.     {  
  37.         //X2Action_ExitCover(arrFoundActions[0]).bSkipExitCoverVisualization = true; //breaks ability animation and makes the soldier shoot primary weapon. wtf???
  38.         X2Action_ExitCover(arrFoundActions[0]).TargetLocation = OppositePos;
  39.  
  40.         MoveTurnAction = X2Action_MoveTurn(class'X2Action_MoveTurn'.static.AddToVisualizationTree(ActionMetadata, AbilityContext, true, ArrFoundActions[0]));
  41.         MoveTurnAction.m_vFacePoint = OppositePos;
  42.     }
  43.  
  44.     //  make sure camera always looks at duke from the front
  45.     VisMgr.GetNodesOfType(VisMgr.BuildVisTree, class'X2Action_StartCinescriptCamera', arrFoundActions);
  46.     if (arrFoundActions.Length > 0)
  47.     {  
  48.         `LOG("Focus points:" @ X2Action_StartCinescriptCamera(arrFoundActions[0]).CinescriptCamera.VisFocusPoints.Length,, 'IRIDUKE');
  49.         for (i = 0; i < X2Action_StartCinescriptCamera(arrFoundActions[0]).CinescriptCamera.VisFocusPoints.Length; i++)
  50.         {
  51.             `LOG("Focus point:" @ X2Action_StartCinescriptCamera(arrFoundActions[0]).CinescriptCamera.VisFocusPoints[i].vFocusPoint,, 'IRIDUKE');
  52.         }
  53.     }
  54.     else
  55.     {
  56.         `LOG("Could not find camera action.",, 'IRIDUKE');
  57.     }
  58.  
  59.     //  make sure the Duke keeps looking in the opposite direction. Otherwise he snap turns before the ability camera exits.
  60.     VisMgr.GetNodesOfType(VisMgr.BuildVisTree, class'X2Action_EnterCover', arrFoundActions);
  61.     if (arrFoundActions.Length > 0)
  62.     {  
  63.         //  add a delay action to the parent of the Enter Cover action
  64.         DelayAction = X2Action_Delay(class'X2Action_Delay'.static.AddToVisualizationTree(ActionMetadata, AbilityContext, false, arrFoundActions[0].ParentActions[0]));
  65.         DelayAction.Duration = 2.5f;
  66.  
  67.         //  reparent Enter Cover to the Delay Action
  68.         VisMgr.DisconnectAction(arrFoundActions[0]);    //  if it is, then it is the Psi Pinions action. We disconnect it from its parents
  69.         VisMgr.ConnectAction(arrFoundActions[0], VisMgr.BuildVisTree,, DelayAction);    //  and set it as a child of the Wait Action so that it comes after it
  70.     }
  71.  
  72.     // use Vis Manager to find the Fire Action so we can parent the explosion FX to it
  73.     arrFoundActions.Length = 0;
  74.     VisMgr.GetNodesOfType(VisMgr.BuildVisTree, class'X2Action_Fire', arrFoundActions)
  75.  
  76.     //  there should be only one Fire Action, so we use the first one found
  77.     if (arrFoundActions.Length > 0)
  78.     {
  79.         WaitAction = X2Action_WaitForAbilityEffect(class'X2Action_WaitForAbilityEffect'.static.AddToVisualizationTree(ActionMetadata, AbilityContext, true, arrFoundActions[0]));
  80.  
  81.         //Do the detonation
  82.         EffectAction = X2Action_PlayEffect(class'X2Action_PlayEffect'.static.AddToVisualizationTree(ActionMetadata, AbilityContext, false, WaitAction));
  83.         EffectAction.EffectName = "IRI_Duke.PS_PipeBombExplosion";
  84.         EffectAction.EffectLocation = AbilityContext.InputContext.TargetLocations[0];
  85.         EffectAction.EffectRotation = Rotator(vect(0, 0, 1));
  86.         EffectAction.bWaitForCompletion = false;
  87.         EffectAction.bWaitForCameraArrival = false;
  88.         EffectAction.bWaitForCameraCompletion = false;
  89.         EffectAction.CenterCameraOnEffectDuration = 2.0f;
  90.         EffectAction.RevealFOWRadius = class'XComWorldData'.const.WORLD_StepSize * 5.0f;
  91.  
  92.         SoundAction = X2Action_StartStopSound(class'X2Action_StartStopSound'.static.AddToVisualizationTree(ActionMetadata, AbilityContext, false, WaitAction));
  93.         SoundAction.Sound = new class'SoundCue';
  94.         SoundAction.Sound.AkEventOverride = AkEvent'SoundX2CharacterFX.Proximity_Mine_Explosion';
  95.         SoundAction.bIsPositional = true;
  96.         SoundAction.vWorldPosition = AbilityContext.InputContext.TargetLocations[0];
  97.  
  98.         //Keep the camera there after things blow up
  99.         //DelayAction = X2Action_Delay(class'X2Action_Delay'.static.AddToVisualizationTree(ActionMetadata, AbilityContext, true, EffectAction));
  100.         //DelayAction.Duration = 3;
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement