[an error occurred while processing this directive]
[<a href="index.shtml">Package Index</a></code> | <a href="index_std.shtml">Mudlib Index</a></code> | <a href="index_eff.shtml">Effect Index</a></code>]<br><h2>File /d/cwc/families/handlers/cwc_mission_handler.c</h2> 
The CWC Mission system is made up of three files.  This Handler, the
mission_controller inherit, and the mission_chit inherit.
<p>  
<b>How It works</b>
<p>  
when a player says "mission" in front of the mission_controller npc the
handler checks the directory "/d/cwc/families/handlers/mission" for the
existance of files named *_chit.c, it will also checks two subdirectories,
family_name and guild_name depending on what guild and family the player
belongs too.  If you are a creator and say "cretest" the handler will only
look in the "mission_dev" subdirectory. This is allow creators to test 
missions they are working on.
<p>
When the handler has retrieved the list of all files available to the
player, it subtracts the last three missions the player has done and then
select one at random.  The handler then goes through a check and decides 
what family to send the player against.  It does this whether the mission
needs a terget family or not.  Finally it clones the chit and calls:- 
<p> setup_mission_data(string player,string faction,string target_family)
<p> on it. Finally it moves the chit to the player and returns the setup
string from the chit to the mission_controller npc, so the they can tell
the player.
<p> right the handler has done its work and thats all you need to know about
it for the moment.  Now on to the mission_chit.  
<p> The Mission chit must have the following :-
<ol>
<li>inherit "/d/cwc/families/handlers/mission/inherit/chit"
<li>call ::init() in init()
<li>have add_property("mission_value",int); in setup()
<li>have a function string setup_mission(string,string,string) which includes
  <ul>
  <li>setup_mission_base(player,faction,target_family);
  <li>set_read_mess(read_mess); well you'll want to give them some instructions
  </ul>         
</ol>
<p><b>more about setup_mission</b>
<p>The setup_mission function will be called by the mission_handler with 
three string values:-
<ul>
<li> player -> who is the mission for.
<li> faction -> what family is the player a member of.
<li> target_family -> what family is the mission against, you dont have
to use this
</ul>
you need to pass these values to the to setup_mission_base this allows the 
chit to remember som key values.  These values can be accessed through the 
following functions:-
<ul>
<li>query_player()
<li>query_faction()
<li>query_target_family()
<li>query_mission_time()
</ul>
<p>The last one query_mission_time() can be compared against 
query_player_data_key(query_player(),"missiondata")*["mission time"]) 
to ensure this chit is for the mission the player is 
actually on.
<p>Ok, but what about variables you want to add, e.g the room the player
needs to go through. well you can use <b>set_mission_data_item</b>(string item,
mixed value) to add new variables to the chit, these will automatically
be restored if the player logs off and will be recreated by the handler 
should the chit need be replaced.  You can store anything you like in there 
except objects.  You can access these variables using
<b>query_mission_data</b>(string item).
<p><b>Chit replacement</b>
<p> Normally the handler will do all that you need to do when the chit is 
replaced. However should you need to so something special, like clone a npc
for the player to find, then you will need to overload :-
<p>void replace_chit(mapping mission_data)
<p>The mapping mission_data contains all the variables for the mission,
including, the player so teh first line of the overload should be 
::replace_chit(mission_data), this will allow query_player(), 
query_mission_data etc to work.

<p>You can have variables that are not restored when the mission chit is
replaced, if so make sure you overload query_dynamic_auto_load() and 
init_dynamic_arg properly.
<p><b>Completing Missions</b>
<p>Your can complete the missions in one of two ways. calling 
add_property("mission_complete",1) on the chit and telling the Player to 
give it the the mission_controller npc. Or calling 
close_mission(playername,1) on the handler. Calling 
close_mission(playername,0) will fail the mission.
<p>One final function on the handler worth mentioning is:-
<p>void add_object_to_delete(string obj,int delay,string msgin,string msgout)
<p>Sometimes when writing a mission, you will want to clone objects on the fly.
this functions allows you to mark them for deletion at a later date. The 
handler will take care of moving them /room/rubbish etc.

<P><p><b>Some Examples</b>
<p>/d/cwc/families/handlers/mission/investigate_chit.c
<p>Very basic mission, good place to start. chit needs to be returned.
<p>/d/cwc/families/handlers/mission/graffiti_chit.c
<p>Example of cloning objects on the fly which are marked for deletion later
by the handler, auto succeeds
<p>/d/cwc/families/handlers/mission/graffiti_chit.c
<p>more complicated example with over loads to replace_chit,
query_dynamic_auto_load and init_dynamic_arg, auto succeeds/fails
<p>Written by Noir<p>Started January 2006<h2>Includes</h2>
This class includes the following files <a href="include.move_failures.h.shtml">/include/move_failures.h</a>, /d/cwc/families/handlers/path.h, /include/shops/bank.h and <a href="include.money.h.shtml">/include/money.h</a><h2>Method index</h2>
<ul>
<li><a href="#cap_family">cap_family</a>(string)<br/>
  return proper capitalization for BP family.
<li><a href="#close_mission">close_mission</a>(string, int)<br/>
close mission for a player with success or failure, call this from a chit
to close a mission

<li><a href="#delete_player">delete_player</a>(string)<br/>
  remove a player from the mapping, call it to delete old records

<li><a href="#delete_player_data">delete_player_data</a>(string, string)<br/>
  remove a single key for a player from the mapping, call it to delete 
  key values

<li><a href="#is_family_member">is_family_member</a>(string, string)<br/>returns true if player is a member of the Family 
<li><a href="#query_cap_families">query_cap_families</a>()<br/>
  List all the families capitalised

<li><a href="#query_families">query_families</a>()<br/>
  List all the families

<li><a href="#query_player_data">query_player_data</a>(string)<br/>
<li><a href="#query_player_data_key">query_player_data_key</a>(string, string)<br/>
<li><a href="#query_players">query_players</a>()<br/>
<li><a href="#return_all_data">return_all_data</a>()<br/>
<li><a href="#set_player_data_key">set_player_data_key</a>(string, string, mixed)<br/>
  set a piece of data for a single key

</ul>
<h2>Public Functions</h2>
These are functions that everyone can access.<p>
<dl>
<dt class="autodocfuncname"><a name="cap_family">
cap_family</a><pre class="autodocfuncdef">
string cap_family(string fam)
</pre><dd><br />
  return proper capitalization for BP family. ( damn McSweeneys)
<br />

<dt class="autodocfuncname"><a name="close_mission">
close_mission</a><pre class="autodocfuncdef">
int close_mission(string player,
                  int succeeded)
</pre><dd><br />
close mission for a player with success or failure, call this from a chit
to close a mission
<br />

<dt class="autodocfuncname"><a name="delete_player">
delete_player</a><pre class="autodocfuncdef">
int delete_player(string player)
</pre><dd><br />
  remove a player from the mapping, call it to delete old records
<br />
<br /><dl>
<dd><b>Parameters:</b><br />
player - name of the player
<br />
<br />
<dd><b>Returns:</b>
<br />1 for success, 0 for failure<br /><br />
<br /></dl>

<dt class="autodocfuncname"><a name="delete_player_data">
delete_player_data</a><pre class="autodocfuncdef">
int delete_player_data(string player,
                       string thekey)
</pre><dd><br />
  remove a single key for a player from the mapping, call it to delete 
  key values
<br />
<br /><dl>
<dd><b>Parameters:</b><br />
player - name of the player<br />
thekey - name of key to remove
<br />
<br />
<dd><b>Returns:</b>
<br />1 for success, 0 for failure<br /><br />
<br /></dl>

<dt class="autodocfuncname"><a name="is_family_member">
is_family_member</a><pre class="autodocfuncdef">
int is_family_member(string playername,
                     string ufid)
</pre><dd><br />returns true if player is a member of the Family <br />

<dt class="autodocfuncname"><a name="query_cap_families">
query_cap_families</a><pre class="autodocfuncdef">
string * query_cap_families()
</pre><dd><br />
  List all the families capitalised
<br />

<dt class="autodocfuncname"><a name="query_families">
query_families</a><pre class="autodocfuncdef">
string * query_families()
</pre><dd><br />
  List all the families
<br />

<dt class="autodocfuncname"><a name="query_player_data">
query_player_data</a><pre class="autodocfuncdef">
mapping query_player_data(string player)
</pre><dd><br /><br />
<br /><dl>
<dd><b>Parameters:</b><br />
player - name of player
<br />
<br />
<dd><b>Returns:</b>
<br />mapping of all the data for a single player<br /><br />
<br /></dl>

<dt class="autodocfuncname"><a name="query_player_data_key">
query_player_data_key</a><pre class="autodocfuncdef">
mixed query_player_data_key(string player,
                            string thekey)
</pre><dd><br /><br />
<br /><dl>
<dd><b>Parameters:</b><br />
player - name of the player<br />
thekey - the name of the key you want the data for   
<br />
<br />
<dd><b>Returns:</b>
<br />data for a single player for one key<br /><br />
<br /></dl>

<dt class="autodocfuncname"><a name="query_players">
query_players</a><pre class="autodocfuncdef">
string * query_players()
</pre><dd><br /><br />
<br /><dl>
<dd><b>Returns:</b>
<br />an array of all the playernames currently stored in the mapping
<br /><br />
<br /></dl>

<dt class="autodocfuncname"><a name="return_all_data">
return_all_data</a><pre class="autodocfuncdef">
mapping return_all_data()
</pre><dd><br /><br />
<br /><dl>
<dd><b>Returns:</b>
<br />The full _data mapping, use with caution
<br /><br />
<br /></dl>

<dt class="autodocfuncname"><a name="set_player_data_key">
set_player_data_key</a><pre class="autodocfuncdef">
int set_player_data_key(string player,
                        string thekey,
                        mixed thedata)
</pre><dd><br />
  set a piece of data for a single key
<br />
<br /><dl>
<dd><b>Parameters:</b><br />
player - name of the player<br />
thekey - the name of the key you want to set the data for <br />
thedata - value you want to set
<br />
<br />
<dd><b>Returns:</b>
<br />1 for success 0 for failure<br /><br />
<br /></dl>

</dl>
[an error occurred while processing this directive]

