ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/skill_util.c
(Generate patch)

Comparing deliantra/server/server/skill_util.c (file contents):
Revision 1.2 by pippijn, Sat Apr 29 13:44:15 2006 UTC vs.
Revision 1.6 by elmex, Sat Jul 15 11:57:02 2006 UTC

1/* 1/*
2 * static char *rcsid_skill_util_c = 2 * static char *rcsid_skill_util_c =
3 * "$Id: skill_util.c,v 1.2 2006/04/29 13:44:15 pippijn Exp $"; 3 * "$Id: skill_util.c,v 1.6 2006/07/15 11:57:02 elmex Exp $";
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
55static int attack_hth(object *pl, int dir, const char *string, object *skill);
56static int attack_melee_weapon(object *op, int dir, const char *string, object *skill);
54 57
55const char *skill_names[NUM_SKILLS]; 58const 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
287int do_skill (object *op, object *part, object *skill, int dir, const char *string) { 290int 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
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 skill = find_best_player_hth_skill(op);
890 }
860 891
861 if (!skill) { 892 if (!skill) {
862 new_draw_info(NDI_BLACK, 0, op, "You have no unarmed combat skills!"); 893 new_draw_info(NDI_BLACK, 0, op, "You have no unarmed combat skills!");
863 return 0; 894 return 0;
864 } 895 }
990/* July 5, 1995 - I broke up attack_hth() into 2 parts. In the first 1021/* 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 1022 * (attack_hth) we check for weapon use, etc in the second (the new
992 * function skill_attack() we actually attack. 1023 * function skill_attack() we actually attack.
993 */ 1024 */
994 1025
995int attack_hth(object *pl, int dir, const char *string, object *skill) { 1026static int attack_hth(object *pl, int dir, const char *string, object *skill) {
996 object *enemy=NULL,*weapon; 1027 object *enemy=NULL,*weapon;
997 1028
998 if(QUERY_FLAG(pl, FLAG_READY_WEAPON)) 1029 if(QUERY_FLAG(pl, FLAG_READY_WEAPON))
999 for(weapon=pl->inv;weapon;weapon=weapon->below) { 1030 for(weapon=pl->inv;weapon;weapon=weapon->below) {
1000 if (weapon->type==WEAPON && QUERY_FLAG(weapon, FLAG_APPLIED)) { 1031 if (weapon->type==WEAPON && QUERY_FLAG(weapon, FLAG_APPLIED)) {
1020 * we may make this routine handle 'special' melee weapons attacks 1051 * we may make this routine handle 'special' melee weapons attacks
1021 * (like disarming manuever with sai) based on player SK_level and 1052 * (like disarming manuever with sai) based on player SK_level and
1022 * weapon type. 1053 * weapon type.
1023 */ 1054 */
1024 1055
1025int attack_melee_weapon(object *op, int dir, const char *string, object *skill) { 1056static int attack_melee_weapon(object *op, int dir, const char *string, object *skill) {
1026 1057
1027 if(!QUERY_FLAG(op, FLAG_READY_WEAPON)) { 1058 if(!QUERY_FLAG(op, FLAG_READY_WEAPON)) {
1028 if(op->type==PLAYER) 1059 if(op->type==PLAYER)
1029 new_draw_info(NDI_UNIQUE, 0,op,"You have no ready weapon to attack with!"); 1060 new_draw_info(NDI_UNIQUE, 0,op,"You have no ready weapon to attack with!");
1030 return 0; 1061 return 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines