Changed since list version ========================== Pointed out by Terry Grunwald <mudmstr@mud.imperium.net>: * Not all of the structure should be made constant - gcc complains if spell_fun is made constant * There was some stuff in the file which was specific to my MUD (sysdata, and dynamic allocation of skill_levels). This was removed. What follows is the text of the original message sent to the MERC mailing list. From erwin@pip.dknet.dk Sun Oct 13 18:07:59 1996 Status: O X-Status: Newsgroups: Date: Sun, 13 Oct 1996 18:07:57 +0100 (MET) From: erwin@pip.dknet.dk X-Sender: erwin@shire.shire.dk To: MERC/Envy Mailing List <merc-l@webnexus.com> Subject: Dynamic assignment of spells/skills Message-ID: <Pine.LNX.3.91.961013174606.831B@shire.shire.dk> Fcc: sent-mail MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII One thing I found very tiring was modifying every entry in the skill_table every time a new class was added. Therefore, I wrote this extension to the current system, which loads those levels from a file, rather than have them hard-coded. Using the SKILL command you can quickly assign new skills/spells to classes. The usage is: SKILL <class-name> <skill> <level> e.g. SKILL Mag 'magic missile' 4 to give Mages 'magic missile' at level 4. To use this code, first make the CLASS_DIR (whatever value you assign to it, see below). Then add a call to save_classes() in , say, boot_db(). Compile and run the MUD, then break it, as soon as it starts up. Check now that you have a file for each class in your CLASS_DIR, and they have the correct levels (it's been a while since I wrote this code, I might be forgetting something :) Now, remove the call to save_classes() and add one to load_classes() instead, somewhere in boot_db(). Double check that all classes have the correct spells/skills at correct levels after booting. I originally wanted to make creation of new classes dynamic as well, but never got around doing this in the Envy version of my code. This is the reason for the uncommented alloc_perms in load_classes(). You need to #define CLASS_DIR to some dir you want all class files to be in, e.g. #define CLASS_DIR "../data/Classes/" (I've created a data/ directory at the same level as area/ src/ etc. where I put such files) You also should add a new element to the class_table, const char * name. This is the full name of this class, which is used as file name for saving. You could also use the 3-letter name if you wish. Be sure to actually give this field a value in your class_table. skill_table should be made non-constant, but you could then add const to the constant fields of skill_type, i.e. everything but the skill_level array. You should not set the spell_fun element constant, either. This file is (or will be soon) available at my ftp site, ftp://pip.dknet.dk/pub/pip1773 Since the class files are ASCII, they can be easily editted offline as well. PS: Please mail me if you find this of any value :) PPS: You can leave the initializers for the skill_levels in place in const.c, they will be overwritten anyway. You don't need to add anything there when you add a new class: unitialized entries will default to 0, but will be overwritten by load_classes() anyway.