Jump to content

help requested: intermediate ability creation


davidlallen

Recommended Posts

So, I have been trying to learn more about creating abilities, but I am not getting anywhere fast. I have been able to make a few simple ones, which are "reskins" or minor variants of existing abilities. I have created a tiny standalone mod with the "shells" of the more advanced abilities I would like to create, attached to this post.

 

Any help or specific guidance would be worthwhile. If only there were an ability guide :-)

 

a. I have an ability with a 4 turn cooldown which lasts two turns. So, at any time the ability may be active or not, and the player may not remember. I would like to have an icon appear in the lower left ability icon row while the ability is active. I have succeeded in making an icon permanently visible there, for example in a passive. But, I want the icon to appear when the effect starts, and disappear 2 turns later when the effect ends. I am not sure how to hook the effect ending, and if I hooked it, I would not know how to make the icon disappear. This is for PA_ViperSlither in the attachment.

 

b. I would like to make a variant of Implacable. I would like the soldier to be able to take a normal shot as their first action, and then get a half move afterwards, regardless of whether the shot was a kill or even a hit. I don't want the soldier to be able to take *any* action, only a move, so it is more similar to Implacable than Quickdraw. This is for PA_ViperShootAndScoot in the attachment.

 

c. I would like to make an ability which is like Mimic Beacon, for the Mec in its tank role. In a classic MMO like World of Warcraft, the tank class can attract aggro (the attention of the monsters) and hold it, so the monsters attack the tank instead of attacking other, weaker characters. This seems a lot like the mimic beacon. I don't want to *force* all the enemies to attack, the way mimic beacon does, but I would like to *highly encourage* it. This is for PA_MecTaunt in the attachment.

 

d. I have a regeneration ability working for HP, by reusing the Faceless ability. But I would like one which works for armor damage. That is, if the MEC tank is affected by shred, I would like the armor to "grow back". Probably this should not be an automatic passive like faceless regeneration; if it cost one action point and grew back 1 or 2 armor points, that would probably work well. This is for PA_MecArmorReplate in the attachment.

 

I have a bunch of other ideas but hopefully I can learn from the above, and possibly help write a guide afterwards.

 

The zip file is a full zip of the modbuddy directory, which creates a new class "AbilityGuy". I have been testing by loading the mod, buying five recruits, "levelupbarracks 7", find the one which got promoted as AbilityGuy, clicking all the abilities in the promotion screen, and then taking them on a tactical mission. If there is a more efficient way to get the abilities into a tactical fight, that would be a handy tip to have as well.

Edited by davidlallen
Link to comment
Share on other sites

On Item 1, you'll want to tie the display of the icon to the effect, not the ability. Since it lasts 2 turns, presumably you are using some extension of X2Effect_Persistent.

In the AbilityTemplate definition code, when you define your effect, look at X2Effect.SetDisplayInfo( ... ). That can be used to tie display of a passive icon in lower left container to the effect being active.

Link to comment
Share on other sites

I'm not sure how helpful this will be, but at least it might give you an idea of what to search for (I'm not able to search right now, so can't help much), but for #2, there is an X2Effect_GrantActionPoint (or something very similar) that grants action points of different types. Off the top of my head (so these may not be the exact names in game), I've seen the StandardActionPoint, RunAndGunActionPoint, and a couple related to the Viper's bind ability (I think they're similar to BindActionPoint and EndBindActionPoint). If you can somewhere find a list of all of those, there might be a MoveActionPoint or something similar that does what you want (may be what they give with implacable, I'd start checking there, but I'm guessing if it was that obviously there, you'd have seen it). If that exists and you can figure out what the actual name is, then you can just make the ability cost 2 action points and grant an additional move point to the shooter as part of the ability.

 

If there isn't a move-type action point, then things likely get trickier.

Link to comment
Share on other sites

Correct, the ranger is a good one to look at for that, because he gets those:

ActionPointEffect = new class'X2Effect_GrantActionPoints';
ActionPointEffect.NumActionPoints = 1;
ActionPointEffect.PointType = class'X2CharacterTemplateManager'.default.RunAndGunActionPoint;
Template.AddTargetEffect(ActionPointEffect);
Template.AbilityTargetStyle = default.SelfTarget;
Template.AbilityTriggers.AddItem(default.PlayerInputTrigger);

Most of this stuff is actually used by the Unit GameState, and they are defined in X2CharacterTemplateManager

	StandardActionPoint="standard"
	MoveActionPoint="move"
	OverwatchReserveActionPoint="overwatch"
	PistolOverwatchReserveActionPoint="pistoloverwatch"
	GremlinActionPoint="gremlin"
	RunAndGunActionPoint="runandgun"
	EndBindActionPoint="endbind"
	GOHBindActionPoint="gohbind"
	CounterattackActionPoint="counterattack"
	UnburrowActionPoint="unburrow"
	ReturnFireActionPoint="returnfire"
	DeepCoverActionPoint="deepcover"
Link to comment
Share on other sites

Thanks! For shoot and scoot, I guess I want MoveActionPoint. The trick is that this should apply to any shot, including a shot granted by a special ability (notably spit). I'll look at the code more carefully in 8 hours from now.

 

Any leads on a weaker mimic beacon? I wasn't able to find the details of this ability, but it is obviously *very* enticing to the enemy AI.

Link to comment
Share on other sites

I know that I do something similar with listening for the Overwatch ability (specifically) for EstablishedDefenses in the Infantry class.

 

If ScootAndShoot is a persistent effect on the Viper, you can override PostAbilityCostPaid to look at every ability that the Viper uses and see if you want to do something extra because of it. You should be able to do something like this in the effect class:

class X2Effect_PA_ShootAndScoot extends X2Effect_Persistent;

var string GrantedActionPointName;

// Triggered on the unit after they pay for an ability
function bool PostAbilityCostPaid(XComGameState_Effect EffectState, XComGameStateContext_Ability AbilityContext, XComGameState_Ability kAbility, XComGameState_Unit SourceUnit, XComGameState_Item AffectWeapon, XComGameState NewGameState, const array<name> PreCostActionPoints, const array<name> PreCostReservePoints)
{
	local UnitValue UnitValue;
	local X2AbilityTemplate AbilityTemplate;
	
	// Check if this is an offensive ability
	if (kAbility.GetMyTemplate().Hostility == eHostility_Offensive)
	{
            // Check if we've granted the move action point yet this turn
            if (!SourceUnit.GetUnitValue(GrantedActionPointName, UnitValue) || UnitValue.fValue != 1)
            {
	        // Grant the action point. Don't need to add a gamestate object because the caller takes care of that, just modify the one they've passed in
                SourceUnit.ActionPoints.AddItem(class'X2CharacterTemplateManager'.default.MoveActionPoint);
		
	        // Indicate that we've granted the move action point this turn. Unit value is cleaned up at the start of this unit's controller's next turn
                SourceUnit.SetUnitFloatValue(GrantedActionPointName, 1, eCleanup_BeginTurn);
	    }
	}
}

DefaultProperties
{
    GrantedActionPointName="GrantedShootAndScoot"
}

Regarding #4: I have no proof at all of this, just a suspicion that "Shred" damage is a stat stored on the unit state somewhere and is subtracted from the total of all armor effects (due to items or abilities) that the unit has active. If that's the case, then you might be able to find it as a UnitValue or a property on the unit state and reduce it with your ability. This is all just huge speculation on my part, though.

 

 

Edit: Just got home and looked. The total amount of armor shredded during a mission is stored on the unit at XComGameState_Unit.Shredded.

Edited by Lucubration
Link to comment
Share on other sites

Thanks for the tips. I was able to pursue a few of these and I got one layer deeper, but I still haven't reached the bottom.

 

For (b) Shoot and Scoot, I can find that Implacable registers for event UnitDied, checks to make sure the unit is an enemy, and then grants a movement point to the current unit. That is pretty similar to what I want. Except, I want to register for an event like UnitAttacked, and check to make sure it is the current unit. Unfortunately, I cannot find where the various types of events are defined. Where is this? Or more specifically, is there an event which triggers when a unit attacks, using any attack ability?

 

For ©, I still have no clue how the mimic beacon effect works.

 

For (d) regenerating armor, I can find the eStat_ArmorMitigation, and (thanks to Lucubration) I can see the unitstate maintains the shred damage, and I can see how these are used together. What I would like to do, is to have an ability whose button is illuminated only when unitstate.Shredded is nonzero. When the ability is activated, I would like a persistent effect which decrements unitstate.Shredded, or simply sets it to zero. Unfortunately the existing persistent effect only affects elements in the eStat array, and this Shredded count is not one of them. How can I build an ability which will change unitstate.Shredded?

Link to comment
Share on other sites

For (b) Shoot and Scoot, I can find that Implacable registers for event UnitDied, checks to make sure the unit is an enemy, and then grants a movement point to the current unit. That is pretty similar to what I want. Except, I want to register for an event like UnitAttacked, and check to make sure it is the current unit. Unfortunately, I cannot find where the various types of events are defined. Where is this? Or more specifically, is there an event which triggers when a unit attacks, using any attack ability?

 

There is an event 'AbilityActivated' which you can register, but you shouldn't even have to do that; the class I posted up above should accomplish what you're looking for if you just have the ability persist it on the soldier.

Edited by Lucubration
Link to comment
Share on other sites

Thanks, I will try out shoot and scoot.

 

I have looked further for mimic beacon information. All I can find is details about how it is thrown. Why do the aliens attack the mimic beacon before anything else? I cannot figure out why its target priority is higher.

Link to comment
Share on other sites

So, I've been looking around a bit and I can't find anything that should set it's priority higher. I even grepped all the files for the word "beacon" and then the word "mimic" and looked at every place they're mentioned and, if it's there, i'm missing it. Closest I can find is in XGAIBehavior. First this is declared:

var int BTPriorityTarget; // Priority Target specified by Behavior Tree for use in movement profile scoring.

 

and then later:

// If a visible mimic beacon exists, all destinations must have LoS to it.
if( BTPriorityTarget > 0 && bScoringPriorityTarget )
{
TilePosition = XWorld.GetTileCoordinatesFromPosition(vPosition);
PriorityTile = XWorld.GetTileCoordinatesFromPosition(ScoringPriorityLocation);
if (!`XWORLD.CanSeeTileToTile(TilePosition, PriorityTile, VisInfo))
{
return false;
}
}
Because of that, I did a bit of looking in some of the behavior tree files (X2AIBT*whatever* and X2Effect_RunBehaviorTree) and can't find anything specifically there. There are a bunch of scoring methods based on stats, so maybe there's a stat which the Mimic Beacon has an abnormally high value, but I can't find something like that anywhere (took another look through the various mimic beacon files and X2Action_CreateDoppleganger and didn't spot it).
I didn't look as well as I possibly could have, so it's possible there's something there and I missed the line, but I figured since I spent a little time on that I should mention it, in case it gives you any ideas of where to look. And to give you a heads up there's nothing in any of the source files that ever DIRECTLY says to give the mimic beacon priority (at least not that uses the word "beacon" or "mimic" that I could see).
Oh, and apparently mimic beacon is the only unit that is set bNeverSelectable, which I got from a few lines like this:
if( bSkipUnselectable && CurrentUnitState.GetMyTemplate().bNeverSelectable ) // Currently includes only mimic beacons.
So maybe there's a check for THAT somewhere in targeting priority, but I don't know. And now I'm off to do my real work. :)
Link to comment
Share on other sites

  • Recently Browsing   0 members

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