Innate Object Code [by Danny Jacobs]
Snippet Posted Wednesday, August 12th @ 11:29:13 PM, by George Greer in the Objects dept.
Added Jun 23, 1997. Click the link below to read it or download it.

From:  Pain  / Danny Jacobs
Subject: Innate affects for Objects

Hello imps,


This code requires the inn_spl.txt snippet to be impped.  It draws
on the base code that innate spells use, though not the control features.
But this WILL NOT WORK without it.


Here is a little hack I did on the inn_spl.txt code.  It adds the
ability for my coder immorts to set a wearable object as having an innate
ability association with it.  We have all seen the nice equipment that has
sanctuary or detect alignment or such.  This here is code that will put it
to work for you.


It is a bit wacky, since I am still new to circlemud but it works
nicely.  And after all my mods, I dont really want to download the cirlcemud
source again and do a test compile.  If anyone else would, well I give you
more than the authorization to pull this and post a newer one :)

        I am Pain on a few muds (most of the time it is taken) and I am
Pain on World of Pain (conceited aint I) at wop.mlx.net 4000 (too lazy to
even change the port number hehe) drop by if you have a question or
concern with this code.


**** In ----> structs.h ****

  add to struct obj_flag_data

    int obj_innate;   /* Variable to hold the spell that you assign */

**** In ----> utils.h ****

  add to the obj utils defines

    #define GET_OBJ_INNATE(obj)  ((obj)->obj_flags.obj_innate)

**** In ----> act.item.c ****

  add a variable int OBJ_INNATE; somewhere close to the top

  to perform_wear add struct affected_type *aff;
     then following wear_message(ch, ojb, where);


    obj_from_char(obj);


    equip_char(ch, obj, where);


    /*  Add the following */
  if(obj->obj_flags.obj_innate)
  {
    for(aff = ch->affected;aff;aff = aff->next)  /* run through list */
      if(aff->type == obj->obj_flags.obj_innate) /* if already affected */
        return;
    OBJ_INNATE = TRUE;
    mag_effects(90, NOBODY, ch, obj->obj_flags.obj_innate, NULL);
    OBJ_INNATE = FALSE;
  }

  // This is clean and no body gets hurt.  However your comiler will balk at
  // you on var 2 and var 5 call to mag_effects.  I set these as null and had t
o
  // remove that condition in mag_effects (see magic.c), but since these
  // variables are not being used for my purpose I left them alone...

  in preform_remove add the variables:  struct obj_data *obj;





struct affected_type *aff;
  then following else to add remove messages (bottome of function)



/*  Add the following */
  if(obj->obj_flags.obj_innate)
    for(aff = ch->affected;aff;aff = aff->next)
      if(aff->type == obj->obj_flags.obj_innate)
        affect_remove(ch, aff);

  **************************************************************************
  That is the functional code.  Here is the code that does the work to cause
  an innate condition.  I added this later to my regular innate code.
  **************************************************************************

**** In ----> magic.c ****

  add the extern variable at the top:  extern int OBJ_INNATE;
  in mag_affects change the following:
    should be right below the declarations:
 -  if(ch == NULL || victim == NULL)  /* change to *?
 +  if(victim == NULL)

  then in the rest of the function is your spells.  Note that in order of it
  to be innate, the duration has to be -1 so I set up my check as follows:
  if(OBJ_INNATE)
    af[?].duration = -1
  else
    af[?].duration = (what was originally there);

  This way you can go through an add the ability to each of the spells you
  want innate, and not have to worry about sleep being set as innate :)

**** In ----> db.c ****

  Last thing is to add support for the mud to read it in.  I added it after
  my obj_level_restriction flag, which you probably wont have, or at least not
  my home brew version.  But in db.c I added it as

  in parse_object()

  obj_proto[i].obj_flags.weight = t[0];
  obj_proto[i].obj_flags.cost = t[1];
  obj_proto[i].obj_flags.cost_per_day = t[2];
  obj_proto[i].obj_flags.level_okay = t[3];
  obj_proto[i].obj_flags.innate = t[4];
  t[4] = 0; /*  didnt research, but all obj after inital obj with innate

     *  ability carried the same ability.  This turned it off,
             *  so I left it hehe
             */

  since you probably wont have level okay, just make it .innate = t[3]; then
  t[3] = 0;

  **********************************************************************
  Now for the creator portion.  I added a home brew into the medit.c as
  well as a flag for OEDIT_INNATE in olc.h.  I am not sure what editors
  you are using or if you are not.  If you are not, then simple hand edit
  your object files with the last line of numbers, add on the spell # you
  wish the obj to have.  IE in spells.h you will see the numbers defined.
  EG Sanc is #36, so just add 36 as the last number on the line.
  ***********************************************************************

  For those of you using oasisolc, your in luck *grin*

**** In ----> olc.h ****

  add:  with the rest of the #define OEDIT flags
    #define OEDIT_INNATE      XX /* next available number */

**** In ----> oedit.c ****

  go to oedit_disp_menu()
  I added it in as a last number and used the * as the char:
  add to sprintf after quit:
     "%s*%s)  IMPLEMENTORS ONLY! Innate affect = %s%d%s\r\n"
  then at the end sprintf add:
     , grn, nrm, cyn, GET_OBJ_INNATE(obj), nrm
  this should stick out fairly well and make you quit uncomfortable, but it
  works none the less.

  Further down in oedit_disp_menu are the case statements for the letters
  and numbers.  Add this:
    case '*':
      /*. Object innate spell in my mud...  */
      if(GET_LEVEL(d->character) >= 99)
      {
        send_to_char("Enter spell # : ", d->character);
        OLC_MODE(d) = OEDIT_INNATE;
      }
      else
        send_to_char("Says coder and impl only right?  Shesh!", d->character);
      break;

  then further down past the numbers is the case statements for OEDIT_????
  Add this:
    case OEDIT_INNATE:
      number = atoi(arg);
      GET_OBJ_INNATE(OLC_OBJ(d)) = number;
      break;

  Lastly in oedit_save_to_disk()
    in the fprintf function, add a %d to the end of the stack should be
layed out  %d %d %d,
      then %d %d %d %d,
      then %d %d %d <- add another one here,
then at the bottom of the variable fillers add:

       GET_OBJ_INNATE(obj);


And now this is ended.  With oedit you should now be able to see it, and
change it.  Future mods that would be nice, are a listing of the spells and
numbers you have provided ability to set as innate.

Well have fun with it :)

Pain  / Danny Jacobs



<< Innate Spell Code [by Patrick J. Dughi] | Reply | View as text | Threaded | Interposing Hand [by JTP94] >>

 


Related Links
  CircleMUD
download
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.