From pro08@dec51.tietgen.dkSat Dec 9 19:35:31 1995 Date: Wed, 4 Oct 1995 11:33:41 +0100 (MET) From: MUD-master To: Glenn Campbell Cc: circle@pvv.unit.no Subject: Re: your mail Regarding the code for a portal spell. Below is my implementation of this spell I assume you now how to do the spell assigning stuff so here goes the explanation of the code. The spell itself (spell_portal) should be placed in spells.c. It will create a portal at the caster and at the target. You have to change the define to the object number of the object you wish to use as the portal. (I have included mine below). Next you have to place the special in spec_procs.c and assign it to the object in spec_assigns.c. The last bit of code is to be placed in limits.c right after the check for corpses lifespan. This bit makes sure that the world wont be scattered with portals, as they will vanish after a given time, dependant on the casters level. Hope this helps. :) Amiga Imp on TietgenMUD (dec51.tietgen.dk 4711) ---------------------------spells.c------------------------- #define PORTAL 31 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_NOMAGIC)) { send_to_char("Eldritch wizardry obstructs thee.\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->name); 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] = level/5; 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->name); 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] = level/5; 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); } ------------------- spec_procs.c ------------------------- SPECIAL (portal) { struct obj_data *obj = (struct obj_data *) me; struct obj_data *port; char obj_name[MAX_STRING_LENGTH]; if (!CMD_IS("enter")) return FALSE; argument = one_argument(argument,obj_name); if (!(port = get_obj_in_list_vis(ch, obj_name, world[ch->in_room].contents))) { return(FALSE); } if (port != obj) return(FALSE); if (port->obj_flags.value[1] <= 0 || port->obj_flags.value[1] > 32000) { send_to_char("The portal leads nowhere\n\r", ch); return TRUE; } act("$n enters $p, and vanishes!", FALSE, ch, port, 0, TO_ROOM); act("You enter $p, and you are transported elsewhere", FALSE, ch, port, 0, TO_CHAR); char_from_room(ch); char_to_room(ch, port->obj_flags.value[1]); look_at_room(ch,0); act("$n appears from thin air!", FALSE, ch, 0, 0, TO_ROOM); return TRUE; } ------------------------ limits.c ------------------------- if (GET_OBJ_VNUM(j) == 31) { if (GET_OBJ_VAL(j,0) > 0) GET_OBJ_VAL(j,0)--; if (GET_OBJ_VAL(j,0) == 1) { if ((j->in_room != NOWHERE) &&(world[j->in_room].people)) { act("$p starts to fade!", FALSE, world[j->in_room].people, j, 0, TO_ROOM); act("$p starts to fade!", FALSE, world[j->in_room].people, j, 0, TO_CHAR); } } if (GET_OBJ_VAL(j,0) == 0) { if ((j->in_room != NOWHERE) &&(world[j->in_room].people)) { act("$p vanishes in a cloud of smoke!", FALSE, world[j->in_room].people, j, 0, TO_ROOM); act("$p vanishes in a cloud of smoke!", FALSE, world[j->in_room].people, j, 0, TO_CHAR); } extract_obj(j); } } ---------The Portal object ------------------- #31 portal gate~ A misty portal~ A misty portal floats here, beckoning you to enter, if you dare!~ ~ 13 0 0 0 0 0 0 1000 0 -1