Post by slacker on Jan 7, 2008 4:52:38 GMT
since this lpc forum is so dead, here is a furniture object i created for a contest. can you tell whats so magic about it? sorry it's so ugly and missing comments, there was a size limitation in the contest.
#pragma strict_types
inherit "w/adinos/houses/baseobj/removable";
// Magic mirror for the house furniture contest
// Slacker // 10/18/2006
#include "/sys/body_position.h"
#define MIRROR_ID "\nHOUSE_MIRROR"
#define MSG message
#define STR string
#define OBJ object
#define TP this_player()
#define CAP capitalize
#define NAME CAP((STR)TP->query_real_name())
#define PRO CAP((STR)TP->query_pronoun())
#define ENV environment
#define FIND find_player
#define LINK_DELAY 2
STR scryed; // currently linked to a player? gives a name or 0 if not
OBJ check_scry();
void link_scryed(OBJ who);
void unlink_scryed();
void create() {
::create();
set_name("mirror");
set_alias(({"magic mirror", "enchanted mirror"}));
set_short("an enchanted mirror");
set_long("##my_long");
set_touch("##my_touch");
set_weight(4);
set_value(2000);
//removable functions
set_msg_already("The wall is already adorned with a mirror.");
set_msg_install("# awkwardly &0 a silver mirror to the "
"wall and &1 it in place.@hold holds nail nails");
set_msg_remove("# swiftly &0 out the nails holding up an enchanted mirror and "
"&1 it onto $ back.@pull pulls flip flips");
set_msg_nodestroy("You mericlessly pound on the mirror and you think you hear "
"a faint snicker. Try removing it instead.");
set_unique_id(MIRROR_ID);
set_unique_str("A mirror is already placed in this room.");
}
void init() {
::init();
add_action("_enter", "enter");
add_action("_clean", "clean");
add_action("_clean", "polish");
}
//installable functions
STR ok_to_install(OBJ r) { return 0; }
STR ok_to_uninstall(OBJ r) {
if(scryed != 0)
return "The mirror glimmers as you try to remove it from the wall and the "
"finger-print on its surface flares with magical fire!";
return 0;
}
STR query_content() {
return "w/slacker/open/magicmirror.c";
}
void initialize(STR *arg) {
scryed = 0;
}
STR extra_long() {
if(!query_installed()) return 0;
return "A towering silver mirror is held fast to the wall.";
}
//custom functions
void magic_long() {
OBJ room, plyr;
plyr = check_scry();
if(!plyr) {
//show the looker their reflection
write("\n");
TP->force_us("exa "+(STR)NAME);
}
else {
//show the scryed player's room
writef("\nA smudged fingerprint glows bright on the mirror's surface. Peering "
"into the mirror it seems as if you are looking elsewhere:\n\n");
room = ENV(plyr);
if(room->set_light(0) < 0) {
write("\nThe mirror seems to absorb the light in shadowy darkness.\n");
}
else {
room->long();
writef((STR)room->query_contents_look());
}
}
}
void my_long() {
writef("This gilded silver mirror has been polished to an unearthly shine. It "
"stands the height of a man and is a regal device for decorating any grand "
"wall.");
magic_long();
}
void my_touch() {
if(check_scry() == 0) {
writef("The mirror is perfectly smooth and feels warm to the touch.");
if(query_installed()) call_out("link_scryed", LINK_DELAY, TP);
}
else writef("You try to touch the mirror but only feel empty air where "
"polished silver should be.");
}
int _enter(STR arg) {
OBJ dest, plyr;
if(!id(arg)) return 0;
plyr = check_scry();
if(plyr != 0) {
dest = ENV(plyr);
if((int)TP->query_body_position() != STANDING) {
writef("You would have to be standing to try such a foolish thing as "
"entering a mirror!");
}
else if(dest == ENV(TP)) {
writef("You close your eyes and step into the mirror. When you open your "
"eyes you are still here, with your back to the mirror.");
say(NAME+" walks towards an enchanted mirror and steps into it! "+PRO+
"just as swiftly steps out.\n");
}
else {
writef("You close your eyes and brace for impact. You find yourself "
"somewhere else.");
say(NAME+" walks toward an enchanted mirror on the wall and "
"quickly disappears!\n");
TP->move(dest); TP->force_us("look");
tell_room(dest, NAME+" steps out of the shadows.\n", ({TP}));
}
}
else
//theres no fingerprint
MSG("# foolishly &0 to walk through an enchanted mirror. # &1 off "
"the polished silver. You hear a faint cackling in the room."
"@try tries bounce bounces");
return 1;
}
int _clean(STR arg) {
if(!id(arg)) return 0;
MSG("# carefully &0 off the enchanted mirror, leaving its surface "
"spotless!@clean cleans");
if(scryed != 0) unlink_scryed();
return 1;
}
void link_scryed(OBJ who) {
MSG("$ touch on the mirror left a smudged fingerprint, which starts to "
"glow red-hot!", who);
scryed = (STR)who->query_real_name();
}
void unlink_scryed() {
MSG("The glowing fingerprint on the mirror fades away as the mirror shimmers.");
scryed = 0;
}
OBJ still_online(STR who) {
return (OBJ)FIND(who);
}
OBJ check_scry() {
OBJ plyr;
if(scryed != 0) {
plyr = still_online(scryed);
if(plyr) return plyr;
else unlink_scryed();
}
return 0;
}