本文整理汇总了C++中Town::change_loyalty方法的典型用法代码示例。如果您正苦于以下问题:C++ Town::change_loyalty方法的具体用法?C++ Town::change_loyalty怎么用?C++ Town::change_loyalty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Town
的用法示例。
在下文中一共展示了Town::change_loyalty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cast_on_loc
//--------- Begin of function UnitGod::cast_on_loc ---------//
//
void UnitGod::cast_on_loc(int castXLoc, int castYLoc)
{
Location* locPtr = world.get_loc( castXLoc, castYLoc );
//--- if there is any unit on the location ---//
if( locPtr->has_unit(UNIT_LAND) )
{
cast_on_unit( locPtr->unit_recno(UNIT_LAND), 1 );
}
else if( locPtr->has_unit(UNIT_SEA) )
{
Unit* unitPtr = unit_array[ locPtr->unit_recno(UNIT_SEA) ];
//-- only heal human units belonging to our nation in ships --//
if( unitPtr->nation_recno == nation_recno &&
unit_res[unitPtr->unit_id]->unit_class == UNIT_CLASS_SHIP )
{
UnitMarine* unitMarine = (UnitMarine*) unitPtr;
for( int i=0 ; i<unitMarine->unit_count ; i++ )
{
int divider = 4; // the size of a ship is 4 locations (2x2)
cast_on_unit( unitMarine->unit_recno_array[i], divider ); // the effects are weaken on ship units, only 50% of the original effects
}
}
}
//--------- on firms ---------//
else if( locPtr->is_firm() )
{
Firm* firmPtr = firm_array[ locPtr->firm_recno() ];
int divider = (firmPtr->loc_x2-firmPtr->loc_x1+1) * (firmPtr->loc_y2-firmPtr->loc_y1+1);
if( god_id == GOD_ZULU )
divider = 1; // range of zulu god is 1, no need to divide
if( firmPtr->overseer_recno )
{
cast_on_unit( firmPtr->overseer_recno, divider );
}
if( firmPtr->worker_array && firm_res[firmPtr->firm_id]->live_in_town==0 )
{
Worker* workerPtr = firmPtr->worker_array;
for( int i=0 ; i<firmPtr->worker_count ; i++, workerPtr++ )
{
cast_on_worker(workerPtr, firmPtr->nation_recno, divider);
}
}
}
//--------- on towns ----------//
else if( locPtr->is_town() )
{
Town* townPtr = town_array[ locPtr->town_recno() ];
if( god_id == GOD_JAPANESE && townPtr->nation_recno != nation_recno)
{
int divider = STD_TOWN_LOC_WIDTH * STD_TOWN_LOC_HEIGHT;
for( int i=0 ; i<MAX_RACE ; i++ )
{
if( townPtr->race_pop_array[i]==0 )
continue;
float changePoints = (float)7 + misc.random(8); // decrease 7 to 15 loyalty points instantly
if( townPtr->nation_recno )
townPtr->change_loyalty(i+1, -changePoints/divider);
else
townPtr->change_resistance(i+1, nation_recno, -changePoints/divider);
}
}
else if( god_id == GOD_EGYPTIAN && townPtr->nation_recno == nation_recno)
{
int headCount;
int raceId;
for( headCount = 5; headCount > 0 && townPtr->population < MAX_TOWN_GROWTH_POPULATION
&& (raceId = townPtr->pick_random_race(1,1)); --headCount )
{
townPtr->inc_pop(raceId, 0, (int)townPtr->race_loyalty_array[raceId-1]);
}
}
}
}