[MOD] random planet count in system

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

    • [MOD] random planet count in system

      Простенькая реализация идеи рандомного количества планет в системе.

      add in config.php

      PHP Source Code: config.php

      1. define('GALAXYSALT', '#ItN:OD;c'); // any salt
      2. define('MINPLANET', 3);
      3. define('MAXPLANET', 12);
      add in GeneralFunctions.php

      PHP Source Code: GeneralFunctions.php

      1. function getGlPlanetCount($galaxy, $system) {
      2. $sha1 = hash("sha1", GALAXYSALT.$galaxy.GALAXYSALT.$system);
      3. $numhash = unpack('n1', $sha1)[1];
      4. return randNum($numhash) + MINPLANET;
      5. }
      6. function randNum($number){
      7. $number = strval($number);
      8. $sum = 0;
      9. for($i = 0; $i < strlen($number); $i++) {
      10. $sum += $number[$i];
      11. }
      12. if($sum > MAXPLANET - MINPLANET)
      13. $sum = randNum($sum);
      14. return $sum;
      15. }
      Display All
      in PlayerUtil.class.php find


      PHP Source Code

      1. $position = mt_rand(round($config->max_planets * 0.2), round($config->max_planets * 0.8));
      change to


      PHP Source Code

      1. $position = mt_rand(1, getGlPlanetCount($galaxy, $system));


      find

      PHP Source Code

      1. || $config->max_planets < $position);
      change to


      PHP Source Code

      1. || getGlPlanetCount($galaxy, $system) < $position);


      find

      PHP Source Code

      1. $dataIndex = (int) ceil($position / ($config->max_planets / count($planetData)));
      change to


      PHP Source Code

      1. $dataIndex = (int) ceil($position / (getGlPlanetCount($galaxy, $system) / count($planetData)));


      in ShowGalaxyPage.class.php
      find

      PHP Source Code

      1. 'max_planets' => $config->max_planets,
      change to


      PHP Source Code

      1. 'max_planets' => getGlPlanetCount($galaxy, $system),


      find

      PHP Source Code

      1. $planet = min(max(HTTP::_GP('planet', (int) $PLANET['planet']), 1), $config->max_planets);
      change to

      PHP Source Code

      1. $planet = min(max(HTTP::_GP('planet', (int) $PLANET['planet']), 1), getGlPlanetCount($galaxy, $system));
      in ShowCreatorPage.php find all

      Source Code

      1. $config->max_planets
      and change to


      PHP Source Code

      1. getGlPlanetCount($Galaxy, $System)
      in class.FleetFunctions.php find

      PHP Source Code

      1. if ($MissionInfo['planet'] == (Config::get($USER['universe'])->max_planets + 1) && isModuleAvailable(MODULE_MISSION_EXPEDITION))
      change to

      PHP Source Code

      1. if ($MissionInfo['planet'] == (getGlPlanetCount($MissionInfo['galaxy'], $MissionInfo['system']) + 1) && isModuleAvailable(MODULE_MISSION_EXPEDITION))
      in ShowFleetStep1Page.class.php find
      if ($targetPlanet != Config::get()->max_planets + 1)
      change to
      if ($targetPlanet != getGlPlanetCount($targetGalaxy, $targetSystem) + 1)


      если у вас еще где то есть

      PHP Source Code

      1. $config->max_planets
      то поменяйте его как сделано выше


      Устанавливайте мод только в пустых серверах или переносите вручную планеты. Мод только как пример, можете модифицировать под свои нужды

      The post was edited 2 times, last by Kaizoku ().

    • Проверю на баги на своей версии)
      Пока все нравится, думаю установлю на New-Star
    • UPDATE
      in PlayerUtil.class.php
      find

      Source Code

      1. do {
      2. $position = mt_rand(1, getGlPlanetCount($galaxy, $system));
      3. if ($planet < 3) {
      4. $planet += 1;
      5. } else {
      6. if ($system >= $config->max_system) {
      7. $system = 1;
      8. if($galaxy >= $config->max_galaxy) {
      9. $galaxy = 1;
      10. } else {
      11. $galaxy += 1;
      12. }
      13. } else {
      14. $system += 1;
      15. }
      16. }
      17. } while (self::isPositionFree($universe, $galaxy, $system, $position) === false);
      Display All

      change to

      PHP Source Code

      1. do {
      2. if ($planet < 3) {
      3. $planet += 1;
      4. } else {
      5. if ($system >= $config->max_system) {
      6. $system = 1;
      7. if($galaxy >= $config->max_galaxy) {
      8. $galaxy = 1;
      9. } else {
      10. $galaxy += 1;
      11. }
      12. } else {
      13. $system += 1;
      14. }
      15. }
      16. $position = mt_rand(1, getGlPlanetCount($galaxy, $system));
      17. } while (self::isPositionFree($universe, $galaxy, $system, $position) === false);
      Display All
    • UPDATE

      change

      PHP Source Code: PlayerUtil.class.php

      1. $dataIndex = (int) ceil($position / (getGlPlanetCount($galaxy, $system) / count($planetData)));

      to

      PHP Source Code

      1. $dataIndex = (int) ceil(($position / getGlPlanetCount($galaxy, $system)) * count($planetData));
    • yamilrh wrote:

      que no entiendo lo que haría este mod, puedes mostrar una imagen?
    • ahhhhhhhhh, jajaja me gusta, ta interesante lo que hiciste.. Gracias por el aporte... ahora me surge una duda si la galaxia tiene 4 planetas nada mas, entonces como seria la temperatura la misma como si tuviera los 16, o simplemente el ultimo adquiere la temperatura del 16
      VERY SAD :/ :/ :/ :/
    • yamilrh wrote:

      ahhhhhhhhh, jajaja me gusta, ta interesante lo que hiciste.. Gracias por el aporte... ahora me surge una duda si la galaxia tiene 4 planetas nada mas, entonces como seria la temperatura la misma como si tuviera los 16, o simplemente el ultimo adquiere la temperatura del 16
      4 планета будет холодной
      1 планета горячей
    • отличное дополнение с не большими у меня правками работает отлично но увы у меня двиг сильно переписан
      Делаю качественно в сроки! на любой версии moons, встрою, или напишу любой мод , но дорого! afire-space.com
    • 'planetcount'=> sprintf($LNG['gl_populed_planets'], count($Result)),
      У меня ругается на эту строку 80

      WARNING
      Message: count(): Parameter must be an array or an object that implements Countable
      File: /includes/pages/game/ShowGalaxyPage.class.php
      Line: 80
    • vova_barmoley wrote:

      'planetcount'=> sprintf($LNG['gl_populed_planets'], count($Result)),
      У меня ругается на эту строку 80

      WARNING
      Message: count(): Parameter must be an array or an object that implements CountableFile: /includes/pages/game/ShowGalaxyPage.class.php
      Line: 80

      это не из за мода
    • vova_barmoley wrote:

      У меня версия 1.8 и php 7.3, но обычная галактика переключалась.
      откатись и перепроверь и обычная будет выдавать ошибку, когда нету заселенных планет
    • А где поправить что бы максимальное количество планет было определенное? А то как то скачет интересно :)