Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class X2Ability_Silacoid_AbilitySet extends X2Ability;
- static function array<X2DataTemplate> CreateTemplates()
- {
- local array<X2DataTemplate> Templates;
- Templates.AddItem(FireTrail());
- Templates.AddItem(PurePassive('FireTrail_Passive', "img:///UILibrary_PerkIcons.UIPerk_andromedon_poisoncloud"));
- return Templates;
- }
- static function X2AbilityTemplate FireTrail()
- {
- local X2AbilityTemplate Template;
- local X2AbilityTrigger_EventListener EventListener;
- `CREATE_X2ABILITY_TEMPLATE(Template, 'FireTrail');
- Template.IconImage = "img:///UILibrary_PerkIcons.UIPerk_andromedon_poisoncloud"; // TODO: This needs to be changed
- Template.AdditionalAbilities.AddItem('FireTrail_Passive');
- Template.AbilitySourceName = 'eAbilitySource_Standard';
- Template.eAbilityIconBehaviorHUD = EAbilityIconBehavior_NeverShow;
- Template.Hostility = eHostility_Neutral;
- //This ability fires as part of game states where the Andromedon robot moves
- EventListener = new class'X2AbilityTrigger_EventListener';
- EventListener.ListenerData.Deferral = ELD_OnStateSubmitted;
- EventListener.ListenerData.EventID = 'UnitMoveFinished';
- EventListener.ListenerData.Filter = eFilter_Unit;
- EventListener.ListenerData.EventFn = BuildFireTrail_Self;
- Template.AbilityTriggers.AddItem(EventListener);
- // Targets the Andromedon unit so it can be replaced by the andromedon robot;
- Template.AbilityTargetStyle = default.SelfTarget;
- //NOTE: This ability does not require a build game state or visualization function because this is handled
- // by the event listener and associated functionality when creating world tile effects
- Template.BuildNewGameStateFn = Empty_BuildGameState;
- return Template;
- }
- function XComGameState Empty_BuildGameState( XComGameStateContext Context )
- {
- return none;
- }
- static function EventListenerReturn BuildFireTrail_Self(Object EventData, Object EventSource, XComGameState GameState, Name EventID)
- {
- local XComGameStateContext_Ability MoveContext;
- local int TileIndex;
- local XComGameState NewGameState;
- local float AbilityRadius;
- local XComWorldData WorldData;
- local vector TargetLocation;
- local array<TilePosPair> OutTiles;
- local TTile MovementTile;
- local XComGameState_Unit UnitStateObject;
- local XComGameStateHistory History;
- local int FireNumTurns;
- MoveContext = XComGameStateContext_Ability(GameState.GetContext());
- History = `XCOMHISTORY;
- WorldData = `XWORLD;
- //Define how wide the trail will spread
- AbilityRadius = class'XComWorldData'.const.WORLD_StepSize * 0.5f;
- //Define how long the trail will last
- FireNumTurns = 2;
- //These branches define different situations for which we should generate tile effects. Our first step is to
- //see what tiles we will be affecting
- if( MoveContext.InputContext.MovementPaths[0].MovementTiles.Length > 0 )
- {
- //If this move was uninterrupted, or we do not have a resume
- if( MoveContext.InterruptionStatus == eInterruptionStatus_None || MoveContext.ResumeHistoryIndex < 0 )
- {
- //Build the list of tiles that will be affected by the fire and set it into our tile update game state object
- for(TileIndex = 0; TileIndex < MoveContext.InputContext.MovementPaths[0].MovementTiles.Length; ++TileIndex)
- {
- MovementTile = MoveContext.InputContext.MovementPaths[0].MovementTiles[TileIndex];
- TargetLocation = WorldData.GetPositionFromTileCoordinates(MovementTile);
- WorldData.CollectTilesInSphere( OutTiles, TargetLocation, AbilityRadius );
- }
- }
- }
- else
- {
- //This may occur during teleports, spawning, or other instaneous modes of travel
- UnitStateObject = XComGameState_Unit(History.GetGameStateForObjectID(MoveContext.InputContext.SourceObject.ObjectID));
- UnitStateObject.GetKeystoneVisibilityLocation(MovementTile);
- TargetLocation = WorldData.GetPositionFromTileCoordinates(MovementTile);
- WorldData.CollectTilesInSphere( OutTiles, TargetLocation, AbilityRadius );
- }
- //If we will be adding fire to any tiles, do the rest of the set up
- if( OutTiles.Length > 0 )
- {
- //Build the game state for the fire trail update
- NewGameState = History.CreateNewGameState(true, class'XComGameStateContext_AreaDamage'.static.CreateXComGameStateContext());
- if( UnitStateObject == none )
- {
- //This may occur during teleports, spawning, or other instaneous modes of travel
- UnitStateObject = XComGameState_Unit(History.GetGameStateForObjectID(MoveContext.InputContext.SourceObject.ObjectID));
- }
- class'X2Effect_ApplyFireToWorld'.static.SharedApplyFireToTiles('X2Effect_ApplyFireToWorld', X2Effect_ApplyFireToWorld(class'Engine'.static.FindClassDefaultObject("X2Effect_ApplyFireToWorld")), NewGameState, OutTiles, UnitStateObject, FireNumTurns);
- //Submit the new game state to the rules engine
- `GAMERULES.SubmitGameState(NewGameState);
- }
- return ELR_NoInterrupt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement