Jump to content

Adding Perks to Aliens


Yzaxtol

Recommended Posts

As near as I can tell, aliens don't appear to be given perks in the same way as XCOM soldiers.

 

The most likely place I could find that their abilities are set is in XGAIAbilityDM.RebuildAbilityList. This calls XGUnit.BuildAbilities, which is the same function that builds the ability list for player-controlled units.

 

With that being true, it may be possible to manually give an alien unit a perk (either via the GivePerk call or by incrementing XGUnit.aUpgrades[PerkID]). The XGUnit.BuildAbilities call is in native code, and there may be direct assignments there granting specific aliens specific abilities, bypassing the aUpgrades list entirely, though.

 

EDIT:

Some abilities could be granted directly, however, bypassing the regular perk/ability structure. Examples of this are the damage reduction and regeneration abilities that I've coded for units (primarily intended for aliens, though ^_^).

 

Lightning reflexes, for example, is handled in the XGAbility_Targeted.RollForHit function. It looks like:

 

 

if(m_bReactionFire && (GetPrimaryTarget().GetCharacter().HasUpgrade(35)) && (!GetPrimaryTarget().m_bLightningReflexesUsed))

{

m_bHit = false;

GetPrimaryTarget().m_bLightningReflexesUsed = true;

kBroadcastWorldMessage = XComPresentationLayer(XComPlayerController(WorldInfo.GetALocalPlayerController()).m_Pres).GetWorldMessenger().Message(XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kGameCore.GetUnexpandedLocalizedMessageString(1), GetPrimaryTarget().GetLocation(), 3, m_kUnit.m_eTeamVisibilityFlags, class'XComUIBroadcastWorldMessage_UnexpandedLocalizedString');

// End:0x131a Loop:False

if(kBroadcastWorldMessage != none)

{

XComUIBroadcastWorldMessage_UnexpandedLocalizedString(kBroadcastWorldMessage).Init_UnexpandedLocalizedString(1, GetPrimaryTarget().GetLocation(), 3, m_kUnit.m_eTeamVisibilityFlags);

}

}

 

Simply granting an alien perk 35 (ePerk_LightningReflexes) should trigger this code. Alternatively, specific code checking against each alien type could be used to trigger the above conditional.

 

This latter approach is most-often used in the default game.

 

The bombard perk/ability, for example -- rather than assigning the perk or ability to the alien unit during unit creation, there is a function defined in XGUnit:

 

simulated function bool HasBombardAbility()

{

local int iType;

 

iType = GetCharacter().m_kChar.iType;

// End:0x84 Loop:False

if(iType == 10 || (iType == 11) || (iType == 8 ) || (iType == 16))

{

return true;

}

return false;

}

 

This specifically checks for four types of aliens that are given the Bombard ability. To unlock the Bombard perk for XCOM units I had to modify that function to return true also if the unit had the perk ePerk_Bombard. Edited by Amineri
Link to comment
Share on other sites

I think I'll try how this GivePerk performs on aliens. Does anyone know of a good place to add the call, preferably in XGUnit or XGCharacter? Is that OnTurnEndHook function safe to edit?

 

I thought of using this to give aliens squadsight (to compensate the fact that now all my soldiers have squadsight as well, but with long range aim penalty), but indeed this could be used to customize aliens a bit more, and in conjunction with the Dynamic Alien stats modlet it could be used to grant perks to aliens as the invasion progresses, but maybe most interestingly, it could be used to give random perks to aliens, I'm thinking of a few that would cause a surprise, like covering fire, lightning reflexes, spinter, tactical sense, aggression, and many many more... I'm not expecting the AI to handle activable abilities, but those passive abilities they all could be used... I'm trying to imagine the effect that could have if each alien got just 1 perk at random at the beginning of the map... and just another thought, I could be cool to make a "ultimate alien tactical fighter", an alien with all the abilities, covering fire, danger zone, mayhem, rapid reaction, ALL! Just to see how cool it is to kill them after the hell of a battle they'd offer.

 

... and thinking of Amineri's shivs mods, perhaps the aliens should have their anti-tank specialist with HEAT ammo ¿?

Link to comment
Share on other sites

The UpdateEquipment call made during OnTurnBegin is a safer place to add new code. All it does currently is update the Overheat increment of the weapons, which is an old feature that doesn't work.

 

It is where johnnlump and I put in DR and regeneration code, and where I plan to put in the actual regeneration as well, once I get back to the dynamic stats mod and implement the DR and regeneration.

 

------------------

 

Following up on your idea of giving out random perks... each alien could have its stats randomized within a certain range, which would provide a degree of unpredictability (can that sectoid reach that cover? maybe it has +1 move compared to "base" sectoids). Aim can actually be adjusted in increments as low as 1% change. The game actually takes pains to keep the "soldier randomization" aim amount in multiples of 5 -- presumably to try and make it easier for players? More like a d20 instead of a true %. I don't know.

 

This random range could be adjusted based on "how well" the player is doing, thus always keeping the game challenging. It's a little bit cheating, but the OG (based on Julian Gollop's own recent presentation about the game at GDC) had a dynamic loop that measured how well the player was doing and adjusted the difficulty dynamically. This was because so much of the game was procedural that it was nigh-impossible to balance the game beforehand in a static manner.

 

I really like the idea of there being "super alien soldiers" -- rather like a mini-boss. I guess they'd look just like any other alien, but in all fairness a Rookie in ghost armor and with a plasma rifle looks just a Colonel with the same kit.

Link to comment
Share on other sites

I was thinking of something more along the lines of a color-palette shift of the textures applied to the different aliens, which could allow for some basic color-coding of different alien types (albeit in a very crude way).

 

The only other way to distinguish different alien types is via the weapon attached. I once tried to give a sectoid a light plasma rifle via an INI file edit, but it didn't work. Clearly some aliens can have weapons swapped out -- I just don't know what the limit is or how to implement it.

 

Just had a funny vision of a sectoid armed with Heavy Plasma :).

 

-------------------------------------------

 

Along with adding perks, you might consider improving their existing perks. Making Mindmerge grant 2 or even 3 (and thus also heal) HP would make it more powerful, particularly if the sectoids could be made to mindmerge non-sectoid aliens (imagine a sectoid granting a buffed MindMerge to a Muton Elite).

 

Another possible enhancement to Mindmerge is to make it only have a _chance_ to kill the linked target if the merger unit is killed. This chance could be reduced as the game progresses, to keep it from being too easy to kill late-game tough units by killing the linked sectoids.

 

Other possibly enhancements could include giving late-game sectoids increased visual range, letting them act as "psionic scouts". Their plasma pistols could still be limited to shooting in visual range, but they could act as spotters for other aliens with squadsight.

Link to comment
Share on other sites

I have set up a great place to do all sorts of things to individual alien units.

 

This can include:

1) Assigning alien units perks

2) Randomizing alien unit stats

3) Adding to an individual unit's stats to create a mini-boss

 

------------------------------------

 

This involves the following two changes, both in XComGame.upk >> XGUnit.

 

First off, in XGUnit.Init, change:

 

if(IsAI())

{
InitBehavior();
}
// End:0x1BF
else // 3 bytes
{
// End:0x1BF
if(isHuman()) // 3 bytes + function call
{
}
}
to:

 

if(IsAI())

{
InitBehavior();
DebugAnims(local1, local2);
}

 

The local variable are just dummy calls, because the DebugAnims function requires two parameters. However, we won't be using these passed parameters for anything. (In fact we can't -- trying to use them would crash the game).

 

The DebugAnims function is a big remnant function left over from debugging the game. It can be 100% rewritten to do whatever is desired. Given that the function is 2562 bytes, a lot can be done in it.

 

Hex code for the XGUnit.Init change :

 

XGUnit.Init

original hex:
40 B0 00 00 50 55 00 00 00 00 00 00 25 B0 00 00 13 32 00 00 00 00 00 00 2B B0 00 00 00 00 00 00 7D 05 00 00 01 BF 00 00 4F 02 00 00 BF 01 00 00 49 02 00 28 15 49 02 00 27 15 1C 13 32 00 00 00 2B B0 00 00 00 2A B0 00 00 00 29 B0 00 00 2D 00 28 B0 00 00 4A 16 0F 01 62 AF 00 00 01 ED F9 FF FF 0F 01 0A 31 00 00 00 2A B0 00 00 19 01 0A 31 00 00 0A 00 00 00 00 00 00 1B F3 3A 00 00 00 00 00 00 16 1B 5C 02 00 00 00 00 00 00 35 CE 0D 00 00 D5 0D 00 00 00 00 19 01 0A 31 00 00 09 00 C3 A2 00 00 00 01 C3 A2 00 00 4A 16 0F 01 63 AF 00 00 00 2B B0 00 00 1B E8 5D 00 00 00 00 00 00 16 1B D5 5D 00 00 00 00 00 00 16 1B DE 5D 00 00 00 00 00 00 16 1B E6 5D 00 00 00 00 00 00 16 14 2D 01 89 AF 00 00 19 01 0A 31 00 00 0A 00 B7 A2 00 00 00 2D 01 B7 A2 00 00 1B 20 62 00 00 00 00 00 00 24 00 16 1B 9E 66 00 00 00 00 00 00 2D 00 27 B0 00 00 4A 16 07 52 01 72 01 09 31 00 00 2A 16 04 28 07 6E 01 2D 00 28 B0 00 00 07 6E 01 1B E1 19 00 00 00 00 00 00 16 04 28 19 00 29 B0 00 00 15 00 00 00 00 00 00 1B 75 02 00 00 00 00 00 00 17 2D 01 F1 30 00 00 16 07 B2 01 1B C6 3C 00 00 00 00 00 00 16 1B 5B 3A 00 00 00 00 00 00 16 06 BF 01 07 BF 01 1B 82 3D 00 00 00 00 00 00 16 07 03 02 9A 35 D3 0D 00 00 D5 0D 00 00 00 00 19 01 0A 31 00 00 09 00 C3 A2 00 00 00 01 C3 A2 00 00 2C 0E 16 14 2D 01 EF 30 00 00 27 1B 2F 63 00 00 00 00 00 00 4A 16 1B BC 61 00 00 00 00 00 00 24 00 16 1B 6E 13 00 00 00 00 00 00 16 1B F1 01 00 00 00 00 00 00 16 0F 01 68 AF 00 00 1B 2F 35 00 00 00 00 00 00 16 04 27 04 3A 26 B0 00 00 53
new hex: (virtual 0x253)
40 B0 00 00 50 55 00 00 00 00 00 00 25 B0 00 00 13 32 00 00 00 00 00 00 2B B0 00 00 00 00 00 00 7D 05 00 00 01 BF 00 00 53 02 00 00 BF 01 00 00 49 02 00 28 15 49 02 00 27 15 1C 13 32 00 00 00 2B B0 00 00 00 2A B0 00 00 00 29 B0 00 00 2D 00 28 B0 00 00 4A 16 0F 01 62 AF 00 00 01 ED F9 FF FF 0F 01 0A 31 00 00 00 2A B0 00 00 19 01 0A 31 00 00 0A 00 00 00 00 00 00 1B F3 3A 00 00 00 00 00 00 16 1B 5C 02 00 00 00 00 00 00 35 CE 0D 00 00 D5 0D 00 00 00 00 19 01 0A 31 00 00 09 00 C3 A2 00 00 00 01 C3 A2 00 00 4A 16 0F 01 63 AF 00 00 00 2B B0 00 00 1B E8 5D 00 00 00 00 00 00 16 1B D5 5D 00 00 00 00 00 00 16 1B DE 5D 00 00 00 00 00 00 16 1B E6 5D 00 00 00 00 00 00 16 14 2D 01 89 AF 00 00 19 01 0A 31 00 00 0A 00 B7 A2 00 00 00 2D 01 B7 A2 00 00 1B 20 62 00 00 00 00 00 00 24 00 16 1B 9E 66 00 00 00 00 00 00 2D 00 27 B0 00 00 4A 16 07 52 01 72 01 09 31 00 00 2A 16 04 28 07 6E 01 2D 00 28 B0 00 00 07 6E 01 1B E1 19 00 00 00 00 00 00 16 04 28 19 00 29 B0 00 00 15 00 00 00 00 00 00 1B 75 02 00 00 00 00 00 00 17 2D 01 F1 30 00 00 16 07 CD 01 1B C6 3C 00 00 00 00 00 00 16 1B 5B 3A 00 00 00 00 00 00 16 1B 91 14 00 00 00 00 00 00 00 2B B0 00 00 00 2B B0 00 00 16 0B 0B 07 11 02 9A 35 D3 0D 00 00 D5 0D 00 00 00 00 19 01 0A 31 00 00 09 00 C3 A2 00 00 00 01 C3 A2 00 00 2C 0E 16 14 2D 01 EF 30 00 00 27 1B 2F 63 00 00 00 00 00 00 4A 16 1B BC 61 00 00 00 00 00 00 24 00 16 1B 6E 13 00 00 00 00 00 00 16 1B F1 01 00 00 00 00 00 00 16 0F 01 68 AF 00 00 1B 2F 35 00 00 00 00 00 00 16 04 27 53

 

 

--------------------------------------------------------------------------

 

I'm going to start playing around with things like giving sectoid +/- 1 HP, (( deltaHP = rand(3) - 1; m_kCharacter.m_kChar.aStats[0] +=deltaHP; and aCurrentStats[0] += deltaHP; ))

 

I'm also going to try giving them different perks and see which ones work on aliens.

 

Here's the list of perks that I think might work with aliens without any AI adjustments (they may not work WELL, but could work) (they also can't be easily replicated with simple stat adjustments)

 

Low Profile

Opportunist

Damn Good Ground

Will to Survive

Holo Targeting

Danger Zone

Rapid Reaction

Aggression

Tactical Sense

Lightning Reflexes

Close and Personal

Close Combat Specialist

Bring 'Em On

Resilience

Covering Fire

HEAT Ammo

Mayhem

 

Any others would require AI changes to allow the unit to actively use the ability. Some of the above could be drastically improved by some AI alterations ((for example, a unit with lightning reflexes could be encouraged to move if only one unit is overwatching it, to consume the overwatch and allow its team to move freely))

 

Any other thoughts on perks to test?

 

 

 

 

Also to test:

Do perks assigned in this way show up when viewing the unit (with an autopsy)?

Do altered stats show up when viewing the unit?

Link to comment
Share on other sites

Excellent finding! I really hope it doesn't tell you particular perks of each alien when you aim at them, that'd spoil most of the fun... approaching a harmless sectoid with the arc thrower and it turns out it had close combat specialist... that perk Vengange sounds good for some tough or resentful alien, rapid reaction and sentinel could be a real surprise too if they worked on aliens, ... ready for anything, bullet swarm, double tap (if unrestricted), not sure if the AI would make use of it, that'd be cool to have too.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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