… | |
… | |
24 | #include <assert.h> |
24 | #include <assert.h> |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <living.h> |
26 | #include <living.h> |
27 | #include <material.h> |
27 | #include <material.h> |
28 | #include <skills.h> |
28 | #include <skills.h> |
29 | |
|
|
30 | #ifndef __CEXTRACT__ |
|
|
31 | # include <sproto.h> |
|
|
32 | #endif |
|
|
33 | |
|
|
34 | #include <sounds.h> |
29 | #include <sounds.h> |
|
|
30 | #include <sproto.h> |
35 | |
31 | |
36 | typedef struct att_msg_str |
32 | typedef struct att_msg_str |
37 | { |
33 | { |
38 | char *msg1; |
34 | char *msg1; |
39 | char *msg2; |
35 | char *msg2; |
… | |
… | |
654 | { |
650 | { |
655 | i = 4; |
651 | i = 4; |
656 | map = hitter->map; |
652 | map = hitter->map; |
657 | if (out_of_map (map, hitter->x, hitter->y)) |
653 | if (out_of_map (map, hitter->x, hitter->y)) |
658 | return; |
654 | return; |
|
|
655 | |
659 | next = GET_MAP_OB (map, hitter->x, hitter->y); |
656 | next = GET_MAP_OB (map, hitter->x, hitter->y); |
660 | if (next) |
657 | if (next) |
661 | while (next) |
658 | while (next) |
662 | { |
659 | { |
663 | if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE)) |
660 | if (next->type == SPELL_EFFECT && (next->subtype == SP_EXPLOSION || next->subtype == SP_BULLET || next->subtype == SP_CONE)) |
664 | i *= 3; |
661 | i *= 3; |
665 | tmp = next; |
662 | tmp = next; |
666 | next = tmp->above; |
663 | next = tmp->above; |
667 | } |
664 | } |
|
|
665 | |
668 | if (i < 0) |
666 | if (i < 0) |
669 | return; |
667 | return; |
|
|
668 | |
670 | if (rndm (0, i) != 0) |
669 | if (rndm (0, i) != 0) |
671 | return; |
670 | return; |
672 | } |
671 | } |
673 | else if (rndm (0, 5) != 0) |
672 | else if (rndm (0, 5) != 0) |
674 | return; |
673 | return; |
|
|
674 | |
675 | sprintf (buf, "Your %s%s %s.", &hitter->name, buf2, &op->name); |
675 | sprintf (buf, "Your %s%s %s.", &hitter->name, buf2, &op->name); |
676 | play_sound_map (op->map, op->x, op->y, SOUND_PLAYER_HITS4); |
676 | play_sound_map (op->map, op->x, op->y, SOUND_PLAYER_HITS4); |
677 | new_draw_info (NDI_BLACK, 0, hitter->owner, buf); |
677 | new_draw_info (NDI_BLACK, 0, hitter->owner, buf); |
678 | } |
678 | } |
679 | } |
679 | } |
… | |
… | |
1529 | skill = owner->current_weapon->skill; |
1529 | skill = owner->current_weapon->skill; |
1530 | else |
1530 | else |
1531 | LOG (llevError, "kill_object - unable to find skill that killed monster\n"); |
1531 | LOG (llevError, "kill_object - unable to find skill that killed monster\n"); |
1532 | |
1532 | |
1533 | /* We have the skill we want to credit to - now find the object this goes |
1533 | /* We have the skill we want to credit to - now find the object this goes |
1534 | * to. Make sure skop is an actual skill, and not a skill tool! |
1534 | * to. Make sure skop is an actual skill, and not a skill tool! |
1535 | */ |
1535 | */ |
1536 | if ((!skop || skop->type != SKILL) && skill) |
1536 | if ((!skop || skop->type != SKILL) && skill) |
1537 | { |
1537 | { |
1538 | int i; |
1538 | int i; |
1539 | |
1539 | |
… | |
… | |
1781 | if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) |
1781 | if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) |
1782 | { |
1782 | { |
1783 | /* FIXME: If a player is killed by a rune in a door, the |
1783 | /* FIXME: If a player is killed by a rune in a door, the |
1784 | * destroyed() check above doesn't return, and might get here. |
1784 | * destroyed() check above doesn't return, and might get here. |
1785 | */ |
1785 | */ |
|
|
1786 | |
|
|
1787 | /* FIXME: This for example happens when a dead door is on a mover and |
|
|
1788 | gets it's speed_left raised on each mover-tick. |
|
|
1789 | Doors are removed in a kinda funny way by giving them speed and speed_left |
|
|
1790 | and waiting for that to run out. |
|
|
1791 | */ |
1786 | LOG (llevDebug, "victim %s already dead in hit_player()\n", op->debug_desc ()); |
1792 | LOG (llevDebug, "victim %s (%d) already dead in hit_player()\n", op->debug_desc (), op->stats.hp); |
1787 | return 0; |
1793 | return 0; |
1788 | } |
1794 | } |
1789 | |
1795 | |
1790 | #ifdef ATTACK_DEBUG |
1796 | #ifdef ATTACK_DEBUG |
1791 | LOG (llevDebug, "hit player: attacktype %d, dam %d\n", type, dam); |
1797 | LOG (llevDebug, "hit player: attacktype %d, dam %d\n", type, dam); |
… | |
… | |
2189 | op->speed_left = (float) -(FABS (op->speed) * max); |
2195 | op->speed_left = (float) -(FABS (op->speed) * max); |
2190 | |
2196 | |
2191 | /* tmp->stats.food = (signed short) (max/FABS(op->speed)); */ |
2197 | /* tmp->stats.food = (signed short) (max/FABS(op->speed)); */ |
2192 | } |
2198 | } |
2193 | |
2199 | |
2194 | |
|
|
2195 | /* Attempts to kill 'op'. hitter is the attack object, dam is |
2200 | /* Attempts to kill 'op'. hitter is the attack object, dam is |
2196 | * the computed damaged. |
2201 | * the computed damaged. |
2197 | */ |
2202 | */ |
2198 | void |
2203 | void |
2199 | deathstrike_player (object *op, object *hitter, int *dam) |
2204 | deathstrike_player (object *op, object *hitter, int *dam) |
… | |
… | |
2216 | if (def_lev < 1) |
2221 | if (def_lev < 1) |
2217 | { |
2222 | { |
2218 | LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->name, &op->name); |
2223 | LOG (llevError, "BUG: arch %s, name %s with level < 1\n", &op->arch->name, &op->name); |
2219 | def_lev = 1; |
2224 | def_lev = 1; |
2220 | } |
2225 | } |
|
|
2226 | |
2221 | atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; |
2227 | atk_lev = (hitter->chosen_skill ? hitter->chosen_skill->level : hitter->level) / 2; |
2222 | /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", |
2228 | /* LOG(llevDebug,"Deathstrike - attack level %d, defender level %d\n", |
2223 | atk_lev, def_lev); */ |
2229 | atk_lev, def_lev); */ |
2224 | |
2230 | |
2225 | if (atk_lev >= def_lev) |
2231 | if (atk_lev >= def_lev) |
… | |
… | |
2240 | */ |
2246 | */ |
2241 | *dam *= kill_lev / def_lev; |
2247 | *dam *= kill_lev / def_lev; |
2242 | } |
2248 | } |
2243 | } |
2249 | } |
2244 | else |
2250 | else |
2245 | { |
|
|
2246 | *dam = 0; /* no harm done */ |
2251 | *dam = 0; /* no harm done */ |
2247 | } |
|
|
2248 | } |
2252 | } |
2249 | |
2253 | |
2250 | /* thrown_item_effect() - handles any special effects of thrown |
2254 | /* thrown_item_effect() - handles any special effects of thrown |
2251 | * items (like attacking living creatures--a potion thrown at a |
2255 | * items (like attacking living creatures--a potion thrown at a |
2252 | * monster). |
2256 | * monster). |
… | |
… | |
2356 | #endif |
2360 | #endif |
2357 | |
2361 | |
2358 | return adjust; |
2362 | return adjust; |
2359 | } |
2363 | } |
2360 | |
2364 | |
2361 | |
|
|
2362 | /* determine if the object is an 'aimed' missile */ |
2365 | /* determine if the object is an 'aimed' missile */ |
2363 | int |
2366 | int |
2364 | is_aimed_missile (object *op) |
2367 | is_aimed_missile (object *op) |
2365 | { |
2368 | { |
2366 | |
2369 | |
… | |
… | |
2372 | if (op->type == ARROW || op->type == THROWN_OBJ) |
2375 | if (op->type == ARROW || op->type == THROWN_OBJ) |
2373 | return 1; |
2376 | return 1; |
2374 | else if (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_EXPLOSION)) |
2377 | else if (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_EXPLOSION)) |
2375 | return 1; |
2378 | return 1; |
2376 | } |
2379 | } |
|
|
2380 | |
2377 | return 0; |
2381 | return 0; |
2378 | } |
2382 | } |