示例#1
0
文件: of_camp.cpp 项目: mecirt/7k2
//--------- Begin of function sort_soldier_function ---------//
//
static int sort_soldier_function( const void *va, const void *vb )
{
	Soldier *a = (Soldier *)va;
	Soldier *b = (Soldier *)vb;

	int rc = a->is_under_training() - b->is_under_training();

	if( rc == 0 )
		return int( b->skill_level() - a->skill_level() );
	else
		return rc;
}
示例#2
0
文件: of_camp.cpp 项目: mecirt/7k2
//--------- Begin of function sort_soldier_id_function ---------//
//
static int sort_soldier_id_function( const void *va, const void *vb )
{
	Soldier *a = &cur_firm_ptr->soldier_array[*((short*)va) - 1];
	Soldier *b = &cur_firm_ptr->soldier_array[*((short*)vb) - 1];

	int rc = a->is_under_training() - b->is_under_training();

	if( rc == 0 )
		return int( b->skill_level() - a->skill_level() );
	else
		return rc;
}
示例#3
0
文件: of_campi.cpp 项目: 112212/7k2
//--------- Begin of function FirmCamp::detect_soldier_info ---------//
//
void FirmCamp::detect_soldier_info()
{
	int dispY1 = disp_soldier_info_y1;

	if( selected_soldier_id==0 )		// display overseer info
	{
		detect_overseer_info();
		return;
	}

	if( selected_soldier_id > 0 && selected_soldier_id <= soldier_count )
	{
		int x=INFO_X1+20, y=dispY1;
		Soldier *soldierPtr = soldier_array + selected_soldier_id - 1;
		UnitInfo *unitInfo = unit_res[soldierPtr->unit_id];

		if( unitInfo->class_info.has_loyalty && nation_recno
			&& mouse.single_click( x, y+14, x+79 , y+27 ) )
		{
			// detect loyalty
			disp_combat_or_skill = 4;
		}
		else if( unitInfo->class_info.has_combat_level
			&& mouse.single_click( x+110, y+14, x+189, y+27 ) )
		{
			// detect combat level
			disp_combat_or_skill = 1;
		}
		else if( unitInfo->class_info.has_skill_level
			&& soldierPtr->skill_level() > 0
			&& mouse.single_click( x+110, y+28, x+189, y+41 ) )
		{
			// detect skill
			disp_combat_or_skill = 2;
		}
		else if( mouse.single_click( x-4, y-4, x+200, y+47 ) )
		{
			disp_combat_or_skill = 0;
		}
	}
}
示例#4
0
文件: of_camp.cpp 项目: mecirt/7k2
//------- 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 );
		}
	}
}
示例#5
0
文件: oun_ai.cpp 项目: 112212/7k2
int Unit::think_assign_soldier_to_camp()
{
	//---- think about assign the unit to a camp/fort that needs soldiers ----//

	Nation* ownNation = nation_array[nation_recno];
	FirmCamp *firmCamp, *bestFirm=NULL;
	int  regionId = world.get_region_id( next_x_loc(), next_y_loc() );
	int  skillLevel = skill_level();
	int  curRating, bestRating=0;
	int  curXLoc = next_x_loc(), curYLoc = next_y_loc();

	for( int i=0 ; i<ownNation->ai_camp_count ; i++ )
	{
		firmCamp = firm_array[ownNation->ai_camp_array[i]]->cast_to_FirmCamp();

		if( firmCamp->nation_recno != nation_recno )
			continue;

		if( firmCamp->region_id != regionId || firmCamp->under_construction )
			continue;

		if( !firmCamp->can_accept_assign(sprite_recno) )
			continue;

		curRating = 0;

		//----- if the camp is already full of soldier ------//

		if( firmCamp->is_soldier_full() )
		{
			//---- get the lowest skill soldier of the firm -----//

			Soldier* soldierPtr = firmCamp->soldier_array;
			int	   minSkill=100;

			for( int j=0 ; j<firmCamp->soldier_count ; j++, soldierPtr++ )
			{
				if( soldierPtr->is_under_training() )
					continue;

				if( soldierPtr->skill_level() < minSkill )
					minSkill = soldierPtr->skill_level();
			}

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

			if( firmCamp->majority_race() == race_id )
			{
				if( skill_level() < minSkill+10 )
					continue;
			}
			else //-- for different race, only assign if the skill is significantly higher than the existing ones --//
			{
				if( skill_level() < minSkill+30 )
					continue;
			}
		}
		else
		{
			curRating += 300;		// if the firm is not full, rating + 300
		}

		//-------- calculate the rating ---------//

		curRating += world.distance_rating( curXLoc, curYLoc, firmCamp->center_x, firmCamp->center_y );

		if( firmCamp->majority_race() == race_id )
			curRating += 70;

		curRating += (MAX_SOLDIER - firmCamp->soldier_count) * 10;

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

		if( curRating > bestRating )
		{
			bestRating = curRating;
			bestFirm   = firmCamp;
		}
	}

	if( bestFirm )
	{
		assign(bestFirm->loc_x1, bestFirm->loc_y1);
		return 1;
	}
	else
		return 0;
}
示例#6
0
文件: of_campi.cpp 项目: 112212/7k2
//--------- 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;
	*/
}
示例#7
0
文件: of_campi.cpp 项目: 112212/7k2
//--------- 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;
			}
		}
	}
*/
}
示例#8
0
文件: of_campi.cpp 项目: 112212/7k2
//--------- Begin of function FirmCamp::disp_camp_info ---------//
//
void FirmCamp::disp_camp_info(int dispY1, int refreshFlag)
{
	if( is_own() )
	{
		int x1 = INFO_X1 +13;
		int y1 = INFO_Y1 +235;
		int x2 = INFO_X1 +13;
		int y2 = INFO_Y1 +281;
		if( refreshFlag==INFO_REPAINT )
		{
			// ##### begin Gilbert 31/12 #######//
			// button_patrol.create( INFO_X1+13, INFO_Y1+235, 'A', "PATROL" );
			// button_reward.create( INFO_X1+13+BUTTON_DISTANCE, INFO_Y1+235, 'A', "REWARDCB" );
			// button_defense.create( INFO_X1+13+2*BUTTON_DISTANCE, INFO_Y1+235, 'A', defense_flag ? "DEFENSE1" : "DEFENSE0" );

			if (!is_monster())
				button_patrol.create( INFO_X1+13+BUTTON_DISTANCE, INFO_Y1+281, 'A', "PATROL" );
			else
				button_patrol.create( INFO_X1+13+BUTTON_DISTANCE, INFO_Y1+281, 'A', "F_PATROL" );

			if (!is_monster())
				button_reward.create( INFO_X1+13, INFO_Y1+235, 'A', "REWARD" );				
			else
				button_reward.create( INFO_X1+13, INFO_Y1+235, 'A', "F_REWARD" );				
							
			if (!is_monster())
				button_defense.create( INFO_X1+13+2*BUTTON_DISTANCE, INFO_Y1+281, 'A', defense_flag ? "DEFENSE1" : "DEFENSE0" );
			else
				button_defense.create( INFO_X1+13+2*BUTTON_DISTANCE, INFO_Y1+281, 'A', defense_flag ? "F_DEFEN1" : "F_DEFEN0" );
				
			if (!is_monster())
				button_promote.create( INFO_X1+13+2*BUTTON_DISTANCE , INFO_Y1+235, 'A', "PROMOTE" );
			else
				button_promote.create( INFO_X1+13+2*BUTTON_DISTANCE , INFO_Y1+235, 'A', "F_PROMOT" );
			// ##### end Gilbert 31/12 #######//
		}
		if( overseer_recno )
		{
			button_patrol.enable_flag = 1;
		}
		else
		{
			for( int i = 0; i < soldier_count && soldier_array[i].is_under_training(); ++i );
			button_patrol.enable_flag = i < soldier_count;
		}
		
		String str;
		switch(patrol_state)
		{
			case PATROL_ALL:
			//	str = "Sortie All";
				str = "";
				break;
			case PATROL_NO_GENERAL:
				str = "Sortie No Leader";
				break;
			case PATROL_NO_INJURED_SOILDER:
				str = "Sortie No Injured";
				break;
			default:
				break;
		}

		button_patrol.paint();
	//	vga.active_buf->bar_alpha( button_patrol.x1, button_patrol.y1+15, button_patrol.x1+BUTTON_ACTION_WIDTH-1, button_patrol.y1+BUTTON_ACTION_HEIGHT-16, 1, 0 );
		font_whbl.center_put_paragraph( button_patrol.x1, button_patrol.y1, button_patrol.x1+BUTTON_ACTION_WIDTH-1, button_patrol.y1+BUTTON_ACTION_HEIGHT-1, str );

		// ###### begin Gilbert 15/4 ########//
		if( nation_array[nation_recno]->cash >= REWARD_COST &&
			 ( (overseer_recno && unit_array[overseer_recno]->rank_id != RANK_KING && unit_res[unit_array[overseer_recno]->unit_id]->class_info.has_loyalty)
			  || (selected_soldier_id && selected_soldier_id <= soldier_count && unit_res[soldier_array[selected_soldier_id-1].unit_id]->class_info.has_loyalty)) )
			button_reward.enable_flag = 1;			// call paint
		// ###### end Gilbert 15/4 ########//
		else
			button_reward.enable_flag = 0;		// call paint
		button_reward.paint();

		if (!is_monster())
			button_defense.update_bitmap( defense_flag ? "DEFENSE1" : "DEFENSE0" );		// call paint
		else
			button_defense.update_bitmap( defense_flag ? "F_DEFEN1" : "F_DEFEN0" );

		if( (button_promote.visible_flag = !overseer_recno) )
		{
			button_promote.enable_flag = 0;
			if( selected_soldier_id > 0 && selected_soldier_id <= soldier_count )
			{
				Soldier *soldierPtr = soldier_array + selected_soldier_id - 1;
				// ##### begin Gilbert 24/3 ######//
				err_when( soldierPtr->unit_id == UNIT_WAGON );

				if( soldierPtr->race_id != 0
					&& soldierPtr->rank_id == RANK_SOLDIER 
					&& !soldierPtr->is_under_training()
					&& soldierPtr->skill_level() > 0 )
				// ##### end Gilbert 24/3 ######//
				{
					button_promote.enable_flag = 1;
				}
			}

			button_promote.paint();
		}
	}
	disp_spy_button( INFO_X1+13+BUTTON_DISTANCE, INFO_Y1+281, refreshFlag);
}
示例#9
0
文件: of_campi.cpp 项目: 112212/7k2
//--------- 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 );
	}
}