X2CommunityCore / X2WOTCCommunityHighlander

https://steamcommunity.com/workshop/filedetails/?id=1134256495
MIT License
60 stars 68 forks source link

Allow XComAlienPawn to have multiple Voicebanks and randomly pick one of them when created #275

Closed E3245 closed 6 years ago

E3245 commented 6 years ago

At the moment, the alien pawn only allows for one voicebank. What I want is the ability to assign an array of voicebanks in the AlienPawn archetype, and let the game arbitrarily pick a voicebank and stick with it on load.

GingerAvalanche commented 6 years ago

I don't think that implementing the entire extra voicebanks thing is within the scope of the highlander, since it doesn't fix anything, and most of it can be done without any sort of override.

That being said, giving another mod the ability to arbitrarily change the voice of a given XComAlienPawn in its PostBeginPlay event is something that could be done. Sticking an event trigger there that a separate mod could listen for and then assign the voice based on its own logic (some mods might want it random, some mods might want a specific voice, for example) would be a good compromise.

XComAlienPawn.PostBeginPlay calls XComUnitPawn.PostBeginPlay, and the chain probably goes further up. It may be useful to put the event somewhere higher in the hierarchy, so as to be able to affect more unit types, and allow mods to restrict their scope based on whether or not the passed object can be cast to their desired type.

robojumper commented 6 years ago

We cannot make the originally proposed change to XComAlienPawn, because it's a "cooked class" -- making changes to non-transient properties of classes that have cooked objects breaks the base game's cooked content.

Apart from @GingerAvalanche's suggestion, what we could do is un-private the voice property in XComAlienPawn in the Highlander:

var() /*privatewrite*/ XComCharacterVoice   Voice;

Then, you could create a pawn subclass like this in your mod:

class XComAlienPawnRandomVoice extends XComAlienPawn;

var() array<XComCharacterVoice> Voices;

simulated event PostBeginPlay()
{
    Voice = Voices[Rand(Voices.Length)];
    super.PostBeginPlay();
}

and create your alien pawns as this class and assign all the voices you need.