On Mon, 20 Jan 1997, Ray Campbell wrote:
> Heyas, I got a little question that prolly can be answered by a yes/no
> question (hopefully)...I wanna know if I can make a skil/spell RACE
> specific, like in class.c make a seperate function to give a particular
> race a set of spells and skills so that no other class could get them
> unless they where this race. My hypothesis was to write this:
>
> /* Arachnid */
> spell_level(SKILL_EIGTH_ATTACK, RACE_ARACHNID, 90);
No, you can't. The RACE_ defines most likely have the same numbers
as the class defines (eg., RACE_HUMAN==0, CLASS_MAGIC_USER==0), so
there's no way to tell the difference between them, thus RACE_ARACHNID
would either be determined as a class (if it's within the range of
classes), or cause an error.
The solution, then, is to make a seperate function that sets a spell
race dependant, and change the spell structure in spells.h to support
this. Add the following to the spell structure:
// instead of the below you may have to use 'bool race_dependant;'
int race_dependant : 1;
int valid_races;
We are going to use 'valid_races' as a bitvector. This will be a
problem if you have more than 32 classes, but since Erik is working
on his bitv array (or is he finished?), this won't be a problem for
too long. His idea worked in my from-the-ground-up MUD, I know the
theory works, but it'll probably be harder in CircleMUD, which has
a lot more code in it than I do, yet.
Now, in spell_parser.c, add the following:
void spell_race(int skillnum, int race) {
if (skillnum <= 0 || skillnum > MAX_SKILLS)
return;
if (race < 0 || race >= NUM_RACES)
return;
spell_info[skillnum].race_dependant = 1;
SET_BIT(spell_info[skillnum].valid_races, (1 << race));
}
You might want to change spello() to set 'race_dependant' to 0. Then
always have the spell_race() call follow it. Just for safety.
Now in the practice spec procs (see beginning of spec_procs.c), you
have to check if the person's *race* has the spell, too. So, for
instance, find code *similar* (I don't have access to the code at this
time, so I'm guessing how the stock code looks) to this:
if (spell_info[i].min_level[(int)GET_CLASS(ch)] <= GET_LEVEL(ch))
..and before it, add an 'if' check like so:
if (spell_info[i].race_dependant &&
!IS_SET(spell_info[i].valid_races, (1 << GET_RACE(ch))))
For the spell listing routine, the 'i' is the variable you want, and
you want the 'if' to continue. For the actual practice routine, you
want to send a message and return.
I'm probably making this sound a lot harder than it is...
--
Daniel Koepke
dkoepke@california.com
Forgive me father, for I am sin.
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://cspo.queensu.ca/~fletcher/Circle/list_faq.html |
+-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST