[Package Index | Mudlib Index | Effect Index]

File /obj/misc/quest_info_utils.c

Quest info utils. General inheritable for use by anything really. Using quest_info stuff is a bit of a pain. This is just syntactic sugar to make it a lot more friendly. Quest info is saved as a mapping, so you can index any info you like under named keys.

Written by Dek

Started March 2001

Includes

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

Method index

Public Functions

These are functions that everyone can access.

clear_quest_info
void clear_quest_info(mixed player)

Clears all the quest info associated with a player for this quest.

Parameters:
player - The player object, or the name of the player, whose info to clear

Example:
 if( player->query_al() > 500 ) {
    pig->do_death();
    clear_quest_info( player );
 }

query_quest_done
int query_quest_done(mixed player)

This tests if the quest has been done by a given player.

Parameters:
player - The player object, or the name of the player, to check for having done the quest

Returns:
1 if they have done the quest, 0 if they haven't

Example:
 if( query_quest_done( this_player() ) )
    write( "Having already taken care of pigs, you have no desire to do so "
             "again.\n" );

query_quest_param
mixed query_quest_param(mixed player,
                        string key)

Gets the quest info value addressed by a given key.

Parameters:
player - The player object, or the name of the player, whose info to find
key - The keyword to get the value for

Returns:
The value associated with the key

Example:
 string name = query_quest_param( player, "pig name" );
 if( name != pig->pig_name() )
    tell_object( player, "This isn't your pig!  You're supposed to look "
             after " + name + "!\n" );

set_quest
int set_quest(mixed player)

This awards a player with the quest.

Parameters:
player - The player object, or the name of the player, to award with the quest

Returns:
-1 if the player specified was invalid, 0 if the quest couldn't be awarded, and 1 if it was successfully awarded

Example:
 if( pig->query_happiness() > 10 )
    set_quest( this_player() );

set_quest_name
void set_quest_name(string quest_name)

Sets the name of the quest this item applies to. Call this function in setup(). This is making the assumption that one item only deals with one quest, but it's a fairly safe assumption.

Parameters:
quest_name - The name of the quest this object deals with

Example:
 set_quest_name( "pig caretaker" );

set_quest_param
void set_quest_param(mixed player,
                     string key,
                     mixed value)

Sets the quest info value addressed by a certain key.

Parameters:
player - The player object, or the name of the player, whose info to change
key - The keyword to set info for
value - The value to set the info to. Can be of any type

Example:
 set_quest_param( this_player(), "pig name", "Horace" );
 set_quest_param( this_player(), "fed pig", 1 );