Portal Spell (Code) [by Glenn Campbell]
Snippet Posted Wednesday, August 12th @ 11:33:52 PM, by George Greer in the Skills dept.
Added May 6, 1997. Click the link below to read it or download it.

From: Glenn Campbell <glenn@ccyc.tc.gc.ca>
Subject: Portal Code

----------------------------------------------------------------------------

Make appropriate spell define.


spell_parser.c
--------------
case SPELL_PORTAL:              MANUAL_SPELL(spell_portal); break;

spello(SPELL_PORTAL, 150, 100, 5, POS_STANDING,
       TAR_CHAR_WORLD | TAR_NOT_SELF, FALSE, MAG_MANUAL);



spells.c
--------
ASPELL(spell_portal)
{
  /* create a magic portal */
  struct obj_data *tmp_obj, *tmp_obj2;
  struct extra_descr_data *ed;
  struct room_data *rp, *nrp;
  struct char_data *tmp_ch = (struct char_data *) victim;
  char buf[512];

  assert(ch);
  assert((level >= 0) && (level <= LVL_IMPL));


  /*
    check target room for legality.
   */
  rp = &world[ch->in_room];
  tmp_obj = read_object(PORTAL, VIRTUAL);
  if (!rp || !tmp_obj) {
    send_to_char("The magic fails\n\r", ch);
    extract_obj(tmp_obj);
    return;
  }
  if (IS_SET(rp->room_flags, ROOM_TUNNEL)) {
    send_to_char("There is no room in here to summon!\n\r", ch);
    extract_obj(tmp_obj);
    return;
  }

  if (!(nrp = &world[tmp_ch->in_room])) {
    char str[180];
    sprintf(str, "%s not in any room", GET_NAME(tmp_ch));
    log(str);
    send_to_char("The magic cannot locate the target\n", ch);
    extract_obj(tmp_obj);
    return;
  }

  if (ROOM_FLAGGED(tmp_ch->in_room, ROOM_NOMAGIC)) {
    send_to_char("Your target is protected against your magic.\n\r", ch);
    extract_obj(tmp_obj);
    return;
  }

  sprintf(buf, "Through the mists of the portal, you can faintly see %s",nrp->n
ame);

  CREATE(ed , struct extra_descr_data, 1);
  ed->next = tmp_obj->ex_description;
  tmp_obj->ex_description = ed;
  CREATE(ed->keyword, char, strlen(tmp_obj->name) + 1);
  strcpy(ed->keyword, tmp_obj->name);
  ed->description = str_dup(buf);

  tmp_obj->obj_flags.value[0] = 1;
  tmp_obj->obj_flags.value[1] = tmp_ch->in_room;
  obj_to_room(tmp_obj,ch->in_room);

  act("$p suddenly appears.",TRUE,ch,tmp_obj,0,TO_ROOM);
  act("$p suddenly appears.",TRUE,ch,tmp_obj,0,TO_CHAR);

/* Portal at other side */
   rp = &world[ch->in_room];
   tmp_obj2 = read_object(PORTAL, VIRTUAL);
   if (!rp || !tmp_obj2) {
     send_to_char("The magic fails\n\r", ch);
     extract_obj(tmp_obj2);
     return;
   }
  sprintf(buf,"Through the mists of the portal, you can faintly see %s", rp->na
me);

  CREATE(ed , struct extra_descr_data, 1);
  ed->next = tmp_obj2->ex_description;
  tmp_obj2->ex_description = ed;
  CREATE(ed->keyword, char, strlen(tmp_obj2->name) + 1);
  strcpy(ed->keyword, tmp_obj2->name);
  ed->description = str_dup(buf);
  tmp_obj2->obj_flags.value[0] = 1;
  tmp_obj2->obj_flags.value[1] = ch->in_room;
  obj_to_room(tmp_obj2,tmp_ch->in_room);
  act("$p suddenly appears.", TRUE, tmp_ch, tmp_obj2, 0, TO_ROOM);
  act("$p suddenly appears.", TRUE, tmp_ch, tmp_obj2, 0, TO_CHAR);
}


<< Portal Spell (Ideas) [by Ground Zero] | Reply | View as text | Flattened | Portals -- With Objects [by Tony Robbins] >>

 


Related Links
  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.