Hooks
static bool BeforeCvMinorCivAI_DoBulliedByMajorReaction(CvMinorCivAI* self, PlayerTypes eBully, int iInfluenceChangeTimes100);static void AfterCvMinorCivAI_DoBulliedByMajorReaction(CvMinorCivAI* self, PlayerTypes eBully, int iInfluenceChangeTimes100);static void ReplaceCvMinorCivAI_DoBulliedByMajorReaction(void (*original)(CvMinorCivAI*, PlayerTypes, int), CvMinorCivAI* self, PlayerTypes eBully, int iInfluenceChangeTimes100);CivRegisterBefore<CivHooks::CvMinorCivAI_DoBulliedByMajorReaction>(host, &BeforeCvMinorCivAI_DoBulliedByMajorReaction);CivRegisterAfter<CivHooks::CvMinorCivAI_DoBulliedByMajorReaction>(host, &AfterCvMinorCivAI_DoBulliedByMajorReaction);CivRegisterReplace<CivHooks::CvMinorCivAI_DoBulliedByMajorReaction>(host, &ReplaceCvMinorCivAI_DoBulliedByMajorReaction);
Code
9563// We were just bullied, how do we react?9564void CvMinorCivAI::DoBulliedByMajorReaction(PlayerTypes eBully, int iInfluenceChangeTimes100)9565{9566 CvAssertMsg(eBully >= 0, "eBully is expected to be non-negative (invalid Index)");9567 CvAssertMsg(eBully < MAX_MAJOR_CIVS, "eBully is expected to be within maximum bounds (invalid Index)");9568 if(eBully < 0 || eBully >= MAX_MAJOR_CIVS) return;95699570 CvPlayer* pBully = &GET_PLAYER(eBully);9571 CvAssertMsg(pBully, "pBully not expected to be NULL. Please send Anton your save file and version.");9572 if (!pBully) return;95739574 SetTurnLastBulliedByMajor(eBully, GC.getGame().getGameTurn());9575 ChangeFriendshipWithMajorTimes100(eBully, iInfluenceChangeTimes100);95769577 // In case we have quests that bullying makes obsolete, check now9578 DoTestActiveQuests(/*bTestComplete*/ false, /*bTestObsolete*/ true);95799580 // Inform alive majors who have met the bully9581 for (int iMajorLoop = 0; iMajorLoop < MAX_MAJOR_CIVS; iMajorLoop++)9582 {9583 PlayerTypes eMajorLoop = (PlayerTypes) iMajorLoop;9584 CvPlayer* pMajorLoop = &GET_PLAYER(eMajorLoop);9585 if (!pMajorLoop) continue;95869587 if(pMajorLoop->isAlive())9588 {9589 if(GET_TEAM(pMajorLoop->getTeam()).isHasMet(pBully->getTeam()))9590 {9591 pMajorLoop->GetDiplomacyAI()->DoPlayerBulliedSomeone(eBully, GetPlayer()->GetID());9592 }9593 }9594 }95959596 // Inform other alive minors, in case they had a quest that this fulfills9597 for (int iMinorLoop = MAX_MAJOR_CIVS; iMinorLoop < MAX_CIV_PLAYERS; iMinorLoop++)9598 {9599 PlayerTypes eMinorLoop = (PlayerTypes) iMinorLoop;9600 if (eMinorLoop == GetPlayer()->GetID()) continue;96019602 CvPlayer* pMinorLoop = &GET_PLAYER(eMinorLoop);9603 if (!pMinorLoop) continue;96049605 if (pMinorLoop->isAlive() && pMinorLoop->GetMinorCivAI()->IsHasMetPlayer(eBully))9606 {9607 pMinorLoop->GetMinorCivAI()->DoTestActiveQuestsForPlayer(eBully, /*bTestComplete*/ true, /*bTestObsolete*/ false, MINOR_CIV_QUEST_BULLY_CITY_STATE);9608 }9609 }9610}