… | |
… | |
610 | strcpy (buf1, "hit"); |
610 | strcpy (buf1, "hit"); |
611 | strcpy (buf2, " hits"); |
611 | strcpy (buf2, " hits"); |
612 | } |
612 | } |
613 | |
613 | |
614 | /* bail out if a monster is casting spells */ |
614 | /* bail out if a monster is casting spells */ |
615 | if (!(hitter->type == PLAYER || (get_owner (hitter) != NULL && hitter->owner->type == PLAYER))) |
615 | if (!(hitter->type == PLAYER || (hitter->owner != NULL && hitter->owner->type == PLAYER))) |
616 | return; |
616 | return; |
617 | |
617 | |
618 | /* scale down magic considerably. */ |
618 | /* scale down magic considerably. */ |
619 | if (type & AT_MAGIC && rndm (0, 5)) |
619 | if (type & AT_MAGIC && rndm (0, 5)) |
620 | return; |
620 | return; |
621 | |
621 | |
622 | /* Did a player hurt another player? Inform both! */ |
622 | /* Did a player hurt another player? Inform both! */ |
623 | if (op->type == PLAYER && (get_owner (hitter) == NULL ? hitter->type : hitter->owner->type) == PLAYER) |
623 | if (op->type == PLAYER && (hitter->owner == NULL ? hitter->type : hitter->owner->type) == PLAYER) |
624 | { |
624 | { |
625 | if (get_owner (hitter) != NULL) |
625 | if (hitter->owner != NULL) |
626 | sprintf (buf, "%s's %s%s you.", &hitter->owner->name, &hitter->name, buf2); |
626 | sprintf (buf, "%s's %s%s you.", &hitter->owner->name, &hitter->name, buf2); |
627 | else |
627 | else |
628 | { |
628 | { |
629 | sprintf (buf, "%s%s you.", &hitter->name, buf2); |
629 | sprintf (buf, "%s%s you.", &hitter->name, buf2); |
630 | if (dam != 0) |
630 | if (dam != 0) |
… | |
… | |
652 | else |
652 | else |
653 | play_sound_player_only (hitter->contr, SOUND_PLAYER_HITS3, 0, 0); |
653 | play_sound_player_only (hitter->contr, SOUND_PLAYER_HITS3, 0, 0); |
654 | } |
654 | } |
655 | new_draw_info (NDI_BLACK, 0, hitter, buf); |
655 | new_draw_info (NDI_BLACK, 0, hitter, buf); |
656 | } |
656 | } |
657 | else if (get_owner (hitter) != NULL && hitter->owner->type == PLAYER) |
657 | else if (hitter->owner != NULL && hitter->owner->type == PLAYER) |
658 | { |
658 | { |
659 | /* look for stacked spells and start reducing the message chances */ |
659 | /* look for stacked spells and start reducing the message chances */ |
660 | if (hitter->type == SPELL_EFFECT && (hitter->subtype == SP_EXPLOSION || hitter->subtype == SP_BULLET || hitter->subtype == SP_CONE)) |
660 | if (hitter->type == SPELL_EFFECT && (hitter->subtype == SP_EXPLOSION || hitter->subtype == SP_BULLET || hitter->subtype == SP_CONE)) |
661 | { |
661 | { |
662 | i = 4; |
662 | i = 4; |
… | |
… | |
806 | if (QUERY_FLAG (op, FLAG_SLEEP)) |
806 | if (QUERY_FLAG (op, FLAG_SLEEP)) |
807 | CLEAR_FLAG (op, FLAG_SLEEP); |
807 | CLEAR_FLAG (op, FLAG_SLEEP); |
808 | |
808 | |
809 | /* If the victim can't see the attacker, it may alert others |
809 | /* If the victim can't see the attacker, it may alert others |
810 | * for help. */ |
810 | * for help. */ |
811 | if (op->type != PLAYER && !can_see_enemy (op, hitter) && !get_owner (op) && rndm (0, op->stats.Int)) |
811 | if (op->type != PLAYER && !can_see_enemy (op, hitter) && !op->owner && rndm (0, op->stats.Int)) |
812 | npc_call_help (op); |
812 | npc_call_help (op); |
813 | |
813 | |
814 | /* if you were hidden and hit by a creature, you are discovered */ |
814 | /* if you were hidden and hit by a creature, you are discovered */ |
815 | if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE)) |
815 | if (op->hide && QUERY_FLAG (hitter, FLAG_ALIVE)) |
816 | { |
816 | { |
… | |
… | |
1064 | } |
1064 | } |
1065 | |
1065 | |
1066 | void |
1066 | void |
1067 | scare_creature (object *target, object *hitter) |
1067 | scare_creature (object *target, object *hitter) |
1068 | { |
1068 | { |
1069 | object *owner = get_owner (hitter); |
1069 | object *owner = hitter->owner; |
1070 | |
1070 | |
1071 | if (!owner) |
1071 | if (!owner) |
1072 | owner = hitter; |
1072 | owner = hitter; |
1073 | |
1073 | |
1074 | SET_FLAG (target, FLAG_SCARED); |
1074 | SET_FLAG (target, FLAG_SCARED); |
… | |
… | |
1278 | * Try to credit the owner. We try to display player -> player drain |
1278 | * Try to credit the owner. We try to display player -> player drain |
1279 | * attacks, hence all the != PLAYER checks. |
1279 | * attacks, hence all the != PLAYER checks. |
1280 | */ |
1280 | */ |
1281 | if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1281 | if (!op_on_battleground (hitter, NULL, NULL) && !QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1282 | { |
1282 | { |
1283 | object *owner = get_owner (hitter); |
1283 | object *owner = hitter->owner; |
1284 | |
1284 | |
1285 | if (owner && owner != hitter) |
1285 | if (owner && owner != hitter) |
1286 | { |
1286 | { |
1287 | if (op->type != PLAYER || owner->type != PLAYER) |
1287 | if (op->type != PLAYER || owner->type != PLAYER) |
1288 | change_exp (owner, op->stats.exp / (rate * 2), |
1288 | change_exp (owner, op->stats.exp / (rate * 2), |
… | |
… | |
1435 | |
1435 | |
1436 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1436 | if (QUERY_FLAG (op, FLAG_FRIENDLY) && op->type != PLAYER) |
1437 | { |
1437 | { |
1438 | remove_friendly_object (op); |
1438 | remove_friendly_object (op); |
1439 | |
1439 | |
1440 | if (get_owner (op) && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op) |
1440 | if (op->owner && op->owner->type == PLAYER && op->owner->contr->ranges[range_golem] == op) |
1441 | op->owner->contr->ranges[range_golem] = 0; |
1441 | op->owner->contr->ranges[range_golem] = 0; |
1442 | |
1442 | |
1443 | op->destroy (); |
1443 | op->destroy (); |
1444 | return maxdam; |
1444 | return maxdam; |
1445 | } |
1445 | } |
1446 | |
1446 | |
1447 | /* Now lets start dealing with experience we get for killing something */ |
1447 | /* Now lets start dealing with experience we get for killing something */ |
1448 | |
1448 | |
1449 | owner = get_owner (hitter); |
1449 | owner = hitter->owner; |
1450 | if (!owner) |
1450 | if (!owner) |
1451 | owner = hitter; |
1451 | owner = hitter; |
1452 | |
1452 | |
1453 | /* is the victim (op) standing on battleground? */ |
1453 | /* is the victim (op) standing on battleground? */ |
1454 | if (op_on_battleground (op, NULL, NULL)) |
1454 | if (op_on_battleground (op, NULL, NULL)) |
… | |
… | |
1635 | |
1635 | |
1636 | if (op->type != PLAYER) |
1636 | if (op->type != PLAYER) |
1637 | { |
1637 | { |
1638 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
1638 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
1639 | { |
1639 | { |
1640 | object *owner1 = get_owner (op); |
1640 | object *owner1 = op->owner; |
1641 | |
1641 | |
1642 | if (owner1 && owner1->type == PLAYER) |
1642 | if (owner1 && owner1->type == PLAYER) |
1643 | { |
1643 | { |
1644 | play_sound_player_only (owner1->contr, SOUND_PET_IS_KILLED, 0, 0); |
1644 | play_sound_player_only (owner1->contr, SOUND_PET_IS_KILLED, 0, 0); |
1645 | /* Maybe we should include the owner that killed this, maybe not */ |
1645 | /* Maybe we should include the owner that killed this, maybe not */ |
… | |
… | |
1687 | return 0; |
1687 | return 0; |
1688 | |
1688 | |
1689 | if (hitter->type == PLAYER && hitter->contr->peaceful == 1) |
1689 | if (hitter->type == PLAYER && hitter->contr->peaceful == 1) |
1690 | return 1; |
1690 | return 1; |
1691 | |
1691 | |
1692 | if ((owner = get_owner (hitter)) != NULL) |
1692 | if ((owner = hitter->owner) != NULL) |
1693 | { |
1693 | { |
1694 | if (owner->type == PLAYER && owner->contr->peaceful == 1) |
1694 | if (owner->type == PLAYER && owner->contr->peaceful == 1) |
1695 | friendlyfire = 2; |
1695 | friendlyfire = 2; |
1696 | } |
1696 | } |
1697 | |
1697 | |
… | |
… | |
1731 | return 0; |
1731 | return 0; |
1732 | |
1732 | |
1733 | #ifdef PROHIBIT_PLAYERKILL |
1733 | #ifdef PROHIBIT_PLAYERKILL |
1734 | if (op->type == PLAYER) |
1734 | if (op->type == PLAYER) |
1735 | { |
1735 | { |
1736 | object *owner = get_owner (hitter); |
1736 | object *owner = hitter->owner; |
1737 | |
1737 | |
1738 | if (!owner) |
1738 | if (!owner) |
1739 | owner = hitter; |
1739 | owner = hitter; |
1740 | |
1740 | |
1741 | if (owner->type == PLAYER && (!op_on_battleground (op, 0, 0) && (op->contr->peaceful || owner->contr->peaceful)) && op != owner) |
1741 | if (owner->type == PLAYER && (!op_on_battleground (op, 0, 0) && (op->contr->peaceful || owner->contr->peaceful)) && op != owner) |
… | |
… | |
1899 | |
1899 | |
1900 | #ifdef ATTACK_DEBUG |
1900 | #ifdef ATTACK_DEBUG |
1901 | LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam); |
1901 | LOG (llevDebug, "Attacktype %d did %d damage\n", type, maxdam); |
1902 | #endif |
1902 | #endif |
1903 | |
1903 | |
1904 | if (get_owner (hitter)) |
1904 | if (hitter->owner) |
1905 | op->enemy = hitter->owner; |
1905 | op->enemy = hitter->owner; |
1906 | else if (QUERY_FLAG (hitter, FLAG_ALIVE)) |
1906 | else if (QUERY_FLAG (hitter, FLAG_ALIVE)) |
1907 | op->enemy = hitter; |
1907 | op->enemy = hitter; |
1908 | |
1908 | |
1909 | if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER) |
1909 | if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE) && op->type != PLAYER) |
… | |
… | |
1961 | 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)) |
1962 | { |
1962 | { |
1963 | int i; |
1963 | int i; |
1964 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
1964 | int friendly = QUERY_FLAG (op, FLAG_FRIENDLY); |
1965 | int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE); |
1965 | int unaggressive = QUERY_FLAG (op, FLAG_UNAGGRESSIVE); |
1966 | object *owner = get_owner (op); |
1966 | object *owner = op->owner; |
1967 | |
1967 | |
1968 | if (!op->other_arch) |
1968 | if (!op->other_arch) |
1969 | { |
1969 | { |
1970 | LOG (llevError, "SPLITTING without other_arch error.\n"); |
1970 | LOG (llevError, "SPLITTING without other_arch error.\n"); |
1971 | return maxdam; |
1971 | return maxdam; |
… | |
… | |
1984 | { |
1984 | { |
1985 | SET_FLAG (tmp, FLAG_FRIENDLY); |
1985 | SET_FLAG (tmp, FLAG_FRIENDLY); |
1986 | add_friendly_object (tmp); |
1986 | add_friendly_object (tmp); |
1987 | tmp->attack_movement = PETMOVE; |
1987 | tmp->attack_movement = PETMOVE; |
1988 | if (owner != NULL) |
1988 | if (owner != NULL) |
1989 | set_owner (tmp, owner); |
1989 | tmp->set_owner (owner); |
1990 | } |
1990 | } |
1991 | |
1991 | |
1992 | if (unaggressive) |
1992 | if (unaggressive) |
1993 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
1993 | SET_FLAG (tmp, FLAG_UNAGGRESSIVE); |
1994 | |
1994 | |
… | |
… | |
2036 | if (QUERY_FLAG (hitter, FLAG_ALIVE)) |
2036 | if (QUERY_FLAG (hitter, FLAG_ALIVE)) |
2037 | tmp->stats.dam += hitter->level / 2; |
2037 | tmp->stats.dam += hitter->level / 2; |
2038 | else |
2038 | else |
2039 | tmp->stats.dam = dam; |
2039 | tmp->stats.dam = dam; |
2040 | |
2040 | |
2041 | copy_owner (tmp, hitter); /* so we get credit for poisoning kills */ |
2041 | tmp->set_owner (hitter); /* so we get credit for poisoning kills */ |
2042 | if (hitter->skill && hitter->skill != tmp->skill) |
2042 | if (hitter->skill && hitter->skill != tmp->skill) |
2043 | { |
2043 | { |
2044 | tmp->skill = hitter->skill; |
2044 | tmp->skill = hitter->skill; |
2045 | } |
2045 | } |
2046 | |
2046 | |
… | |
… | |
2057 | fix_player (op); |
2057 | fix_player (op); |
2058 | new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); |
2058 | new_draw_info (NDI_UNIQUE, 0, op, "You suddenly feel very ill."); |
2059 | } |
2059 | } |
2060 | if (hitter->type == PLAYER) |
2060 | if (hitter->type == PLAYER) |
2061 | new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); |
2061 | new_draw_info_format (NDI_UNIQUE, 0, hitter, "You poison %s.", &op->name); |
2062 | else if (get_owner (hitter) != NULL && hitter->owner->type == PLAYER) |
2062 | else if (hitter->owner != NULL && hitter->owner->type == PLAYER) |
2063 | new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name); |
2063 | new_draw_info_format (NDI_UNIQUE, 0, hitter->owner, "Your %s poisons %s.", &hitter->name, &op->name); |
2064 | } |
2064 | } |
2065 | tmp->speed_left = 0; |
2065 | tmp->speed_left = 0; |
2066 | } |
2066 | } |
2067 | else |
2067 | else |
… | |
… | |
2143 | tmp = insert_ob_in_ob (tmp, op); |
2143 | tmp = insert_ob_in_ob (tmp, op); |
2144 | change_abil (op, tmp); /* Mostly to display any messages */ |
2144 | change_abil (op, tmp); /* Mostly to display any messages */ |
2145 | fix_player (op); /* This takes care of some other stuff */ |
2145 | fix_player (op); /* This takes care of some other stuff */ |
2146 | |
2146 | |
2147 | if (hitter->owner) |
2147 | if (hitter->owner) |
2148 | owner = get_owner (hitter); |
2148 | owner = hitter->owner; |
2149 | else |
2149 | else |
2150 | owner = hitter; |
2150 | owner = hitter; |
2151 | |
2151 | |
2152 | new_draw_info_format (NDI_UNIQUE, 0, owner, "Your attack blinds %s!", query_name (op)); |
2152 | new_draw_info_format (NDI_UNIQUE, 0, owner, "Your attack blinds %s!", query_name (op)); |
2153 | } |
2153 | } |
… | |
… | |
2299 | } |
2299 | } |
2300 | |
2300 | |
2301 | /* aimed missiles use the owning object's sight */ |
2301 | /* aimed missiles use the owning object's sight */ |
2302 | if (is_aimed_missile (hitter)) |
2302 | if (is_aimed_missile (hitter)) |
2303 | { |
2303 | { |
2304 | if ((attacker = get_owner (hitter)) == NULL) |
2304 | if ((attacker = hitter->owner) == NULL) |
2305 | attacker = hitter; |
2305 | attacker = hitter; |
2306 | /* A player who saves but hasn't quit still could have objects |
2306 | /* A player who saves but hasn't quit still could have objects |
2307 | * owned by him - need to handle that case to avoid crashes. |
2307 | * owned by him - need to handle that case to avoid crashes. |
2308 | */ |
2308 | */ |
2309 | if (QUERY_FLAG (attacker, FLAG_REMOVED)) |
2309 | if (QUERY_FLAG (attacker, FLAG_REMOVED)) |