Biased Random Damage Mod
Moderators: Forum Moderators, Developers
Forum rules
 Please use [code] BBCode tags in your posts for embedding WML snippets.
 To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Biased Random Damage Mod
*edit: This is now on the 1.11 and 1.10 addons servers.*
What is it?
This is a mod that when installed in addons can be accessed from the ingame right click menu. It affects the battle damage system in that damage is no longer simply a full on hit or a miss it uses a bell curve to determine the probability of how much damage will be inflicted based on 2 things,* the chance to hit and the damage. If the chance to hit is 30% and a unit does 10 damage, expect the damage per hit to be 3, more than likely 24, and occasionally higher or lower. If the CTH is 50%, expect the damage to be 5, more likely 46, and again occasionally higher or lower. The spirit of randomness is kept in that there is no real guarantee of the damage numbers, but instead they are biased toward a particular result.
Poison and slow use the stock RNG system to determine if they take effect a poison dart can do damage but may not inflict poison unless it counts as a hit in Wesnoth's usual battle system, same goes for slow.
*there is also a calculation to give a bonus/penalty when attacking a unit of a different level If a L2 unit attacks a L1 unit they get +1 damage. A L3 attacking a L1 gets +2, and the opposite is true, the L1 gets 2. This can be disabled by commenting out line 233 of damage_distribution_mod.lua like so (I consider this to be experimental still in terms of gameplay):
There is another adjustment available as well in the first line of the damage_distribution_mod.lua there is a "steepness" value this can be changed to affect the shape of the bell curve that determines the damage value percentages. A lower number makes it steeper (less random), a higher number makes it flatter (more random).
What is the gameplay like?
In my experience, because of the amount of actual hitting happening, I find myself save loading much less. I've been playing through TROW on normal and have been on the high end of turns to get through scenarios (the PRNG mod is so aggressive I'd get through scenarios pretty quickly). You still get misses and the big hits, and it seems more "realistic" in that not every blow is a perfectly solid one. Is the original balance preserved? Probably not, but I found this system to be pretty fun anyway.
Any feedback on the above customizable settings would be appreciated
***A big thanks to the Mad Coding Genius Dugi for the code***
Enjoy!
What is it?
This is a mod that when installed in addons can be accessed from the ingame right click menu. It affects the battle damage system in that damage is no longer simply a full on hit or a miss it uses a bell curve to determine the probability of how much damage will be inflicted based on 2 things,* the chance to hit and the damage. If the chance to hit is 30% and a unit does 10 damage, expect the damage per hit to be 3, more than likely 24, and occasionally higher or lower. If the CTH is 50%, expect the damage to be 5, more likely 46, and again occasionally higher or lower. The spirit of randomness is kept in that there is no real guarantee of the damage numbers, but instead they are biased toward a particular result.
Poison and slow use the stock RNG system to determine if they take effect a poison dart can do damage but may not inflict poison unless it counts as a hit in Wesnoth's usual battle system, same goes for slow.
*there is also a calculation to give a bonus/penalty when attacking a unit of a different level If a L2 unit attacks a L1 unit they get +1 damage. A L3 attacking a L1 gets +2, and the opposite is true, the L1 gets 2. This can be disabled by commenting out line 233 of damage_distribution_mod.lua like so (I consider this to be experimental still in terms of gameplay):
Code: Select all
result_damage = result_damage  defender_code.level + attacker_code.level
There is another adjustment available as well in the first line of the damage_distribution_mod.lua there is a "steepness" value this can be changed to affect the shape of the bell curve that determines the damage value percentages. A lower number makes it steeper (less random), a higher number makes it flatter (more random).
What is the gameplay like?
In my experience, because of the amount of actual hitting happening, I find myself save loading much less. I've been playing through TROW on normal and have been on the high end of turns to get through scenarios (the PRNG mod is so aggressive I'd get through scenarios pretty quickly). You still get misses and the big hits, and it seems more "realistic" in that not every blow is a perfectly solid one. Is the original balance preserved? Probably not, but I found this system to be pretty fun anyway.
Any feedback on the above customizable settings would be appreciated
***A big thanks to the Mad Coding Genius Dugi for the code***
Enjoy!
 Attachments

 Damage_Distribution_Mod.tar.gz
 (2.65 KiB) Downloaded 577 times
Last edited by Crow_T on October 15th, 2014, 9:04 pm, edited 1 time in total.
Re: Biased Random Damage Mod
I did not (yet) try this, so just one question:
Does the battle preview "Damage calculation" dialog know about your system, and can calculate the right information?
Does the battle preview "Damage calculation" dialog know about your system, and can calculate the right information?
Re: Biased Random Damage Mod
No, it's not that "deep" codewise, I'm not sure you'd be able to to that with lua as opposed to a C code patchpauxlo wrote:I did not (yet) try this, so just one question:
Does the battle preview "Damage calculation" dialog know about your system, and can calculate the right information?
Looking at it in game it looks like it is totally fried I don't use that feature because IMO those numbers are irrelevant the RNG will do what the RNG wants. Unless you are going to do several takes at one attack then those numbers will start to make sense.
Edit:Also I imagine since this system has so many combinations of outcomes the current code doesn't handle it well.

 Posts: 76
 Joined: July 12th, 2014, 4:09 am
Re: Biased Random Damage Mod
Crow_T, congrats you finally got your idea working I played couple of games, damages seem to be quite close to estimations.
Re: Biased Random Damage Mod
Thanks for trying this out Yes I've been playing on a slower speed and sort of keeping track mentally of the damage that happens, it seems a good balance of expected/random enough to keep it interesting.optimother wrote:Crow_T, congrats you finally got your idea working I played couple of games, damages seem to be quite close to estimations.
This is now on the 1.11 and 1.10 addons servers.
 Chief_Chasso
 Posts: 132
 Joined: December 15th, 2012, 2:36 am
Re: Biased Random Damage Mod
Hey, I've been trying this mod out. However, poison and slow doesn't seem to work. I did comment out the level bonus/penalty... I'm not sure if that has anything to do with it?
SP Campaign: Rally For Roanic
Re: Biased Random Damage Mod
Hmmm, do you mean they never take effect? It's set up to utilize the stock Wesnoth RNG to determine if the actual effect of poison/slow takes place while using the mod for actual damage, the idea being that poison/slow wouldn't be a guaranteed effect.
One thing I've noticed happening on occasion is that if a unit misses the first hit they will miss all the rest, have you noticed that at all? Generally I see it with thugs and their higher levels, probably because there are 4 swings.
One thing I've noticed happening on occasion is that if a unit misses the first hit they will miss all the rest, have you noticed that at all? Generally I see it with thugs and their higher levels, probably because there are 4 swings.
 Chief_Chasso
 Posts: 132
 Joined: December 15th, 2012, 2:36 am
Re: Biased Random Damage Mod
Yeah, I meant poison/slow never seem to take effect. Maybe it's just been a string of bad/good luck,
Actually, that seems to be true, but I'll make sure to look for a pattern. It seems like WC's seem to miss a lot too. I had 3 WC's in a row miss all their hits.One thing I've noticed happening on occasion is that if a unit misses the first hit they will miss all the rest, have you noticed that at all?
SP Campaign: Rally For Roanic
Re: Biased Random Damage Mod
There is a new version uploaded to the 1.10 and 1.11 servers, the constant miss bug should be fixed.
Re: Biased Random Damage Mod
Is there a new version for 1.12, too,?
Thanks for directing me here, I like that system ^^ makes it more realistic, that is for sure. Though, the 1 2 damage on leveldifference is worrying me because of Lvl5 Lvl6 and Lvl7 units in some campaigns. My lvl 1 units would get a 6 damage penelity, combine it with the unit having good resistance against the attack, and the damage will result in 0 (or maybe 1 if there is a minimum damage thingy going on). A lvl1 physical damage unit against a lvl 3 ghost seems also to have an not so nice gap.
Thanks for directing me here, I like that system ^^ makes it more realistic, that is for sure. Though, the 1 2 damage on leveldifference is worrying me because of Lvl5 Lvl6 and Lvl7 units in some campaigns. My lvl 1 units would get a 6 damage penelity, combine it with the unit having good resistance against the attack, and the damage will result in 0 (or maybe 1 if there is a minimum damage thingy going on). A lvl1 physical damage unit against a lvl 3 ghost seems also to have an not so nice gap.
I do GPE(Genuine Playing Experience), Screenshotreinforced and detailed BugReports for Campaigns. If you want me to check yours, be it PreAlpha, Alpha, Beta or finished, let me know. Since I don't know anything about coding, I'll be unable to tell you why something bad happens though. PM me.
Re: Biased Random Damage Mod
It should be on the 1.12 addon server let me know if it isn't
In the first post I describe how to disable the level difference bonus, which would be a good idea if you are playing campaigns with highlevel custom units.
In the first post I describe how to disable the level difference bonus, which would be a good idea if you are playing campaigns with highlevel custom units.
Re: Biased Random Damage Mod
A new version with some fixes is out, from Dugi:
I have made an update to the biased random damage mod. It fixes the multiplayer desynch issue (uses the WML random number generator instead of the lua one as before, because the WML one is synched and the lua one isn't). I have also added support for most custom weapon specials (so simpler things like set chance to hit to 80 when defending or increase chance to hit by 20 should work, but stuff like decrease the opponent's chance to hit by 20 if he's an orc standing in swamp will not).
Re: Biased Random Damage Mod
 couldn't find it 
EDIT: Sorry, my bad, found it. Ignore my comment
Really cool idea
EDIT: Sorry, my bad, found it. Ignore my comment
Really cool idea
Author of the Underness Series, consisting of V parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Standalone works: The Ravagers  now for 1.14, with new bugs!
Standalone works: The Ravagers  now for 1.14, with new bugs!

 Posts: 2
 Joined: January 26th, 2017, 1:48 am
Re: Biased Random Damage Mod
I'm playing on 1.12.6, and I've been noticing a quirk of the system which is a bit bothersome. It seems that retaliation damage is only calculated once; that is, if a unit is attacked, they will strike back for the same amount of damage with each of their retaliation attacks. This adds a bit of swingy randomness to combat which isn't present in vanilla BfW, because an unusually high or low roll has its effects multiplied over however many retaliation attacks the defending unit has. Overall this mod is great  I, too, am much less prone to impulsive saveloading with it active, and I like how it makes combat outcomes more granular than vanilla where e.g. an attacking spearman would always deal 7, 14, or 21 damage  but the onesharedresult retaliation attack thing has stuck out every now and then and I wanted to bring it to the addon devs' attention and/or hear from them on it.
It also sorta seems like the system favors numerous smaller attacks over fewer large attacks, but I haven't done any detailed tracking of that so it may just be me seeing a pattern where there isn't one.
It also sorta seems like the system favors numerous smaller attacks over fewer large attacks, but I haven't done any detailed tracking of that so it may just be me seeing a pattern where there isn't one.
Re: Biased Random Damage Mod
yet another idea on this topic.
I put it here because maybe it could be similar to the one realized in your MOD.
the damage is: partly random and partly equal to the expected value of that shot (default 50% 50%)
in pseudocode (actually R):
D′ = D ± ∆(D,μ)/k
the damage is decreased or increased for a fraction of the difference between the damage and the expected value
regards
I put it here because maybe it could be similar to the one realized in your MOD.
the damage is: partly random and partly equal to the expected value of that shot (default 50% 50%)
in pseudocode (actually R):
Dam = 14 # damage examples
dumm = T # it's an Hit shot ? [True or False]
p_shot = 4/10 # the probability to hit ... p(dumm == T)
K = 2 # p arameter fixed on 2 that means: 50% by random and 50% by the expected value .. (also try K = 1.5)
μ = p_shot * Dam # expected value for the shot, calculation
Altered_Damage = round( Dam * dumm − (dumm * 2 − 1) * ((Dam * dumm − (dumm * 2 − 1) * μ)/K) )
in other words dumm = T # it's an Hit shot ? [True or False]
p_shot = 4/10 # the probability to hit ... p(dumm == T)
K = 2 # p arameter fixed on 2 that means: 50% by random and 50% by the expected value .. (also try K = 1.5)
μ = p_shot * Dam # expected value for the shot, calculation
Altered_Damage = round( Dam * dumm − (dumm * 2 − 1) * ((Dam * dumm − (dumm * 2 − 1) * μ)/K) )
D′ = D ± ∆(D,μ)/k
the damage is decreased or increased for a fraction of the difference between the damage and the expected value
regards