Re: GUILD related layout

From: Thomas Arp (t_arp@mail1.stofanet.dk)
Date: 03/28/01


<snip of implementation details/reasons>

>  struct trainer_data trn_skills[MAX_SPELLS + MAX_SKILLS]

This should just be
/* +1 because of all skills + skill number 0 */
struct trainer_data trn_skills[MAX_SKILLS+1]

> Now I have the following questions, how is it I can designate to an
> array a meaningful set of values based upon SPELL/SKILL numbers, when
> the two differ widely from each other.

They don't - see below.

>  struct trainer_data trn_skills[MAX_SPELLS + MAX_SKILLS]
>

Use:

struct trainer_data trn_skills[MAX_SKILLS+1]

for the reasons in the other posting.
See below for another idea.

> In turn designating each chosen SKILL/SPELL from a menu layout in medit,
> in an assignment line similar to:
>
>    trn_skills[(atoi(arg))] = { (atoi(arg)), (2nd input for percent),
> -> cont'd. (3rd input for cost of learning)};
>                ^ spell number as produced from listing.
>

This part is easily emulated from the rest of the medit code.
See below.

> Now I have the following questions, how is it I can designate to an
> array a meaningful set of values based upon SPELL/SKILL numbers, when
> the two differ widely from each other.

They don't - see below (and yes, this time there really is something below)

> How do I distinguish between
> SKILL/SPELL (after) user input.

The skill-list in stock circle is constructed via these principles:

first skill is 0 - reserved
next entries in the list (from 1 to MAX_SPELLS) are spells
next entried in the list (from MAX_SPELLS+1 to MAX_SKILLS) are skills
next entries in the list (MAX_SKILLS+1 to MAX_SPELL_DEFINE) cannot be
learned by players, but can still be cast from scrolls, potions etc.
entries above MAX_SPELL_DEFINE (up to TYPE_SUFFERING) are weapon
attack types.

Thus, to distinguish between skills and spells after user input, just
check if the entered number is less than or equal to MAX_SPELLS.

> How do I list through a medit display
> feature I would create a numbered display of both skills and spells,
> and accept inputted value as the number to which corresponds to that
> skill and or spell.

Take a look at the oedit_disp_spells_menu() function and mimic what
that one does - you'll just want to make it loop all the way to
MAX_SKILLS instead.

> Aswell if the above even close to a slight
> representation of how this can be done effectively?

The entering values part is no problem - it can hardly be done more
effectively. The memory consumption of the struct is something completely
different. See below.

> And last but not
> least if so... how would I go about initializing and or maintaining
> minimal memory use without having to fill up MOB values with 0.
> What I mean there is, if I'm creating a new mob, will it fill it's
> values all to 0, and blow memory away.. or will it not become
> initialized
> and or set unless specified by the builder.  Sorry forgot one -
> if it will not become initialized and I don't have to run through all
> my mob files adding 330 0's for every mob inorder for db.c to boot up,
> what means of initializing will be inorder to remember mob related
> attributes (that of which they can teach) to others.

This is the main disadvantage of this setup. Another way to do it would
be to make the 'trainer list' a linked list, like this:

struct trainer_data {
  int spell_num;
  int percent;
  int cost;
  struct trainer_data *next;
}

This way you only use the memory for the skills the trainer actually
can train. If in doubt about how to use linked lists, you might want
to have a look at the code where it handles affects.

Welcor

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/04/01 PST