[Package Index | Mudlib Index | Effect Index]

File /obj/misc/dart_board_inherit.c

An inherit for "dart" boards. This can be customised to some extent, you can specify the targets, the darts, the skill used and messages.

Written by Kaylar

Inherits

This class inherits the following classes /std/object.c

Includes

This class includes the following files /include/player_handler.h, /include/tasks.h and /include/achievements.h

Method index

Public Functions

These are functions that everyone can access.

check_timeout
void check_timeout()
do_abandon
int do_abandon()
do_play
int do_play()
do_practise
int do_practise()
do_throw
int do_throw()
event_darts
void event_darts(object board,
                 string action,
                 object player,
                 int score,
                 object winner)

Called on the room and anyone in it when something is done with the dart board. You may want to use init_command in any NPCs as the event may happen before the add_succeeded_mess is seen.

Parameters:
board - The dart board the game is being played on.
action - The action that caused the event. "challenge" when someone first starts a game, "accept" when someone accepts, "throw" when someone throws a dart, "turn" when it's someone else's turn, "abandon" when someone abandons a game, "end" when the game ends and "reset_game" when the game is reset.
player - the player doing the action, will be 0 for "end" and "reset_game" and the player whose turn it is for "turn.
score - The score, only useful for the "throw" and "end" actions. 50 points is awarded for a bullseye, 30-45 is the next best followed by 15-25, 8-13, 4-7, 3-5, 1-3, 0 is a complete miss.
winner - The winner, only useful for the "end" action, if it is a tie it will be 0.

Example:
void event_darts( object board, string action, object player, int score,
  object winner ) {

  switch( action ) {
    case "challenge":
        init_command( "'I could go for a game.", 1 );
        init_command( "play game", 2 );
        init_command( "unhold weapon 1", 3 );
      }
    break;
    case "accept":
      if( player == TO ) {
        _playing_darts = 1;
        init_command( "'Prepare to lose." );
      }
    break;
    case "throw":
      if( _playing_darts ) {
        if( player != TO ) {
          if( score == 0 ) {
            init_command( "point laugh " +player->query_name(), 1 );
          }
        }
      }
    break;
    case "end":
    case "abandon":
      _playing_darts = 0;
      init_command( "equip", 1 );
    break;
    case "turn":
      if( player == TO ) {
        init_command( "throw", 1 );
        init_command( "throw", 3 );
        init_command( "throw", 5 );
    break;
  }

}

final_scores
void final_scores()
get_target
string get_target()
get_winner_list
string get_winner_list()
load_file
void load_file()
query_players
object * query_players()
query_practising
object query_practising()
record_score
void record_score(object player,
                  string type,
                  int score)
reset_game
void reset_game()
save_file
void save_file()
set_dart
void set_dart(string dart)

This function allows you to set the "dart" used.

Parameters:
dart - The name of the dart to be used (not an actual object).

Example:
set_dart( "throwing axe" );

set_messages
void set_messages(string * msgs)

This function allows you to set custom messages for the dart board. These will be seen when a player throws a dart and the score will be shown separately, afterwards. Use the usual dollar thingies used for add_succeeded_mess and $target can be used to get the target name and $points can be used to get the points. Messages should be marginal success through to critical failure. Note: the target will be a random creator unless this is set otherwise. The nose is the "bullseye" and should be used only for a critical success. Similarly, zero points are awarded for a critical failure, and could be described as a complete miss.

Parameters:
msgs - An array of eight messages, from marginal success to critical failure.

Example:
set_messages( ({ "$N throw$s a dart at the dart board.  It "
 "soars forward and pierces $target's lip, scoring $points points.\n",
 "normal success", "exceptional success", "critical success",
 "marginal failure", "normal failure", "exceptional failure", "critical
 failure" }) );

set_no_take
void set_no_take(int i)

Use this to set it so that the line: You take the dart from the dartboard. isn't displayed before the shot.
set_random_messages
void set_random_messages(mapping messages)

This function allows you to set messages for 'freak' shots. Eg someone might get a bullseye because a drunk knocked their hand as they threw. If these messages are set they will have a 1 in 50 chance of happening but the individual frequency of the messages can be set.

Parameters:
messages - This is a mapping. The key should be a mixed array: ({ "message", points value for throw }) and the value should be the weighted chance of the message occuring (it will use roulette_wheel to determine the chance). Note that the message should be in add_succeeded_mess format and the points value should (ideally) not exceed 50.

Example:
 set_random_messages( ([
   ({ "$N throw$s a dart at the dart board.  Suddenly, a troll strolls "
       "in front of it and the dart riccochets off his rock-like skin, "
       "causing the dart to miss the board completely.  $N score$s "
       "$points points.\n", 0 }) : 10,
   ({ "$N hurl$s a dart at the dart board just as a drunk knocks into "
       "$o, sending the dart flying straight up into the ceiling.  It "
       "bounces off the lamp, hits a chair, and then hits the bullseye.  "
       "What luck!  $C$$N score$s $points points.\n", 50 }) : 5
   ]) );

set_room
void set_room(object room)

Use this function to set the room that the dart board will appear in. Best to set this in the room after you've cloned it. For example: dart_board = clone_object( "pathofdartboard" ); dart_board->set_room( this_object() ); dart_board->move( this_object() ); dart_board->reset_get();

Parameters:
room - The room object.


set_save_file
void set_save_file(string file,
                   string language)

This sets the save file for the dart board. This is needed if you want to record the top dart players.

Parameters:
file - The path for the save file
language - The language for the scores to be shown in.


set_scores
void set_scores(int * scores)

This function can be used to set custom scores for the target. If not set the default scores (which involve a random element except for bullseye) will be used. The scores should be in an array from marginal to critical success then marginal to critical failure.
set_skill
void set_skill(string skill)

This function allows you to set the skill used for the "throwing" the dart.

Parameters:
skill - The skill (default is thrown).

Example:
set_skill( "magic.methods.mental.animating" );

set_targets
void set_targets(string * targets,
                 int use_people)

This function can be used to set the targets to throw at, they should all be people, or at least have faces if custom messages aren't set.

Parameters:
targets - An array of targets, they must be valid player names if the following flag is 0.
use_people - If 1 the targets are players (or creators), if 0 they aren't.


setup_stuff
void setup_stuff()
update_winners
void update_winners()