CvDangerPlots::ModifyDangerByRelationship(PlayerTypes, CvPlot *, int)
- Defined in
- CvDangerPlots.cpp, line 306
- Class
- CvDangerPlots
- Hook name
CivHooks::CvDangerPlots_ModifyDangerByRelationship
Hooks
static bool BeforeCvDangerPlots_ModifyDangerByRelationship(CvDangerPlots* self, PlayerTypes ePlayer, CvPlot* pPlot, int iDanger, int& result);static void AfterCvDangerPlots_ModifyDangerByRelationship(CvDangerPlots* self, PlayerTypes ePlayer, CvPlot* pPlot, int iDanger, int& result);static int ReplaceCvDangerPlots_ModifyDangerByRelationship(int (*original)(CvDangerPlots*, PlayerTypes, CvPlot*, int), CvDangerPlots* self, PlayerTypes ePlayer, CvPlot* pPlot, int iDanger);CivRegisterBefore<CivHooks::CvDangerPlots_ModifyDangerByRelationship>(host, &BeforeCvDangerPlots_ModifyDangerByRelationship);CivRegisterAfter<CivHooks::CvDangerPlots_ModifyDangerByRelationship>(host, &AfterCvDangerPlots_ModifyDangerByRelationship);CivRegisterReplace<CivHooks::CvDangerPlots_ModifyDangerByRelationship>(host, &ReplaceCvDangerPlots_ModifyDangerByRelationship);
Code
306int CvDangerPlots::ModifyDangerByRelationship(PlayerTypes ePlayer, CvPlot* pPlot, int iDanger)307{308 CvAssertMsg(pPlot, "No plot passed in?");309 bool bIgnoreInFriendlyTerritory = false;310 int iResult = iDanger;311312 // Full value if a player we're at war with313 if(GET_TEAM(GET_PLAYER(m_ePlayer).getTeam()).isAtWar(GET_PLAYER(ePlayer).getTeam()))314 {315 return iResult;316 }317318 // if it's a human player, ignore neutral units319 if(GET_PLAYER(m_ePlayer).isHuman())320 {321 return 0;322 }323324 if(GET_PLAYER(m_ePlayer).isMinorCiv()) // if the evaluator is a minor civ325 {326 if(!GET_TEAM(GET_PLAYER(m_ePlayer).getTeam()).isAtWar(GET_PLAYER(ePlayer).getTeam())) // and they're not at war with the other player327 {328 bIgnoreInFriendlyTerritory = true; // ignore friendly territory329 }330 }331 else if(!GET_PLAYER(ePlayer).isMinorCiv())332 {333 // should we be using bHideTrueFeelings?334 switch(GET_PLAYER(m_ePlayer).GetDiplomacyAI()->GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ false))335 {336 case MAJOR_CIV_APPROACH_WAR:337 iResult = (int)(iResult * m_fMajorWarMod);338 break;339 case MAJOR_CIV_APPROACH_HOSTILE:340 iResult = (int)(iResult * m_fMajorHostileMod);341 bIgnoreInFriendlyTerritory = true;342 break;343 case MAJOR_CIV_APPROACH_DECEPTIVE:344 iResult = (int)(iResult * m_fMajorDeceptiveMod);345 bIgnoreInFriendlyTerritory = true;346 break;347 case MAJOR_CIV_APPROACH_GUARDED:348 iResult = (int)(iResult * m_fMajorGuardedMod);349 bIgnoreInFriendlyTerritory = true;350 break;351 case MAJOR_CIV_APPROACH_AFRAID:352 iResult = (int)(iResult * m_fMajorAfraidMod);353 bIgnoreInFriendlyTerritory = true;354 break;355 case MAJOR_CIV_APPROACH_FRIENDLY:356 iResult = (int)(iResult * m_fMajorFriendlyMod);357 bIgnoreInFriendlyTerritory = true;358 break;359 case MAJOR_CIV_APPROACH_NEUTRAL:360 iResult = (int)(iResult * m_fMajorNeutralMod);361 bIgnoreInFriendlyTerritory = true;362 break;363 }364 }365 else366 {367 switch(GET_PLAYER(m_ePlayer).GetDiplomacyAI()->GetMinorCivApproach(ePlayer))368 {369 case MINOR_CIV_APPROACH_IGNORE:370 iResult = (int)(iResult * m_fMinorNeutralrMod);371 bIgnoreInFriendlyTerritory = true;372 break;373 case MINOR_CIV_APPROACH_FRIENDLY:374 iResult = (int)(iResult * m_fMinorFriendlyMod);375 bIgnoreInFriendlyTerritory = true;376 break;377 case MINOR_CIV_APPROACH_BULLY:378 iResult = (int)(iResult * m_fMinorBullyMod);379 break;380 case MINOR_CIV_APPROACH_CONQUEST:381 iResult = (int)(iResult * m_fMinorConquestMod);382 break;383 }384 }385386 // if the plot is in our own territory and, with the current approach, we should ignore danger values in our own territory387 // zero out the value388 if(pPlot && pPlot->getOwner() == m_ePlayer && bIgnoreInFriendlyTerritory)389 {390 iResult = 0;391 }392393 return iResult;394}
Calls
- CvDiplomacyAI::GetMajorCivApproach(PlayerTypes, bool) const
- CvDiplomacyAI::GetMinorCivApproach(PlayerTypes) const
- CvPlayer::GetDiplomacyAI() const
- CvPlayer::getTeam() const
- CvPlayer::isHuman() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlot::getOwner() const
- CvTeam::getTeam(TeamTypes)
- CvTeam::isAtWar(TeamTypes) const