Welcome to the Builder Academy

Question Races With Spells

More
01 Feb 2013 20:36 - 01 Feb 2013 20:41 #1444 by Fubar
Races With Spells was created by Fubar
Code:
/* Dragonball Z Dimension Snippet Version 1.0 Author: David Piner Email: Dapiner@yahoo.com <---Not that long http://newpinerorder.hypermart.net Date: June 26, 2001 */ Binary files old/bin/circle and new/bin/circle differ Binary files old/src/act.informative.o and new/src/act.informative.o differ Binary files old/src/act.item.o and new/src/act.item.o differ Binary files old/src/act.movement.o and new/src/act.movement.o differ Binary files old/src/act.offensive.o and new/src/act.offensive.o differ Binary files old/src/act.other.o and new/src/act.other.o differ Binary files old/src/act.social.o and new/src/act.social.o differ Binary files old/src/act.wizard.o and new/src/act.wizard.o differ Binary files old/src/asciimap.o and new/src/asciimap.o differ Binary files old/src/castle.o and new/src/castle.o differ diff -uNr old/src/class.c new/src/class.c --- old/src/class.c 2013-01-29 18:11:10.000000000 -0800 +++ new/src/class.c 2013-01-29 18:52:11.013294335 -0800 @@ -1585,78 +1585,85 @@ void init_spell_levels(void) { /* MAGES */ - spell_level(SPELL_MAGIC_MISSILE, CLASS_MAGIC_USER, 1); - spell_level(SPELL_DETECT_INVIS, CLASS_MAGIC_USER, 2); - spell_level(SPELL_DETECT_MAGIC, CLASS_MAGIC_USER, 2); - spell_level(SPELL_CHILL_TOUCH, CLASS_MAGIC_USER, 3); - spell_level(SPELL_INFRAVISION, CLASS_MAGIC_USER, 3); - spell_level(SPELL_INVISIBLE, CLASS_MAGIC_USER, 4); - spell_level(SPELL_ARMOR, CLASS_MAGIC_USER, 4); - spell_level(SPELL_BURNING_HANDS, CLASS_MAGIC_USER, 5); - spell_level(SPELL_LOCATE_OBJECT, CLASS_MAGIC_USER, 6); - spell_level(SPELL_STRENGTH, CLASS_MAGIC_USER, 6); - spell_level(SPELL_SHOCKING_GRASP, CLASS_MAGIC_USER, 7); - spell_level(SPELL_SLEEP, CLASS_MAGIC_USER, 8); - spell_level(SPELL_LIGHTNING_BOLT, CLASS_MAGIC_USER, 9); - spell_level(SPELL_BLINDNESS, CLASS_MAGIC_USER, 9); - spell_level(SPELL_DETECT_POISON, CLASS_MAGIC_USER, 10); - spell_level(SPELL_COLOR_SPRAY, CLASS_MAGIC_USER, 11); - spell_level(SPELL_ENERGY_DRAIN, CLASS_MAGIC_USER, 13); - spell_level(SPELL_CURSE, CLASS_MAGIC_USER, 14); - spell_level(SPELL_POISON, CLASS_MAGIC_USER, 14); - spell_level(SPELL_FIREBALL, CLASS_MAGIC_USER, 15); - spell_level(SPELL_CHARM, CLASS_MAGIC_USER, 16); - spell_level(SPELL_IDENTIFY, CLASS_MAGIC_USER, 20); - spell_level(SPELL_FLY, CLASS_MAGIC_USER, 22); - spell_level(SPELL_ENCHANT_WEAPON, CLASS_MAGIC_USER, 26); - spell_level(SPELL_CLONE, CLASS_MAGIC_USER, 30); + spell_level_class(SPELL_MAGIC_MISSILE, CLASS_MAGIC_USER, 1); + spell_level_class(SPELL_DETECT_INVIS, CLASS_MAGIC_USER, 2); + spell_level_class(SPELL_DETECT_MAGIC, CLASS_MAGIC_USER, 2); + spell_level_class(SPELL_CHILL_TOUCH, CLASS_MAGIC_USER, 3); + spell_level_class(SPELL_INFRAVISION, CLASS_MAGIC_USER, 3); + spell_level_class(SPELL_INVISIBLE, CLASS_MAGIC_USER, 4); + spell_level_class(SPELL_ARMOR, CLASS_MAGIC_USER, 4); + spell_level_class(SPELL_BURNING_HANDS, CLASS_MAGIC_USER, 5); + spell_level_class(SPELL_LOCATE_OBJECT, CLASS_MAGIC_USER, 6); + spell_level_class(SPELL_STRENGTH, CLASS_MAGIC_USER, 6); + spell_level_class(SPELL_SHOCKING_GRASP, CLASS_MAGIC_USER, 7); + spell_level_class(SPELL_SLEEP, CLASS_MAGIC_USER, 8); + spell_level_class(SPELL_LIGHTNING_BOLT, CLASS_MAGIC_USER, 9); + spell_level_class(SPELL_BLINDNESS, CLASS_MAGIC_USER, 9); + spell_level_class(SPELL_DETECT_POISON, CLASS_MAGIC_USER, 10); + spell_level_class(SPELL_COLOR_SPRAY, CLASS_MAGIC_USER, 11); + spell_level_class(SPELL_ENERGY_DRAIN, CLASS_MAGIC_USER, 13); + spell_level_class(SPELL_CURSE, CLASS_MAGIC_USER, 14); + spell_level_class(SPELL_POISON, CLASS_MAGIC_USER, 14); + spell_level_class(SPELL_FIREBALL, CLASS_MAGIC_USER, 15); + spell_level_class(SPELL_CHARM, CLASS_MAGIC_USER, 16); + spell_level_class(SPELL_IDENTIFY, CLASS_MAGIC_USER, 20); + spell_level_class(SPELL_FLY, CLASS_MAGIC_USER, 22); + spell_level_class(SPELL_ENCHANT_WEAPON, CLASS_MAGIC_USER, 26); + spell_level_class(SPELL_CLONE, CLASS_MAGIC_USER, 30); /* CLERICS */ - spell_level(SPELL_CURE_LIGHT, CLASS_CLERIC, 1); - spell_level(SPELL_ARMOR, CLASS_CLERIC, 1); - spell_level(SPELL_CREATE_FOOD, CLASS_CLERIC, 2); - spell_level(SPELL_CREATE_WATER, CLASS_CLERIC, 2); - spell_level(SPELL_DETECT_POISON, CLASS_CLERIC, 3); - spell_level(SPELL_DETECT_ALIGN, CLASS_CLERIC, 4); - spell_level(SPELL_CURE_BLIND, CLASS_CLERIC, 4); - spell_level(SPELL_BLESS, CLASS_CLERIC, 5); - spell_level(SPELL_DETECT_INVIS, CLASS_CLERIC, 6); - spell_level(SPELL_BLINDNESS, CLASS_CLERIC, 6); - spell_level(SPELL_INFRAVISION, CLASS_CLERIC, 7); - spell_level(SPELL_PROT_FROM_EVIL, CLASS_CLERIC, 8); - spell_level(SPELL_POISON, CLASS_CLERIC, 8); - spell_level(SPELL_GROUP_ARMOR, CLASS_CLERIC, 9); - spell_level(SPELL_CURE_CRITIC, CLASS_CLERIC, 9); - spell_level(SPELL_SUMMON, CLASS_CLERIC, 10); - spell_level(SPELL_REMOVE_POISON, CLASS_CLERIC, 10); - spell_level(SPELL_IDENTIFY, CLASS_CLERIC, 11); - spell_level(SPELL_WORD_OF_RECALL, CLASS_CLERIC, 12); - spell_level(SPELL_EARTHQUAKE, CLASS_CLERIC, 12); - spell_level(SPELL_DISPEL_EVIL, CLASS_CLERIC, 14); - spell_level(SPELL_DISPEL_GOOD, CLASS_CLERIC, 14); - spell_level(SPELL_SANCTUARY, CLASS_CLERIC, 15); - spell_level(SPELL_CALL_LIGHTNING, CLASS_CLERIC, 15); - spell_level(SPELL_HEAL, CLASS_CLERIC, 16); - spell_level(SPELL_CONTROL_WEATHER, CLASS_CLERIC, 17); - spell_level(SPELL_SENSE_LIFE, CLASS_CLERIC, 18); - spell_level(SPELL_HARM, CLASS_CLERIC, 19); - spell_level(SPELL_GROUP_HEAL, CLASS_CLERIC, 22); - spell_level(SPELL_REMOVE_CURSE, CLASS_CLERIC, 26); + spell_level_class(SPELL_CURE_LIGHT, CLASS_CLERIC, 1); + spell_level_class(SPELL_ARMOR, CLASS_CLERIC, 1); + spell_level_class(SPELL_CREATE_FOOD, CLASS_CLERIC, 2); + spell_level_class(SPELL_CREATE_WATER, CLASS_CLERIC, 2); + spell_level_class(SPELL_DETECT_POISON, CLASS_CLERIC, 3); + spell_level_class(SPELL_DETECT_ALIGN, CLASS_CLERIC, 4); + spell_level_class(SPELL_CURE_BLIND, CLASS_CLERIC, 4); + spell_level_class(SPELL_BLESS, CLASS_CLERIC, 5); + spell_level_class(SPELL_DETECT_INVIS, CLASS_CLERIC, 6); + spell_level_class(SPELL_BLINDNESS, CLASS_CLERIC, 6); + spell_level_class(SPELL_INFRAVISION, CLASS_CLERIC, 7); + spell_level_class(SPELL_PROT_FROM_EVIL, CLASS_CLERIC, 8); + spell_level_class(SPELL_POISON, CLASS_CLERIC, 8); + spell_level_class(SPELL_GROUP_ARMOR, CLASS_CLERIC, 9); + spell_level_class(SPELL_CURE_CRITIC, CLASS_CLERIC, 9); + spell_level_class(SPELL_SUMMON, CLASS_CLERIC, 10); + spell_level_class(SPELL_REMOVE_POISON, CLASS_CLERIC, 10); + spell_level_class(SPELL_IDENTIFY, CLASS_CLERIC, 11); + spell_level_class(SPELL_WORD_OF_RECALL, CLASS_CLERIC, 12); + spell_level_class(SPELL_EARTHQUAKE, CLASS_CLERIC, 12); + spell_level_class(SPELL_DISPEL_EVIL, CLASS_CLERIC, 14); + spell_level_class(SPELL_DISPEL_GOOD, CLASS_CLERIC, 14); + spell_level_class(SPELL_SANCTUARY, CLASS_CLERIC, 15); + spell_level_class(SPELL_CALL_LIGHTNING, CLASS_CLERIC, 15); + spell_level_class(SPELL_HEAL, CLASS_CLERIC, 16); + spell_level_class(SPELL_CONTROL_WEATHER, CLASS_CLERIC, 17); + spell_level_class(SPELL_SENSE_LIFE, CLASS_CLERIC, 18); + spell_level_class(SPELL_HARM, CLASS_CLERIC, 19); + spell_level_class(SPELL_GROUP_HEAL, CLASS_CLERIC, 22); + spell_level_class(SPELL_REMOVE_CURSE, CLASS_CLERIC, 26); /* THIEVES */ - spell_level(SKILL_SNEAK, CLASS_THIEF, 1); - spell_level(SKILL_PICK_LOCK, CLASS_THIEF, 2); - spell_level(SKILL_BACKSTAB, CLASS_THIEF, 3); - spell_level(SKILL_STEAL, CLASS_THIEF, 4); - spell_level(SKILL_HIDE, CLASS_THIEF, 5); - spell_level(SKILL_TRACK, CLASS_THIEF, 6); + spell_level_class(SKILL_SNEAK, CLASS_THIEF, 1); + spell_level_class(SKILL_PICK_LOCK, CLASS_THIEF, 2); + spell_level_class(SKILL_BACKSTAB, CLASS_THIEF, 3); + spell_level_class(SKILL_STEAL, CLASS_THIEF, 4); + spell_level_class(SKILL_HIDE, CLASS_THIEF, 5); + spell_level_class(SKILL_TRACK, CLASS_THIEF, 6); /* WARRIORS */ - spell_level(SKILL_KICK, CLASS_WARRIOR, 1); - spell_level(SKILL_RESCUE, CLASS_WARRIOR, 3); - spell_level(SKILL_TRACK, CLASS_WARRIOR, 9); - spell_level(SKILL_BASH, CLASS_WARRIOR, 12); - spell_level(SKILL_WHIRLWIND, CLASS_WARRIOR, 12); + spell_level_class(SKILL_KICK, CLASS_WARRIOR, 1); + spell_level_class(SKILL_RESCUE, CLASS_WARRIOR, 3); + spell_level_class(SKILL_TRACK, CLASS_WARRIOR, 9); + spell_level_class(SKILL_BASH, CLASS_WARRIOR, 12); + spell_level_class(SKILL_WHIRLWIND, CLASS_WARRIOR, 12); + + /* WARRIORS */ + spell_level(SKILL_KICK, RACE_HUMANOID, 1); + spell_level(SKILL_RESCUE, RACE_HUMANOID, 3); + spell_level(SKILL_TRACK, RACE_HUMANOID, 9); + spell_level(SKILL_BASH, RACE_HUMANOID, 12); + spell_level(SKILL_WHIRLWIND, RACE_HUMANOID, 12); } /* This is the exp given to implementors -- it must always be greater than the Binary files old/src/class.o and new/src/class.o differ Binary files old/src/comm.o and new/src/comm.o differ Binary files old/src/db.o and new/src/db.o differ Binary files old/src/dg_handler.o and new/src/dg_handler.o differ Binary files old/src/dg_misc.o and new/src/dg_misc.o differ Binary files old/src/dg_mobcmd.o and new/src/dg_mobcmd.o differ Binary files old/src/dg_scripts.o and new/src/dg_scripts.o differ Binary files old/src/dg_triggers.o and new/src/dg_triggers.o differ Binary files old/src/dg_variables.o and new/src/dg_variables.o differ Binary files old/src/fight.o and new/src/fight.o differ Binary files old/src/genmob.o and new/src/genmob.o differ Binary files old/src/graph.o and new/src/graph.o differ Binary files old/src/handler.o and new/src/handler.o differ Binary files old/src/interpreter.o and new/src/interpreter.o differ Binary files old/src/limits.o and new/src/limits.o differ Binary files old/src/magic.o and new/src/magic.o differ Binary files old/src/medit.o and new/src/medit.o differ Binary files old/src/mobact.o and new/src/mobact.o differ Binary files old/src/modify.o and new/src/modify.o differ Binary files old/src/oasis_list.o and new/src/oasis_list.o differ Binary files old/src/objsave.o and new/src/objsave.o differ Binary files old/src/oedit.o and new/src/oedit.o differ Binary files old/src/races.o and new/src/races.o differ Binary files old/src/shop.o and new/src/shop.o differ diff -uNr old/src/spec_procs.c new/src/spec_procs.c --- old/src/spec_procs.c 2012-04-04 16:11:23.000000000 -0700 +++ new/src/spec_procs.c 2013-01-29 18:56:29.573294339 -0800 @@ -101,6 +101,7 @@ const char *overflow = "\r\n**OVERFLOW**\r\n"; int i, sortpos; size_t len = 0, nlen; + char buf[MAX_STRING_LENGTH]; char buf2[MAX_STRING_LENGTH]; len = snprintf(buf2, sizeof(buf2), "You have %d practice session%s remaining.\r\n" @@ -115,6 +116,10 @@ break; len += nlen; } + if (GET_LEVEL(ch) >= spell_info[i].min_level_race[(int) GET_RACE(ch)]) { + sprintf(buf, "%-20s %s\r\n", spell_info[i].name, how_good(GET_SKILL(ch, i))); + strcat(buf2, buf); /* This shows the Race practices */ + } } if (len >= sizeof(buf2)) strcpy(buf2 + sizeof(buf2) - strlen(overflow) - 1, overflow); /* strcpy: OK */ @@ -142,8 +147,9 @@ skill_num = find_skill_num(argument); - if (skill_num < 1 || - GET_LEVEL(ch) < spell_info[skill_num].min_level[(int) GET_CLASS(ch)]) { + if (skill_num < 1 || + (GET_LEVEL(ch) < spell_info[skill_num].min_level[(int) GET_CLASS(ch)] && + GET_LEVEL(ch) < spell_info[skill_num].min_level_race[(int) GET_RACE(ch)])){ send_to_char(ch, "You do not know of that %s.\r\n", SPLSKL(ch)); return (TRUE); } Binary files old/src/spec_procs.o and new/src/spec_procs.o differ diff -uNr old/src/spell_parser.c new/src/spell_parser.c --- old/src/spell_parser.c 2012-04-04 16:11:23.000000000 -0700 +++ new/src/spell_parser.c 2013-01-29 18:55:50.721294311 -0800 @@ -520,10 +520,11 @@ send_to_char(ch, "Cast what?!?\r\n"); return; } - if (GET_LEVEL(ch) < SINFO.min_level[(int) GET_CLASS(ch)]) { - send_to_char(ch, "You do not know that spell!\r\n"); + if ((GET_LEVEL(ch) < SINFO.min_level[(int) GET_CLASS(ch)]) && + (GET_LEVEL(ch) < SINFO.min_level_race[(int) GET_RACE(ch)])) { + send_to_char(ch, "You do not know that attack!\r\n"); return; - } + } if (GET_SKILL(ch, spellnum) == 0) { send_to_char(ch, "You are unfamiliar with that spell.\r\n"); return; @@ -626,7 +627,35 @@ } } -void spell_level(int spell, int chclass, int level) +void spell_level(int spell, int race, int level) +{ + int bad = 0; + + if (spell < 0 || spell > TOP_SPELL_DEFINE) { + log("SYSERR: attempting assign to illegal spellnum %d/%d", spell, TOP_SPELL_DEFINE); + return; + } + + if (race < 0 || race >= NUM_RACES) { + log("SYSERR: assigning '%s' to illegal race %d/%d.", skill_name(spell), + race, NUM_RACES -1); /* If you have a good compiler, this should not happen*/ + bad = 1; + } + + + if (level < 1 || level > LVL_IMPL) { + log("SYSERR: assigning '%s' to illegal level %d/%d.", skill_name(spell), + level, LVL_IMPL); + bad = 1; + } + + if (!bad) /* Right there \ is the new race stuff to */ + spell_info[spell].min_level_race[race] = level; +} + +/* This is the old class one, if you don't use races that much + switch the names */ +void spell_level_class(int spell, int chclass, int level) { int bad = 0; @@ -635,7 +664,7 @@ return; } - if (chclass < 0 || chclass >= NUM_CLASSES) { + if (chclass < 0 || chclass >= NUM_CLASSES) { log("SYSERR: assigning '%s' to illegal class %d/%d.", skill_name(spell), chclass, NUM_CLASSES - 1); bad = 1; @@ -647,7 +676,7 @@ bad = 1; } - if (!bad) + if (!bad) spell_info[spell].min_level[chclass] = level; } @@ -658,6 +687,9 @@ { int i; + for (i = 0; i < NUM_RACES; i++) + spell_info[spl].min_level_race[i] = LVL_IMMORT; + for (i = 0; i < NUM_CLASSES; i++) spell_info[spl].min_level[i] = LVL_IMMORT; spell_info[spl].mana_max = max_mana; @@ -675,6 +707,9 @@ { int i; + for (i = 0; i < NUM_RACES; i++) + spell_info[spl].min_level_race[i] = LVL_IMPL + 1; + for (i = 0; i < NUM_CLASSES; i++) spell_info[spl].min_level[i] = LVL_IMPL + 1; spell_info[spl].mana_max = 0; Binary files old/src/spell_parser.o and new/src/spell_parser.o differ diff -uNr old/src/spells.h new/src/spells.h --- old/src/spells.h 2012-04-04 16:11:23.000000000 -0700 +++ new/src/spells.h 2013-01-29 18:43:21.693294378 -0800 @@ -184,6 +184,7 @@ int mana_change; /* Change in mana used by spell from lev to lev */ int min_level[NUM_CLASSES]; + int min_level_race[NUM_RACES]; int routines; byte violent; int targets; /* See below for use with TAR_XXX */ @@ -265,7 +266,8 @@ struct obj_data *tobj, int spellnum); /* other prototypes */ -void spell_level(int spell, int chclass, int level); +void spell_level(int spell, int race, int level); +void spell_level_class(int spell, int chclass, int level); void init_spell_levels(void); const char *skill_name(int num); Binary files old/src/spells.o and new/src/spells.o differ Binary files old/src/utils.o and new/src/utils.o differ

All I did was add this code to tbamud (3.63), and fix any errors that came up. I used the Races3.1 snippet, other race snippets may cause issues. I have also added the patch file. It was super easy to put in and fix the small errors.

Attachment racespellsv1.tgz not found

Attachments:
Last edit: 01 Feb 2013 20:41 by Fubar.

Please Log in or Create an account to join the conversation.

Time to create page: 0.629 seconds