On Wed, Aug 27, 1997 at 01:18:25AM -0400, Thomas Pedersen wrote:
Thomas Pedersen> Not that I care (since I've changed things so much), but I think
Thomas Pedersen> this is a not-such-a-great idea. All you get is one really long function
Thomas Pedersen> which will not look very neat. I don't even like the spell system
Thomas Pedersen> really...one function per skill..nice and neat...(ok, some of the same
Thomas Pedersen> code is repeated in each function..but still..easier to work with).
I kindoff have to disagree. By letting a call to a skill run through a
central point one can make the real skill code a lot smaller.
From the code we use... (similar setup as Rasdan described only a bit
simpler, though with the addition that we incorporated parts of class.c in
the structures):
typedef struct skill_info
{
const char *name;
int levels[NUM_CLASSES];
int flags;
void (*command_pointer) (CHAR_DATA *ch, CHAR_DATA *vict,
char * argument, int cmd, int subcmd);
sh_int subcmd;
byte minimum_position;
} SKILL_INFO;
#define XX -1
const SKILL_INFO skills[] = { .....
//name when a class gets it several flags for generic checks
// {Mu,Cl,Th,Wa,Ra,Ba,No,Al}
{"kick", {XX,XX,XX, 1,XX, 5,XX,XX}, SK_FIGHT_VICT|SK_VIOLENT|SK_NOT_BLIND,
// the func a subcmd minimum position
do_kick, 0, POS_FIGHTING},
}
The do_kick function:
void do_kick(CHAR_DATA *ch, CHAR_DATA *vict, char *arg, int cmd, int subcmd)
{
if (!ability_success(((10 - (GET_AC(vict) / 10)) << 1) +
number(1, 101),
GET_SKILL(ch, SKILL_KICK),
dex_app[GET_DEX(ch)].reaction,
GET_SKILL(vict, SKILL_KICK),
dex_app[GET_DEX(vict)].reaction))
damage(ch, vict, 0, get_skill(ch, SKILL_KICK), NULL);
else
damage(ch, vict, GET_LEVEL(ch) >> 1, get_skill(ch, SKILL_KICK), NULL);
add_wait(ch, PULSE_VIOLENCE * 3);
}
This against the 3 pages the old version was. Inside the damage function the
appropriate messages are printed. It could be that this looks a bit strange
to a standard circle guru, our mud is heavily modified and uses C++ ability
classes for a lot of message generating and more. But I'm sidetracking i guess
:) ... IMHO using these kind of structures you can make it a lot easier to
add new skills.
A few more details.... In the command_interpreter the
skill/command/spell/social is handled by their appropriate handler, for a
skill do_skill. do_skill then checks all the standard boring dribble. You
can also circumvent this procedure and use an old style ACMD(do_xxx) so it
won't be limiting in any way. In the advance stuff we use the same
skill_info struct for checking if a player should get new skills. Thus a
new skill is defined much more in a new place....
We use similar but more extended structures for spells. With these we use a
lot of C++ classes, to provide a very flexible magic core, with as much code
reuse as possible eg put as many 'standard' checks in one place. If there's
interest in it I could post a bit about them.. how we set them up.... see if
we did something stupid ;) (it was one of our first C++ rewrites of a part of
circle)
--
-----+++++*****************************************************+++++++++-------
- Ric Klaren - ia_ric@cs.utwente.nl ------- klaren@cs.utwente.nl --------------
-----+++++*****************************************************+++++++++-------
``Why don't we just invite them to dinner and massacre them all when
they're drunk?''
``You heard the man. There's seven hundred thousand of them.''
``Ah? So it'd have to be something simple with pasta, then.''
-------------------------------------------------------------------------------
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST