Esempio n. 1
0
File: oc_east1.cpp Progetto: 7k2/7k2
int CampaignEastWest::stage_1_create_firm()
{
    //----- create firms around established towns -----//

    Nation* nationPtr = nation_array[PLAYER_NATION_RECNO];

    int townRecno1 = king_oversee_town_recno(PLAYER_NATION_RECNO);
    int townRecno2 = random_pick_town_with_camp(PLAYER_NATION_RECNO, 2);		// only pick towns with <= 2 links

    if( townRecno2 && misc.random(2)==0 )		// swap the town in 50% chance
    {
        int t=townRecno1;
        townRecno1 = townRecno2;
        townRecno2 = t;
    }

    //--- while the races of towns are random, the two main towns' race has to be the king's race ---//

    town_array[townRecno1]->set_race(nationPtr->race_id);

    if( townRecno2 )
        town_array[townRecno2]->set_race(nationPtr->race_id);

    if( !create_economic_firm(townRecno1) )
        return 0;

    if( townRecno2 && !create_military_firm(townRecno2) )
        return 0;

    return 1;
}
Esempio n. 2
0
int CampaignEastWest::stage_12_create_firm()
{
	//----- create firms around established towns -----//

	Nation* nationPtr = nation_array[PLAYER_NATION_RECNO];

	int townRecno1 = king_oversee_town_recno(PLAYER_NATION_RECNO);
	int townRecno2 = random_pick_town_with_camp(PLAYER_NATION_RECNO, 2);		// only pick towns with <= 2 links

	if( townRecno2 && m.random(2)==0 )		// swap the town in 50% chance
	{
		int t=townRecno1;
		townRecno1 = townRecno2;
		townRecno2 = t;
	}

	if( !create_economic_firm(townRecno1) )
		return 0;

	if( townRecno2 && !create_military_firm(townRecno2) )
		return 0;

	//------ create additional military/economic firms ------//

	int addCount = 1+m.random(2);		// 1 to 2

	for( int i=0 ; i<addCount ; i++ )
	{
		int townRecno = random_pick_town_with_camp(PLAYER_NATION_RECNO, 2);		// only pick towns with <= 2 links
		int rc;

		if( !townRecno )
      	break;

		if( has_situation )
		{
			rc = m.random( cur_situation.economy_level+cur_situation.military_level )
				  < cur_situation.economy_level;
		}
		else
		{
			rc = m.random(2)==0;
		}

		if( rc )
			rc = create_economic_firm(townRecno);
		else
			rc = create_military_firm(townRecno, 30+m.random(30));		// power rating: 30 to 60

		if( !rc )
			break;
	}

	return 1;
}
Esempio n. 3
0
int CampaignEastWest::stage_4_create_firm()
{
	//----- create firms around established towns -----//

	Nation* nationPtr = nation_array[STAGE_4_EASTERN_NATION_RECNO];

	int townRecno1 = king_oversee_town_recno(STAGE_4_EASTERN_NATION_RECNO);
	int townRecno2 = random_pick_town_with_camp(STAGE_4_EASTERN_NATION_RECNO, 2);		// only pick towns with <= 2 links

	if( townRecno2 && misc.random(2)==0 )		// swap the town in 50% chance
	{
		int t=townRecno1;
		townRecno1 = townRecno2;
		townRecno2 = t;
	}

	//--- while the races of towns are random, the two main towns' race has to be the king's race ---//

	town_array[townRecno1]->set_race(nationPtr->race_id);

	if( townRecno2 )
		town_array[townRecno2]->set_race(nationPtr->race_id);

	//--- set other towns to your race, as they were yours originally ---//

	int playerRaceId = nation_array[PLAYER_NATION_RECNO]->race_id;

	for( int i=town_array.size() ; i>0 ; i-- )
	{
		if( town_array.is_deleted(i) )
			continue;

		town_array[i]->set_race(playerRaceId);
	}

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

	if( !create_economic_firm(townRecno1) )
		return 0;

	if( townRecno2 && !create_military_firm(townRecno2) )
		return 0;

	return 1;
}
Esempio n. 4
0
void CampaignEastWest::plot_a3_create_game()
{
	// one viking nation and one mongol nation

	plot_nation_recno1 = nation_array.new_nation( NATION_HUMAN, NATION_AI, RACE_VIKING, nation_array.random_unused_color() );
	god_res[GOD_VIKING]->enable_know(plot_nation_recno1);

	plot_nation_recno2 = nation_array.new_nation( NATION_HUMAN, NATION_AI, RACE_MONGOL, nation_array.random_unused_color() );

	// create viking race

	{
		Nation* vikingNation = nation_array[plot_nation_recno1];

		//---- create towns for the rebel nation ----//

		int townAddCount   = 3;
		int hasFortPercent = 100;

		create_town( plot_nation_recno1, townAddCount, hasFortPercent );

		int townRecno = random_pick_town_with_camp(plot_nation_recno1, 2);		// only pick towns with <= 2 links

		// change town population to 100

		if( townRecno )
		{
			town_array[townRecno]->init_pop( MAX_TOWN_POPULATION, 100 );

			create_economic_firm(townRecno);
      }

		// -------- build 4 viking seat of power -------//

		int trial = 100;
		int seatCount = 4;

		for( ; trial > 0 && seatCount > 0; --trial )
		{
			if( (townRecno = random_pick_town_with_camp(plot_nation_recno1, 8)) )		// only pick town with <= 8 links
			{
				int firmRecno;
				if( (firmRecno = create_firm_next_to_place( town_array[townRecno], FIRM_BASE, vikingNation->race_id)) )
				{
					FirmBase *firmPtr = firm_array[firmRecno]->cast_to_FirmBase();

					if( firmPtr )
					{
						firmPtr->set_needed_worker_count( MAX_WORKER, COMMAND_AUTO );
					}
					--seatCount;
				}
			}
		}

		//--- hard-wire the viking 's relation with the Fryhtan ---//

		static short neverConsiderArray1[] =
		{
			TALK_PROPOSE_TRADE_TREATY,
			TALK_PROPOSE_FRIENDLY_TREATY,
			TALK_PROPOSE_ALLIANCE_TREATY,
			0
		};

		vikingNation->get_relation(plot_enemy_nation_recno)->set_ai_never_consider(neverConsiderArray1);

		//--- hard-wire the viking's relation with the player ---//

		static short neverConsiderArray2[] =
		{
			TALK_PROPOSE_ALLIANCE_TREATY,
			TALK_DECLARE_WAR,
			TALK_SURRENDER,
			0
		};

		vikingNation->get_relation(nation_array.player_recno)->set_ai_never_consider(neverConsiderArray2);

		//--- hard-wire the viking's relation with the mongol nation ---//

		static short neverConsiderArray3[] =
		{
			TALK_PROPOSE_TRADE_TREATY,
			TALK_PROPOSE_FRIENDLY_TREATY,
			TALK_PROPOSE_ALLIANCE_TREATY,
			TALK_SURRENDER,
			0
		};

		vikingNation->get_relation(plot_nation_recno2)->set_ai_never_consider(neverConsiderArray3);
	}

	// create mongol race

	{
		Nation* mongolNation = nation_array[plot_nation_recno2];

		//---- create towns for the rebel nation ----//

		int townAddCount   = 2 + m.random(2);		// 2 to 3 towns
		int hasFortPercent = 100;

		create_town( plot_nation_recno2, townAddCount, hasFortPercent );

		int townRecno1 = king_oversee_town_recno(plot_nation_recno2);
		int townRecno2 = random_pick_town_with_camp(plot_nation_recno2, 2);		// only pick towns with <= 2 links

		if( !create_military_firm(townRecno1) )
			return;

		if( townRecno2 && !create_economic_firm(townRecno2) )
			return;

		//--- hard-wire the mongol 's relation with the Fryhtan ---//

		static short neverConsiderArray1[] =
		{
			TALK_PROPOSE_TRADE_TREATY,
			TALK_PROPOSE_FRIENDLY_TREATY,
			TALK_PROPOSE_ALLIANCE_TREATY,
			0
		};

		mongolNation->get_relation(plot_enemy_nation_recno)->set_ai_never_consider(neverConsiderArray1);

		//--- hard-wire the rebel's relation with the player ---//

		static short neverConsiderArray2[] =
		{
			TALK_PROPOSE_ALLIANCE_TREATY,
			TALK_DECLARE_WAR,
			TALK_SURRENDER,
			0
		};

		mongolNation->get_relation(nation_array.player_recno)->set_ai_never_consider(neverConsiderArray2);

		//--- hard-wire the mongol 's relation with the viking nation ---//

		static short neverConsiderArray3[] =
		{
			TALK_PROPOSE_TRADE_TREATY,
			TALK_PROPOSE_FRIENDLY_TREATY,
			TALK_PROPOSE_ALLIANCE_TREATY,
			TALK_SURRENDER,
			0
		};

		mongolNation->get_relation(plot_nation_recno1)->set_ai_never_consider(neverConsiderArray3);
	}

	// disable know of the nation
	// such that no scroll left after either king is killed
	god_res[GOD_VIKING]->disable_know(plot_nation_recno1);

}
Esempio n. 5
0
File: oc_eas23.cpp Progetto: 7k2/7k2
int CampaignEastWest::stage_23_create_firm()
{
    //----- create firms around established towns -----//

    Nation* nationPtr = nation_array[STAGE_23_EASTERN_NATION_RECNO];

    int townRecno1 = king_oversee_town_recno(STAGE_23_EASTERN_NATION_RECNO);
    int townRecno2 = random_pick_town_with_camp(STAGE_23_EASTERN_NATION_RECNO, 2);		// only pick towns with <= 2 links

    if( townRecno2 && misc.random(2)==0 )		// swap the town in 50% chance
    {
        int t=townRecno1;
        townRecno1 = townRecno2;
        townRecno2 = t;
    }

    //--- while the races of towns are random, the two main towns' race has to be the king's race ---//

    town_array[townRecno1]->set_race(nationPtr->race_id);

    if( townRecno2 )
        town_array[townRecno2]->set_race(nationPtr->race_id);

    create_economic_firm(townRecno1);
    create_offensive_structure(townRecno1);

    if( townRecno2 )
    {
        create_military_firm(townRecno2);
        create_offensive_structure(townRecno2);
    }

    //----- four possible situations -------//

    int eastSituation = misc.random(2)+1;

    //-------------------------------------------------//
    // The target state has an emphasis on weapon
    // development and production. There are a number
    // of war factories and a large number of weapons.
    //-------------------------------------------------//

    if( eastSituation==1 )
    {
        //---- build a war factory next to the town with mostly economic facilities.

        create_work_firm( town_array[townRecno1], FIRM_WAR_FACTORY );

        //-- fill most of the forts with weapons -----//

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

            int addCount = MAX_SOLDIER - firmCamp->soldier_count - misc.random(3);		// don't always full up, sometimes leave a free slots empty

            for( int j=addCount ; j>0 ; j-- )
                add_weapon_to_camp( firmCamp->firm_recno );
        }

        //---- give it more cash upfront ------//

        nationPtr->cash += 2300 + 1000 * campaign_difficulty;
    }

    //-------------------------------------------------//
    // The target state has an emphasis on economic
    // development, it is vastly rich. And can use money
    // to boost up its military rapidly.
    //-------------------------------------------------//

    if( eastSituation==2 )
    {
        //--- create one more series of economic buildings ---//

        int townRecno2 = random_pick_town_with_camp(STAGE_23_EASTERN_NATION_RECNO, 2);		// only pick towns with <= 2 links

        if( townRecno2 )
            create_economic_firm(townRecno2);

        //---- give it more cash upfront ------//

        nationPtr->cash += 3000 + 2300 * campaign_difficulty;
    }

    //------- add more groups of economy and military structures ---//

    int townRecno;

    if( campaign_difficulty >= 3 )
    {
        townRecno = random_pick_town_with_camp(STAGE_23_EASTERN_NATION_RECNO, 2);		// only pick towns with <= 2 links

        if( townRecno )
        {
            town_array[townRecno]->set_race(nationPtr->race_id);
            create_military_firm(townRecno);
            create_offensive_structure(townRecno);
        }
    }

    if( campaign_difficulty >= 4 )
    {
        townRecno = random_pick_town_with_camp(STAGE_23_EASTERN_NATION_RECNO, 2);		// only pick towns with <= 2 links

        if( townRecno )
        {
            town_array[townRecno]->set_race(nationPtr->race_id);
            create_economic_firm(townRecno);
            create_offensive_structure(townRecno);
        }
    }

    if( campaign_difficulty >= 5 )
    {
        townRecno = random_pick_town_with_camp(STAGE_23_EASTERN_NATION_RECNO, 2);		// only pick towns with <= 2 links

        if( townRecno )
        {
            town_array[townRecno]->set_race(nationPtr->race_id);
            create_military_firm(townRecno);
            create_offensive_structure(townRecno);
        }
    }

    return 1;
}