clan.zip
snippets · 6.8 KB · 2010-03-30
Clan system: clan.c/h, a clan list and do_guild. Read the whole document before editing your code.
Download « Back to the snippets list
readme
------------------------------------------------------------------------- | READ THE WHOLE DOCUMENT BEFORE TAMPERING WITH YOUR CODE. And make a | | backup too, just in case... | ------------------------------------------------------------------------- Okay, here's _part_ of the clan code I've written. Making the clan table readable from a file is NOT a trivial exercise. It involves changing about half of the source files. I've added is some extra stuff so that the clan name and status shows up in score. There is a function that I've written called 'char_color' which returns TRUE if the player has ansi-color on, and FALSE otherwise. If you don't have a similiar method for deciding if ansi-color should be used you can add the line: #define char_color(ch) TRUE or just take out all the bits that use it. At some time before players are allowed to connect you must call read_clan_table(NULL). If the clan table fails to load at this stage a bug is reported and the program is terminated. Two commands need to be added: do_petition do_loadclans (make sure it's after do_load in interp.c) do_clans (make sure it's after do_clan in interp.c) I suggest level 10 for do_petition and level 59 or 60 for do_loadclans and do_clans at no lower than level 52. To #include merc.h some other headers need to be included. This is not a very good programming technique, so I muddled around it my making a header called merc_pref.h which includes merc.h is a friendlier manner. Changes to merc.h #define MAX_CLAN <n> becomes extern short MAX_CLAN; at the end add in: #include "clan.h" Changes to act_info.c MAX_CLAN becomes UPPER_MAX_CLAN (there are two of these to change) If you ever go above UPPER_MAX_CLAN (in clan.h) clans the mud _will_ crash, so make it a nice high number. Remove all the clan_table stuff from const.c (or was it table.c?) and well as the clan_table definition in merc.h Replace the do_guild function in act_wiz.c with the one in the do_guild file. Also add a field to char_data in merc.h as follows: sh_int clan_status; And add bits to save.c to load and save this field like this: In fwrite_char add this after if (ch->clan): fprintf(fp, "ClanS %d\n", ch->clan_status); And in fread_char after KEY( "Clan", ... KEY( "ClanS", ch->clan_status, fread_number(fp) ); Right! Now for the most difficult bit! EVERY reference to clan_table has to be changed as follows: clan_table[x].y becomes get_clan_table(x)->y Don't forget to add clan.o to the makefile. Recompile everything and pray. Oh, and don't forget to quote the author somewhere on you mud :) In the area directory you need a file called "clans.txt" to store the clans in. An example of a clan table is included with this archive. The format is very easy: <number of clans> <clan_id> "<name>" "<who_name>" <color> <recall> <hall> <ind> clan_id must be unique for each clan. The ids 0 and 1 MUST be present. <name> is the name that is used in petition and who_name is the name that appears in the who list. <color> is something I added to allow the clan names in the who list to have a different color (you can just put 0 here, if you like). <recall> is the room that you recall to (this patch is not included). <hall> is the clan's death hall, and <ind> is the independent flag. If you add clans remember to increase <number of clans> accordingly. If you put 0 for one of the room vnums the default rooms will be put in for you. That should be it, but if I've left out something let me know. The clan code was written by Dale Wilson (dale@spaceman.cs.wits.ac.za), but I'm known as Kharon Implementor of the mud that, as yet, doesn't have a name :( mud address: spaceman.cs.wits.ac.za 4000
Archive contents (7 files)
| File | Size |
|---|---|
| clan.c | 10.3 KB |
| clan.h | 573 B |
| clans.txt | 146 B |
| do_guild | 2.1 KB |
| merc_pref.h | 343 B |
| readme | 3.7 KB |
| ftp.kyndig.com | 935 B |