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 ().