Skip to content

Commit

Permalink
v1.2.7.8
Browse files Browse the repository at this point in the history
- let player instant-ferment wrapped bales
- allow mission bales in storage
- catch unknown fillTypes
- add "off" values to hardMode settings
- Allow forage wagon on grass missions (#118)
- format reward values > 100.000 (#113)
  • Loading branch information
Mmtrx committed Apr 12, 2023
1 parent c8c823c commit f15ad70
Show file tree
Hide file tree
Showing 16 changed files with 149 additions and 29 deletions.
29 changes: 24 additions & 5 deletions betterContracts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
-- Read userDefined missions from "BCuserDefined.xml" in modSettings dir
-- v1.2.7.6 21.03.2023 format rewd values > 100.000 (issue #113)
-- Read userDefined from modSettings/FS22_BetterContracts/<mapName>/ (issue #115)
-- v1.2.7.7 29.03.2023 add "off" values to hardMode settings. Allow forage wagon on grass missions (#118)
-- "userDefined.xml" compat with FS22_DynamicMissionVehicles
-- v1.2.7.8 12.04.2023 getfilltypePrice() catch unknown fillType. Allow mission bales in storage.
-- let player instant-ferment wrapped bales
--=======================================================================================================
SC = {
FERTILIZER = 1, -- prices index
Expand All @@ -72,6 +76,7 @@ SC = {
FARMMANAGER = 2,
PLAYER = 3,
-- hardMode expire:
OFF = 0,
DAY = 1,
MONTH = 2,
-- Gui farmerBox controls:
Expand Down Expand Up @@ -482,6 +487,8 @@ function BetterContracts:initialize()

-- to show our ingame menu settings page when admin logs in:
Utility.appendedFunction(InGameMenuMultiplayerUsersFrame,"onAdminLoginSuccess",adminMP)
-- to allow forage wagon on bale missions:
Utility.overwrittenFunction(BaleMission, "new", baleMissionNew)

-- to count and save/load # of jobs per farm per NPC
Utility.appendedFunction(AbstractFieldMission,"finish",finish)
Expand Down Expand Up @@ -741,12 +748,17 @@ function BetterContracts:getFilltypePrice(m)
self.name, m.type.name, self.ft[m.fillType].title, m.field.fieldId)
return 0
end
-- check for Maize+ filltype
-- check for Maize+ (or other unknown) filltype
local fillType = m.fillType
if m.sellPoint.fillTypePrices[fillType] == nil then
fillType = FillType.SILAGE
if m.sellPoint.fillTypePrices[fillType] ~= nil then
return m.sellPoint:getEffectiveFillTypePrice(fillType)
end
return m.sellPoint:getEffectiveFillTypePrice(fillType)
if m.sellPoint.fillTypePrices[FillType.SILAGE] then
return m.sellPoint:getEffectiveFillTypePrice(FillType.SILAGE)
end
Logging.warning("[%s]:addMission(): SellPoint %s has no price for fillType %s.",
self.name, m.sellPoint:getName(), self.ft[m.fillType].title)
return 0
end
function BetterContracts:calcProfit(m, successFactor)
-- calculate brutto income as reward + value of kept harvest
Expand Down Expand Up @@ -937,10 +949,17 @@ end
function abstractMissionNew(isServer, superf, isClient, customMt )
local self = superf(isServer, isClient, customMt)
self.mission = g_currentMission
-- Fix for error in AbstractMission 'self.mission' still missing in Version 1.6
-- Fix for error in AbstractMission 'self.mission' still missing in Version 1.9
return self
end
function adminMP(self)
-- appended to InGameMenuMultiplayerUsersFrame:onAdminLoginSuccess()
BetterContracts.gameMenu:updatePages()
end
function baleMissionNew(isServer, superf, isClient, customMt )
local self = superf(isServer, isClient, customMt)
self.workAreaTypes[WorkAreaType.FORAGEWAGON] = true
self.workAreaTypes[WorkAreaType.CUTTER] = true
-- allow forage wagons to collect grass/ hay, for baling/wrapping at stationary baler
return self
end
1 change: 1 addition & 0 deletions l10n/l10n_br.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- Keys -->
<text name = "input_MENU_EXTRA_3" text = "Melhores contratos: Detalhes Ligado/Desligado"/>
<text name = "input_BC_MTOGGLE" text = "BC: Toggle display of active farm contracts"/>
<text name = "bc_ferment" text = "Ferment Bale"/>
<!-- Gui Buttons -->
<text name="bc_hidden" text="Oculto: %d" />
<text name="bc_other" text="Outros" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_cs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- Keys -->
<text name = "input_MENU_EXTRA_3" text = "更好的合同:开启/关闭详情"/>
<text name = "input_BC_MTOGGLE" text = "BC: Toggle display of active farm contracts"/>
<text name = "bc_ferment" text = "Ferment Bale"/>
<!-- Gui Buttons -->
<text name="bc_hidden" text="隐藏的:%d" />
<text name="bc_other" text="其他" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_cz.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- Keys -->
<text name = "input_MENU_EXTRA_3" text = "Vylepšené zakázky: Detaily zap/vyp"/>
<text name = "input_BC_MTOGGLE" text = "BC: Přepnout zobrazení aktivních zakázek farmy"/>
<text name = "bc_ferment" text = "Ferment Bale"/>
<!-- Gui Buttons -->
<text name="bc_hidden" text="Skryté: %d" />
<text name="bc_other" text="Další" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- Keys -->
<text name = "input_MENU_EXTRA_3" text = "BC: Details an/aus"/>
<text name = "input_BC_MTOGGLE" text = "BC: Anzeige aktiver Farm-Verträge an/aus"/>
<text name = "bc_ferment" text = "Ballen fermentieren"/>
<!-- Gui Buttons -->
<text name="bc_hidden" text="Ausgeblendet: %d" />
<text name="bc_other" text="Sonstige" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- Keys -->
<text name = "input_MENU_EXTRA_3" text = "Better Contracts: Details on/off"/>
<text name = "input_BC_MTOGGLE" text = "BC: Toggle display of active farm contracts"/>
<text name = "bc_ferment" text = "Ferment Bale"/>
<!-- Gui Buttons -->
<text name="bc_hidden" text="Hidden: %d" />
<text name="bc_other" text="Other" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_fr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- Keys -->
<text name = "input_MENU_EXTRA_3" text = "Better Contracts: Sans/avec détails"/>
<text name = "input_BC_MTOGGLE" text = "BC: Toggle display of active farm contracts"/>
<text name = "bc_ferment" text = "Ferment Bale"/>
<!-- Gui Buttons -->
<text name="bc_hidden" text="Caché: %d" />
<text name="bc_other" text="L'autre" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_it.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<texts>
<!-- Keys -->
<text name = "input_MENU_EXTRA_3" text = "Better Contracts: Détails on/off"/>
<text name = "bc_ferment" text = "Ferment Bale"/>
<text name = "input_BC_MTOGGLE" text = "BC: Toggle display of active farm contracts"/>
<!-- Gui Buttons -->
<text name="bc_hidden" text="Hidden: %d" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_jp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- Keys -->
<text name = "input_MENU_EXTRA_3" text = "契約詳細表示切替"/>
<text name = "input_BC_MTOGGLE" text = "BC: Toggle display of active farm contracts"/>
<text name = "bc_ferment" text = "Ferment Bale"/>
<!-- Gui Buttons -->
<text name="bc_hidden" text="Hidden: %d" />
<text name="bc_other" text="Other" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_pl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- Keys -->
<text name = "input_MENU_EXTRA_3" text = "Better Contracts: Szczegóły wł./wył."/>
<text name = "input_BC_MTOGGLE" text = "BC: Przełącz wyświetlanie aktywnych umów rolniczych"/>
<text name = "bc_ferment" text = "Ferment Bale"/>
<!-- Gui Buttons -->
<text name="bc_hidden" text="Ukryty: %d" />
<text name="bc_other" text="Inny" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- Keys -->
<text name = "input_MENU_EXTRA_3" text = "Better Contracts: Детали вкл./выкл."/>
<text name = "input_BC_MTOGGLE" text = "BC: Переключить отображение активных контрактов ферм"/>
<text name = "bc_ferment" text = "Ferment Bale"/>
<!-- Gui Buttons -->
<text name="bc_hidden" text="Скрыто: %d" />
<text name="bc_other" text="Другое" />
Expand Down
11 changes: 8 additions & 3 deletions modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="73">
<author>Mmtrx</author>
<version>1.2.7.6</version>
<version>1.2.7.8</version>
<title>
<en>Better Contracts</en>
</title>
Expand All @@ -24,8 +24,13 @@ Disclaimer: All values shown in details display are ESTIMATES. You should not ta
The mod keeps track of the amount of contracts you completed for each of the NPC farmers (number of completed jobs is displayed below the farmers image, if "Details" on). If you enable the optional discount mode or hard mode options (on the mods settings page), the amount of completed jobs influence gameplay.
Changelog v1.2.7.6:
- format reward values > 100.000 (issue #113)
Changelog v1.2.7.8:
- let player instant-ferment wrapped bales
- allow mission bales in storage
- catch unknown fillTypes
- add "off" values to hardMode settings
- Allow forage wagon on grass missions (#118)
- format reward values > 100.000 (#113)
- read userDefined from modSettings/FS22_BetterContracts/<mapName>/ (issue #115)
Changelog v1.2.7.5:
Expand Down
12 changes: 7 additions & 5 deletions scripts/missionVehicles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
-- show leased vehicles for active contracts
-- v1.2.7.5 28.02.2023 Read userDefined missions from "BCuserDefined.xml" in modSettings dir
-- v1.2.7.6 21.03.2023 Read userDefined from modSettings/FS22_BetterContracts/<mapName>/ (issue #115)
-- v1.2.7.7 03.04.2013 userDefined.xml compatible with FS22_DynamicMissionVehicles
--=======================================================================================================

---------------------- mission vehicle loading functions --------------------------------------------
Expand Down Expand Up @@ -54,12 +55,13 @@ function BetterContracts.loadMissionVehicles(missionManager, superFunc, xmlFilen
if found and self:checkExtraMissionVehicles(userdef) then
-- check for other mod:
if g_modIsLoaded.FS22_DynamicMissionVehicles then
Logging.warning("[%s] '%s' not loaded. Incompatible with FS22_DynamicMissionVehicles",
self.name, userdef)
else
debugPrint("[%s] loading user mission vehicles from '%s'.",self.name, userdef)
self.overwrittenVehicles = self:loadExtraMissionVehicles(userdef)
Logging.warning("[%s] Mod FS22_DynamicMissionVehicles detected. Make sure '%s' contains 'variant definitions'",self.name, userdef)
local dmv = FS22_DynamicMissionVehicles.DynamicMissionVehicles
dmv.variants = {}
dmv:loadVariants(userdef)
end
debugPrint("[%s] loading user mission vehicles from '%s'.",self.name, userdef)
self.overwrittenVehicles = self:loadExtraMissionVehicles(userdef)
end
return true
end
Expand Down
14 changes: 9 additions & 5 deletions scripts/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
-- v1.2.7.1 10.02.2023 fix mission visual tags for MP: renderIcon().
-- v1.2.7.2 12.02.2023 icon for roller missions. Don't show negative togos
-- v1.2.7.3 20.02.2023 double progress bar active contracts. Fix PnH BGA/ Maize+
-- v1.2.7.7 29.03.2023 add "off" values to hardMode settings
--=======================================================================================================

--------------------- lazyNPC ---------------------------------------------------------------------------
Expand Down Expand Up @@ -339,7 +340,7 @@ end
function BetterContracts:onDayChanged()
-- hard mode: cancel any active field missions
if g_server == nil or not self.config.hardMode
or self.config.hardExpire == SC.MONTH then return end
or self.config.hardExpire ~= SC.DAY then return end
for _, m in ipairs(g_missionManager:getActiveMissions()) do
if m:hasField() then
g_missionManager:cancelMission(m)
Expand All @@ -348,11 +349,12 @@ function BetterContracts:onDayChanged()
end
function BetterContracts:onHourChanged()
-- hard mode: issue warnings 6,3,1 h before active missions cancel
if not self.config.hardMode or g_client == nil then return end
if not self.config.hardMode or self.config.hardExpire == SC.OFF or g_client == nil
then return end
local env = g_currentMission.environment
if self.config.hardExpire == SC.MONTH and
env.currentDayInPeriod ~= env.daysPerPeriod then return end
if not TableUtility.contains({18,21,23}, env.currentHour) then return end
if not table.hasElement({18,21,23}, env.currentHour) then return end

local farmId = g_currentMission:getFarmId()
local count = 0
Expand All @@ -367,14 +369,16 @@ function BetterContracts:onHourChanged()
end
end
function onButtonCancel(self, superf)
if not BetterContracts.config.hardMode then return superf(self) end
local bc = BetterContracts
if not bc.config.hardMode or bc.config.hardPenalty == 0.0
then return superf(self) end
local contract = self:getSelectedContract()
local m = contract.mission
--local difficulty = 0.7 + 0.3 * g_currentMission.missionInfo.economicDifficulty
local text = g_i18n:getText("fieldJob_endContract")
local reward = m:getReward()
if reward then
local penalty = MathUtil.round(reward * BetterContracts.config.hardPenalty)
local penalty = MathUtil.round(reward * bc.config.hardPenalty)
text = text.. g_i18n:getText("bc_warnCancel") ..
g_i18n:formatMoney(penalty, 0, true, true)
end
Expand Down
15 changes: 7 additions & 8 deletions scripts/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-- v1.2.6.0 30.11.2022 UI for all settings
-- v1.2.6.5 18.01.2023 add setting "toDeliver": harvest contract success factor
-- v1.2.7.4 22.02.2023 increase range for "toDeliver". Add setting "toDeliverBale"
-- v1.2.7.7 29.03.2023 add "off" values to hardMode settings
--=======================================================================================================
local function lazyNPCDisabled()
return not BetterContracts.config.lazyNPC
Expand Down Expand Up @@ -152,27 +153,25 @@ BCSettingsBySubtitle = {
tooltip = "bc_hardMode_tooltip",
},
{name = "hardPenalty",
values = {.1,.2,.3,.4,.5,.6,.7},
texts = {"10 %","20 %","30 %","40 %","50 %","60 %","70 %"},
default = 1,
min = .0, max = .7, increment = .1, unit = true,
default = 2,
title = "bc_hardPenalty",
tooltip = "bc_hardPenalty_tooltip",
isDisabledFunc = hardDisabled,
noTranslate = true
},
{name = "hardLease",
values = {1,2,3,4,5,6,7},
texts = {"1", "2", "3", "4", "5", "6", "7",},
min = 0, max = 7, increment = 1,
default = 2,
title = "bc_hardLease",
tooltip = "bc_hardLease_tooltip",
isDisabledFunc = hardDisabled,
noTranslate = true
},
{name = "hardExpire",
values = {SC.DAY, SC.MONTH},
texts = {"ui_day", "ui_month"},
default = 2,
values = {SC.OFF, SC.DAY, SC.MONTH},
texts = {"ui_off", "ui_day", "ui_month"},
default = 3,
title = "bc_hardExpire",
tooltip = "bc_hardExpire_tooltip",
isDisabledFunc = hardDisabled,
Expand Down
Loading

0 comments on commit f15ad70

Please sign in to comment.