… | |
… | |
72 | esrv_send_item (op->env, op); |
72 | esrv_send_item (op->env, op); |
73 | } |
73 | } |
74 | } |
74 | } |
75 | } |
75 | } |
76 | |
76 | |
77 | |
|
|
78 | |
|
|
79 | /* did_make_save_item just checks to make sure the item actually |
77 | /* did_make_save_item just checks to make sure the item actually |
80 | * made its saving throw based on the tables. It does not take |
78 | * made its saving throw based on the tables. It does not take |
81 | * any further action (like destroying the item). |
79 | * any further action (like destroying the item). |
82 | */ |
80 | */ |
83 | |
|
|
84 | int |
81 | int |
85 | did_make_save_item (object *op, int type, object *originator) |
82 | did_make_save_item (object *op, int type, object *originator) |
86 | { |
83 | { |
87 | int i, roll, saves = 0, attacks = 0, number; |
84 | int i, roll, saves = 0, attacks = 0, number; |
88 | materialtype_t *mt; |
85 | materialtype_t *mt; |
89 | |
86 | |
90 | if (op->materialname == NULL) |
87 | if (op->materialname == NULL) |
91 | { |
88 | { |
92 | for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) |
89 | for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) |
93 | { |
|
|
94 | if (op->material & mt->material) |
90 | if (op->material & mt->material) |
95 | break; |
91 | break; |
96 | } |
|
|
97 | } |
92 | } |
98 | else |
93 | else |
99 | mt = name_to_material (op->materialname); |
94 | mt = name_to_material (op->materialname); |
100 | if (mt == NULL) |
95 | if (mt == NULL) |
101 | return TRUE; |
96 | return TRUE; |
… | |
… | |
218 | |
213 | |
219 | if (tmp) |
214 | if (tmp) |
220 | esrv_del_item (tmp->contr, op->count); |
215 | esrv_del_item (tmp->contr, op->count); |
221 | } |
216 | } |
222 | |
217 | |
223 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
|
|
224 | op->remove (); |
|
|
225 | |
|
|
226 | op->destroy (0); |
218 | op->destroy (); |
227 | } |
219 | } |
228 | |
220 | |
229 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
221 | if (type & (AT_FIRE | AT_ELECTRICITY)) |
230 | if (env) |
222 | if (env) |
231 | { |
223 | { |
… | |
… | |
769 | * which then gets here again. By decreasing the speed before |
761 | * which then gets here again. By decreasing the speed before |
770 | * we call process_object, the 'if' statement above will fail. |
762 | * we call process_object, the 'if' statement above will fail. |
771 | */ |
763 | */ |
772 | op->speed_left--; |
764 | op->speed_left--; |
773 | process_object (op); |
765 | process_object (op); |
|
|
766 | |
774 | if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack)) |
767 | if (op->destroyed () || hitter->destroyed () || abort_attack (op, hitter, simple_attack)) |
775 | goto error; |
768 | goto error; |
776 | } |
769 | } |
777 | |
770 | |
778 | op_name = op->name; |
771 | op_name = op->name; |
… | |
… | |
830 | * when they hit the victim. For things like thrown daggers, |
823 | * when they hit the victim. For things like thrown daggers, |
831 | * this sets 'hitter' to the actual dagger, and not the |
824 | * this sets 'hitter' to the actual dagger, and not the |
832 | * wrapper object. |
825 | * wrapper object. |
833 | */ |
826 | */ |
834 | thrown_item_effect (hitter, op); |
827 | thrown_item_effect (hitter, op); |
|
|
828 | |
835 | if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) |
829 | if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) |
836 | goto leave; |
830 | goto leave; |
837 | } |
831 | } |
838 | |
832 | |
839 | /* Need to do at least 1 damage, otherwise there is no point |
833 | /* Need to do at least 1 damage, otherwise there is no point |
… | |
… | |
962 | if (hitter->destroyed () || hitter->env != NULL) |
956 | if (hitter->destroyed () || hitter->env != NULL) |
963 | { |
957 | { |
964 | if (container) |
958 | if (container) |
965 | { |
959 | { |
966 | container->remove (); |
960 | container->remove (); |
967 | container->destroy (0); |
961 | container->destroy (); |
968 | } |
962 | } |
969 | |
963 | |
970 | return 0; |
964 | return 0; |
971 | } |
965 | } |
972 | |
966 | |
… | |
… | |
982 | hitter = fix_stopped_arrow (hitter); |
976 | hitter = fix_stopped_arrow (hitter); |
983 | if (!hitter) |
977 | if (!hitter) |
984 | return 0; |
978 | return 0; |
985 | } |
979 | } |
986 | else |
980 | else |
987 | { |
|
|
988 | container->remove (); |
|
|
989 | container->destroy (0); |
981 | container->destroy (); |
990 | } |
|
|
991 | |
982 | |
992 | /* Try to stick arrow into victim */ |
983 | /* Try to stick arrow into victim */ |
993 | if (!victim->destroyed () && stick_arrow (hitter, victim)) |
984 | if (!victim->destroyed () && stick_arrow (hitter, victim)) |
994 | return 0; |
985 | return 0; |
995 | |
986 | |
… | |
… | |
1040 | } |
1031 | } |
1041 | else if (!GET_ANIM_ID (op)) |
1032 | else if (!GET_ANIM_ID (op)) |
1042 | { |
1033 | { |
1043 | /* Object has been called - no animations, so remove it */ |
1034 | /* Object has been called - no animations, so remove it */ |
1044 | if (op->stats.hp < 0) |
1035 | if (op->stats.hp < 0) |
1045 | { |
|
|
1046 | op->remove (); /* Should update LOS */ |
|
|
1047 | op->destroy (0); |
1036 | op->destroy (); |
1048 | /* Don't know why this is here - remove_ob should do it for us */ |
|
|
1049 | /*update_position(m, x, y); */ |
|
|
1050 | } |
1037 | |
1051 | return; /* no animations, so nothing more to do */ |
1038 | return; /* no animations, so nothing more to do */ |
1052 | } |
1039 | } |
|
|
1040 | |
1053 | perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp; |
1041 | perc = NUM_ANIMATIONS (op) - ((int) NUM_ANIMATIONS (op) * op->stats.hp) / op->stats.maxhp; |
|
|
1042 | |
1054 | if (perc >= (int) NUM_ANIMATIONS (op)) |
1043 | if (perc >= (int) NUM_ANIMATIONS (op)) |
1055 | perc = NUM_ANIMATIONS (op) - 1; |
1044 | perc = NUM_ANIMATIONS (op) - 1; |
1056 | else if (perc < 1) |
1045 | else if (perc < 1) |
1057 | perc = 1; |
1046 | perc = 1; |
|
|
1047 | |
1058 | SET_ANIMATION (op, perc); |
1048 | SET_ANIMATION (op, perc); |
1059 | update_object (op, UP_OBJ_FACE); |
1049 | update_object (op, UP_OBJ_FACE); |
|
|
1050 | |
1060 | if (perc == NUM_ANIMATIONS (op) - 1) |
1051 | if (perc == NUM_ANIMATIONS (op) - 1) |
1061 | { /* Reached the last animation */ |
1052 | { /* Reached the last animation */ |
1062 | if (op->face == blank_face) |
1053 | if (op->face == blank_face) |
1063 | { |
|
|
1064 | /* If the last face is blank, remove the ob */ |
1054 | /* If the last face is blank, remove the ob */ |
1065 | op->remove (); /* Should update LOS */ |
|
|
1066 | op->destroy (0); |
1055 | op->destroy (); |
1067 | |
|
|
1068 | /* remove_ob should call update_position for us */ |
|
|
1069 | /*update_position(m, x, y); */ |
|
|
1070 | |
|
|
1071 | } |
|
|
1072 | else |
1056 | else |
1073 | { /* The last face was not blank, leave an image */ |
1057 | { /* The last face was not blank, leave an image */ |
1074 | CLEAR_FLAG (op, FLAG_BLOCKSVIEW); |
1058 | CLEAR_FLAG (op, FLAG_BLOCKSVIEW); |
1075 | update_all_los (op->map, op->x, op->y); |
1059 | update_all_los (op->map, op->x, op->y); |
1076 | op->move_block = 0; |
1060 | op->move_block = 0; |
… | |
… | |
1454 | remove_friendly_object (op); |
1438 | remove_friendly_object (op); |
1455 | |
1439 | |
1456 | if (get_owner (op) && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op) |
1440 | if (get_owner (op) && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op) |
1457 | op->owner->contr->ranges[range_golem] = 0; |
1441 | op->owner->contr->ranges[range_golem] = 0; |
1458 | |
1442 | |
1459 | op->remove (); |
|
|
1460 | op->destroy (0); |
1443 | op->destroy (); |
1461 | return maxdam; |
1444 | return maxdam; |
1462 | } |
1445 | } |
1463 | |
1446 | |
1464 | /* Now lets start dealing with experience we get for killing something */ |
1447 | /* Now lets start dealing with experience we get for killing something */ |
1465 | |
1448 | |
… | |
… | |
1664 | } |
1647 | } |
1665 | |
1648 | |
1666 | remove_friendly_object (op); |
1649 | remove_friendly_object (op); |
1667 | } |
1650 | } |
1668 | |
1651 | |
1669 | op->remove (); |
|
|
1670 | op->destroy (0); |
1652 | op->destroy (); |
1671 | } |
1653 | } |
1672 | else |
1654 | else |
1673 | { |
1655 | { |
1674 | /* Player has been killed! */ |
1656 | /* Player has been killed! */ |
1675 | if (owner->type == PLAYER) |
1657 | if (owner->type == PLAYER) |
… | |
… | |
1787 | |
1769 | |
1788 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1770 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1789 | if (tmp->type == RUNE || tmp->type == TRAP) |
1771 | if (tmp->type == RUNE || tmp->type == TRAP) |
1790 | { |
1772 | { |
1791 | spring_trap (tmp, hitter); |
1773 | spring_trap (tmp, hitter); |
|
|
1774 | |
1792 | if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) |
1775 | if (hitter->destroyed () || op->destroyed () || abort_attack (op, hitter, simple_attack)) |
1793 | return 0; |
1776 | return 0; |
|
|
1777 | |
1794 | break; |
1778 | break; |
1795 | } |
1779 | } |
1796 | } |
1780 | } |
1797 | |
1781 | |
1798 | if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) |
1782 | if (!QUERY_FLAG (op, FLAG_ALIVE) || op->stats.hp < 0) |
… | |
… | |
1950 | |
1934 | |
1951 | if (QUERY_FLAG (op, FLAG_TEAR_DOWN)) |
1935 | if (QUERY_FLAG (op, FLAG_TEAR_DOWN)) |
1952 | { |
1936 | { |
1953 | if (maxdam) |
1937 | if (maxdam) |
1954 | tear_down_wall (op); |
1938 | tear_down_wall (op); |
|
|
1939 | |
1955 | return maxdam; /* nothing more to do for wall */ |
1940 | return maxdam; /* nothing more to do for wall */ |
1956 | } |
1941 | } |
1957 | |
1942 | |
1958 | /* See if the creature has been killed */ |
1943 | /* See if the creature has been killed */ |
1959 | rtn_kill = kill_object (op, maxdam, hitter, type); |
1944 | rtn_kill = kill_object (op, maxdam, hitter, type); |
… | |
… | |
1967 | */ |
1952 | */ |
1968 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1953 | if (QUERY_FLAG (hitter, FLAG_ONE_HIT)) |
1969 | { |
1954 | { |
1970 | if (QUERY_FLAG (hitter, FLAG_FRIENDLY)) |
1955 | if (QUERY_FLAG (hitter, FLAG_FRIENDLY)) |
1971 | remove_friendly_object (hitter); |
1956 | remove_friendly_object (hitter); |
1972 | hitter->remove (); |
1957 | |
1973 | hitter->destroy (0); |
1958 | hitter->destroy (); |
1974 | } |
1959 | } |
1975 | /* Lets handle creatures that are splitting now */ |
1960 | /* Lets handle creatures that are splitting now */ |
1976 | else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) |
1961 | else if (type & AT_PHYSICAL && !QUERY_FLAG (op, FLAG_FREED) && QUERY_FLAG (op, FLAG_SPLITTING)) |
1977 | { |
1962 | { |
1978 | int i; |
1963 | int i; |
… | |
… | |
1983 | if (!op->other_arch) |
1968 | if (!op->other_arch) |
1984 | { |
1969 | { |
1985 | LOG (llevError, "SPLITTING without other_arch error.\n"); |
1970 | LOG (llevError, "SPLITTING without other_arch error.\n"); |
1986 | return maxdam; |
1971 | return maxdam; |
1987 | } |
1972 | } |
|
|
1973 | |
1988 | op->remove (); |
1974 | op->remove (); |
|
|
1975 | |
1989 | for (i = 0; i < NROFNEWOBJS (op); i++) |
1976 | for (i = 0; i < NROFNEWOBJS (op); i++) |
1990 | { /* This doesn't handle op->more yet */ |
1977 | { /* This doesn't handle op->more yet */ |
1991 | object *tmp = arch_to_object (op->other_arch); |
1978 | object *tmp = arch_to_object (op->other_arch); |
1992 | int j; |
1979 | int j; |
1993 | |
1980 | |
1994 | tmp->stats.hp = op->stats.hp; |
1981 | tmp->stats.hp = op->stats.hp; |
|
|
1982 | |
1995 | if (friendly) |
1983 | if (friendly) |
1996 | { |
1984 | { |
1997 | SET_FLAG (tmp, FLAG_FRIENDLY); |
1985 | SET_FLAG (tmp, FLAG_FRIENDLY); |
1998 | add_friendly_object (tmp); |
1986 | add_friendly_object (tmp); |
1999 | tmp->attack_movement = PETMOVE; |
1987 | tmp->attack_movement = PETMOVE; |
2000 | if (owner != NULL) |
1988 | if (owner != NULL) |
2001 | set_owner (tmp, owner); |
1989 | set_owner (tmp, owner); |
2002 | } |
1990 | } |
|
|
1991 | |
2003 | if (unaggressive) |
1992 | if (unaggressive) |
2004 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
1993 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
|
|
1994 | |
2005 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
1995 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
|
|
1996 | |
2006 | if (j == -1) /* No spot to put this monster */ |
1997 | if (j == -1) /* No spot to put this monster */ |
2007 | tmp->destroy (0); |
1998 | tmp->destroy (); |
2008 | else |
1999 | else |
2009 | { |
2000 | { |
2010 | tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; |
2001 | tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; |
2011 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2002 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2012 | } |
2003 | } |
2013 | } |
2004 | } |
2014 | if (friendly) |
2005 | |
2015 | remove_friendly_object (op); |
|
|
2016 | op->destroy (0); |
2006 | op->destroy (); |
2017 | } |
2007 | } |
2018 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
2008 | else if (type & AT_DRAIN && hitter->type == GRIMREAPER && hitter->value++ > 10) |
2019 | { |
|
|
2020 | hitter->remove (); |
|
|
2021 | hitter->destroy (0); |
2009 | hitter->destroy (); |
2022 | } |
2010 | |
2023 | return maxdam; |
2011 | return maxdam; |
2024 | } |
2012 | } |
2025 | |
2013 | |
2026 | |
2014 | |
2027 | void |
2015 | void |