inherit NPC_OBJ;
int oeid;
object owner;
mapping knockers;
void setup() {
set_name( "light" );
set_short( "small blue light" );
add_adjective( ({ "small", "blue" }) );
set_main_plural( "small blue lights" );
set_long( "This small blue light floats in the air, zipping back and "+
"forth in short, sharp jerks.\n" );
add_extra_look( this_object() );
basic_setup("elemental", 1, 0 );
set_height( 10 );
set_base_weight( 1 );
adjust_bonus_dex( 25 );
set_light( 40 );
knockers = ([ ]);
add_property( "magic light", 50 );
add_property( "no fleas", 1 );
} /* setup() */
string extra_look( object thing ) {
if ( !objectp( owner ) )
return "It seems to be zipping about rather aimlessly.\n";
return "It seems to be mostly zipping about "+
(string)owner->the_short() +".\n";
} /* extra_look() */
int attack_by( object thing ) {
if(thing == owner) {
tell_object(thing, "The blue light doesn't seem to like being attacked "
"and leaves.\n");
this_object()->move("/room/rubbish");
return 0;
}
if ( thing ) {
knockers[ thing ]++;
if ( knockers[ thing ] > 5 ) {
tell_object( thing, "You get fed up with seeing the small blue "+
"light dodge aside, so you stop fighting it.\n" );
thing->stop_fight( this_object() );
map_delete( knockers, thing );
return 0;
}
}
return 1;
} /* attack_by() */
void attack_ob( object thing ) { return; }
int query_skill_bonus( string word ) {
string temp;
if ( sscanf( word, "%sdodging%s", temp, temp ) == 2 )
return 1000000;
return ::query_skill_bonus( word );
} /* query_skill_bonus() */
int query_ac( string type, int amount, string zone ) {
if ( type != "magic" )
return amount;
return ::query_ac( type, amount, zone );
} /* query_ac() */
int query_oeid() { return oeid; }
object query_owner() { return owner; }
void set_owner( object thing, int number ) {
owner = thing;
oeid = number;
owner->add_follower( this_object() );
} /* set_owner() */
void go_away() {
if ( objectp( owner ) ) {
owner->remove_follower( this_object() );
if ( environment( owner ) == environment() )
tell_object( owner, "Your small blue light crumples to dust.\n" );
tell_room( environment(), "The small blue light crumples to dust.\n",
owner );
} else
tell_room( environment(), "The small blue light crumples to dust.\n" );
oeid = -1;
move( "/room/rubbish" );
} /* go_away() */
void init() {
::init();
if ( !objectp( owner ) && ( oeid != -1 ) )
call_out( "go_away", 0 );
} /* init() */
void event_exit( object thing, string mess, object dest ) {
::event_exit( thing, mess, dest );
if ( thing != owner )
return;
if ( find_call_out( "check_owner" ) == -1 )
call_out( "check_owner", 2 );
} /* event_exit() */
void check_owner() {
if ( !objectp( owner ) ) {
go_away();
return;
}
if ( environment() != environment( owner ) ) {
move( environment( owner ), "$N dart$s into the area and zip$s around "+
(string)owner->the_short() +".",
"$N zip$s off, leaving a faint smell of ozone." );
owner->add_follower( this_object() );
}
} /* check_em() */
int second_life() {
if ( objectp( owner ) )
owner->delete_effect( (int)owner->sid_to_enum( oeid ) );
else
go_away();
return 1;
} /* second_life() */