示例#1
0
文件: of_forti.cpp 项目: mecirt/7k2
//--------- Begin of function FirmCamp::detect_camp_info ---------//
//
void FirmFort::detect_camp_info()
{
	FirmCamp::detect_camp_info();

	int rc = button_train.detect(0, 0, 1);
	if( rc )
	{
		if( !town_array.is_deleted(active_link_town_recno) 
			&& town_array[active_link_town_recno]->recruitable_pop(1) > 0)
		{
			recruit_soldier( active_link_town_recno, 0, COMMAND_PLAYER );
		}
		else
		{
			short townRecnoArray[MAX_RACE];
			int raceCount = scan_best_recruitable_town(townRecnoArray);
			if( rc == 1 && raceCount == 1 )	// only one race, recruit from that town
			{
				err_when( !townRecnoArray[0] );
				recruit_soldier( townRecnoArray[0], 0, COMMAND_PLAYER );
			}
			else if( rc == 2 || rc == 1 && raceCount > 1 )
			{
				firm_menu_mode = FIRM_MENU_TRAIN;
			}
		}
	//	se_ctrl.immediate_sound("TURN_ON");
		se_ctrl.immediate_sound("ARM-ALRT");
	}

	switch( button_tower_count.detect(0, 0, 1) )
	{
		case 1:		// left click increase
		{
			set_target_archer( -1, COMMAND_PLAYER );
			se_ctrl.immediate_sound("ARM-ALRT");
			break;
		}
		case 2:		// right click decrease
		{
			set_target_archer( -2, COMMAND_PLAYER );
			se_ctrl.immediate_sound("TURN_OFF");
			break;
		}
	}

}
示例#2
0
//--------- Begin of function FirmMonster::next_day ---------//
//
void FirmMonster::next_day()
{
	//-------- validate patrol unit --------//

	validate_patrol_unit();

	//---- the monster boss recruit new monsters ----//

	if( info.game_date%10 == firm_recno%10 )
		recruit_soldier();

	//----- monsters recover hit points -------//

	if( info.game_date%15 == firm_recno%15 )			// once a week
		recover_hit_points();

	//------ monster thinks about expansion -------//

	if( config.monster_type == OPTION_MONSTER_OFFENSIVE )
	{
		if( info.game_date%30 == firm_recno%30 && m.random(3)==0 )
			recruit_general();
/*
		if( info.game_date%90 == firm_recno%90 )
			think_attack_neighbor();
*/
		//------ attack human towns and firms randomly -----//

		if( info.game_date > info.game_start_date + 1000 &&	// only start attacking 3 years after the game starts so the human can build up things
			 info.game_date%30 == firm_recno%30 &&
			 m.random( firm_res[FIRM_MONSTER]->total_firm_count*6 )==0 )		// it will expand slower when there are already a lot of the monster structures on the map
		{
			think_attack_human();
		}

		//--------- think expansion ---------//

		if( info.game_date%180 == firm_recno%180 &&
			 m.random( firm_res[FIRM_MONSTER]->total_firm_count*10 )==0 )		// it will expand slower when there are already a lot of the monster structures on the map
		{
			think_expansion();
		}
	}
}
示例#3
0
文件: of_forti.cpp 项目: mecirt/7k2
//--------- Begin of function FirmCamp::detect_train_menu ---------//
//
void FirmFort::detect_train_menu()
{
	short townRecnoArray[MAX_RACE];
	int raceCount = scan_best_recruitable_town( townRecnoArray );

	if( mouse.any_click(1) )		// any right click
	{
		firm_menu_mode = FIRM_MENU_MAIN;
		return;
	}

	// display in ascending order to make the overseer on top

	for( int i = 0; i < raceCount; ++i )
	{
		Town *townPtr = town_array[townRecnoArray[i]];
		int raceId = townPtr->race_id;

		// display soldier i

		int row = (raceId-1)/SOLDIER_PER_ROW;
		int x = INFO_X1 + 18 + ((raceId-1) % SOLDIER_PER_ROW) * SOLDIER_X_SPACING;
		int y = INFO_Y1 + 50 + row * SOLDIER_Y_SPACING;
		int yLoyalty = 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 = race_res[raceId]->infantry_unit_id;

		err_when( townPtr->nation_recno != nation_recno );

		if( info.draw_unit_icon( x+SOLDIER_X_SPACING/2, y,
			unitId, townPtr->nation_recno,
			windowX1, windowY1, windowX2, windowY2, 8 ) & 8 )
		{
			recruit_soldier( townRecnoArray[i], 0, COMMAND_PLAYER );
			break;
		}
	}
}