Esempio n. 1
0
//------- Begin of function FirmCamp::basic_train -------//
//
// Training a villager into a soldier.
//
void FirmCamp::basic_train()
{
	if( game.game_mode == GAME_TUTORIAL && 
		nation_recno != nation_array.player_recno)
		return;
	
	for( int i = 1; i <= soldier_count; ++i )
	{
		Soldier *soldierPtr = soldier_array + i - 1;

		// ###### begin Gilbert 19/11 #######//
		if( soldierPtr->is_under_training() )
		{
			int basicCombatLevel = BASIC_COMBAT_TRAIN;
			// ###### patch begin Gilbert 16/2 ######//
			// if( nation_recno && soldierPtr->race_id == RACE_ROMAN 
			//	&& god_res[GOD_ROMAN]->nation_prayer_count(nation_recno) > 0 )
			if( nation_recno && god_res[GOD_ROMAN]->nation_prayer_count(nation_recno) > 0 )
			{
				basicCombatLevel += BASIC_COMBAT_TRAIN / 2;		// roman can train to combat level 30
			}
			// ###### patch end Gilbert 16/2 ######//

			int totalBuildDays = unit_res[soldierPtr->unit_id]->build_days;
			soldierPtr->skill.inc_combat_level( ((float) basicCombatLevel + 0.125f)/ totalBuildDays );
			soldierPtr->skill.inc_skill_level( ((float) BASIC_SKILL_TRAIN + 0.125f) / totalBuildDays );
			// add a little more to avoid truncation error

			soldierPtr->hit_points = soldierPtr->max_hit_points();

			if( soldierPtr->hit_points > soldierPtr->max_hit_points() )
				soldierPtr->hit_points = soldierPtr->max_hit_points();

			--soldierPtr->remain_build_days;
			err_when( soldierPtr->remain_build_days < 0 );

		// ###### end Gilbert 19/11 #######//

			break;		// only train one unit at a time.
		}
	}
}
Esempio n. 2
0
//------- Begin of function FirmCamp::recover_hit_point -------//
//
// Soldiers recover their hit points.
//
// No need to recover the hit points of the general here as
// this is taken care in the Unit class function of the general.
//
void FirmCamp::recover_hit_point()
{
	Soldier* soldierPtr = soldier_array;

	for( int i=0 ; i<soldier_count ; i++, soldierPtr++ )
	{
		int hpInc = 1;
		short maxHp = soldierPtr->max_hit_points();

		//------- item effect -------- //

		hpInc += ( 1 + soldierPtr->item.ability(ITEM_ABILITY_RECOVERY) ) / 2;

		// ####### begin Gilbert 24/6 ########//
		// high max_hit_points recover faster
		// integer algorithm to increase maxHp / 200

		// /8 because recover_hit_point is called every 8 days
		// %200 for to recover maxHp/200 
		int cycle = (info.game_date / 8 ) % 200;
		cycle += 200;		// because cycle is going to be subtracted, avoid negative
		hpInc += (cycle * maxHp / 200) - ((cycle - 1) * maxHp / 200);

		// ####### end Gilbert 24/6 ########//

		//------- increase soldier hit points --------//

		if( soldierPtr->hit_points < maxHp )
		{
			soldierPtr->hit_points += hpInc;

			if( soldierPtr->hit_points > maxHp )
				soldierPtr->hit_points = maxHp;
		}
	}
}
Esempio n. 3
0
//------- Begin of function FirmCamp::advanced_train -------//
//
// Increase the leadership and ocmbat level of the general and the soldiers.
//
void FirmCamp::advanced_train()
{
	if( game.game_mode == GAME_TUTORIAL && 
		nation_recno != nation_array.player_recno)
		return;
	
	if( !overseer_recno )
		return;

	Unit* overseerUnit = unit_array[overseer_recno];

	int overseerSkill = (int) overseerUnit->skill_level();
								// + overseerUnit->item.ability( ITEM_ABILITY_SKILL_LEVEL );
								// skill_level() already contain enhancement
	int incValue;

	//------- increase the commander's leadership ---------//

	if( soldier_count > 0
		 && (int) overseerUnit->skill_level() < MAX_SKILL_TRAIN ) // do not use overseerSkill
	{
		//-- the more soldiers this commander has, the higher the leadership will increase ---//

		incValue = 5 * soldier_count
					  * (int) overseerUnit->hit_points / overseerUnit->max_hit_points()
					  * (100+overseerUnit->skill.skill_potential*2) / 100;

		// AI_CHEAT

		if( is_ai && config.ai_aggressiveness > OPTION_MODERATE )
			incValue += incValue * (config.ai_aggressiveness-OPTION_MODERATE) / 3;		// 33% faster if aggressivness is high, 66% faster if aggressiveness is very high

		overseerUnit->skill.inc_skill_level( (float)incValue/100 );
	}

	//------- increase the commander's combat level ---------//

	if( overseerUnit->combat_level() < MAX_COMBAT_TRAIN )
	{
		incValue = 10 * (int) overseerUnit->hit_points / overseerUnit->max_hit_points()
					  * (100+overseerUnit->skill.skill_potential*2) / 100;

		// ------ effect of god ----------//

		// ##### patch begin Gilbert 16/2 ######//
//		if( overseerUnit->race_id == RACE_CELTIC && nation_recno 
//			&& god_res[GOD_CELTIC]->nation_prayer_count(nation_recno) > 0 )
		if( nation_recno && god_res[GOD_CELTIC]->nation_prayer_count(nation_recno) > 0 )
		{
			if( overseerUnit->race_id == RACE_CELTIC )
				incValue += incValue / 2;		// 50% skill increase in fort
			else
				incValue += incValue / 5;		// 20% skill increase in fort
		}
		// ##### patch end Gilbert 16/2 ######//

		if( is_ai && config.ai_aggressiveness > OPTION_MODERATE )
			incValue += incValue * (config.ai_aggressiveness-OPTION_MODERATE) / 5;		// 20% faster if aggressivness is high, 40% faster if aggressiveness is very high

		overseerUnit->skill.inc_combat_level( (float)incValue/100 );
	}

	//------- increase the solider's combat level -------//

	for( int i=0 ; i<soldier_count ; i++ )
	{
		Soldier* soldierPtr = soldier_array + i;

		#ifdef DEBUG

		err_when( !soldierPtr->name_id );

		err_when( soldierPtr->is_monster() &&
					 monster_res.name_used_array[soldierPtr->name_id-1] < 1 );

		#endif

		if( soldierPtr->is_under_training() )		// skip unit under initial training
			continue;

		//------- increase soldier skill -----------//

		if( soldierPtr->combat_level() < overseerSkill
			&& soldierPtr->combat_level() < MAX_COMBAT_TRAIN )
		{
			incValue = max(20, overseerSkill - (int)soldierPtr->combat_level())
						  * soldierPtr->hit_points / soldierPtr->max_hit_points()
						  * (100+soldierPtr->skill.skill_potential*2+overseerUnit->item.ability(ITEM_ABILITY_TRAIN)) / 100;

			// ------ effect of god ----------//

			// ###### patch begin Gilbert 16/2 ######//
			//if( soldierPtr->race_id == RACE_CELTIC && nation_recno 
			//	&& god_res[GOD_CELTIC]->nation_prayer_count(nation_recno) > 0 )
			if( nation_recno 
				&& god_res[GOD_CELTIC]->nation_prayer_count(nation_recno) > 0 )
			{
				if( soldierPtr->race_id == RACE_CELTIC )
					incValue += incValue / 2;		// 50% skill increase in fort
				else
					incValue += incValue / 5;		// 20% skill increase in fort
			}
			// ###### patch end Gilbert 16/2 ######//

			// ###### patch begin Gilbert 23/12 #########//
			// penalty of egyptain
			if( soldierPtr->race_id == RACE_EGYPTIAN && nation_recno
				&& god_res[GOD_EGYPTIAN]->nation_prayer_count(nation_recno) > 0 )
			{
				incValue = incValue * (MAX_WORKER*2) / (MAX_WORKER*2+god_res[GOD_EGYPTIAN]->nation_prayer_count(nation_recno));
			}
			// ###### patch end Gilbert 23/12 #########//

			if( is_ai && config.ai_aggressiveness > OPTION_MODERATE )
				incValue += incValue * (config.ai_aggressiveness-OPTION_MODERATE) / 5;		// 20% faster if aggressivness is high, 40% faster if aggressiveness is very high

			soldierPtr->skill.inc_combat_level( (float)incValue/100 );
		}

		//-- if the soldier has leadership potential, he learns leadership --//

		if( soldierPtr->skill.skill_potential > 0
			 && soldierPtr->skill_level() < MAX_SKILL_TRAIN )
		{
			incValue = (int) max(50, overseerSkill-soldierPtr->skill_level())
						  * soldierPtr->hit_points / soldierPtr->max_hit_points()
						  * soldierPtr->skill.skill_potential*2 / 100;

			if( is_ai && config.ai_aggressiveness > OPTION_MODERATE )
				incValue += incValue * (config.ai_aggressiveness-OPTION_MODERATE) / 5;		// 20% faster if aggressivness is high, 40% faster if aggressiveness is very high

			soldierPtr->skill.inc_skill_level( (float)incValue/100 );
		}
	}
}
Esempio n. 4
0
//--------- Begin of function FirmCamp::detect_soldier_list ---------//
//
// <int> selecteSpyMenu        0=main menu; 1=selecting spy
// when selectSpyMenu is 0, return 1 if left click on a unit, return 2 if right click on a unit
// when selectSpyMenu is 1, return spy_recno of the clicked spy, 0 if no own spy is clicked
//
int FirmCamp::detect_soldier_list(int selectSpyMenu)
{
	int dispY1 = disp_soldier_list_y1;

	// display in ascending order to select the overseer first

	for( int i = 0; i <= soldier_count; ++i )
	{
		// display soldier i

		int row = i/SOLDIER_PER_ROW;
		int x = INFO_X1 + 18 + (i % SOLDIER_PER_ROW) * SOLDIER_X_SPACING;
		int y = INFO_Y1 + 50 + row * SOLDIER_Y_SPACING;
		int yHp = INFO_Y1 + 7 + row * SOLDIER_Y_SPACING;

		int windowX1 = INFO_X1 + 16;
		int windowX2 = INFO_X1 + 220;
		int windowY1 = INFO_Y1 + 5 + row * 84;	// 5,89
		int windowY2 = windowY1 + 80 - 1 ;

		int unitId;
		int hp;
		int maxHp;
		// ##### begin Gilbert 21/9 ######//
		int combatLevel;
		int skillLevel;
		int loyalty;
		// ##### end Gilbert 21/9 ######//
		int ownSpy;

		if( i==0 )
		{
			if( !overseer_recno )
				continue;

			// overseer
			Unit *overseer = unit_array[overseer_recno];
			unitId = overseer->unit_id;

			hp = (int) overseer->hit_points;
			maxHp = overseer->max_hit_points();
			combatLevel = (int) overseer->combat_level();
			skillLevel = (int) overseer->skill_level();

			if( overseer->rank_id != RANK_GENERAL )
				loyalty = overseer->loyalty;
			else
				loyalty = -1;		// king or other(?)

			ownSpy = overseer->is_own_spy() ? overseer->spy_recno : 0;
		}
		else
		{
			// soldier
			Soldier *soldierPtr = &soldier_array[i-1];
			unitId = soldierPtr->unit_id;

			hp = soldierPtr->hit_points;
			maxHp = soldierPtr->max_hit_points();
			combatLevel = (int) soldierPtr->combat_level();
			skillLevel = (int) soldierPtr->skill_level();

			if( soldierPtr->race_id )
				loyalty = soldierPtr->loyalty;
			else
				loyalty = -1;
			ownSpy = soldierPtr->is_own_spy() ? soldierPtr->spy_recno : 0;
		}

		if( selectSpyMenu && !ownSpy )
			continue;

		int rc = info.draw_unit_icon( x+SOLDIER_X_SPACING/2, y,
			unitId, nation_recno, 
			windowX1, windowY1, windowX2, windowY2, 24 );		// detect left button (8) and right button(16)

		if( !rc )
			continue;

		if( selectSpyMenu == 0 )
		{
			// -------- main menu ---------//

			if( rc & 8 )
			{
				// ----- left click select soldier/overseer -------//

				selected_soldier_id = i;
				return 1;
			}
			else if( rc & 16 && is_own() )
			{
				// ------ right click mobilize solidier/overseer ------//

				if( i == 0 )
				{
					if(remote.is_enable())
					{
						// packet structure : <firm recno>
						short *shortPtr=(short *)remote.new_send_queue_msg(MSG_FIRM_MOBL_OVERSEER, sizeof(short));
						shortPtr[0] = firm_recno;
					}
					else
					{
						assign_overseer(0);		// the overseer quits the camp
					}
				}
				else
				{
					// #### begin Gilbert 26/1 #####//
					if( !soldier_array[i-1].is_under_training() )
						mobilize_soldier(i, COMMAND_PLAYER);
					else
						cancel_train_soldier(i, COMMAND_PLAYER);
					// #### end Gilbert 26/1 #####//
				}
				return 2;
			}
		}
		else if( selectSpyMenu == 1 )
		{
			if( rc & 8 && ownSpy )
			{
				selected_soldier_id = i;
				return ownSpy;
			}
		}
	}

	return 0;

	/*
	if( !should_show_info() )
		return 0;

	if( is_own() )
	{
		//------ detect the overseer button -----//
		int rc = mouse.single_click(INFO_X1+6, INFO_Y1+58,
					INFO_X1+5+UNIT_LARGE_ICON_WIDTH, INFO_Y1+57+UNIT_LARGE_ICON_HEIGHT, 2 );

		if( rc==1 )
		{
			selected_soldier_id = 0;
			return 1;
		}
		else if( rc==2 && is_own() )
		{
			if(remote.is_enable())
			{
				// packet structure : <firm recno>
				short *shortPtr=(short *)remote.new_send_queue_msg(MSG_FIRM_MOBL_OVERSEER, sizeof(short));
				shortPtr[0] = firm_recno;
			}
			else
			{
				assign_overseer(0);		// the overseer quits the camp
			}
			return 1;
		}
	}

	//------- detect buttons on hiring firm soldiers -------//

	int i, x, y;

	for( i=0 ; i<soldier_count ; i++ )
	{
		x = INFO_X1+6+i%4*50;
		y = pop_disp_y1+1+i/4*29;

		switch( mouse.single_click(x, y, x+27, y+23, 2) )
		{
		case 1:         // left button to select soldier
			selected_soldier_id = i+1;
			return 1;

		case 2:
			if( is_own() )		// only if this is our own firm
			{
				//--- if the town where the unit lives belongs to the nation of this firm ---//

				mobilize_soldier(i+1, COMMAND_PLAYER);
				return 1;
			}
			break;
		}
	}

	return 0;
	*/
}
Esempio n. 5
0
//--------- Begin of function FirmCamp::disp_soldier_list ---------//
//
void FirmCamp::disp_soldier_list(int dispY1, int refreshFlag, int dispSpyMenu)
{
	disp_soldier_list_y1 = dispY1;

	for( int inc = -1; inc <= 1; inc += 2 )
	{
		err_when( inc == 0 );

		// first round is descending draw to icon
		// second round is ascending to draw the frame

		int inAreaFlag = 4;

		for( int i = inc>=0?0:soldier_count; i >= 0 && i <= soldier_count; i +=inc )
		{
			// display soldier i

			int row = i/SOLDIER_PER_ROW;
			int x = INFO_X1 + 18 + (i % SOLDIER_PER_ROW) * SOLDIER_X_SPACING;
			int y = INFO_Y1 + 50 + row * SOLDIER_Y_SPACING;
			int yHp = INFO_Y1 + 7 + row * SOLDIER_Y_SPACING;

			int windowX1 = INFO_X1 + 16;
			int windowX2 = INFO_X1 + 220;
			int windowY1 = INFO_Y1 + 5 + row * 84;	// 5,89
			int windowY2 = windowY1 + 80 - 1 ;

			int unitId;
			int hp;
			int maxHp;
			// ##### begin Gilbert 21/9 ######//
			int combatLevel;
			int skillLevel;
			int loyalty;
			// ##### end Gilbert 21/9 ######//
			int ownSpy;
			int itemId;

			if( i==0 )
			{
				if( !overseer_recno )
					continue;

				// overseer
				Unit *overseer = unit_array[overseer_recno];
				unitId = overseer->unit_id;

				hp = (int) overseer->hit_points;
				maxHp = overseer->max_hit_points();
				combatLevel = (int) overseer->combat_level();
				skillLevel = (int) overseer->skill_level();

				if( overseer->rank_id != RANK_GENERAL )
					loyalty = -1;		// king or other(?)
				else
					loyalty = overseer->loyalty;

				ownSpy = overseer->is_own_spy() ? overseer->spy_recno : 0;
				itemId = overseer->item.id;
			}
			else
			{
				// soldier
				Soldier *soldierPtr = &soldier_array[i-1];
				unitId = soldierPtr->unit_id;

				hp = soldierPtr->hit_points;
				maxHp = soldierPtr->max_hit_points();
				combatLevel = (int) soldierPtr->combat_level();
				skillLevel = (int) soldierPtr->skill_level();

				// ####### begin Gilbert 24/3 #########//
				if( unit_res[soldierPtr->unit_id]->class_info.has_loyalty && nation_recno )
				// ####### end Gilbert 24/3 #########//
					loyalty = soldierPtr->loyalty;
				else
					loyalty = -1;
				ownSpy = soldierPtr->is_own_spy() ? soldierPtr->spy_recno : 0;
				itemId = soldierPtr->item.id;
			}

			if( dispSpyMenu && !ownSpy )			// skip displaying spy
				continue;

			UnitInfo *unitInfo = unit_res[unitId];

			// display that solider icon at x+SOLDIER_X_SPACING/2, y
			// draw a frame if selected

			if( inc < 0 )
			{
				// first round is descending draw to icon
				Soldier *soldierPtr = &soldier_array[i-1];
				info.draw_unit_icon( x+SOLDIER_X_SPACING/2, y,
					unitId, nation_recno,
					windowX1, windowY1, windowX2, windowY2,
					(i>0 && soldierPtr->combat_level() < 20) ? (((20 - soldierPtr->combat_level()) <<6)+ 33) : 1);
			}
			else
			{
				// second round is ascending to draw the frame

				if( info.draw_unit_icon( x+SOLDIER_X_SPACING/2, y,
					unitId, nation_recno,
					windowX1, windowY1, windowX2, windowY2, 
					inAreaFlag | (i==selected_soldier_id?3:0) ) & 4 )
				{
					inAreaFlag = 0;		// frame for mouse cursor is drawn, disable the frame
				}

				// display combat skill

				// ######## begin Gilbert 21/9 #######//
				Font *font = &font_whbl;

				if( !dispSpyMenu )
				{
					if( disp_combat_or_skill )		// display skill level
					{
						font = &font_blue;
						int attribute = -1;
						switch( disp_combat_or_skill )
						{
						case 1: 
							if( unitInfo->class_info.has_combat_level )
								attribute = combatLevel;
							break;
						case 2:
							if( unitInfo->class_info.has_skill_level && skillLevel > 0 )
								attribute = skillLevel; 
							break;
						case 4:
							if( unitInfo->class_info.has_loyalty && nation_recno )
								attribute = loyalty;
							break;
						default:
							err_here();
						}
						if( attribute >= 0 )	// hide attribute on some cases
							font->center_put( x, yHp, x+SOLDIER_X_SPACING, 
								yHp+font->max_font_height, m.format(attribute) );
					}
					else if( ownSpy )		// display spy icon
					{
						vga.active_buf->put_bitmap_trans( x+SOLDIER_X_SPACING/2-8, yHp-5, image_icon.read("U_SPY") );
					}
					else if( unitInfo->class_info.has_combat_level ) 	// display combat skill
					{
						font->center_put( x, yHp, x+SOLDIER_X_SPACING, yHp+font->max_font_height, 
							m.format(combatLevel) );
					}

					if( itemId )
					{
						char *iconPtr = item_res.item_unit_interface(itemId);
						if( iconPtr )
							vga.active_buf->put_bitmap_trans( x+SOLDIER_X_SPACING/2-((Bitmap *)iconPtr)->get_width()/2,
							yHp +53, iconPtr );
					}
				}
				else
				{
					// display spy skill
					err_when( !ownSpy );
					font_whbl.center_put( x, yHp, x+SOLDIER_X_SPACING, yHp+font->max_font_height, 
						m.format(spy_array[ownSpy]->spy_skill) );
				}

				// display hit points bar

				if( i > 0 && soldier_array[i-1].is_under_training() )
					disp_training_bar( x, yHp+font->max_font_height+2, x+SOLDIER_X_SPACING*7/8-1,
						soldier_array[i-1].skill_level(), BASIC_COMBAT_TRAIN );
				else
					disp_soldier_hit_points( x, yHp+font->max_font_height+2, x+SOLDIER_X_SPACING*7/8-1, hp, maxHp );
			}
		}
	}

/*
	//---------------- paint the panel --------------//

	if( overseer_recno )
	{
		//------------ display overseer info -------------//

		Unit* overseerUnit = unit_array[overseer_recno];

		int x=INFO_X1+6, y=dispY1+4, x1=x+UNIT_LARGE_ICON_WIDTH+8;

		if( selected_soldier_id == 0 )
		{
			vga_front.rect( x-2, y-2, x+UNIT_LARGE_ICON_WIDTH+1, y+UNIT_LARGE_ICON_HEIGHT+1, 2, V_YELLOW );
		}
		else
		{
			vga.blt_buf( x-2, y-2, x+UNIT_LARGE_ICON_WIDTH+1, y-1, 0 );
			vga.blt_buf( x-2, y+UNIT_LARGE_ICON_HEIGHT+1, x+UNIT_LARGE_ICON_WIDTH+1, y+UNIT_LARGE_ICON_HEIGHT+2, 0 );
			vga.blt_buf( x-2, y-2, x-1, y+UNIT_LARGE_ICON_HEIGHT+2, 0 );
			vga.blt_buf( x+UNIT_LARGE_ICON_WIDTH, y-2, x+UNIT_LARGE_ICON_WIDTH+1, y+UNIT_LARGE_ICON_HEIGHT+2, 0 );
		}

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

		if( refreshFlag == INFO_REPAINT )
		{
			vga_front.put_bitmap(x, y, unit_res[overseerUnit->unit_id]->get_large_icon_ptr(overseerUnit->rank_id) );
		}

		//-------- set help parameters --------//

		if( mouse.in_area(x, y, x+UNIT_LARGE_ICON_WIDTH+3, y+UNIT_LARGE_ICON_HEIGHT+3) )
			help.set_unit_help( overseerUnit->unit_id, overseerUnit->rank_id, x, y, x+UNIT_LARGE_ICON_WIDTH+3, y+UNIT_LARGE_ICON_HEIGHT+3);

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

		if( overseerUnit->rank_id == RANK_KING )
		{
			if( refreshFlag == INFO_REPAINT )
				font_san.put( x1, y, "King" );

			y+=14;
		}

		if( refreshFlag == INFO_REPAINT )
			font_san.put( x1, y, overseerUnit->unit_name(0), 0, INFO_X2-2 );		// 0-ask unit_name() not to return the title of the unit

		y+=14;

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

		String str;

		str  = translate.process("Leadership");
		str += ": ";
		str += overseerUnit->skill.skill_level;

		font_san.disp( x1, y, str, INFO_X2-10 );
		y+=14;

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

		if( overseerUnit->rank_id != RANK_KING )
		{
			x1 = font_san.put( x1, y, "Loyalty:" );

			int x2 = info.disp_loyalty( x1, y-1, x1, overseerUnit->loyalty, overseerUnit->target_loyalty, nation_recno, refreshFlag );

			if( overseerUnit->spy_recno )
			{
				//------ if this is the player's spy -------//

				if( overseerUnit->is_own_spy() )
				{
					vga_front.put_bitmap( x2+5, y+1, image_icon.get_ptr("U_SPY") );
					x2 += 15;
				}
			}

			vga.blt_buf( x2, y-1, INFO_X2-2, dispY1+44, 0 );
		}
	}

	pop_disp_y1 = dispY1;

	//---------------- paint the panel --------------//

	if( refreshFlag == INFO_REPAINT )
		vga.d3_panel_up( INFO_X1, dispY1, INFO_X2, dispY1+60 );

	//----------- display populatin distribution ---------//

	int overseerRaceId=0;

	if( overseer_recno )
		overseerRaceId = unit_array[overseer_recno]->race_id;

	if( selected_soldier_id > soldier_count )
		selected_soldier_id = soldier_count;

	//------ display population composition -------//

	int	  x, y;
	Soldier* soldierPtr = soldier_array;
	static  char last_race_id_array[MAX_SOLDIER];
	static  char last_unit_id_array[MAX_SOLDIER];

	dispY1+=1;

	for( int i=0 ; i<MAX_SOLDIER ; i++, soldierPtr++ )
	{
		x = INFO_X1+4+i%4*50;
		y = dispY1+i/4*29;

		if( i<soldier_count )
		{
			if( refreshFlag==INFO_REPAINT ||
				 last_race_id_array[i] != soldierPtr->race_id ||
				 last_unit_id_array[i] != soldierPtr->unit_id )
			{
				vga_front.put_bitmap(x+2, y+2, soldierPtr->small_icon_ptr());
			}

			//----- highlight the selected soldier -------//

			if( selected_soldier_id == i+1 )
				vga_front.rect( x, y, x+27, y+23, 2, V_YELLOW );
			else
				vga_front.rect( x, y, x+27, y+23, 2, vga_front.color_up );

			//------ display hit points bar --------//

			disp_soldier_hit_points( x+2, y+24, x+25, soldierPtr->shown_hit_points(), soldierPtr->max_hit_points() );

			//----- display combat or skill level ------//

			char* spyIconName=NULL;

			if( soldierPtr->spy_recno )
			{
				Spy* spyPtr = spy_array[soldierPtr->spy_recno];

				//------ if this is the player's spy -------//

				if( nation_array.player_recno &&
					 spyPtr->true_nation_recno == nation_array.player_recno )
				{
					spyIconName = "U_SPY";
				}

				//--------------------------------------------//
				//
				// If this is an enemy spy and this firm belongs
				// to the player and there is a player's phoenix
				// over this firm and the spying skill of the spy
				// is low (below 40)
				//
				//--------------------------------------------//

//				else if( spyPtr->spy_skill < 40 &&
//							nation_recno == nation_array.player_recno &&
//							nation_array.player_recno &&
//					 (~nation_array)->revealed_by_phoenix(loc_x1, loc_y1) )
//				{
//					spyIconName = "ENEMYSPY";
//				}

			}

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

			if( spyIconName )
			{
				vga_front.put_bitmap( x+30, y+6, image_icon.get_ptr(spyIconName) );
				vga.blt_buf( x+40, y+6, x+49, y+15, 0 );
				vga.blt_buf( x+30, y+16, x+49, y+26, 0 );
			}
			else
			{
				font_san.disp(x+30, y+6, soldierPtr->skill.combat_level, 1, x+49);
			}

			last_race_id_array[i] = soldierPtr->race_id;
			last_unit_id_array[i] = soldierPtr->unit_id;

			//------- set help parameters ---------//

			if( mouse.in_area(x, y, x+27, y+23) )
				help.set_unit_help( soldierPtr->unit_id, 0, x, y, x+27, y+23 );
		}
		else
		{
			if( last_race_id_array[i] != 0 || last_unit_id_array[i] != 0 )
			{
				vga.blt_buf( x, y, x+49, y+27, 0 );
				last_race_id_array[i] = 0;
				last_unit_id_array[i] = 0;
			}
		}
	}
*/
}
Esempio n. 6
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 );
	}
}