View difference between Paste ID: LjBRQQxY and 5DAbyiwy
SHOW: | | - or go back to the newest paste.
1
/*
2
Original post text provided from author (https://forum.wurmonline.com/index.php?/topic/162331-horse-speed-calculator/)
3
4
I butchered together some decompiled WU code into a horse speed calculator to see how much of an effect the various factors (traits, weight, gear QL) can have.
5
6
To use it, go to the link below:
7
https://pastebin.com/5DAbyiwy
8
9
Copy the code presented there, then go to this link:
10
https://www.jdoodle.com/online-java-compiler
11
12
Erase anything in the box, and paste the code you copied.
13
14
Click Execute at the bottom to make sure it gives some output.  That'll be for an untraited, ungeared horse, being ridden by somebody carrying 50 Kg of gear.  Even if it's not being factored in for the speed boost, the horse's weight value still has saddle/shoes added in since I assumed that would be the most likely thing tested.  Set mountCarriedWeight to 0 for a true reading of an ungeared horse.
15
16
(My comments say that unicorns are exempt from soul strength checks, but don't take that as a hard truth.)
17
18
Set the values in the first little bit to whatever you'd like to see, then Execute.  Make sure to set isSaddled, isShoed to true to see those values have an effect.
19
20
Based on the creature's soul strength the traits will flip on and off at random, so in-game you can expect the actual speed to fluctuate anywhere between the min and max values.
21
22
Feedback and reports of any inaccuracies are appreciated.
23
Disclaimer:  This comes from WU code, who the hell knows what WO code really says, but they're usually pretty similar. 
24
*/
25
26
27
public class MyClass {
28
    public static void main(String args[]) {
29
 
30
        boolean horse = true;
31
        boolean hellHorse = false;
32
        boolean unicorn = false;
33
        // Unicorns are exempt from SoulStrength checks on traits, not modeled here.
34
   
35
        boolean isRidden = true;
36
        boolean isSecondRider = false;
37
        boolean isSaddled = false;
38
        boolean isShoed = false;
39
       
40
        float saddleQL = 70.0F;
41
        byte saddleRarity = 0;    //0 normal, 1 rare, 2 supreme, 3 fantastic
42
        float saddleWoA = 0.0F;
43
       
44
        float horseShoe1QL = 70.0F;
45
        byte horseShoe1Rarity = 0;
46
        float horseShoe1WoA = 0.0F;
47
       
48
        float horseShoe2QL = 70.0F;
49
        byte horseShoe2Rarity = 0;
50
        float horseShoe2WoA = 0.0F;
51
       
52
        float horseShoe3QL = 70.0F;
53
        byte horseShoe3Rarity = 0;
54
        float horseShoe3WoA = 0.0F;
55
       
56
        float horseShoe4QL = 70.0F;
57
        byte horseShoe4Rarity = 0;
58
        float horseShoe4WoA = 0.0F;
59
       
60
       
61
        boolean trait1 = false;      //It has fleeter movement than normal
62
        boolean trait3 = false;      //It has a strong body
63
        boolean trait4 = false;      //It has lightning movement
64
        boolean trait5 = false;      //It can carry more than average
65
        boolean trait6 = false;      //It has very strong leg muscles
66
        boolean trait8 = false;     //It has malformed hindlegs
67
        boolean trait9 = false;     //The legs are of different length
68
        boolean trait11 = false;    //It looks very unmotivated
69
        boolean trait23 = false;    //Color is ebony black
70
   
71
 
72
        float mountCarriedWeight = 6500;    // Assumes four 500 gram shoes and one 4500 saddle
73
        float riderOneFatLevel = 125;       // 0 - 125, Only matters if under 30
74
        float riderOneCarriedWeight = 50000;    // Weight in grams
75
        float riderTwoFatLevel = 0;
76
        float riderTwoCarriedWeight = 0;
77
       
78
        int hungerPercent = 0;
79
        int damagePercent = 0;
80
       
81
       
82
       
83
       
84
       
85
        //The below are calculated values, do not change
86
        float mountStrength = 0;
87
        float mountMaxSpeed = 0;
88
        boolean isHorse = false;
89
        boolean isUnicorn = false;
90
        float shoeBonus = 0;
91
        float saddleBonus = 0;
92
       
93
        if (horse)
94
        {
95
            mountStrength = 25;
96
            mountMaxSpeed = 30;
97
            isHorse = true;
98
            isUnicorn = false;
99
        }
100
        if (hellHorse)
101
        {
102
            mountStrength = 35;
103
            mountMaxSpeed = 32;
104
            isHorse = true;
105
            isUnicorn = false;
106
        }
107
        if (unicorn)
108
        {
109
            mountStrength = 30;
110
            mountMaxSpeed = 33;
111
            isHorse = false;
112
            isUnicorn = true;
113
        }
114
       
115
        int hunger = hungerPercent * 65535 / 100;
116
        int damage = damagePercent * 65535 / 100;
117
   
118
        float factor = 0.5F;
119
        if (hunger < 45000) {
120
          factor += 0.2F;
121
        }
122
        if (hunger < 10000) {
123
          factor += 0.1F;
124
        }
125
        if (damage < 10000) {
126
          factor += 0.1F;
127
        } else if (damage > 20000) {
128
          factor -= 0.5F;
129
        } else if (damage > 45000) {
130
          factor -= 0.7F;
131
        }
132
        if ((isHorse) || (isUnicorn))
133
        {
134
            if (isShoed)
135
            {
136
              shoeBonus += Math.max(10.0F, horseShoe1QL) / 2000.0F;
137
              shoeBonus += horseShoe1WoA / 2000.0F;
138
              shoeBonus += horseShoe1Rarity * 0.03F;
139
             
140
              shoeBonus += Math.max(10.0F, horseShoe2QL) / 2000.0F;
141
              shoeBonus += horseShoe2WoA / 2000.0F;
142
              shoeBonus += horseShoe2Rarity * 0.03F;
143
             
144
              shoeBonus += Math.max(10.0F, horseShoe3QL) / 2000.0F;
145
              shoeBonus += horseShoe3WoA / 2000.0F;
146
              shoeBonus += horseShoe3Rarity * 0.03F;
147
             
148
              shoeBonus += Math.max(10.0F, horseShoe4QL) / 2000.0F;
149
              shoeBonus += horseShoe4WoA / 2000.0F;
150
              shoeBonus += horseShoe4Rarity * 0.03F;
151
              factor += shoeBonus;
152
            }
153
        }
154
       
155
        float postperc = 0;
156
        float negtperc = 0;
157
        float tperc = 0;
158
        float poswmod = 0;
159
        float negwmod = 0;
160
        float wmod = 0;
161
        float weightPenalty = 0;
162
 
163
 
164
        if (trait1) { postperc += 0.1; }
165
        if (trait3) { poswmod += 10000; }
166
        if (trait4) { postperc += 0.2; }
167
        if (trait5) { poswmod += 20000; }
168
        if (trait6) { postperc += 0.1; }
169
        if (trait6) { poswmod += 10000; }
170
        if (trait8) { negtperc -= 0.1; }
171
        if (trait9) { negtperc -= 0.3; }
172
        if (trait11) {negwmod -= 30000; }
173
        if (trait23) {postperc += 0.025; }
174
           
175
 
176
        if (isRidden)
177-
        
177+
178
            if (isSaddled)
179
            {
180
              saddleBonus += Math.max(10.0F, saddleQL) / 1000.0F;
181-
        
181+
182
              saddleBonus += saddleWoA / 2000.0F;
183
            }
184
            factor += saddleBonus;
185
           
186
            mountCarriedWeight += Math.max(30000, riderOneFatLevel * 1000);
187-
        
187+
188
           
189
           
190
            if (isUnicorn)
191
            {
192
                if (isSecondRider)
193
                {
194-
        allFactor -= allWeightPenalty; 
194+
195-
        
195+
196
                }
197
            }
198
        }
199
       
200-
        minFactor -= minWeightPenalty;       
200+
201
        float minFactor = 0;
202
        float maxFactor = 0;
203
       
204
        float allWeightPenalty = 0;
205
        float minWeightPenalty = 0;
206
        float maxWeightPenalty = 0;
207
       
208
       
209
        //factor += tperc;
210
        allFactor = factor + negtperc + postperc;
211-
        
211+
212
        maxFactor = factor + postperc;
213
       
214
       
215
       
216
        if (mountCarriedWeight > (mountStrength * 5000 + poswmod + negwmod))
217
        {
218
            allWeightPenalty = (float)(0.15D * (mountCarriedWeight - mountStrength * 5000.0D - poswmod - negwmod) / 50000.0D);
219
        }
220
        allFactor -= allWeightPenalty;
221
       
222
        if (mountCarriedWeight > (mountStrength * 5000 + negwmod))
223
        {
224
            minWeightPenalty = (float)(0.15D * (mountCarriedWeight - mountStrength * 5000.0D - negwmod) / 50000.0D);
225
        }
226
        minFactor -= minWeightPenalty;      
227
       
228
        if (mountCarriedWeight > (mountStrength * 5000 + poswmod))
229
        {
230
            maxWeightPenalty = (float)(0.15D * (mountCarriedWeight - mountStrength * 5000.0D - poswmod) / 50000.0D);
231
        }
232
        maxFactor -= maxWeightPenalty;
233
       
234
        int allSpeed = (int)Math.max(0.0D, Math.min(127.0D, allFactor * mountMaxSpeed));
235
        int minSpeed = (int)Math.max(0.0D, Math.min(127.0D, minFactor * mountMaxSpeed));
236
        int maxSpeed = (int)Math.max(0.0D, Math.min(127.0D, maxFactor * mountMaxSpeed));
237
       
238
        System.out.println("If the mount is classified as a horse, all traits (even negative ones) must pass");
239
        System.out.println("intermittent Soul Strength checks to stay active.");
240
        System.out.println("");
241
        System.out.println("");
242
        System.out.println("shoeBonus = " + shoeBonus);
243
        System.out.println("saddleBonus = " + saddleBonus);
244
        System.out.println("");
245
        System.out.println("All traits active weight penalty = " + allWeightPenalty);
246
        System.out.println("Worst traits active weight penalty = " + minWeightPenalty);
247
        System.out.println("Best traits active weight penalty = " + maxWeightPenalty);
248
        System.out.println("");
249
        System.out.println("All traits active speed = " + allSpeed);
250
        System.out.println("Worst traits active speed = " + minSpeed);
251
        System.out.println("Best traits active speed = " + maxSpeed);
252
    }
253
}