[Package Index | Mudlib Index | Effect Index]

File /obj/music/instrument_inherit.c

A musical instrument inherit. Has basic functions to allow instruments to be played, tuned, strummed and used to perform a solo. Also allows for custom messages and has a music event so NPCs and rooms can respond to the instrument being played. Use "/obj/music/instrument" for holdable instruments, others should inherit this and another suitable object inherit, and should be set as non-holdable using the function. The help file and aliases will also need to be added if suitable.

Written by Kaylar

Started February 2004, changed in June 2005 to not inherit anything, changed in May 2006 to allow more creative messages.

Includes

This class includes the following files /include/tasks.h

Method index

Public Functions

These are functions that everyone can access.

basic_checks
mixed basic_checks(object player,
                   string verb)
change_message
mixed change_message(mixed msg,
                     object serenadee)
do_msp_event
void do_msp_event(object player,
                  object sheet_music,
                  int success)
do_music_play
int do_music_play(object sheet_music)

The function used to play the instrument with sheet music, the messages are set in the music books rather than the instrument.
do_perform
int do_perform(object * indirect_obs,
               string indir_match,
               string dir_match,
               mixed * args,
               string pattern)

The function used to perform a solo on the instrument. Custom messages can be set.

See also:
set_perform_mess()


do_play
varargs int do_play(string play_str)

The function used to play the instrument. Custom messages can be set for this and players can add their own play string.

See also:
set_play_mess()


do_serenade
varargs int do_serenade(object player,
                        string serenade_str)

The function used to serenade with the instrument. Custom messages can be set for this and players can add their own string.

See also:
set_play_mess()


do_strum
int do_strum(object * indirect_obs,
             string indir_match,
             string dir_match,
             mixed * args,
             string pattern)

The function used to strum the instrument. Custom messages can be set for this.

See also:
set_strum_mess()


do_the_event
void do_the_event(object player,
                  string command,
                  string result,
                  string degree,
                  string message)

The function that creates the event_music event.
do_tune
int do_tune(object * indirect_obs,
            string indir_match,
            string dir_match,
            mixed * args,
            string pattern)

The function used to tune the instrument.
event_music
void event_music(object instrument,
                 object player,
                 string command,
                 string result,
                 string degree,
                 string message)

Called on the room and anyone in it when a musical instrument is played

Parameters:
instrument - the instrument being played
player - the player playing the instrument
command - the command used to cause the event, such as "play", "serenade", "strum" or "perform"
result - "succeed" if the player passed the skillcheck, "fail" if failed
degree - the degree of success or failure, either "marginal", "normal", "exceptional", "critical" or "no_degrees"
message - the (custom or default) message. Probably not overly useful since the default messages will include the $N, $p and such.

Example:
void event_music( object instrument, object player, string command,
  string result, string degree, string message ) {

  if( result == "succeed" ) {
    tell_room( environment( this_object() ), this_object()->the_short()+
      " starts to sway back and forth as though in a trance as "
      +player->query_cap_name()+ " plays " +player->query_posessive()+
      " " +instrument->query_short()+ ".\n", player );
    tell_object( player, this_object()->the_short()+ " starts to sway "
      "back and forth seemingly hypnotised as you play your "
      +instrument->query_short()+ ".\n" );
    return;
  }

  return;

}

query_instrument
int query_instrument()
query_instrument_difficulty
string query_instrument_difficulty()

This function gives how difficult an instrument is to play. This is difficulty dependent on type, so both a recorder and a simple drum would be "easy" despite the recorder being harder to play than the drum

Returns:
How difficult the instrument is to play; easy, medium, difficult or expert

See also:
set_instrument_type() and query_instrument_type()


query_instrument_type
string query_instrument_type()

This function gives the type of instrument it is.

Returns:
The type of instrument; stringed, wind, percussion or keyboard

See also:
set_instrument_type() and query_instrument_difficulty()


query_tuned
int query_tuned()

This function returns if the instrument is tuned or not.

Returns:
0 if not tuned, 1 if tuned, -1 if the instrument is not tuneable.

See also:
set_tuned()


set_implement
void set_implement(string name,
                   string property)

This sets a name and property associated with an implement needed to play an instrument. For example, violin bows, drumsticks and plectrums. It must be holdable, so inheriting /obj/implement is probably best

Parameters:
name - The name of the implement which will be shown in fail messages
property - The property given to the implement using add_property, this is what will be used in any checks

Example:
set_implement( "violin bow", "violin_bow" );

set_instrument_type
void set_instrument_type(string type,
                         string difficulty,
                         int tune,
                         int perform,
                         int strum)

This sets the type of instrument it is and determines default messages and the skill used. This must be set before any custom messages can be set.

Parameters:
type - The type of instrument with the choices of; percussion, wind, stringed or keyboard
difficulty - The difficulty of the instrument with choices of; easy, medium, difficult or expert. Note: this is difficulty dependent on type, that is, a recorder and a simple drum would both be given "easy" even though it is harder to play a recorder
tune - Set to 1 if it can be tuned, 0 if not
perform - Set to 1 if a solo can be played on it, 0 if not
strum - Set to 1 if it can be strummed, 0 if not (stringed only)

See also:
set_play_mess(), set_perform_mess() and set_strum_mess()

Example:
set_instrument_type( "wind", "easy", 1, 1, 0 );

set_not_holdable
void set_not_holdable(int i)

This sets whether the instrument does not need to be held to be played. This can be used for large instruments such as pianos, organs etc. Such instruments should inherit something else such as /std/object.

Parameters:
i - This should be set to 1 if the instrument does not need to be held.


set_perform_mess
void set_perform_mess(string * messages)

Sets custom messages to be used when a solo is performed. If not set the default messages are used.

Parameters:
*messages - An array of eight messages. Firstly successes from marginal to critical then failures from marginal to critical. You should format it like an add_succeeded_mess with the usual dollar thingies and a "\n" on the end. You can use $instrument for the instrument short, $a_instrument for the a_short, $poss_instrument for the possessive short and $the_instrument for the the_short. All eight messages need to be included and if you use a two member array for a message, the first string will be shown to the player, and the second to the room.

See also:
set_instrument_type(), set_play_mess(), set_serenade_mess() and set_strum_mess()

Example:
 set_perform_mess( ({
   "$N perform$s a loud solo on $poss_instrument.\n",
   "$N play$s an upbeat solo on $poss_instrument.\n",
   "$N skillfully perform$s a funky solo on $poss_instrument.\n",
   "Fingers moving so quickly that they are a blur, $N perform$s a really "
     "cool solo on $poss_instrument.\n",
   "$N perform$s a somewhat boring solo on $poss_instrument.\n",
   "With no real skill, $N play$s an awful solo on $poss_instrument.\n",
   ({ "You perform a solo on $poss_instrument.\n",
      "$N perform$s an unhip solo on $poss_instrument.  What a rectangular "
       "thynge.\n" }),
   "$N play$s a horrible clash of notes on $poss_instrument.\n"
 }) );

set_perform_tm_mess
void set_perform_tm_mess(string str)

This sets the message seen by players when they TM from performing a solo.

Parameters:
str - The message, without the colour codes and \n. You can use $instrument for the instrument short, $a_instrument for the a_short, $poss_instrument for the possessive short and $the_instrument for the the_short.

Example:
set_perform_tm_mess( "You feel you've learnt something about "
 "performing a solo." );

set_play_mess
void set_play_mess(mixed messages)

Sets custom messages to be used when the instrument is played. If not set the default messages are used.

Parameters:
*messages - An array of eight messages. Firstly successes from marginal to critical then failures from marginal to critical. You should format it like an add_succeeded_mess with the usual dollar thingies and a "\n" on the end. You can use $instrument for the instrument short, $a_instrument for the a_short, $poss_instrument for the possessive short and $the_instrument for the the_short. All eight messages need to be included and if you use a two member array for a message, the first string will be shown to the player, and the second to the room.

See also:
set_instrument_type(), set_serenade_mess(), set_perform_mess() and set_strum_mess()

Example:
 set_play_mess( ({
   "$N play$s a plain tune on $poss_instrument.\n",
   "Playing softly, $N create$s a haunting melody on $poss_instrument.\n",
   ({ "A delicate melody comes from $poss_instrument as you skillfully "
       "pluck the strings.\n",
      "A delicate melody comes from $N's instrument as $r skillfully "
       "pluck$s the strings.\n" }),
   "A beautiful tune comes from $the_instrument as $N delicately pluck$s "
     "the strings.\n",
   "$N play$s a dull melody on $poss_instrument.\n",
   "$N hastily play$s an awful tune on $poss_instrument.\n",
   "Carelessly plucking the strings, $N create$s an ear-shattering melody "
     "on $poss_instrument.\n",
   $N play$s something on $poss_instrument that does not really resemble "
     "music at all.\n"
 }) );

set_play_tm_mess
void set_play_tm_mess(string str)

This sets the message seen by players when they TM from playing.

Parameters:
str - The message, without the colour codes and \n. You can use $instrument for the instrument short, $a_instrument for the a_short, $poss_instrument for the possessive short and $the_instrument for the the_short.

Example:
set_play_tm_mess( "You learn something new about blowing your "
 "own trumpet." );

set_serenade_mess
void set_serenade_mess(string * messages)

Sets custom messages to be used when the instrument is used to serenade with. If not set the default messages are used.

Parameters:
*messages - An array of eight messages. Firstly successes from marginal to critical then failures from marginal to critical. You should format it like an add_succeeded_mess with the usual dollar thingies and a "\n" on the end. You can use $instrument for the instrument short, $a_instrument for the a_short, $poss_instrument for the possessive short and $the_instrument for the the_short. $serenadee can be used for the the_short of the person being serenaded, $serenadee_pos for the possesive, $serenade_pro for the pronoun and $serenadee_obj for the objective. Note that the last three will look odd to the serenadee if used in a room message. All eight messages need to be included and if you use a two member array for a message, the first string will be shown to the player, and the second to the room.

See also:
set_instrument_type(), set_play_mess(), set_perform_mess() and set_strum_mess()

Example:
 set_serenade_mess( ({
   "$N play$s a simple tune on $poss_instrument for $serenadee.\n",
   "$N skillfully serenade$s $serenadee with a romantic tune on "
     "$poss_instrument.\n",
   "$N serenade$s $serenadee with a tune about forbidden love on "
     "$poss_instrument.\n",
   "Seductively plucking the strings of $poss_instrument, $N serenade$s "
     "$serenadee with a beautifully romantic melody.\n",
   "$N serenade$s $serenadee with an awful tune on $poss_instrument.\n",
   "$N play$s an insulting tune for $serenadee on $poss_instrument.\n",
   ({ "You serenade $serenadee with $poss_instrument, $serenadee_pro "
       "does not look very impressed.\n",
      "$N make$s a horrible noise on $poss_instrument, apparently "
       "serenading $serenadee.\n" }),
   "$N serenade$s $serenadee with a collection of rude noises on "
      "$poss_instrument.  Not very romantic.\n"
 }) );

set_serenade_tm_mess
void set_serenade_tm_mess(string str)

This sets the message seen by players when they TM from serenading.

Parameters:
str - The message, without the colour codes and \n. You can use $instrument for the instrument short, $a_instrument for the a_short, $poss_instrument for the possessive short and $the_instrument for the the_short. $serenadee can be used for the the_short of the person being serenaded, $serenadee_pos for the possesive, $serenade_pro for the pronoun and $serenadee_obj for the objective.

Example:
set_serenade_tm_mess( "You learn something new about wooing "
 "$serenadee with $poss_instrument." );

set_strum_mess
void set_strum_mess(string * messages)

Sets custom messages to be used when an instrument is strummed. If not set the default messages are used. Note: only stringed instruments can be strummed.

Parameters:
*messages - An array of eight messages. Firstly successes from marginal to critical then failures from marginal to critical. You should format it like an add_succeeded_mess with the usual dollar thingies and a "\n" on the end. You can use $instrument for the instrument short, $a_instrument for the a_short, $poss_instrument for the possessive short and $the_instrument for the the_short. All eight messages need to be included and if you use a two member array for a message, the first string will be shown to the player, and the second to the room.

See also:
set_instrument_type(), set_play_mess(), set_serenade_mess() and set_perform_mess()

Example:
 set_strum_mess( ({
   "$N strum$s the chords to a simple dance tune on $poss_instrument.\n",
   "$N skillfully strum$s a popular folksong on $poss_instrument.\n",
   "$N play$s a Wizard's Staff has a Knob on the end, strumming skillfully "
     "on $poss_instrument.\n",
   "$N energetically strum$s the chords to a song with Rocks in it on "
     "$poss_instrument.\n",
   "$N strum$s a few boring chords on $poss_instrument.\n",
   "$N carelessly strum$s the chords to an awful sailor's tune on "
     "$poss_instrument.\n",
   "$N strum$s mindlessly at the strings of $the_instrument.\n",
   ({ "You strum the chords to a folksong about turnips on "
       "$poss_instrument, a tear in your eye.\n",
      "$N strum$s the chords to a mind-numbing folksong about "
       "turnips on $poss_instrument.\n" })
 }) );

set_strum_tm_mess
void set_strum_tm_mess(string str)

This sets the message seen by players when they TM from strumming.

Parameters:
str - The message, without the colour codes and \n. You can use $instrument for the instrument short, $a_instrument for the a_short, $poss_instrument for the possessive short and $the_instrument for the the_short.

Example:
set_strum_tm_mess( "You learn something new strumming "
 "$poss_instrument." );

set_tune_tm_mess
void set_tune_tm_mess(string str)

This sets the message seen by players when they TM from tuning.

Parameters:
str - The message, without the colour codes and \n. You can use $instrument for the instrument short, $a_instrument for the a_short, $poss_instrument for the possessive short and $the_instrument for the the_short.

Example:
set_tune_tm_mess( "You learn something new by fiddling with "
 "$poss_instrument." );

set_tuned
void set_tuned(int value)

A function used to set whether the instrument is tuned or not

See also:
query_tuned()