Warning massive very simple function incoming I’ve been digging and digging trying to find out how to grab a range of integers within a single if statement. I’m coming up short applicable to my situation. Hopefully someone can point me in the right direction. Also looking for a clamp at the end of this thing (see comment.)
Thanks folks!
private void ToHitRoll()
{
//zero modifier, natural roll only
D20 = Random.Range (1,21);
hitRoll = D20;
if (hitRoll == 1 )
{
toHitFumble = true;
hitCondString = "FUMBLE";
fumbleTime = 2; //the next attack takes 2x the weapondelay to happen
}
if (hitRoll == 20) {
toHitCrit = true;
hitCondString = "CRITICAL";
}
//modifiers added
else
{
hitRoll = D20 + playerStats.toHit;
}
if (hitRoll == 2)
{
toHitMiss = true;
hitCondString = "...a swing and a miss...";
}
if (hitRoll == 3)
{
toHitMiss = true;
hitCondString = "...a swing and a miss...";
}
if (hitRoll == 4)
{
toHitMiss = true;
hitCondString = "...a swing and a miss...";
}
if (hitRoll == 5)
{
toHitMiss = true;
hitCondString = "...a swing and a miss...";
}
if (hitRoll == 6)
{
toHitMiss = true;
hitCondString = "...a swing and a miss...";
}
if (hitRoll == 7)
{
toHitMiss = true;
hitCondString = "...a swing and a miss...";
}
if (hitRoll == 8)
{
toHitGlancing = true;
hitCondString = "... a glancing blow...";
}
if (hitRoll == 9)
{
toHitGlancing = true;
hitCondString = "... a glancing blow...";
}
if (hitRoll == 10)
{
toHitGlancing = true;
hitCondString = "... a glancing blow...";
}
if (hitRoll == 11)
{
toHitGlancing = true;
hitCondString = "... a glancing blow...";
}
if (hitRoll == 12)
{
toHitGlancing = true;
hitCondString = "... a glancing blow...";
}
if (hitRoll == 13)
{
toHitHit = true;
hitCondString = "...a good strike...";
}
if (hitRoll == 14)
{
toHitHit = true;
hitCondString = "...a good strike...";
}
if (hitRoll == 15)
{
toHitHit = true;
hitCondString = "...a good strike...";
}
if (hitRoll == 16)
{
toHitHit = true;
hitCondString = "...a good strike...";
}
if (hitRoll == 17)
{
toHitHit = true;
hitCondString = "...a good strike...";
}
if (hitRoll == 18)
{
toHitSolid = true;
hitCondString = "...a solid hit...";
}
if (hitRoll == 19)
{
toHitSolid = true;
hitCondString = "...a solid hit...";
//how do I clamp the range here if the "hitRoll" + "playerStats.toHit" exceeds 19?
}
}