Re: Passing args to Spells Question 1998 at 10:17:27PM +0000

From: Eric Green (ejg3@CORNELL.EDU)
Date: 06/20/98


On Sat, Jun 20, 1998 at 10:17:27PM +0000, Chuck Carson wrote:
> I am trying to code a knock spell that works like this:
>
> PC types: cast 'knock' <direction> or
>           cast 'knock' <door alias>  (or have both work)
>
> The spell will then do all the mumno jumbo to check that
> direction and all that stuff.
>
> I cannot figure out how to get this argument from the player. I
> look at spells like summon and locate object that take pointers
> to structs, but I just want to a take a raw argument that I can
> strcmp for one of 6 directions and proceed from there.
>
> Am I looking at this the right way and has anyone done anything
> similiar? I was toying with the idea of adding a new spell type,
> MAG_MISC_ROOM, but I thought I'd see if there was an easier way.

I would suggest adding argument passing for manual spells.
In spells.h, add 'char *arg' to ASPELL and MANUAL_SPELL defines:

#define ASPELL(spellname) \
void    spellname(int level, struct char_data *ch, \
                  struct char_data *victim, struct obj_data *obj, \
                  char *arg)

#define MANUAL_SPELL(spellname) spellname(level, caster, cvict, ovict, arg);

In spell_parser.c, pass the argument 'arg' to the calls to cast_spell in
do_cast.  In cast_spell and mag_objectmagic, pass the argument 'arg'
in the call_magic calls.  Add 'char *arg' to call_magic and cast_spell:

int call_magic(struct char_data * caster, struct char_data * cvict,
             struct obj_data * ovict, int spellnum, int level, int casttype,
             char *arg)

int cast_spell(struct char_data * ch, struct char_data * tch,
                   struct obj_data * tobj, int spellnum, char *arg)

Then when you define a MANUAL_SPELL, you can use the parameter 'arg'
which is now passed to figure out the door name or direction.  This
also can be used to fix the bug with locate object.

Death's Gate does something like that.  You can check that code for
a reference.


Eric


     +------------------------------------------------------------+
     | 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/15/00 PST