Re: mag_materials

From: Ron Hensley (ron@cross.dmv.com)
Date: 10/14/96


> if (!has_materials(ch, spellnum)) 
> { blah }
> 
> where has_materials looks something like:
> has_materials(struct char_data * ch, int spellnum) 
> {
>   switch (spellnum) {
>     case SPELL_ARMOR:
>       return (mag_materials(ch, 1, 2, 3, TRUE, FALSE));
>       break;
>     }
>     etc.
>   }
>   return 0;

What I did, is first in:
 int call_magic(struct cha....
in spell_parser.c, I added this:

  if (IS_SET(SINFO.routines, MAG_MATERIALS))
    if (!mag_materials(level, caster, cvict, spellnum, savetype))
      return(0); 

Just before:
  if (IS_SET(SINFO.routines, MAG_DAMAGE))
    mag_damage(level, caster, cvict, spellnum, savetype);

Note thats not the way it comes defined in the stock code, i edited the 
mag_maerials call to take the same arguments as the others like mag_damage

So the check up there on the return value, exits us if mag_materials
returns false, the char didnt have the materials, thus never going further
to call the spell itself

To add this to a spell, heres an example of a spell_clone define

 spello(SPELL_CLONE,
         100, 100, 0,
         POS_STANDING, TAR_CHAR_ROOM | TAR_SELF_ONLY, FALSE, MAG_MATERIALS
                       | MAG_SUMMONS);

So we are tackin on the MAG_MATERIALS.


In magic.c I edited the header of mag materials to:

!int  mag_materials(int level, struct char_data *ch, struct char_data
!                   *victim, int spellnum, int savetype) {

+  int verbose = TRUE, extract = TRUE, item0 = 0, item1 = 0, item2 = 0;
  struct obj_data *tobj;
  struct obj_data *obj0 = NULL, *obj1 = NULL, *obj2 = NULL;

+  switch (spellnum) {
+    case SPELL_CLONE : item0 = 3012;
+                       break;
+    default: return(FALSE);
+             break;
+  }

  for (tobj = ch->carrying; tobj; tobj = tobj->next_content) {
    if ((item0 > 0) && (GET_OBJ_VNUM(tobj) == item0)) {


Note the lines with the + is what I added. So I have a switch where
I add whatever spells i want, and the obj vnums that spell takes

This could all be done many ways.

The reason I edited the def of mag_maerials is otherwise the switch would
have been back in spell_parser and to keep things consistant Id rather
have it over in magic.c like all the other spell types do

    *******************************************************************
    *   Ron Hensley                     ron@dmv.com                   *
    *   Systems Administrator           http://www.dmv.com/~ron       *
    *                                   PGP Key at WWW Page           *
    *   DelMarVa OnLine                 749-7898 Ext. 403             *
    *******************************************************************

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



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