X2CommunityCore / X2WOTCCommunityHighlander

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

Allow mods to control priority of Overwatch vs Pistol Overwatch with Ever Vigilant #685

Open pledbrook opened 4 years ago

pledbrook commented 4 years ago

The EverVigilantTurnEndListener in XComGameState_Ability always prioritises Pistol Overatch over Overwatch if a soldier has the former ability. This is done on the assumption that Sharpshooters are the only soldiers that can have Pistol Overwatch, but that's not the case for several mods.

It would be possible to override the Ever Vigilant ability or even that ability's trigger, but that would require code duplication, and wouldn't work for other abilities that wanted to use EverVigilantTurnEndListener.

I propose we add an override event that allows mods to control which overwatch ability is activated when Ever Vigilant procs.

Iridar commented 4 years ago

Yo dawg, I heard you like events, so I put an even trigger in your event trigger, so you can listen to events while you listen to events xzibit.jpg

Modifying a behavior of an event listener with an event listener, is that even possible? Perhaps, we could patch the code itself? The default behavior for snipers would remain the same.

What I propose is to make the Ever Vigilant Event Listener check the iTypicalActionCost of the weapon the Overwatch ability is attached to, and if it's >1, default to using pistol overwatch instead, since that was the original intent behind the code - prevent the soldier from overwatching with a bulky sniper rifle, but allow overwatching with a nimbler assault rifle/pistol.

Xymanek commented 4 years ago

Modifying a behavior of an event listener with an event listener, is that even possible?

Yes. Even more, there is a lot of (un)registering listeners and triggering events from listeners in base game