Welcome to the Builder Academy

Question Portal spell help

More
06 Sep 2017 16:03 #6859 by JTP
Portal spell help was created by JTP
Hi, anyone able to get this old circlemud snippet working with tba ?
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); }

Please Log in or Create an account to join the conversation.

More
06 Sep 2017 21:23 #6860 by thomas
Replied by thomas on topic Portal spell help
I assume you're talking about this spell: drive.google.com/open?id=0B40XbRH2Qbx5SWJCZzIzUlloeFU ? The code certainly looks similar.

It's been a while since I last actually tested my code - this seems to be working against the latest build:
Code:
diff --git a/src/act.movement.c b/src/act.movement.c index a5a8e1d..1c242cf 100644 --- a/src/act.movement.c +++ b/src/act.movement.c @@ -676,12 +676,26 @@ ACMD(do_gen_door) ACMD(do_enter) { char buf[MAX_INPUT_LENGTH]; + char *tmp = buf; int door; + struct obj_data *obj; one_argument(argument, buf); - if (*buf) { /* an argument was supplied, search for door - * keyword */ + if (*buf) { + int number = get_number(&tmp); + /* an argument was supplied, search for door keyword */ + if ((obj = get_obj_in_list_vis(ch, buf, &number, world[IN_ROOM(ch)].contents)) + && CAN_SEE_OBJ(ch, obj) + && GET_OBJ_VNUM(obj) == PORTAL_VNUM) { + room_rnum target_room_rnum = real_room(GET_OBJ_VAL(obj, 1)); + if (target_room_rnum != NOWHERE) { + char_from_room(ch); + char_to_room(ch, target_room_rnum); + look_at_room(ch, 1); + return; + } + } for (door = 0; door < DIR_COUNT; door++) if (EXIT(ch, door)) if (EXIT(ch, door)->keyword) diff --git a/src/limits.c b/src/limits.c index a79f8cb..bc3fe43 100644 --- a/src/limits.c +++ b/src/limits.c @@ -448,6 +448,17 @@ void point_update(void) extract_obj(j); } } + + else if (GET_OBJ_VNUM(j) == PORTAL_VNUM) { + if (GET_OBJ_TIMER(j) > 0) + GET_OBJ_TIMER(j)--; + if (!GET_OBJ_TIMER(j)) { + act("A glowing portal fades from existance.",TRUE, world[j->in_room].people, j, 0, TO_ROOM); + act("A glowing portal fades from existance.", TRUE, world[j->in_room].people, j, 0, TO_CHAR); + extract_obj(j); + } + } + /* If the timer is set, count it down and at 0, try the trigger * note to .rej hand-patchers: make this last in your point-update() */ else if (GET_OBJ_TIMER(j)>0) { diff --git a/src/spell_parser.c b/src/spell_parser.c index 30510d4..0aa4e0b 100644 --- a/src/spell_parser.c +++ b/src/spell_parser.c @@ -277,6 +277,7 @@ int call_magic(struct char_data *caster, struct char_data *cvict, case SPELL_SUMMON: MANUAL_SPELL(spell_summon); break; case SPELL_WORD_OF_RECALL: MANUAL_SPELL(spell_recall); break; case SPELL_TELEPORT: MANUAL_SPELL(spell_teleport); break; + case SPELL_PORTAL: MANUAL_SPELL(spell_portal); break; } return (1); @@ -881,6 +882,9 @@ void mag_assign_spells(void) MAG_AFFECTS | MAG_ALTER_OBJS, "You feel less sick."); + spello(SPELL_PORTAL, "portal", 150, 100, 5, POS_STANDING, + TAR_CHAR_WORLD | TAR_NOT_SELF, FALSE, MAG_MANUAL, NULL); + spello(SPELL_PROT_FROM_EVIL, "protection from evil", 40, 10, 3, POS_STANDING, TAR_CHAR_ROOM | TAR_SELF_ONLY, FALSE, MAG_AFFECTS, "You feel less protected."); diff --git a/src/spells.c b/src/spells.c index 1861408..c09b46a 100644 --- a/src/spells.c +++ b/src/spells.c @@ -448,3 +448,78 @@ ASPELL(spell_detect_poison) } } } + +ASPELL(spell_portal) { + /* create a magic portal */ + struct obj_data *portal_obj; + struct extra_descr_data *extra_desc; + char buf[512]; + + assert(ch); + assert((level >= 0) && (level <= LVL_IMPL)); + + /* + check target room for legality. + */ + + portal_obj = read_object(PORTAL_VNUM, VIRTUAL); + if (IN_ROOM(ch) == NOWHERE || !portal_obj) { + send_to_char(ch, "The magic fails\r\n"); + extract_obj(portal_obj); + return; + } + if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_TUNNEL)) { + send_to_char(ch, "There is no room in here to summon!\r\n"); + extract_obj(portal_obj); + return; + } + + if (IN_ROOM(victim) == NOWHERE) { + log("%s not in any room", GET_NAME(victim)); + send_to_char(ch, "The magic cannot locate the target\n"); + extract_obj(portal_obj); + return; + } + + if (ROOM_FLAGGED(IN_ROOM(victim), ROOM_NOMAGIC)) { + send_to_char(ch, "Your target is protected against your magic.\r\n"); + extract_obj(portal_obj); + return; + } + + sprintf(buf, "Through the mists of the portal, you can faintly see %s", + world[IN_ROOM(victim)].name); + + CREATE(extra_desc, struct extra_descr_data, 1); + extra_desc->next = portal_obj->ex_description; + portal_obj->ex_description = extra_desc; + CREATE(extra_desc->keyword, char, strlen(portal_obj->name) + 1); + strcpy(extra_desc->keyword, portal_obj->name); + extra_desc->description = strdup(buf); + + portal_obj->obj_flags.timer = 2; + portal_obj->obj_flags.value[1] = world[IN_ROOM(victim)].number; + obj_to_room(portal_obj, IN_ROOM(ch)); + + act("$p suddenly appears.", TRUE, ch, portal_obj, 0, TO_ROOM); + act("$p suddenly appears.", TRUE, ch, portal_obj, 0, TO_CHAR); + + /* Portal at other side */ + portal_obj = read_object(PORTAL_VNUM, VIRTUAL); + sprintf(buf, "Through the mists of the portal, you can faintly see %s", + world[IN_ROOM(ch)].name); + + CREATE(extra_desc, struct extra_descr_data, 1); + extra_desc->next = portal_obj->ex_description; + portal_obj->ex_description = extra_desc; + CREATE(extra_desc->keyword, char, strlen(portal_obj->name) + 1); + strcpy(extra_desc->keyword, portal_obj->name); + extra_desc->description = strdup(buf); + + portal_obj->obj_flags.timer = 2; + portal_obj->obj_flags.value[1] = world[IN_ROOM(ch)].number; + obj_to_room(portal_obj, IN_ROOM(victim)); + + act("$p suddenly appears.", TRUE, victim, portal_obj, 0, TO_ROOM); + act("$p suddenly appears.", TRUE, victim, portal_obj, 0, TO_CHAR); +} diff --git a/src/spells.h b/src/spells.h index c88c554..c5c63b4 100644 --- a/src/spells.h +++ b/src/spells.h @@ -15,6 +15,8 @@ #define DEFAULT_STAFF_LVL 12 #define DEFAULT_WAND_LVL 12 +#define PORTAL_VNUM 20 + #define CAST_UNDEFINED (-1) #define CAST_SPELL 0 #define CAST_POTION 1 @@ -93,8 +95,9 @@ #define SPELL_IDENTIFY 52 /* Reserved Skill[] DO NOT CHANGE */ #define SPELL_FLY 53 /* Reserved Skill[] DO NOT CHANGE */ #define SPELL_DARKNESS 54 +#define SPELL_PORTAL 55 /** Total Number of defined spells */ -#define NUM_SPELLS 54 +#define NUM_SPELLS 55 /* Insert new spells here, up to MAX_SPELLS */ #define MAX_SPELLS 130 @@ -226,6 +229,7 @@ ASPELL(spell_information); ASPELL(spell_identify); ASPELL(spell_enchant_weapon); ASPELL(spell_detect_poison); +ASPELL(spell_portal); /* basic magic calling functions */

Please Log in or Create an account to join the conversation.

More
08 Sep 2017 09:31 - 08 Sep 2017 09:31 #6863 by JTP
Replied by JTP on topic Portal spell help
Wanted to restrict portal a bit:
Code:
/* Houses: Can the player walk into the house? */ if (ROOM_FLAGGED(was_in, ROOM_ATRIUM)) { if (!House_can_enter(ch, GET_ROOM_VNUM(going_to))) { send_to_char(ch, "That's private property -- no trespassing!\r\n"); return ; } } /* Check zone flag restrictions */ if (ZONE_FLAGGED(GET_ROOM_ZONE(going_to), ZONE_CLOSED)) { send_to_char(ch, "A mysterious barrier forces you back! That area is off-limits.\r\n"); return; } /* Room Level Requirements: Is ch privileged enough to enter the room? */ if (ROOM_FLAGGED(going_to, ROOM_GODROOM) && GET_LEVEL(ch) < LVL_GOD) { send_to_char(ch, "You aren't godly enough to use that room!\r\n"); return; } added to spell_portal: ASPELL(spell_portal) { /* create a magic portal */ struct obj_data *portal_obj; struct extra_descr_data *extra_desc; char buf[512]; + int dir; + room_rnum was_in = IN_ROOM(ch); + room_rnum going_to = EXIT(ch, dir)->to_room; But compiles gives me the following errors: gcc -g -O2 -Wall -c -o spells.o spells.c spells.c: In function ‘spell_portal’: spells.c:749: warning: ‘dir’ is used uninitialized in this function gcc -o ../bin/circle act.comm.o act.informative.o act.item.o act.movement.o act.offensive.o act.other.o act.social.o act.wizard.o aedit.o asciimap.o ban.o boards.o bsd-snprintf.o castle.o cedit.o clan.o class.o comm.o config.o constants.o db.o dg_comm.o dg_db_scripts.o dg_event.o dg_handler.o dg_misc.o dg_mobcmd.o dg_objcmd.o dg_olc.o dg_scripts.o dg_triggers.o dg_variables.o dg_wldcmd.o fight.o genmob.o genobj.o genolc.o genqst.o genshp.o genwld.o genzon.o graph.o handler.o hedit.o house.o ibt.o improved-edit.o interpreter.o limits.o lists.o magic.o mail.o medit.o mobact.o modify.o msgedit.o mud_event.o oasis.o oasis_copy.o oasis_delete.o oasis_list.o objsave.o oedit.o players.o prefedit.o protocol.o qedit.o quest.o races.o random.o redit.o sedit.o shop.o spec_assign.o spec_procs.o spell_parser.o spells.o tedit.o utils.o weather.o zedit.o zmalloc.o -lcrypt
Last edit: 08 Sep 2017 09:31 by JTP.

Please Log in or Create an account to join the conversation.

More
08 Sep 2017 14:18 #6864 by JTP
Replied by JTP on topic Portal spell help
Code:
This was in the patch and works. if (ROOM_FLAGGED(IN_ROOM(victim), ROOM_NOMAGIC)) { send_to_char(ch, "Your target is protected against your magic.\r\n"); extract_obj(portal_obj); return; } But this one still allows portal: /* Room Level Requirements: Is ch privileged enough to enter the room? */ if (ROOM_FLAGGED(IN_ROOM(victim), ROOM_GODROOM) && GET_LEVEL(ch) < LVL_GOD) { send_to_char(ch, "You aren't godly enough to use that room!\r\n"); extract_obj(portal_obj); return; } I dont get it.

Please Log in or Create an account to join the conversation.

More
08 Sep 2017 16:45 #6865 by JTP
Replied by JTP on topic Portal spell help
But need to restrict people from Going into People's houses and gloses zones to.

Please Log in or Create an account to join the conversation.

More
08 Sep 2017 19:49 #6866 by thomas
Replied by thomas on topic Portal spell help

Jan wrote:

Code:
This was in the patch and works. if (ROOM_FLAGGED(IN_ROOM(victim), ROOM_NOMAGIC)) { send_to_char(ch, "Your target is protected against your magic.\r\n"); extract_obj(portal_obj); return; } But this one still allows portal: /* Room Level Requirements: Is ch privileged enough to enter the room? */ if (ROOM_FLAGGED(IN_ROOM(victim), ROOM_GODROOM) && GET_LEVEL(ch) < LVL_GOD) { send_to_char(ch, "You aren't godly enough to use that room!\r\n"); extract_obj(portal_obj); return; } I dont get it.

Have you tested it with a mortal?

I just tested your code with a level 1 magic user (had to alter the mana requirements a bit and add it to the learned spells list for mages) and I am forbidden from entering a godroom, just as you intended.

Please Log in or Create an account to join the conversation.

Time to create page: 0.264 seconds