bool swapTo(unitScript unit, WeaponType type) { for (int i = 0; i < unit.getWeaponCount(); i++) { if (unit.getWeapon(i).type == type) { unit.setCurrentWeapon(i); return(true); } } return(false); }