本文整理汇总了C++中Town::camp_influence方法的典型用法代码示例。如果您正苦于以下问题:C++ Town::camp_influence方法的具体用法?C++ Town::camp_influence怎么用?C++ Town::camp_influence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Town
的用法示例。
在下文中一共展示了Town::camp_influence方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find_best_capturer
//-------- Begin of function Nation::find_best_capturer ------//
//
// Find an existing unit as the capturer of the town.
//
// <int> townRecno - recno of the town to capture
// <int> raceId - race id. of the capturer. 0 if any races.
// <int&> bestTargetResistance - a reference var for returning the target resistance if the returned unit is assigned as the overseer
//
// return: <int> the recno of the unit found.
//
int Nation::find_best_capturer(int townRecno, int raceId, int& bestTargetResistance)
{
#define MIN_CAPTURE_RESISTANCE_DEC 20 // if we assign a unit as the commander, the minimum expected resistance decrease should be 20, otherwise we don't do it.
Unit* unitPtr;
Town* targetTown = town_array[townRecno];
Firm* firmPtr;
int targetResistance;
int bestUnitRecno=0;
bestTargetResistance = 100;
for( int i=ai_general_count-1 ; i>=0 ; i-- )
{
unitPtr = unit_array[ ai_general_array[i] ];
if( raceId && unitPtr->race_id != raceId )
continue;
err_when( unitPtr->nation_recno != nation_recno );
err_when( unitPtr->rank_id != RANK_KING && unitPtr->rank_id != RANK_GENERAL );
if( unitPtr->nation_recno != nation_recno )
continue;
//---- if this unit is on a mission ----//
if( unitPtr->home_camp_firm_recno )
continue;
//---- don't use the king to build camps next to capture enemy towns, only next to independent towns ----//
if( unitPtr->rank_id == RANK_KING && targetTown->nation_recno )
continue;
//----- if this unit is in a camp -------//
if( unitPtr->unit_mode == UNIT_MODE_OVERSEE )
{
firmPtr = firm_array[unitPtr->unit_mode_para];
//--- check if the unit currently in a command base trying to take over an independent town ---//
int j;
for( j=firmPtr->linked_town_count-1 ; j>=0 ; j-- )
{
Town* townPtr = town_array[ firmPtr->linked_town_array[j] ];
//--- if the unit is trying to capture an independent town and he is still influencing the town to decrease resistance ---//
if( townPtr->nation_recno==0 &&
townPtr->average_target_resistance(nation_recno) <
townPtr->average_resistance(nation_recno) )
{
break; // then don't use this unit
}
}
if( j>=0 ) // if so, don't use this unit
continue;
}
//--- if this unit is idle and the region ids are matched ---//
if( unitPtr->action_mode != ACTION_STOP ||
unitPtr->region_id() != targetTown->region_id )
{
continue;
}
//------- get the unit's influence index --------//
err_when( unitPtr->skill.skill_id != SKILL_LEADING );
targetResistance = 100-targetTown->camp_influence(unitPtr->sprite_recno); // influence of this unit if he is assigned as a commander of a military camp
//-- see if this unit's rating is higher than the current best --//
if( targetResistance < bestTargetResistance )
{
bestTargetResistance = targetResistance;
bestUnitRecno = unitPtr->sprite_recno;
}
}
return bestUnitRecno;
}