version 1.37 | | version 1.38 |
---|
| | |
/* | | /* |
* static char *rcsid_apply_c = | | * static char *rcsid_apply_c = |
* "$Id: apply.c,v 1.37 2001/05/25 04:29:01 mwedel Exp $"; | | * "$Id: apply.c,v 1.38 2001/05/29 04:41:53 mwedel Exp $"; |
*/ | | */ |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
* Note: Nothing should break by allowing this ratio to be different or | | * Note: Nothing should break by allowing this ratio to be different or |
* using normal level - it is just a matter of play balance. | | * using normal level - it is just a matter of play balance. |
*/ | | */ |
#ifdef ALLOW_SKILLS | | |
if(who->type==PLAYER) { | | if(who->type==PLAYER) { |
object *wc_obj=NULL; | | object *wc_obj=NULL; |
| | |
| | |
level=wc_obj->level; | | level=wc_obj->level; |
} | | } |
return (improvs <= ((level/5)+5)); | | return (improvs <= ((level/5)+5)); |
#else | | |
return (improvs <= (level+5)); | | |
#endif | | |
} | | } |
| | |
/* Returns the object count that of the number of objects found that | | /* Returns the object count that of the number of objects found that |
| | |
| | |
static void apply_book (object *op, object *tmp) | | static void apply_book (object *op, object *tmp) |
{ | | { |
#ifdef ALLOW_SKILLS | | |
int lev_diff; | | int lev_diff; |
#endif | | |
| | |
if(QUERY_FLAG(op, FLAG_BLIND)&&!QUERY_FLAG(op,FLAG_WIZ)) { | | if(QUERY_FLAG(op, FLAG_BLIND)&&!QUERY_FLAG(op,FLAG_WIZ)) { |
new_draw_info(NDI_UNIQUE, 0,op,"You are unable to read while blind."); | | new_draw_info(NDI_UNIQUE, 0,op,"You are unable to read while blind."); |
| | |
"You open the %s and find it empty.", tmp->name); | | "You open the %s and find it empty.", tmp->name); |
return; | | return; |
} | | } |
#ifdef ALLOW_SKILLS /* need a literacy skill to read stuff! */ | | |
| | /* need a literacy skill to read stuff! */ |
if ( ! change_skill(op,SK_LITERACY)) { | | if ( ! change_skill(op,SK_LITERACY)) { |
new_draw_info(NDI_UNIQUE, 0,op, | | new_draw_info(NDI_UNIQUE, 0,op, |
"You are unable to decipher the strange symbols."); | | "You are unable to decipher the strange symbols."); |
| | |
new_draw_info(NDI_UNIQUE, 0,op,"This book is totally beyond your comprehension."); | | new_draw_info(NDI_UNIQUE, 0,op,"This book is totally beyond your comprehension."); |
return; | | return; |
} | | } |
#endif | | |
| | |
new_draw_info_format (NDI_UNIQUE, 0, op, | | new_draw_info_format (NDI_UNIQUE, 0, op, |
"You open the %s and start reading.", tmp->name); | | "You open the %s and start reading.", tmp->name); |
new_draw_info(NDI_UNIQUE | NDI_NAVY, 0, op, tmp->msg); | | new_draw_info(NDI_UNIQUE | NDI_NAVY, 0, op, tmp->msg); |
| | |
#ifdef ALLOW_SKILLS /* gain xp from reading */ | | /* gain xp from reading */ |
if(!QUERY_FLAG(tmp,FLAG_NO_SKILL_IDENT)) { /* only if not read before */ | | if(!QUERY_FLAG(tmp,FLAG_NO_SKILL_IDENT)) { /* only if not read before */ |
int exp_gain=calc_skill_exp(op,tmp); | | int exp_gain=calc_skill_exp(op,tmp); |
if(!QUERY_FLAG(tmp,FLAG_IDENTIFIED)) { | | if(!QUERY_FLAG(tmp,FLAG_IDENTIFIED)) { |
| | |
add_exp(op,exp_gain); | | add_exp(op,exp_gain); |
SET_FLAG(tmp,FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ | | SET_FLAG(tmp,FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
} | | } |
#endif | | |
} | | } |
| | |
| | |
#ifdef ALLOW_SKILLS | | |
static void apply_skillscroll (object *op, object *tmp) | | static void apply_skillscroll (object *op, object *tmp) |
{ | | { |
switch ((int) learn_skill (op, tmp)) | | switch ((int) learn_skill (op, tmp)) |
| | |
return; | | return; |
} | | } |
} | | } |
#endif | | |
| | |
| | |
/* Special prayers are granted by gods and lost when the follower decides | | /* Special prayers are granted by gods and lost when the follower decides |
| | |
tmp->slaying=NULL; | | tmp->slaying=NULL; |
} | | } |
| | |
#ifdef ALLOW_SKILLS | | |
/* need a literacy skill to learn spells. Also, having a literacy level | | /* need a literacy skill to learn spells. Also, having a literacy level |
* lower than the spell will make learning the spell more difficult */ | | * lower than the spell will make learning the spell more difficult */ |
if ( ! change_skill(op,SK_LITERACY)) { | | if ( ! change_skill(op,SK_LITERACY)) { |
new_draw_info(NDI_UNIQUE, 0,op,"You can't read! Your attempt fails."); | | new_draw_info(NDI_UNIQUE, 0,op,"You can't read! Your attempt fails."); |
return; | | return; |
} | | } |
#endif | | |
if(tmp->stats.sp < 0 || tmp->stats.sp > NROFREALSPELLS | | if(tmp->stats.sp < 0 || tmp->stats.sp > NROFREALSPELLS |
|| spells[tmp->stats.sp].level>(SK_level(op)+10)) { | | || spells[tmp->stats.sp].level>(SK_level(op)+10)) { |
new_draw_info(NDI_UNIQUE, 0,op,"You are unable to decipher the strange symbols."); | | new_draw_info(NDI_UNIQUE, 0,op,"You are unable to decipher the strange symbols."); |
| | |
learn_spell[spells[tmp->stats.sp].cleric ? op->stats.Wis : op->stats.Int]) { | | learn_spell[spells[tmp->stats.sp].cleric ? op->stats.Wis : op->stats.Int]) { |
new_draw_info(NDI_UNIQUE, 0,op,"You succeed in learning the spell!"); | | new_draw_info(NDI_UNIQUE, 0,op,"You succeed in learning the spell!"); |
do_learn_spell (op, tmp->stats.sp, 0); | | do_learn_spell (op, tmp->stats.sp, 0); |
#ifdef ALLOW_SKILLS /* xp gain to literacy for spell learning */ | | |
| | /* xp gain to literacy for spell learning */ |
if ( ! QUERY_FLAG (tmp, FLAG_STARTEQUIP)) | | if ( ! QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
add_exp(op,calc_skill_exp(op,tmp)); | | add_exp(op,calc_skill_exp(op,tmp)); |
#endif | | |
} else { | | } else { |
play_sound_player_only(op->contr, SOUND_FUMBLE_SPELL,0,0); | | play_sound_player_only(op->contr, SOUND_FUMBLE_SPELL,0,0); |
new_draw_info(NDI_UNIQUE, 0,op,"You fail to learn the spell.\n"); | | new_draw_info(NDI_UNIQUE, 0,op,"You fail to learn the spell.\n"); |
| | |
} | | } |
| | |
if(op->type==PLAYER) { | | if(op->type==PLAYER) { |
#ifdef ALLOW_SKILLS /* players need a literacy skill to read stuff! */ | | /* players need a literacy skill to read stuff! */ |
int exp_gain=0; | | int exp_gain=0; |
| | |
if ( ! change_skill(op,SK_LITERACY)) { | | if ( ! change_skill(op,SK_LITERACY)) { |
| | |
SET_FLAG(tmp,FLAG_APPLIED); | | SET_FLAG(tmp,FLAG_APPLIED); |
(void) check_skill_to_apply(op,tmp); | | (void) check_skill_to_apply(op,tmp); |
CLEAR_FLAG(tmp,FLAG_APPLIED); | | CLEAR_FLAG(tmp,FLAG_APPLIED); |
| | |
#endif/* ALLOW_SKILLS */ | | |
old_shoot= op->contr->shoottype; | | old_shoot= op->contr->shoottype; |
old_spell = op->contr->chosen_spell; | | old_spell = op->contr->chosen_spell; |
op->contr->shoottype=range_scroll; | | op->contr->shoottype=range_scroll; |
| | |
} | | } |
| | |
case SKILLSCROLL: | | case SKILLSCROLL: |
#ifdef ALLOW_SKILLS /* calls here shouldnt happen, but to be on safe side put here */ | | |
if (op->type == PLAYER) { | | if (op->type == PLAYER) { |
apply_skillscroll (op, tmp); | | apply_skillscroll (op, tmp); |
return 1; | | return 1; |
} | | } |
#endif | | |
return 0; | | return 0; |
| | |
case SPELLBOOK: | | case SPELLBOOK: |
| | |
case WAND: | | case WAND: |
case ROD: | | case ROD: |
case HORN: | | case HORN: |
#ifdef ALLOW_SKILLS | | |
case SKILL: | | case SKILL: |
#endif | | |
case BOW: | | case BOW: |
if (tmp->env != op) | | if (tmp->env != op) |
return 2; /* not in inventory */ | | return 2; /* not in inventory */ |
| | |
switch(op->type) { | | switch(op->type) { |
case WEAPON: | | case WEAPON: |
(void) change_abil (who,op); | | (void) change_abil (who,op); |
#ifdef ALLOW_SKILLS /* 'unready' melee weapons skill if it is current skill */ | | /* 'unready' melee weapons skill if it is current skill */ |
(void) check_skill_to_apply(who,op); | | (void) check_skill_to_apply(who,op); |
if(QUERY_FLAG(who,FLAG_READY_WEAPON)) | | if(QUERY_FLAG(who,FLAG_READY_WEAPON)) |
CLEAR_FLAG(who,FLAG_READY_WEAPON); | | CLEAR_FLAG(who,FLAG_READY_WEAPON); |
#endif | | |
sprintf(buf,"You unwield %s.",query_name(op)); | | sprintf(buf,"You unwield %s.",query_name(op)); |
break; | | break; |
#ifdef ALLOW_SKILLS | | |
case SKILL: /* allows objects to impart skills */ | | case SKILL: /* allows objects to impart skills */ |
if (op != who->chosen_skill) { | | if (op != who->chosen_skill) { |
LOG (llevError, "BUG: apply_special(): applied skill is not " | | LOG (llevError, "BUG: apply_special(): applied skill is not " |
| | |
CLEAR_FLAG (who, FLAG_READY_SKILL); | | CLEAR_FLAG (who, FLAG_READY_SKILL); |
buf[0] = '\0'; | | buf[0] = '\0'; |
break; | | break; |
#endif | | |
case ARMOUR: | | case ARMOUR: |
case HELMET: | | case HELMET: |
case SHIELD: | | case SHIELD: |
| | |
case WAND: | | case WAND: |
case ROD: | | case ROD: |
case HORN: | | case HORN: |
#ifdef ALLOW_SKILLS | | |
(void) check_skill_to_apply(who,op); | | (void) check_skill_to_apply(who,op); |
#endif | | |
sprintf(buf,"You unready %s.",query_name(op)); | | sprintf(buf,"You unready %s.",query_name(op)); |
if(who->type==PLAYER) { | | if(who->type==PLAYER) { |
who->contr->shoottype = range_none; | | who->contr->shoottype = range_none; |
| | |
| | |
SET_FLAG(op, FLAG_APPLIED); | | SET_FLAG(op, FLAG_APPLIED); |
| | |
#ifdef ALLOW_SKILLS /*check for melee weapons skill, alter player status. | | /* check for melee weapons skill, alter player status. |
* Note that we need to call this *before* change_abil */ | | * Note that we need to call this *before* change_abil */ |
if(!check_skill_to_apply(who,op)) return 1; | | if(!check_skill_to_apply(who,op)) return 1; |
if(!QUERY_FLAG(who,FLAG_READY_WEAPON)) | | if(!QUERY_FLAG(who,FLAG_READY_WEAPON)) |
SET_FLAG(who, FLAG_READY_WEAPON); | | SET_FLAG(who, FLAG_READY_WEAPON); |
#endif | | |
| | |
(void) change_abil (who,op); | | (void) change_abil (who,op); |
sprintf(buf,"You wield %s.",query_name(op)); | | sprintf(buf,"You wield %s.",query_name(op)); |
| | |
(void) change_abil (who,op); | | (void) change_abil (who,op); |
sprintf(buf,"You wear %s.",query_name(op)); | | sprintf(buf,"You wear %s.",query_name(op)); |
break; | | break; |
#ifdef ALLOW_SKILLS /* this part is needed for skill-tools */ | | |
| | /* this part is needed for skill-tools */ |
case SKILL: | | case SKILL: |
if (who->chosen_skill) { | | if (who->chosen_skill) { |
LOG (llevError, "BUG: apply_special(): can't apply two skills\n"); | | LOG (llevError, "BUG: apply_special(): can't apply two skills\n"); |
| | |
SET_FLAG (who, FLAG_READY_SKILL); | | SET_FLAG (who, FLAG_READY_SKILL); |
buf[0] = '\0'; | | buf[0] = '\0'; |
break; | | break; |
#endif | | |
| | |
case WAND: | | case WAND: |
case ROD: | | case ROD: |
case HORN: | | case HORN: |
case BOW: | | case BOW: |
#ifdef ALLOW_SKILLS /* check for skill, alter player status */ | | /* check for skill, alter player status */ |
SET_FLAG(op, FLAG_APPLIED); | | SET_FLAG(op, FLAG_APPLIED); |
if(!check_skill_to_apply(who,op)) return 1; | | if(!check_skill_to_apply(who,op)) return 1; |
#endif | | |
new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name(op)); | | new_draw_info_format (NDI_UNIQUE, 0, who, "You ready %s.", query_name(op)); |
if(who->type==PLAYER) { | | if(who->type==PLAYER) { |
switch (op->type) { | | switch (op->type) { |