int CampaignEastWest::stage_4_create_town() { int townAddCount = 5 + misc.random(3); int hasFortPercent = 50; return create_town(STAGE_4_EASTERN_NATION_RECNO, townAddCount, hasFortPercent); }
int CampaignEastWest::stage_23_create_town() { int townAddCount = 8 + misc.random(2); int hasFortPercent = 100; int combatLevel = 40 + campaign_difficulty*10; return create_town( STAGE_23_EASTERN_NATION_RECNO, townAddCount, hasFortPercent, combatLevel); }
//-------- Begin of function Battle::create_pregame_object --------// // // Initialize pre-game objects - towns, sites, independent towns. // void Battle::create_pregame_object() { #define CREATE_UNIT_AREA_WIDTH 16 #define CREATE_UNIT_AREA_HEIGHT 16 // ###### begin Gilbert 24/10 ######// const int dispProgress = 1; const int maxGenMapSteps = 100; const int newWorldSection = 1; vga_front.unlock_buf(); int curGenMapSteps = 0; if( dispProgress ) { vga_front.lock_buf(); game.disp_gen_map_status( curGenMapSteps, maxGenMapSteps, newWorldSection); vga_front.unlock_buf(); } // ###### end Gilbert 24/10 ######// //------- create nation and units --------// int nationRecno, unitId, rankId, xLoc, yLoc, townRecno; int kingUnitRecno; int noSpaceFlag=0; Nation* nationPtr; for( nationRecno=1 ; nationRecno<=nation_array.size() ; nationRecno++ ) { if( nation_array.is_deleted(nationRecno) ) continue; nationPtr = nation_array[nationRecno]; //--------- create town -----------// townRecno = create_town( nationRecno, nationPtr->race_id, xLoc, yLoc ); if( !townRecno ) { noSpaceFlag = 1; break; } //------- create military camp -------// Town* townPtr = town_array[townRecno]; int firmRecno = firm_array.build_firm(townPtr->loc_x1+6, townPtr->loc_y1, nationRecno, FIRM_CAMP, race_res[nationPtr->race_id]->code); if( !firmRecno ) { noSpaceFlag = 1; break; } firm_array[firmRecno]->complete_construction(); //--------- create units ----------// unitId = race_res[nationPtr->race_id]->basic_unit_id; kingUnitRecno = create_unit(townRecno, unitId, RANK_KING); if( kingUnitRecno ) { nation_array[nationRecno]->set_king(kingUnitRecno, 1); // 1-this is the first king of the nation firm_array[firmRecno]->assign_overseer(kingUnitRecno); // assign the king as the overseer of the command base } else { noSpaceFlag = 1; break; } //----- create skilled units if config.random_start_up is 1 -----// if( config.random_start_up ) { int createCount = (50-townPtr->population)/3; // the less population the villager has the more mobile units will be created for( int i=0 ; i<createCount ; i++ ) { if( misc.random(2)==0 ) unitId = race_res[nationPtr->race_id]->basic_unit_id; else unitId = race_res[ misc.random(MAX_RACE)+1 ]->basic_unit_id; if( misc.random(3)==0 ) rankId = RANK_GENERAL; else rankId = RANK_SOLDIER; if( !create_unit(townRecno, unitId, rankId) ) break; } } //------ create mines near towns in the beginning -----// if( config.start_up_has_mine_nearby && !nationPtr->is_ai() ) site_array.create_raw_site(0, townRecno); } //--- if there is no space for creating new town/firm or unit, delete the unprocessed nations ---// if( noSpaceFlag ) { for( ; nationRecno<=nation_array.size() ; nationRecno++ ) nation_array.del_nation(nationRecno); // no space for creating a town for the nation, so we have to delete the nation } // ###### begin Gilbert 24/10 ########// curGenMapSteps += 10; // 10 if( dispProgress ) { vga_front.lock_buf(); game.disp_gen_map_status( curGenMapSteps, maxGenMapSteps, newWorldSection); vga_front.unlock_buf(); } // ###### end Gilbert 24/10 ######// //---- init the type of active monsters in this game ----// monster_res.init_active_monster(); // ###### begin Gilbert 24/10 ########// curGenMapSteps += 5; // 15 if( dispProgress ) { vga_front.lock_buf(); game.disp_gen_map_status( curGenMapSteps, maxGenMapSteps, newWorldSection); vga_front.unlock_buf(); } // ###### end Gilbert 24/10 ######// //------ create independent towns -------// //### begin alex 27/8 ###// int startUpIndependentTown = config.start_up_independent_town; //int startUpRawSite = config.start_up_raw_site; int startUpMonsterFirm = 10; int i, j, raceId; site_array.generate_raw_site(config.start_up_raw_site); // ###### begin Gilbert 24/10 ########// curGenMapSteps += 10; // 25 if( dispProgress ) { vga_front.lock_buf(); game.disp_gen_map_status( curGenMapSteps, maxGenMapSteps, newWorldSection); vga_front.unlock_buf(); } int targetStep = maxGenMapSteps; // ###### end Gilbert 24/10 ######// int maxLoopCount = startUpIndependentTown + startUpMonsterFirm; for(j=0, i=1; j<maxLoopCount; j++, i++) { if(startUpIndependentTown) { //------ create independent towns -------// raceId = i%MAX_RACE+1; if(!create_town( 0, raceId, xLoc, yLoc ) ) { startUpIndependentTown = 0; break; } // ##### begin Gilbert 24/10 #######// else startUpIndependentTown--; // ###### end Gilbert 24/10 ########// } if(startUpMonsterFirm) { //------- create mosnters --------// if(config.monster_type != OPTION_MONSTER_NONE) { monster_res.generate(1); startUpMonsterFirm--; } else startUpMonsterFirm = 0; } if(!(startUpIndependentTown+startUpMonsterFirm)) break; // ###### begin Gilbert 24/10 ########// if( dispProgress ) { vga_front.lock_buf(); game.disp_gen_map_status( curGenMapSteps + j*(targetStep-curGenMapSteps)/maxLoopCount, maxGenMapSteps, newWorldSection); vga_front.unlock_buf(); } // ###### end Gilbert 24/10 ######// } //#### end alex 27/8 ####// // ###### begin Gilbert 24/10 ########// // finish curGenMapSteps = targetStep; // 100 if( dispProgress ) { vga_front.lock_buf(); game.disp_gen_map_status( curGenMapSteps, maxGenMapSteps, newWorldSection); vga_front.unlock_buf(); } // ###### end Gilbert 24/10 ######// vga_front.lock_buf(); }
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); }