CvMinorCivAI::CanMajorBuyout(PlayerTypes)
- Defined in
- CvMinorCivAI.cpp, line 8745
- Class
- CvMinorCivAI
- Hook name
CivHooks::CvMinorCivAI_CanMajorBuyout- Lua events
GameEvents.PlayerCanBuyOut
Hooks
static bool BeforeCvMinorCivAI_CanMajorBuyout(CvMinorCivAI* self, PlayerTypes eMajor, bool& result);static void AfterCvMinorCivAI_CanMajorBuyout(CvMinorCivAI* self, PlayerTypes eMajor, bool& result);static bool ReplaceCvMinorCivAI_CanMajorBuyout(bool (*original)(CvMinorCivAI*, PlayerTypes), CvMinorCivAI* self, PlayerTypes eMajor);CivRegisterBefore<CivHooks::CvMinorCivAI_CanMajorBuyout>(host, &BeforeCvMinorCivAI_CanMajorBuyout);CivRegisterAfter<CivHooks::CvMinorCivAI_CanMajorBuyout>(host, &AfterCvMinorCivAI_CanMajorBuyout);CivRegisterReplace<CivHooks::CvMinorCivAI_CanMajorBuyout>(host, &ReplaceCvMinorCivAI_CanMajorBuyout);
Code
8744/// Can this minor be bought out by this major? (Austria UA)8745bool CvMinorCivAI::CanMajorBuyout(PlayerTypes eMajor)8746{8747 CvAssertMsg(eMajor >= 0, "eMajor is expected to be non-negative (invalid Index)");8748 CvAssertMsg(eMajor < MAX_MAJOR_CIVS, "eMajor is expected to be within maximum bounds (invalid Index)");8749 if(eMajor < 0 || eMajor >= MAX_MAJOR_CIVS) return false;87508751 // Is alive?8752 if (!GET_PLAYER(eMajor).isAlive() || !GetPlayer()->isAlive())8753 return false;8754 8755 // Has the trait or the policy?8756 if(!GET_PLAYER(eMajor).IsAbleToAnnexCityStates())8757 return false;87588759 // Not at war?8760 if(GET_TEAM(GetPlayer()->getTeam()).isAtWar(GET_PLAYER(eMajor).getTeam()))8761 return false;87628763 // Allies?8764 if(!IsAllies(eMajor))8765 return false;87668767 // Allied long enough?8768 if (GetAlliedTurns() < GC.getMINOR_CIV_BUYOUT_TURNS())8769 {8770 return false;8771 }87728773 // Has enough gold?8774 const int iBuyoutCost = GetBuyoutCost(eMajor);8775 if(GET_PLAYER(eMajor).GetTreasury()->GetGold() < iBuyoutCost)8776 return false;87778778#if defined(MOD_EVENTS_MINORS_INTERACTION)8779 if (MOD_EVENTS_MINORS_INTERACTION) {8780 if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanBuyOut, eMajor, GetPlayer()->GetID()) == GAMEEVENTRETURN_FALSE) {8781 return false;8782 }8783 }8784#endif 8785 8786 return true;8787}
Calls
- CustomMods::eventTestAll(const char *, const char *, ...)
- CustomMods::isEVENTS_MINORS_INTERACTION()
- CvGlobals::getMINOR_CIV_BUYOUT_TURNS()
- CvMinorCivAI::GetAlliedTurns() const
- CvMinorCivAI::GetBuyoutCost(PlayerTypes)
- CvMinorCivAI::GetPlayer()
- CvMinorCivAI::IsAllies(PlayerTypes) const
- CvPlayer::GetID() const
- CvPlayer::getTeam() const
- CvPlayer::GetTreasury() const
- CvPlayer::IsAbleToAnnexCityStates() const
- CvPlayer::isAlive() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvTeam::getTeam(TeamTypes)
- CvTeam::isAtWar(TeamTypes) const
- CvTreasury::GetGold() const