[MOD]2moons-bots

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • [MOD]2moons-bots

      2moons-bots on github

      copy the 5 botfiles
      eidt admin.php, find

      PHP Source Code: admin.php

      1. case 'bans':
      2. include_once('includes/pages/adm/ShowBanPage.php');
      3. ShowBanPage();
      4. break;


      and after it insert

      PHP Source Code: admin.php

      1. case 'EditBots':
      2. include_once('includes/pages/adm/ShowEditBotsPage.php');
      3. ShowEditBotsPage();
      4. break;

      now edits /styles/templates/adm/ShowMenuPage.tpl , add the following line on the position you like

      Smarty-Template: /styles/templates/adm/ShowMenuPage.tpl

      1. {if allowedTo('ShowEditBotsPage')}<li><a href="?page=EditBots" target="Hauptframe">Edit Bots</a></li>{/if}


      now go to admin panel and click on 'edit bots' in the menu
      click "create bot"
      Files
      • 2moons-bots.zip

        (89.16 kB, downloaded 55 times, last: )
    • optimization, optional

      when you have created a bot, the sql tables have been set.
      the bots can be taken out of statsbuilder, this so they can be many but not impressing the serverperformace too much.

      edit
      find this lines

      PHP Source Code: includes/classes/class.statbuilder.php

      1. $Return['Planets'] = $database->select('SELECT SQL_BIG_RESULT DISTINCT '.$select_buildings.' p.id, p.universe, p.id_owner, u.authlevel, u.bana, u.username FROM %%PLANETS%% as p LEFT JOIN %%USERS%% as u ON u.id = p.id_owner;');
      2. $Return['Users'] = $database->select('SELECT SQL_BIG_RESULT DISTINCT '.$selected_tech.$select_fleets.$select_defenses.' u.id, u.ally_id, u.authlevel, u.bana, u.universe, u.username, s.tech_rank AS old_tech_rank, s.build_rank AS old_build_rank, s.defs_rank AS old_defs_rank, s.fleet_rank AS old_fleet_rank, s.total_rank AS old_total_rank FROM %%USERS%% as u LEFT JOIN %%STATPOINTS%% as s ON s.stat_type = 1 AND s.id_owner = u.id LEFT JOIN %%PLANETS%% as p ON u.id = p.id_owner GROUP BY s.id_owner, u.id, u.authlevel;');




      and add where is_bot = 0 to the selection

      PHP Source Code: includes/classes/class.statbuilder.php

      1. $Return['Planets'] = $database->select('SELECT SQL_BIG_RESULT DISTINCT '.$select_buildings.' p.id, p.universe, p.id_owner, u.authlevel, u.bana, u.username FROM %%PLANETS%% as p LEFT JOIN %%USERS%% as u ON u.id = p.id_owner WHERE p.is_bot = 0;');
      2. $Return['Users'] = $database->select('SELECT SQL_BIG_RESULT DISTINCT '.$selected_tech.$select_fleets.$select_defenses.' u.id, u.ally_id, u.authlevel, u.bana, u.universe, u.username, s.tech_rank AS old_tech_rank, s.build_rank AS old_build_rank, s.defs_rank AS old_defs_rank, s.fleet_rank AS old_fleet_rank, s.total_rank AS old_total_rank FROM %%USERS%% as u LEFT JOIN %%STATPOINTS%% as s ON s.stat_type = 1 AND s.id_owner = u.id LEFT JOIN %%PLANETS%% as p ON u.id = p.id_owner WHERE u.is_bot = 0 GROUP BY s.id_owner, u.id, u.authlevel;');
      like this they are not calculated in the statistics


      now we also don't show them in the statistic by changing the sql query in
      find this lines in statsticspage

      PHP Source Code: includes/pages/game/ShowStatisticsPage.class.php

      1. if ($config->stat == 2) {
      2. $sql = "SELECT DISTINCT s.*, u.id, u.username, u.ally_id, a.ally_name FROM %%STATPOINTS%% as s
      3. INNER JOIN %%USERS%% as u ON u.id = s.id_owner
      4. LEFT JOIN %%ALLIANCE%% as a ON a.id = s.id_ally
      5. WHERE s.universe = :universe AND s.stat_type = 1 AND u.authlevel < :authLevel
      6. ORDER BY ".$Order." ASC LIMIT :offset, :limit;";
      7. $query = $db->select($sql, array(
      8. ':universe' => Universe::current(),
      9. ':authLevel'=> $config->stat_level,
      10. ':offset' => $start,
      11. ':limit' => 100,
      12. ));
      13. } else {
      14. $sql = "SELECT DISTINCT s.*, u.id, u.username, u.ally_id, a.ally_name FROM %%STATPOINTS%% as s
      15. INNER JOIN %%USERS%% as u ON u.id = s.id_owner
      16. LEFT JOIN %%ALLIANCE%% as a ON a.id = s.id_ally
      17. WHERE s.universe = :universe AND s.stat_type = 1
      18. ORDER BY ".$Order." ASC LIMIT :offset, :limit;";
      19. $query = $db->select($sql, array(
      20. ':universe' => Universe::current(),
      21. ':offset' => $start,
      22. ':limit' => 100,
      23. ));
      24. }
      Display All
      and add " and is_bot = 0" to their where clauses

      PHP Source Code: includes/pages/game/ShowStatisticsPage.class.php

      1. if ($config->stat == 2) {
      2. $sql = "SELECT DISTINCT s.*, u.id, u.username, u.ally_id, a.ally_name FROM %%STATPOINTS%% as s
      3. INNER JOIN %%USERS%% as u ON u.id = s.id_owner
      4. LEFT JOIN %%ALLIANCE%% as a ON a.id = s.id_ally
      5. WHERE s.universe = :universe AND s.stat_type = 1 AND u.authlevel < :authLevel AND u.is_bot = 0
      6. ORDER BY ".$Order." ASC LIMIT :offset, :limit;";
      7. $query = $db->select($sql, array(
      8. ':universe' => Universe::current(),
      9. ':authLevel'=> $config->stat_level,
      10. ':offset' => $start,
      11. ':limit' => 100,
      12. ));
      13. } else {
      14. $sql = "SELECT DISTINCT s.*, u.id, u.username, u.ally_id, a.ally_name FROM %%STATPOINTS%% as s
      15. INNER JOIN %%USERS%% as u ON u.id = s.id_owner
      16. LEFT JOIN %%ALLIANCE%% as a ON a.id = s.id_ally
      17. WHERE s.universe = :universe AND s.stat_type = 1 AND u.is_bot = 0
      18. ORDER BY ".$Order." ASC LIMIT :offset, :limit;";
      19. $query = $db->select($sql, array(
      20. ':universe' => Universe::current(),
      21. ':offset' => $start,
      22. ':limit' => 100,
      23. ));
      24. }
      Display All
      so thats it for optimasition
    • Dany92 wrote:

      good, now go back to your ghost game
      My ghost game is coming along nicely, by the way. Don't get me started on a subject you don't know much about. Because all your statistics are wrong. In short, I don't care.
      Images
      • Capture d'écran 2025-01-14 160649.png

        1.77 MB, 1,200×879, viewed 69 times
      You can contact me by Discord : danter14
      Discord Galactic Conquest
      Video Youtube dev + tutorials

      Webside
    • the admin panel
      on the first page you see the monthly contingent of resources the bots bring to the universe, in this example there are 3 bottypes wich hav different ress growth and ships.
      this is just so you have an overview what comes into the galaxy,



      on this screen we see the settings of the bottypes, here we can set the behavior of the bots.



      and here we can see the bots themself, how many ships they have, when they land again and so on.


      the bots can not attack, thought about it for a while and i see no benefit in attacking bots for the players. so they can not, but it would not be hard to implement it.
      in my usecase the bots have special ships the players can not build, and by attacing the botfleets they can capture some of the ships defeted.