1 | /* |
1 | /* |
2 | * static char *rcsid_skill_util_c = |
2 | * static char *rcsid_skill_util_c = |
3 | * "$Id: skill_util.c,v 1.1.1.3 2006/03/15 14:05:38 elmex Exp $"; |
3 | * "$Id: skill_util.c,v 1.8 2006/08/13 17:16:04 elmex dead $"; |
4 | */ |
4 | */ |
5 | /* |
5 | /* |
6 | CrossFire, A Multiplayer game for X-windows |
6 | CrossFire, A Multiplayer game for X-windows |
7 | |
7 | |
8 | Copryight (C) 2002 Mark Wedel & Crossfire Development Team |
8 | Copryight (C) 2002 Mark Wedel & Crossfire Development Team |
… | |
… | |
49 | #ifndef __CEXTRACT__ |
49 | #ifndef __CEXTRACT__ |
50 | #include <sproto.h> |
50 | #include <sproto.h> |
51 | #endif |
51 | #endif |
52 | #include <living.h> /* for defs of STR,CON,DEX,etc. -b.t.*/ |
52 | #include <living.h> /* for defs of STR,CON,DEX,etc. -b.t.*/ |
53 | #include <spells.h> |
53 | #include <spells.h> |
|
|
54 | |
|
|
55 | static int attack_hth(object *pl, int dir, const char *string, object *skill); |
|
|
56 | static int attack_melee_weapon(object *op, int dir, const char *string, object *skill); |
54 | |
57 | |
55 | const char *skill_names[NUM_SKILLS]; |
58 | const char *skill_names[NUM_SKILLS]; |
56 | |
59 | |
57 | /* init_skills basically just sets up the skill_names table |
60 | /* init_skills basically just sets up the skill_names table |
58 | * above. The index into the array is set up by the |
61 | * above. The index into the array is set up by the |
… | |
… | |
283 | * give any exp for their direct use (eg, throwing). |
286 | * give any exp for their direct use (eg, throwing). |
284 | * It returns 0 if no skill was used. |
287 | * It returns 0 if no skill was used. |
285 | */ |
288 | */ |
286 | |
289 | |
287 | int do_skill (object *op, object *part, object *skill, int dir, const char *string) { |
290 | int do_skill (object *op, object *part, object *skill, int dir, const char *string) { |
288 | int success=0, exp=0; |
291 | int success=0, exp=0, ev=0; |
289 | int did_alc = 0; |
292 | int did_alc = 0; |
290 | object *tmp, *next; |
293 | object *tmp, *next; |
291 | |
294 | |
292 | if (!skill) return 0; |
295 | if (!skill) return 0; |
293 | |
296 | |
… | |
… | |
301 | if (tmp->type == SKILL && tmp->skill == skill->skill) break; |
304 | if (tmp->type == SKILL && tmp->skill == skill->skill) break; |
302 | } |
305 | } |
303 | if (!tmp) tmp=give_skill_by_name(op, skill->skill); |
306 | if (!tmp) tmp=give_skill_by_name(op, skill->skill); |
304 | skill = tmp; |
307 | skill = tmp; |
305 | } |
308 | } |
|
|
309 | |
|
|
310 | // elmex: do a special case here. most times we only want to capture player skills? |
|
|
311 | if (op->type==PLAYER) |
|
|
312 | ev = execute_global_event(EVENT_PLAYER_USE_SKILL, op, part, skill, dir, string); |
|
|
313 | else |
|
|
314 | ev = execute_global_event(EVENT_MONSTER_USE_SKILL, op, part, skill, dir, string); |
|
|
315 | |
|
|
316 | if (ev) |
|
|
317 | return 0; |
306 | |
318 | |
307 | switch(skill->subtype) { |
319 | switch(skill->subtype) { |
308 | case SK_LEVITATION: |
320 | case SK_LEVITATION: |
309 | /* Not 100% sure if this will work with new movement code - |
321 | /* Not 100% sure if this will work with new movement code - |
310 | * the levitation skill has move_type for flying, so when |
322 | * the levitation skill has move_type for flying, so when |
… | |
… | |
358 | break; |
370 | break; |
359 | |
371 | |
360 | case SK_FLAME_TOUCH: |
372 | case SK_FLAME_TOUCH: |
361 | (void) attack_hth(op,dir,"flamed", skill); |
373 | (void) attack_hth(op,dir,"flamed", skill); |
362 | break; |
374 | break; |
|
|
375 | |
|
|
376 | case SK_SPARK_TOUCH: |
|
|
377 | (void) attack_hth(op,dir,"zapped", skill); |
|
|
378 | break; |
|
|
379 | |
|
|
380 | case SK_SHIVER: |
|
|
381 | (void) attack_hth(op,dir,"froze", skill); |
|
|
382 | break; |
|
|
383 | |
|
|
384 | case SK_ACID_SPLASH: |
|
|
385 | (void) attack_hth(op,dir,"dissolved", skill); |
|
|
386 | break; |
|
|
387 | |
|
|
388 | case SK_POISON_NAIL: |
|
|
389 | (void) attack_hth(op,dir,"injected poison into", skill); |
|
|
390 | break; |
363 | |
391 | |
364 | case SK_CLAWING: |
392 | case SK_CLAWING: |
365 | (void) attack_hth(op,dir,"clawed", skill); |
393 | (void) attack_hth(op,dir,"clawed", skill); |
366 | break; |
394 | break; |
367 | |
395 | |
… | |
… | |
718 | cp = determine_god(op); |
746 | cp = determine_god(op); |
719 | new_draw_info_format(NDI_UNIQUE, 0, op, |
747 | new_draw_info_format(NDI_UNIQUE, 0, op, |
720 | "You worship %s.", cp?cp:"no god at current time"); |
748 | "You worship %s.", cp?cp:"no god at current time"); |
721 | |
749 | |
722 | new_draw_info_format(NDI_UNIQUE,0,op, "Your equipped item power is %d out of %d\n", |
750 | new_draw_info_format(NDI_UNIQUE,0,op, "Your equipped item power is %d out of %d\n", |
723 | op->contr->item_power, op->level); |
751 | op->contr->item_power, (int) (op->level * settings.item_power_factor)); |
724 | } |
752 | } |
725 | |
753 | |
726 | /* use_skill() - similar to invoke command, it executes the skill in the |
754 | /* use_skill() - similar to invoke command, it executes the skill in the |
727 | * direction that the user is facing. Returns false if we are unable to |
755 | * direction that the user is facing. Returns false if we are unable to |
728 | * change to the requested skill, or were unable to use the skill properly. |
756 | * change to the requested skill, or were unable to use the skill properly. |
… | |
… | |
854 | break; |
882 | break; |
855 | } |
883 | } |
856 | } |
884 | } |
857 | /* If we didn't find a skill above, look harder for a good skill */ |
885 | /* If we didn't find a skill above, look harder for a good skill */ |
858 | if (!skill) { |
886 | if (!skill) { |
859 | skill = find_best_player_hth_skill(op); |
887 | skill = find_best_player_hth_skill(op); |
|
|
888 | // if ((skill = execute_global_event(EVENT_FIND_UNARMED_SKILL, op)) <= 0) { |
|
|
889 | // } |
860 | |
890 | |
861 | if (!skill) { |
891 | if (!skill) { |
862 | new_draw_info(NDI_BLACK, 0, op, "You have no unarmed combat skills!"); |
892 | new_draw_info(NDI_BLACK, 0, op, "You have no unarmed combat skills!"); |
863 | return 0; |
893 | return 0; |
864 | } |
894 | } |
… | |
… | |
990 | /* July 5, 1995 - I broke up attack_hth() into 2 parts. In the first |
1020 | /* July 5, 1995 - I broke up attack_hth() into 2 parts. In the first |
991 | * (attack_hth) we check for weapon use, etc in the second (the new |
1021 | * (attack_hth) we check for weapon use, etc in the second (the new |
992 | * function skill_attack() we actually attack. |
1022 | * function skill_attack() we actually attack. |
993 | */ |
1023 | */ |
994 | |
1024 | |
995 | int attack_hth(object *pl, int dir, const char *string, object *skill) { |
1025 | static int attack_hth(object *pl, int dir, const char *string, object *skill) { |
996 | object *enemy=NULL,*weapon; |
1026 | object *enemy=NULL,*weapon; |
997 | |
1027 | |
998 | if(QUERY_FLAG(pl, FLAG_READY_WEAPON)) |
1028 | if(QUERY_FLAG(pl, FLAG_READY_WEAPON)) |
999 | for(weapon=pl->inv;weapon;weapon=weapon->below) { |
1029 | for(weapon=pl->inv;weapon;weapon=weapon->below) { |
1000 | if (weapon->type==WEAPON && QUERY_FLAG(weapon, FLAG_APPLIED)) { |
1030 | if (weapon->type==WEAPON && QUERY_FLAG(weapon, FLAG_APPLIED)) { |
… | |
… | |
1020 | * we may make this routine handle 'special' melee weapons attacks |
1050 | * we may make this routine handle 'special' melee weapons attacks |
1021 | * (like disarming manuever with sai) based on player SK_level and |
1051 | * (like disarming manuever with sai) based on player SK_level and |
1022 | * weapon type. |
1052 | * weapon type. |
1023 | */ |
1053 | */ |
1024 | |
1054 | |
1025 | int attack_melee_weapon(object *op, int dir, const char *string, object *skill) { |
1055 | static int attack_melee_weapon(object *op, int dir, const char *string, object *skill) { |
1026 | |
1056 | |
1027 | if(!QUERY_FLAG(op, FLAG_READY_WEAPON)) { |
1057 | if(!QUERY_FLAG(op, FLAG_READY_WEAPON)) { |
1028 | if(op->type==PLAYER) |
1058 | if(op->type==PLAYER) |
1029 | new_draw_info(NDI_UNIQUE, 0,op,"You have no ready weapon to attack with!"); |
1059 | new_draw_info(NDI_UNIQUE, 0,op,"You have no ready weapon to attack with!"); |
1030 | return 0; |
1060 | return 0; |