//--------- Begin of function FirmMarket::disp_income ---------// // // Display monthly expense information. // void FirmMarket::disp_income(int dispY1, int refreshFlag) { // int x2 = font_snds.put( INFO_X1+26, INFO_Y1+21, "Yearly Income" ) + 12; // x2 = font_snds.put( x2, INFO_Y1+21, (int) income_365days() ); font_snds.put( INFO_X1+26, INFO_Y1+21, text_firm.str_yearly_income((int) income_365days()) ); }
//----- Begin of function Nation::think_surrender -----// // int Nation::think_surrender() { //--- don't surrender if the nation still has a town ---// int rc=0; if( total_population == 0 ) rc = 1; if( cash <= 0 && income_365days()==0 ) rc = 1; if( !rc ) return 0; //---- see if there is any nation worth getting our surrender ---// Nation* nationPtr; int curRating, bestRating=0, bestNationRecno=0; if( !king_unit_recno ) // if there is no successor to the king, the nation will tend more to surrender bestRating = -100; for( int i=nation_array.size() ; i>0 ; i-- ) { if( nation_array.is_deleted(i) || i==nation_recno ) continue; nationPtr = nation_array[i]; if( nationPtr->cash <= 300 ) // don't surrender to an ecnomically handicapped nation continue; curRating = ai_surrender_to_rating(i); //--- if the nation will tend to surrender if there is only a small number of units left ---// curRating += 50 - total_unit_count*5; if( curRating > bestRating ) { bestRating = curRating; bestNationRecno = i; } } //---------------------------------------// if( bestNationRecno ) { surrender(bestNationRecno); return 1; } return 0; }
int Nation::think_attack_monster() { if( config.monster_type == OPTION_MONSTER_NONE ) // no monsters in the game return 0; //--- if the AI has run out of money and is currently cheating, it will have a urgent need to attack monsters to get money ---// int useAllCamp = income_365days(INCOME_CHEAT) > 0; if( !useAllCamp ) // use all camps to attack the monster { if( !is_at_war() ) { if( cash < 500 && military_rank_rating() >= 75-pref_attack_monster/4 ) // 50 to 75 useAllCamp = 1 ; } } if( !useAllCamp ) { if( military_rank_rating() < 50-pref_attack_monster/4 ) // don't attack if the military strength is too low, 25 to 50 return 0; } //------- select a monster target ---------// int targetCombatLevel; int targetFirmRecno = think_monster_target(targetCombatLevel); if( !targetFirmRecno ) return 0; targetCombatLevel = targetCombatLevel * 150 / 100; // X 150% //--- we need to use veteran soldiers to attack powerful monsters ---// FirmMonster* targetFirm = (FirmMonster*) firm_array[targetFirmRecno]; int monsterLevel = monster_res[targetFirm->monster_id]->level; int attackerMinCombatLevel = 0; if( targetCombatLevel > 100 ) // if the nation's cash runs very low, it will attack anyway attackerMinCombatLevel = 20 + monsterLevel*3; //--- call ai_attack_target() to attack the target town ---// return ai_attack_target(targetFirm->loc_x1, targetFirm->loc_y1, targetCombatLevel, 0, 0, attackerMinCombatLevel, 0, useAllCamp ); }