Nirran, I propose better determining the AP ammo:
/* Armor Piercing Ammo Bonus */
// if (attack_ammo_pid == 30) or (attack_ammo_pid == 33) or (attack_ammo_pid == 36) or (attack_ammo_pid == 37) or (attack_ammo_pid == 362) and (threshold > 0) then
if...