mob
determine_part(mob/target, prob)
if(!(target.LeftArm.Condition || target.RightArm.Condition || target.LeftLeg.Condition || target.RightLeg.Condition))
return 0
switch(round(rand(1,100), 1))
if(1 to 25)
if(target.LeftArm.Condition)
return target.LeftArm
else
determine_part(target, prob)
if(26 to 50)
if(target.RightArm.Condition)
return target.RightArm
else
determine_part(target, prob)
if(51 to 75)
if(target.LeftLeg.Condition)
return target.LeftLeg
else
determine_part(target, prob)
if(76 to 100)
if(target.RightLeg.Condition)
return target.RightLeg
else
determine_part(target, prob)
else
return 0
Problem description:
I'm using this system to determine which Limb to use in a successful block. I however don't want to use a broken limb, hence the Condition checks.
This looks so ugly though, and I haven't tested it to determine that it works. Is there a more logical way to go about this check?
There are 4 limbs, and I'm trying to give each of them a 25% chance to be chosen.
Also:
You don't seem to be using the 'prob' argument.
rand(a, b) always returns an integer (no rounding necessary).