本文整理汇总了C++中CvUnit::canMoveInto方法的典型用法代码示例。如果您正苦于以下问题:C++ CvUnit::canMoveInto方法的具体用法?C++ CvUnit::canMoveInto怎么用?C++ CvUnit::canMoveInto使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvUnit
的用法示例。
在下文中一共展示了CvUnit::canMoveInto方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AI_GroupPower
// uses the same scale as CvPlayerAI::AI_getOurPlotStrength
int CvSelectionGroupAI::AI_GroupPower(CvPlot* pPlot, bool bDefensiveBonuses) const
{
CLLNode<IDInfo>* pUnitNode;
CvUnit* pLoopUnit;
int iValue;
iValue = 0;
pUnitNode = headUnitNode();
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
if ((bDefensiveBonuses && pLoopUnit->canDefend()) || pLoopUnit->canAttack())
{
if (!(pLoopUnit->isInvisible(getTeam(), false)))
{
if (pLoopUnit->atPlot(pPlot) || pLoopUnit->canMoveInto(pPlot) || pLoopUnit->canMoveInto(pPlot, /*bAttack*/ true))
{
iValue += pLoopUnit->currEffectiveStr((bDefensiveBonuses ? pPlot : NULL), NULL);
}
}
}
}
return iValue;
}
示例2: AI_sumStrength
int CvSelectionGroupAI::AI_sumStrength(const CvPlot* pAttackedPlot, DomainTypes eDomainType, bool bCheckCanAttack, bool bCheckCanMove) const
{
CLLNode<IDInfo>* pUnitNode;
CvUnit* pLoopUnit;
int strSum = 0;
pUnitNode = headUnitNode();
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
if (!pLoopUnit->isDead())
{
bool bCanAttack = false;
if (pLoopUnit->getDomainType() == DOMAIN_AIR)
bCanAttack = pLoopUnit->canAirAttack();
else
bCanAttack = pLoopUnit->canAttack();
if (!bCheckCanAttack || bCanAttack)
{
if (!bCheckCanMove || pLoopUnit->canMove())
if (!bCheckCanMove || pAttackedPlot == NULL || pLoopUnit->canMoveInto(pAttackedPlot, /*bAttack*/ true, /*bDeclareWar*/ true))
if (eDomainType == NO_DOMAIN || pLoopUnit->getDomainType() == eDomainType)
strSum += pLoopUnit->currEffectiveStr(pAttackedPlot, pLoopUnit);
}
}
}
return strSum;
}
示例3: AI_getBestGroupAttacker
CvUnit* CvSelectionGroupAI::AI_getBestGroupAttacker(const CvPlot* pPlot, bool bPotentialEnemy, int& iUnitOdds, bool bForce, bool bNoBlitz) const
{
CLLNode<IDInfo>* pUnitNode;
CvUnit* pLoopUnit;
CvUnit* pBestUnit;
int iValue;
int iBestValue;
int iOdds;
int iBestOdds;
iBestValue = 0;
iBestOdds = 0;
pBestUnit = NULL;
pUnitNode = headUnitNode();
bool bIsHuman = (pUnitNode != NULL) ? GET_PLAYER(::getUnit(pUnitNode->m_data)->getOwnerINLINE()).isHuman() : true;
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
if (!pLoopUnit->isDead())
{
bool bCanAttack = false;
bCanAttack = pLoopUnit->canAttack();
if (bCanAttack && bNoBlitz && pLoopUnit->isBlitz() && pLoopUnit->isMadeAttack())
{
bCanAttack = false;
}
if (bCanAttack)
{
if (bForce || pLoopUnit->canMove())
{
if (bForce || pLoopUnit->canMoveInto(pPlot, /*bAttack*/ true, /*bDeclareWar*/ bPotentialEnemy))
{
iOdds = pLoopUnit->AI_attackOdds(pPlot, bPotentialEnemy);
iValue = iOdds;
FAssertMsg(iValue > 0, "iValue is expected to be greater than 0");
// if non-human, prefer the last unit that has the best value (so as to avoid splitting the group)
if (iValue > iBestValue || (!bIsHuman && iValue > 0 && iValue == iBestValue))
{
iBestValue = iValue;
iBestOdds = iOdds;
pBestUnit = pLoopUnit;
}
}
}
}
}
}
iUnitOdds = iBestOdds;
return pBestUnit;
}
示例4: AI_getBestGroupSacrifice
CvUnit* CvSelectionGroupAI::AI_getBestGroupSacrifice(const CvPlot* pPlot, bool bPotentialEnemy, bool bForce, bool bNoBlitz) const
{
int iBestValue = 0;
CvUnit* pBestUnit = NULL;
CLLNode<IDInfo>* pUnitNode = headUnitNode();
while (pUnitNode != NULL)
{
CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
if (!pLoopUnit->isDead())
{
bool bCanAttack = false;
if (pLoopUnit->getDomainType() == DOMAIN_AIR)
{
bCanAttack = pLoopUnit->canAirAttack();
}
else
{
bCanAttack = pLoopUnit->canAttack();
if (bCanAttack && bNoBlitz && pLoopUnit->isBlitz() && pLoopUnit->isMadeAttack())
{
bCanAttack = false;
}
}
if (bCanAttack)
{
if (bForce || pLoopUnit->canMove())
{
if (bForce || pLoopUnit->canMoveInto(pPlot, true))
{
int iValue = pLoopUnit->AI_sacrificeValue(pPlot);
FAssertMsg(iValue > 0, "iValue is expected to be greater than 0");
// we want to pick the last unit of highest value, so pick the last unit with a good value
if (iValue >= iBestValue)
{
iBestValue = iValue;
pBestUnit = pLoopUnit;
}
}
}
}
}
}
return pBestUnit;
}
示例5: AI_getBestGroupAttacker
CvUnit* CvSelectionGroupAI::AI_getBestGroupAttacker(const CvPlot* pPlot, bool bPotentialEnemy, int& iUnitOdds, bool bForce, bool bNoBlitz) const
{
CLLNode<IDInfo>* pUnitNode;
CvUnit* pLoopUnit;
CvUnit* pBestUnit;
int iPossibleTargets;
int iValue;
int iBestValue;
int iOdds;
int iBestOdds;
iBestValue = 0;
iBestOdds = 0;
pBestUnit = NULL;
pUnitNode = headUnitNode();
bool bIsHuman = (pUnitNode != NULL) ? GET_PLAYER(::getUnit(pUnitNode->m_data)->getOwnerINLINE()).isHuman() : true;
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
if (!pLoopUnit->isDead())
{
bool bCanAttack = false;
if (pLoopUnit->getDomainType() == DOMAIN_AIR)
{
bCanAttack = pLoopUnit->canAirAttack();
}
else
{
bCanAttack = pLoopUnit->canAttack();
if (bCanAttack && bNoBlitz && pLoopUnit->isBlitz() && pLoopUnit->isMadeAttack())
{
bCanAttack = false;
}
}
if (bCanAttack)
{
if (bForce || pLoopUnit->canMove())
{
if (bForce || pLoopUnit->canMoveInto(pPlot, /*bAttack*/ true, /*bDeclareWar*/ bPotentialEnemy))
{
iOdds = pLoopUnit->AI_attackOdds(pPlot, bPotentialEnemy);
iValue = iOdds;
FAssertMsg(iValue > 0, "iValue is expected to be greater than 0");
if (pLoopUnit->collateralDamage() > 0)
{
iPossibleTargets = std::min((pPlot->getNumVisibleEnemyDefenders(pLoopUnit) - 1), pLoopUnit->collateralDamageMaxUnits());
if (iPossibleTargets > 0)
{
iValue *= (100 + ((pLoopUnit->collateralDamage() * iPossibleTargets) / 5));
iValue /= 100;
}
}
// if non-human, prefer the last unit that has the best value (so as to avoid splitting the group)
if (iValue > iBestValue || (!bIsHuman && iValue > 0 && iValue == iBestValue))
{
iBestValue = iValue;
iBestOdds = iOdds;
pBestUnit = pLoopUnit;
}
}
}
}
}
}
iUnitOdds = iBestOdds;
return pBestUnit;
}
示例6: AI_sumStrength
// K-Mod. I've removed bCheckMove, and changed bCheckCanAttack to include checks for moves, and for hasAlreadyAttacked / blitz
int CvSelectionGroupAI::AI_sumStrength(const CvPlot* pAttackedPlot, DomainTypes eDomainType, bool bCheckCanAttack) const
{
CLLNode<IDInfo>* pUnitNode;
CvUnit* pLoopUnit;
int strSum = 0;
bool bDefenders = pAttackedPlot ? pAttackedPlot->isVisibleEnemyUnit(getHeadOwner()) : false; // K-Mod
bool bCountCollateral = pAttackedPlot && pAttackedPlot != plot(); // K-Mod
pUnitNode = headUnitNode();
int iBaseCollateral = bCountCollateral
? iBaseCollateral = estimateCollateralWeight(pAttackedPlot, pAttackedPlot->getTeam() == getTeam() ? NO_TEAM : pAttackedPlot->getTeam())
: 0;
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
if (!pLoopUnit->isDead())
{
// K-Mod. (original checks deleted.)
if (bCheckCanAttack)
{
if (pLoopUnit->getDomainType() == DOMAIN_AIR)
{
if (!pLoopUnit->canAirAttack() || !pLoopUnit->canMove() || (pAttackedPlot && bDefenders && !pLoopUnit->canMoveInto(pAttackedPlot, true, true)))
continue; // can't attack.
}
else
{
if (!pLoopUnit->canAttack() || !pLoopUnit->canMove()
|| (pAttackedPlot && bDefenders && !pLoopUnit->canMoveInto(pAttackedPlot, true, true))
|| (!pLoopUnit->isBlitz() && pLoopUnit->isMadeAttack()))
continue; // can't attack.
}
}
// K-Mod end
if (eDomainType == NO_DOMAIN || pLoopUnit->getDomainType() == eDomainType)
{
strSum += pLoopUnit->currEffectiveStr(pAttackedPlot, pLoopUnit);
// K-Mod estimate the attack power of collateral units. (cf with calculation in AI_localAttackStrength)
if (bCountCollateral && pLoopUnit->collateralDamage() > 0)
{
int iPossibleTargets = pLoopUnit->collateralDamageMaxUnits();
// If !bCheckCanAttack, then lets not assume pAttackPlot won't get more units on it.
if (bCheckCanAttack && pAttackedPlot->isVisible(getTeam(), false))
iPossibleTargets = std::min(iPossibleTargets, pAttackedPlot->getNumVisibleEnemyDefenders(pLoopUnit) - 1);
if (iPossibleTargets > 0)
{
// collateral damage is not trivial to calculate. This estimate is pretty rough.
// (Note: collateralDamage() and iBaseCollateral both include factors of 100.)
strSum += pLoopUnit->baseCombatStr() * iBaseCollateral * pLoopUnit->collateralDamage() * iPossibleTargets / 10000;
}
}
// K-Mod end
}
}
}
return strSum;
}
示例7: AI_getBestGroupAttacker
CvUnit* CvSelectionGroupAI::AI_getBestGroupAttacker(const CvPlot* pPlot, bool bPotentialEnemy, int& iUnitOdds, bool bForce, bool bNoBlitz) const
{
PROFILE_FUNC();
int iBestValue = 0;
int iBestOdds = 0;
CvUnit* pBestUnit = NULL;
CLLNode<IDInfo>* pUnitNode = headUnitNode();
bool bIsHuman = (pUnitNode != NULL) ? GET_PLAYER(::getUnit(pUnitNode->m_data)->getOwnerINLINE()).isHuman() : true;
while (pUnitNode != NULL)
{
CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
if (!pLoopUnit->isDead())
{
bool bCanAttack = false;
if (pLoopUnit->getDomainType() == DOMAIN_AIR)
{
bCanAttack = pLoopUnit->canAirAttack();
}
else
{
bCanAttack = pLoopUnit->canAttack();
if (bCanAttack && bNoBlitz && pLoopUnit->isBlitz() && pLoopUnit->isMadeAttack())
{
bCanAttack = false;
}
}
if (bCanAttack)
{
if (bForce || pLoopUnit->canMove())
{
if (bForce || pLoopUnit->canMoveInto(pPlot, /*bAttack*/ true, /*bDeclareWar*/ bPotentialEnemy))
{
/************************************************************************************************/
/* BETTER_BTS_AI_MOD 02/21/10 jdog5000 */
/* */
/* Lead From Behind */
/************************************************************************************************/
// From Lead From Behind by UncutDragon
if (GC.getLFBEnable() && GC.getLFBUseCombatOdds())
{
//pLoopUnit->LFBgetBetterAttacker(&pBestUnit, pPlot, bPotentialEnemy, iBestOdds, iValue);
pLoopUnit->LFBgetBetterAttacker(&pBestUnit, pPlot, bPotentialEnemy, iBestOdds, iBestValue); // K-Mod.
}
else
{
int iOdds = pLoopUnit->AI_attackOdds(pPlot, bPotentialEnemy);
int iValue = iOdds;
FAssertMsg(iValue > 0, "iValue is expected to be greater than 0");
if (pLoopUnit->collateralDamage() > 0)
{
int iPossibleTargets = std::min((pPlot->getNumVisibleEnemyDefenders(pLoopUnit) - 1), pLoopUnit->collateralDamageMaxUnits());
if (iPossibleTargets > 0)
{
iValue *= (100 + ((pLoopUnit->collateralDamage() * iPossibleTargets) / 5));
iValue /= 100;
}
}
// if non-human, prefer the last unit that has the best value (so as to avoid splitting the group)
if (iValue > iBestValue || (!bIsHuman && iValue > 0 && iValue == iBestValue))
{
iBestValue = iValue;
iBestOdds = iOdds;
pBestUnit = pLoopUnit;
}
}
/************************************************************************************************/
/* BETTER_BTS_AI_MOD END */
/************************************************************************************************/
}
}
}
}
}
iUnitOdds = iBestOdds;
return pBestUnit;
}
示例8: AI_getBestGroupSacrifice
CvUnit* CvSelectionGroupAI::AI_getBestGroupSacrifice(const CvPlot* pPlot, bool bPotentialEnemy, bool bForce, bool bNoBlitz) const
{
int iBestValue = 0;
CvUnit* pBestUnit = NULL;
CLLNode<IDInfo>* pUnitNode = headUnitNode();
while (pUnitNode != NULL)
{
CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
if (!pLoopUnit->isDead())
{
bool bCanAttack = false;
if (pLoopUnit->getDomainType() == DOMAIN_AIR)
{
bCanAttack = pLoopUnit->canAirAttack();
}
else
{
bCanAttack = pLoopUnit->canAttack();
if (bCanAttack && bNoBlitz && pLoopUnit->isBlitz() && pLoopUnit->isMadeAttack())
{
bCanAttack = false;
}
}
if (bCanAttack)
{
if (bForce || pLoopUnit->canMove())
{
if (bForce || pLoopUnit->canMoveInto(pPlot, true))
{
int iValue = pLoopUnit->AI_sacrificeValue(pPlot);
FAssertMsg(iValue > 0, "iValue is expected to be greater than 0");
/*************************************************************************************************/
/** BETTER AI (Summons make good groupattack sacrifice units) Sephi **/
/** **/
/** **/
/*************************************************************************************************/
if (pLoopUnit->getDuration()>0)
{
iValue+=10000;
}
/*************************************************************************************************/
/** END **/
/*************************************************************************************************/
/*************************************************************************************************/
/** BETTER AI (Block some Units from attacking at low odds) Sephi **/
/** **/
/** **/
/*************************************************************************************************/
if (!GET_PLAYER(pLoopUnit->getOwnerINLINE()).isHuman())
{
if (pLoopUnit->AI_getUnitAIType()==UNITAI_WARWIZARD)
{
iValue=1;
}
if (pLoopUnit->AI_getUnitAIType()==UNITAI_HERO)
{
iValue=1;
}
if (pLoopUnit->getLevel()>4)
{
iValue=1;
}
}
/*************************************************************************************************/
/** END **/
/*************************************************************************************************/
// we want to pick the last unit of highest value, so pick the last unit with a good value
if (iValue >= iBestValue)
{
iBestValue = iValue;
pBestUnit = pLoopUnit;
}
}
}
}
}
}
return pBestUnit;
}