version 1.33 | | version 1.34 |
---|
| | |
/* | | /* |
* static char *rcsid_skill_util_c = | | * static char *rcsid_skill_util_c = |
* "$Id: skill_util.c,v 1.33 2002/11/26 08:37:11 garbled Exp $"; | | * "$Id: skill_util.c,v 1.34 2002/12/03 07:40:18 mwedel Exp $"; |
*/ | | */ |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
/* 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 |
* to utilize skills. Success should be the amount of experience gained | | * to utilize skills. Returns 1 on use of skill, otherwise 0. |
* from the activity. Also, any skills that monster will use, will need | | * This is changed (2002-11-30) from the old method that returned |
* to return a positive value of success if performed correctly. Usually | | * exp - no caller needed that info, but it also prevented the callers |
* this is handled in calc_skill_exp(). Thus failed skill use re- | | * from know if a skill was actually used, as many skills don't |
* sults in a 0, or false value of 'success'. | | * give any exp for their direct use (eg, throwing). |
* - b.t. thomas@astro.psu.edu | | * It returns 0 if no skill was used. |
*/ | | */ |
| | |
int do_skill (object *op, int dir, char *string) { | | int do_skill (object *op, object *part, int dir, char *string) { |
int success=0; /* needed for monster_skill_use() too */ | | int success=0, exp=0; |
int skill = op->chosen_skill->stats.sp; | | int skill = op->chosen_skill->stats.sp; |
int did_alc = 0; | | int did_alc = 0; |
int x, y; | | int x, y; |
| | |
SET_FLAG(op,FLAG_FLYING); | | SET_FLAG(op,FLAG_FLYING); |
new_draw_info(NDI_UNIQUE,0,op,"You rise into the air!."); | | new_draw_info(NDI_UNIQUE,0,op,"You rise into the air!."); |
} | | } |
| | success=1; |
break; | | break; |
| | |
case SK_STEALING: | | case SK_STEALING: |
success = steal(op, dir); | | exp = success = steal(op, dir); |
break; | | break; |
| | |
case SK_LOCKPICKING: | | case SK_LOCKPICKING: |
success = pick_lock(op, dir); | | exp = success = pick_lock(op, dir); |
break; | | break; |
| | |
case SK_HIDING: | | case SK_HIDING: |
success = hide(op); | | exp = success = hide(op); |
break; | | break; |
| | |
case SK_JUMPING: | | case SK_JUMPING: |
success = jump(op, dir); | | success = jump(op, dir); |
break; | | break; |
| | |
case SK_INSCRIPTION: | | case SK_INSCRIPTION: |
success = write_on_item(op,string); | | exp = success = write_on_item(op,string); |
break; | | break; |
| | |
case SK_MEDITATION: | | case SK_MEDITATION: |
meditate(op); | | meditate(op); |
| | success=1; |
break; | | break; |
/* note that the following 'attack' skills gain exp through hit_player() */ | | /* note that the following 'attack' skills gain exp through hit_player() */ |
| | |
case SK_KARATE: | | case SK_KARATE: |
(void) attack_hth(op,dir,"karate-chopped"); | | (void) attack_hth(op,dir,"karate-chopped"); |
break; | | break; |
| | |
case SK_BOXING: | | case SK_BOXING: |
(void) attack_hth(op,dir,"punched"); | | (void) attack_hth(op,dir,"punched"); |
break; | | break; |
| | |
case SK_FLAME_TOUCH: | | case SK_FLAME_TOUCH: |
(void) attack_hth(op,dir,"flamed"); | | (void) attack_hth(op,dir,"flamed"); |
break; | | break; |
| | |
case SK_CLAWING: | | case SK_CLAWING: |
(void) attack_hth(op,dir,"clawed"); | | (void) attack_hth(op,dir,"clawed"); |
break; | | break; |
| | |
case SK_MELEE_WEAPON: | | case SK_MELEE_WEAPON: |
(void) attack_melee_weapon(op,dir,NULL); | | (void) attack_melee_weapon(op,dir,NULL); |
break; | | break; |
| | |
case SK_FIND_TRAPS: | | case SK_FIND_TRAPS: |
success = find_traps(op); | | exp = success = find_traps(op); |
break; | | break; |
| | |
case SK_MUSIC: | | case SK_MUSIC: |
success = singing(op,dir); | | exp = success = singing(op,dir); |
break; | | break; |
| | |
case SK_ORATORY: | | case SK_ORATORY: |
success = use_oratory(op,dir); | | exp = success = use_oratory(op,dir); |
break; | | break; |
| | |
case SK_SMITH: | | case SK_SMITH: |
case SK_BOWYER: | | case SK_BOWYER: |
case SK_JEWELER: | | case SK_JEWELER: |
| | |
case SK_LITERACY: | | case SK_LITERACY: |
case SK_WOODSMAN: | | case SK_WOODSMAN: |
/* first, we try to find a cauldron, and do the alchemy thing. | | /* first, we try to find a cauldron, and do the alchemy thing. |
failing that, we go and identify stuff. */ | | * failing that, we go and identify stuff. |
| | */ |
for (y=op->y-1; y <= op->y+1; y++) { | | for (y=op->y-1; y <= op->y+1; y++) { |
for (x=op->x-1; x <= op->x+1; x++) { | | for (x=op->x-1; x <= op->x+1; x++) { |
if (out_of_map(op->map, x, y) || wall(op->map, x, y) || | | if (out_of_map(op->map, x, y) || wall(op->map, x, y) || |
| | |
} | | } |
} | | } |
if (did_alc == 0) | | if (did_alc == 0) |
success = skill_ident(op); | | exp = success = skill_ident(op); |
break; | | break; |
| | |
case SK_DET_MAGIC: | | case SK_DET_MAGIC: |
case SK_DET_CURSE: | | case SK_DET_CURSE: |
success = skill_ident(op); | | exp = success = skill_ident(op); |
break; | | break; |
| | |
case SK_REMOVE_TRAP: | | case SK_REMOVE_TRAP: |
success = remove_trap(op,dir); | | exp = success = remove_trap(op,dir); |
break; | | break; |
| | |
case SK_THROWING: | | case SK_THROWING: |
success = skill_throw(op,dir,string); | | success = skill_throw(op,part,dir,string); |
break; | | break; |
| | |
case SK_SET_TRAP: | | case SK_SET_TRAP: |
new_draw_info(NDI_UNIQUE, 0,op,"This skill is not currently implemented."); | | new_draw_info(NDI_UNIQUE, 0,op,"This skill is not currently implemented."); |
break; | | break; |
| | |
case SK_USE_MAGIC_ITEM: | | case SK_USE_MAGIC_ITEM: |
case SK_MISSILE_WEAPON: | | case SK_MISSILE_WEAPON: |
new_draw_info(NDI_UNIQUE, 0,op,"There is no special attack for this skill."); | | new_draw_info(NDI_UNIQUE, 0,op,"There is no special attack for this skill."); |
break; | | break; |
| | |
case SK_PRAYING: | | case SK_PRAYING: |
success = pray(op); | | success = pray(op); |
break; | | break; |
| | |
case SK_SPELL_CASTING: | | case SK_SPELL_CASTING: |
case SK_CLIMBING: | | case SK_CLIMBING: |
case SK_BARGAINING: | | case SK_BARGAINING: |
new_draw_info(NDI_UNIQUE, 0,op,"This skill is already in effect."); | | new_draw_info(NDI_UNIQUE, 0,op,"This skill is already in effect."); |
break; | | break; |
| | |
default: | | default: |
LOG(llevDebug,"%s attempted to use unknown skill: %d\n" | | LOG(llevDebug,"%s attempted to use unknown skill: %d\n" |
,query_name(op), op->chosen_skill->stats.sp); | | ,query_name(op), op->chosen_skill->stats.sp); |
| | |
* gain problems. | | * gain problems. |
*/ | | */ |
| | |
if(success&&skills[skill].category!=EXP_NONE) add_exp(op,success); | | if(success&&skills[skill].category!=EXP_NONE) add_exp(op,exp); |
| | |
return success; | | return success; |
} | | } |
| | |
| | |
/* Change to the new skill, then execute it. */ | | /* Change to the new skill, then execute it. */ |
if(change_skill(op,sknum)) | | if(change_skill(op,sknum)) |
if(do_skill(op,op->facing,string)) return 1; | | if(do_skill(op,op,op->facing,string)) return 1; |
| | |
return 0; | | return 0; |
} | | } |