|
Ground Zero: Portal Spell (Ideas) |
|
Contributed by greerga on Wednesday August 12, @11:19PM,
from the Skills dept.
. Click the link below to read it or download it.
From: Ground Zero Enterprises <zero@cnw.com>
Subject: CODE: step-by-step add enterable portals and objects
This is how I have imped portals in my mud. If you come across
something that doesn''t work right, or even look right, you may want to
ask me about it because my source is far from stock and I have changed
many basic functions and added many new ones. Just follow these
directions as they are written here and you should be ready to go.
structs.h
Add an item type for portal:
#define ITEM_PORTAL 24 /* or whatever the next highest number is */
constants.c
Add a listing in item_types[] for portals.
limits.c
After the code to extract a corpse but within that for statement add:
if (GET_OBJ_TYPE(j) == ITEM_PORTAL) {
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);
}
}
spells.h
Add:
#define SPELL_GATE 53 /* or whatever the netx highest number is */
And where the other ASPELL prototypes are:
ASPELL(spell_gate);
spell_parser.c
In the spell names list:
"gate",
In call_magic() where other manual spells are called:
case SPELL_GATE: MANUAL_SPELL(spell_gate); break;
Anywhere in mag_assign_spells() between spellos:
spello(SPELL_GATE, 50, 50, 0, POS_STANDING,
TAR_CHAR_WORLD | TAR_NOT_SELF, FALSE, MAG_MANUAL);
spells.c
Anywhere between the other ASPELL functions:
#define PORTAL_OBJ 20 /* the vnum of the portal object */
ASPELL(spell_gate)
{
struct obj_data *portal, *tportal;
struct extra_descr_data *new_descr, *new_tdescr;
char buf[80];
if (ch == NULL || victim == NULL)
return;
/* create the portal */
portal = read_object(PORTAL_OBJ, VIRTUAL);
GET_OBJ_VAL(portal, 0) = victim->in_room;
GET_OBJ_TIMER(portal) = (int) (GET_LEVELX(ch, CLASS_MAGIC_USER) / 10);
CREATE(new_descr, struct extra_descr_data, 1);
new_descr->keyword = str_dup("portal gate gateway");
sprintf(buf, "You can barely make out %s.", world[victim->in_room].name);
new_descr->description = str_dup(buf);
new_descr->next = portal->ex_description;
portal->ex_description = new_descr;
obj_to_room(portal, ch->in_room);
act("$n conjures a portal out of thin air.",
TRUE, ch, 0, 0, TO_ROOM);
act("You conjure a portal out of thin air.",
TRUE, ch, 0, 0, TO_CHAR);
/* create the portal at the other end */
tportal = read_object(PORTAL_OBJ, VIRTUAL);
GET_OBJ_VAL(tportal, 0) = ch->in_room;
GET_OBJ_TIMER(tportal) = (int) (GET_LEVELX(ch, CLASS_MAGIC_USER) / 10);
CREATE(new_tdescr, struct extra_descr_data, 1);
new_tdescr->keyword = str_dup("portal gate gateway");
sprintf(buf, "You can barely make out %s.", world[ch->in_room].name);
new_tdescr->description = str_dup(buf);
new_tdescr->next = tportal->ex_description;
tportal->ex_description = new_tdescr;
obj_to_room(tportal, victim->in_room);
act("A glowing portal appears out of thin air.",
TRUE, victim, 0, 0, TO_ROOM);
act("A glowing portal opens here for you.",
TRUE, victim, 0, 0, TO_CHAR);
}
_____________________________________
You also need to create an object in one of your .obj files for a
portal template, this is the one I use:
#20
portal gateway gate~
a glowing portal~
A glowing portal hovers here forming a gateway to another place.~
~
24 0 0
0 0 0 0
0 0 0
____________________________________
If you use an object with a different vnum you need to change the
value of the PORTAL_OBJ define before ASPELL(spell_gate).
To be able to enter portals (probably pretty useful, eh?) you need to
add this piece of code to do_enter in act.movement.c:
above ''int door;''
struct obj_data *obj = NULL;
after ''if (*buf) {'' and before ''for (door = 0; door < NUM_OF_DIRS; door++)''
if ((obj = get_obj_in_list_vis(ch, buf, world[ch-<in_room].contents))) {
if (CAN_SEE_OBJ(ch, obj)) {
if (GET_OBJ_TYPE(obj) == ITEM_PORTAL) {
if (GET_OBJ_VAL(obj, 0) != NOWHERE) {
char_from_room(ch);
char_to_room(ch, GET_OBJ_VAL(obj, 0));
} else if (real_room(GET_OBJ_VAL(obj, 1)) != NOWHERE) {
char_from_room(ch);
char_to_room(ch, real_room(GET_OBJ_VAL(obj, 1)));
}
look_at_room(ch, 1);
return;
}
}
}
That should be all, if I left anything out or there is any bugs let me
know but there shouldn''t be any problems with it. The other thing this
code is useful for is that you can make permanent objects that can be
entered to move the player to rooms by making the objects ITEM_PORTAL,
setting their first obj value to -1 and setting the next obj value to
the virtual number of the room you want them moved to.
<< ?: Object Timers | Reply | Flattened | Glenn Campbell: Portal Spell (Code) >> |
|
Features
| |
This is the new CircleMUD News site. It is based off the Slashdot 0.2 Perl code and will resemble Slashdot.org site for awhile. |
|