CvGameReligions::GetBeliefYieldForKill(YieldTypes, int, int, PlayerTypes)
- Defined in
- CvReligionClasses.cpp, line 2516
- Class
- CvGameReligions
- Hook name
CivHooks::CvGameReligions_GetBeliefYieldForKill
Hooks
static bool BeforeCvGameReligions_GetBeliefYieldForKill(CvGameReligions* self, YieldTypes eYield, int iX, int iY, PlayerTypes eWinningPlayer, int& result);static void AfterCvGameReligions_GetBeliefYieldForKill(CvGameReligions* self, YieldTypes eYield, int iX, int iY, PlayerTypes eWinningPlayer, int& result);static int ReplaceCvGameReligions_GetBeliefYieldForKill(int (*original)(CvGameReligions*, YieldTypes, int, int, PlayerTypes), CvGameReligions* self, YieldTypes eYield, int iX, int iY, PlayerTypes eWinningPlayer);CivRegisterBefore<CivHooks::CvGameReligions_GetBeliefYieldForKill>(host, &BeforeCvGameReligions_GetBeliefYieldForKill);CivRegisterAfter<CivHooks::CvGameReligions_GetBeliefYieldForKill>(host, &AfterCvGameReligions_GetBeliefYieldForKill);CivRegisterReplace<CivHooks::CvGameReligions_GetBeliefYieldForKill>(host, &ReplaceCvGameReligions_GetBeliefYieldForKill);
Code
2515/// Does the religion in nearby city give this battle winner a yield? If so return multipler of losing unit strength2516int CvGameReligions::GetBeliefYieldForKill(YieldTypes eYield, int iX, int iY, PlayerTypes eWinningPlayer)2517{2518 int iRtnValue = 0;2519 int iMultiplier;2520 int iLoop;2521 CvCity* pLoopCity;25222523 // Only Faith supported for now2524 if(eYield != YIELD_FAITH)2525 {2526 return iRtnValue;2527 }25282529 for(pLoopCity = GET_PLAYER(eWinningPlayer).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(eWinningPlayer).nextCity(&iLoop))2530 {2531 // Find religion in this city2532 ReligionTypes eReligion = pLoopCity->GetCityReligions()->GetReligiousMajority();25332534 if(eReligion != NO_RELIGION)2535 {2536 // Find distance to this city2537 int iDistance = plotDistance(iX, iY, pLoopCity->getX(), pLoopCity->getY());25382539 // Do we have a yield from this?2540 iMultiplier = GetReligion(eReligion, eWinningPlayer)->m_Beliefs.GetFaithFromKills(iDistance);2541 if(iMultiplier > 0)2542 {2543 // Just looking for one city providing this2544 iRtnValue = iMultiplier;2545 break;2546 }2547 else2548 {2549 BeliefTypes eSecondaryPantheon = pLoopCity->GetCityReligions()->GetSecondaryReligionPantheonBelief();2550 if (eSecondaryPantheon != NO_BELIEF)2551 {2552 iMultiplier = GC.GetGameBeliefs()->GetEntry(eSecondaryPantheon)->GetFaithFromKills();2553 if(iMultiplier > 0 && iDistance <= GC.GetGameBeliefs()->GetEntry(eSecondaryPantheon)->GetMaxDistance())2554 {2555 // Just looking for one city providing this2556 iRtnValue = iMultiplier;2557 break;2558 } 2559 }2560 }2561 }2562 }25632564 return iRtnValue;2565}
Calls
- CvBeliefEntry::GetFaithFromKills() const
- CvBeliefEntry::GetMaxDistance() const
- CvBeliefXMLEntries::GetEntry(int)
- CvCity::GetCityReligions() const
- CvCity::getX() const
- CvCity::getY() const
- CvCityReligions::GetReligiousMajority()
- CvCityReligions::GetSecondaryReligionPantheonBelief()
- CvGameReligions::GetReligion(ReligionTypes, PlayerTypes) const
- CvGlobals::GetGameBeliefs() const
- CvPlayer::firstCity(int *, bool)
- CvPlayer::nextCity(int *, bool)
- CvPlayerAI::getPlayer(PlayerTypes)
- CvReligionBeliefs::GetFaithFromKills(int) const
- plotDistance(int, int, int, int)