Gawesome Posted May 20, 2016 Share Posted May 20, 2016 I've been trying to create an ability but have run into a roadblock and would love some help with my code. The ability is called Wraithstrike, and it is a sword attack meant to allow the player to maintain concealment if the target is killed. As part of that, the ability is supposed to reduce enemy detection radius to nothing for the duration of the attack (or the player's turn... I don't actually know how to limit it just to the attack right now). Here's the snippet of code that controls the detection radius: PersistentEffect = new class'X2Effect_PersistentStatChange';PersistentEffect.BuildPersistentEffect(1, false, false);PersistentEffect.AddPersistentStatChange(eStat_DetectionModifier, 1.0f);PersistentEffect.SetDisplayInfo(ePerkBuff_Passive, Template.LocFriendlyName, Template.GetMyLongDescription(), Template.IconImage,,,Template.AbilitySourceName);Template.AddShooterEffect(PersistentEffect); For whatever reason, it doesn't work. Now, if I add this code to a passive ability that the player gets, it does work. I've run tests in which I've started a mission with this effect set to be forever active, and nobody can detect the player unless he attacks. But when attached to a sword attack ability, it doesn't seem to ever go into effect. I've tried setting the BuildPersisteEffect() to actually run forever, and that didn't work either. Does anyone have any ideas what I'm doing wrong? For reference, here is the full ability function: static function X2AbilityTemplate Wraithstrike(){local X2AbilityTemplate Template; local X2AbilityCost_SwiftBladeActionPoints ActionPointCost;local X2Effect_ApplyWeaponDamage WeaponDamageEffect;local array<name> SkipExclusions;local X2AbilityCooldown Cooldown;local X2AbilityToHitCalc_StandardMelee StandardMelee;local X2AbilityToHitCalc_StandardAim ToHitCalc;local X2Effect_Sunder SwordEffect;local X2Effect_PersistentStatChange PersistentEffect; `CREATE_X2ABILITY_TEMPLATE(Template, 'Wraithstrike'); Template.AdditionalAbilities.AddItem('WraithstrikeDamage'); // Icon PropertiesTemplate.IconImage = "img:///UILibrary_PerkIcons.UIPerk_bulletshred";Template.ShotHUDPriority = class'UIUtilities_Tactical'.const.CLASS_LIEUTENANT_PRIORITY;Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_AlwaysShow;Template.AbilitySourceName = 'eAbilitySource_Perk';Template.DisplayTargetHitChance = true;Template.AbilityConfirmSound = "TacticalUI_SwordConfirm"; SwordEffect = new class'X2Effect_Sunder';SwordEffect.BuildPersistentEffect(1, false, false);SwordEffect.SetDisplayInfo(ePerkBuff_Passive, Template.LocFriendlyName, Template.GetMyLongDescription(), Template.IconImage,,,Template.AbilitySourceName);Template.AddShooterEffect(SwordEffect); // Activated by a button press; additionally, tells the AI this is an activatableTemplate.AbilityTriggers.AddItem(default.PlayerInputTrigger); // *** VALIDITY CHECKS *** //// Normal effect restrictions (except disoriented)SkipExclusions.AddItem(class'X2AbilityTemplateManager'.default.DisorientedName);Template.AddShooterEffectExclusions(SkipExclusions); // Target Conditions//Template.AbilityTargetConditions.AddItem(default.LivingHostileTargetProperty);Template.AbilityTargetConditions.AddItem(default.MeleeVisibilityCondition); SkipExclusions.AddItem(class'X2StatusEffects'.default.BurningName);Template.AddShooterEffectExclusions(SkipExclusions); // Shooter Conditions//Template.AbilityShooterConditions.AddItem(default.LivingShooterProperty);SkipExclusions.AddItem(class'X2StatusEffects'.default.BurningName);Template.AddShooterEffectExclusions(SkipExclusions); // Damage Effect WeaponDamageEffect = new class'X2Effect_ApplyWeaponDamage';Template.AddTargetEffect(WeaponDamageEffect); ActionPointCost = new class'X2AbilityCost_SwiftBladeActionPoints';ActionPointCost.iNumPoints = 1;ActionPointCost.bMoveCost = true;ActionPointCost.bConsumeAllPoints = true;Template.AbilityCosts.AddItem(ActionPointCost); Cooldown = new class'X2AbilityCooldown';Cooldown.iNumTurns = default.SUNDER_COOLDOWN;Template.AbilityCooldown = Cooldown; // Reduce detection radiusPersistentEffect = new class'X2Effect_PersistentStatChange';PersistentEffect.BuildPersistentEffect(1, false, false);PersistentEffect.AddPersistentStatChange(eStat_DetectionModifier, 1.0f);PersistentEffect.SetDisplayInfo(ePerkBuff_Passive, Template.LocFriendlyName, Template.GetMyLongDescription(), Template.IconImage,,,Template.AbilitySourceName);Template.AddShooterEffect(PersistentEffect); //ToHitCalc = new class'X2AbilityToHitCalc_StandardAim';//ToHitCalc.FinalMultiplier = default.SUNDER_AIM_MULTIPLIER;//Template.AbilityToHitCalc = ToHitCalc; // Weapon Upgrade CompatibilityTemplate.bAllowFreeFireWeaponUpgrade = true; // Flag that permits action to become 'free action' via 'Hair Trigger' or similar upgrade / effects Template.bAllowBonusWeaponEffects = true;Template.bSkipMoveStop = true; StandardMelee = new class'X2AbilityToHitCalc_StandardMelee';StandardMelee.bHitsAreCrits = false;Template.AbilityToHitCalc = StandardMelee; // Targeting MethodTemplate.AbilityTargetStyle = new class'X2AbilityTarget_MovingMelee';Template.TargetingMethod = class'X2TargetingMethod_MeleePath';Template.bUsesFiringCamera = true;Template.CinescriptCameraType = "Ranger_Reaper"; // Voice eventsTemplate.ActivationSpeech = 'BulletShred';Template.SourceMissSpeech = 'SwordMiss'; // MAKE IT LIVE! Template.BuildNewGameStateFn = TypicalMoveEndAbility_BuildGameState;Template.BuildInterruptGameStateFn = TypicalMoveEndAbility_BuildInterruptGameState; Template.BuildVisualizationFn = TypicalAbility_BuildVisualization; //Conceal upon killshotTemplate.ConcealmentRule = eConceal_KillShot; Template.bCrossClassEligible = false; return Template; } static function X2AbilityTemplate WraithstrikeDamage(){local X2AbilityTemplate Template;local X2Effect_DeadeyeDamage DamageEffect; // Icon Properties`CREATE_X2ABILITY_TEMPLATE(Template, 'WraithstrikeDamage');Template.IconImage = "img:///UILibrary_PerkIcons.UIPerk_momentum"; Template.AbilitySourceName = 'eAbilitySource_Perk';Template.eAbilityIconBehaviorHUD = EAbilityIconBehavior_NeverShow;Template.Hostility = eHostility_Neutral; Template.AbilityToHitCalc = default.DeadEye;Template.AbilityTargetStyle = default.SelfTarget;Template.AbilityTriggers.AddItem(default.UnitPostBeginPlayTrigger); DamageEffect = new class'X2Effect_DeadeyeDamage';DamageEffect.BuildPersistentEffect(1, true, false, false);DamageEffect.SetDisplayInfo(ePerkBuff_Passive, Template.LocFriendlyName, Template.GetMyLongDescription(), Template.IconImage, false,,Template.AbilitySourceName);Template.AddTargetEffect(DamageEffect); Template.BuildNewGameStateFn = TypicalAbility_BuildGameState;// NOTE: No visualization on purpose! return Template;} Link to comment Share on other sites More sharing options...
dubiousintent Posted May 20, 2016 Share Posted May 20, 2016 Wrong forum. You want the XCOM-2 Mod Talk forum. You can PM a moderator to have them move this post there. -Dubious- Link to comment Share on other sites More sharing options...
Recommended Posts