Loading

busybee subsidy reward fo

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

Comments