[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 197 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 179 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.
    • sehr nice!
      und danke für den schnellen support!!

      aber...

      ist es normal daß die Bot-Planeten irgendwann einfach verschwinden, die Bots selbst jedoch noch zu sehen waren im Admin?
      ich hab jetzt mal alle gelöscht und nur einen neuen rein geklickt.

      automatisches löschen bei inaktivität hab ich eigentlich aus.
      evtl. funktioniert bei mir das mit den cronjobs nicht?
      Es zählt nicht wie lang man lebt, sondern wie intensiv.Euer Mond ist meine Sonne, Euer Montag - mein Sonntag.Musik ist Leben!

      ⭐Psy Love Is My Love⭐
    • А у меня вот такая ошибка при попытке создать бота, не могу исправить :(
      Display Spoiler

      USER ERROR
      Message: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS `is_bot` INT DEFAULT 0' at line 1
      File: /includes/classes/Database.class.php
      Line: 247
      URL: test/admin.php?page=EditBots&mode=create_bot
      PHP-Version: 7.3.33
      PHP-API: apache2handler
      2Moons Version: 1.8.git
      Debug Backtrace:
      #0 /includes/classes/Database.class.php(247): PDO->exec('ALTER TABLE `el...')
      #1 /includes/classes/class.BotManager.php(199): Database->query('ALTER TABLE `el...')
      #2 /includes/pages/adm/ShowEditBotsPage.php(81): BotManager->createBot('1', '3')
      #3 /admin.php(211): ShowEditBotsPage()
      #4 {main}

    • I have the following error

      [19-Feb-2025 10:42:12] NOTICE: "Undefined offset: 3"
      File: /www/wwwroot/localhost/includes/classes/cronjob/botsCronjob.class.php | Line: 128
      URL: uni1.xnovawop.com/cronjob.php?cronjobID=10 | Version: 1.81.git
      Stack trace:
      #0 /includes/classes/cronjob/botsCronjob.class.php(128): errorHandler(8, 'Undefined offse...', '/www/wwwroot/un...', 128, Array)
      #1 /includes/classes/Cronjob.class.php(57): botsCronjob->run()
      #2 /cronjob.php(54): Cronjob::execute(10)
      #3 {main}


      line: 128
      foreach ($bot_setting[$value['bot_type']]['ships_array'] as $key => $ship) {
      if ($ship['leave_on_planet'] == 0) {
      $fleet_select_sql .= $ship['name'] . ' , ';
      $fleet_delete_sql .= $ship['name'] . ' = 0 , ';
      }else{//leave % of the ships on the planet, not good cause users can determine the size of the fleet like that, best set to 1
      $fleet_select_sql .= '('. $ship['name'] . ' * '. (1 - $ship['leave_on_planet']) . ') as ' . $ship['name'] . ' , ';
      $fleet_delete_sql .= $ship['name'] . ' = (' . $ship['name'] . ' * '. $ship['leave_on_planet'] . ') , ';
      }
    • Hallo!

      ich bin grad im phpMyAdmin und da fällt mir was ins Auge...

      in der SQL sehe ich grad in "uni1_bot_setting" bei "is_bot" steht "0"


      müsste da nicht ne 1 stehen?

      Es zählt nicht wie lang man lebt, sondern wie intensiv.Euer Mond ist meine Sonne, Euer Montag - mein Sonntag.Musik ist Leben!

      ⭐Psy Love Is My Love⭐