As a totally no knowledge about modding sort I am hesitant to make a suggestion...but...
Say the original damage is ten, so you either randomize it from 0-20 to average ten, or you randomize it 0-10 and multiply by two to average ten. Maintaining the average so the overall effectiveness of the unit doesn't change.
Another way to get the damage to average out to the original ten is to randomize it and then add five. That not only puts the average at the original value, but it makes the range less extreme. I personally would prefer the RNG didn't have the power to create a total misfire, or a super shot of double effect...though introducing some vagaries of chance is clearly a good thing.
I kinda enjoyed the total randomness of it. Because it was so rare that a 0 was hit (not like the DCM range bombard where a miss would happen rather often), I caught myself actually being "drawn in" to the combat results, going :" ah comon! only 1%!!!
or Ooooohhh 38% !!!!
). At least there isnt any critical fire or Friendly Fire
anyway, the problem is to add 5, coz it is a different number for each unit. but....
(Random of X) + ((Max X)/2) would do the trick, in a nice easy simple way
f.ex. Collateral Damage :
Code:
int CvUnit::collateralDamage() const
{
return ((GC.getGameINLINE().getSorenRandNum((std::max(0, (m_pUnitInfo->getCollateralDamage()))), "Some Log Message")) + ((std::max(0, (m_pUnitInfo->getCollateralDamage()))) / 2));
}
(I do like parentheses (ALOT)) (
)
----------------
And, ofcourse if using the original method, and instead of doing XML changes and not wanting a equal numbers result, the *2 could ofcourse be added to the inside of the Sorenrand, which would give unequal numbers too :
Code:
return (GC.getGameINLINE().getSorenRandNum(((std::max(0, (m_pUnitInfo->getCollateralDamage()))) * 2), "Some Log Message"));
note that I havent tested either yet, so they are purely hypothetical (Im VERY new at all this SDK/C++ so Im not totally sure about the syntaxes)
-------------------
Alternatively to the first, coz if doing like that, the whole idea about randomizing is "almost" gone, is to instead of RND10 + 5, it could be (RND10+(½ a 10)) + (1/4 of 10) or RND15 + 2.5, which would produce results of 2.5-17.5 and average at 10 (right?)
So it would look like : return=((RND(X+(X/2)))/(X/4))
I think this way would be the best overall. (Not resulting in failure, nor extremes)
----------------------
Regarding the code efficiency, I think (without knowing the exact function of sorenrand) it could be like a whole game is like shooting a bullet from mars and hitting England, but with the new randomization it would hit France instead. (Note to CIA, FBI, NSA or whoever is listening, I do NOT intend to go to Mars to actually shoot a bullet at neither England nor France, just to set the record clear
)