diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d8fe4fa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/.project
diff --git a/company.nut b/company.nut
index 58e8d45..63634a9 100644
--- a/company.nut
+++ b/company.nut
@@ -25,7 +25,11 @@ class CompanyGoal {
delivered_amount = 0; // Amount delivered so far.
goal_id = null; // Number of the goal in OpenTTD goal window.
timeout = null; // Timeout in ticks before the goal becomes obsolete.
-
+ reward = 0; // reward for reached goal (makes this come closer to subsidies)
+ subsidyfactor = GSController.GetSetting("subsidy_factor") * 20;
+ rewardfactor_town = GSController.GetSetting("rewardfactor_town");
+ rewardfactor_ind = GSController.GetSetting("rewardfactor_ind");
+
displayed_string = null;
displayed_count = null;
@@ -38,6 +42,7 @@ class CompanyGoal {
this.cargo = cargo;
this.accept = accept;
this.wanted_amount = wanted_amount;
+ this.reward = this.wanted_amount * subsidyfactor; // estimated factor, better would be a random value
this.ResetTimeout();
// Construct goal if a company id was provided.
@@ -48,17 +53,23 @@ class CompanyGoal {
destination_string = GSText(GSText.STR_TOWN_NAME, destination);
destination_string_news = GSText(GSText.STR_TOWN_NAME_NEWS, destination);
goal_type = GSGoal.GT_TOWN;
+ this.reward = this.reward * rewardfactor_town;
} else {
destination = accept.ind;
destination_string = GSText(GSText.STR_INDUSTRY_NAME, destination);
destination_string_news = GSText(GSText.STR_INDUSTRY_NAME_NEWS, destination);
goal_type = GSGoal.GT_INDUSTRY;
+ this.reward = this.reward * rewardfactor_ind;
+ }
+ local goal_text, goal_news_text;
+ if (this.reward > 0) {
+ goal_text = GSText(GSText.STR_COMPANY_GOAL_REWARD, cargo.cid, this.wanted_amount, destination_string, this.reward);
+ goal_news_text = GSText(GSText.STR_COMPANY_GOAL_REWARD_NEWS, cargo.cid, this.wanted_amount, destination_string_news, this.reward);
+ } else {
+ goal_text = GSText(GSText.STR_COMPANY_GOAL, cargo.cid, this.wanted_amount, destination_string);
+ goal_news_text = GSText(GSText.STR_COMPANY_GOAL_NEWS, cargo.cid, this.wanted_amount, destination_string_news);
}
- local goal_text = GSText(GSText.STR_COMPANY_GOAL, cargo.cid,
- this.wanted_amount, destination_string);
this.goal_id = GSGoal.New(comp_id, goal_text, goal_type, destination);
- local goal_news_text = GSText(GSText.STR_COMPANY_GOAL_NEWS, cargo.cid,
- this.wanted_amount, destination_string_news);
this.PublishNews(goal_news_text, comp_id);
}
}
@@ -90,7 +101,7 @@ function CompanyGoal::ResetTimeout()
function CompanyGoal::SaveGoal()
{
return {cid=this.cargo.cid, accept=this.accept, wanted=this.wanted_amount,
- delivered=this.delivered_amount, goal=this.goal_id, timeout=this.timeout};
+ delivered=this.delivered_amount, goal=this.goal_id, timeout=this.timeout, reward=this.reward};
}
// Load an existing goal.
@@ -106,6 +117,7 @@ function CompanyGoal::LoadGoal(loaded_data, cargoes)
goal.delivered_amount = loaded_data.delivered;
goal.goal_id = loaded_data.goal;
goal.timeout = loaded_data.timeout;
+ goal.reward = loaded_data.reward;
return goal;
}
}
@@ -151,8 +163,12 @@ function CompanyGoal::UpdateDelivered(mon, comp_id)
} else {
destination_string_news = GSText(GSText.STR_INDUSTRY_NAME_NEWS, this.accept.ind);
}
- local goal_won_news = GSText(GSText.STR_COMPANY_GOAL_WON_NEWS, cargo.cid,
- this.wanted_amount, destination_string_news);
+ local goal_won_news;
+ if (this.reward > 0) {
+ goal_won_news = GSText(GSText.STR_COMPANY_GOAL_REWARD_WON_NEWS, cargo.cid, this.wanted_amount, destination_string_news, this.reward);
+ } else {
+ goal_won_news = GSText(GSText.STR_COMPANY_GOAL_WON_NEWS, cargo.cid, this.wanted_amount, destination_string_news);
+ }
this.PublishNews(goal_won_news, comp_id);
} else {
perc = 100 * this.delivered_amount / this.wanted_amount;
@@ -512,7 +528,8 @@ function CompanyData::CheckAndFinishGoals()
if (goal == null) continue;
if (goal.CheckFinished()) {
goal.FinalizeGoal();
- this.active_goals[num] = null;
+ GSCompany.ChangeBankBalance(this.comp_id, goal.reward, 0);
+ this.active_goals[num] = null;
}
}
}
diff --git a/info.nut b/info.nut
index ffd048e..10d6640 100644
--- a/info.nut
+++ b/info.nut
@@ -21,13 +21,13 @@ SAVEGAME_VERSION <- 2; // Set manually if/when save games break.
MINCOMPATIBLE_SAVEGAME_VERSION <- 2; // cset: bf1430b223d5df73a0c6ba9c996594a77d497cf1
PROGRAM_VERSION <- 5538;
-PROGRAM_DATE <- "2015-03-01";
-PROGRAM_NAME <- "BusyBee RC2M";
+PROGRAM_DATE <- "2015-06-12";
+PROGRAM_NAME <- "BusyBee RC2M with reward";
class BusyBeeInfo extends GSInfo {
- function GetAuthor() { return "alberth & andythenorth"; }
- function GetName() { return "Busy Bee"; } // Old: return PROGRAM_NAME;
- function GetDescription() { return "Make connection, transport cargo"; }
+ function GetAuthor() { return "alberth & andythenorth, reward by jottyfan"; }
+ function GetName() { return "Busy Bee Reward"; } // Old: return PROGRAM_NAME;
+ function GetDescription() { return "Make connection, transport cargo, recieve reward"; }
function GetVersion() { return PROGRAM_VERSION + SAVEGAME_VERSION * 100000; }
function GetDate() { return PROGRAM_DATE; }
function CreateInstance() { return "BusyBeeClass"; }
@@ -85,6 +85,36 @@ function BusyBeeInfo::GetSettings()
hard_value=1,
custom_value=1,
flags=GSInfo.CONFIG_INGAME});
+ GSInfo.AddSetting({name="subsidy_factor",
+ description="Factor to be multiplied with cargo amount as reward",
+ min_value=0,
+ max_value=4,
+ easy_value=3,
+ medium_value=2,
+ hard_value=1,
+ custom_value=0,
+ step_size=0.5,
+ flags=GSInfo.CONFIG_INGAME});
+ GSInfo.AddSetting({name="rewardfactor_town",
+ description="Extra factor to be multiplied with reward for towns",
+ min_value=0,
+ max_value=2,
+ easy_value=2,
+ medium_value=1,
+ hard_value=0,
+ custom_value=0,
+ step_size=0.1,
+ flags=GSInfo.CONFIG_INGAME});
+ GSInfo.AddSetting({name="rewardfactor_ind",
+ description="Extra factor to be multiplied with reward for industries",
+ min_value=0,
+ max_value=2,
+ easy_value=2,
+ medium_value=1,
+ hard_value=0,
+ custom_value=0,
+ step_size=0.1,
+ flags=GSInfo.CONFIG_INGAME});
}
RegisterGS(BusyBeeInfo());
diff --git a/lang/english.txt b/lang/english.txt
index c9e3eeb..ca6602d 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -1,8 +1,11 @@
##plural 0
-STR_COMPANY_GOAL :Deliver {GOLD}{CARGO_LONG} {ORANGE}to {STRING}
+STR_COMPANY_GOAL_REWARD :Deliver {GOLD}{CARGO_LONG} {ORANGE}to {STRING}{ORANGE} for {WHITE}{STRING}{CURRENCY_LONG}
+STR_COMPANY_GOAL :Deliver {GOLD}{CARGO_LONG} {ORANGE}to {STRING}{ORANGE}
+STR_COMPANY_GOAL_REWARD_NEWS:New goal! Deliver {CARGO_LONG} to {STRING} for {STRING}{CURRENCY_LONG}
STR_COMPANY_GOAL_NEWS :New goal! Deliver {CARGO_LONG} to {STRING}
STR_PROGRESS :{YELLOW}{NUM}% {ORANGE}done
+STR_COMPANY_GOAL_REWARD_WON_NEWS:Goal won! {CARGO_LONG} delivered to {STRING} and earned {STRING}{CURRENCY_LONG}
STR_COMPANY_GOAL_WON_NEWS :Goal won! {CARGO_LONG} delivered to {STRING}
STR_TIMEOUT_YEARS :{GOLD}{NUM} {ORANGE}year{P "" s} remaining
STR_TIMEOUT_MONTHS :{GOLD}{NUM} {ORANGE}month{P "" s} remaining
diff --git a/lang/german.txt b/lang/german.txt
index 546806d..cd9d61a 100644
--- a/lang/german.txt
+++ b/lang/german.txt
@@ -1,8 +1,11 @@
##plural 0
-STR_COMPANY_GOAL :Liefere {GOLD}{CARGO_LONG} {ORANGE}nach {STRING}
+STR_COMPANY_GOAL_REWARD :Lieferung von {GOLD}{CARGO_LONG} {ORANGE}nach {STRING}{ORANGE} bringt {WHITE}{STRING}{CURRENCY_LONG} {ORANGE}ein
+STR_COMPANY_GOAL :Lieferung von {GOLD}{CARGO_LONG} {ORANGE}nach {STRING}{GOLD}
+STR_COMPANY_GOAL_REWARD_NEWS:Neues Ziel! Liefere {CARGO_LONG} nach {STRING} für {STRING}{CURRENCY_LONG}
STR_COMPANY_GOAL_NEWS :Neues Ziel! Liefere {CARGO_LONG} nach {STRING}
STR_PROGRESS :{YELLOW}{NUM}% {ORANGE}erreicht
+STR_COMPANY_GOAL_REWARD_WON_NEWS:Ziel erreicht! {CARGO_LONG} nach {STRING} geliefert und {STRING}{CURRENCY_LONG} kassiert
STR_COMPANY_GOAL_WON_NEWS :Ziel erreicht! {CARGO_LONG} nach {STRING} geliefert
STR_TIMEOUT_YEARS :{GOLD}{NUM} {ORANGE}Jahr{P "" e} verbleib{P t en}
STR_TIMEOUT_MONTHS :{GOLD}{NUM} {ORANGE}Monat{P "" e} verbleib{P t en}