kexx456 Posted July 5, 2016 Share Posted July 5, 2016 Hi all! Hoping someone can point me in the right direction. I've created a new enemy unit, and given it a new ability. The ability performs much like the Sectopod's Lightning Field, damaging soldiers inside a radius. Now, I would like to give this enemy skill the ability to cause the "Unconscious" Status Effects, but I'm having trouble understanding how other existing skills implement it. Actually, I've only found it on the Stun Lancer's ability, and don't understand what I have to write in the code. Here is what my code looks like: // This is an Unreal Script class X2Ability_ValkyriePoop extends X2Ability; static function array<X2DataTemplate> CreateTemplates() { local array<X2DataTemplate> Templates; Templates.AddItem(CreateValkyriePoopAbility()); return Templates; } static function X2AbilityTemplate CreateValkyriePoopAbility() { local X2AbilityTemplate Template; local X2AbilityCost_ActionPoints ActionPointCost; local X2AbilityTrigger_PlayerInput InputTrigger; local X2AbilityMultiTarget_Radius RadiusMultiTarget; local X2Condition_UnitProperty UnitProperty; local X2Effect_ApplyWeaponDamage DamageEffect; local X2AbilityCooldown_LocalAndGlobal Cooldown; local X2Effect_Persistent UnconsciousEffect; `CREATE_X2ABILITY_TEMPLATE(Template, 'ValkyriePoop'); //IconImage needs to be changed once there is an icon for this Template.IconImage = "img:///UILibrary_PerkIcons.UIPerk_lightningfield"; Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_AlwaysShow; Template.Hostility = eHostility_Offensive; UnitProperty = new class'X2Condition_UnitProperty'; UnitProperty.ExcludeDead = true; Template.AbilityShooterConditions.AddItem(UnitProperty); Template.AbilityToHitCalc = default.DeadEye; //Cooldowns Cooldown = new class'X2AbilityCooldown_LocalAndGlobal'; Cooldown.iNumTurns = 1; Cooldown.NumGlobalTurns = 1; Template.AbilityCooldown = Cooldown; // Targets enemies UnitProperty = new class'X2Condition_UnitProperty'; UnitProperty.ExcludeFriendlyToSource = true; UnitProperty.ExcludeDead = true; UnitProperty.ExcludeCivilian = true; Template.AbilityMultiTargetConditions.AddItem(UnitProperty); //it's 1 for testing purposes, but change to 3 or more once ready!!!!!! ActionPointCost = new class'X2AbilityCost_ActionPoints'; ActionPointCost.iNumPoints = 1; Template.AbilityCosts.AddItem(ActionPointCost); //Triggered by player or AI InputTrigger = new class'X2AbilityTrigger_PlayerInput'; Template.AbilityTriggers.AddItem(InputTrigger); //fire from self, with a radius amount Template.AbilityTargetStyle = default.SelfTarget; RadiusMultiTarget = new class'X2AbilityMultiTarget_Radius'; RadiusMultiTarget.fTargetRadius = 8; RadiusMultiTarget.bIgnoreBlockingCover = true; Template.AbilityMultiTargetStyle = RadiusMultiTarget; //Weapon damage to all affected DamageEffect = new class'X2Effect_ApplyWeaponDamage'; DamageEffect.EffectDamageValue = class'X2Item_DefaultWeapons'.default.SECTOPOD_LIGHTINGFIELD_BASEDAMAGE; Template.AddMultiTargetEffect(DamageEffect); Template.BuildNewGameStateFn = TypicalAbility_BuildGameState; Template.BuildVisualizationFn = TypicalAbility_BuildVisualization; Template.bShowActivation = true; Template.bSkipFireAction = false; Template.bSkipExitCoverWhenFiring = true; Template.CustomFireAnim = 'HL_SignalPositivePoop'; //Template.CinescriptCameraType = "Sectopod_LightningField"; //currently not working!!!! UnconsciousEffect = class'X2StatusEffects'.static.CreateUnconsciousStatusEffect(true); UnconsciousEffect.MinStatContestResult = 5; UnconsciousEffect.MaxStatContestResult = 0; UnconsciousEffect.bRemoveWhenSourceDies = false; Template.AddTargetEffect(UnconsciousEffect); return Template; }I've searched the other files, mainly inside the X2Ability, and found many instances of the following being written: Template.AbilitySourceName = 'eAbilitySource_Standard'; Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_ShowIfAvailable; Template.Hostility = eHostility_Defensive; Template.IconImage = "img:///UILibrary_PerkIcons.UIPerk_coupdegrace"; Template.AddTargetEffect(class'X2StatusEffects'.static.CreateUnconsciousStatusEffect());I don't know if that plays into it or not, but I'm having no luck so far. I want it to be simple, no conditions attached to it, no unit vs unit on strength stats or anything of the sort. Just a simple % roll if the status will land or not on the multiple soldiers inside the radius. Please help someone! Link to comment Share on other sites More sharing options...
kexx456 Posted July 5, 2016 Author Share Posted July 5, 2016 (edited) ok, so digging further and testing trial n' error style, I removed local X2Effect_Persistent UnconsciousEffect;and UnconsciousEffect = class'X2StatusEffects'.static.CreateUnconsciousStatusEffect(true); UnconsciousEffect.MinStatContestResult = 5; UnconsciousEffect.MaxStatContestResult = 0; UnconsciousEffect.bRemoveWhenSourceDies = false; Template.AddTargetEffect(UnconsciousEffect);and instead added this at the bottom Template.AbilitySourceName = 'eAbilitySource_Standard'; Template.AddTargetEffect(class'X2StatusEffects'.static.CreateUnconsciousStatusEffect()); Template.BuildNewGameStateFn = TypicalAbility_BuildGameState; Results: The unit is falling unconscious after casting the ability, not the enemies who did suffer damage. 2 notes: 1. I haven't gotten as far as to implement this in the unit's AI, so I'm testing this by going into debug, tactical, console command: dropunit valkyrie, and using the unit. The unit has a blue health bar, and is on my side. I'm triggering the ability, so maybe the ability actually works properly but from an alien perspective? ignoring friendly aliens and hitting the enemy xcom? what's the console command that lets me control the alien forces? 2. If the previous point isn't true and has nothing to at all, then I'm guessing it has to do with the fact that the ability triggers from self, right? How do I go about changing it so that the unconscious status effect affects the enemy units and not myself? Edited July 5, 2016 by kexx456 Link to comment Share on other sites More sharing options...
LeaderEnemyBoss Posted July 5, 2016 Share Posted July 5, 2016 1.to create an enemy unit an control it yourself: dropunit valkyrie 1(the 1 at the end is the team, 1 is enemy, 0 is xcom if i remember correctly) 2.to control enemy units: X2allowselectall 1(the interface is a bit buggy in this mode, you have to end the xcom turn to use the alien) Link to comment Share on other sites More sharing options...
kexx456 Posted July 5, 2016 Author Share Posted July 5, 2016 (edited) Hey leader! Thanks for the tip. Got any insights perhaps on my issue at hand? EDIT: I went in and used an enemy unit this time, but yeah, same issue. It's the alien caster that falls unconscious after casting the ability, and not the xcom soldiers. The xcom soldiers do take damage though, thankfully. Just gotta sort out what lines of code are needed so that the status effect lands on them as well and not the caster. Anyone know? Edited July 5, 2016 by kexx456 Link to comment Share on other sites More sharing options...
LeaderEnemyBoss Posted July 5, 2016 Share Posted July 5, 2016 (edited) try to change Template.AddTargetEffect to Template.AddMultiTargetEffect or something similar (dont know the exact syntax atm). I dont have the modbuddy available atm, but AddTargetEffect references your (single-)targetstyle, which is this:Template.AbilityTargetStyle = default.SelfTarget; Edited July 5, 2016 by LeaderEnemyBoss Link to comment Share on other sites More sharing options...
fxsjosh Posted July 5, 2016 Share Posted July 5, 2016 This ability looks like a self-targeted AOE. Using AddTargetEffect will hit the caster. Use AddMultiTargetEffect instead. Also, MinStatContestResult = 5 is what was preventing it from applying before since it won't apply unless the stat contest succeeds >= 5. Link to comment Share on other sites More sharing options...
kexx456 Posted July 6, 2016 Author Share Posted July 6, 2016 Thank you both so much!! I did that exact change, and it now works wonderfully! Now I'm afraid the ability might be too OP. Ability:Doesn't end turn. (because i haven't gotten around to it, but in theory it will)Deals 8-9 damage. (appears mid-game, just like archons, so I think this amount is fine. it's meant to be a high priority, deadly enemy. Focus should be taking her down first.)Guaranteed unconscious effect to anyone caught inside radius. (love this, makes the player have to shift strats and focus fire her down before other aliens)Radius of 8 tiles. (seems fine, forces players to scatter a bit more.) How can I make it so that the unconscious status effect is not guaranteed, but instead just a simple % based hit? Also, would like to make this percentage number configurable in an ini. Link to comment Share on other sites More sharing options...
prowler83 Posted July 6, 2016 Share Posted July 6, 2016 Change Template.AbilityToHitCalc = default.DeadEye to some other subclass of X2AbilityToHitCalc. Probably X2AbilityToHitCalc_PercentChance, and set that HitCalc's PercentToHit from an ini. Link to comment Share on other sites More sharing options...
kexx456 Posted July 6, 2016 Author Share Posted July 6, 2016 Won't changing that make the entire ability percentage based? Like, the normal electrical damage of 8-9 I want that to always hit, and only the unconscious status effect to be % based. Do I need to differentiate that? Link to comment Share on other sites More sharing options...
LeaderEnemyBoss Posted July 6, 2016 Share Posted July 6, 2016 (edited) What you had at first basically would achieve this. It implements a stat check, the higher the soldiers will stat, the higher the chance to resist the the effect. So basically the following should do the work: UnconsciousEffect = class'X2StatusEffects'.static.CreateUnconsciousStatusEffect(true); UnconsciousEffect.MinStatContestResult = 5; UnconsciousEffect.MaxStatContestResult = 0; UnconsciousEffect.bRemoveWhenSourceDies = false; Template.AddMultiTargetEffect(UnconsciousEffect); I dont really know how the numbers work, but you can mess around with them to alter the chances. Edited July 6, 2016 by LeaderEnemyBoss Link to comment Share on other sites More sharing options...
Recommended Posts