MajorMUD Accuracy Formula

General MajorMUD Discussion
User avatar
syntax
Site Admin
Posts: 545
Joined: Tue Jun 02, 2009 10:02 am

MajorMUD Accuracy Formula

Post by syntax »

Code: Select all

Accuracy_Rating = Fix(SquareRootOF(CHAR_LEVEL))
Do While ((Accuracy_Rating + 1) * (Accuracy_Rating + 1)) <= CHAR_LEVEL
	Accuracy_Rating = Accuracy_Rating + 1
Loop

//note that CombatLevel in the game is stored +2 from what players see.  
//e.g. Combat-1 is stored as 3 in the game, so (nCombatLevel - 1) below would result in a 2 for combat-1
Accuracy_Rating = Accuracy_Rating * (nCombatLevel - 1)
Accuracy_Rating = (Accuracy_Rating + (nCombatLevel * 2) + Fix(CHAR_LEVEL / 2) - 2) * 2
Accuracy_Rating = Accuracy_Rating + Fix((CHAR_STRENGTH - 50) / 3)
Accuracy_Rating = Accuracy_Rating + Fix((CHAR_AGILITY - 50) / 6)

//ACCURACY_FROM_WORN_ITEMS = Total Accuracy from the dedicated accuracy field on all equipped items
If ACCURACY_FROM_WORN_ITEMS = 0 Then ACCURACY_FROM_WORN_ITEMS = 1

//If encumbrance < 33% then +12 to +15 accy (32% == +12, 0% == +15)
nTemp = Fix((CURRENT_ENCUM / MAX_ENCUM) * 100)
If nTemp < 33 Then
	nTemp = 15 - Fix(nTemp / 10)
	ACCURACY_FROM_WORN_ITEMS = ACCURACY_FROM_WORN_ITEMS + nTemp
End If

//this is just how it's calculated in the mmud code (and would make the previous bonus +1 void IF encumbrance is >= 33 becase fix(1/2)=0)
ACCURACY_FROM_WORN_ITEMS = (Fix(ACCURACY_FROM_WORN_ITEMS / 2) * 2)

Accuracy_Rating = Accuracy_Rating + ACCURACY_FROM_WORN_ITEMS

Accuracy_Rating = Accuracy_Rating + MAXIMUM_SINGLE_VALUE_FROM_ABILITY22

If FRONTRANK then Accuracy_Rating = Accuracy_Rating + 5
If BACKRANK then Accuracy_Rating = Accuracy_Rating - 10
If BLIND then Accuracy_Rating = Accuracy_Rating - 10

//that LOOKS like it probably is when knocked down, stunned, or something of that effect
If SOME_MOVEMENT_THING then Accuracy_Rating = IIF(Accuracy_Rating >= 35, Accuracy_Rating - 35, 0)

A note on Accuracy from Ability 22 (MAXIMUM_SINGLE_VALUE_FROM_ABILITY22 in the code above):

From my testing, only the highest +Accuracy from ability 22 globally actually counts towards accuracy.

(Worn) items have a dedicated accuracy field. Those fields always count. However, those same worn items as well as classes, races, and especially Spells via blesses/auras provide +Accuracy boosts via ability 22. Quests can also directly provide permanent +accuracy to a character's ability table.

Only the max +Accuracy from ability 22 from any single slot from one of those sources counts towards the accuracy rating in game. So if you have 20 items with +2 accuracy (from abil 22), but your class has +10 accuracy, then you have +10 accuracy added to the accuracy rating.

There are also two other accuracy abilities, that I do see used very sparingly, but I have not tested those.


User avatar
syntax
Site Admin
Posts: 545
Joined: Tue Jun 02, 2009 10:02 am

Re: MajorMUD Accuracy Formula

Post by syntax »

I did some research into the room light effect and came to the conclusion that only blindness effects accuracy. The code is there for room light to effect it, but the way it's coded it doesn't work.

Here is where the game decides if it's going to subtract 10 accuracy for something room light related:
Image

The first IF is checking against an area in the user record where a bunch of unknown flags are. Looking through the codes I see references to blindness. I did test casting blind on myself and I lost 10 accuracy for it. There could be more conditions that also trigger this.

The second IF is checking if the difference in room light is > 900.

Here is the code from the _get_light_level function:
Image

Effectively, this gets the light level of the room from the room record (which is usually a negative number) and adds that to the cumulative ILLU (ability 13) value from the user. This right off the bat doesn't really make sense because the if in the calling code is looking for >900 to institute a penalty. The way this is written, the more +Illu you have, the more likely you would get up to +900 and be penalized. That is, unless I'm missing something.

But... that doesn't actually matter, either. Circled in red is a condition that says if the calculated value so far is >900 then set it to 900. Meaning, the function would never return >900 anyway. There is one more bit of code right below it that adds a second value to that before actually returning back. From what I can tell, those 4th and 5th arguments to the _get_user_ability_value function are a means for the game to calculate on two abilities at the same time. It looks like it's looking for ability #53 (which NMR defines as "BlindingLight" with an unknown description) and storing the result of that into the &ABIL2_VAL. For the record, this behaves differently for different abilities. For ability 53, it looks like it's only considering the highest value it can find (not totaling them).

So... in conclusion, effectively this room light level function will never return a value >900, and therefore never be penalized in accuracy for room light level alone, unless the character has an unused ability called BlindingLight and the value of that combined with the room and +illu somehow get over 900.

I tested a room with 0 light level versus one with -1000 and there was no difference in accuracy rating.


User avatar
BearFather
Posts: 665
Joined: Sun Feb 09, 2014 6:27 pm
Location: Portland, OR
Contact:

Re: MajorMUD Accuracy Formula

Post by BearFather »

Sounds like it doesn't want you to go too far over 900. And only go over 900 if that blinding light abil is on you. Question is what uses that blinding light, and what would the max value be? Maybe there are worried about some sort of roll over if your too far over 1k.


User avatar
syntax
Site Admin
Posts: 545
Joined: Tue Jun 02, 2009 10:02 am

Re: MajorMUD Accuracy Formula

Post by syntax »

Yeah, it occurred to me as I thought about it some more, and especially with the name of that ability, that this could actually be a penalty for being "too bright".

Firstly, I've confirmed that "barely visible" has no effect on accuracy, either. Played around with different light levels and couldn't get it to change the accuracy rating.

As for blinding light, I tested it. These tests have nothing to do with accuracy:
  • If I have a +1500 Illu (abil 13) item, everything is normal and just very not dark.
  • If I have a +1 Blinding Light (abil 53) on its own, nothing changes.
  • But, put together any combination of +Illu between the room, spells, items, etc to get to 900+ illu and just +1 blinding light and I am blind.
...and I already noted that being blind results in -10 accuracy, regardless of that second bit of code.


cha0tic
Posts: 3
Joined: Wed Mar 12, 2025 10:04 pm

Re: MajorMUD Accuracy Formula

Post by cha0tic »

I am working on a 3rd person combat sim game modeled from the MajorMud Labyrinth Area of majormud. I was working out the Accuracy calculations and stumbled on this post. I was using MME to sort of brute force the values for calculating Accuracy and noticed that the Level, CombatLevel, Agility, Intellect, Charm, Encum, spells, and worn items were all factors in the players calculated Accuracy (at least from an MME perspective). It is interesting that the lighting in the room also affects the players accuracy. Given that my game is losely following the MajorMud concept and being a single-player makes party rank bonus/penalty irrelevant, I was able to calculate the players Accuracy (or what i called BaseAccuracy which is calculations purely on player primary stat values, level and combatLevel before any worn equipment, spell buffs/curses, encum bonus/penalty) using the following, which passed all my unit tests.

Code: Select all

public static int CalculateBaseAccuracy(int _level, int _combatLevel, int _agility, int _intellect, int _charm)
{
	int levelAndCombatModifier = CalculateLevelAndCombatAccuracyModifier(_level, _combatLevel);
	int agilityModifier = CalculateAgilityAccuracyModifier(_agility);
	int intellectModifier = CalculateIntellectAccuracyModifier(_intellect);
	int charmModifier = CalculateCharmAccuracyModifier(_charm);

	return levelAndCombatModifier + agilityModifier + intellectModifier + charmModifier;
}

public static int CalculateLevelAndCombatAccuracyModifier(int _level, int _combatLevel)
{
	int baseAccuracy = 13 + (6 * (_combatLevel - 1));
	int accuracy = baseAccuracy;
	int leapBonus = (_combatLevel * 2) + 3;

	for (int i = 2; i <= _level; i++)
	{
		int squareRoot = (int)Math.Sqrt(i);
		accuracy += (squareRoot * squareRoot == i) ? leapBonus : 1;
	}

	return accuracy;
}

public static int CalculateAgilityAccuracyModifier(int _agility)
{
	if (_agility <= 20) { return -16 + (_agility / 3); }
	if (_agility >= 21 && _agility <= 52) { return (_agility - 21) / 3 - 9; }
	if (_agility >= 53) { return (_agility - 53) / 3 + 1; }

	throw new ArgumentOutOfRangeException("_agility", "Value is out of bounds!");
}

public static int CalculateIntellectAccuracyModifier(int _intellect)
{
	if (_intellect <= 2) { return -8; }
	if (_intellect >= 45 && _intellect <= 55) { return 0; }
	if (_intellect >= 3 && _intellect <= 44) { return ((_intellect - 3) / 6) - 7; }
	if (_intellect >= 56) { return ((_intellect - 56) / 6) + 1; }
	
	throw new ArgumentOutOfRangeException("_intellect", "Value is out of bounds!");
}

public static int CalculateCharmAccuracyModifier(int _charm)
{
	if (_charm == 0) { return -5; }
	if (_charm >= 1 && _charm <= 40) { return (_charm - 1) / 10 - 4; }
	if (_charm >= 41 && _charm <= 59) { return 0; }
	if (_charm >= 60 && _charm <= 109) { return (_charm - 60) / 10 + 1; }
	if (_charm >= 110) { return (_charm - 100) / 10 + 5; }

	throw new ArgumentOutOfRangeException("_charm", "Value is out of bounds!");
}


User avatar
syntax
Site Admin
Posts: 545
Joined: Tue Jun 02, 2009 10:02 am

Re: MajorMUD Accuracy Formula

Post by syntax »

cha0tic wrote: Thu Mar 13, 2025 4:54 pm I am working on a 3rd person combat sim game modeled from the MajorMud Labyrinth Area of majormud. I was working out the Accuracy calculations and stumbled on this post. I was using MME to sort of brute force the values for calculating Accuracy and noticed that the Level, CombatLevel, Agility, Intellect, Charm, Encum, spells, and worn items were all factors in the players calculated Accuracy (at least from an MME perspective). It is interesting that the lighting in the room also affects the players accuracy. Given that my game is losely following the MajorMud concept and being a single-player makes party rank bonus/penalty irrelevant, I was able to calculate the players Accuracy (or what i called BaseAccuracy which is calculations purely on player primary stat values, level and combatLevel before any worn equipment, spell buffs/curses, encum bonus/penalty) using the following, which passed all my unit tests.
What do you mean brute forced MME? The current version of MME does not calculate accuracy? (next release will though!)

It's cool that you were able to figure something out, but I see a few differences right off the bat. What I shared is an interpretation of the code directly from the dll. Unless I made a mistake somewhere, it's accurate.


cha0tic
Posts: 3
Joined: Wed Mar 12, 2025 10:04 pm

Re: MajorMUD Accuracy Formula

Post by cha0tic »

I nerded out. The hover tooltip in equipment panel shows the bonus/penalty applied to each derived stat. So i Just cleared out all equipment, set class to a combat 1 (mage), then kept increasing level, noting the change in the accuracy tooltip (Level/Combat). Then did same for Combat 2 and combat 3. Noticed a pattern for "levels with an larger increase in accuracy" (4, 9, 16, 25) than assumed the next level with large increae would be 5 or 11 levels higher and confirmed(5, 7, 9, 11, 13, 15, etc) was a pattern that started at level 4. So 4+5=9, 9+7=16, etc. Verified my assumptions in mme with combat 2 and 3. Noticed combat 1 had a base of 13, and combat 2 had base of 19, combat 3 had a base of 25, and assumed that each combat level raised by 6 so combat 4 must be base 31 and combat 5 base 37. Verified in mme, wrote a method and some unit tests to confirm, getting the expected result from mme. so each level increased accuracy in the (Level/Combat) by 1 unless it was a "leap level", where it would increase it by the combatlevels leapBonus: (_combatLevel * 2) + 3 So 5 for combat 1, 7 for combat 2, etc.

Then did same idea with Agility, Intellect, Charm. zeroing them all out. and increasing a single stat until a had enough data to assume some sort of pattern. Like in Agility: starting at 20(which is the lowest base agility with data i was using from paramud dats) every 3 raised decreased the floor penalty of -9 by 1. Then i played around with the stat till i found a range of values that gave a 0 bonus/pen(48-52). I then assume that after the "threshold range" that +1 would be applied every 3. So to verify, i entered numbes into mme. I then wrote a method and created unit tests plugging in a bunch of different values to test and the expected results gathered from mme. After, all 4 of the Modifer methods were written, i wrote several unit tests for CalculateBaseAccuracy() to test different level and combat level combinations with different agility, intellect, charm settings. So in theory I took a bruite force approach to gather all the data points i needed to create the methods. I am currious if I changed the dat file from Paramud to the stock.data if my methods would still yield proper results. Cheers.


User avatar
syntax
Site Admin
Posts: 545
Joined: Tue Jun 02, 2009 10:02 am

Re: MajorMUD Accuracy Formula

Post by syntax »

I take it you were using the Paramud version of mme… my version does not calculate accuracy (until now). I haven’t looked at how they are calculating accuracy to see if it’s the same as the OG game.


User avatar
syntax
Site Admin
Posts: 545
Joined: Tue Jun 02, 2009 10:02 am

Re: MajorMUD Accuracy Formula

Post by syntax »

syntax wrote: Fri Mar 14, 2025 6:50 am I take it you were using the Paramud version of mme… my version does not calculate accuracy (until now). I haven’t looked at how they are calculating accuracy to see if it’s the same as the OG game.
Also... MME code is available online (both mine and the gmud fork). Would be much easier to figure stuff out that way :)

Here is how I am calculating accuracy in the next version of mme:
https://github.com/syntax53/MMUD-Explor ... frm#L23957

And here is how gmud is calculating it:
https://github.com/stevek202/GMUD-Explo ... frm#L21220

This part is slightly different:
OG mud:

Code: Select all

nAccyBonus = nAccyBonus * (nCombatLevel - 1)
nAccyBonus = (nAccyBonus + (nCombatLevel * 2) + Fix(Val(txtGlobalLevel(0).Text) / 2) - 2) * 2
GMUD:

Code: Select all

accuracy = Fix(((levelValue * (combat + 1)) + ((((combat + 2) * 2) + (level / 2)) - 2)) * 2)
I wasn't sure if these would actually calculate differently, but they do. My MME calculates a value of 24 given a level of 9 and combat 1. GMUD is calculating 28 for those same parameters. Note that in my version I am taking the raw value of the combat rating from the DB and the GMUD version is using the adjusted "visual value" of the combat rating (raw combat-1 = 3 in the database. I am using the 3. GMUD is using 1. But, I have accounted for this in my calculation when I compared them).

Further, the next MME only utilizes STR and AGI for additional accuracy bonuses, as this how is OG mud calculates it:

Code: Select all

accuracy += Fix((charStr - 50) / 3)
accuracy += Fix((charAgi - 50) / 6)
GMUD is utilizing AGI, INT, and CHA:

Code: Select all

accuracy = Fix((charAgi - 50) / 3)
accuracy += Fix((charInt - 50) / 6)
accuracy += Fix((charCharm - 50) / 10)


cha0tic
Posts: 3
Joined: Wed Mar 12, 2025 10:04 pm

Re: MajorMUD Accuracy Formula

Post by cha0tic »

I appreciate the insight. I have been making use of the github code to create things like manaRegen, and maxHP. But pretty much just from modMMudFunc.bas, so I am thankful for the links you posted. I had briefly browsed through the other files but it has been a couple decades since I really used Visual Basic (or VBA). Thanks again for all the advice.


Post Reply