Loading

busybeesubsidypatch

  1. diff --git a/company.nut b/company.nut
  2. index 58e8d45..1546680 100644
  3. --- a/company.nut
  4. +++ b/company.nut
  5. @@ -25,7 +25,9 @@ class CompanyGoal {
  6.      delivered_amount = 0; // Amount delivered so far.
  7.      goal_id = null;       // Number of the goal in OpenTTD goal window.
  8.      timeout = null;       // Timeout in ticks before the goal becomes obsolete.
  9. -
  10. +    reward = 0;    // reward for reached goal (makes this come closer to subsidies)
  11. +    subsidyfactor = GSController.GetSetting("subsidy_factor");
  12. +    
  13.      displayed_string = null;
  14.      displayed_count = null;
  15.  
  16. @@ -38,6 +40,7 @@ class CompanyGoal {
  17.          this.cargo = cargo;
  18.          this.accept = accept;
  19.          this.wanted_amount = wanted_amount;
  20. +        this.reward = this.wanted_amount * subsidyfactor; // estimated factor, better would be a random value
  21.          this.ResetTimeout();
  22.  
  23.          // Construct goal if a company id was provided.
  24. @@ -48,17 +51,22 @@ class CompanyGoal {
  25.                  destination_string = GSText(GSText.STR_TOWN_NAME, destination);
  26.                  destination_string_news = GSText(GSText.STR_TOWN_NAME_NEWS, destination);
  27.                  goal_type = GSGoal.GT_TOWN;
  28. +                this.reward = this.reward * 2; // for town goals, multiply reward
  29.              } else {
  30.                  destination = accept.ind;
  31.                  destination_string = GSText(GSText.STR_INDUSTRY_NAME, destination);
  32.                  destination_string_news = GSText(GSText.STR_INDUSTRY_NAME_NEWS, destination);
  33.                  goal_type = GSGoal.GT_INDUSTRY;
  34.              }
  35. -            local goal_text = GSText(GSText.STR_COMPANY_GOAL, cargo.cid,
  36. -                                     this.wanted_amount, destination_string);
  37. +            local goal_text, goal_news_text;
  38. +            if (this.reward > 0) {
  39. +              goal_text      = GSText(GSText.STR_COMPANY_GOAL_REWARD,      cargo.cid, this.wanted_amount, destination_string,      this.reward);
  40. +              goal_news_text = GSText(GSText.STR_COMPANY_GOAL_REWARD_NEWS, cargo.cid, this.wanted_amount, destination_string_news, this.reward);
  41. +            } else {
  42. +              goal_text      = GSText(GSText.STR_COMPANY_GOAL,      cargo.cid, this.wanted_amount, destination_string);
  43. +              goal_news_text = GSText(GSText.STR_COMPANY_GOAL_NEWS, cargo.cid, this.wanted_amount, destination_string_news);
  44. +            }
  45.              this.goal_id = GSGoal.New(comp_id, goal_text, goal_type, destination);
  46. -            local goal_news_text = GSText(GSText.STR_COMPANY_GOAL_NEWS, cargo.cid,
  47. -                                     this.wanted_amount, destination_string_news);
  48.              this.PublishNews(goal_news_text, comp_id);
  49.          }
  50.      }
  51. @@ -90,7 +98,7 @@ function CompanyGoal::ResetTimeout()
  52.  function CompanyGoal::SaveGoal()
  53.  {
  54.      return {cid=this.cargo.cid, accept=this.accept, wanted=this.wanted_amount,
  55. -            delivered=this.delivered_amount, goal=this.goal_id, timeout=this.timeout};
  56. +            delivered=this.delivered_amount, goal=this.goal_id, timeout=this.timeout, reward=this.reward};
  57.  }
  58.  
  59.  // Load an existing goal.
  60. @@ -106,6 +114,7 @@ function CompanyGoal::LoadGoal(loaded_data, cargoes)
  61.              goal.delivered_amount = loaded_data.delivered;
  62.              goal.goal_id = loaded_data.goal;
  63.              goal.timeout = loaded_data.timeout;
  64. +            goal.reward = loaded_data.reward;
  65.              return goal;
  66.          }
  67.      }
  68. @@ -151,8 +160,12 @@ function CompanyGoal::UpdateDelivered(mon, comp_id)
  69.                  } else {
  70.                      destination_string_news = GSText(GSText.STR_INDUSTRY_NAME_NEWS, this.accept.ind);
  71.                  }
  72. -                local goal_won_news = GSText(GSText.STR_COMPANY_GOAL_WON_NEWS, cargo.cid,
  73. -                                         this.wanted_amount, destination_string_news);
  74. +                local goal_won_news;
  75. +                if (this.reward > 0) {
  76. +                  goal_won_news = GSText(GSText.STR_COMPANY_GOAL_REWARD_WON_NEWS, cargo.cid, this.wanted_amount, destination_string_news, this.reward);
  77. +                } else {
  78. +                  goal_won_news = GSText(GSText.STR_COMPANY_GOAL_WON_NEWS,        cargo.cid, this.wanted_amount, destination_string_news);
  79. +                }
  80.                  this.PublishNews(goal_won_news, comp_id);
  81.              } else {
  82.                  perc = 100 * this.delivered_amount / this.wanted_amount;
  83. @@ -512,7 +525,8 @@ function CompanyData::CheckAndFinishGoals()
  84.          if (goal == null) continue;
  85.          if (goal.CheckFinished()) {
  86.              goal.FinalizeGoal();
  87. -            this.active_goals[num] = null;
  88. +       GSCompany.ChangeBankBalance(this.comp_id, goal.reward, 0);
  89. +       this.active_goals[num] = null;
  90.          }
  91.      }
  92.  }
  93. diff --git a/info.nut b/info.nut
  94. index ffd048e..e0dde37 100644
  95. --- a/info.nut
  96. +++ b/info.nut
  97. @@ -21,13 +21,13 @@ SAVEGAME_VERSION <- 2; // Set manually if/when save games break.
  98.  MINCOMPATIBLE_SAVEGAME_VERSION <- 2; // cset: bf1430b223d5df73a0c6ba9c996594a77d497cf1
  99.  
  100.  PROGRAM_VERSION <- 5538;
  101. -PROGRAM_DATE <- "2015-03-01";
  102. -PROGRAM_NAME <- "BusyBee RC2M";
  103. +PROGRAM_DATE <- "2015-06-12";
  104. +PROGRAM_NAME <- "BusyBee RC2M with reward";
  105.  
  106.  class BusyBeeInfo extends GSInfo {
  107. -    function GetAuthor()        { return "alberth & andythenorth"; }
  108. -    function GetName()          { return "Busy Bee"; } // Old: return PROGRAM_NAME;
  109. -    function GetDescription()   { return "Make connection, transport cargo"; }
  110. +    function GetAuthor()        { return "alberth & andythenorth, reward by jottyfan"; }
  111. +    function GetName()          { return "Busy Bee Reward"; } // Old: return PROGRAM_NAME;
  112. +    function GetDescription()   { return "Make connection, transport cargo, recieve reward"; }
  113.      function GetVersion()       { return PROGRAM_VERSION + SAVEGAME_VERSION * 100000; }
  114.      function GetDate()          { return PROGRAM_DATE; }
  115.      function CreateInstance()   { return "BusyBeeClass"; }
  116. @@ -85,6 +85,15 @@ function BusyBeeInfo::GetSettings()
  117.                         hard_value=1,
  118.                         custom_value=1,
  119.                         flags=GSInfo.CONFIG_INGAME});
  120. +    GSInfo.AddSetting({name="subsidy_factor",
  121. +                                    description="Factor to be multiplied with cargo amount as reward",
  122. +                                    min_value=0,
  123. +                                    max_value=99,
  124. +                                    easy_value=3,
  125. +                                    medium_value=2,
  126. +                                    hard_value=1,
  127. +                                    custom_value=0,
  128. +                                    flags=GSInfo.CONFIG_INGAME});
  129.  }
  130.  
  131.  RegisterGS(BusyBeeInfo());
  132. diff --git a/lang/english.txt b/lang/english.txt
  133. index c9e3eeb..ca6602d 100644
  134. --- a/lang/english.txt
  135. +++ b/lang/english.txt
  136. @@ -1,8 +1,11 @@
  137.  ##plural 0
  138.  
  139. -STR_COMPANY_GOAL            :Deliver {GOLD}{CARGO_LONG} {ORANGE}to {STRING}
  140. +STR_COMPANY_GOAL_REWARD     :Deliver {GOLD}{CARGO_LONG} {ORANGE}to {STRING}{ORANGE} for {WHITE}{STRING}{CURRENCY_LONG}
  141. +STR_COMPANY_GOAL            :Deliver {GOLD}{CARGO_LONG} {ORANGE}to {STRING}{ORANGE}
  142. +STR_COMPANY_GOAL_REWARD_NEWS:New goal! Deliver {CARGO_LONG} to {STRING} for {STRING}{CURRENCY_LONG}
  143.  STR_COMPANY_GOAL_NEWS       :New goal! Deliver {CARGO_LONG} to {STRING}
  144.  STR_PROGRESS                :{YELLOW}{NUM}% {ORANGE}done
  145. +STR_COMPANY_GOAL_REWARD_WON_NEWS:Goal won! {CARGO_LONG} delivered to {STRING} and earned {STRING}{CURRENCY_LONG}
  146.  STR_COMPANY_GOAL_WON_NEWS   :Goal won! {CARGO_LONG} delivered to {STRING}
  147.  STR_TIMEOUT_YEARS           :{GOLD}{NUM} {ORANGE}year{P "" s} remaining
  148.  STR_TIMEOUT_MONTHS          :{GOLD}{NUM} {ORANGE}month{P "" s} remaining
  149. diff --git a/lang/german.txt b/lang/german.txt
  150. index 546806d..cd9d61a 100644
  151. --- a/lang/german.txt
  152. +++ b/lang/german.txt
  153. @@ -1,8 +1,11 @@
  154.  ##plural 0
  155.  
  156. -STR_COMPANY_GOAL            :Liefere {GOLD}{CARGO_LONG} {ORANGE}nach {STRING}
  157. +STR_COMPANY_GOAL_REWARD     :Lieferung von {GOLD}{CARGO_LONG} {ORANGE}nach {STRING}{ORANGE} bringt {WHITE}{STRING}{CURRENCY_LONG} {ORANGE}ein
  158. +STR_COMPANY_GOAL            :Lieferung von {GOLD}{CARGO_LONG} {ORANGE}nach {STRING}{GOLD}
  159. +STR_COMPANY_GOAL_REWARD_NEWS:Neues Ziel! Liefere {CARGO_LONG} nach {STRING} für {STRING}{CURRENCY_LONG}
  160.  STR_COMPANY_GOAL_NEWS       :Neues Ziel! Liefere {CARGO_LONG} nach {STRING}
  161.  STR_PROGRESS                :{YELLOW}{NUM}% {ORANGE}erreicht
  162. +STR_COMPANY_GOAL_REWARD_WON_NEWS:Ziel erreicht! {CARGO_LONG} nach {STRING} geliefert und {STRING}{CURRENCY_LONG} kassiert
  163.  STR_COMPANY_GOAL_WON_NEWS   :Ziel erreicht! {CARGO_LONG} nach {STRING} geliefert
  164.  STR_TIMEOUT_YEARS           :{GOLD}{NUM} {ORANGE}Jahr{P "" e} verbleib{P t en}
  165.  STR_TIMEOUT_MONTHS          :{GOLD}{NUM} {ORANGE}Monat{P "" e} verbleib{P t en}

Comments