29 Dec, 2014, wifidi wrote in the 1st comment:
Votes: 0
Below is a portal spell for Murk++. Programming professors talk about reaching milestones as a programmer, e.g. saving or reading from a file for the first time. I think making a portal spell is one of those milestones in MUD coding. I'm asking programmers to reply a list of these kinds of achievements and estimate their difficulty so coders like me have something realistic to look forward to in addition to coming across ideas on our own.

Murk++ basic portal spell using light ball as an object

spell_list.hpp:

97: SPELL (spell_lightning_breath)
98: SPELL (spell_portal)
99:

spells.cpp:

1154: void Character::spell_portal (int sn, int lvl, void *vo)
1155: {
1156: Character *victim;
1157:
1158: if ((victim = get_char_world (target_name)) == NULL
1159: || victim == this
1160: || victim->in_room == NULL // || in_room == victim->in_room
1161: || IS_SET (victim->in_room->room_flags, ROOM_SAFE)
1162: || IS_SET (victim->in_room->room_flags, ROOM_PRIVATE)
1163: || IS_SET (victim->in_room->room_flags, ROOM_SOLITARY)
1164: || IS_SET (victim->in_room->room_flags, ROOM_NO_RECALL)
1165: || victim->level >= lvl + 3
1166: || victim->fighting != NULL
1167: || victim->in_room->area != in_room->area
1168: || (victim->is_npc () && victim->saves_spell (lvl))) {
1169: send_to_char ("You failed.\r\n");
1170: return;
1171: }
1172:
1173: Object *portal;
1174: portal = get_obj_index(OBJ_VNUM_LIGHT_BALL)->create_object(0);
1175: portal->value[0] = victim->in_room->vnum;
1176: portal->timer = 1;
1177: portal->obj_to_room (in_room);
1178: act ("$n gazes and $p appears.", portal, NULL, TO_ROOM);
1179: act ("You gaze and $p appears.", portal, NULL, TO_CHAR);
1180:
1181: Object *portal2;
1182: portal2 = get_obj_index(OBJ_VNUM_LIGHT_BALL)->create_object(0);
1183: portal2->value[0] = in_room->vnum;
1184: portal2->timer = 1;
1185: portal2->obj_to_room (victim->in_room);
1186: act ("$p appears.", portal2, NULL, TO_ROOM);
1187: return;
1188: }

cmd_list.hpp:

184: COMMAND (do_gag)
185: COMMAND (do_enter)
186:

commands.cpp:

5382: void Character::do_enter (std::string argument)
5383: {
5384: std::string arg;
5385:
5386: one_argument (argument, arg);

5387: if (arg.empty()) {
5388: send_to_char ("Enter what?\r\n");
5389: return;
5391:
5392: if (fighting != NULL) {
5393: send_to_char ("You're fighting!\r\n");
5394: return;
5396:
5397: if (!str_cmp (argument, "portal")) {
5398: ObjIter o;
5399: for (o = in_room->contents.begin(); o != in_room->contents.end(); o++) {
5400: if (can_see_obj(*o) && (*o)->item_type == ITEM_LIGHT && (*o)->value[0] != NULL) {
5401: send_to_char("You enter a portal.\r\n");
5402: act ("$n enters a portal.", NULL, NULL, TO_ROOM);
5403: char_from_room();
5404: char_to_room(get_room_index((*o)->value[0]));
5405: act ("$n comes through a portal.", NULL, NULL, TO_ROOM);
5406: do_look ("auto");
5407: return;
5408: }
5409: }
5410: }
5411:
5412: send_to_char ("There is no portal here.\r\n");
5413: return;
5414: }

murk.cpp:

448: {"where", &Character::do_where, POS_RESTING, 0},
449: {"enter", &Character::do_enter, POS_STANDING, 0},
450:

706: 10, 12, "poison", "You feel less sick."},
707: { "portal", {1, 1, 1, 1},
708: &Character::spell_portal, TAR_IGNORE, POS_STANDING,
709: 1, 12, "", "!Portal!"},
710: { "protection", {37, 6, 37, 37},

IDEAS: make 'look in portal' show blurry view of room it leads to
make portal untakeable/getable, dispellable, redirectable
make and use an item type called ITEM_PORTAL
Random Picks
0.0/1