How can I create a new temporary bonus

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

    • It's easy peasy.

      "/* [...] */ " means there are data inside array or php code before, so I am skipping to save you lines. If you see something already exists, like 'MoreFound', is intentional, it means you add after this line.

      SQL

      SQL-Query

      1. ALTER TABLE uni1_vars ADD `bonusFleetCost` float(4,2) NOT NULL DEFAULT '0', `bonusFleetCostUnit` smallint(1) NOT NULL DEFAULT '0';

      Varsbuildcache.php

      PHP Source Code

      1. $pricelist[$varsRow['elementID']] = array(
      2. /* [...] */
      3. 'bonus' => array(
      4. /* [...] */
      5. 'MoreFound' => array($varsRow['bonusMoreFound'], $varsRow['bonusMoreFoundUnit']),
      6. 'FleetCost' => array($varsRow['bonusFleetCost'], $varsRow['bonusFleetCostUnit']),
      7. ),
      8. );
      9. /* [...] */
      10. if (($varsRow['bonusAttack'] + /* [...] */ + $varsRow['bonusFleetCost']) != 0) { $reslist['bonus'][] = $varsRow['elementID']; }
      Display All

      class.BuildFunctions.php

      PHP Source Code

      1. static $bonusList = array(
      2. 'Attack',
      3. /* [...] */
      4. /* [...] */ 'MoreFound',
      5. 'FleetCost',
      6. );
      7. /* [...] */
      8. public static function getElementPrice($USER, $PLANET, $Element, $forDestroy = false, $forLevel = NULL, $Multiplier = 1)
      9. {
      10. /* [...] */
      11. foreach ($reslist['ressources'] as $resType) {
      12. /* [...] */
      13. if ($forDestroy === true) {
      14. $price[$resType] /= 2;
      15. }
      16. if (in_array($Element, $reslist['fleet'])) {
      17. $price[$resType] *= (1 + $USER['factor']['FleetCost']);
      18. }
      19. }
      20. return $price;
      21. }
      Display All

      CUSTOM.php

      PHP Source Code

      1. $LNG['bonus']['FleetCost'] = "Fleet cost";

      Now, an officier with bonusFleetCost -0.05 means ship are 5% cheaper.

      Do not forget to clear cache.

      Clean, beautiful, and you don't use primitive code full of "foreach"'es or "if"'s, instead, you use 2moons existing core code.
      Looking for good VPS to host your game? Use DigitalOcean and get 100$ bonus credit for 2 months!

      Check my mods here - stellaron.space/index.php?page=2Moons

      I can build any mod. Need my service? Contact me via PM

      The post was edited 1 time, last by Qwa ().

    • The occurrence is good.
      But I would like to make ships and defenses available in the hangar for a limited time, say they will be available only on holidays or specific dates.
      How can I do this using the existing code already in 2moons.
    • Skylon wrote:

      The occurrence is good.
      But I would like to make ships and defenses available in the hangar for a limited time, say they will be available only on holidays or specific dates.
      How can I do this using the existing code already in 2moons.

      uni1_vars_requriements for help

      elementID - ship id
      requireID - bonus/officier id
    • It is not exactly what I want to do.
      It is not a dependency of officers, but an event dependency.
      For example, I want a new ship to be available on Christmas December 25, but after that day, it is no longer available in the hangar.
      Initially consider modifying the isElementBuyable function.
    • В идеале вам надо много поправить в moons, но мой совет пишите свой мод.. желательно не использовать крон можно без него обойтись.. где поставлены условия выполнения того что вам надо выдать.. я так сделал награды пользователю за что либо - постоянные и временные, включая получения ключ столицы после достижения 3 лвл мирного опыта .. изначально две луны не предназначены для многих решений включая анимационную боевку и что то менять глобально надо менять подход и ядро самого движка но в вашем случае просто
      Делаю качественно в сроки! на любой версии moons, встрою, или напишу любой мод , но дорого! afire-space.com
    • Skylon wrote:

      It is not exactly what I want to do.
      It is not a dependency of officers, but an event dependency.
      For example, I want a new ship to be available on Christmas December 25, but after that day, it is no longer available in the hangar.
      Initially consider modifying the isElementBuyable function.
      what kaizoku suggested works.

      You can create a ship now with requirement of something impossible (like shipyard lvl 255). When the event starts remove the requirement and when it ends add it again.

      This is easily managed with cronjob so you do not have to worry.
      Looking for good VPS to host your game? Use DigitalOcean and get 100$ bonus credit for 2 months!

      Check my mods here - stellaron.space/index.php?page=2Moons

      I can build any mod. Need my service? Contact me via PM