Advertisement
Guest User

civdos ai wonders (fix 2)

a guest
Apr 5th, 2020
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.65 KB | None | 0 0
  1. //CIVDOS AI WONDERS RULES v3
  2.  
  3. #define W_DARWINS_VOYAGE    0x0E
  4. #define W_MANHATTAN_PROJECT 0x11
  5.  
  6. #define T_ROCKETRY 0x2E
  7.  
  8. void FUN_global_warming_and_ai_wonders()
  9. {
  10.     //skip some global warming code here...
  11.    
  12.     counter = 0;
  13.     do
  14.     {
  15.         if (counter > difficulty)
  16.             return;
  17.         wond = 1+random(21); //21 - number of wonders
  18.         //for some reason wonders are counting from 1 and not from 0... (1 = pyramids, 2 = gardens etc.)
  19.         if (difficulty != 0 || check_civ_advance(human_player_civ,wonder_tech[wond]) == 1)
  20.         //on Chieftain difficulty comp. player can build any wonder only if hum. player can build it!
  21.         {
  22.             if (difficulty < 2) //Chieftain or Warlord
  23.             {
  24.                 //this loop prohibits AI to build a wonder if human already is building one...
  25.                 //but only if it's not Manhattan Project...
  26.                 city = 0;
  27.                 do
  28.                 {
  29.                     if (city_civ[city] == human_player_civ
  30.                     && city_flags[city] != -1 //city exists
  31.                     && city_production[city] == -(24+wond)) //0 is settler, > 0 are units, -1..-24 are used for buildings and SS parts.
  32.                     {
  33.                         wond = W_MANHATTAN_PROJECT;
  34.                         //why not break here though?
  35.                     }
  36.                     city++;
  37.                 }
  38.                 while (city < 128);
  39.             }
  40.             city = random(128);
  41.             cit_civ = city_civ[city];
  42.             if (city_flags[city] != -1 //city exists
  43.             && (diplomacy_status[cit_civ][0])&4 == 0 //The civilization is not in anarchy. (third ('ALLY') bit of cit_civ diplomacy with 'barbarians' is 0).
  44.             && (wond != W_MANHATTAN_PROJECT || check_civ_advance(cit_civ,T_ROCKETRY) == 1)) //AI will build Manhattan Proj. only if it can build nukes...
  45.             {
  46.                 if (counter == 0
  47.                 && check_civ_advance(cit_civ,T_ROCKETRY) == 1 //rocketry is hardcoded, it will not change here if you change prerequisite tech for Nuclear unit...
  48.                 && check_civ_advance(human_player_civ,T_ROCKETRY) == 0
  49.                 && wonder_city[W_MANHATTAN_PROJECT] == -1) ////Manh. Proj. has never been built before...
  50.                 {
  51.                     wond = W_MANHATTAN_PROJECT;
  52.                 }
  53.                 if ((wond != W_MANHATTAN_PROJECT
  54.                 || check_civ_advance(human_player_civ,T_ROCKETRY) == 0
  55.                 || military_power[cit_civ] <= military_power[human_player_civ]) //if AI is weaker than the player, it can build MP even if the player knows the rocketry...
  56.                 &&
  57.                 (cit_civ != -1 && cit_civ != human_player_civ
  58.                 && wonder_city[wond] == -1)) //wonder never was built before...
  59.                 {
  60.                     if (city_size[city] > wonder_shield_rows_cost[wond]/10  //for example: you need 30 rows for Pyramids (300 shields), so AI can build Pyramids only in city with size 4 or more
  61.                     && check_civ_advance(cit_civ,wonder_tech_B[wond]) == 1) //alternative place for check. Used only here...
  62.                     {
  63.                         city_shields_count[city] = 0;
  64.                         write_replay_entry(10,2,cit_civ,wond); //10 - event type (wonder). 2 - record length.
  65.                        
  66.                         //concatenate some strings for "City (Civilization) builds a wonder" message here...
  67.                        
  68.                         var_B = normalize_min_max(civ_gold[cit_civ]/3,0,wonder_shield_rows_cost[wond]*10-city_shields_count[city]);
  69.                         //AI actually pays for wonders! But not more than 1/3 of the treasury!
  70.                         civ_gold[cit_civ] -= var_B;
  71.                         if (gl_debug_flag_A == 1) //some debug flag: no message about wonder and no civ jingle...
  72.                         {
  73.                             goto LAB_AI_WONDER_ACTIONS;
  74.                         }
  75.                         play_sound(civ_jingle[cit_civ+2*civ_pair[cit_civ]]);
  76.                         if ((diplomacy_status[human_player_civ][cit_civ]&0x40)==0) //you don't have an embassy for cit_civ...
  77.                         {
  78.                             var_C = 2; //Travellers report:
  79.                         }
  80.                         else
  81.                         {
  82.                             var_C = 5; //Foreign Minister:
  83.                         }
  84.                         gl_message_type = var_C;
  85.                         var_C = 80;
  86.                         goto LAB_WONDER_MESSAGE;
  87.                     }
  88.                 }
  89.             }
  90.         }
  91.         counter++;
  92.     }
  93.     while (1);
  94.    
  95.     //actually these labels are within some IF block in global warming logic.
  96.     LAB_WONDER_MESSAGE:
  97.     draw_message_function(curr_string,100,var_C); //draw message x: 100, y: 80?
  98.    
  99.     //software interruption 0x3f here... waiting for mouse click/key press?
  100.    
  101.     black_screen_update_graphics(); //screen fadeout -> go to civilopedia?..
  102.     play_sound(1); //stop current sound?..
  103.     LAB_AI_WONDER_ACTIONS:
  104.     if (wond == W_DARWINS_VOYAGE)
  105.     {
  106.         get_some_civ_advance(civ,0); //0 - source (discovered by civ itself). Always 0 for every call of this function within the program, so this param is useless...
  107.         get_some_civ_advance(civ,0);
  108.     }
  109.     city = 0;
  110.     while (city < 128)
  111.     {
  112.         if (city_flags[city] != -1 //city exists
  113.         && city_civ[city] == human_player_civ
  114.         && city_production[city] == -(24+wond)) //city is building this wonder...
  115.         {
  116.             goto_city_screen(human_player_civ,city); //you should change it...
  117.         }
  118.         city++;
  119.     }
  120.     return;
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement