RimWorld

RimWorld

Blazikasu Sep 24, 2019 @ 11:23am
Melee attacks ¿How do they work?
Melee weapon usually have 2 or 3 attacks. One with the base, and another is a stab, a cut, a blunt hit, a combination of those. How does that work? IE. If I make a melee attack and hit, do I roll a dice or something to see which attack procs? if so, what's the chance? Would it be the equal chance for every attack (IE 50/50 or 33/33/33)? If not, can the attack proc more than a hit simultaneously (IE. weapon has 2 identical stab attacks, can I get 2 stabs from a single attack, or a stab and hit with the base)? How does this affect the CD?
I looked this up on the wiki but came out empty handed, at most it lists the attacks available for the weapons but it says nothing about chances per attack or something.

Thanks in advance for at least taking your time to chime in here!
Originally posted by Aryath:
If a melee weapon has several attacks, what are the chances of each attack to get used?
The chances are not hardcoded. Rather, they are calculated based on the attack's power and cooldown. (This is based on own experimentation results, see thread for details)

higher power = higher chance
higher CD = higher chance

Own experimentation data of a Cleaver with a handle (blunt) and edge (sharp) attack:
attack [power] | [CD]

handle 5 | 2
edge 12 | 1.8
chances handle vs edge: 16.2% to 83.8%
total DPS 6.59

handle 1 | 2
edge 12 | 1.8
chances handle vs edge: 0.74% to 99.26%
total DPS 7.28
(decreasing the power of the weaker attack in this case actually increased the total DPS, because the weaker attack is used much less)

handle 5 | 10
edge 12 | 1.8
total DPS 4.00
chances handle vs edge: 49% to 51%

handle 5 | 0.4
edge 12 | 1.8
total DPS 7.57
chances handle vs edge: 3.74% to 96.26%

Can several attacks hit simultaniously?
As far as I can tell, no, they can't. Even if you have a flail with separate attacks for each of the 3 heads, that could IRL hit an enemy at the same time, the game will always choose only 1 attack, then use that attack's CD and then use the next, randomly chosen attack.
< >
Showing 1-15 of 18 comments
grapplehoeker Sep 24, 2019 @ 11:28am 
I very rarely use melee, so I'll just provide you with a link ;)
https://rimworldwiki.com/wiki/Weapons#Melee_Formulas
Last edited by grapplehoeker; Sep 24, 2019 @ 11:34am
Aryath Sep 24, 2019 @ 11:30am 
That didnt really answer the question

If I had to take a guess, I'd say all attacks have the same chance, they cant proc more than once at a time, and thus the CD is not affected by the attack type number of procs.

Edit: I just looked at the DPS of a random melee weapon with 2 attacks and noticed that they DONT have the same chance! Otherwise, the average DPS and AP would be different...

Edit2: The chance for each attack is not hardcoded into the attributes of the weapon (it's a weapon from a mod, btw), so the chance for each attack has to be calculated by an algorithm by the game

Edit3: The chances of those 2 attacks are about 15% to 85%, so they are not equal at all
Last edited by Aryath; Sep 24, 2019 @ 12:00pm
Aryath Sep 24, 2019 @ 12:14pm 
To sum it up:
1) the game uses a fancy algorithm that decides the chances of a melee weapon's attacks. And it seems nobody knows how that algorithm actually works.

2) You cant proc more than 1 hit at once. IRL, how would you hit an enemy with a cleaver with the handle (blunt) and edge (sharp) at the same time!?

3) The CD after the attack is based on which attack was used. E.g. if it used the handle, it has 2s CD, and if it used the edge, it has 1.8s CD (those are hardcoded attributes for each attack).
Last edited by Aryath; Sep 24, 2019 @ 12:17pm
Blazikasu Sep 24, 2019 @ 12:38pm 
I see. So I guess at least the main attack of a weapon should have more chances to proc than the weak base hit. That's helpful to know!
Originally posted by Thaliviel:
To sum it up:
2) You cant proc more than 1 hit at once. IRL, how would you hit an enemy with a cleaver with the handle (blunt) and edge (sharp) at the same time!?
Hum, all this doubts came from installing some mods with medieval weapons, and you have weapons like flails, that have a weapon attack for each of the 3 heads on the flail plus the base attack. If you look at it from a real world perspective, it would be possible to get more than a single head to hit the target. Or a trident, where a prong in real life could pierce the target on a single point, but you could actually get all 3 to pierce a limb or the body, from a single well aimed stab.
It's also an interesting possibility to consider for weapons like that, to have more than single hit to land, given blunt weapons like maces can hit more than a single body part from a blow (limb/head + body).
Last edited by Blazikasu; Sep 24, 2019 @ 12:41pm
Monoxide Sep 24, 2019 @ 12:45pm 
Same question was asked a few days ago - I dont know if anyone came up with an answer. My posts can be mostly disregarded as I am no longer convinced I am correct, though I dont know if I am wrong either.

https://steamcommunity.com/app/294100/discussions/0/2952595757899419774/
Aryath Sep 24, 2019 @ 12:51pm 
Originally posted by Byron Love:
you have weapons like flails, that have a weapon attack for each of the 3 heads on the flail plus the base attack. If you look at it from a real world perspective, it would be possible to get more than a single head to hit the target ...
While that is certainly true, the game has no chance to know which weapons can cause which attacks to hit simultaniously at which chance, if that info is not hardcoded somewhere.

At least for that cleaver, it is not hardcoded, and I doubt that it is hardcoded for any weapon.

If you have some time you can experiment with some pawns using melee weapons and look at the fight log. Maybe you'll discover something interesting; maybe it just plainly works like we suspect, without multiple hits...
Last edited by Aryath; Sep 24, 2019 @ 12:52pm
elipod Sep 24, 2019 @ 12:59pm 
Originally posted by Thaliviel:
1) the game uses a fancy algorithm that decides the chances of a melee weapon's attacks. And it seems nobody knows how that algorithm actually works.
Looks like weighted random, some attacks have <chanceFactor>
for example: in "Races_Humanlike.xml" human has 0.07 for bite, 0.2 for head bash, and none specified for left and right fists, assuming 1 for each.

That said, I don't see <chanceFactor> in weapon defs.
Aryath Sep 24, 2019 @ 1:23pm 
Originally posted by Monoxide:
Same question was asked a few days ago - I dont know if anyone came up with an answer
I feel sorry for Poliwog, that discussion went into entirely different ways, but nobody even slightly answered his real question.

"Is there some way to tell how often a pawn will use any one of these particular attacks?"

I've been thinking some more about it, and the only value that I see which could be used as a basis for calculating the chance of any attack is its DPS (damage and CD, maybe also AP to some extent?). That Cleaver does not have any type specified, i.e. it is not a 'sharp' weapon per se. So it is not using the edge attack more often because it is the attack which corresponds to its type, but simply because that attack is more powerful.

Some calculations:
Cleaver
handle: power 5, cd 2, DPS 2.5
edge: power 12, cd 1.8, DPS 6.7
handle vs edge: about 15:85

Mace (vanilla)
handle: power 9, cd 2, DPS 4.5
head: power 15.7, cd 2, DPS 7.85
handle vs head: 24.78% to 75.22%

the Cleaver has a higher difference between it's attacks DPS and is using the more powerful attack more often than the mace, which has a lower difference in DPS, as far as I can tell...
Last edited by Aryath; Sep 24, 2019 @ 1:24pm
Aryath Sep 24, 2019 @ 1:38pm 
Wow!

I went ahead and reduced the power of the Cleaver's handle attack from 5 to 1

And guess what!?
The total DPS increased!! From 6.59 to 7.28!

The new attack chances are
handle vs edge: 0.74% to 99.26%

So I was right, more powerful attacks are used more often. And they are used even more often the higher the difference in DPS is.

I could look into how changing CD and AP changes those next...
Aryath Sep 24, 2019 @ 1:48pm 
I increased the handle CD from 2s to 10s, which yields the same DPS for this attack as reducing the power to 1.

However, the total DPS is now 4.00

handle vs edge: 49% to 51%

This is weird. Increasing the CD and thus decreasing the attack DPS seems to have the opposite effect on its chance.

That means:
higher power = more chance
higher CD = more chance
Aryath Sep 24, 2019 @ 1:55pm 
Now I decreased the handle CD to 0.4s
Total DPS = 7.57
handle vs edge: 3.74% to 96.26%

So that confirms it:
higher CD and higher power = higher chance for that attack to get used
Last edited by Aryath; Sep 24, 2019 @ 1:55pm
Preechr Sep 24, 2019 @ 2:03pm 
Talking straight out my butt, but my thinking is that weapons have a chance to hit or miss, which is based on the skill of the wielder, but sharp weapons also have a chance to not miss but not hit with the blade, which is likely also tied to skill. Blunt weapon types, like clubs, vary in dps due to the quality of construction and the blunt modifier for the material used to make it. The type of blunt damage done is more related to the body part being hit and its health after the hit. Mangled, shattered, destroyed, bruised, etc all seem to be more descriptive of the extent of damage (or rather the health left) on whatever was randomly hit. As someone said, blunt damage is just done, so without residual bleeding there's less chance of a downed pawn dying with blunt.

Sharp weapon types do piercing, cutting, etc, but pretty sure any of these can cause bleeding as well. My guess is that a pawn with lower skill has a higher chance of hitting with the wrong part of a sharp weapon as well as missing, so instead of just sharp damage types you could also see blunt damage because they suck at melee. I would bet that even a level 20 melee fighter would still see some random blunt hits, just like a level 20 tailor can still randomly, if rarely, screw up a hat.

There are, by the way, additional types of melee damage effects that I think are probably also related to skill. A good fighter *probably* has a higher chance of flinging some of whatever they are standing on (sand, water, dirt, mud...) in the eyes of his opponent, temporarily affecting their vision and thus their ability to land hits.

The best way to figure out what you are looking for here is to simply test it. Start a game and use dev tools to make a nice big stone surface and then spawn in some pawns and steel daggers, all of the same quality. Save the game and set their skill levels to 20 then make them fight. Do a bunch of fighters all at once so you can get a clear idea of what's going on. Then do it all again from your save point with their levels at 5, 10 and 15. Write down what you see from each fight and you should be able to see some patterns emerging that give you a better idea of what's going on under the hood than the wiki or us just guessing will.
Last edited by Preechr; Sep 24, 2019 @ 2:10pm
Preechr Sep 24, 2019 @ 2:06pm 
Oh... I kept getting interrupted as I typed that and forgot to mention that when a sharp weapon does sharp damage, the combination of skill, weapon material sharp modifier and luck determine the damage, but when they screw up and cause blunt damage, the weapon material's blunt modifier is used.
Aryath Sep 24, 2019 @ 2:11pm 
As for AP, changing blunt and sharp does not do anything to the AP value of an attack.

The AP value depends on the power.
power = 5 --- AP = 8.2%
power = 1 --- AP = 1.6%

And we already know that changing the power changes the chance, so nothing new here.
I'll end my experiments at this point. I hope that info is useful in some way :)
Aryath Sep 24, 2019 @ 2:17pm 
@Preechr
that is all nice and swell, but actually nobody asked for that kind of info
nevertheless, it could be useful to someone, so I dont think your efforts were wasted :)

just a tip: before writing an essay about something, make sure what the questioner actually wants to know...
Last edited by Aryath; Sep 24, 2019 @ 2:24pm
< >
Showing 1-15 of 18 comments
Per page: 1530 50

Date Posted: Sep 24, 2019 @ 11:23am
Posts: 18