Re: Disarm problems...

From: Paul Cole (pcole@ccwf.cc.utexas.edu)
Date: 08/09/95


On Wed, 9 Aug 1995, Mark Garringer wrote:

> 
> Ok, I need some advice here...I got this disarm thing down, finally. 
> However, a 1st level char without any skill whatever in disarm will 
> always disarm someone...
> 
> Here is my code:
> 
>    percent = number(1, 101); /* 101% is a complete failure */
>    prob = GET_SKILL(ch, SKILL_DISARM);
>    
>    if (percent > prob) {
>       act ("You failed to disarm $s.", FALSE, ch, 0, victim, TO_CHAR);
>    } else {
>    disarm(ch, victim);
>    }
> }
> 
> Advice? Thanks.

Piece of cake.  
  "percent" is bounded by [1,101].  I.e. its minimum value is 1.
  "prob" is equal to your skill level.  Which is 0 if you don't have any.

   your test 
      if (percent < prob) 
          then fail;
      else 
          succeed.
 
   means, if I roll less than my skill level I fail otherwise I succeed.
   WRONG!

   if my skill is 100 your giving me a 1% chance <roll of 101> to succeed.

   To demonstrate the problem your experiencing with no skill guys...
     I have no skill so prob = 0;
     I roll the worst possible on percent, percent = 1;
     (prob < percent)  --> (0 < 1) --> false
         then fail; <-- gets skipped, test is false
     else
         success; <-- here we are.. I have no skill yet I suceed.

Your problem?  Invert your test.  
   (prob > percent) not ( prob < percent )

Incidentally, 101 AND 100 are complete failures because (prob < 101) is 
always true as well as (prob < 100).  You need (prob <= percent) to get only
101 as a complete failure.  
<based on the theory that you can't get more than 100% in any given skill.>

  --Paul Cole

--
Shamless Plug -- Forbidden Lands <mud.cyberspace.com 5000>
                                 <http://www.cyberspace.com/flmud>



This archive was generated by hypermail 2b30 : 12/18/00 PST