On Thu, 10 Aug 1995, Mark Garringer wrote:
>
> Ok, circle 2.2...
>
> A 1st level charcter, with no skill in disarm does not disarm.
> However, a 4th level charcter, with max skill in disarm does not disarm
> either.
> A God will always disarm, however...
>
> code to follow:
>
> 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);
> }
> }
>
> Help? Advice?
>
> --Ziz, NetShamen
Lets try this one more time....
Well, gee.. at a glance it looks technically correct.
Try some debugging logs to see whats really going on here.
For example:
char bigbuf[80];
percent = number(1, 101); /* 101% is a complete failure */
prob = GET_SKILL(ch, SKILL_DISARM);
sprintf(bigbuf, "You rolled %d with probability %d\r\n", percent, prob);
send_to_char(ch, bigbuf); /* check your code for exact argument order *
* of send_to_char(...) */
/* or use this instead if you don't wish to lookup send_to_char *
* act (bigbuf, FALSE, ch, 0, victim, TO_CHAR); */
if (percent > prob) {
act ("You failed to disarm $s.", FALSE, ch, 0, victim, TO_CHAR);
} else {
disarm(ch, victim);
}
}
This will hopefully show you whats malfunctioning.
TIP: Debug logs are wonderful tools for software developers of any
expertise level... But especially for those who haven't yet delved
into source level debuggers <gdb, dbx> because they allow you to
see what your code is doing without any esoteric knowledge of
other software tools..
If you can add a few lines of code, you can surely use debug logs
to hack out the final version.
--Paul Cole
-- Shameless Plug
Stil @ Forbidden Lands <mud.cyberspace.com 5000>
<http://www.cyberspace.com/flmud>
This archive was generated by hypermail 2b30 : 12/18/00 PST