version 1.16 | | version 1.17 |
---|
| | |
/* | | /* |
* static char *rcsid_skill_util_c = | | * static char *rcsid_skill_util_c = |
* "$Id: skill_util.c,v 1.16 2001/04/19 04:37:36 mwedel Exp $"; | | * "$Id: skill_util.c,v 1.17 2001/05/29 04:41:54 mwedel Exp $"; |
*/ | | */ |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
}; | | }; |
| | |
| | |
| | typedef struct _skill_name_table { |
| | char *name; |
| | int id; |
| | }_skill_name_table; |
| | |
| | static _skill_name_table skill_name_table[] = { |
| | {"agility", CS_STAT_SKILLEXP_AGILITY}, |
| | {"personality", CS_STAT_SKILLEXP_PERSONAL}, |
| | {"mental", CS_STAT_SKILLEXP_MENTAL}, |
| | {"physique", CS_STAT_SKILLEXP_PHYSIQUE}, |
| | {"magic", CS_STAT_SKILLEXP_MAGIC}, |
| | {"wisdom", CS_STAT_SKILLEXP_WISDOM}, |
| | {"",-1} |
| | }; |
| | |
| | /* find and assign the skill exp stuff */ |
| | |
| | void find_skill_exp_name(object *pl, object *exp, int index) |
| | { |
| | |
| | register int s; |
| | |
| | for(s=0;skill_name_table[s].id != -1;s++) |
| | { |
| | if(!strcmp(skill_name_table[s].name, exp->name) ) |
| | { |
| | pl->contr->last_skill_ob[index] = exp; |
| | pl->contr->last_skill_id[index] = skill_name_table[s].id; |
| | pl->contr->last_skill_index++; |
| | return; |
| | } |
| | |
| | } |
| | } |
| | |
| | |
/* do_skill() - Main skills use function-similar in scope to cast_spell(). | | /* do_skill() - Main skills use function-similar in scope to cast_spell(). |
* We handle all requests for skill use outside of some combat here. | | * We handle all requests for skill use outside of some combat here. |
* We require a separate routine outside of fire() so as to allow monsters | | * We require a separate routine outside of fire() so as to allow monsters |
| | |
LOG(llevError, "init_player_exp(): called non-player %s.\n",pl->name); | | LOG(llevError, "init_player_exp(): called non-player %s.\n",pl->name); |
return 0; | | return 0; |
} | | } |
| | |
| | pl->contr->last_skill_index = 0; |
| | |
/* first-pass find all current exp objects */ | | /* first-pass find all current exp objects */ |
for(tmp=pl->inv;tmp;tmp=tmp->below) | | for(tmp=pl->inv;tmp;tmp=tmp->below) |
if(tmp->type==EXPERIENCE) { | | if(tmp->type==EXPERIENCE) { |
exp_ob[exp_index] = tmp; | | exp_ob[exp_index] = tmp; |
| | find_skill_exp_name(pl, tmp, pl->contr->last_skill_index); |
exp_index++; | | exp_index++; |
} else if (exp_index == MAX_EXP_CAT) | | } else if (exp_index == MAX_EXP_CAT) |
return 0; | | return 0; |
| | |
/* We're going to unapply all skills */ | | /* We're going to unapply all skills */ |
pl->chosen_skill = NULL; | | pl->chosen_skill = NULL; |
CLEAR_FLAG (pl, FLAG_READY_SKILL); | | CLEAR_FLAG (pl, FLAG_READY_SKILL); |
| | pl->contr->last_skill_index = 0; |
| | |
/* first find all exp and skill objects */ | | /* first find all exp and skill objects */ |
for(tmp=pl->inv;tmp&&sk_index<100;tmp=tmp->below) | | for(tmp=pl->inv;tmp&&sk_index<100;tmp=tmp->below) |
if(tmp->type==EXPERIENCE) { | | if(tmp->type==EXPERIENCE) { |
exp_ob[exp_index] = tmp; | | exp_ob[exp_index] = tmp; |
| | find_skill_exp_name(pl, tmp, pl->contr->last_skill_index); |
tmp->nrof=1; /* to handle multiple instances */ | | tmp->nrof=1; /* to handle multiple instances */ |
exp_index++; | | exp_index++; |
} else if (tmp->type==SKILL) { | | } else if (tmp->type==SKILL) { |
| | |
object *head = op->head ? op->head : op; | | object *head = op->head ? op->head : op; |
int level; | | int level; |
| | |
#ifdef ALLOW_SKILLS | | |
if(head->type==PLAYER && head->chosen_skill && head->chosen_skill->level!=0) { | | if(head->type==PLAYER && head->chosen_skill && head->chosen_skill->level!=0) { |
level = head->chosen_skill->level; | | level = head->chosen_skill->level; |
} else { | | } else { |
level = head->level; | | level = head->level; |
} | | } |
#else | | |
level = head->level; | | |
#endif | | |
| | |
if(level<=0) | | if(level<=0) |
{ | | { |