|
I have been doing services for multiple servers, and noticed that a lot of servers have terrible implementations of combat. This was quite a shock, considering next year will mark the 10-year anniversary of the release of the Evolution of Combat (known as ‘EoC’) update to the main game.
Therefore, I have decided to spend some time into documenting some key fundamentals of what I believe can best be improved in most servers. This thread mainly be focused on;
- General points
- Calculating NPC accuracy
- 503+ Equipment stats
- 503+ Mathematical approach to guessing
General points
One of the biggest problems most servers have, is that they put too many differences between NPC and Player combat when it comes to calculating rolls, but also performing special attacks focused on target levels e.g. Bandos Godsword lowering a target’s stats. The truth is that Runescape’s combat system is not actually splitting behavior from Players and NPC’s that much (obviously there are some exceptions). Both are seen as entities, and therefore a lot of known combat formulas/mechanics can be applied to NPC’s as well (1). This includes, but is not limited to:
- Calculating NPC Combat level
- Calculating NPC Accuracy
- Calculating NPC Levels
- Assuming NPC's have equipment stats as well.
Calculating NPC Accuracy
In 2014, Jake_ has released a similar thread explaining how to calculate Player versus Player accuracy. Based on (1), we are going to implement NPC’s into this formula. What is important to know, is that his accuracy formula (which has little to none difference from the formulas used by the OSRS community to calculate DPS) uses the following factors;
- Combat levels: Attack, Defense, Ranged and Magic
- Equipment stats such as Stab Defense, Ranged Attack...
- Style bonus: Stab, Slash, Crush, Ranged, Magic
- Prayer bonuses; Prayer spells can give the user bonuses used in calculating accuracy
- Stance bonuses: Accurate, Aggressive, Controlled and Defensive.
- Optional factors e.g. accuracy bonuses, special attack bonuses…
Some of these factors are easy to fill:
Prayer bonuses: Npc’s don’t use prayer and those who use protection prayers (e.g. kalphite queen) have zero effect on accuracy. However, curses leech prayers do provide a negative prayer bonus on a target, which is the only case where npc’s have a prayer bonus other than 0.
Stance bonuses: Npc’s use a neutral stance that provided a bonus point of 1 to both offense and defense (which means npc stance = controlled)
Optional factors: Npc’s don’t use any optional factors. Therefore this can also be left empty.
The factors Combat Levels, Equipment stats and Style bonus are also easy to fill… if you’re limiting yourself to OSRS. This is because Jagex enabled the Monster Examine magic spell to include important combat information in an update in 2014. However, a good chunk of RSPS development focusses on revisions between 503 and 742, and back then, players weren’t able to gather this information. In fact, most players (if not all) were not even aware of NPC’s sharing formulas and mechanics with players. This also means that the wiki pages back in 2008-2012 did not include any information such as npc combat levels. Before we get into the real fun, there are a few small modifications that have to be made to the accuracy formula when it comes to calculating augmented_defence.
First of all, when it comes to magic based attacks, magic defense of players exists of 70% of a player’s magic level and 30% of their defense level. For npc’s however, magic defense is calculated using 100% of their magic level.
Second, higher revisions have an additional defensive equipment stat called Summoning Bonus used in calculating augmented_defence as well. Truthfully speaking, I am not completely aware of the exact numbers for this one, but I personally have implemented it myself by checking if an attacker is a familiar, and if so, calculating def_equipment_bonus by adding up 70% of the original def_equipment_bonus and 30% of the summoning bonus.Code:if (isNPC) effective_magic = def_current_magic_level else { effective_magic = Math.floor(def_current_magic_level * 0.7) effective_defence = Math.floor(def_current_defence_level * def_defence_prayer_bonus * 0.3) }
503+ Equipment statsCode:def_equipment_bonus = Math.floor(0.7 * def_equipment_bonus + 0.3 * def_summoning_bonus);
Okay, if equipment stats were not available until 2014, how are we going to get these from npcs that were released after 2007 and do not exist in higher revisions (e.g. Nex)? Well, for player items, equipment stats are found in the cache, and you’re definitely not going to guess where I found them for npcs….in the cache! In rev731, the equipment stats are found in NPC definitions -> opcode249. This instruction is used to map additional npc information. Here is a table that displays relevant keys and values.
Key Value 0 stab_attack 1 slash_attack 2 crush_attack 3 magic_attack 4 range_attack 5 stab_defense 6 slash_defense 7 crush_defense 8 magic_defense 9 range_defense 641 melee_strength 643 range_strength 965 magic_strength
As expected, npc’s do not have equipment prayer bonus or defensive summoning bonus. However, they do have strength bonuses, which also strongly hints that NPC max hit is calculated based on the same formula used for players as well! Now that we have the equipment stats, we can do an accurate guess on the Style bonus. The Style bonus is only relevant in offensive melee attacks, and therefore should not become a consistent problem when calculating accuracy. That being said, npc’s often use only one style when using melee, which means you can either guess it by looking at what kind of attack it does (does it stab you with a dagger, slash you with a sword or crush you with a hammer?), you can look at the npc classtype (e.g. trolls tend to use crush, while demons use slash) but also check the equipment stats. If an npc only has bonuses in one specific style, it most likely uses that style as well.
Important notes: The equipment stats may differ from OSRS npcs, mainly due to changes / re-releases e.g. godwars, but we now have all equipment data required for npcs. Also, this data is not found in npc definitions in lower revisions such as 634. Therefore you should grab these from a 718+ cache (not sure when they started putting equipment data in defs, but 718 is the lowest rev I know of).
503+ Mathematical approach to guessing
An npc has 6 levels (apart from combat level, which is calculated using these levels by the way). Attack, Strength, Defense, Magic, Ranged, Hitpoints. While Runescape does calculate max hits using the same formula for calculating player max hit, it is not necessary to entirely copy this as npc max hits were known prior to 2014 as well. That being said, it is very useful to still use that formula in cases where npcs use different styles and only the highest hit is known (e.g. npcs maxing 370 with magic, but 740 with ranged is usually noted as ‘’max hit: 740”). This means that Strength is not that interesting to us at all. Hitpoints level equals to the npc’s lifepoints (/10 when using x10 hits), and considering lifepoints were known back then as well, the only levels we are really interested in are Attack, Defense, Magic and Ranged (since Strength is only used in determining max hit).
So how do we get them?
We can easily gather the following information from the older wiki pages: Combat level, Lifepoints and Max hit. Since we know that, based on (1), npcs use the same formula for combat level and max hit, we can reverse these formulas to accurately guess levels. You may ask why I call it accurately guessing, well that is because Jagex sometimes overrides NPC combat levels to better represent their power (for example: an npc is originally combat level 21, but has a special attack that can do up to 500 damage).
Note: I left out irrelevant factors such as void bonus. The formula’s are also based on x10 hits (e.g. max hit being 400 rather than 40), since the majority of the backed-up wiki pages also use x10 hits.
Melee and Range Max hits
Original formula:
Where M is max hit, P is strength/range level and RB is Relevant Bonus (e.g. range_strength from equipment stats). In order to get P, the original level, we reverse the formula to:
Thanks to this formula, we know have calculated the Strenght / Ranged level. We only need a defense level now, and then we have all levels required for a one-style npc. Now we are going to see how Combat level is calculated.
Where CB is combat level, DEF is defense level, HP is Hitpoints level and S is style type. We can use this formula to determine our defense level by reversing once again. But before we do that, we have to calculate S. S is calculated by:
As you can see, combat level is calculated using the combat style with the highest stats. This is why it is important to use a NPC’s highest max hit excluding special attacks which have custom max hits. Otherwise, you’re going to end up with results that may be very off. Also please keep in mind that melee-based combat levels use both Attack and Strength level, but because we most likely don’t have the Attack level, we can replace the sum of both with multiplying the strength level of 2. This has proven myself to give the most accurate results (and that way you also get an Attack level).
Now that we have calculated S, we can calculate defense using the reversed combat level formula:
Magic Max Hit
TODO
Conclusion
Understanding the numbers is important, because it allows you to gather information that may not be available to you, and better understand how things work. The reason this thread might be a bit too long is because I tried my best explaining things as clear as possible in order for you, the reader, to understand the thoughts and process behind all of this (and hopefully become able to attempt researching something yourself!).
Good thread. Can't wait to read it all when it's fully finished. So far haven't noticed anything incorrect.
Magic max hit is a static value fwiw, just like how each player spell has its own defined max hit, the same applies to NPCs. Max hit of a spell isn't affected by your magic level. It can however be boosted by magic damage % and %-boosting items.
Sadly it's because most people don't care and are in it for the $$$.
Other comments though:
I never got what the purpose of having the npc bonuses available for the client was, without putting their levels on the cache too.
The NPC melee attack bonus (the stat that Graardor has +120 of, next to the NPC str bonus on the osrs wiki) that old school has isn't in the 731+ cache, so I'm curious to hear where you think the osrs team is getting this from.
To add to that, I noticed at some point in 2019, the barrows' brothers melee attack bonuses were removed (I guess they were pointless though?)
Thanks for these formulas though. I have the correct combat formulas implemented that added I while following Bitterkoekje's thread, but I haven't done much pre-eoc content yet as I'm still working on getting all of the pre 2008 quests implemented.
It's important to me to have close to accurate levels for things like armoured zombies, tds, nex etc.
Oh another note, I'm not sure if you used this in determining your formulas for calculating stats, but couldn't solving backwards with bonus experience also be used?
Found here
Hey, really interesting topic. I tried to dump the NPC bonusses from 731, 718 and 742 caches, yet I only ever find the defensive bonusses in the hash map, no keys for offensive ones or strength bonusses. How did you get those? Cheers
I'm using the standard Matrix 718 source to load the caches and then I list all the keys in the NPC definitions hash map, yet it only contains 5 keys each cache for defensive bonusses, sometimes an additional value (not sure for what though).
Using this quick & dirty code in Matrix launcher lmao:
Code:Cache.init(); NPCDefinitions def = NPCDefinitions.getNPCDefinitions(20); // Paladin System.out.println("~ " + def.name + " - Keys ~"); def.parameters.forEach((key, value) -> System.out.println(key + " = " + value));
Sample output with 731 cache from Displee:
Code:~ Paladin - Keys ~ 641 = 220 5 = 87 6 = 84 7 = 76 8 = -10 9 = 79 14 = 5
5 to 9 are the defensive bonusses, 641 is actually 220, tenfold the strength bonus... All the other keys don't exist/are null for me...
OSRS Wiki Info Box for Paladin:
What am I doing wrong?
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |