|
2 | 2 | // Used by the visualizer system to control a Visualization Actor |
3 | 3 | //----------------------------------------------------------- |
4 | 4 | class X2Action_ApplyWeaponDamageToUnit extends X2Action |
5 | | - dependson(XComAnimNodeBlendDynamic) |
| 5 | + dependson(XComAnimNodeBlendDynamic, XComLWTuple) |
6 | 6 | config(Animation); |
7 | 7 |
|
8 | 8 | var X2AbilityTemplate AbilityTemplate; //The template for the ability that is affecting us |
@@ -752,12 +752,73 @@ simulated state Executing |
752 | 752 | simulated function ShowMitigationMessage(EWidgetColor DisplayColor) |
753 | 753 | { |
754 | 754 | local int CurrentArmor; |
| 755 | + // Begin Issue #1566 |
| 756 | + /// HL-Docs: feature:EditMitigationMessages; issue:1566; tags:tactical |
| 757 | + /// This feature allows mods to add or replace flyovers related to armor mitigation, |
| 758 | + /// e.g. to display extra mitigation from an AdjustArmorMitigation |
| 759 | + /// callback. |
| 760 | + /// |
| 761 | + /// Note that mods overriding X2Action_ApplyWeaponDamageToUnit::ShowMitigationMessage |
| 762 | + /// might not emit or respect the associated event. |
| 763 | + /// |
| 764 | + /// ```event |
| 765 | + /// EventID: EditMitigationMessages |
| 766 | + /// EventData: [inout int CurrentArmor, out array<XComLWTuple> ExtraMessages] |
| 767 | + /// EventSource: X2Action_ApplyWeaponDamageToUnit |
| 768 | + /// NewGameState: AssociatedState |
| 769 | + /// ``` |
| 770 | + /// |
| 771 | + /// Listeners should format their response tuples as: |
| 772 | + /// |
| 773 | + /// - ResponseID: ExtraMitigationMessage |
| 774 | + /// - ResponseData: [string MessageText, int MessageAmount] |
| 775 | + /// |
| 776 | + /// You can also modify CurrentArmor (e.g. setting it to 0 to suppress the vanilla flyover), |
| 777 | + /// but this might result in unexpected behavior if other listeners depend on it. |
| 778 | + local XComLWTuple EditMitigationMessagesTuple; |
| 779 | + local Object Message; |
| 780 | + local XComLWTuple MessageTuple; |
| 781 | + local XComLWTValue Text, Amount; |
| 782 | + // End Issue #1566 |
| 783 | + |
755 | 784 | CurrentArmor = UnitState.GetArmorMitigationForUnitFlag(); |
| 785 | + // Begin Issue #1566 |
| 786 | + EditMitigationMessagesTuple = new class'XComLWTuple'; |
| 787 | + EditMitigationMessagesTuple.Id = 'EditMitigationMessages'; |
| 788 | + EditMitigationMessagesTuple.Data.Add(2); |
| 789 | + EditMitigationMessagesTuple.Data[0].kind = XComLWTVInt; |
| 790 | + EditMitigationMessagesTuple.Data[0].i = CurrentArmor; |
| 791 | + EditMitigationMessagesTuple.Data[1].kind = XComLWTVArrayObjects; |
| 792 | + `XEVENTMGR.TriggerEvent('EditMitigationMessages', EditMitigationMessagesTuple, self, StateChangeContext.AssociatedState); |
| 793 | + CurrentArmor = EditMitigationMessagesTuple.Data[0].i; |
| 794 | + // End Issue #1566 |
| 795 | + |
756 | 796 | //The flyover shows the armor amount that exists after shred has been applied. |
757 | 797 | if (CurrentArmor > 0) |
758 | 798 | { |
759 | 799 | class'UIWorldMessageMgr'.static.DamageDisplay(m_vHitLocation, Unit.GetVisualizedStateReference(), class'XGLocalizedData'.default.ArmorMitigation, UnitPawn.m_eTeamVisibilityFlags, , CurrentArmor, /*modifier*/, /*crit*/, eWDT_Armor, DisplayColor); |
760 | 800 | } |
| 801 | + |
| 802 | + // Begin Issue #1566 |
| 803 | + foreach EditMitigationMessagesTuple.Data[1].ao(Message) |
| 804 | + { |
| 805 | + MessageTuple = XComLWTuple(Message); |
| 806 | + if (MessageTuple == none || MessageTuple.Id != 'ExtraMitigationMessage' || MessageTuple.Data.Length != 2) |
| 807 | + { |
| 808 | + continue; |
| 809 | + } |
| 810 | + |
| 811 | + Text = MessageTuple.Data[0]; |
| 812 | + Amount = MessageTuple.Data[1]; |
| 813 | + if (Text.kind != XComLWTVString || Amount.kind != XComLWTVInt) |
| 814 | + { |
| 815 | + continue; |
| 816 | + } |
| 817 | + |
| 818 | + // No content validation here, assume the message only got sent if it wanted to be. |
| 819 | + class'UIWorldMessageMgr'.static.DamageDisplay(m_vHitLocation, Unit.GetVisualizedStateReference(), Text.s, UnitPawn.m_eTeamVisibilityFlags, , Amount.i, /*modifier*/, /*crit*/, eWDT_Armor, DisplayColor); |
| 820 | + } |
| 821 | + // End Issue #1566 |
761 | 822 | } |
762 | 823 |
|
763 | 824 | simulated function ShowShieldedMessage(EWidgetColor DisplayColor) |
|
0 commit comments