CvPlayer::receiveGoody(CvPlot *, GoodyTypes, CvUnit *)
- Defined in
- CvPlayer.cpp, line 6682
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_receiveGoody- Lua events
GameEvents.UnitUpgraded,GameEvents.GoodyHutCanResearch,GameEvents.GoodyHutTechResearched
Hand-placed hooks inside
A replacement for this function that does not call original stops these hooks from running.
Hooks
static bool BeforeCvPlayer_receiveGoody(CvPlayer* self, CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit);static void AfterCvPlayer_receiveGoody(CvPlayer* self, CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit);static void ReplaceCvPlayer_receiveGoody(void (*original)(CvPlayer*, CvPlot*, GoodyTypes, CvUnit*), CvPlayer* self, CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit);CivRegisterBefore<CivHooks::CvPlayer_receiveGoody>(host, &BeforeCvPlayer_receiveGoody);CivRegisterAfter<CivHooks::CvPlayer_receiveGoody>(host, &AfterCvPlayer_receiveGoody);CivRegisterReplace<CivHooks::CvPlayer_receiveGoody>(host, &ReplaceCvPlayer_receiveGoody);
Code
6682void CvPlayer::receiveGoody(CvPlot* pPlot, GoodyTypes eGoody, CvUnit* pUnit)6683{6684 CvPlot* pLoopPlot;6685 CvPlot* pBestPlot = NULL;6686 CvString strBuffer;6687 CvString strTempBuffer;6688 TechTypes eBestTech;6689 UnitTypes eUnit;6690 int iGold;6691 int iOffset;6692 int iRange;6693 int iBarbCount;6694 int iValue;6695 int iBestValue;6696 int iPass;6697 int iDX, iDY;6698 int iI;66996700 CvAssertMsg(canReceiveGoody(pPlot, eGoody, pUnit), "Instance is expected to be able to recieve goody");67016702 Database::SingleResult kResult;6703 CvGoodyInfo kGoodyInfo;6704 const bool bResult = DB.SelectAt(kResult, "GoodyHuts", eGoody);6705 DEBUG_VARIABLE(bResult);6706 CvAssertMsg(bResult, "Cannot find goody info.");6707 kGoodyInfo.CacheResult(kResult);67086709 CvGoodyHuts::DoPlayerReceivedGoody(GetID(), eGoody);67106711 strBuffer = kGoodyInfo.GetDescription();67126713 // Gold6714 iGold = kGoodyInfo.getGold() + (kGoodyInfo.getNumGoldRandRolls() * GC.getGame().getJonRandNum(kGoodyInfo.getGoldRandAmount(), "Goody Gold Rand"));67156716 if(iGold != 0)6717 {6718 GetTreasury()->ChangeGold(iGold);67196720 strBuffer += GetLocalizedText("TXT_KEY_MISC_RECEIVED_GOLD", iGold);6721 }67226723 // Population6724 if(kGoodyInfo.getPopulation() > 0)6725 {6726 int iDistance;6727 int iBestCityDistance = -1;6728 CvCity* pBestCity = NULL;67296730 CvCity* pLoopCity;6731 int iLoop;6732 // Find the closest City to us to add a Pop point to6733 for(pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))6734 {6735 iDistance = plotDistance(pPlot->getX(), pPlot->getY(), pLoopCity->getX(), pLoopCity->getY());67366737 if(iBestCityDistance == -1 || iDistance < iBestCityDistance)6738 {6739 iBestCityDistance = iDistance;6740 pBestCity = pLoopCity;6741 }6742 }67436744 if(pBestCity != NULL)6745 {6746 pBestCity->changePopulation(kGoodyInfo.getPopulation());6747 }6748 }67496750 // Culture6751 int iCulture = kGoodyInfo.getCulture();6752 if(iCulture > 0)6753 {6754 // Game Speed Mod6755 iCulture *= GC.getGame().getGameSpeedInfo().getCulturePercent();6756 iCulture /= 100;67576758 changeJONSCulture(iCulture);67596760#if defined(MOD_BUGFIX_GOODY_HUT_MESSAGES)6761 strBuffer += GetLocalizedText("TXT_KEY_MISC_RECEIVED_CULTURE", iCulture);6762#endif6763 }67646765 // Faith6766 int iFaith = kGoodyInfo.getFaith();6767 if(iFaith > 0)6768 {6769 // Game Speed Mod6770 iFaith *= GC.getGame().getGameSpeedInfo().getFaithPercent();6771 iFaith /= 100;67726773 ChangeFaith(iFaith);67746775#if defined(MOD_BUGFIX_GOODY_HUT_MESSAGES)6776 strBuffer += GetLocalizedText("TXT_KEY_MISC_RECEIVED_FAITH", iFaith);6777#endif6778 }67796780 // Faith for pantheon6781 bool bPantheon = kGoodyInfo.isPantheonFaith();6782 if(bPantheon)6783 {6784 // Enough so still get a pantheon if 3 civs pop this in same turn6785 iFaith = GC.getGame().GetGameReligions()->GetMinimumFaithNextPantheon() + 2 * GC.getRELIGION_GAME_FAITH_DELTA_NEXT_PANTHEON();6786 int iDivisor = /*10*/ GC.getGOLD_PURCHASE_VISIBLE_DIVISOR();6787 iFaith /= iDivisor;6788 iFaith *= iDivisor;6789 ChangeFaith(iFaith);67906791#if defined(MOD_BUGFIX_GOODY_HUT_MESSAGES)6792 strBuffer += GetLocalizedText("TXT_KEY_MISC_RECEIVED_FAITH", iFaith);6793#endif6794 }67956796 // Faith for percent of great prophet6797 int iProphetPercent = kGoodyInfo.getProphetPercent();6798 if(iProphetPercent > 0)6799 {6800#if defined(MOD_GLOBAL_TRULY_FREE_GP)6801 iFaith = GetReligions()->GetCostNextProphet(false /*bIncludeBeliefDiscounts*/, true /*bAdjustForSpeedDifficulty*/, MOD_GLOBAL_TRULY_FREE_GP) * iProphetPercent / 100;6802#else6803 iFaith = GetReligions()->GetCostNextProphet(false /*bIncludeBeliefDiscounts*/, true /*bAdjustForSpeedDifficulty*/) * iProphetPercent / 100;6804#endif6805 int iDivisor = /*10*/ GC.getGOLD_PURCHASE_VISIBLE_DIVISOR();6806 iFaith /= iDivisor;6807 iFaith *= iDivisor;6808 ChangeFaith(iFaith);68096810#if defined(MOD_BUGFIX_GOODY_HUT_MESSAGES)6811 strBuffer += GetLocalizedText("TXT_KEY_MISC_RECEIVED_FAITH", iFaith);6812#endif6813 }68146815 // Reveal Nearby Barbs6816 if(kGoodyInfo.getRevealNearbyBarbariansRange() > 0)6817 {6818 // Look at nearby Plots to make sure another camp isn't too close6819 const int iBarbCampDistance = kGoodyInfo.getRevealNearbyBarbariansRange();6820 for(iDX = -(iBarbCampDistance); iDX <= iBarbCampDistance; iDX++)6821 {6822 for(iDY = -(iBarbCampDistance); iDY <= iBarbCampDistance; iDY++)6823 {6824 CvPlot* pNearbyBarbarianPlot = plotXY(pPlot->getX(), pPlot->getY(), iDX, iDY);6825 if(pNearbyBarbarianPlot != NULL)6826 {6827 if(plotDistance(pNearbyBarbarianPlot->getX(), pNearbyBarbarianPlot->getY(), pPlot->getX(), pPlot->getY()) <= iBarbCampDistance)6828 {6829 if(pNearbyBarbarianPlot->getImprovementType() == GC.getBARBARIAN_CAMP_IMPROVEMENT())6830 {6831 // Reveal Plot6832 pNearbyBarbarianPlot->setRevealed(getTeam(), true);6833 // Reveal Barb Camp here6834 pNearbyBarbarianPlot->setRevealedImprovementType(getTeam(), pNearbyBarbarianPlot->getImprovementType());6835 }6836 }6837 }6838 }6839 }6840 }68416842 // Map6843 iRange = kGoodyInfo.getMapRange();68446845 if(iRange > 0)6846 {6847 iOffset = kGoodyInfo.getMapOffset();68486849 if(iOffset > 0)6850 {6851 iBestValue = 0;6852 pBestPlot = NULL;68536854 int iRandLimit;68556856 for(iDX = -(iOffset); iDX <= iOffset; iDX++)6857 {6858 for(iDY = -(iOffset); iDY <= iOffset; iDY++)6859 {6860 pLoopPlot = plotXYWithRangeCheck(pPlot->getX(), pPlot->getY(), iDX, iDY, iOffset);68616862 if(pLoopPlot != NULL)6863 {6864 if(!(pLoopPlot->isRevealed(getTeam())))6865 {6866 // Avoid water plots!6867 if(pPlot->isWater())6868 iRandLimit = 10;6869 else6870 iRandLimit = 10000;68716872 iValue = (1 + GC.getGame().getJonRandNum(iRandLimit, "Goody Map"));68736874 iValue *= plotDistance(pPlot->getX(), pPlot->getY(), pLoopPlot->getX(), pLoopPlot->getY());68756876 if(iValue > iBestValue)6877 {6878 iBestValue = iValue;6879 pBestPlot = pLoopPlot;6880 }6881 }6882 }6883 }6884 }6885 }68866887 if(pBestPlot == NULL)6888 {6889 pBestPlot = pPlot;6890 }68916892 for(iDX = -(iRange); iDX <= iRange; iDX++)6893 {6894 for(iDY = -(iRange); iDY <= iRange; iDY++)6895 {6896 pLoopPlot = plotXY(pBestPlot->getX(), pBestPlot->getY(), iDX, iDY);68976898 if(pLoopPlot != NULL)6899 {6900 if(plotDistance(pBestPlot->getX(), pBestPlot->getY(), pLoopPlot->getX(), pLoopPlot->getY()) <= iRange)6901 {6902 if(GC.getGame().getJonRandNum(100, "Goody Map") < kGoodyInfo.getMapProb())6903 {6904 pLoopPlot->setRevealed(getTeam(), true);6905 }6906 }6907 }6908 }6909 }6910 }69116912 // Experience6913 if(pUnit != NULL)6914 {6915#if defined(MOD_UNITS_XP_TIMES_100)6916 pUnit->changeExperienceTimes100(kGoodyInfo.getExperience() * 100);6917#else6918 pUnit->changeExperience(kGoodyInfo.getExperience());6919#endif6920 }69216922 // Unit Heal6923 if(pUnit != NULL)6924 {6925 pUnit->changeDamage(-(kGoodyInfo.getHealing()));6926 }69276928 // Reveal Unknown Resource6929 if(kGoodyInfo.isRevealUnknownResource())6930 {6931 if(getCapitalCity() != NULL)6932 {6933 CvCity* pCapital = getCapitalCity();69346935 CvPlot* pResourcePlot;6936 int iResourceDistance;6937 TechTypes eRevealTech;6938 int iResourceCost;6939 int iBestResourceCost = -1;6940 ResourceTypes eResource;6941 ResourceTypes eBestResource = NO_RESOURCE;6942 CvPlot* pBestResourcePlot = NULL;69436944 ResourceClassTypes eResourceClassBonus;69456946 // Look at Resources on all Plots6947 for(int iPlotLoop = 0; iPlotLoop < GC.getMap().numPlots(); iPlotLoop++)6948 {6949 pResourcePlot = GC.getMap().plotByIndexUnchecked(iPlotLoop);6950 eResource = pResourcePlot->getResourceType();69516952 if(eResource != NO_RESOURCE)6953 {6954 CvResourceInfo& pResource = *GC.getResourceInfo(eResource);6955 eResourceClassBonus = (ResourceClassTypes) GC.getInfoTypeForString("RESOURCECLASS_BONUS");69566957 // No "Bonus" Resources (that only give Yield), because those are lame to get from a Hut6958 if(pResource.getResourceClassType() != eResourceClassBonus)6959 {6960 // Can't be on a Plot that we've already force-revealed!6961 if(!pResourcePlot->IsResourceForceReveal(getTeam()))6962 {6963 // Must be a Resource we don't already see6964 eRevealTech = (TechTypes) pResource.getTechReveal();6965 if(!GET_TEAM(getTeam()).GetTeamTechs()->HasTech(eRevealTech))6966 {6967 iResourceDistance = plotDistance(pResourcePlot->getX(), pResourcePlot->getY(), pCapital->getX(), pCapital->getY());69686969 // Must be within 10 plots of our Capital6970 if(iResourceDistance <= 10)6971 {6972 iResourceCost = GC.getTechInfo(eRevealTech)->GetResearchCost();69736974 // Find the one with the cheapest Tech (or pick one if we haven't identified one yet)6975 if(iBestResourceCost == -1 || iResourceCost < iBestResourceCost)6976 {6977 iBestResourceCost = iResourceCost;6978 eBestResource = eResource;6979 pBestResourcePlot = pResourcePlot;6980 }6981 }6982 }6983 }6984 }6985 }6986 }69876988 CvAssert(pBestResourcePlot);69896990 // Did we find something to show?6991 if(pBestResourcePlot != NULL)6992 {6993 pBestResourcePlot->setRevealed(getTeam(), true);6994 pBestResourcePlot->SetResourceForceReveal(getTeam(), true);6995 //pBestPlot->updateFog();69966997 if(getTeam() == GC.getGame().getActiveTeam())6998 {6999 pBestResourcePlot->setLayoutDirty(true);7000 }70017002 // Also reveal adjacent Plots7003 CvPlot* pAdjacentPlot;7004 for(int iDirectionLoop = 0; iDirectionLoop < NUM_DIRECTION_TYPES; iDirectionLoop++)7005 {7006 pAdjacentPlot = plotDirection(pBestResourcePlot->getX(), pBestResourcePlot->getY(), ((DirectionTypes) iDirectionLoop));70077008 if(pAdjacentPlot != NULL)7009 {7010 pAdjacentPlot->setRevealed(getTeam(), true);7011 }7012 }70137014 CvString strTempString;7015 strTempString.Format(" (%s)", GC.getResourceInfo(eBestResource)->GetDescription());7016 strBuffer += strTempString;7017 }7018 }7019 }70207021 // Unit Upgrade7022 if(kGoodyInfo.isUpgradeUnit())7023 {7024 UnitClassTypes eUpgradeUnitClass = NO_UNITCLASS;7025 UnitTypes eUpgradeUnit = NO_UNIT;70267027 if(pUnit != NULL)7028 {7029 eUpgradeUnitClass = (UnitClassTypes) pUnit->getUnitInfo().GetGoodyHutUpgradeUnitClass();7030 eUpgradeUnit = (UnitTypes) getCivilizationInfo().getCivilizationUnits(eUpgradeUnitClass);7031 }7032 7033 if(eUpgradeUnit != NO_UNIT)7034 {7035 // Add new upgrade Unit70367037 // if we promoted an scouting unit from a goody hut, turn him into whatever the new unit's default AI is if it is not a suitable explorer anymore7038 UnitAITypes currentAIDefault = pUnit->AI_getUnitAIType();7039 UnitAITypes newAIDefault = (UnitAITypes)GC.getUnitInfo(eUpgradeUnit)->GetDefaultUnitAIType();7040 if(currentAIDefault == UNITAI_EXPLORE)7041 {7042 if(newAIDefault == UNITAI_EXPLORE || newAIDefault == UNITAI_ATTACK || newAIDefault == UNITAI_DEFENSE || newAIDefault == UNITAI_FAST_ATTACK || newAIDefault == UNITAI_COUNTER)7043 {7044 newAIDefault = UNITAI_EXPLORE;7045 }7046 }70477048 CvUnit* pNewUnit = initUnit(eUpgradeUnit, pPlot->getX(), pPlot->getY(), newAIDefault, NO_DIRECTION, false, false, 0, pUnit->GetNumGoodyHutsPopped());7049 pUnit->finishMoves();7050 pUnit->SetBeenPromotedFromGoody(true);70517052 CvAssert(pNewUnit);7053 if (pNewUnit != NULL)7054 {7055#if defined(MOD_EVENTS_UNIT_UPGRADES)7056 // MUST call the event before convert() as that kills the old unit7057 if (MOD_EVENTS_UNIT_UPGRADES) {7058 GAMEEVENTINVOKE_HOOK(GAMEEVENT_UnitUpgraded, GetID(), pUnit->GetID(), pNewUnit->GetID(), true);7059 } else {7060#endif7061 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();7062 if (pkScriptSystem)7063 {7064 CvLuaArgsHandle args;7065 args->Push(GetID());7066 args->Push(pUnit->GetID());7067 args->Push(pNewUnit->GetID());7068 args->Push(true); // bGoodyHut70697070 bool bScriptResult;7071 LuaSupport::CallHook(pkScriptSystem, "UnitUpgraded", args.get(), bScriptResult);7072 }7073#if defined(MOD_EVENTS_UNIT_UPGRADES)7074 }7075#endif70767077 pNewUnit->convert(pUnit, true);7078 pNewUnit->setupGraphical();7079 }7080 else7081 pUnit->kill(false);70827083 // Since the old unit died, it will block the goody reward popup unless we call this7084 GC.GetEngineUserInterface()->SetDontShowPopups(false);7085 }7086 }70877088 // Tech7089 if(kGoodyInfo.isTech())7090 {7091 iBestValue = 0;7092 eBestTech = NO_TECH;70937094 for(iI = 0; iI < GC.getNumTechInfos(); iI++)7095 {7096 const TechTypes eTech = static_cast<TechTypes>(iI);7097 CvTechEntry* pkTech = GC.getTechInfo(eTech);7098 if(pkTech != NULL && pkTech->IsGoodyTech())7099 {7100 if(GetPlayerTechs()->CanResearch(eTech))7101 {7102 bool bUseTech = true;71037104#if defined(MOD_EVENTS_GOODY_TECH)7105 if (MOD_EVENTS_GOODY_TECH) {7106 if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_GoodyHutCanResearch, GetID(), iI) == GAMEEVENTRETURN_FALSE) {7107 bUseTech = false;7108 }7109 } else {7110#endif7111 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();7112 if (pkScriptSystem)7113 {7114 CvLuaArgsHandle args;7115 args->Push(GetID());7116 args->Push(eTech);71177118 // Attempt to execute the game events.7119 // Will return false if there are no registered listeners.7120 bool bScriptResult = false;7121 if (LuaSupport::CallTestAll(pkScriptSystem, "GoodyHutCanResearch", args.get(), bScriptResult))7122 {7123 bUseTech = bScriptResult;7124 }7125 }7126#if defined(MOD_EVENTS_GOODY_TECH)7127 }7128#endif71297130 if(bUseTech)7131 {7132 iValue = (1 + GC.getGame().getJonRandNum(10000, "Goody Tech"));71337134 if(iValue > iBestValue)7135 {7136 iBestValue = iValue;7137 eBestTech = eTech;7138 }7139 }7140 }7141 }7142 }71437144 CvAssertMsg(eBestTech != NO_TECH, "BestTech is not assigned a valid value");71457146#if defined(MOD_EVENTS_GOODY_TECH)7147 if (MOD_EVENTS_GOODY_TECH) {7148 GAMEEVENTINVOKE_HOOK(GAMEEVENT_GoodyHutTechResearched, GetID(), eBestTech);7149 } else {7150#endif7151 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();7152 if (pkScriptSystem) 7153 {7154 CvLuaArgsHandle args;7155 args->Push(GetID());7156 args->Push(eBestTech);71577158 bool bScriptResult;7159 LuaSupport::CallHook(pkScriptSystem, "GoodyHutTechResearched", args.get(), bScriptResult);7160 }7161#if defined(MOD_EVENTS_GOODY_TECH)7162 }7163#endif71647165 GET_TEAM(getTeam()).setHasTech(eBestTech, true, GetID(), true, true);7166 GET_TEAM(getTeam()).GetTeamTechs()->SetNoTradeTech(eBestTech, true);7167 }71687169 // Units7170 if(kGoodyInfo.getUnitClassType() != NO_UNITCLASS)7171 {7172 eUnit = (UnitTypes)getCivilizationInfo().getCivilizationUnits(kGoodyInfo.getUnitClassType());71737174 if(eUnit != NO_UNIT)7175 {7176 CvUnit* pNewUnit = initUnit(eUnit, pPlot->getX(), pPlot->getY());7177 // see if there is an open spot to put him - no over-stacking allowed!7178 if(pNewUnit && pUnit && pUnit->AreUnitsOfSameType(*pNewUnit)) // pUnit isn't in this plot yet (if it even exists) so we can't check on if we are over-stacked directly7179 {7180 pBestPlot = NULL;7181 iBestValue = INT_MAX;7182 const int iPopRange = 2;7183 for(iDX = -(iPopRange); iDX <= iPopRange; iDX++)7184 {7185 for(iDY = -(iPopRange); iDY <= iPopRange; iDY++)7186 {7187 pLoopPlot = plotXYWithRangeCheck(pPlot->getX(), pPlot->getY(), iDX, iDY, iPopRange);7188 if(pLoopPlot != NULL)7189 {7190 if(pLoopPlot->isValidDomainForLocation(*pNewUnit))7191 {7192 if(pNewUnit->canMoveInto(*pLoopPlot))7193 {7194#if defined(MOD_GLOBAL_STACKING_RULES)7195 if(pLoopPlot->getNumFriendlyUnitsOfType(pUnit) < pLoopPlot->getUnitLimit())7196#else7197 if(pLoopPlot->getNumFriendlyUnitsOfType(pUnit) < GC.getPLOT_UNIT_LIMIT())7198#endif7199 {7200 if(pNewUnit->canEnterTerritory(pLoopPlot->getTeam()) && !pNewUnit->isEnemy(pLoopPlot->getTeam(), pLoopPlot))7201 {7202 if((pNewUnit->getDomainType() != DOMAIN_AIR) || pLoopPlot->isFriendlyCity(*pNewUnit, true))7203 {7204 if(pLoopPlot->isRevealed(getTeam()))7205 {7206 iValue = 1 + GC.getGame().getJonRandNum(6, "spawn goody unit that would over-stack"); // okay, I'll admit it, not a great heuristic72077208 if(plotDistance(pPlot->getX(),pPlot->getY(),pLoopPlot->getX(),pLoopPlot->getY()) > 1)7209 {7210 iValue += 12;7211 }72127213 if(pLoopPlot->area() != pPlot->area()) // jumped to a different land mass, cool7214 {7215 iValue *= 10;7216 }72177218 if(iValue < iBestValue)7219 {7220 iBestValue = iValue;7221 pBestPlot = pLoopPlot;7222 }7223 }7224 }7225 }7226 }7227 }7228 }7229 }7230 }7231 }7232 if(pBestPlot != NULL)7233 {7234 bool bVis = pBestPlot->isVisibleToWatchingHuman();7235 pNewUnit->setXY(pBestPlot->getX(), pBestPlot->getY(), false, true, true && bVis, true);7236 pNewUnit->SetPosition(pBestPlot); // Need this to put the unit in the right spot graphically7237 pNewUnit->finishMoves();7238 }7239 else7240 {7241 pNewUnit->kill(false);7242 }7243 }7244 }7245 }72467247 // Barbarians7248 if(kGoodyInfo.getBarbarianUnitClass() != NO_UNITCLASS)7249 {7250 iBarbCount = 0;72517252 eUnit = (UnitTypes)GET_PLAYER(BARBARIAN_PLAYER).getCivilizationInfo().getCivilizationUnits(kGoodyInfo.getBarbarianUnitClass());72537254 if(eUnit != NO_UNIT)7255 {7256 for(iPass = 0; iPass < 10; iPass++)7257 {7258 if(iBarbCount < kGoodyInfo.getMinBarbarians())7259 {7260 for(iI = 0; iI < NUM_DIRECTION_TYPES; iI++)7261 {7262 pLoopPlot = plotDirection(pPlot->getX(), pPlot->getY(), ((DirectionTypes)iI));72637264 if(pLoopPlot != NULL)7265 {7266 if(pLoopPlot->getArea() == pPlot->getArea())7267 {7268 if(!(pLoopPlot->isImpassable()) && !pLoopPlot->isMountain() && !(pLoopPlot->getPlotCity()))7269 {7270 if(pLoopPlot->getNumUnits() == 0)7271 {7272 if((iPass > 0) || (GC.getGame().getJonRandNum(100, "Goody Barbs") < kGoodyInfo.getBarbarianUnitProb()))7273 {7274 GET_PLAYER(BARBARIAN_PLAYER).initUnit(eUnit, pLoopPlot->getX(), pLoopPlot->getY(), ((pLoopPlot->isWater()) ? UNITAI_ATTACK_SEA : UNITAI_ATTACK));7275 iBarbCount++;72767277 if((iPass > 0) && (iBarbCount == kGoodyInfo.getMinBarbarians()))7278 {7279 break;7280 }7281 }7282 }7283 }7284 }7285 }7286 }7287 }7288 }7289 }7290 }72917292 if(!strBuffer.empty() && GC.getGame().getActivePlayer() == GetID())7293 {7294 GC.GetEngineUserInterface()->AddPlotMessage(0, pPlot->GetPlotIndex(), GetID(), true, GC.getEVENT_MESSAGE_TIME(), strBuffer);7295 }72967297#if defined(CIV_HOST_API)7298 CivHandPopupRaised(GetID(), BUTTONPOPUP_GOODY_HUT_REWARD, eGoody, iGold > 0 ? iGold : (iCulture > 0 ? iCulture : (iFaith > 0 ? iFaith : 0)), -1, false, false, strBuffer.c_str());hand-placed hook: PopupRaised7299#endif7300 // If it's the active player then show the popup7301 if(GetID() == GC.getGame().getActivePlayer())7302 {7303 GC.getMap().updateDeferredFog();73047305 bool bDontShowRewardPopup = GC.GetEngineUserInterface()->IsOptionNoRewardPopups();73067307 // Don't show in MP, or if the player has turned it off7308#if defined(MOD_API_EXTENSIONS)7309 if(!GC.getGame().isReallyNetworkMultiPlayer() && !bDontShowRewardPopup)7310#else7311 if(!GC.getGame().isNetworkMultiPlayer() && !bDontShowRewardPopup) // KWG: Candidate for !GC.getGame().isOption(GAMEOPTION_SIMULTANEOUS_TURNS)7312#endif7313 {7314 int iSpecialValue = 0;73157316 if(iGold > 0)7317 iSpecialValue = iGold;7318 else if(iCulture > 0)7319 iSpecialValue = iCulture;7320 else if(iFaith > 0)7321 iSpecialValue = iFaith;73227323 CvPopupInfo kPopupInfo(BUTTONPOPUP_GOODY_HUT_REWARD, eGoody, iSpecialValue);7324 GC.GetEngineUserInterface()->AddPopup(kPopupInfo);7325 // We are adding a popup that the player must make a choice in, make sure they are not in the end-turn phase.7326 CancelActivePlayerEndTurn();7327 }7328 }7329}
Calls
- CancelActivePlayerEndTurn()
CivHandPopupRaised- CustomMods::eventHook(const char *, const char *, ...)
- CustomMods::eventTestAll(const char *, const char *, ...)
- CustomMods::isEVENTS_GOODY_TECH()
- CustomMods::isEVENTS_UNIT_UPGRADES()
- CustomMods::isGLOBAL_TRULY_FREE_GP()
- CvBaseInfo::CacheResult(Database::Results &)
- CvBaseInfo::GetDescription() const
- CvCity::changePopulation(int, bool)
- CvCity::getX() const
- CvCity::getY() const
- CvCivilizationInfo::getCivilizationUnits(int) const
- CvGame::getActivePlayer() const
- CvGame::getActiveTeam()
- CvGame::GetGameReligions()
- CvGame::getGameSpeedInfo() const
- CvGame::getJonRandNum(int, const char *)
- CvGame::isReallyNetworkMultiPlayer() const
- CvGameReligions::GetMinimumFaithNextPantheon() const
- CvGameSpeedInfo::getCulturePercent() const
- CvGameSpeedInfo::getFaithPercent() const
- CvGlobals::getBARBARIAN_CAMP_IMPROVEMENT()
- CvGlobals::getDLLIFace()
- CvGlobals::GetEngineUserInterface()
- CvGlobals::getEVENT_MESSAGE_TIME()
- CvGlobals::getGame()
- CvGlobals::GetGameDatabase()
- CvGlobals::getGOLD_PURCHASE_VISIBLE_DIVISOR()
- CvGlobals::getInfoTypeForString(const char *, bool) const
- CvGlobals::getMap()
- CvGlobals::getNumTechInfos()
- CvGlobals::getRELIGION_GAME_FAITH_DELTA_NEXT_PANTHEON()
- CvGlobals::getResourceInfo(ResourceTypes)
- CvGlobals::getTechInfo(TechTypes)
- CvGlobals::getUnitInfo(UnitTypes)
- CvGoodyHuts::DoPlayerReceivedGoody(PlayerTypes, GoodyTypes)
- CvGoodyInfo::CvGoodyInfo()
- CvGoodyInfo::getBarbarianUnitClass() const
- CvGoodyInfo::getBarbarianUnitProb() const
- CvGoodyInfo::getCulture() const
- CvGoodyInfo::getExperience() const
- CvGoodyInfo::getFaith() const
- CvGoodyInfo::getGold() const
- CvGoodyInfo::getGoldRandAmount() const
- CvGoodyInfo::getHealing() const
- CvGoodyInfo::getMapOffset() const
- CvGoodyInfo::getMapProb() const
- CvGoodyInfo::getMapRange() const
- CvGoodyInfo::getMinBarbarians() const
- CvGoodyInfo::getNumGoldRandRolls() const
- CvGoodyInfo::getPopulation() const
- CvGoodyInfo::getProphetPercent() const
- CvGoodyInfo::getRevealNearbyBarbariansRange() const
- CvGoodyInfo::getUnitClassType() const
- CvGoodyInfo::isPantheonFaith() const
- CvGoodyInfo::isRevealUnknownResource() const
- CvGoodyInfo::isTech() const
- CvGoodyInfo::isUpgradeUnit() const
- CvLuaArgsHandle::CvLuaArgsHandle()
- CvLuaArgsHandle::get() const
- CvLuaArgsHandle::operator->() const
- CvMap::numPlots() const
- CvMap::plotByIndexUnchecked(int) const
- CvMap::updateDeferredFog()
- CvPlayer::ChangeFaith(int)
- CvPlayer::changeJONSCulture(int)
- CvPlayer::firstCity(int *, bool)
- CvPlayer::getCapitalCity()
- CvPlayer::getCivilizationInfo() const
- CvPlayer::GetID() const
- CvPlayer::GetPlayerTechs() const
- CvPlayer::GetReligions() const
- CvPlayer::getTeam() const
- CvPlayer::GetTreasury() const
- CvPlayer::initUnit(UnitTypes, int, int, UnitAITypes, DirectionTypes, bool, bool, int, int)
- CvPlayer::nextCity(int *, bool)
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerReligions::GetCostNextProphet(bool, bool, bool) const
- CvPlayerTechs::CanResearch(TechTypes, bool) const
- CvPlot::area() const
- CvPlot::getArea() const
- CvPlot::getImprovementType() const
- CvPlot::getNumFriendlyUnitsOfType(const CvUnit *, bool) const
- CvPlot::getNumUnits() const
- CvPlot::getPlotCity() const
- CvPlot::GetPlotIndex() const
- CvPlot::getResourceType(TeamTypes) const
- CvPlot::getTeam() const
- CvPlot::getUnitLimit() const
- CvPlot::getX() const
- CvPlot::getY() const
- CvPlot::isFriendlyCity(const CvUnit &, bool) const
- CvPlot::isImpassable() const
- CvPlot::isMountain() const
- CvPlot::IsResourceForceReveal(TeamTypes) const
- CvPlot::isRevealed(TeamTypes) const
- CvPlot::isValidDomainForLocation(const CvUnit &) const
- CvPlot::isVisibleToWatchingHuman() const
- CvPlot::isWater() const
- CvPlot::setLayoutDirty(bool)
- CvPlot::SetResourceForceReveal(TeamTypes, bool)
- CvPlot::setRevealed(TeamTypes, bool, CvUnit *, bool, TeamTypes)
- CvPlot::setRevealedImprovementType(TeamTypes, ImprovementTypes)
CvPopupInfo::CvPopupInfo- CvResourceInfo::getResourceClassType() const
- CvResourceInfo::getTechReveal() const
CvString::CvStringCvString::FormatCvString::operator const char *CvString::operator=- CvTeam::getTeam(TeamTypes)
- CvTeam::GetTeamTechs() const
- CvTeam::setHasTech(TechTypes, bool, PlayerTypes, bool, bool)
- CvTeamTechs::HasTech(TechTypes) const
- CvTeamTechs::SetNoTradeTech(TechTypes, bool)
- CvTechEntry::GetResearchCost() const
- CvTechEntry::IsGoodyTech() const
- CvTreasury::ChangeGold(int)
- CvUnit::AI_getUnitAIType() const
- CvUnit::AreUnitsOfSameType(const CvUnit &, const bool) const
- CvUnit::canEnterTerritory(TeamTypes, bool, bool, bool) const
- CvUnit::canMoveInto(const CvPlot &, byte) const
- CvUnit::changeDamage(int, PlayerTypes, int, float, const CvString *)
- CvUnit::changeExperienceTimes100(int, int, bool, bool, bool)
- CvUnit::convert(CvUnit *, bool)
- CvUnit::finishMoves()
- CvUnit::getDomainType() const
- CvUnit::GetID() const
- CvUnit::GetNumGoodyHutsPopped() const
- CvUnit::getUnitInfo() const
- CvUnit::isEnemy(TeamTypes, const CvPlot *) const
- CvUnit::kill(bool, PlayerTypes)
- CvUnit::SetBeenPromotedFromGoody(bool)
- CvUnit::SetPosition(CvPlot *)
- CvUnit::setupGraphical()
- CvUnit::setXY(int, int, bool, bool, bool, bool, bool)
- CvUnitEntry::GetDefaultUnitAIType() const
- CvUnitEntry::GetGoodyHutUpgradeUnitClass() const
Database::Connection::SelectAtDatabase::SingleResult::SingleResultGetLocalizedTextICvEngineScriptSystemArgs1::PushICvEngineScriptSystemArgs1::PushICvEngineUtility1::GetScriptSystemICvUserInterface1::AddPlotMessageICvUserInterface1::AddPopupICvUserInterface1::IsOptionNoRewardPopupsICvUserInterface1::SetDontShowPopups- LuaSupport::CallHook(ICvEngineScriptSystem1 *, const char *, ICvEngineScriptSystemArgs1 *, bool &)
- LuaSupport::CallTestAll(ICvEngineScriptSystem1 *, const char *, ICvEngineScriptSystemArgs1 *, bool &)
- plotDirection(int, int, DirectionTypes)
- plotDistance(int, int, int, int)
- plotXY(int, int, int, int)
- plotXYWithRangeCheck(int, int, int, int, int)
std::basic_string::c_strstd::basic_string::emptystd::basic_string::operator+=