CvUnit::isActionRecommended(int)
- Defined in
- CvUnit.cpp, line 2167
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_isActionRecommended
Hooks
static bool BeforeCvUnit_isActionRecommended(CvUnit* self, int iAction, bool& result);static void AfterCvUnit_isActionRecommended(CvUnit* self, int iAction, bool& result);static bool ReplaceCvUnit_isActionRecommended(bool (*original)(CvUnit*, int), CvUnit* self, int iAction);CivRegisterBefore<CivHooks::CvUnit_isActionRecommended>(host, &BeforeCvUnit_isActionRecommended);CivRegisterAfter<CivHooks::CvUnit_isActionRecommended>(host, &AfterCvUnit_isActionRecommended);CivRegisterReplace<CivHooks::CvUnit_isActionRecommended>(host, &ReplaceCvUnit_isActionRecommended);
Code
2167bool CvUnit::isActionRecommended(int iAction)2168{2169 VALIDATE_OBJECT21702171 BuildTypes eBuild;21722173 if(getOwner() != GC.getGame().getActivePlayer())2174 {2175 return false;2176 }21772178 CvPlot* pPlot = NULL;21792180 if(pPlot == NULL)2181 {2182 if(gDLL->shiftKey())2183 {2184 pPlot = LastMissionPlot();2185 }2186 }21872188 if(pPlot == NULL)2189 {2190 pPlot = plot();2191 }21922193 if(GC.getActionInfo(iAction)->getMissionType() == CvTypes::getMISSION_HEAL())2194 {2195 if(IsHurt())2196 {2197 if(!hasMoved())2198 {2199 if((pPlot->getTeam() == getTeam()) || (healTurns(pPlot) < 4))2200 {2201 return true;2202 }2203 }2204 }2205 }22062207 if(GC.getActionInfo(iAction)->getMissionType() == CvTypes::getMISSION_FOUND())2208 {2209 if(canFound(pPlot))2210 {2211 if(pPlot->isBestAdjacentFound(getOwner()))2212 {2213 return true;2214 }2215 }2216 }22172218 if(GC.getActionInfo(iAction)->getMissionType() == CvTypes::getMISSION_BUILD())2219 {2220 eBuild = ((BuildTypes)(GC.getActionInfo(iAction)->getMissionData()));2221 CvAssert(eBuild != NO_BUILD);2222 CvAssertMsg(eBuild < GC.getNumBuildInfos(), "Invalid Build");22232224 const int ciDirectiveSize = 1;2225 BuilderDirective aDirective[ ciDirectiveSize ];22262227 GET_PLAYER(getOwner()).GetBuilderTaskingAI()->EvaluateBuilder(this, aDirective, ciDirectiveSize, false, true);22282229 if(aDirective[0].m_eDirective != BuilderDirective::NUM_DIRECTIVES && aDirective[0].m_eBuild == eBuild)2230 {2231 return true;2232 }2233 }22342235 if(GC.getActionInfo(iAction)->getCommandType() == COMMAND_PROMOTION)2236 {2237 return true;2238 }22392240 return false;2241}
Calls
- BuilderDirective::BuilderDirective()
- CvActionInfo::getCommandType() const
- CvActionInfo::getMissionData() const
- CvActionInfo::getMissionType() const
- CvBuilderTaskingAI::EvaluateBuilder(CvUnit *, BuilderDirective *, UINT, bool, bool, bool)
- CvGame::getActivePlayer() const
- CvGlobals::getActionInfo(int)
- CvGlobals::getDLLIFace()
- CvGlobals::getGame()
- CvPlayer::GetBuilderTaskingAI() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlot::getTeam() const
- CvPlot::isBestAdjacentFound(PlayerTypes)
- CvTypes::getMISSION_BUILD()
- CvTypes::getMISSION_FOUND()
- CvTypes::getMISSION_HEAL()
- CvUnit::canFound(const CvPlot *, bool) const
- CvUnit::getOwner() const
- CvUnit::getTeam() const
- CvUnit::hasMoved() const
- CvUnit::healTurns(const CvPlot *) const
- CvUnit::IsHurt() const
- CvUnit::LastMissionPlot()
- CvUnit::plot() const
ICvEngineUtility1::shiftKey