Bret1 Posted March 26, 2016 Share Posted March 26, 2016 (edited) I am trying to create a new "passive" Ability which triggers when the unit (which has the ability) dies.I look at the Andromedon (and the Vengeance ability, as the trigger is similar) code (X2Ability_Andromedon; were the templates get created) and i copied the code, but for some odd reason the ability doesnt trigger. This is the Code that creates the Template for my ability: (I changed the 'UnitDied' to 'UnitMoveFinished' just to try if that works (it didnt), but 'UnitDies' is what i actualy want it to trigger on) static function X2AbilityTemplate PsiFeedback() { local X2AbilityTemplate Template; //local X2Effect_Vengeance VengeanceEffect; local X2Condition_UnitProperty ShooterProperty, MultiTargetProperty; local X2AbilityTrigger_EventListener Listener; local X2Effect_FeedbackDamage DmgEffect; local X2Condition_UnitProperty UnitPropertyCondition; local Object ThisObj; ThisObj = class'X2Ability_LegitPsi'; `CREATE_X2ABILITY_TEMPLATE(Template, 'PsiFeedback');//` Template.AbilitySourceName = 'eAbilitySource_Perk'; Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_AlwaysShow;//eAbilityIconBehavior_NeverShow; Template.Hostility = eHostility_Offensive; Template.IconImage = "img:///UILibrary_PerkIcons.UIPerk_soulfire"; Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_AlwaysShow; Template.AbilitySourceName = 'eAbilitySource_Psionic'; Template.AbilityToHitCalc = default.DeadEye; Template.AbilityTargetStyle = default.SelfTarget; //Template.AbilityTargetStyle = default.SimpleSingleTarget; //Template.AbilityMultiTargetStyle = new class'X2AbilityMultiTarget_AllAllies'; Listener = new class'X2AbilityTrigger_EventListener'; Listener.ListenerData.Filter = eFilter_Unit; Listener.ListenerData.Deferral = ELD_OnStateSubmitted; Listener.ListenerData.EventFn = class'XComGameState_Ability'.static.AbilityTriggerEventListener_Self; Listener.ListenerData.EventID = 'UnitMoveFinished'; //Listener.ListenerData.OverrideListenerSource = ThisObj; Template.AbilityTriggers.AddItem(Listener); DmgEffect = new class'X2Effect_FeedbackDamage'; Template.AddTargetEffect(DmgEffect); // Target must be an enemy //UnitPropertyCondition = new class'X2Condition_UnitProperty'; //UnitPropertyCondition.ExcludeDead = true; //UnitPropertyCondition.ExcludeFriendlyToSource = true; //UnitPropertyCondition.RequireWithinRange = false; //Template.AbilityTargetConditions.AddItem(UnitPropertyCondition); Template.bSkipFireAction = true; Template.bShowActivation = true; Template.BuildNewGameStateFn = TypicalAbility_BuildGameState; Template.BuildVisualizationFn = TypicalAbility_BuildVisualization; `Log("Created PsiFeedback Template"); return Template; } Im pretty new to Unreal and I hope someone finds my error [Which is probaly realy dumb ^^] :wink: EDIT: typos; added //` to make to code look good in the "code" block^^ ; Edited March 26, 2016 by Bret1 Link to comment Share on other sites More sharing options...
davidlallen Posted March 26, 2016 Share Posted March 26, 2016 I am not an expert by any means, but when you say "it does not trigger", what effect are you expecting to see in game when this triggers? I'm not able to find "X2Effect_FeedbackDamage" in the code. How are you checking whether it triggers or not? Link to comment Share on other sites More sharing options...
Bret1 Posted March 26, 2016 Author Share Posted March 26, 2016 (edited) I'm not able to find "X2Effect_FeedbackDamage" in the code. X2Effect_FeedbackDamage is my own effect which does work (its only logs that its OnEffectAdded funtion is called), when i added it to other templates (i edited the vanilla dominate ability and added the effect). Edited March 26, 2016 by Bret1 Link to comment Share on other sites More sharing options...
davidlallen Posted March 26, 2016 Share Posted March 26, 2016 OK, FWIW I usually name my own classes with some prefix, that indicates they are mod code. For playable advent, all my classes are PA_whatever. Sorry, I don't know why your code is not working. Link to comment Share on other sites More sharing options...
CaveRat Posted March 26, 2016 Share Posted March 26, 2016 Hm, you've added some odd conditions. ExcludeFriendlyToSource = true?? Since the source and the target is one and the same, perhaps this condition prevents it from working. Link to comment Share on other sites More sharing options...
Bret1 Posted March 26, 2016 Author Share Posted March 26, 2016 Hm, you've added some odd conditions. ExcludeFriendlyToSource = true?? Since the source and the target is one and the same, perhaps this condition prevents it from working.I have removed that, still doesnt work :( Link to comment Share on other sites More sharing options...
Bret1 Posted March 26, 2016 Author Share Posted March 26, 2016 I looked through Lucubrations Infantry Code and he doesnt use the method that the Andromedon and the other vanilla Abilities use.He uses XComGameStates (dont ask me what this even is ^^) to listen to the Events.Next time i try to get this to work ill go through his code and try to understand it (= copy all of it ^^).Hopefully that way i can get this to work. Link to comment Share on other sites More sharing options...
CaveRat Posted March 26, 2016 Share Posted March 26, 2016 To be honest, I am not quite sure why your code is not working. Can you describe (preferably, in detail) how your unit obtains this ability, and how you are testing this in the tactical game? Are you loading a save with tactical game, or are you starting a quick game from debug menu? Link to comment Share on other sites More sharing options...
Bret1 Posted March 26, 2016 Author Share Posted March 26, 2016 (edited) Sooo. Main goal is to add a feedback effect to the vanilla Domiante effect (if the target dies u get some dmg, maybe get disoriented or even panik).I wrote an Effect which i added to the DominateTemplate which adds an ability to the target (if the target doesnt already has the ability).This Effect works just fine, i was able to add Deadeye (the sniper skill) to a Trooper by Dominating him. Next step was to replace Deadeye with a new Ability "PsiFeedback" which triggers when the unit dies and do some dmg to the PsiOperative.The Ability (for now its only a dummy ability that gives dmg to both target and shooter) gets added to the unit by dominating just like Deadeye and works when i set the trigger to "player activated", but doesnt when i set the trigger to "X2AbilityTrigger_EventListener" with 'UnitDied' as Event. Im Testing this by loading in a TacticalMission were i have a PsiOperative (tier 3) with Dominate in concealment next to a trooper pod (first mission force lvl, so Domiante allways hits). Did you get this method to work ? if so can u send me ur code so i can copy it ? :D Edited March 26, 2016 by Bret1 Link to comment Share on other sites More sharing options...
Lucubration Posted March 26, 2016 Share Posted March 26, 2016 Hey, Bret1. I use GameState objects because I often find that EventListeners and the default ability trigger functions aren't quite right for the sort of conditions under which I want my abilities to activate. Under the hood its all pretty similar, I'm just putting a new callback on a different object that I've created instead of using one of the default ones from the vanilla game scripts; I just find it a lot harder to track down what's not working correctly in situations like this when the even logic is all packaged away. If I understand correctly, the ability should be triggering damage against the unit with the ability every time they end a move? From what I can tell, it does look like that should be working. Link to comment Share on other sites More sharing options...
Recommended Posts