OF_BASE2.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. //Filename : OF_BASE2.CPP
  21. //Description : Firm Base - part 2, the AI functions
  22. #include <ONATION.h>
  23. #include <OTOWN.h>
  24. #include <OF_BASE.h>
  25. //--------- Begin of function FirmBase::process_ai ---------//
  26. void FirmBase::process_ai()
  27. {
  28. think_assign_unit();
  29. think_invoke_god();
  30. }
  31. //----------- End of function FirmBase::process_ai -----------//
  32. //--------- Begin of function FirmBase::think_assign_unit ---------//
  33. void FirmBase::think_assign_unit()
  34. {
  35. Nation* nationPtr = nation_array[nation_recno];
  36. //-------- assign overseer ---------//
  37. if( info.game_date%15==firm_recno%15 ) // do not call too often because when an AI action is queued, it will take a while to carry it out
  38. {
  39. if( !overseer_recno )
  40. nationPtr->add_action(loc_x1, loc_y1, -1, -1, ACTION_AI_ASSIGN_OVERSEER, FIRM_BASE);
  41. }
  42. //------- recruit workers ---------//
  43. if( info.game_date%15==firm_recno%15 )
  44. {
  45. if( worker_count < MAX_WORKER )
  46. ai_recruit_worker();
  47. }
  48. }
  49. //----------- End of function FirmBase::think_assign_unit -----------//
  50. //--------- Begin of function FirmBase::think_invoke_god ---------//
  51. void FirmBase::think_invoke_god()
  52. {
  53. if( pray_points < MAX_PRAY_POINTS || !can_invoke() )
  54. return;
  55. invoke_god();
  56. }
  57. //----------- End of function FirmBase::think_invoke_god -----------//