//---- Begin of function CampaignEastWest::stage_28_create_game ----// // // Vars defined in event functions before calling this function: // // None // int CampaignEastWest::stage_28_create_game() { init_random_plot(0); // no plot //------- create objects and vars --------// if( !stage_28_create_nation() ) return 0; //----- create independent towns ------// Battle::create_independent_town(5+misc.random(3)); //---- create the player force and peasants ----// create_troop(PLAYER_NATION_RECNO, 16, 50 ); // 50-average combat level Nation* playerNation = nation_array[PLAYER_NATION_RECNO]; Unit* kingUnit = unit_array[ playerNation->king_unit_recno ]; //---- create a group of peasants with the player's nationality ---// int unitId = race_res[playerNation->race_id]->civilian_unit_id; int peasantCount = 25 + misc.random(6); for( int i=0 ; i<peasantCount ; i++ ) { create_unit( PLAYER_NATION_RECNO, unitId, RANK_SOLDIER, kingUnit->next_x_loc(), kingUnit->next_y_loc(), kingUnit->next_x_loc(), kingUnit->next_y_loc() ); } //------ init stage 1 vars -------// stage_28_init_vars(); //---- generate plants and other objects on the map -----// world.gen_rocks(); // generate mountains world.generate_map2(); //------- create additional raw sites ----------// create_raw_site(); // ----- create royal units ------// create_royal_units(CAMPAIGN_PLAYER_NATION_RECNO); //------ plot create game --------// (this->*plot_create_game_FP)(); return 1; }
//---- Begin of function CampaignEastWest::stage_19_create_game ----// // // Vars defined in event functions before calling this function: // // -eastern_nation_recno // -attack_state_recno // -target_state_recno // int CampaignEastWest::stage_19_create_game() { // ###### begin Gilbert 1/4 ########// init_random_plot('C'); // ###### end Gilbert 1/4 ########// if( !stage_19_create_nation() ) return 0; if( !stage_19_create_town() ) return 0; if( !stage_19_create_firm() ) return 0; //----- create offensive structures ---------// if( m.random(2)==0 ) create_offensive_structure( STAGE_19_EASTERN_NATION_RECNO, 1 + campaign_difficulty/2 ); // build 2 structures if the difficulty > 3 //------ create the player troop -------// create_troop(PLAYER_NATION_RECNO, 86-campaign_difficulty*6); //------ init stage 1 vars -------// stage_19_init_vars(); //---- generate plants and other objects on the map -----// world.gen_rocks(); world.generate_map2(); //------- create additional raw sites ----------// create_raw_site(); //------- init relationship -------// stage_19_init_relation(); // ####### begin Gilbert 9/4 ########// // ----- create royal units ------// create_royal_units(CAMPAIGN_PLAYER_NATION_RECNO); // ####### end Gilbert 9/4 ########// // ###### begin Gilbert 1/4 ########// (this->*plot_create_game_FP)(); // ###### end Gilbert 1/4 ########// return 1; }
//---- Begin of function CampaignEastWest::stage_12_create_game ----// // // Vars defined in event functions before calling this function: // // -cur_monster_nation_recno - the attacking monster nation recno // -attacker_state_recno - the monster attacking state // -target_state_recno - the player target state // int CampaignEastWest::stage_12_create_game() { init_random_plot('D'); //--- randomly init the current situation -----// set_cur_situation( m.random(CAMPAIGN_SITUATION_COUNT)+1 ); //------- create objects and vars --------// if( !stage_12_create_nation() ) return 0; if( !stage_12_create_town() ) return 0; if( !stage_12_create_firm() ) return 0; //------ create monsters ---------// create_troop(STAGE_12_MONSTER_NATION_RECNO, campaign_difficulty*15); //------ init stage 1 vars -------// stage_12_init_vars(); //---- generate plants and other objects on the map -----// world.gen_rocks(); // generate mountains world.generate_map2(); //------- create additional raw sites ----------// create_raw_site(); //------- init relationship -------// stage_12_init_relation(); // ####### begin Gilbert 9/4 ########// // ----- create royal units ------// create_royal_units(CAMPAIGN_PLAYER_NATION_RECNO); // ####### end Gilbert 9/4 ########// //------ plot create game --------// (this->*plot_create_game_FP)(); return 1; }
//---- Begin of function CampaignEastWest::stage_24_create_game ----// // // Vars defined in event functions before calling this function: // // -cur_monster_nation_recno - the target monster nation recno // -attacker_state_recno - the player attacking state // -attacker_state_recno2 - the eastern empire attacking state // -target_state_recno - the monster target state // int CampaignEastWest::stage_24_create_game() { init_random_plot('A'); plot_enemy_nation_recno = STAGE_24_MONSTER_NATION_RECNO; //---- create game objects and vars ----// if( !stage_24_create_nation() ) return 0; //------- init relationship -------// stage_24_init_relation(); // must init relationship first so that allied units are visible on the map //------ create lairs --------// if( !stage_24_create_lair() ) return 0; //---- create the player force ----// create_troop(PLAYER_NATION_RECNO, 60-campaign_difficulty*6 ); //---- create the eastern empire force ----// create_troop(STAGE_24_EASTERN_NATION_RECNO, 60-campaign_difficulty*6, 0, 0, 1 ); // last 1-create new units on the location next to the last bunch units created //------ init stage 1 vars -------// stage_24_init_vars(); //---- generate plants and other objects on the map -----// world.gen_rocks(); // generate mountains world.generate_map2(); //------- create additional raw sites ----------// create_raw_site(); // ----- create royal units ------// create_royal_units(CAMPAIGN_PLAYER_NATION_RECNO); //------ plot create game --------// (this->*plot_create_game_FP)(); return 1; }
//---- Begin of function CampaignEastWest::stage_9_create_game ----// // // Vars defined in event functions before calling this function: // // -cur_monster_nation_recno // -attack_state_recno // -target_state_recno // int CampaignEastWest::stage_9_create_game() { init_random_plot('D'); if( !stage_9_create_nation() ) return 0; if( !stage_9_create_town() ) return 0; if( !stage_9_create_firm() ) return 0; //---- create the invading force from the eastern empire ----// create_troop(STAGE_9_EASTERN_NATION_RECNO, 10+campaign_difficulty*12); create_wagon(STAGE_9_EASTERN_NATION_RECNO, 10+campaign_difficulty*15+misc.random(10), 1); // 1-useLastLocation //------ init stage 9 vars -------// stage_9_init_vars(); //---- generate plants and other objects on the map -----// world.gen_rocks(); // generate mountains world.generate_map2(); //------- create additional raw sites ----------// create_raw_site(); //------- init relationship -------// stage_9_init_relation(); // ####### begin Gilbert 9/4 ########// // ----- create royal units ------// create_royal_units(CAMPAIGN_PLAYER_NATION_RECNO); //------ plot create game --------// (this->*plot_create_game_FP)(); // ####### end Gilbert 9/4 ########// return 1; }
//---- Begin of function CampaignEastWest::stage_10_create_game ----// // // Vars defined in event functions before calling this function: // // -cur_monster_nation_recno // -attack_state_recno // -target_state_recno // int CampaignEastWest::stage_10_create_game() { init_random_plot('A'); plot_enemy_nation_recno = STAGE_10_MONSTER_NATION_RECNO; //---- create game objects and vars ----// if( !stage_10_create_nation() ) return 0; if( !stage_10_create_lair() ) return 0; //---- create the player force ----// create_troop(PLAYER_NATION_RECNO, 65-campaign_difficulty*5, 75 ); // 70 - average combat level, an elite force //------ init stage 1 vars -------// stage_10_init_vars(); //---- generate plants and other objects on the map -----// world.gen_rocks(); // generate mountains world.generate_map2(); //------- create additional raw sites ----------// create_raw_site(); //------- init relationship -------// stage_10_init_relation(); // ####### begin Gilbert 9/4 ########// // ----- create royal units ------// create_royal_units(CAMPAIGN_PLAYER_NATION_RECNO); // ####### end Gilbert 9/4 ########// //------ plot create game --------// (this->*plot_create_game_FP)(); return 1; }
//---- Begin of function CampaignEastWest::stage_4_create_game ----// // // Vars defined in event functions before calling this function: // // -eastern_nation_recno // -target_state_recno // int CampaignEastWest::stage_4_create_game() { init_random_plot('C'); //----------------------------------// if( !stage_4_create_nation() ) return 0; if( !stage_4_create_town() ) return 0; if( !stage_4_create_firm() ) return 0; //------ create the player troop -------// create_troop(PLAYER_NATION_RECNO, 65-campaign_difficulty*10, 65-campaign_difficulty*5); //------ init stage 1 vars -------// stage_4_init_vars(); //---- generate plants and other objects on the map -----// world.gen_rocks(); world.generate_map2(); //------- create additional raw sites ----------// create_raw_site(); //------- init relationship -------// stage_4_init_relation(); // ----- create royal units ------// create_royal_units(CAMPAIGN_PLAYER_NATION_RECNO); //------ plot create game --------// (this->*plot_create_game_FP)(); //---- randomly unveil the locations of some of the Eastern Empire's towns ----// for( int i=town_array.size() ; i>0 ; i-- ) { if( town_array.is_deleted(i) ) continue; Town* townPtr = town_array[i]; if( townPtr->nation_recno == STAGE_4_EASTERN_NATION_RECNO && misc.random(2)==0 ) { world.unveil( townPtr->loc_x1, townPtr->loc_y1, townPtr->loc_x2, townPtr->loc_y2 ); world.visit( townPtr->loc_x1, townPtr->loc_y1, townPtr->loc_x2, townPtr->loc_y2, EXPLORE_RANGE-1 ); } } return 1; }
//---- Begin of function CampaignEastWest::stage_1_create_game ----// // // Vars defined in event functions before calling this function: // // None // int CampaignEastWest::stage_1_create_game() { // ###### begin Gilbert 9/4 ########// init_random_plot(0); // no plot // ###### end Gilbert 9/4 ########// if( !stage_1_create_nation() ) return 0; if( !stage_1_create_town() ) return 0; if( !stage_1_create_firm() ) return 0; //------ create monsters ---------// int unitCountArray[MAX_CAMPAIGN_DIFFICULTY] = { 6, 10, 22, 31, 42 }; create_troop(STAGE_1_MONSTER_NATION_RECNO, unitCountArray[campaign_difficulty-1] ); if( unit_group.size() > 0 ) // when a troop is created successfully in create_troop(), unit_group will keep the created units { //--- create a unit for building Unit* unitPtr = unit_group.get_unit(1); int xLoc = unitPtr->cur_x_loc(); int yLoc = unitPtr->cur_y_loc(); int unitRecno = create_unit( STAGE_1_MONSTER_NATION_RECNO, unitPtr->unit_id, RANK_SOLDIER, xLoc, yLoc, xLoc, yLoc ); } //------ init stage 1 vars -------// stage_1_init_vars(); //---- generate plants and other objects on the map -----// world.gen_rocks(); // generate mountains world.generate_map2(); //------- create additional raw sites ----------// create_raw_site(); //------- init relationship -------// stage_1_init_relation(); // ####### begin Gilbert 9/4 ########// // ----- create royal units ------// create_royal_units(CAMPAIGN_PLAYER_NATION_RECNO); // ####### end Gilbert 9/4 ########// //------ plot create game --------// // ###### begin Gilbert 28/3 ########// (this->*plot_create_game_FP)(); // ###### end Gilbert 28/3 ########// return 1; }
//--------- Begin of function SiteArray::generate_raw_site ----------// // // Generate raw sites. This function is both called at the beginning // of a game and when existing raw sites are being used up. // // [int] rawGenCount - no. of raw sites to be generated. // (if this is not given, it will use the existing std_raw_site_count) // void SiteArray::generate_raw_site(int rawGenCount) { if( rawGenCount ) std_raw_site_count = rawGenCount; // use this number for determing whether new sites should emerge in the future #define MAX_RAW_REGION 3 // maximum no. of regions that has raw sites #define SMALLEST_RAW_REGION 50 // only put raw on the region if its size is larger than this #define REGION_SIZE_PER_RAW 100 //----- count the no. of existing raw sites -------// Site* sitePtr; int existRawSiteCount=0; int i; for( i=size() ; i>0 ; i-- ) { if( site_array.is_deleted(i) ) continue; sitePtr = site_array[i]; if( sitePtr->site_type == SITE_RAW && sitePtr->reserve_qty >= EXIST_RAW_RESERVE_QTY ) { existRawSiteCount++; } } if( existRawSiteCount >= std_raw_site_count ) return; //----- check which regions are valid for raw sites -----// int regionCount = min( MAX_RAW_REGION, region_array.region_info_count ); int validRegionCount, totalValidSize=0; RegionInfo* regionInfo; for( validRegionCount=0 ; validRegionCount<regionCount ; validRegionCount++ ) { regionInfo = region_array.get_sorted_region(validRegionCount+1); if( regionInfo->region_type != REGION_LAND ) continue; if( regionInfo->region_size < SMALLEST_RAW_REGION ) break; totalValidSize += regionInfo->region_size; } if( validRegionCount==0 ) // valid regions are those that are big enough to put raw sites return; //----- count the no. of existing raw sites in each ragion ------// int regionId; char regionRawCountArray[MAX_REGION]; memset( regionRawCountArray, 0, sizeof(regionRawCountArray) ); for( i=size() ; i>0 ; i-- ) { if( site_array.is_deleted(i) ) continue; sitePtr = site_array[i]; if( sitePtr->site_type == SITE_RAW && sitePtr->reserve_qty >= EXIST_RAW_RESERVE_QTY ) { regionId = world.get_region_id(sitePtr->map_x_loc, sitePtr->map_y_loc); regionRawCountArray[regionId-1]++; } } //--------- generate raw sites now ----------// int avgValidSize = min( 10000, totalValidSize / std_raw_site_count ); int j, createCount; err_when( validRegionCount > region_array.region_info_count || validRegionCount > MAX_RAW_REGION ); for( int k=0 ; k<10 ; k++ ) // one loop may not be enough to generate all raw sites, have more loops to make sure all are generated { for( i=0 ; i<regionCount ; i++ ) { regionInfo = region_array.get_sorted_region(i+1); if( regionInfo->region_type != REGION_LAND ) continue; if( regionInfo->region_size < SMALLEST_RAW_REGION ) break; createCount = regionInfo->region_size / avgValidSize; createCount = max(1, createCount); //--------- create now --------// for( j=regionRawCountArray[regionInfo->region_id-1] ; j<createCount ; j++ ) // if currently there are already some, don't create new ones { if( create_raw_site(regionInfo->region_id) ) { if( ++existRawSiteCount == std_raw_site_count ) return; } } } } }