guildobj

lib
OBJECT
        /p/guilds/std/guildobj


LAST UPDAT
	Eilan, 26-Apr-97

SYNOPSIS
	#include <guild.h> 
	
	inherit G_GUILDOBJ;
	
DESCRIPTION
	The guildobj is meant to offer several functions to be used i
	your guildobject. It offers a who of all guildmembers, a shou
	to all guildmembers and a teleport for the guildleader to
	her/his guild with complex checks.
	Furthermore it offers some basic functions to handle the
	skills which might be set in the guild, including automati
	advancing while using it.
	The /p/guilds/std/guildobj is not a standalone-file which just
	needs to be inherited. You have to inherit the std-file whic
	fits to your guildobject and this file, e. g.:
	  inherit "/std/weapon";
	  inherit G_GUILDOBJ;
	  int IdGuildobject()
	    With this function the guildobject identifies itself to
	    others by returning 1.

	  string SetGuildLog(string filename)
	  string QueryGuildLog()
	    GuildLog() is the file where logs from gbug etc. are
	    written to. By default, this is the domain, where th
	    guildobject is located at. If you specify a name, th
	    reports will be saved to: /log/rep/<name>
	  string QuerySource()
	    Will be queried by the /p/guilds/std/guild in prevent_leave. If
	    non-zero, i. e. the guildleader teleported her/himself
	    into the guild, then (s)he mustn't leave the guild.

	  string SetGuild(string filename)
	    Set the filename of the guild. This is needed to do
	    several queries by calling the guild. Set this in the
	    create of your guildobject.

	  string SetOwner(string plname
          string QueryOwner()
	    Set the uid of the owner of this guildobject. This nee
	    not to be done by hand. The function will be called
	    automatically.

	  int LoadGuild()
	    Load the guild and return 1 on success, 0 on failure.

	  object QueryGuildObject()
	    This returns the object-pointer to the guild this
	    guildobject belongs to.

	  object *guild_users()
	    Returns an array of all guildmembers currently online.

	  int check_owner(object pl)
	    Checks if the guildobject may be used by player <pl>. If
	    not, the guildobject will destruct itself, returning 0 as
	    result. Else 1 is returned.

	  int cmd_gshout(string txt)
	    This is the guildshout to all members. It just needs to be
	    accessed by 'add_action("cmd_gshout","gshout")' or an
	    other command. 0 is returned on failure and the
	    notify_fail is set else 1 is returned.
	    If the shouter has the echomode switched on, (s)he'l
	    receive the message: You shout to all guildmembers: <txt
	    (if echomode is switched off, (s)he'll only get 'Ok.') an
	    all others get: <name> shouts to all guildmembers: <txt
	    If you want to modify the style of this, e. g. you want
	    the shout to look like a channel, you may define a
	    function
	      public string InformGShout(object receiver,
	                                 object sender,string text)
	    This function will be called for every guildmember. If the
	    receiver is equal to the sender then you should return the
	    message the player who's shouting should get (if her/his
	    echomode is switched on else (s)he'll still just receive
	    an 'Ok.').
	    Example:
	      public string InformGShout(object receiver,
	                                 object sender, string text)
	      {
	        if (receiver==sender)
	          return "You take a mental contact to the "
                         "adventurers shouting: "+text+"\n";
	        return sender->QueryName()+" takes a mental contact "
                       "to all adventurers shouting: "+text+"\n";
              }

	  int cmd_gemote(string txt)
	    This is the guildemote to all members. It just needs to be
	    accessed by 'add_action("cmd_gemote","gemote")' or any
	    other command. 0 is returned on failure and the
	    notify_fail is set else 1 is returned.
	    If the emoter has the echomode switched off, (s)he'll
	    only get 'Ok.' otherwise, (s)he'll see the same text as
	    the other guildmembers get.
	    The message to the guildmember will look like this:
	      <guild>*<name> <txt>
	    If you want to modify the style of this, e. g. you want
	    the shout to look like a channel, you may define a
	    function
	      public string InformGEmote(object receiver,
	                                 object sender,string text)
	    This function will be called for every guildmember. If the
	    receiver is equal to the sender then you should return the
	    message the player who's emoting should get (if her/his
	    echomode is switched on else (s)he'll still just receive
	    an 'Ok.').
	    Example:
	      public string InformEmote(object receiver
	                                 object sender, string text)
	      {
	        return "[adventurer:"+capitalize(sender->QueryName())+
	               text+"]\n";
              }

	  int cmd_gwho(string arg
	    This is the guild-who to show all members, which are
	    online. Simply add 'add_action("cmd_gwho","gwho")' to the
	    guildobject. Arguments are not supported. If passed, a
	    notify_fail message will be defined.

	  int cmd_gtp()
	    Add this as command to the init of the guildobject and the
	    guildleaders will be able to teleport to their guild at
	    any time if they have no enemies and if the environment
	    allows teleport.
	    Btw: If the guild forbids teleport, it will be set to
	    another value while teleporting in . After that, it will
	    be set back.

      int cmd_gmail()
	    Add this as command to the init of the guildobject and the
		members of the guild will be able to write a guild mail to all
		guildmembers.

	  mixed QueryAutoObject()
	    This will return 1, so the guildobject will b
	    autoloading. If any values need to be saved, override it.

	  mixed SetAutoObject()
	    This may be modified to restore the saved data. But the
	    function check_owner(this_player()) should be called in
	    it.

	The skills allow to handle the pick-lock ability for thieves,
	the critical-hit ability for fighters, and so on. They are
	saved in the attributes of a player and might be queried with
	  <player>->QueryAttribute(<skillname>).
	The skills will be set when joining the guild, if you called
	AddSkill in the create of the guild.
	
	  status learn_skill(int value)
	    Value has to be between 0 and 100. This is called to see
	    if the player learned (advanced) a skill or not. If the
	    player can advance the skill 1 is returned else 0.
	    This function is called by UseSkill().

	  int check_success(int value,int percent,int chance)
	    This checks if a skill was successfully used.
	    The function is called by CheckSkill()
	    
	  void AdvanceSkill(object pl,string name)
	    Advance the skill of player <pl>. This will be
	    automatically called  by UseSkill, if the player got more
	    experienced in using the skill.

	  int CheckSkill(object pl,string name,
	                 int chance,void|int percentage)
	    Returns 1 on success and 0 on failure using a skill. If
	    <percentage> is called by reference, it will return the
	             percentage of success or the percentage of failure
	    <pl> is the player using the skill,
	    <name> is the name of the skill saved in the attributes of
	             the player,
	    <chance> is the chance that the player has a success
	             e. g. to pick a lock you can pass the value
	             queried from P_PICK_CHANCE as chance.

	    Example (assuming the Chance is 100%):
	      Ability is at: 60%, i. e. you have 40% fail-chance
	      Test shows: 95%, i. e. the test failed
	      The player used 35% of the 40% fail-chance.
	      35 is 87% of 40, so the player failed with 87%.
	      This may be used to calculate different handlings of the
	      failure.

	      Ability is at: 70%
	      Test shows: 40%, i. e. the test succeede
	      40 is 57% of 70. So the player used 57% of 100,
	      i. e. the player has 43% success.

	  int UseSkill(object pl,string name,
                       int chance,void|int percentage)
	    Calls CheckSkill and handles learning the skill.

	  int cmd_skills(string str
	    This will list all skills and their value to the
	    player. If <str> is given an error message is printed, as
	    this function doesn't accept any arguments
	    By default the list will be given with a description and
	    not with a value. Some guilds might want to have a special
	    list. For them this function might just be an example how
	    to handle it.
	    
	  int cmd_gmail(string str)
	  int cmd_gbug(string str)
	  int cmd_gidea(string str
	  int cmd_gtypo(string str)
	    If you add these commands to your guild-object it allows
	    the player to give comments to your guild just as wit
	    'idea', 'typo' and 'bug'
	    The reports will be saved in the same file as for 'idea'
	    etc. but the identification starts with GIDEAS and a lin
	    will be added: 'Reporting object:' to see which object
	    saved the report.
	    
INHERITANCE TRE
        guildobj

SEE ALS
        guild(S