version 1.17 | | version 1.18 |
---|
| | |
/* | | /* |
* static char *rcsid_skill_util_c = | | * static char *rcsid_skill_util_c = |
* "$Id: skill_util.c,v 1.17 2001/05/29 04:41:54 mwedel Exp $"; | | * "$Id: skill_util.c,v 1.18 2001/06/29 05:59:46 mwedel Exp $"; |
*/ | | */ |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
LOG(llevError,"Error: unlink_skill() called for non-player!\n"); | | LOG(llevError,"Error: unlink_skill() called for non-player!\n"); |
return; | | return; |
} | | } |
| | |
#ifdef LINKED_SKILL_LIST | | |
if(remove_skill_from_list(op,skillop)) | | |
#endif | | |
skillop->exp_obj = NULL; | | skillop->exp_obj = NULL; |
} | | } |
| | |
int remove_skill_from_list(object *op, object *skillop) { | | |
objectlink *obl=op->sk_list,*first,*prev=NULL,*nxt; | | |
| | |
if(!skillop) return 0; | | |
| | |
prev=first=obl; | | |
while(obl) { | | |
nxt = obl->next ? obl->next: NULL; | | |
if(obl->id==skillop->stats.sp) { | | |
if(obl==first) { | | |
op->sk_list = nxt; | | |
nxt = (nxt&&nxt->next) ? nxt->next: NULL; | | |
} | | |
if(prev) prev->next = nxt; | | |
#if 0 | | |
LOG(llevDebug,"Removing skill: %s from list\n", | | |
skillop->name); | | |
#endif | | |
CFREE(obl); | | |
obl = NULL; | | |
return 1; | | |
} else | | |
prev = obl; | | |
obl=nxt; | | |
} | | |
| | |
if(first) op->sk_list = first; | | |
return 0; | | |
} | | |
| | |
/* link_player_skills() - linking skills with experience objects | | /* link_player_skills() - linking skills with experience objects |
* and creating a linked list of skills for later fast access. | | * and creating a linked list of skills for later fast access. |
| | |
} | | } |
/* Ok, create linked list and link the associated skills to exp objects */ | | /* Ok, create linked list and link the associated skills to exp objects */ |
for(i=0;i<sk_index;i++) { | | for(i=0;i<sk_index;i++) { |
#ifdef LINKED_SKILL_LIST | | |
objectlink *obl; | | |
obl = (objectlink *) malloc(sizeof(objectlink)); | | |
obl->ob=sk_ob[i]; | | |
obl->id=sk_ob[i]->stats.sp; | | |
obl->next = pl->sk_list; | | |
pl->sk_list = obl; | | |
#endif | | |
cat = skills[sk_ob[i]->stats.sp].category; | | cat = skills[sk_ob[i]->stats.sp].category; |
if(cat==EXP_NONE) continue; | | if(cat==EXP_NONE) continue; |
| | |
| | |
int link_player_skill(object *pl, object *skillop) { | | int link_player_skill(object *pl, object *skillop) { |
object *tmp; | | object *tmp; |
int cat; | | int cat; |
#ifdef LINKED_SKILL_LIST | | |
objectlink *obl; | | |
| | |
/* add it to the linked list */ | | |
obl = (objectlink *) malloc(sizeof(objectlink)); | | |
obl->ob=skillop; | | |
obl->id=skillop->stats.sp; | | |
obl->next = pl->sk_list; | | |
pl->sk_list = obl; | | |
#endif | | |
| | |
cat = skills[skillop->stats.sp].category; | | cat = skills[skillop->stats.sp].category; |
| | |
| | |
learn_skill (object *pl, object *scroll) { | | learn_skill (object *pl, object *scroll) { |
object *tmp; | | object *tmp; |
archetype *skill; | | archetype *skill; |
#ifdef LINKED_SKILL_LIST | | |
objectlink *obl; | | |
#else | | |
object *tmp2; | | object *tmp2; |
#endif | | int has_meditation=0; |
| | |
skill=find_archetype(scroll->slaying); | | skill=find_archetype(scroll->slaying); |
if(!skill) | | if(!skill) |
return 2; | | return 2; |
| | |
if(!tmp) return 2; | | if(!tmp) return 2; |
| | |
/* check if player already has it */ | | /* check if player already has it */ |
#ifdef LINKED_SKILL_LIST | | for (tmp2=pl->inv;tmp2;tmp2=tmp2->below) { |
for(obl=pl->sk_list;obl;obl=obl->next) | | if(tmp2->type==SKILL&&tmp2->invisible) { |
if(obl->ob->invisible | | if (tmp2->stats.sp==tmp->stats.sp) return 0; |
&&(obl->ob->stats.sp==tmp->stats.sp)) return 0; | | else if (tmp2->stats.sp == SK_MEDITATION) has_meditation=1; |
#else /* LINKED_SKILL_LIST */ | | } |
for(tmp2=pl->inv;tmp2;tmp2=tmp2->below) | | } |
if(tmp2->type==SKILL&&tmp2->invisible | | |
&&tmp2->stats.sp==tmp->stats.sp) return 0; | | |
# endif /* LINKED_SKILL_LIST */ | | |
| | |
| | /* Special check - if the player has meditation (monk), they can not |
| | * learn melee weapons. Prevents monk from getting this |
| | * skill. |
| | */ |
| | if (tmp->stats.sp == SK_MELEE_WEAPON && has_meditation) { |
| | new_draw_info(NDI_UNIQUE, 0,pl,"Your knowledge of inner peace prevents you from learning about melee weapons."); |
| | return 2; |
| | } |
/* now a random change to learn, based on player Int */ | | /* now a random change to learn, based on player Int */ |
if(RANDOM()%100>learn_spell[pl->stats.Int]) | | if(RANDOM()%100>learn_spell[pl->stats.Int]) |
return 2; /* failure :< */ | | return 2; /* failure :< */ |
| | |
object *tmp=NULL; | | object *tmp=NULL; |
char buf[MAX_BUF], *in; | | char buf[MAX_BUF], *in; |
int i,length,is_first; | | int i,length,is_first; |
#ifdef LINKED_SKILL_LIST | | |
objectlink *obl; | | |
| | |
if (!op->sk_list) { | | |
new_draw_info(NDI_UNIQUE, 0,op,"You know no skills."); | | |
op->chosen_skill=NULL; /* double safety - for those who lose skills */ | | |
return; | | |
} else { | | |
#endif | | |
length = 31; | | length = 31; |
in = ""; | | in = ""; |
if (op) | | if (op) |
| | |
/* sprintf(buf,"Player Skills Category /lvl"); */ | | /* sprintf(buf,"Player Skills Category /lvl"); */ |
sprintf(buf,"Player skills by experience category"); | | sprintf(buf,"Player skills by experience category"); |
new_draw_info(NDI_UNIQUE, 0,op,buf); | | new_draw_info(NDI_UNIQUE, 0,op,buf); |
#ifdef LINKED_SKILL_LIST | | |
} | | |
#endif | | |
| | |
/* print out skills by category */ | | /* print out skills by category */ |
for (i=0;i<=nrofexpcat;i++) { | | for (i=0;i<=nrofexpcat;i++) { |
| | |
Special[0]='\0'; | | Special[0]='\0'; |
is_first=1; | | is_first=1; |
if(i==nrofexpcat) i=EXP_NONE; /* skip to misc exp category */ | | if(i==nrofexpcat) i=EXP_NONE; /* skip to misc exp category */ |
#ifdef LINKED_SKILL_LIST | | |
for (obl=op->sk_list;obl;obl=obl->next) { | | |
tmp = obl->ob; | | |
#else | | |
for (tmp=op->inv;tmp;tmp=tmp->below) { | | for (tmp=op->inv;tmp;tmp=tmp->below) { |
if(tmp->type!=SKILL) continue; | | if(tmp->type!=SKILL) continue; |
#endif | | |
if(skills[tmp->stats.sp].category==i | | if(skills[tmp->stats.sp].category==i |
&&(tmp->invisible||QUERY_FLAG(tmp,FLAG_APPLIED))) { | | &&(tmp->invisible||QUERY_FLAG(tmp,FLAG_APPLIED))) { |
/* header info */ | | /* header info */ |
| | |
tmp_exp->stats.exp, | | tmp_exp->stats.exp, |
level_exp(tmp_exp->level+1, op->expmul)); | | level_exp(tmp_exp->level+1, op->expmul)); |
} | | } |
if (strcmp(tmp_exp->name,"physique")==0) | | if (strcmp(tmp_exp->name,"physique")==0) { |
{ | | |
sprintf(Special,"You can handle %d weapon improvements.",tmp_exp->level/5+5); | | sprintf(Special,"You can handle %d weapon improvements.",tmp_exp->level/5+5); |
} | | } |
if (strcmp(tmp_exp->name,"wisdom")==0) | | if (strcmp(tmp_exp->name,"wisdom")==0) { |
{ | | |
char *cp = determine_god(op); | | char *cp = determine_god(op); |
| | |
sprintf(Special,"You worship %s.", cp?cp:"no god at current time"); | | sprintf(Special,"You worship %s.", cp?cp:"no god at current time"); |
} | | } |
} else if(i==EXP_NONE) { | | } else if(i==EXP_NONE) { |
new_draw_info(NDI_UNIQUE,0,op,"misc."); | | new_draw_info(NDI_UNIQUE,0,op,"misc."); |
} | | } |
} | | } /* is_first */ |
| | |
/* print matched skills */ | | /* print matched skills */ |
if((!op || QUERY_FLAG(op, FLAG_WIZ))) | | if((!op || QUERY_FLAG(op, FLAG_WIZ))) |
(void) sprintf(buf,"%s%s %s (%5d)",in, | | (void) sprintf(buf,"%s%s %s (%5d)",in, |
| | |
(void) sprintf(buf,"%s%s %s",in, | | (void) sprintf(buf,"%s%s %s",in, |
QUERY_FLAG(tmp,FLAG_APPLIED)?"*":"-", | | QUERY_FLAG(tmp,FLAG_APPLIED)?"*":"-", |
skills[tmp->stats.sp].name); | | skills[tmp->stats.sp].name); |
| | |
new_draw_info(NDI_UNIQUE,0,op,buf); | | new_draw_info(NDI_UNIQUE,0,op,buf); |
} | | } |
} | | } |
if (Special[0]!='\0') | | if (Special[0]!='\0') { |
{ | | |
new_draw_info(NDI_UNIQUE,0,op,Special); | | new_draw_info(NDI_UNIQUE,0,op,Special); |
} | | } |
} | | } |