[MOD] Fast Building From Queue for Shipyard [Not finished]

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

  • [MOD] Fast Building From Queue for Shipyard [Not finished]

    Hello, this post is under development.
    This is not Instant Buy buildings/research/ships/defenses
    This MOD enable function 'FastBuildingFromQueue' like Buildings and Research to setup time queue in 0, its mean finish time to build ships / defenses /missiles

    includes\pages\game\ShowShipyardPage.class.php
    ADD this function, no replace:

    PHP Source Code

    1. //instant build ships/defenses/missiles
    2. private function FastBuildingFromQueue()
    3. {
    4. global $PLANET, $USER, $resource;
    5. $CurrentQueue = unserialize($PLANET['b_hangar_id']);
    6. if (empty($CurrentQueue)){
    7. $PLANET['b_hangar_id'] = '';
    8. $PLANET['b_hangar'] = 0;
    9. return;
    10. }
    11. $Element = $CurrentQueue[0][0];
    12. $BuildMode = $CurrentQueue[0][4];
    13. $fast = $resource[$Element];
    14. $NeededDm = 10 + ((400*($PLANET['b_hangar']-TIMESTAMP))/3600);
    15. if($NeededDm < 10)
    16. $NeededDm=10;
    17. if ($USER['darkmatter'] >= $NeededDm){
    18. $USER['darkmatter'] -= $NeededDm;
    19. Database::get()->update($sql, array(':planetId' => $PLANET['id']));
    20. array_shift($CurrentQueue);
    21. if (count($CurrentQueue) == 0) {
    22. $PLANET['b_hangar'] = 0;
    23. $PLANET['b_hangar_id'] = '';
    24. }else{
    25. $BuildEndTime = TIMESTAMP;
    26. $NewQueueArray = array();
    27. foreach($CurrentQueue as $ListIDArray) {
    28. $BuildEndTime += BuildFunctions::getBuildingTime($USER, $PLANET, $ListIDArray[0], NULL, $ListIDArray[4] == 'destroy');
    29. $ListIDArray[3] = $BuildEndTime;
    30. $NewQueueArray[] = $ListIDArray;
    31. }
    32. if(!empty($NewQueueArray)) {
    33. $PLANET['b_EndTime'] = TIMESTAMP;
    34. $PLANET['b_EndTime_id'] = serialize($NewQueueArray);
    35. $this->ecoObj->setData($USER, $PLANET);
    36. $this->ecoObj->SetNextQueueElementOnTop();
    37. list($USER, $PLANET) = $this->ecoObj->getData();
    38. }else{
    39. $PLANET['b_EndTime'] = 0;
    40. $PLANET['b_EndTime_id'] = '';
    41. }
    42. }
    43. return true;
    44. }
    45. }
    Display All
    Find:

    PHP Source Code

    1. 'BuildList' => $Buildlist,
    2. 'maxlength' => strlen(Config::get()->max_fleet_per_build),
    Replace:

    PHP Source Code

    1. 'BuildList' => $Buildlist,
    2. 'need_dm' => floor(10 + ((400*($PLANET['b_hangar']-TIMESTAMP))/3600)),
    3. 'maxlength' => strlen(Config::get()->max_fleet_per_build),
    styles\theme\nsc\templates\game\page.shipyard.default.tpl
    Find:

    PHP Source Code

    1. <div class="element_row {if $List@first}active_row{/if}" style="background:url({$dpath}gebaeude/{$ID}.gif)">
    2. <div class="right_hand">
    3. {if $List@first}
    4. <span class="onlistretit">{$LNG.tech.{$ID}}</span>
    5. <form action="game.php?page=shipyard&mode={$mode}" method="post" class="build_form">
    6. <input type="hidden" name="action" value="delete">
    7. <input type="hidden" name="auftr[]" value="{$List@iteration - 1}">
    8. <button type="submit" class="del tooltip" data-tooltip-content="{$LNG.bd_cancel_warning}"></button>
    9. </form>
    10. {else}
    Replace:

    PHP Source Code

    1. {if $List@first}
    2. <span class="onlistretit">{$LNG.tech.{$ID}}</span>
    3. <form action="game.php?page=shipyard&mode={$mode}" method="post" class="build_form">
    4. <input type="hidden" name="action" value="delete">
    5. <input type="hidden" name="auftr[]" value="{$List@iteration - 1}">
    6. <button type="submit" class="del tooltip" data-tooltip-content="{$LNG.bd_cancel_warning}"></button>
    7. </form>
    8. <form action="game.php?page=shipyard" method="post" class="build_form">
    9. <input type="hidden" name="queuetype" value="1">
    10. <input type="hidden" name="cmd" value="fast">
    11. <button type="submit" class="build_submit onlist tooltip" data-tooltip-content="{$LNG.cost} {if $need_dm<10}{10}{else}{shortly_number($need_dm)}{/if} {$LNG.tech.921}" style="float: right; line-height: 43px;">
    12. <img src="{$dpath}img/iconav/up.png" alt="" width="16" height="16">
    13. </button>
    14. </form>
    15. {else}
    Display All
    Thank you @Songoku for help with this MOD.

    Regards.
    Images
    • image_2024-07-21_112912893.png

      55.49 kB, 545×204, viewed 156 times

    The post was edited 11 times, last by Zuno ().




  • I did the integration, everything is ok, just finish quickly, it is not active, the page just refreshes.

    and also
    When you produce 1 unit, it requires 10 dark matter, this is very normal and nice.

    When you produce 1000 units, it requires 10 dark matter and the amount does not increase.
  • Zeus wrote:




    I did the integration, everything is ok, just finish quickly, it is not active, the page just refreshes.

    and also
    When you produce 1 unit, it requires 10 dark matter, this is very normal and nice.

    When you produce 1000 units, it requires 10 dark matter and the amount does not increase.
    Yes, amount increase is easy, hard part is decreased time to 0 because a lot of conditions about shipyard, type of ship or defense, etc

    I hope this night do that, maybe in this hours someone can suggest a better way.

    Regards.
  • I think there is something missing from your main class, as on line 20 you have : Database::get()->update($sql, array(':planetId' => $PLANET['id']));
    but $sql is not defined :) This is why just the refresh happens without doing anything xd
  • dany88 wrote:

    @Zuno is finished ?
    No, il try to finish now, Also Thank you @Songoku you are right, i was thinking in shipyard.js of course wrong, its in php.

    I try this function, but still not works.


    PHP Source Code

    1. private function FastBuildingFromQueue()
    2. {
    3. global $PLANET, $USER, $resource;
    4. $CurrentQueue = unserialize($PLANET['b_hangar_id']);
    5. if (empty($CurrentQueue)){
    6. $PLANET['b_hangar_id'] = '';
    7. $PLANET['b_hangar'] = 0;
    8. return;
    9. }
    10. $Element = $CurrentQueue[0][0];
    11. $BuildMode = $CurrentQueue[0][4];
    12. $fast = $resource[$Element];
    13. $NeededDm = 10 + ((400*($PLANET['b_hangar_id']-TIMESTAMP))/3600);
    14. if($NeededDm < 10)
    15. $NeededDm=10;
    16. if ($USER['darkmatter'] >= $NeededDm){
    17. $USER['darkmatter'] -= $NeededDm;
    18. if ($BuildMode == 'destroy'){
    19. $PLANET['b_hangar'] -=1;
    20. $PLANET[$resource[$Element]] -= 1;
    21. $sql = "UPDATE %%PLANETS%% SET ".$fast." = ".$fast." - 1 WHERE id = :planetId;";
    22. }
    23. else{
    24. $PLANET['b_hangar'] +=1;
    25. $PLANET[$resource[$Element]] += 1;
    26. $sql = "UPDATE %%PLANETS%% SET ".$fast." = ".$fast." + 1 WHERE id = :planetId;";
    27. }
    28. Database::get()->update($sql, array(':planetId' => $PLANET['id']));
    29. array_shift($CurrentQueue);
    30. if (count($CurrentQueue) == 0) {
    31. $PLANET['b_hangar'] = 0;
    32. $PLANET['b_hangar_id'] = '';
    33. }else{
    34. $BuildEndTime = TIMESTAMP;
    35. $NewQueueArray = array();
    36. foreach($CurrentQueue as $ListIDArray) {
    37. $BuildEndTime += BuildFunctions::getBuildingTime($USER, $PLANET, $ListIDArray[0], NULL, $ListIDArray[4] == 'destroy');
    38. $ListIDArray[3] = $BuildEndTime;
    39. $NewQueueArray[] = $ListIDArray;
    40. }
    41. if(!empty($NewQueueArray)) {
    42. $PLANET['b_hangar'] = TIMESTAMP;
    43. $PLANET['b_hangar_id'] = serialize(array_values($ElementQueue));
    44. $this->ecoObj->setData($USER, $PLANET);
    45. $this->ecoObj->SetNextQueueElementOnTop();
    46. list($USER, $PLANET) = $this->ecoObj->getData();
    47. }else{
    48. $PLANET['b_hangar'] = 0;
    49. $PLANET['b_hangar_id'] = '';
    50. }
    51. }
    52. return true;
    53. }
    54. }
    Display All
    Maybe some one can help us or tomorrow i will try again.

    Regards.

    The post was edited 3 times, last by Zuno ().