Jump to content

"draw fire" ability for playable mec?


davidlallen

Recommended Posts

For the "playable advent" mod, I want to give the mec a new ability "draw fire": by hacking into the Advent command network, the Mec can temporarily make itself a high priority target and draw enemy fire. This allows other units to take riskier positions and get better shots, knowing that the mec will be absorbing fire.

 

I have tried a few things and I can't get the effect I want. Can anybody suggest an approach?

 

My original thought was to duplicate the mimic beacon, only weaker, so it would not force units to run out of cover at it. But the mimic beacon is hard coded as a special case into every enemy AI routine. Search MimicBeacon in DefaultAI.ini for details. I would rather not add another special case to every AI routine.

 

I thought of adding a -50% defense to the unit while the ability is in effect. My theory is that the enemy AI is more likely to target units it can hit easily. I implemented this effect, and if the AI has a choice between two mecs, one with the effect and one without, it will usually target the one with the effect. That's good.

 

But very often, given a variety of targets, the enemy AI will ignore a mec right in front of them and shoot at some other target in cover. So, my effect is not strong enough. I don't know the details of AI targeting. The mec has high HP and high armor; that might count against being a good target?

 

Any help or suggestions would be appreciated.

Link to comment
Share on other sites

Targeting works by giving all options a TargetScore. The one with the highest score will be shot at.

 

If you want to get to your goal just with ini editing (and without plowing through all that Mimic Beacon behaviour), you will need to hook into the different target evaluations like for example

Behaviors=(BehaviorName=GenericTargetEvaluations, NodeType=Sequence, Child[0]=TargetScoreHitChance, Child[1]=TargetScoreHealth, Child[2]=TargetScoreFlanking, Child[3]=TargetScoreMarked, Child[4]=ApplyDifficultyModifiers, Child[5]=TargetScoreCivilian, Child[6]=AvoidBoundAndPanickedTargets)

and add another Child that checks for any of your MECs in sight, if they are in Draw Fire mode, and if both are true, adds a good amount of points to the TargetScore (Ctrl+F the AI.ini for "AddToTargetScore" for how that works.)

 

Now, there are quite a lot of different of these target evals, i don't know if you want to touch all of them.

 

An alternative would be altering the class that decides wether a unit is a Priority target or not.

 

The relevant lines for context in the AI.ini would be

Behaviors=(BehaviorName=TargetScorePriority, NodeType=Selector, Child[0]=ScoreTargetIfPriority, Child[1]=AddToTargetScore_0) ; If I'm looking for a priority target, then if the target isn't priority, it should be very negative.
Behaviors=(BehaviorName=ScoreTargetIfPriority, NodeType=Sequence, Child[0]=TargetIsPriorityUnit, Child[1]=AddToTargetScore_60) ; set a priority target for very high
Behaviors=(BehaviorName=TargetIsPriorityUnit, NodeType=Condition)

Maybe you could edit the class behind that TargetIsPriorityUnit condition for a more elegant solution than all the ini edits.

Link to comment
Share on other sites

I thought of applying the "Marked" effect to the unit, just as if it had been marked by an Advent Captain. It works! But the visualization is missing. Can anybody suggest something that I missed? When I dropunit a bunch of troopers and mark my mec, all the enemies attack it, which is just what I wanted. When I dropunit a captain, and he marks, I can see the red diamond target visualization on the targeted unit. I can't figure out how that comes. I'm calling the same function CreateMarkedEffect. Here is my whole function.

static function X2AbilityTemplate PA_MecDrawFire()
{
 local X2AbilityTemplate Template;
 local X2AbilityCooldown Cooldown;
 local X2Effect_Persistent Effect;
 `CREATE_X2ABILITY_TEMPLATE(Template, 'PA_MecDrawFire');
 Template.AbilitySourceName = 'eAbilitySource_Perk';
 Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_AlwaysShow;
 Template.Hostility = eHostility_Neutral;
 Template.IconImage = "img:///UILibrary_PerkIcons.UIPerk_item_mimicbeacon";
 Template.ShotHUDPriority = class'UIUtilities_Tactical'.const.CLASS_COLONEL_PRIORITY;
 Template.AbilityToHitCalc = default.DeadEye;
 Template.AbilityTargetStyle = default.SelfTarget;
 Template.AbilityTriggers.AddItem(default.PlayerInputTrigger);
 Template.AbilityCosts.AddItem(default.FreeActionCost);
 Cooldown = new class'X2AbilityCooldown';
 Cooldown.iNumTurns = 4;
 Template.AbilityCooldown = Cooldown;
 Template.AbilityShooterConditions.AddItem(default.LivingShooterProperty);
 Effect = class'X2StatusEffects'.static.CreateMarkedEffect(3, false);
 Effect.SetDisplayInfo(ePerkBuff_Passive, Template.LocFriendlyName, Template.GetMyLongDescription(), Template.IconImage, , , Template.AbilitySourceName);
 Template.AddTargetEffect(Effect);
 Template.BuildNewGameStateFn = TypicalAbility_BuildGameState;
 Template.BuildVisualizationFn = TypicalAbility_BuildVisualization;
 return Template;
}
Edited by davidlallen
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...