| 2797 | return handled; |
| 2798 | } |
| 2799 | bool HandleCounterMeasurePowerups(char *pname, msafe_struct *mstruct, uint8_t *pickup) { |
| 2800 | bool handled = false; |
| 2801 | // Chaff |
| 2802 | if (!stricmp("Chaff", pname)) { |
| 2803 | handled = true; |
| 2804 | int pnum = IOBJ->id; |
| 2805 | int added_count = 0; |
| 2806 | int weapon_id = FindWeaponName("Chaff"); |
| 2807 | |
| 2808 | if (weapon_id != -1) { |
| 2809 | int amount = 12 - Players[pnum].counter_measures.GetTypeIDCount(OBJ_WEAPON, weapon_id); |
| 2810 | if (amount > 4) |
| 2811 | amount = 4; |
| 2812 | if (amount > 0) { |
| 2813 | for (int c = 0; c < amount; c++) { |
| 2814 | if (Players[pnum].counter_measures.AddCounterMeasure(weapon_id, MOBJ->type, MOBJ->id)) { |
| 2815 | added_count++; |
| 2816 | } else |
| 2817 | break; |
| 2818 | } |
| 2819 | if (added_count) { |
| 2820 | // Pick it up |
| 2821 | *pickup = 1; |
| 2822 | } |
| 2823 | if (pnum == Player_num) { |
| 2824 | if (added_count == 1) { |
| 2825 | AddFilteredHUDMessage(TXT_CHAFF); |
| 2826 | } else if (added_count > 1) { |
| 2827 | AddFilteredHUDMessage(TXT_MSG_MULTI_CHAFFS, added_count); |
| 2828 | } else { |
| 2829 | AddFilteredHUDMessage(TXT_COUNTERMEASUREFULL); |
| 2830 | } |
| 2831 | } |
| 2832 | } else if (pnum == Player_num) { |
| 2833 | AddFilteredHUDMessage(TXT_CHAFFSFULL); |
| 2834 | } |
| 2835 | } |
| 2836 | } |
| 2837 | // Betty4pack |
| 2838 | else if (!stricmp("Betty4Pack", pname)) { |
| 2839 | handled = true; |
| 2840 | int pnum = IOBJ->id; |
| 2841 | int added_count = 0; |
| 2842 | int weapon_id = FindWeaponName("Betty"); |
| 2843 | |
| 2844 | if (weapon_id != -1) { |
| 2845 | int amount = 12 - Players[pnum].counter_measures.GetTypeIDCount(OBJ_WEAPON, weapon_id); |
| 2846 | if (amount > 4) |
| 2847 | amount = 4; |
| 2848 | if (amount > 0) { |
| 2849 | for (int c = 0; c < amount; c++) { |
| 2850 | if (Players[pnum].counter_measures.AddCounterMeasure(weapon_id, MOBJ->type, MOBJ->id)) { |
| 2851 | added_count++; |
| 2852 | } else |
| 2853 | break; |
| 2854 | } |
| 2855 | if (added_count) { |
| 2856 | // Pick it up |
no test coverage detected