Biased Random Damage Mod

The place to post your WML questions and answers.

Moderator: Forum Moderators

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.
Post Reply
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Biased Random Damage Mod

Post by Crow_T »

*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 in-game 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 2-4, and occasionally higher or lower. If the CTH is 50%, expect the damage to be 5, more likely 4-6, 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 1008 times
Last edited by Crow_T on October 15th, 2014, 9:04 pm, edited 1 time in total.
User avatar
pauxlo
Posts: 1047
Joined: September 19th, 2006, 8:54 pm

Re: Biased Random Damage Mod

Post by pauxlo »

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?
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: Biased Random Damage Mod

Post by Crow_T »

pauxlo 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?
No, it's not that "deep" code-wise, I'm not sure you'd be able to to that with lua as opposed to a C code patch :hmm:
Looking at it in game it looks like it is totally fried :lol: 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.
optimother
Posts: 76
Joined: July 12th, 2014, 4:09 am

Re: Biased Random Damage Mod

Post by optimother »

Crow_T, congrats you finally got your idea working :) I played couple of games, damages seem to be quite close to estimations.
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: Biased Random Damage Mod

Post by Crow_T »

optimother wrote:Crow_T, congrats you finally got your idea working :) I played couple of games, damages seem to be quite close to estimations.
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.

This is now on the 1.11 and 1.10 addons servers.
User avatar
Chief_Chasso
Posts: 132
Joined: December 15th, 2012, 2:36 am

Re: Biased Random Damage Mod

Post by Chief_Chasso »

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
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: Biased Random Damage Mod

Post by Crow_T »

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.
User avatar
Chief_Chasso
Posts: 132
Joined: December 15th, 2012, 2:36 am

Re: Biased Random Damage Mod

Post by Chief_Chasso »

Yeah, I meant poison/slow never seem to take effect. Maybe it's just been a string of bad/good luck,
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?
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.
SP Campaign: Rally For Roanic
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: Biased Random Damage Mod

Post by Crow_T »

There is a new version uploaded to the 1.10 and 1.11 servers, the constant miss bug should be fixed.
Krolan
Posts: 32
Joined: November 23rd, 2014, 7:12 pm

Re: Biased Random Damage Mod

Post by Krolan »

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 level-difference 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), Screenshot-reinforced and detailed Bug-Reports for Campaigns. If you want me to check yours, be it Pre-Alpha, 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.
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: Biased Random Damage Mod

Post by Crow_T »

It should be on the 1.12 addon server- let me know if it isn't :geek:

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 high-level custom units.
User avatar
Crow_T
Posts: 851
Joined: February 24th, 2011, 4:20 am

Re: Biased Random Damage Mod

Post by Crow_T »

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).
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Biased Random Damage Mod

Post by WhiteWolf »

- couldn't find it -
EDIT: Sorry, my bad, found it. Ignore my comment :D
Really cool idea :)
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
ExtraAnchovies
Posts: 2
Joined: January 26th, 2017, 1:48 am

Re: Biased Random Damage Mod

Post by ExtraAnchovies »

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 save-loading 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 one-shared-result retaliation attack thing has stuck out every now and then and I wanted to bring it to the add-on 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.
StefanoS
Posts: 6
Joined: April 7th, 2018, 10:17 am

Re: Biased Random Damage Mod

Post by StefanoS »

yet another idea on this topic. :lol:
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
D′ = D ± ∆(D,μ)/k
the damage is decreased or increased for a fraction of the difference between the damage and the expected value

regards :)
Post Reply