Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //CIVDOS AI WONDERS RULES v3
- #define W_DARWINS_VOYAGE 0x0E
- #define W_MANHATTAN_PROJECT 0x11
- #define T_ROCKETRY 0x2E
- void FUN_global_warming_and_ai_wonders()
- {
- //skip some global warming code here...
- counter = 0;
- do
- {
- if (counter > difficulty)
- return;
- wond = 1+random(21); //21 - number of wonders
- //for some reason wonders are counting from 1 and not from 0... (1 = pyramids, 2 = gardens etc.)
- if (difficulty != 0 || check_civ_advance(human_player_civ,wonder_tech[wond]) == 1)
- //on Chieftain difficulty comp. player can build any wonder only if hum. player can build it!
- {
- if (difficulty < 2) //Chieftain or Warlord
- {
- //this loop prohibits AI to build a wonder if human already is building one...
- //but only if it's not Manhattan Project...
- city = 0;
- do
- {
- if (city_civ[city] == human_player_civ
- && city_flags[city] != -1 //city exists
- && city_production[city] == -(24+wond)) //0 is settler, > 0 are units, -1..-24 are used for buildings and SS parts.
- {
- wond = W_MANHATTAN_PROJECT;
- //why not break here though?
- }
- city++;
- }
- while (city < 128);
- }
- city = random(128);
- cit_civ = city_civ[city];
- if (city_flags[city] != -1 //city exists
- && (diplomacy_status[cit_civ][0])&4 == 0 //The civilization is not in anarchy. (third ('ALLY') bit of cit_civ diplomacy with 'barbarians' is 0).
- && (wond != W_MANHATTAN_PROJECT || check_civ_advance(cit_civ,T_ROCKETRY) == 1)) //AI will build Manhattan Proj. only if it can build nukes...
- {
- if (counter == 0
- && check_civ_advance(cit_civ,T_ROCKETRY) == 1 //rocketry is hardcoded, it will not change here if you change prerequisite tech for Nuclear unit...
- && check_civ_advance(human_player_civ,T_ROCKETRY) == 0
- && wonder_city[W_MANHATTAN_PROJECT] == -1) ////Manh. Proj. has never been built before...
- {
- wond = W_MANHATTAN_PROJECT;
- }
- if ((wond != W_MANHATTAN_PROJECT
- || check_civ_advance(human_player_civ,T_ROCKETRY) == 0
- || 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...
- &&
- (cit_civ != -1 && cit_civ != human_player_civ
- && wonder_city[wond] == -1)) //wonder never was built before...
- {
- 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
- && check_civ_advance(cit_civ,wonder_tech_B[wond]) == 1) //alternative place for check. Used only here...
- {
- city_shields_count[city] = 0;
- write_replay_entry(10,2,cit_civ,wond); //10 - event type (wonder). 2 - record length.
- //concatenate some strings for "City (Civilization) builds a wonder" message here...
- var_B = normalize_min_max(civ_gold[cit_civ]/3,0,wonder_shield_rows_cost[wond]*10-city_shields_count[city]);
- //AI actually pays for wonders! But not more than 1/3 of the treasury!
- civ_gold[cit_civ] -= var_B;
- if (gl_debug_flag_A == 1) //some debug flag: no message about wonder and no civ jingle...
- {
- goto LAB_AI_WONDER_ACTIONS;
- }
- play_sound(civ_jingle[cit_civ+2*civ_pair[cit_civ]]);
- if ((diplomacy_status[human_player_civ][cit_civ]&0x40)==0) //you don't have an embassy for cit_civ...
- {
- var_C = 2; //Travellers report:
- }
- else
- {
- var_C = 5; //Foreign Minister:
- }
- gl_message_type = var_C;
- var_C = 80;
- goto LAB_WONDER_MESSAGE;
- }
- }
- }
- }
- counter++;
- }
- while (1);
- //actually these labels are within some IF block in global warming logic.
- LAB_WONDER_MESSAGE:
- draw_message_function(curr_string,100,var_C); //draw message x: 100, y: 80?
- //software interruption 0x3f here... waiting for mouse click/key press?
- black_screen_update_graphics(); //screen fadeout -> go to civilopedia?..
- play_sound(1); //stop current sound?..
- LAB_AI_WONDER_ACTIONS:
- if (wond == W_DARWINS_VOYAGE)
- {
- 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...
- get_some_civ_advance(civ,0);
- }
- city = 0;
- while (city < 128)
- {
- if (city_flags[city] != -1 //city exists
- && city_civ[city] == human_player_civ
- && city_production[city] == -(24+wond)) //city is building this wonder...
- {
- goto_city_screen(human_player_civ,city); //you should change it...
- }
- city++;
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement