1 | /* |
1 | /* |
2 | * static char *rcsid_spell_attack_c = |
2 | * static char *rcsid_spell_attack_c = |
3 | * "$Id: spell_attack.C,v 1.6 2006/08/29 08:01:38 root Exp $"; |
3 | * "$Id: spell_attack.C,v 1.8 2006/09/07 10:01:58 pippijn Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
… | |
… | |
282 | return 0; |
282 | return 0; |
283 | |
283 | |
284 | /* peterm: level dependency for bolts */ |
284 | /* peterm: level dependency for bolts */ |
285 | tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust(caster,spob); |
285 | tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust(caster,spob); |
286 | tmp->attacktype = spob->attacktype; |
286 | tmp->attacktype = spob->attacktype; |
287 | if (spob->slaying) tmp->slaying = add_refcount(spob->slaying); |
287 | if (spob->slaying) tmp->slaying = spob->slaying; |
288 | tmp->range = spob->range + SP_level_range_adjust(caster,spob); |
288 | tmp->range = spob->range + SP_level_range_adjust(caster,spob); |
289 | tmp->duration = spob->duration + SP_level_duration_adjust(caster,spob); |
289 | tmp->duration = spob->duration + SP_level_duration_adjust(caster,spob); |
290 | tmp->stats.Dex = spob->stats.Dex; |
290 | tmp->stats.Dex = spob->stats.Dex; |
291 | tmp->stats.Con = spob->stats.Con; |
291 | tmp->stats.Con = spob->stats.Con; |
292 | |
292 | |
… | |
… | |
425 | |
425 | |
426 | /* other_arch contains what this explodes into */ |
426 | /* other_arch contains what this explodes into */ |
427 | tmp = arch_to_object (op->other_arch); |
427 | tmp = arch_to_object (op->other_arch); |
428 | |
428 | |
429 | copy_owner (tmp, op); |
429 | copy_owner (tmp, op); |
430 | if (tmp->skill) FREE_AND_CLEAR_STR(tmp->skill); |
430 | tmp->skill = op->skill; |
431 | if (op->skill) tmp->skill = add_refcount(op->skill); |
|
|
432 | |
431 | |
433 | owner = get_owner(op); |
432 | owner = get_owner(op); |
434 | if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && |
433 | if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && |
435 | !tailor_god_spell(tmp, owner)) { |
434 | !tailor_god_spell(tmp, owner)) { |
436 | remove_ob (op); |
435 | remove_ob (op); |
… | |
… | |
614 | return 0; |
613 | return 0; |
615 | |
614 | |
616 | /* peterm: level dependency for bolts */ |
615 | /* peterm: level dependency for bolts */ |
617 | tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust(caster,spob); |
616 | tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust(caster,spob); |
618 | tmp->attacktype = spob->attacktype; |
617 | tmp->attacktype = spob->attacktype; |
619 | if (spob->slaying) tmp->slaying = add_refcount(spob->slaying); |
618 | if (spob->slaying) tmp->slaying = spob->slaying; |
620 | |
619 | |
621 | tmp->range = 50; |
620 | tmp->range = 50; |
622 | |
621 | |
623 | /* Need to store duration/range for the ball to use */ |
622 | /* Need to store duration/range for the ball to use */ |
624 | tmp->stats.hp = spob->duration + SP_level_duration_adjust(caster,spob); |
623 | tmp->stats.hp = spob->duration + SP_level_duration_adjust(caster,spob); |
… | |
… | |
676 | new_ob->level = op->level; |
675 | new_ob->level = op->level; |
677 | set_owner(new_ob,op->owner); |
676 | set_owner(new_ob,op->owner); |
678 | |
677 | |
679 | /* preserve skill ownership */ |
678 | /* preserve skill ownership */ |
680 | if(op->skill && op->skill != new_ob->skill) { |
679 | if(op->skill && op->skill != new_ob->skill) { |
681 | if (new_ob->skill) free_string(new_ob->skill); |
|
|
682 | new_ob->skill = add_refcount(op->skill); |
680 | new_ob->skill = op->skill; |
683 | } |
681 | } |
684 | insert_ob_in_map(new_ob,op->map,op,0); |
682 | insert_ob_in_map(new_ob,op->map,op,0); |
685 | |
683 | |
686 | } |
684 | } |
687 | |
685 | |
… | |
… | |
692 | tag_t tag; |
690 | tag_t tag; |
693 | |
691 | |
694 | /* if no map then hit_map will crash so just ignore object */ |
692 | /* if no map then hit_map will crash so just ignore object */ |
695 | if (! op->map) { |
693 | if (! op->map) { |
696 | LOG(llevError,"Tried to move_cone object %s without a map.\n", |
694 | LOG(llevError,"Tried to move_cone object %s without a map.\n", |
697 | op->name ? op->name : "unknown"); |
695 | op->name ? &op->name : "unknown"); |
698 | op->speed = 0; |
696 | op->speed = 0; |
699 | update_ob_speed (op); |
697 | update_ob_speed (op); |
700 | return; |
698 | return; |
701 | } |
699 | } |
702 | |
700 | |
… | |
… | |
875 | } |
873 | } |
876 | |
874 | |
877 | |
875 | |
878 | if ( !(tmp->move_type & MOVE_FLY_LOW)) |
876 | if ( !(tmp->move_type & MOVE_FLY_LOW)) |
879 | LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", |
877 | LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", |
880 | spell->other_arch->name); |
878 | &spell->other_arch->name); |
881 | |
879 | |
882 | if (!tmp->move_on && tmp->stats.dam) { |
880 | if (!tmp->move_on && tmp->stats.dam) { |
883 | LOG (llevDebug, |
881 | LOG (llevDebug, |
884 | "cast_cone(): arch %s doesn't have move_on set\n", |
882 | "cast_cone(): arch %s doesn't have move_on set\n", |
885 | spell->other_arch->name); |
883 | &spell->other_arch->name); |
886 | } |
884 | } |
887 | insert_ob_in_map(tmp,m,op,0); |
885 | insert_ob_in_map(tmp,m,op,0); |
888 | |
886 | |
889 | /* This is used for tracking spells so that one effect doesn't hit |
887 | /* This is used for tracking spells so that one effect doesn't hit |
890 | * a single space too many times. |
888 | * a single space too many times. |
… | |
… | |
956 | tmp->stats.dam = op->stats.dam; |
954 | tmp->stats.dam = op->stats.dam; |
957 | tmp->duration = op->duration; |
955 | tmp->duration = op->duration; |
958 | tmp->attacktype = op->attacktype; |
956 | tmp->attacktype = op->attacktype; |
959 | copy_owner (tmp, op); |
957 | copy_owner (tmp, op); |
960 | if(op->skill && op->skill != tmp->skill) { |
958 | if(op->skill && op->skill != tmp->skill) { |
961 | if (tmp->skill) free_string(tmp->skill); |
|
|
962 | tmp->skill = add_refcount(op->skill); |
959 | tmp->skill = op->skill; |
963 | } |
960 | } |
964 | if(QUERY_FLAG(tmp, FLAG_IS_TURNABLE)) |
961 | if(QUERY_FLAG(tmp, FLAG_IS_TURNABLE)) |
965 | SET_ANIMATION(tmp, i); |
962 | SET_ANIMATION(tmp, i); |
966 | tmp->x = op->x + freearr_x[i]; |
963 | tmp->x = op->x + freearr_x[i]; |
967 | tmp->y = op->y + freearr_x[i]; |
964 | tmp->y = op->y + freearr_x[i]; |
… | |
… | |
1241 | if (tmp->glow_radius > op->glow_radius) |
1238 | if (tmp->glow_radius > op->glow_radius) |
1242 | op->glow_radius = tmp->glow_radius; |
1239 | op->glow_radius = tmp->glow_radius; |
1243 | |
1240 | |
1244 | if(!tmp->env||op!=tmp->env) { |
1241 | if(!tmp->env||op!=tmp->env) { |
1245 | LOG(llevError,"make_object_glow() failed to insert glowing force in %s\n", |
1242 | LOG(llevError,"make_object_glow() failed to insert glowing force in %s\n", |
1246 | op->name); |
1243 | &op->name); |
1247 | return 0; |
1244 | return 0; |
1248 | } |
1245 | } |
1249 | return 1; |
1246 | return 1; |
1250 | } |
1247 | } |
1251 | |
1248 | |
… | |
… | |
1345 | break; |
1342 | break; |
1346 | } |
1343 | } |
1347 | else if (spell_ob->race && spell_ob->race == force->name) { |
1344 | else if (spell_ob->race && spell_ob->race == force->name) { |
1348 | new_draw_info_format(NDI_UNIQUE, 0, op, |
1345 | new_draw_info_format(NDI_UNIQUE, 0, op, |
1349 | "You can not cast %s while %s is in effect", |
1346 | "You can not cast %s while %s is in effect", |
1350 | spell_ob->name, force->name_pl); |
1347 | &spell_ob->name, &force->name_pl); |
1351 | return 0; |
1348 | return 0; |
1352 | } |
1349 | } |
1353 | } |
1350 | } |
1354 | } |
1351 | } |
1355 | |
1352 | |
1356 | if(force==NULL) { |
1353 | if(force==NULL) { |
1357 | force=get_archetype(FORCE_NAME); |
1354 | force=get_archetype(FORCE_NAME); |
1358 | force->subtype = FORCE_CHANGE_ABILITY; |
1355 | force->subtype = FORCE_CHANGE_ABILITY; |
1359 | free_string(force->name); |
|
|
1360 | if (spell_ob->race) |
1356 | if (spell_ob->race) |
1361 | force->name = add_refcount(spell_ob->race); |
1357 | force->name = spell_ob->race; |
1362 | else |
1358 | else |
1363 | force->name = add_refcount(spell_ob->name); |
1359 | force->name = spell_ob->name; |
1364 | free_string(force->name_pl); |
1360 | |
1365 | force->name_pl = add_refcount(spell_ob->name); |
1361 | force->name_pl = spell_ob->name; |
1366 | |
1362 | |
1367 | } else { |
1363 | } else { |
1368 | int duration; |
1364 | int duration; |
1369 | |
1365 | |
1370 | duration = spell_ob->duration + SP_level_duration_adjust(caster, spell_ob) * 50; |
1366 | duration = spell_ob->duration + SP_level_duration_adjust(caster, spell_ob) * 50; |
… | |
… | |
1385 | if (spell_ob->last_grace) |
1381 | if (spell_ob->last_grace) |
1386 | force->path_repelled=god->path_repelled; |
1382 | force->path_repelled=god->path_repelled; |
1387 | if (spell_ob->last_grace) |
1383 | if (spell_ob->last_grace) |
1388 | force->path_denied=god->path_denied; |
1384 | force->path_denied=god->path_denied; |
1389 | new_draw_info_format(NDI_UNIQUE, 0,tmp, |
1385 | new_draw_info_format(NDI_UNIQUE, 0,tmp, |
1390 | "You are a victim of %s's curse!",god->name); |
1386 | "You are a victim of %s's curse!", &god->name); |
1391 | } else |
1387 | } else |
1392 | new_draw_info(NDI_UNIQUE, 0,op,"Your curse seems empty."); |
1388 | new_draw_info(NDI_UNIQUE, 0,op,"Your curse seems empty."); |
1393 | |
1389 | |
1394 | |
1390 | |
1395 | if(tmp!=op && op->type==PLAYER) |
1391 | if(tmp!=op && op->type==PLAYER) |
1396 | new_draw_info_format(NDI_UNIQUE, 0, op, "You curse %s!",tmp->name); |
1392 | new_draw_info_format(NDI_UNIQUE, 0, op, "You curse %s!", &tmp->name); |
1397 | |
1393 | |
1398 | force->stats.ac = spell_ob->stats.ac; |
1394 | force->stats.ac = spell_ob->stats.ac; |
1399 | force->stats.wc = spell_ob->stats.wc; |
1395 | force->stats.wc = spell_ob->stats.wc; |
1400 | |
1396 | |
1401 | change_abil(tmp,force); /* Mostly to display any messages */ |
1397 | change_abil(tmp,force); /* Mostly to display any messages */ |
… | |
… | |
1669 | * from a set of squares surrounding the caster, in a given direction. |
1665 | * from a set of squares surrounding the caster, in a given direction. |
1670 | */ |
1666 | */ |
1671 | |
1667 | |
1672 | void move_swarm_spell(object *op) |
1668 | void move_swarm_spell(object *op) |
1673 | { |
1669 | { |
|
|
1670 | #if 0 |
1674 | static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; |
1671 | static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; |
1675 | static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; |
1672 | static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; |
1676 | sint16 target_x, target_y, origin_x, origin_y; |
1673 | sint16 target_x, target_y, origin_x, origin_y; |
1677 | int basedir, adjustdir; |
1674 | int adjustdir; |
1678 | mapstruct *m; |
1675 | mapstruct *m; |
|
|
1676 | #endif |
|
|
1677 | int basedir; |
1679 | object *owner; |
1678 | object *owner; |
1680 | |
1679 | |
1681 | owner = get_owner(op); |
1680 | owner = get_owner(op); |
1682 | if(op->duration == 0 || owner == NULL) { |
1681 | if(op->duration == 0 || owner == NULL) { |
1683 | remove_ob(op); |
1682 | remove_ob(op); |
… | |
… | |
1963 | disease->stats.sp -= dam_mod; |
1962 | disease->stats.sp -= dam_mod; |
1964 | |
1963 | |
1965 | if(infect_object(walk,disease,1)) { |
1964 | if(infect_object(walk,disease,1)) { |
1966 | object *flash; /* visual effect for inflicting disease */ |
1965 | object *flash; /* visual effect for inflicting disease */ |
1967 | |
1966 | |
1968 | new_draw_info_format(NDI_UNIQUE, 0, op, "You inflict %s on %s!",disease->name,walk->name); |
1967 | new_draw_info_format(NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
1969 | |
1968 | |
1970 | free_object(disease); /* don't need this one anymore */ |
1969 | free_object(disease); /* don't need this one anymore */ |
1971 | flash=get_archetype(ARCH_DETECT_MAGIC); |
1970 | flash=get_archetype(ARCH_DETECT_MAGIC); |
1972 | flash->x = x; |
1971 | flash->x = x; |
1973 | flash->y = y; |
1972 | flash->y = y; |