use Random class, set an integer range
Random ran = new Random(); #generate random object
int x = ran.nextInt(101) #sets x to a random integer between 0 & 100(doesn't reach max)
if (a==1) {
if (x<=30) {
results of 40 damage being done;
}
}
this should work, because chances are equal that it will be anywhere from 0 to 100. 30% chance it will be less than or equal to 30. make sense?