Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //v 1.3 https://pastebin.com/JLUStSk3
- //CIVDOS: AI CITY BUILDING LOGIC (pseudocode) v 1.4
- //I think in strange parts with DX DX should be always 0 (if we want sensible game logic), so I deleted it in such cases.
- //see v 1.3 for strange DX parts
- //per-continent strategies (same numbers as unit roles)
- #define P_SETTLE 0
- #define P_ATTACK 1
- #define P_DEFEND 2
- #define P_TRANSPORT 5
- //unit roles
- #define UR_SETTLER 0
- #define UR_ATTACK 1
- #define UR_DEFENCE 2
- #define UR_SEA_ATTACK 3
- #define UR_TRANSPORT 5
- //unit domain
- #define UD_LAND 0
- #define UD_AIR 1
- #define UD_FLEET 2
- //types of units
- #define U_SETTLERS 0
- #define U_MILITIA 1
- #define U_FIGHTER 14
- #define U_BOMBER 15
- #define U_NUCLEAR 25
- #define U_DIPLOMAT 26
- //city improvements (bit flags)
- #define BB_PALACE 0x1
- #define BB_BARRACKS 0x2
- #define BB_GRANARY 0x4
- #define BB_MARKETPLACE 0x10
- #define BB_LIBRARY 0x20
- #define BB_FACTORY 0x4000
- #define BB_MFG_PLANT 0x8000
- #define BB_POWER_PLANT 0x4 //second word
- #define BB_HYDRO_PLANT 0x8
- #define BB_NUCLEAR_PLANT 0x10
- //city improvements (palace is 1)
- #define B_MARKETPLACE 5
- #define B_LIBRARY 6
- #define B_COURTHOUSE 7
- #define B_BANK 10
- #define B_UNIVERSITY 12
- #define B_FACTORY 15
- #define B_POWER_PLANT 19
- #define B_HYDRO_PLANT 20
- #define B_NUCLEAR_PLANT 21
- //wonders of the world (Pyramids is 1)
- #define W_HOOVER_DAM 15
- #define W_MANHATTAN_PROJECT 17
- #define W_APOLLO_PROGRAM 19
- //civilization advances
- #define T_NUCLEAR_FISSION 0x1b
- #define T_EXPLOSIVES 0x38
- //governments
- #define G_DESPOTISM 1
- //start sequence: 55 8b ec 81 ec 4a 01 57 56...
- //start address: 0xd9a1 in unpacked civ.exe (ver .05 en)
- FUN_prod_menu_and_ai_prod_selection(u8 civ, u8 city_id)
- {
- //1ade:0421
- current_list = 0; //2 - city improvements
- advisers_drawn = 0;
- FUN_city_count_everything(city_id,-1); //darkpanda: CityProcess
- //it calculates various variables for city_id city
- //this function also can draw city screen, but it doesn't do it here ('cause -1 param)
- LAB_CREATE_LIST:
- //omitted: create string: "What should we build in City Name?"
- list_entries = 1; //total menu items to select
- list_prod[0] = 0;
- if (current_list != 2)
- {
- for (counter = 0; counter < 28; counter++)
- {
- if (check_tech(civ,unit_tech[counter]))
- {
- if (check_tech(civ,unit_obsolete_tech[counter]) == 0)
- {
- if (city_flags[city_id]&0x2
- || unit_domain[counter] != UD_FLEET)
- {
- if (counter == U_NUCLEAR)
- {
- if (wonder_city[W_MANHATTAN_PROJECT] == -1)
- continue;
- if (check_tech(civ,T_NUCLEAR_FISSION) == 0)
- continue;
- }
- //omitted: add to string unit string: i.e. "Militia (5 turns, A/D/M:1/1/1)"
- list_prod[list_entries] = counter;
- list_entries++;
- }
- }
- }
- }
- }
- //1ade:05f4
- list_entries_units = list_entries;
- string_pos_units = get_string_length(current_string);
- hoover_dam_eff = 0;
- if (check_wonder_eff(civ,W_HOOVER_DAM))
- {
- if (get_continent(city_x[wonder_city[W_HOOVER_DAM]],city_y[wonder_city[W_HOOVER_DAM]]) ==
- get_continent(city_x[city_id],city_y[city_id])
- {
- hoover_dam_eff = 1;
- }
- }
- //1ade:066b
- if ((debug_flag&0x4)!=0) //you can change debug flags is .SVE using JCivED
- {
- for (counter = 1; counter <= 24; counter++)
- {
- if (counter > 21) //SS parts
- {
- if (wonder_city[W_APOLLO_PROGRAM] == -1)
- continue;
- if ((spaceship_flags&(1<<civ))==0) //civ already launched SS
- continue;
- }
- if (check_tech(civ,city_improvement_tech[counter] == 0)
- continue;
- //1ade:06c8 city already has this improvement: I rewrote it pretty loosely...
- if (counter-1 < 16)
- {
- if ((city_buildings1[city_id]&(1<<(counter-1))) != 0)
- continue;
- }
- else
- {
- if ((city_buildings2[city_id]&(1<<(counter-1-16))) != 0)
- continue;
- }
- //1ade:06fb
- if (counter == B_FACTORY)
- {
- if (city_buildings1[city_id]&BB_MFG_PLANT)
- {
- continue;
- }
- }
- if (counter == B_BANK)
- {
- if ((city_buildings1[city_id]&BB_MARKETPLACE)==0)
- {
- if (check_tech(civ,city_improvement_tech[B_MARKETPLACE]))
- continue;
- }
- }
- if (counter == B_UNIVERSITY)
- {
- if ((city_buildings1[city_id]&BB_LIBRARY)==0)
- {
- if (check_tech(civ,city_improvement_tech[B_LIBRARY]))
- continue;
- }
- }
- if (counter == B_HYDRO_PLANT)
- {
- if ((city_flags[city_id]&0x80)==0) //city doesn't have hydropower
- continue;
- }
- if (counter == B_POWER_PLANT)
- {
- if ((city_buildings1[city_id]&BB_FACTORY)==0)
- continue;
- }
- if (counter == B_POWER_PLANT
- || counter == B_HYDRO_PLANT
- || counter == B_NUCLEAR_PLANT)
- {
- if (hoover_dam_eff)
- continue;
- if ((city_buildings2[city_id]&BB_POWER_PLANT) != 0
- || (city_buildings2[city_id]&BB_HYDRO_PLANT) != 0
- || (city_buildings2[city_id]&BB_NUCLEAR_PLANT) != 0)
- continue;
- }
- //omitted: add city improvement string, i.e. "Barracks (20 turns)"
- list_prod[list_entries] = -counter; //1 -> -1 is palace 2 -> -2 is barracks etc.
- list_entries++;
- }
- }
- //1ade:082f
- for (counter = 25; counter <= 45; counter++)
- {
- if (check_tech(civ,city_improvement_tech[counter])==0)
- continue;
- if (wonder_city[counter-24] == -1 //wonder was never built
- || wonder_city[counter-24] == 127) //wonder was destroyed
- continue;
- if (check_tech(civ,wonder_tech_obsolete[counter-24])
- {
- //omitted: add "*" to string
- }
- //omitted: add wonder string, i.e. "Pyramids (100 turns)"
- list_prod[list_entries] = -counter;
- list_entries++;
- }
- //1ade:08dd
- if (civ == player_civ)
- {
- if ((city_flags[city_id]&0x10)==0) //not autobuild
- {
- if (list_entries >= 30)
- {
- if (current_list == 0)
- {
- current_list = 1;
- goto LAB_CREATE_LIST; //repeat everything? why?..
- }
- //omitted: replace part of "current_string" after "string_pos_units" with string "More..." (1)
- list_prod[list_entries_units] = 99; //flag to switch to the next list
- }
- }
- }
- if (current_list == 2)
- {
- //omitted: add string "More..." (2)
- list_prod[list_entries] = 98; //flag to switch to previous list
- }
- //end of: list creation (position -> what to build) and creation of text for this list--------------------------------------------------------------
- //1ade:094f
- cont = get_continent(city_x[city_id],city_y[city_id]);
- cont_pol = continent_policy[civ][cont];
- pol = 0;
- if (cont_pol == P_ATTACK
- || cont_pol == P_DEFEND)
- {
- pol = 1;
- }
- if (gl_ai_handicap != 0 //'human player dominance': 1st place in civ powergraph, > 4 cities and 0 nuclear bombs, and turn > 200
- && cont_pol == P_TRANSPORT)
- {
- pol = 1;
- }
- if (government[civ] <= G_DESPOTISM)
- {
- settlers_food = 1;
- }
- else
- settlers_food = 2;
- s16 res_food = city_food_prod-settlers_food*settler_counter-2*city_size[city_id]; //city_food_prod is a global var
- //1ade:09dd
- counter = 0;
- do //types of units
- {
- stack_fee6[counter] = 1; //modifer: it's 1 for every unit type, so it's possible to just use '1' instead?
- unit_counter_on_continent[counter] = 0; //stack -0x44
- counter++;
- }
- while (counter < 28);
- //1ade:0a01
- local_civ_un_counter = civ_unit_counter[civ]; //old, normal value (without settlers and nuclears)
- civ_unit_counter[civ] = 0;
- city_count = 0;
- do //all cities
- {
- cit_cont = get_continent(city_x[city_count],city_y[city_count]);
- if (city_flags[city_count] != -1 //a city exists
- && city_civ[city_count] == civ //it's belong to us
- && cit_cont == cont) //a city is on the same continent as our city
- {
- if (city_production[city_count] >= 0) //unit in production
- {
- if (city_count != city_id) //not our city itself
- {
- unit_in_prod_on_cont[city_production[city_count]]++; //local array
- }
- }
- for (i = 0; i < 2; i++) //special fields for unit storage...
- {
- alt_un = city_alt_unit_field[city_count][i]
- if (alt_un != 0xFF)
- {
- civ_units_counter[civ]++; //global array
- unit_counter_on_continent[alt_un&0x3F]++; //local array
- }
- }
- }
- city_count++;
- }
- while (city_count < 128);
- //1ade:0ab2
- counter = 0;
- do //all units
- {
- if (unit_type[counter] != -1) //unit exists
- {
- civ_units_counter[civ]++;
- un_cont = get_continent(unit_x[counter], unit_y[counter]);
- if (un_cont == cont)
- {
- unit_counter_on_continent[unit_type[counter]]++;
- }
- }
- }
- while (counter < 128);
- //1ade:0b0b
- if (civ_units_counter[civ] == 0)
- {
- if (civ != player_civ)
- {
- if (government[civ] <= G_DESPOTISM)
- {
- return 1; //militia //actually does not work for first city (probably because settler is not disbanded yet)
- }
- }
- }
- //1ade:0b2c
- if (civ == 0) //barbarians
- {
- if (first_discoverer_civ[T_EXPLOSIVES] != 0) //explosives was discovered by somebody before...
- {
- return 7; //knights
- }
- return 3; //legion
- }
- //1ade:0b4a
- def_un_desire = 0;
- counter = find_unit_id_in_xy(city_x[city_id],city_y[city_id]);
- if (counter != -1) //there's some unit in the city
- {
- def_units = count_units_of_this_type_in_stack(counter,civ,UR_DEFENCE);
- var_a = city_size[city_id]/4+pol; //pol can be 0 or 1
- if (var_a > def_units)
- def_un_desire = 1; //we need more def units...
- }
- else
- {
- def_un_desire = 2; //we NEED def unit!!
- }
- //1ade:0baf
- best_unit_desire = 999; //the less is better
- best_bldng_desire = 999;
- best_desire = 999;
- best_unit_production = -1;
- best_bldng_production = -1; //stack -0x4a
- counter = 1;
- //1ade:0f57
- for (counter = 0; counter < list_entries; counter++)
- {
- prod_type = list_prod[counter];
- if (prod_type >= 0 //unit, not city improvement
- && prod_type < U_DIPLOMAT) //but not diplomat or caravan
- {
- if (prod_type == U_CARRIER)
- {
- continue; //AI never builds carriers...
- }
- if (prod_type == U_SETTLERS)
- {
- settl_food = 2;
- if (government[civ] <= G_DESPOTISM)
- settl_food = 1;
- if (settl_food >= res_food) //city produces not enough food to support new settler...
- {
- if (units_per_type[civ][U_SETTLERS] != 0
- || unit_in_prod_on_cont[U_SETTLERS] > 1)
- {
- continue;
- }
- }
- }
- //1ade:0fd2
- if (prod_type == U_MILITIA)
- {
- if (government[civ] > G_DESPOTISM) //AI never builds militias if its govt's not Despotism...
- {
- continue;
- }
- }
- if (prod_type == U_NUCLEAR)
- {
- if (units_per_type[civ][U_NUCLEAR] >= 4 //AI never builds nukes if it already has 4 of them
- || units_in_production[civ][U_NUCLEAR] >= 2) //or if >= 2 nukes in production
- {
- continue;
- }
- }
- //1ade:1009
- if (prod_type == U_FIGHTER)
- {
- if (units_per_type[civ][prod_type]+units_in_production[civ][prod_type] >=
- (units_per_type[player_civ][U_BOMBER])>>1)
- {
- continue;
- }
- if ((diplomacy_status[civ][player_civ]&2) != 0) //peace with player
- {
- continue;
- }
- }
- //1ade:1054
- if (unit_domain[prod_type] == UD_LAND)
- {
- curr_desire = (stack_fee6[prod_type]<<1)+unit_counter_on_continent[prod_type]; //stack_fee6[prod_type] is always 1
- //more units of this type (esp. in production) -> less desire to build another one
- }
- else
- {
- if (defence_per_continent[civ][cont] < 8) //not enough defence on continent -> don't build any boats or aircraft...
- {
- continue;
- }
- var_des = (units_in_production[civ][prod_type]<<1)+units_per_type[civ][prod_type]; //var_des: DX -> CX
- //more units of this type (esp. in production) -> less desire to build another one
- curr_desire = var_des*defence_per_continent[civ][cont]/(civ_unit_counter[civ]+1); //AX*CX
- //strange... more defence on continent -> less desire to build non-land unit?..
- //more units in total -> more desire to build non-land unit...
- }
- if (def_un_desire != 0)
- {
- if (unit_role[prod_type] != UR_DEFENCE) //we want to build defence units ONLY...
- {
- continue;
- }
- curr_desire = 2/def_un_desire; //the less is better
- }
- if (unit_role[prod_type] != UR_DEFENCE && unit_role[prod_type] != UR_SETTLER)
- {
- curr_desire = (curr_desire<<1); //if it's not a defender or settler, we need it less...
- if (cont_pol != unit_role[prod_type]) //unit role is not our continent role...
- {
- curr_desire = (curr_desire<<1); //we need it less...
- }
- }
- //1ade:1113
- if (unit_role[prod_type] == UR_TRANSPORT)
- {
- if (cont_pol != P_TRANSPORT) //AI doesn't build any transports if continent role is not 'transport'
- continue;
- curr_desire = ((3*curr_desire)>>1);
- }
- //1ade:113c
- if (prod_type == U_SETTLERS)
- {
- granary_factor = 6; //CX->AX
- if ((city_buildings1[city_id]&BB_GRANARY)!=0) //city has a granary
- granary_factor = 4; //we want to build settlers more
- granary_factor -= get_leader_civilized_attitude(civ,civ_0_or_1_same_color[civ]); //+1->-1 for civilized, -1->+1 for militaristic
- //civilized leaders want to build settlers more... BUT 'expansionism' attitude is not matter here...
- }
- else
- granary_factor = 10; //AX
- granary_factor *= (unit_shield_rows_cost[prod_type]+2); //AX
- granary_factor *= curr_desire; //AX->CX
- unit_coolness = (unit_attack[prod_type]+unit_defence[prod_type])*(unit_tot_moves[prod_type]+1);
- granary_factor /= unit_coolness; //we want to build strongest and fastest units...
- curr_desire = granary_factor;
- //1ade:11a8
- if (unit_role[prod_type] == UR_SEA_ATTACK)
- {
- if (cont_pol != P_SETTLE)
- {
- curr_desire *= 4; //we want it much less (we need military units or transports!)
- }
- else
- {
- curr_desire *= 2; //we want it less
- }
- }
- if (unit_domain[prod_type] == UD_AIR)
- {
- curr_desire = (curr_desire<<1);
- }
- //1ade:11d9
- if (civ_unit_counter[civ] > 120) //too many units...
- {
- curr_desire = (curr_desire<<2);
- }
- if (cont_pol == P_SETTLE)
- {
- //continent policy is not attack/defend or transport -> so we don't units THIS much...
- if (city_tot_shields <= city_supp_units)
- //so, if there's too many supported units (in comparison with city shield production)...
- {
- curr_desire = (curr_desire<<1); //we want to build another unit less...
- }
- }
- if (civ_has_contact_or_peace_with_somebody == 0) //i.e. no contacts with other civs...
- //if diplomacy flags 'contact' or 'peace' is not 0 with some other civ at the beginning of civ turn => then it's 1
- {
- curr_desire = (curr_desire<<1);
- }
- //1ade:1206
- if (curr_desire < best_desire) //better
- {
- best_common_production = counter; // Stack[-0x146]
- best_desire = curr_desire;
- }
- } //normal unit
- else //city improvements, diplomat, caravan
- {
- //1ade:0f79
- curr_desire = 999;
- building_pol = 0;
- temp_var_ax = -prod_type; //city improvement number... -1 palace->1, -2 barracks->2 etc. diplomat: -26, caravan: -27, //NEG AX
- temp_var_ax += 27; // SUB AX, -27 //palace: 28 nuclear plant: 48 SS structural: 49
- //diplomat: 1, caravan: 0
- if (temp_var_ax <= 49) //caravan, diplomat or any city improvement, except SS component, SS module and wonders
- {
- //ADD AX,AX //2 bytes per entry...
- //XCHG AX,BX //AX <-> BX for what purpose?..
- //JMP word ptr CS:[BX + 0xe71] //what the heck?
- //maybe "switch" in original code?
- switch (temp_var_ax)
- {
- case 31: //temple 0x0bcf
- if ((city_flags[city_id]&1) != 0) //city disorder
- curr_desire = -4; //stack 0xfecc
- break;
- case 34: //courthouse 0x0bea
- curr_desire = -((city_corruption<<1)-12);
- break;
- case 38: //cathedral 0x0bfb
- if ((city_flags[city_id]&1) != 0) //city disorder
- curr_desire = -2;
- break;
- case 41: //colosseum 0x0c16
- if ((city_flags[city_id]&1) != 0) //city disorder
- curr_desire = -1;
- break;
- case 29: //barracks 0x0c31
- curr_desire = 5;
- building_pol = 1; //stack 0xfece
- break;
- case 30: //granary 0x0c40
- if (city_tot_shields >= 3)
- curr_desire = 4;
- else
- curr_desire = 8;
- break;
- case 42: //factory
- case 47: //hydro plant 0x0c51
- curr_desire = -(((city_tot_shields)>>1)-13);
- break;
- case 46: //power plant 0x0c5e
- curr_desire = -(city_tot_shields/5-12);
- break;
- case 43: //mfg plant
- case 45: //rec center
- case 48: //nuclear plant 0x0c69
- AX = city_tot_shields;
- AX = AX>>3;
- curr_desire = -(AX-12);
- break;
- case 32: //marketplace 0x0c7d
- curr_desire = -(((city_tot_trade)>>1)-10);
- if ((city_flags[city_id]&1) != 0) //city disorder
- {
- curr_desire = -3;
- }
- break;
- case 33: //library
- case 37: //bank 0x0ca9
- curr_desire = -(city_tot_trade/3-10);
- break;
- case 39: //university 0x0cb8
- AX = city_tot_trade;
- AX = AX>>2;
- curr_desire = -(AX-10);
- break;
- case 35: //city walls 0x0ccb
- curr_desire = -(city_size[city_id]/2-10);
- if (city_buildings1[city_id]&BB_PALACE)
- curr_desire = 4;
- break;
- case 36: //aqueduct 0x0cf8
- AX = 10-(res_food>>1);
- if (AX <= city_size[city_id])
- {
- curr_desire = -(city_size[city_id]+(res_food>>1)-14);
- }
- break;
- case 49: //SS structural 0x0d27
- if ((spaceship_flags&((1<<civ)+(1<<player_civ)))==0) //Our spaceship not launched AND human spaceship not launched too.
- {
- if (spaceship_flags&(1<<8)) //score completed: post game (&0x100)
- {
- curr_desire = 2; //but why AI want it _more_ in this case?..
- }
- else
- {
- curr_desire = 4;
- }
- }
- break;
- case 0: //caravan 0x0d5a
- if (trade_cities[city_id][2] == -1)
- {
- curr_desire = -((city_tot_trade>>1)-10); //I have no idea what's in DX at the moment...
- if (trade_cities[city_id][0] != -1)
- {
- curr_desire += 2;
- }
- if (trade_cities[city_id][1] != -1)
- {
- curr_desire += 2;
- }
- if (curr_desire < 3)
- {
- curr_desire = 3;
- }
- }
- if (player_civ == civ)
- {
- if (city_flags[city_id]&0x10) //auto build
- {
- curr_desire = 999; //human player should NOT build caravans in autobuild!
- }
- }
- break;
- case 1: //diplomat 0xdcd
- if (player_civ != 0) //human doesn't play for Barbarians...
- {
- if ((unknown_array_civ_x_civ[civ][player_civ]&2)==0) //always?..
- //array: 2 bytes per civ, civ x civ = 2*8*8 = 128 bytes total
- //2nd byte is 0xfd, if in the past there was sneak attack by human player on AI or sneak attack by AI on the human player
- //but 1st byte never changes and it's always 0 (if it does not change in overlays...)
- {
- if (units_in_production[civ][diplomat] <= 0)
- {
- counter = random(5); //random block of 16 tech (bit flags, 16*5 = 80 tech max per civ)
- if ((player_civ_near_me&(1<<civ))!=0)
- //it's 1, if human player has > 1 cities on some of our AI civ continents
- //and AI civ defence on this continent is not 0
- //and there can be some other conditions - it's set in big routine which determines AI policy, it's pretty complicated...
- {
- di_var = tech_list[civ][counter];
- ax_var = tech_list[player_civ][counter];
- ax_var |= di_var;
- if (ax_var != dx_var) //player civ has some new techs in this 16 tech chunk...
- {
- ax_var = number_of_tech[civ]-number_of_tech[player_civ]+10;
- curr_desire = normalize_minmax(ax_var,5,10);
- }
- }
- }
- }
- }
- break;
- case 40: //mass transit
- case 44: //sdi defence
- default: //2..28 - military units (not used) and palace
- //do nothing
- }
- }
- //1ade:0ed5
- if (curr_desire >= 400)
- {
- curr_desire = 0x3fff; //whut?
- }
- else
- {
- if (cont_pol != building_pol) //building_pol usually 0, 1 (attack) for barracks
- {
- base_des = 14; //we need attack/defence units or transports, so we don't want to build city improvements...
- }
- else
- base_des = 10;
- curr_desire *= base_des;
- curr_desire = 3*curr_desire/(get_leader_civilized_attitude(civ,civ_0_or_1_same_color[civ])+3);
- // /4 if civilized -> want to build city improvements
- // /2 if militaristic -> don't want to build city improvements
- // /3 otherwise
- }
- //1ade:0f22
- if ((city_buildings1[city_id]&BB_BARRACKS)!=0) //if city has barracks...
- {
- curr_desire += (curr_desire>>2); //you better to build units and not city improvements?..
- }
- if (curr_desire < best_desire) //better
- {
- best_common_production = counter;
- best_desire = curr_desire;
- }
- }
- if (prod_type < 0 //city improvement
- || prod_type >= U_DIPLOMAT) //diplomat or caravan
- {
- if (curr_desire < best_bldng_desire)
- {
- best_bldng_desire = curr_desire;
- best_bldng_production = counter;
- }
- }
- else //normal unit
- {
- if (curr_desire < best_unit_desire)
- {
- best_unit_desire = curr_desire;
- best_unit_production = counter;
- }
- }
- } //loop: select best production
- //1ade:1268
- civ_unit_counter[civ] = local_civ_un_counter; //restore previous value (without settlers and nuclear bombs)
- if ((human_civs_bits&(1<<civ)) == 0) //ai
- {
- if (city_production[city] == -1) //palace
- {
- return -1; //continue palace construction?.. probably AI decides to change capital/select capital if NONE in some different function!
- //but definetely not in this function...
- }
- return list_prod[best_common_production];
- }
- //1ade:12a5
- if ((city_flags[city]&x0x10)!=0) //AUTO
- {
- if (best_bldng_production != -1 //some new buildings was selected for AUTO
- && best_bldng_desire <= 500) //and desire to build it is high enough...
- {
- return list_prod[best_bldng_production];
- }
- else
- return 99; //flag: no good new production for AUTO was found. Do not change production. Go to city screen, if needed...
- }
- //1ade:12cd
- if ((game_settings&0x1)!=0) //instant advice
- {
- if (advisers_drawn == 0)
- {
- if (best_unit_production != -1) //military advisor
- {
- glob_0xaa[16] = 2; //?? m.b. total number of lists/messages??
- if (list_prod[best_unit_production] > 0) //unit
- {
- //omitted: use name from units name list...
- }
- else
- {
- //omitted: use name from city improvements name list - never happens
- }
- //omitted: create string for military advisor message (using produce.txt)
- help_message_on_screen_flag = 1;
- draw_message_B(current_string,8,160); //draw military advisor advice
- }
- if (best_bldng_production != -1) //domestic advisor
- {
- curr_desire = list_prod[best_bldng_production];
- if (list_prod[best_bldng_production] > 0) //unit: diplomat or caravan
- {
- //omitted: use name from units name list...
- }
- else
- {
- //omitted: use name from city improvements name list...
- }
- //omitted: create string for domestic advisor message (using produce.txt)
- draw_message_B(current_string,164,160); //draw domestic advisor advice
- }
- advisers_drawn = 1;
- glob_0xaa[16] = 1; //??
- goto LAB_CREATE_LIST;
- }
- } //instant advice
- //1ade:1438
- if (list_entries > 20 || current_list != 0)
- {
- glob_0xaa[16] = 2; //??
- }
- //1ade:144e
- menu_on_screen_flag = 1;
- SI = draw_message_B(current_string,80,8); //draw menu (what you can build) in X: 80 Y: 8
- current_desire = stack_de[SI]; //stack -0xde, never used elsewhere... should be selected menu item?
- if (current_desire == 99) //go to the next list...
- {
- current_list = 2; //city improvements
- goto LAB_CREATE_LIST;
- }
- if (current_desire == 98) //go to previous list...
- {
- current_list = 1; //units
- goto LAB_CREATE_LIST;
- }
- glob_0xaa[16] = 1; //??
- //1ade:148c
- if (civilopedia_help_flag != 0)
- {
- FUN_black_screen_mb();
- FUN_clear_screen_mb_B(); //some_graph_driver_func_1(0,0,200,320,0,0,glob_0xaa);
- cpedia_from_city_screen_flag = 1;
- if (current_desire >= 0) //unit
- {
- cpedia_type = 2;
- }
- else //city improvement
- {
- cpedia_type = 1;
- current_desire = -current_desire; //city improvements have negative values
- }
- overlay_08_2A06(current_desire,cpedia_type); //civilopedia help
- clear_all_screen_mb(); //some_graph_driver_func_2(0,0,glob_0xaa,200,320,unkn_graph_var) - clear screen?
- update_screen_mb();
- to_other_screen_from_city_screen_flag = 1;
- goto LAB_CREATE_LIST;
- }
- return current_desire;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement