kayrice wrote:Hi! Awesome work so far.
Thank you!
kayrice wrote:My friends and I want basically the same thing as you, except we simply want distance to be ignored for all cargo types except passengers.
Unfortunately, there is no (currently) formula in the application i've made that handles linear distances. But you can get pretty close...
Setting the parameters of a bulk cargo as such:
Results in this:
Here's the detailed info:
As you can see, it's not perfect. 1000 tiles distance gives 15.8% of the maximum possible profits. Whereas double that distance (2000 tiles) gives 30.4% when it should have been 31.6% and technically they should be evenly distributed.
But as i said, it's because i only have formulas set up for diminishing returns at distances. However, the differences with these settings are hardly noticeable when playing. So you could do that, or you could add another formula.
On the flip side...
If you want distance to not matter at all. Then you can simply change the linearity value to 1.
Code: Select all
==========================================================================================================================================================================================================================
MAIL Speeds are in km/h, values in paratheses such as in "Speed(4)" refers to loading time in days/minutes.
··························································································································································································································
Distance ║ Primary time Result | Speed(4) Speed(8) Speed(12) Speed(16) Speed(20) ║ Secondary time Result | Speed(4) Speed(8) Speed(12) Speed(16) Speed(20) ║ Last result
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 ║ Infinity 500 | 0 0 0 0 0 ║ Infinity 500 | 0 0 0 0 0 ║ 500
1 ║ Infinity 500 | 0 0 0 0 0 ║ Infinity 500 | 0 0 0 0 0 ║ 500
2 ║ Infinity 666 | 0 0 0 0 0 ║ Infinity 666 | 0 0 0 0 0 ║ 666
3 ║ Infinity 750 | 0 0 0 0 0 ║ Infinity 750 | 0 0 0 0 0 ║ 750
4 ║ Infinity 800 | 0 0 0 0 0 ║ Infinity 800 | 0 0 0 0 0 ║ 800
5 ║ Infinity 833 | 0 0 0 0 0 ║ Infinity 833 | 0 0 0 0 0 ║ 833
6 ║ Infinity 857 | 0 0 0 0 0 ║ Infinity 857 | 0 0 0 0 0 ║ 857
7 ║ Infinity 875 | 0 0 0 0 0 ║ Infinity 875 | 0 0 0 0 0 ║ 875
8 ║ Infinity 888 | 0 0 0 0 0 ║ Infinity 888 | 0 0 0 0 0 ║ 888
9 ║ Infinity 900 | 0 0 0 0 0 ║ Infinity 900 | 0 0 0 0 0 ║ 900
10 ║ Infinity 909 | 0 0 0 0 0 ║ Infinity 909 | 0 0 0 0 0 ║ 909
11 ║ Infinity 916 | 0 0 0 0 0 ║ Infinity 916 | 0 0 0 0 0 ║ 916
12 ║ Infinity 923 | 0 0 0 0 0 ║ Infinity 923 | 0 0 0 0 0 ║ 923
13 ║ Infinity 928 | 0 0 0 0 0 ║ Infinity 928 | 0 0 0 0 0 ║ 928
14 ║ Infinity 933 | 0 0 0 0 0 ║ Infinity 933 | 0 0 0 0 0 ║ 933
15 ║ Infinity 937 | 0 0 0 0 0 ║ Infinity 937 | 0 0 0 0 0 ║ 937
16 ║ Infinity 941 | 0 0 0 0 0 ║ Infinity 941 | 0 0 0 0 0 ║ 941
17 ║ Infinity 944 | 0 0 0 0 0 ║ Infinity 944 | 0 0 0 0 0 ║ 944
18 ║ Infinity 947 | 0 0 0 0 0 ║ Infinity 947 | 0 0 0 0 0 ║ 947
19 ║ Infinity 950 | 0 0 0 0 0 ║ Infinity 950 | 0 0 0 0 0 ║ 950
20 ║ Infinity 952 | 0 0 0 0 0 ║ Infinity 952 | 0 0 0 0 0 ║ 952
21 ║ Infinity 954 | 0 0 0 0 0 ║ Infinity 954 | 0 0 0 0 0 ║ 954
22 ║ Infinity 956 | 0 0 0 0 0 ║ Infinity 956 | 0 0 0 0 0 ║ 956
23 ║ Infinity 958 | 0 0 0 0 0 ║ Infinity 958 | 0 0 0 0 0 ║ 958
24 ║ Infinity 960 | 0 0 0 0 0 ║ Infinity 960 | 0 0 0 0 0 ║ 960
25 ║ Infinity 961 | 0 0 0 0 0 ║ Infinity 961 | 0 0 0 0 0 ║ 961
26 ║ Infinity 962 | 0 0 0 0 0 ║ Infinity 962 | 0 0 0 0 0 ║ 962
27 ║ Infinity 964 | 0 0 0 0 0 ║ Infinity 964 | 0 0 0 0 0 ║ 964
28 ║ Infinity 965 | 0 0 0 0 0 ║ Infinity 965 | 0 0 0 0 0 ║ 965
29 ║ Infinity 966 | 0 0 0 0 0 ║ Infinity 966 | 0 0 0 0 0 ║ 966
30 ║ Infinity 967 | 0 0 0 0 0 ║ Infinity 967 | 0 0 0 0 0 ║ 967
31 ║ Infinity 968 | 0 0 0 0 0 ║ Infinity 968 | 0 0 0 0 0 ║ 968
32 ║ Infinity 969 | 0 0 0 0 0 ║ Infinity 969 | 0 0 0 0 0 ║ 969
33 ║ Infinity 970 | 0 0 0 0 0 ║ Infinity 970 | 0 0 0 0 0 ║ 970
34 ║ Infinity 971 | 0 0 0 0 0 ║ Infinity 971 | 0 0 0 0 0 ║ 971
35 ║ Infinity 972 | 0 0 0 0 0 ║ Infinity 972 | 0 0 0 0 0 ║ 972
36 ║ Infinity 972 | 0 0 0 0 0 ║ Infinity 972 | 0 0 0 0 0 ║ 972
37 ║ Infinity 973 | 0 0 0 0 0 ║ Infinity 973 | 0 0 0 0 0 ║ 973
38 ║ Infinity 974 | 0 0 0 0 0 ║ Infinity 974 | 0 0 0 0 0 ║ 974
39 ║ Infinity 975 | 0 0 0 0 0 ║ Infinity 975 | 0 0 0 0 0 ║ 975
40 ║ Infinity 975 | 0 0 0 0 0 ║ Infinity 975 | 0 0 0 0 0 ║ 975
41 ║ Infinity 976 | 0 0 0 0 0 ║ Infinity 976 | 0 0 0 0 0 ║ 976
42 ║ Infinity 976 | 0 0 0 0 0 ║ Infinity 976 | 0 0 0 0 0 ║ 976
43 ║ Infinity 977 | 0 0 0 0 0 ║ Infinity 977 | 0 0 0 0 0 ║ 977
44 ║ Infinity 977 | 0 0 0 0 0 ║ Infinity 977 | 0 0 0 0 0 ║ 977
45 ║ Infinity 978 | 0 0 0 0 0 ║ Infinity 978 | 0 0 0 0 0 ║ 978
46 ║ Infinity 978 | 0 0 0 0 0 ║ Infinity 978 | 0 0 0 0 0 ║ 978
47 ║ Infinity 979 | 0 0 0 0 0 ║ Infinity 979 | 0 0 0 0 0 ║ 979
48 ║ Infinity 979 | 0 0 0 0 0 ║ Infinity 979 | 0 0 0 0 0 ║ 979
49 ║ Infinity 980 | 0 0 0 0 0 ║ Infinity 980 | 0 0 0 0 0 ║ 980
50 ║ Infinity 980 | 0 0 0 0 0 ║ Infinity 980 | 0 0 0 0 0 ║ 980
51 ║ Infinity 980 | 0 0 0 0 0 ║ Infinity 980 | 0 0 0 0 0 ║ 980
52 ║ Infinity 981 | 0 0 0 0 0 ║ Infinity 981 | 0 0 0 0 0 ║ 981
53 ║ Infinity 981 | 0 0 0 0 0 ║ Infinity 981 | 0 0 0 0 0 ║ 981
54 ║ Infinity 981 | 0 0 0 0 0 ║ Infinity 981 | 0 0 0 0 0 ║ 981
55 ║ Infinity 982 | 0 0 0 0 0 ║ Infinity 982 | 0 0 0 0 0 ║ 982
56 ║ Infinity 982 | 0 0 0 0 0 ║ Infinity 982 | 0 0 0 0 0 ║ 982
57 ║ Infinity 982 | 0 0 0 0 0 ║ Infinity 982 | 0 0 0 0 0 ║ 982
58 ║ Infinity 983 | 0 0 0 0 0 ║ Infinity 983 | 0 0 0 0 0 ║ 983
59 ║ Infinity 983 | 0 0 0 0 0 ║ Infinity 983 | 0 0 0 0 0 ║ 983
60 ║ Infinity 983 | 0 0 0 0 0 ║ Infinity 983 | 0 0 0 0 0 ║ 983
61 ║ Infinity 983 | 0 0 0 0 0 ║ Infinity 983 | 0 0 0 0 0 ║ 983
62 ║ Infinity 984 | 0 0 0 0 0 ║ Infinity 984 | 0 0 0 0 0 ║ 984
63 ║ Infinity 984 | 0 0 0 0 0 ║ Infinity 984 | 0 0 0 0 0 ║ 984
64 ║ Infinity 984 | 0 0 0 0 0 ║ Infinity 984 | 0 0 0 0 0 ║ 984
65 ║ Infinity 984 | 0 0 0 0 0 ║ Infinity 984 | 0 0 0 0 0 ║ 984
66 ║ Infinity 985 | 0 0 0 0 0 ║ Infinity 985 | 0 0 0 0 0 ║ 985
67 ║ Infinity 985 | 0 0 0 0 0 ║ Infinity 985 | 0 0 0 0 0 ║ 985
68 ║ Infinity 985 | 0 0 0 0 0 ║ Infinity 985 | 0 0 0 0 0 ║ 985
69 ║ Infinity 985 | 0 0 0 0 0 ║ Infinity 985 | 0 0 0 0 0 ║ 985
70 ║ Infinity 985 | 0 0 0 0 0 ║ Infinity 985 | 0 0 0 0 0 ║ 985
71 ║ Infinity 986 | 0 0 0 0 0 ║ Infinity 986 | 0 0 0 0 0 ║ 986
72 ║ Infinity 986 | 0 0 0 0 0 ║ Infinity 986 | 0 0 0 0 0 ║ 986
73 ║ Infinity 986 | 0 0 0 0 0 ║ Infinity 986 | 0 0 0 0 0 ║ 986
74 ║ Infinity 986 | 0 0 0 0 0 ║ Infinity 986 | 0 0 0 0 0 ║ 986
75 ║ Infinity 986 | 0 0 0 0 0 ║ Infinity 986 | 0 0 0 0 0 ║ 986
76 ║ Infinity 987 | 0 0 0 0 0 ║ Infinity 987 | 0 0 0 0 0 ║ 987
77 ║ Infinity 987 | 0 0 0 0 0 ║ Infinity 987 | 0 0 0 0 0 ║ 987
78 ║ Infinity 987 | 0 0 0 0 0 ║ Infinity 987 | 0 0 0 0 0 ║ 987
79 ║ Infinity 987 | 0 0 0 0 0 ║ Infinity 987 | 0 0 0 0 0 ║ 987
80 ║ Infinity 987 | 0 0 0 0 0 ║ Infinity 987 | 0 0 0 0 0 ║ 987
81 ║ Infinity 987 | 0 0 0 0 0 ║ Infinity 987 | 0 0 0 0 0 ║ 987
82 ║ Infinity 987 | 0 0 0 0 0 ║ Infinity 987 | 0 0 0 0 0 ║ 987
83 ║ Infinity 988 | 0 0 0 0 0 ║ Infinity 988 | 0 0 0 0 0 ║ 988
84 ║ Infinity 988 | 0 0 0 0 0 ║ Infinity 988 | 0 0 0 0 0 ║ 988
85 ║ Infinity 988 | 0 0 0 0 0 ║ Infinity 988 | 0 0 0 0 0 ║ 988
86 ║ Infinity 988 | 0 0 0 0 0 ║ Infinity 988 | 0 0 0 0 0 ║ 988
87 ║ Infinity 988 | 0 0 0 0 0 ║ Infinity 988 | 0 0 0 0 0 ║ 988
88 ║ Infinity 988 | 0 0 0 0 0 ║ Infinity 988 | 0 0 0 0 0 ║ 988
89 ║ Infinity 988 | 0 0 0 0 0 ║ Infinity 988 | 0 0 0 0 0 ║ 988
90 ║ Infinity 989 | 0 0 0 0 0 ║ Infinity 989 | 0 0 0 0 0 ║ 989
91 ║ Infinity 989 | 0 0 0 0 0 ║ Infinity 989 | 0 0 0 0 0 ║ 989
92 ║ Infinity 989 | 0 0 0 0 0 ║ Infinity 989 | 0 0 0 0 0 ║ 989
93 ║ Infinity 989 | 0 0 0 0 0 ║ Infinity 989 | 0 0 0 0 0 ║ 989
94 ║ Infinity 989 | 0 0 0 0 0 ║ Infinity 989 | 0 0 0 0 0 ║ 989
95 ║ Infinity 989 | 0 0 0 0 0 ║ Infinity 989 | 0 0 0 0 0 ║ 989
96 ║ Infinity 989 | 0 0 0 0 0 ║ Infinity 989 | 0 0 0 0 0 ║ 989
97 ║ Infinity 989 | 0 0 0 0 0 ║ Infinity 989 | 0 0 0 0 0 ║ 989
98 ║ Infinity 989 | 0 0 0 0 0 ║ Infinity 989 | 0 0 0 0 0 ║ 989
99 ║ Infinity 990 | 0 0 0 0 0 ║ Infinity 990 | 0 0 0 0 0 ║ 990
100 ║ Infinity 990 | 0 0 0 0 0 ║ Infinity 990 | 0 0 0 0 0 ║ 990
I could make a formula that completely ignores distance, quite easily in fact. And even then, once you've pressed the "compile" button, the autogenerated NML file is still there.
One could simply replace the diminishing returns formula in the NML file with a constant value.
kayrice wrote:That or we want the setting to only apply penalties but not bonuses if that makes sense.
There are no bonuses in my formulas or in callbacks in general. Only penalties (as far as the vanilla game is concerned) that are limited in severity by altering the parameters.
The one thing you cannot alter is how much you get in the OTTD source code itself. IIRC, it's something along the lines of "callback * amount * price_factor / 8192", that is, the amount variable cannot be changed.
But you could technically return the max value (12748) and divide that by the amount variable that one can get in the callback itself to negate it.
kayrice wrote:However, we understand little about NewGRF or NML. Looking at your code posted above you describe that switch() but what we don't understand is how to "install" that switch for all cargo types or any of that. Can someone help a guy out?
Well, you could use a bunch of different methods but i would recommend using the application i've made for that ofc.
First and foremost, you need to know what cargoes you are working on. If they are vanilla cargoes then you can check here for their defaults:
https://newgrf-specs.tt-wiki.net/wiki/CargoDefaultProps
Otherwise, you need to check the sources of the industry set(s) you are using.
Then you simply save a clone of the default ECS Vectors template i have set up currently and remove/edit the cargoes to your liking. Making sure their ItemID's are the same as the slot (ID) from the default cargoes linked above or whatever they are in their respective industry sets.
Unfortunately, it's not possible (currently) to convert a perishable cargo to a bulk cargo in the application. The perishable cargoes are Passengers, Tourists, Food, Fruit, Fish, Cereals and livestock in the ECS vectors template.
Which brings me to another point. Templates... You would have to add the relevant "cargo scheme" template files to the "NMLTemplates" folder in the applications directory. Or manually add the necessary GRF information yourself to the auto generated NML file in the "Output" directory.
At this point, i feel it's better if users of the application would ask specific questions if they get stuck trying to implement my templating technique to other industry sets / vanilla rather than me explaining every step.
Returning to your specific question about ignoring distances completely, in the output file you would find this switch:
Code: Select all
switch (FEAT_CARGOS, SELF, switch_perishable_cargo_profit,
[
// CALLBACK VARIABLES
// 0: distance
STORE_TEMP(getbits(extra_callback_info2, 0, 16), 0),
// 1: time
STORE_TEMP(getbits(extra_callback_info2, 24, 8), 1),
...
// CALCULATION VARIABLES
// 21: diminishingReturns
STORE_TEMP((100000 - LOAD_TEMP(3) * 100000 / (min(LOAD_TEMP(0), LOAD_TEMP(2)) + LOAD_TEMP(3))) / (100 - LOAD_TEMP(3) * 100 / (LOAD_TEMP(2) + LOAD_TEMP(3))), 21),
...
]) {
return max(1,
min(1000,
max(
LOAD_TEMP(21) - LOAD_TEMP(23),
max(LOAD_TEMP(21) / LOAD_TEMP(15) - LOAD_TEMP(25),
LOAD_TEMP(21) / LOAD_TEMP(16))
)
));
}
And replace the "diminishingReturns" calculation with a hardcoded value. For example:
Code: Select all
// 21: diminishingReturns
STORE_TEMP(1000, 21),
...
As that's the maximum return value of the diminishing returns formula. Consequently, in the template, 1000 is also the maximum possible return value of the callback. If you want higher returns you would have to edit the related perishable/bulk templates as well changing "return max(1, min(1000..." to a different value.
Of course, there's a similar switch for bulk cargo calculations in the same file. You need to find and edit that as well.
Or, if you want SOME cargoes to care about distance but not others, you can simply duplicate the switch and rename it, alter it and reference it on a per cargo basis.
Once you are done with adding cargoes, templates and editing the output NML file. You just compile with NMLC as per usual and copy the grf file to your documents\ottd\newgrf folder.
Have you tried this and it's still unclear? Feel free to ask about where you got stuck.
And i could add more formulas and templates to the application itself but that would take longer than me responding here.