Example #1
0
//---------- Begin of function FirmCamp::update_loyalty --------//
//
void FirmCamp::update_loyalty()
{
	//----- update loyalty of the soldiers -----//

	Soldier* soldierPtr = soldier_array;

	for( int i=0 ; i<soldier_count ; i++, soldierPtr++ )
	{
		int targetLoyalty = soldierPtr->target_loyalty(firm_recno);

		if( targetLoyalty > soldierPtr->loyalty )
		{
			int incValue = (targetLoyalty - soldierPtr->loyalty)/10;

			int newLoyalty = (int) soldierPtr->loyalty + max(1, incValue);

			if( newLoyalty > targetLoyalty )
				newLoyalty = targetLoyalty;

			soldierPtr->loyalty = newLoyalty;
		}
		else if( targetLoyalty < soldierPtr->loyalty )
		{
			soldierPtr->loyalty--;
		}
	}
}
Example #2
0
//--------- Begin of function FirmCamp::disp_soldier_info ---------//
//
void FirmCamp::disp_soldier_info(int dispY1, int refreshFlag)
{
	disp_soldier_info_y1 = dispY1;

	if( selected_soldier_id==0 )		// display overseer info
	{
		disp_overseer_info(dispY1, refreshFlag);
		return;
	}

	if( selected_soldier_id > 0 && selected_soldier_id <= soldier_count )
	{
		int x=INFO_X1+20, y=dispY1;
		int x2;

		Soldier* soldierPtr = soldier_array + selected_soldier_id - 1;

		//------ if the unit is a living being -----//

		String str;

		if( soldierPtr->race_id )
		{
			if( soldierPtr->is_human() )
			{
				if( soldierPtr->hero_id )
					str  = hero_res[soldierPtr->hero_id]->name;
				else
					str  = race_res[soldierPtr->race_id]->get_name(soldierPtr->name_id);	// unit name
				str += " (";
				str += race_res[soldierPtr->race_id]->name;		// unit type name 
			}
			else
			{
				str  = monster_res.get_name(soldierPtr->name_id);		//monster name
				str += " (";
				str += monster_res[soldierPtr->monster_id()]->name;		// monster type name 
			}

			str += ")";
		}
		else
		{
			str = unit_res[soldierPtr->unit_id]->name;

			//------- if the unit is not a living being -----//

			// ###### begin Gilbert 24/3 #######//
			// if( unit_res[soldierPtr->unit_id]->unit_class == UNIT_CLASS_WEAPON )
			if( unit_res[soldierPtr->unit_id]->class_info.has_weapon_version
				&& soldierPtr->get_weapon_version() > 1 )
			// ###### end Gilbert 24/3 #######//
			{
				str += " ";
				str += m.roman_number( soldierPtr->get_weapon_version() );
			}
		}

		font_snds.put( x, y, str, 0, -1, 1 );

		//------------------------------------------------//

		// line spacing 24

		// ##### begin Gilbert 24/3 ##########//

		// ------- display loyalty ---------//

		UnitInfo *unitInfo = unit_res[soldierPtr->unit_id];

		if( unitInfo->class_info.has_loyalty && nation_recno )
		{
			if (soldierPtr->loyalty != soldierPtr->target_loyalty(firm_recno))
				info.disp_loyalty( x, y+12, INFO_X2-99 - font_snds.text_width(m.format(soldierPtr->loyalty, 4)) -
						font_snds.text_width(m.format(soldierPtr->target_loyalty(firm_recno), 4)) -
						font_snds.text_width("11"),
						soldierPtr->loyalty, soldierPtr->target_loyalty(firm_recno), nation_recno, refreshFlag, disp_combat_or_skill==4 );
			else
				info.disp_loyalty( x, y+12, INFO_X2-99 - font_snds.text_width(m.format(soldierPtr->loyalty, 4)),
						soldierPtr->loyalty, soldierPtr->target_loyalty(firm_recno), nation_recno, refreshFlag, disp_combat_or_skill==4 );
		}

		// ------- display combat ----------//

		if( unitInfo->class_info.has_combat_level )
		{
			x2 = (disp_combat_or_skill==1?font_blu2:font_snds).put( x+110, y+12, "Combat" ) + 10;
			font_snds.right_put( INFO_X2-10, y+12, m.format(soldierPtr->combat_level(),4) );
		}

		// ------- display leadership -------//

		if( unitInfo->class_info.has_skill_level )
		{
			x2 = (disp_combat_or_skill==2?font_blu2:font_snds).put( x+110, y+26, "Leadership" ) + 10;
			font_snds.right_put( INFO_X2-10, y+26, m.format(soldierPtr->skill_level(),4) );
		}

		// ##### end Gilbert 24/3 ##########//

		// ----- display hit point ---------//

		x2 = font_snds.put( x, y+26, "Hit Points" ) + 10;
		str = m.format(soldierPtr->hit_points, 4);
		str += "/";
		str += m.format(soldierPtr->max_hit_points(), 4);
		font_snds.right_put( INFO_X2-100, y+26, str );
	}
}