engine/actions/source/RangedCombatApplicabilityChecker.cpp
// Check to see if the ammunition requires a ranged weapon.
Check to see if the ammunition requires a ranged weapon.
Check to see if the ammunition requires a ranged weapon .
bool RangedCombatApplicabilityChecker::is_ranged_weapon_required_and_equipped(CreaturePtr creature)
{
  bool ranged_weapon_required_and_equipped = true;
  if (creature)
  {
    Equipment& equipment = creature->get_equipment();
    WeaponPtr ammunition = dynamic_pointer_cast<Weapon>(equipment.get_item(EquipmentWornLocation::EQUIPMENT_WORN_AMMUNITION));
    ItemPtr ranged_weapon = equipment.get_item(EquipmentWornLocation::EQUIPMENT_WORN_RANGED_WEAPON);
    bool ammunition_requires_ranged_weapon = false;
    if (ammunition) 
    {
      ammunition_requires_ranged_weapon = ammunition->get_requires_ranged_weapon();
    }
    if (ammunition_requires_ranged_weapon && !ranged_weapon)
    {
      ranged_weapon_required_and_equipped = false;
    }
  }
  return ranged_weapon_required_and_equipped;
}
bool RangedCombatApplicabilityChecker :: is_ranged_weapon_required_and_equipped ( CreaturePtr creature ) { bool ranged_weapon_required_and_equipped = true ; if ( creature ) { Equipment & equipment = creature -> get_equipment ( ) ; WeaponPtr ammunition = dynamic_pointer_cast < Weapon > ( equipment . get_item ( EquipmentWornLocation :: EQUIPMENT_WORN_AMMUNITION ) ) ; ItemPtr ranged_weapon = equipment . get_item ( EquipmentWornLocation :: EQUIPMENT_WORN_RANGED_WEAPON ) ; bool ammunition_requires_ranged_weapon = false ; if ( ammunition ) { ammunition_requires_ranged_weapon = ammunition -> get_requires_ranged_weapon ( ) ; } if ( ammunition_requires_ranged_weapon && ! ranged_weapon ) { ranged_weapon_required_and_equipped = false ; } } return ranged_weapon_required_and_equipped ; }
Check to see if the ammunition requires a ranged weapon.
Check to see if the ammunition requires a ranged weapon .
// may be a potion instead of just ammunition...