19 Aug, 2013, mpvmud wrote in the 1st comment:
Votes: 0
if (number_range(1, 100) == 10);
send_to_char ("Your Backstab has CRITICALLY HIT!!!!!\n\r", ch);
{
dam += (200 * tguild);
}

This is for a critical hit for backstab.

What it is doing is hitting every single time and not doing a random number check. What have I done wrong with this?
19 Aug, 2013, Davion wrote in the 2nd comment:
Votes: 0
if (number_range(1, 100) == 10); 
send_to_char ("Your Backstab has CRITICALLY HIT!!!!!\n\r", ch);
{
dam += (200 * tguild);
}


A semicolon (;) signifies the end of a statement. Putting it at the end of the if statement like that, says you're ending the if statement. What you'd want is to include the message and the dam increase in the scope ({}'s). As well, the ==10 gives you a 1% chance of this happening, if you want 10%, you'd want to include 1-9 too so use <= 10.

if (number_range(1, 100) <= 10)
{ send_to_char ("Your Backstab has CRITICALLY HIT!!!!!\n\r", ch);
dam += (200 * tguild);
}
19 Aug, 2013, mpvmud wrote in the 3rd comment:
Votes: 0
Thanks for the good explanation. Been about 5 years since I messed around with code and did just 2 silly mistakes that I should not have made :) Well it is about trial and error and then after you have pound your head, take it to someone who will see the obvious for you when you have hit your head against the wall too many times haha. Fresh eyes always help. Been messing around with code all day long and yeah… it is starting to run together and all look the same.
0.0/3