1 #include "MercProfile.h" 2 #include "MercProfileInfo.h" 3 #include "Soldier_Profile.h" 4 #include "Soldier_Profile_Type.h" 5 MercProfile(ProfileID profileID)6MercProfile::MercProfile(ProfileID profileID) 7 : m_profileID(profileID), m_profile(&gMercProfiles[profileID]) 8 { 9 if (m_profileID >= lengthof(gMercProfiles)) 10 { 11 ST::string err = ST::format("invalid m_profileID '{}'", m_profileID); 12 throw std::runtime_error(err.to_std_string()); 13 } 14 } 15 MercProfile(const MercProfileInfo * info)16MercProfile::MercProfile(const MercProfileInfo* info) 17 : MercProfile(info->profileID) 18 { 19 } 20 MercProfile(MERCPROFILESTRUCT & p)21MercProfile::MercProfile(MERCPROFILESTRUCT& p) 22 : MercProfile(static_cast<ProfileID>(&p - gMercProfiles)) 23 { 24 } 25 getID() const26ProfileID MercProfile::getID() const 27 { 28 return m_profileID; 29 } 30 isRecruited() const31bool MercProfile::isRecruited() const 32 { 33 return m_profile->ubMiscFlags & PROFILE_MISC_FLAG_RECRUITED; 34 } 35 isForcedNPCQuote() const36bool MercProfile::isForcedNPCQuote() const 37 { 38 return m_profile->ubMiscFlags & PROFILE_MISC_FLAG_FORCENPCQUOTE; 39 } 40 getInfo() const41const MercProfileInfo& MercProfile::getInfo() const 42 { 43 return *(MercProfileInfo::load(m_profileID)); 44 } 45 isAIMMerc() const46bool MercProfile::isAIMMerc() const 47 { 48 return getInfo().mercType == MercType::AIM; 49 } 50 isMERCMerc() const51bool MercProfile::isMERCMerc() const 52 { 53 return getInfo().mercType == MercType::MERC; 54 } 55 isIMPMerc() const56bool MercProfile::isIMPMerc() const 57 { 58 return getInfo().mercType == MercType::IMP; 59 } 60 isRPC() const61bool MercProfile::isRPC() const 62 { 63 return getInfo().mercType == MercType::RPC; 64 } isNPC() const65bool MercProfile::isNPC() const 66 { 67 return getInfo().mercType == MercType::NPC; 68 } 69 isNPCorRPC() const70bool MercProfile::isNPCorRPC() const 71 { 72 return isNPC() || isRPC(); 73 } 74 isVehicle() const75bool MercProfile::isVehicle() const 76 { 77 return getInfo().mercType == MercType::VEHICLE; 78 } 79 isPlayerMerc() const80bool MercProfile::isPlayerMerc() const 81 { 82 return isAIMMerc() || isMERCMerc() || isIMPMerc(); 83 } 84 getStruct() const85MERCPROFILESTRUCT &MercProfile::getStruct() const 86 { 87 return *m_profile; 88 } 89 operator MERCPROFILESTRUCT&() const90MercProfile::operator MERCPROFILESTRUCT&() const 91 { 92 return *m_profile; 93 }