DEV: reward extension
This commit is contained in:
28
company.nut
28
company.nut
@@ -25,7 +25,9 @@ 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;
|
||||
|
||||
displayed_string = null;
|
||||
displayed_count = null;
|
||||
|
||||
@@ -38,6 +40,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.
|
||||
@@ -54,11 +57,15 @@ class CompanyGoal {
|
||||
destination_string_news = GSText(GSText.STR_INDUSTRY_NAME_NEWS, destination);
|
||||
goal_type = GSGoal.GT_INDUSTRY;
|
||||
}
|
||||
local goal_text = GSText(GSText.STR_COMPANY_GOAL, cargo.cid,
|
||||
this.wanted_amount, destination_string);
|
||||
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);
|
||||
}
|
||||
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 +97,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 +113,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 +159,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;
|
||||
|
||||
20
info.nut
20
info.nut
@@ -25,15 +25,15 @@ PROGRAM_DATE <- Syntax error, set by 'make bundle'.
|
||||
PROGRAM_NAME <- Syntax error, set by 'make bundle'.
|
||||
|
||||
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 "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"; }
|
||||
function GetShortName() { return "BBEE"; }
|
||||
function GetShortName() { return "BREW"; }
|
||||
function GetAPIVersion() { return "1.5"; }
|
||||
function GetUrl() { return "http://dev.openttdcoop.org/projects/busy-bee-gs"; }
|
||||
function GetUrl() { return "http://dev.openttdcoop.org/projects/bee-awards"; }
|
||||
function MinVersionToLoad() { return MINCOMPATIBLE_SAVEGAME_VERSION; }
|
||||
function GetSettings();
|
||||
}
|
||||
@@ -95,6 +95,16 @@ 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});
|
||||
}
|
||||
|
||||
RegisterGS(BusyBeeInfo());
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
##plural 0
|
||||
|
||||
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}
|
||||
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
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
##plural 0
|
||||
|
||||
STR_COMPANY_GOAL_REWARD :Liefere {GOLD}{CARGO_LONG} {ORANGE}nach {STRING}{ORANGE} bringt {WHITE}{STRING}{CURRENCY_LONG} {ORANGE}ein
|
||||
STR_COMPANY_GOAL :Liefere {GOLD}{CARGO_LONG} {ORANGE}nach {STRING}
|
||||
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}
|
||||
|
||||
Reference in New Issue
Block a user