OBJECT
/p/guilds/std/guild
LAST UPDATE
Eilan, 26-Apr-97
SYNOPSIS
#include <properties.h>
#include <guild.h>
inherit G_GUILDOFFICE;
DESCRIPTION
The guilds give the players special abilities,
allow them to advance their stats and to see which quests they
have to solve.
The /p/guilds/std/guild offers basic functions to implement such a
guild. Many of those functions call a function called
InformFoo() in the guild with a call_other on
this_object(). Those function offer the possibility to do own
checks, to give own message or anything like that. If a
function offer such a thing, it is described below.
Each guild may have guildleaders, i. e. a guildleader and a
vice-guildleader. They may be elected or they may be set by a
wizard. To get to know more about this topic see the help to
AddVotingbox.
The guild offers the following commands:
'leave guild' to cancel the membership
'banish <name>' to banish a player from the guild and forbid
him to join again; only the adventurer-guild
offers a banish to banish names from the
mud. One reason is, that noone can be
banished from the adventurer guild.
The command can only be called by wizards
and the guildleaders. The banishing will be
logged;
'unbanish <name>' allow a player to join the guild again;
'cost' to list the costs to advance the stats;
'join' to become a member of the guild
'advance' to advance stats or the level in a guild. If
advancing the level, the player will by default
automatically reach the maximum possible level for
him, but you may specify the level you want to
advance to, if this causes any problems.
'help' to print help about certain things like the maximum
stats in a guild. If no fitting topic is found in the
/p/guilds/std/guild the guild itself will be asked as
mentioned above (InformFoo) if there's any other help
available for the player;
'list' to list the quests, the guildquests or the members;
'message <name>' to allow a member of the guild to contact
another member of the guild. The player
will be asked for the message which shall
be given to the other player and if the
other player enters the guild, he'll get a
note with the message on it;
'title <title>' if there's no title specified for the level
the player has, (s)he may change her/his
title with this command. Another chance to
use this is that the player has reached a
certain level, which is defined in the
guild (currently: level 30).
If the title of the player is screwed up for
some reason, using this command without any
argument will set the title to the
guildtitle fitting to the level of the
player.
'correct' Many problems may happen to a player. One of
the current problems is, that players have
their short-description set to 'Someone'
although they are not invisible.
This is a command to check for such things
and correct them if possible.
Each guild may have so called 'guildquests' which have to be
solved to advance to a certain level. These guildquests might
be official or unofficial ones, but they have to handled by
the questcontroler, i. e. the questcontroler is responsible
for setting the quest.
--- /p/guilds/std/guild ---
object CreateGuildobject(object pl)
If defined, the guildobject for the guild will be cloned and
moved into the inventory of <pl>. This will be done
silently. Then InformGuildobject(object player,object ob) is
called in the guild. If this function returns zero, the
player will get a message, that the guildmaster gave the
guildobject to her/him, i. e. if you define your own
InformGuildobject, where <pl> is the player who received the
guildobject and <ob> is the guildobject itself, you may do
last changes to the guildobject, e. g. some settings, or you
may just want to give an own message to the player receiving
the guildobject. In this case return a value different from
zero with this function, so the default message won't be
displayed.
void AddVotingbox()
As described above a guild may have guildleaders. If they
shall be elected by the players, you should call this
function in the create of the guild. It will add the
/obj/votingbox to the guild-room and every two month
there'll be an election about the guildleader which will
take two weeks. Only HLPs can become guildleaders this way.
void ChangeSign(string|string* ids,string descr,string room)
As you might want another sign than the wooden one, you can
change this.
<ids> is a string or an array of strings containing the ids
the sign identifies to
<descr> is the description you get when examining it (will be
followed by the normal helpsign-description)
<room> is the text appended to the roomdescr.
If the sign is described somewhere else in the IntLong
you may set it to "".
void ChangeList(string|string* ids,string descr,string room)
As you might want another toplist than the given one, you can
change this.
<ids> is a string or an array of strings containing the ids
the list identifies to
<descr> is the description you get when examining it (will be
followed by the toplist)
<room> is the text appended to the roomdescr.
If the list is described somewhere else in the IntLong
you may set it to "".
int ForbidJoin (object pl)
Check if the given <pl>ayer may join the guild or not.
If not, the function has to return non-zero and set a suitable
notify_fail() message. If it may join the guild, the function
has to return 0.
string P_GUILDCLASS "Guildclass"
This is the guildclass, which will be used in the
guild-property of the player, e. g. 'adventurer', 'cleric',
'headhunter', ...
string P_GUILDNAME "Guildname"
This is the name of the guild. It will be used in some
message like for example the Top-Score-List. Examples:
'Temple of Fahr', 'Adventurer Guild', 'Headhunter', ...
string P_GUILDOBJECT "Guildobject"
This property contains the file of the guildobject, the
guild uses. It will be automatically cloned, if a player
joins the guild or if a member enters and has no
guildobject. If a member leaves the guild, it will be
destructed.
--- /p/guilds/std/guild/banish ---
You may banish a player from the guild, e. g. if (s)he uses
guildabilities to bother players. The guildleader and all
wizards from vice lord on can do this. The banishing will be
logged, so the AW of Guilds may keep an eye on it.
mapping P_BANISH "Banish"
The mapping of the banished players. It looks like this:
([name:time of banish;banisher;reason])
string AddBanish(string whom,string why)
Add a banished name to the guild with the reason <why>. The
time and the banisher will be set automatically.
The returned value is defined in <guild.h> and will contain
an error-message or just "Ok.\n", i. e. you may directly see
in the result, what was wrong.
string RemoveBanish(string whom)
Remove a banished name and allow the player to join again.
string ListBanished()
Return a printable list of all banished players in the
guild.
int IsBanished(string whom)
Return 1, if the player is banished from the guild, else 0.
string Banisher(string whom)
Returns who banished the player <whom>.
--- /p/guilds/std/guild/guildquests ---
mapping Guildquests()
Returns all guildquests in the form: ([<level>:<short>])
int GuildQuestLevel(object pl)
Return the level up to which <pl> might advance without
solving another guildquest.
string ListGuildquests(object|string pl,void|mapping res)
Returns a printable list of all guildquests. If res is
passed by reference, i. e. you call:
ListGuildquests(name,&res);
res will contain a mapping like this when returning:
([lvl:({guildquests})])
So you can easily control, which quests have to be solved at
which level.
mapping P_GUILDQUESTS "Guildquests"
With this you can directly set the guildquests. The mapping
looks like this:
([quest_id:quest_level;quest_creator;quest_short;quest_long])
But as the structure of this mapping might change in the
future you should better use AddGuidquest as described
below.
mapping AddGuildquest(string id,
int lvl,
string creator,
string short,
string long)
Add one guildquest. The <id> is the id, which will be
recognized by the questcontroler. <lvl> shows the level
up to which you must have solved the quest to can advance.
<creator> is/are the creator(s) of the guild, <short> is the
description given in the list and <long> the description if
asking for an description of this special quest.
--- /p/guilds/std/guild/level ---
void AnnounceNewLevel()
This function announces a players new level on the
news-channel and tells it to the player. The announcement on
the news-channel will not be done, if the player is invis.
int QPtoLevel(int qp)
Returns the level one might get with the given qp.
string GuildLeveltoTitle(int lvl,int gender)
Returns the title for level <lvl> and the gender <gender>
(as defined in <living.h>). If no title is specified for
this level and this gender, the default title is:
<name> the + <guildclass>, e. g.:
"Harry the adventurer"
mapping QueryLevelCosts()
Returns a mapping ([<lvl>:<xp-cost>]) with the XP you need
to advance to the given levels.
int QueryLevelCost(int lvl)
Returns the XP you need for lelvel <lvl>.
mapping P_LEVEL_TITLES "LevelTitles"
This property contains all titles in a mapping which looks
like this:
([lvl:neuter_title;male_title;female_title])
mapping AddLevelTitle(int lvl,int gen,string title)
This is one of the possibilities to set a title for a
certain level and gender. The gender is defined in
<living.h>, NEUTER, MALE or FEMALE.
The maximum possible level is at the moment 50.
The function returns the new leveltitles-mapping.
mapping AddNeuterTitle(int lvl,string title)
Same as above, but you don't need to include <living.h> when
calling this function.
It sets a title for a neuter player.
mapping AddMaleTitle(int lvl,string title)
Same as above for male players.
mapping AddFemaleTitle(int lvl,string title)
Same as above for female players.
mapping AddLevelTitles(int lvl,string *titles)
mapping AddLevelTitles(int lvl,string neuter,
string male,string female)
mapping AddLevelTitles(int lvl,string all_titles)
These are the different possibilities to call
AddLevelTitles. The first one is to give the level and the
titles in an array, which looks like this:
({neuter_title,male_title,female_title}).
The second one offers the same, but you give each title as
single argument.
The third one is to set all titles for each gender to the
same value.
--- /p/guilds/std/guild/member ---
void LoadGuild(int force)
Loads the member-data from the guildfile (see
P_GUILDFILE). If force is not zero, the data will be loaded
in any case. Otherwise they'll only be loaded, if the
member-mapping is empty.
There's a possibility to do this force automatically by
setting the load_force-property (see P_LOAD_FORCE).
void SaveGuild()
This function saves the member-data.
int is_creator(string|object who)
Returns true (1) if <who> is one of the creators of the
guild.
int is_maintenancer(string|object who)
Returns true (1) if <who> is one of the maintenancer of the
guild.
int is_leader(string|object who)
Returns true (1) if <who> is one of the guildleaders of the
guild.
int is_member(string|object who)
Returns true (1) if <who> is one of the member of the guild.
int check_member(object who)
Returns true (1) if <who> is a valid interactive member of
the guild.
The 'is_'-checks build up one on the other, i. e. a creator is
automatically leader and member, a leader is automatically
member (well (s)he should be ;-) ).
string MemberList()
Returns a printable list of all members informing about the
name, the level and the last time (s)he entered the guild.
It is called when typing 'list members'.
string* QueryMemberList()
Returns an array of all guildmembers including Creators and
Maintenancers, even if they have left the guild.
string toplist(int size)
Returns a printable TopScoreLIst of all guildmembers
excluding wizards. You may give the size of the list. The
guild-default is 20. If no argument is given, the whole list
will be returned.
string P_GUILDFILE "Guildfile"
If the date of the guild shall be saved somewhere else,
i. e. not to the default-filename which is the path of the
guild plus the extension ".o" instead of ".c", then specify
the guildfile.
This is needed if you have the guild in
/d/<domain>/<wizard>/ because the guild can only write to
/d/<domain>/common. Or take the adventurer-guild as
example. Several guild-rooms are in different domains. So
the guild needs to save the members at a place accessible to
all domains (in this case the /log-dir).
string P_CREATORS "Creators"
The creators of the guild. You may set them as one string or
as array of strings. In both cases it will at last be saved
as an array. You may specify several creators this way. The
creators will always be listed in the guild-who of the
/p/guilds/std/guildobj.
string P_MAINTENANCERS "Maintenancers"
The maintenancers of the guild. You may set them as one string or
as array of strings. In both cases it will at last be saved
as an array. You may specify several maintenmancers this way. The
maintenancers will always be listed in the guild-who of the
/p/guilds/std/guildobj.
mapping P_MEMBERS "Members"
The mapping of the members, which is build like this:
([string name:int time of entering;int level;
string stat;string *msgs;mixed extra])
mapping AddMember(string name,int level,string stat)
Add a member to the guild. If the member already exists,
(s)he won't be added. The 'time'-entry will be set to the
current time and the 'msgs' to an empty array.
The stat is taken from <guild.h>:
G_LEADER "gl"
G_VICELEADER "vgl"
G_CREATOR "cr"
mapping RemoveMember(string name)
Remove a member from the guild and inform the guild about
this calling InformRemove(<name>). This way you may do other
actions when removing a member, e. g. destroying other items
than the guildobject, change saved data, etc.
If the guildleader is removed from the guild, her/his vice
will automatically become guildleader.
void SetExtraInfo(string name,mixed extra)
mixed QueryExtraInfo(string name)
As you can see above, there's one part of the
member-mapping which isn't exactly defined. This might
contain any informations you would like to specify,
e. g. old home-settings for the vampires and other things
like that. This extra-part might be a mapping, an array, a
string or whatever you can think of.
void ChangeStat(string name,string stat)
Change the status of a member, e.g. from member to
guildleader.
string QueryStat(string name)
Query the status of a member.
string QueryGuildleader()
Returns the Guildleader of the guild. 0 if there's no
guildleader.
string QueryViceGuildleader()
Same as above for the vice.
void ChangeLevel(string name,int level)
Change the level of a member (only in the mapping not in the
player-object!).
int QueryLevel(string name)
Return the level of a member.
void UpdateTime(string name)
Update the enter-time of a member to the current time.
int QueryTime(string name)
Return the time when <name> last entered the guild.
void AddMessage(string name,string *msg)
Add a message to the messages of a member. The message has
to be given in an array, each element containing one line of
the message.
void RemoveMessage(string name,string *msg)
Remove a message from the array.
void RemoveMessages(string name)
Remove all messages of a member.
status P_LOAD_FORCE "LoadForce"
As described above this is to force the guild to update the
member-data every time when they get accessed.
--- /std/guild/stats.c ---
int CalcAdvanceCosts(object pl,string stat)
Returns the amount of XP the player <pl> has to spend to
advance the stat <stat>, where stat is P_CON, P_STR, P_DEX
or P_INT. The amount is
1/10*(xp for level (==stat+1) - xp for level (==stat)).
Then it is modified by the race-stats and the MaxStats of
the guild. So an intelligent race in a spellcaster-guild has
to pay very few XP for advancing Int, but a weak race in a
cleric-guild has to pay very much XP for advancing Str.
string CalcMinStat(object pl)
Calculates the minimal stat of a player and returns it. This
is used to check whether the player may advance a stat or
not (e. g. a race with Str+4 might advance Str to the
MaxStat for strength of the guild + 4.
int CanAdvance(object pl,string stat)
Check if the player can advance the current stat (for one
point). The results are defined in <guild.h>:
ADV_OK 0 stat may be advanced
ADV_NOT_XP 1 not enough XP to advance stat
ADV_NOT_LEVEL 2 the level of the pl is not high enough
ADV_OTHER_FIRST 3 another stat has to be advanced first
ADV_TOO_HIGH 4 the maximum possible stat is
already reached
int AdvanceStat(object pl,string stat)
Try to advance the stat of player <pl> and give the
corrosponding message (ok or notify_fail).
string AdvanceCostList(object pl)
Return a printable list of stat-advancecosts.
void PrintAdvanceCosts(object pl)
This will be called when the player types 'cost'. It prints
all data you'll need to see what you can advance how, i. e.
it'll show the player:
1. QP and XP
2. free XP (not needed for the current level)
3. list of stats and how much it costs to advance them
4. the current state of your stats
5. the level up to which the player might advance
6. the QP the player needs for advancing
7. the XP the player needs for advancing
8. the next guildquest that is needed to advance
mapping P_MIN_STATS "MinStats"
Set the minimum stats you need to join the guild. This
should prevent a newbie from entering the guild. Only one
guild is allowed to have this set to:
([P_CON:1,P_DEX:1,P_STR:1,P_INT:1])
This is only for the adventurers.
QueryMinStats(object pl)
You might also query the minstats with a player object
given. The stats will then be modified by the race-
depending values.
int QueryMinStat(string stat,void|object pl)
Query what the minimum value is for <stat>.
If <pl> is given the returned value will be modified by the
race-dependent values queried from the racemaster.
mapping AddMinStat(string stat,int value)
Add a minimum stat and return the whole minstat-mapping.
Example: AddMinStat(P_DEX,3)
mapping P_MAX_STATS "MaxStats"
Set the maximum stats a player might get when (s)he is a
Low-Level-Player. The maxstats will be modified by the race
a player has, e. g. a race with Str-4 defined in the
race-file and a MaxStat of 20 can only advance Str up to 16.
QueryMaxStats(object pl)
You might also query the maxstats with a player object
given. The stats will then be modified by the race-
depending values.
int QueryMaxStat(string stat,void|object pl)
Query what maximum value is for <stat>.
If <pl> is given the returned value will be modified by the
race-dependent values queried from the racemaster.
mapping AddMaxStat(string stat, int value)
Add a maximum stat and return the whole maxstat-mapping.
Example: AddMaxStat(P_INT,22)
mapping P_MAX_HLP_STATS "MaxHLPStats"
Set the maximum stats for the guild a HLP might get. This
will be modified like the maxstats with the race-
modifications.
QueryMaxHLPStats(object pl)
You might also query the maxhlpstats with a player object
given. The stats will then be modified by the race-
depending values.
int QueryMaxHLPStat(string stat,void|object pl)
Query what the maximum HLP-value is for <stat>.
If <pl> is given the returned value will be modified by the
race-dependent values queried from the racemaster.
mapping AddMaxHLPStat(string stat,int value)
Add a maximum HLP-stat and return the whole mapping.
Example: AddMaxHLPStat(P_CON,28)
mapping P_SKILLS "Skills"
A guild may have special skills. They won't be handled in
any way by the /std/guild except, that they will be set as
attributes in the player, when (s)he joins the guild.
If the /p/guilds/std/guildobj will be used you may easily handle
these skills, but therefore you need to specify them in a
percentage-value.
The mapping looks like this:
([<skill-name>:<skill-initial-value>;<skill-level>])
where <skill-initial-value> is the value to which the skill
will be set and <skill-level> is the level where you will
get this skill, i. e. if it is 0 or 1 you'll get it when
joining the guild, otherwise you'll get it, when you advance
your level.
InitSkills() calls QuerySkills() with the player-object as
argument. This way you may e. g. return the skills depending
on the race.
mapping AddSkill(string name,int value,void|int level)
Add the skill <name> with the initial value <value> and the
<level> when to add this skill to the player. The skills-
mapping will be returned.
void InitSkills(object pl)
If this is called (it will be automatically done, when a
player joins the guild or the player advances in level),
the skills will be set to their initial value in the player.
The following functions are called in the guild, to inform
about certain actions. They are not defined in the /p/guilds/std/guild
but if defined in the guild inheriting the /p/guilds/std/guild they may
handle things like settings special attributes and such:
int InformGuildobject(object pl,object ob)
Called when a guildobject is cloned.
<pl> is the player who'll receive the guildobject,
<ob> is the guildobject.
A return value !=0 omits a message to the player.
void InformRemove(string name)
Called when a member is removed from the guild.
<name> is the name of this member.
void InformEnter(string name)
Called when a member enters the guild.
<name> is the name of this member.
int InformAdvance(object pl,string what)
Called when player <pl> tries to advance something, the
/p/guilds/std/guild doesn't offer. As notify_fail "Advance what?"
is set. Return either 1 on success or 0 on failure.
It will also be called to inform the guild that a player
advanced her/his level. In this case <what> is set to
"level". A return-value will be ignored then.
<pl> is the player who wants to advance,
<what> is the string (s)he typed after 'advance'.
int InformJoin(object <pl>)
Called when player <pl> joins the guild. If the function
returns a non-zero value messages from the /p/guilds/std/guild to the
player and on the news-channel are omitted.
int InformList(object <pl>,string what)
Called when a player calls the 'list'-command but the
/p/guilds/std/guild doesn't offer anything appropriate.
The return-value (and notify_fail) will be the return-value
of the list-function. Default-notify_fail is: "List what?\n"
int InformHelp(object <pl>,string what)
Called when a player calls the 'help'-command but the
/p/guilds/std/guild doesn't offer anything appropriate.
The return-value (and notify_fail) will be the return-value
of the help-function. Default-notify_fail is:
"There's no help available about '"+what+"'.\n"
int InformCorrect(object <pl>,string what)
Called when a player calls the 'correct'-command. This may
be used to do guild-internal updates (like a new
guild-object or whatever). If the returned value is 0, the
player will get a notify_fail()-message that nothing is
wrong with her/him, if nothing else has been corrected.
Otherwise you should return 1 and write a message to the
player what has been changed.
INHERITANCE TREE
guild
|-std/room
|-std/guild/banish
|-std/guild/guildquests
|-std/guild/member
|-std/guild/stats
`-std/guild/level
SEE ALSO
guildobj(L)