… | |
… | |
54 | |
54 | |
55 | players.insert (this); |
55 | players.insert (this); |
56 | ob->remove (); |
56 | ob->remove (); |
57 | ob->map = 0; |
57 | ob->map = 0; |
58 | ob->activate_recursive (); |
58 | ob->activate_recursive (); |
59 | CLEAR_FLAG (ob, FLAG_FRIENDLY); |
59 | ob->clr_flag (FLAG_FRIENDLY); |
60 | add_friendly_object (ob); |
60 | add_friendly_object (ob); |
61 | } |
61 | } |
62 | |
62 | |
63 | void |
63 | void |
64 | player::deactivate () |
64 | player::deactivate () |
… | |
… | |
519 | next = op->below; |
519 | next = op->below; |
520 | |
520 | |
521 | /* Forces get applied per default, unless they have the |
521 | /* Forces get applied per default, unless they have the |
522 | * flag "neutral" set. Sorry but I can't think of a better way |
522 | * flag "neutral" set. Sorry but I can't think of a better way |
523 | */ |
523 | */ |
524 | if (op->type == FORCE && !QUERY_FLAG (op, FLAG_NEUTRAL)) |
524 | if (op->type == FORCE && !op->flag [FLAG_NEUTRAL]) |
525 | SET_FLAG (op, FLAG_APPLIED); |
525 | op->set_flag (FLAG_APPLIED); |
526 | |
526 | |
527 | /* we never give weapons/armour if these cannot be used |
527 | /* we never give weapons/armour if these cannot be used |
528 | * by this player due to race restrictions |
528 | * by this player due to race restrictions |
529 | */ |
529 | */ |
530 | if (pl->type == PLAYER) |
530 | if (pl->type == PLAYER) |
531 | { |
531 | { |
532 | if ((!QUERY_FLAG (pl, FLAG_USE_ARMOUR) |
532 | if ((!pl->flag [FLAG_USE_ARMOUR] |
533 | && |
533 | && |
534 | (op->type == ARMOUR || op->type == BOOTS |
534 | (op->type == ARMOUR || op->type == BOOTS |
535 | || op->type == CLOAK || op->type == HELMET |
535 | || op->type == CLOAK || op->type == HELMET |
536 | || op->type == SHIELD || op->type == GLOVES |
536 | || op->type == SHIELD || op->type == GLOVES |
537 | || op->type == BRACERS || op->type == GIRDLE)) |
537 | || op->type == BRACERS || op->type == GIRDLE)) |
538 | || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
538 | || (!pl->flag [FLAG_USE_WEAPON] && op->type == WEAPON)) |
539 | { |
539 | { |
540 | op->destroy (); |
540 | op->destroy (); |
541 | continue; |
541 | continue; |
542 | } |
542 | } |
543 | } |
543 | } |
… | |
… | |
560 | if (op->nrof > 1) |
560 | if (op->nrof > 1) |
561 | op->nrof = 1; |
561 | op->nrof = 1; |
562 | } |
562 | } |
563 | |
563 | |
564 | if (op->type == SPELLBOOK && op->inv) |
564 | if (op->type == SPELLBOOK && op->inv) |
565 | CLEAR_FLAG (op->inv, FLAG_STARTEQUIP); |
565 | op->inv->clr_flag (FLAG_STARTEQUIP); |
566 | |
566 | |
567 | /* Give starting characters identified, uncursed, and undamned |
567 | /* Give starting characters identified, uncursed, and undamned |
568 | * items. Just don't identify gold or silver, or it won't be |
568 | * items. Just don't identify gold or silver, or it won't be |
569 | * merged properly. |
569 | * merged properly. |
570 | */ |
570 | */ |
571 | if (need_identify (op)) |
571 | if (need_identify (op)) |
572 | { |
572 | { |
573 | SET_FLAG (op, FLAG_IDENTIFIED); |
573 | op->set_flag (FLAG_IDENTIFIED); |
574 | CLEAR_FLAG (op, FLAG_CURSED); |
574 | op->clr_flag (FLAG_CURSED); |
575 | CLEAR_FLAG (op, FLAG_DAMNED); |
575 | op->clr_flag (FLAG_DAMNED); |
576 | } |
576 | } |
577 | |
577 | |
578 | if (op->type == SPELL) |
578 | if (op->type == SPELL) |
579 | { |
579 | { |
580 | op->destroy (); |
580 | op->destroy (); |
581 | continue; |
581 | continue; |
582 | } |
582 | } |
583 | else if (op->type == SKILL) |
583 | else if (op->type == SKILL) |
584 | { |
584 | { |
585 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
585 | op->set_flag (FLAG_CAN_USE_SKILL); |
586 | op->stats.exp = 0; |
586 | op->stats.exp = 0; |
587 | op->level = 1; |
587 | op->level = 1; |
588 | } |
588 | } |
589 | else /* lock all 'normal items by default */ |
589 | else /* lock all 'normal items by default */ |
590 | SET_FLAG (op, FLAG_INV_LOCKED); |
590 | op->set_flag (FLAG_INV_LOCKED); |
591 | } /* for loop of objects in player inv */ |
591 | } /* for loop of objects in player inv */ |
592 | |
592 | |
593 | /* Need to set up the skill pointers */ |
593 | /* Need to set up the skill pointers */ |
594 | pl->contr->link_skills (); |
594 | pl->contr->link_skills (); |
595 | } |
595 | } |
… | |
… | |
729 | |
729 | |
730 | if (ob->msg) |
730 | if (ob->msg) |
731 | ob->msg = 0; |
731 | ob->msg = 0; |
732 | |
732 | |
733 | start_info (ob); |
733 | start_info (ob); |
734 | CLEAR_FLAG (ob, FLAG_WIZ); |
734 | ob->clr_flag (FLAG_WIZ); |
735 | give_initial_items (ob, ob->randomitems); |
735 | give_initial_items (ob, ob->randomitems); |
736 | esrv_send_inventory (ob, ob); |
736 | esrv_send_inventory (ob, ob); |
737 | ob->update_stats (); |
737 | ob->update_stats (); |
738 | |
738 | |
739 | /* This moves the player to a different start map, if there |
739 | /* This moves the player to a different start map, if there |
… | |
… | |
788 | rv_vector rv; |
788 | rv_vector rv; |
789 | |
789 | |
790 | if (op->stats.hp < 0) |
790 | if (op->stats.hp < 0) |
791 | { |
791 | { |
792 | LOG (llevDebug, "Fleeing player is dead.\n"); |
792 | LOG (llevDebug, "Fleeing player is dead.\n"); |
793 | CLEAR_FLAG (op, FLAG_SCARED); |
793 | op->clr_flag (FLAG_SCARED); |
794 | return; |
794 | return; |
795 | } |
795 | } |
796 | |
796 | |
797 | if (!op->enemy) |
797 | if (!op->enemy) |
798 | { |
798 | { |
799 | LOG (llevDebug, "Fleeing player had no enemy.\n"); |
799 | LOG (llevDebug, "Fleeing player had no enemy.\n"); |
800 | CLEAR_FLAG (op, FLAG_SCARED); |
800 | op->clr_flag (FLAG_SCARED); |
801 | return; |
801 | return; |
802 | } |
802 | } |
803 | |
803 | |
804 | if (!(random_roll (0, 4, op, PREFER_LOW)) && did_make_save (op, op->level, 0)) |
804 | if (!(random_roll (0, 4, op, PREFER_LOW)) && did_make_save (op, op->level, 0)) |
805 | { |
805 | { |
806 | op->enemy = NULL; |
806 | op->enemy = NULL; |
807 | CLEAR_FLAG (op, FLAG_SCARED); |
807 | op->clr_flag (FLAG_SCARED); |
808 | return; |
808 | return; |
809 | } |
809 | } |
810 | |
810 | |
811 | get_rangevector (op, op->enemy, &rv, 0); |
811 | get_rangevector (op, op->enemy, &rv, 0); |
812 | |
812 | |
… | |
… | |
818 | if (op->move (absdir (dir + diff * m)) || (diff == 0 && op->move (absdir (dir - diff * m)))) |
818 | if (op->move (absdir (dir + diff * m)) || (diff == 0 && op->move (absdir (dir - diff * m)))) |
819 | return; |
819 | return; |
820 | } |
820 | } |
821 | |
821 | |
822 | /* Cornered, get rid of scared */ |
822 | /* Cornered, get rid of scared */ |
823 | CLEAR_FLAG (op, FLAG_SCARED); |
823 | op->clr_flag (FLAG_SCARED); |
824 | op->enemy = NULL; |
824 | op->enemy = NULL; |
825 | } |
825 | } |
826 | |
826 | |
827 | /* check_pick sees if there is stuff to be picked up/picks up stuff. |
827 | /* check_pick sees if there is stuff to be picked up/picks up stuff. |
828 | * It returns 1 if the player should keep on moving, 0 if he should |
828 | * It returns 1 if the player should keep on moving, 0 if he should |
… | |
… | |
920 | * fighting */ |
920 | * fighting */ |
921 | if (op->contr->mode & PU_INHIBIT) |
921 | if (op->contr->mode & PU_INHIBIT) |
922 | return 1; |
922 | return 1; |
923 | |
923 | |
924 | /* prevent us from turning into auto-thieves :) */ |
924 | /* prevent us from turning into auto-thieves :) */ |
925 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
925 | if (tmp->flag [FLAG_UNPAID]) |
926 | continue; |
926 | continue; |
927 | |
927 | |
928 | /* ignore known cursed objects */ |
928 | /* ignore known cursed objects */ |
929 | if (QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) && op->contr->mode & PU_NOT_CURSED) |
929 | if (tmp->flag [FLAG_KNOWN_CURSED] && op->contr->mode & PU_NOT_CURSED) |
930 | continue; |
930 | continue; |
931 | |
931 | |
932 | /* all food and drink if desired */ |
932 | /* all food and drink if desired */ |
933 | /* question: don't pick up known-poisonous stuff? */ |
933 | /* question: don't pick up known-poisonous stuff? */ |
934 | if (op->contr->mode & PU_FOOD) |
934 | if (op->contr->mode & PU_FOOD) |
… | |
… | |
937 | CHK_PICK_PICKUP; |
937 | CHK_PICK_PICKUP; |
938 | continue; |
938 | continue; |
939 | } |
939 | } |
940 | |
940 | |
941 | if (op->contr->mode & PU_DRINK) |
941 | if (op->contr->mode & PU_DRINK) |
942 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
942 | if (tmp->type == DRINK || (tmp->type == POISON && !tmp->flag [FLAG_KNOWN_CURSED])) |
943 | { |
943 | { |
944 | CHK_PICK_PICKUP; |
944 | CHK_PICK_PICKUP; |
945 | continue; |
945 | continue; |
946 | } |
946 | } |
947 | |
947 | |
… | |
… | |
985 | continue; |
985 | continue; |
986 | } |
986 | } |
987 | |
987 | |
988 | /* pick up all magical items */ |
988 | /* pick up all magical items */ |
989 | if (op->contr->mode & PU_MAGICAL) |
989 | if (op->contr->mode & PU_MAGICAL) |
990 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) |
990 | if (tmp->flag [FLAG_KNOWN_MAGICAL] |
991 | && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
991 | && !tmp->flag [FLAG_KNOWN_CURSED]) |
992 | { |
992 | { |
993 | CHK_PICK_PICKUP; |
993 | CHK_PICK_PICKUP; |
994 | continue; |
994 | continue; |
995 | } |
995 | } |
996 | |
996 | |
… | |
… | |
1080 | continue; |
1080 | continue; |
1081 | } |
1081 | } |
1082 | |
1082 | |
1083 | /* hoping to catch throwing daggers here */ |
1083 | /* hoping to catch throwing daggers here */ |
1084 | if (op->contr->mode & PU_MISSILEWEAPON) |
1084 | if (op->contr->mode & PU_MISSILEWEAPON) |
1085 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1085 | if (tmp->type == WEAPON && tmp->flag [FLAG_IS_THROWN]) |
1086 | { |
1086 | { |
1087 | CHK_PICK_PICKUP; |
1087 | CHK_PICK_PICKUP; |
1088 | continue; |
1088 | continue; |
1089 | } |
1089 | } |
1090 | |
1090 | |
… | |
… | |
1145 | * return 0. |
1145 | * return 0. |
1146 | */ |
1146 | */ |
1147 | static int |
1147 | static int |
1148 | action_makes_visible (object *op) |
1148 | action_makes_visible (object *op) |
1149 | { |
1149 | { |
1150 | if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) |
1150 | if (op->invisible && op->flag [FLAG_ALIVE]) |
1151 | { |
1151 | { |
1152 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
1152 | if (op->flag [FLAG_MAKE_INVIS]) |
1153 | { |
1153 | { |
1154 | // artefact invisibility is permanent, but we still make noise |
1154 | // artefact invisibility is permanent, but we still make noise |
1155 | // this is important for game-balance. |
1155 | // this is important for game-balance. |
1156 | if (op->contr) |
1156 | if (op->contr) |
1157 | op->make_noise (); |
1157 | op->make_noise (); |
… | |
… | |
1184 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1184 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1185 | if (tmp->type == ARROW && !strcmp (&tmp->race, type)) |
1185 | if (tmp->type == ARROW && !strcmp (&tmp->race, type)) |
1186 | return splay (tmp); |
1186 | return splay (tmp); |
1187 | |
1187 | |
1188 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1188 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1189 | if (tmp->type == CONTAINER && QUERY_FLAG (tmp, FLAG_APPLIED) && !strcmp (&tmp->race, type)) |
1189 | if (tmp->type == CONTAINER && tmp->flag [FLAG_APPLIED] && !strcmp (&tmp->race, type)) |
1190 | if (object *arrow = find_arrow (tmp, type)) |
1190 | if (object *arrow = find_arrow (tmp, type)) |
1191 | { |
1191 | { |
1192 | splay (tmp); |
1192 | splay (tmp); |
1193 | return arrow; |
1193 | return arrow; |
1194 | } |
1194 | } |
… | |
… | |
1211 | if (!type) |
1211 | if (!type) |
1212 | return NULL; |
1212 | return NULL; |
1213 | |
1213 | |
1214 | for (arrow = op->inv; arrow; arrow = arrow->below) |
1214 | for (arrow = op->inv; arrow; arrow = arrow->below) |
1215 | { |
1215 | { |
1216 | if (arrow->type == CONTAINER && arrow->race == type && QUERY_FLAG (arrow, FLAG_APPLIED)) |
1216 | if (arrow->type == CONTAINER && arrow->race == type && arrow->flag [FLAG_APPLIED]) |
1217 | { |
1217 | { |
1218 | i = 0; |
1218 | i = 0; |
1219 | ntmp = find_better_arrow (arrow, target, type, &i); |
1219 | ntmp = find_better_arrow (arrow, target, type, &i); |
1220 | |
1220 | |
1221 | if (i > betterby) |
1221 | if (i > betterby) |
… | |
… | |
1322 | break; |
1322 | break; |
1323 | } |
1323 | } |
1324 | |
1324 | |
1325 | if (mflags & P_IS_ALIVE) |
1325 | if (mflags & P_IS_ALIVE) |
1326 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
1326 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
1327 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
1327 | if (tmp->flag [FLAG_ALIVE]) |
1328 | break; |
1328 | break; |
1329 | } |
1329 | } |
1330 | |
1330 | |
1331 | if (!tmp) |
1331 | if (!tmp) |
1332 | return find_arrow (op, type); |
1332 | return find_arrow (op, type); |
… | |
… | |
1393 | { |
1393 | { |
1394 | if (op->type == PLAYER) |
1394 | if (op->type == PLAYER) |
1395 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1395 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1396 | /* FLAG_READY_BOW will get reset if the monsters picks up some arrows */ |
1396 | /* FLAG_READY_BOW will get reset if the monsters picks up some arrows */ |
1397 | else |
1397 | else |
1398 | CLEAR_FLAG (op, FLAG_READY_BOW); |
1398 | op->clr_flag (FLAG_READY_BOW); |
1399 | |
1399 | |
1400 | return 0; |
1400 | return 0; |
1401 | } |
1401 | } |
1402 | } |
1402 | } |
1403 | |
1403 | |
… | |
… | |
1603 | { |
1603 | { |
1604 | object *tmp; |
1604 | object *tmp; |
1605 | |
1605 | |
1606 | if (item->arch) |
1606 | if (item->arch) |
1607 | { |
1607 | { |
1608 | CLEAR_FLAG (item, FLAG_ANIMATE); |
1608 | item->clr_flag (FLAG_ANIMATE); |
1609 | item->face = item->arch->face; |
1609 | item->face = item->arch->face; |
1610 | item->set_speed (0); |
1610 | item->set_speed (0); |
1611 | } |
1611 | } |
1612 | |
1612 | |
1613 | if (object *pl = item->visible_to ()) |
1613 | if (object *pl = item->visible_to ()) |
… | |
… | |
1741 | * |
1741 | * |
1742 | * Change the color so that the message doesn't disappear with |
1742 | * Change the color so that the message doesn't disappear with |
1743 | * all the others. |
1743 | * all the others. |
1744 | */ |
1744 | */ |
1745 | if (pl->contr->usekeys == key_inventory |
1745 | if (pl->contr->usekeys == key_inventory |
1746 | || !QUERY_FLAG (container, FLAG_APPLIED) |
1746 | || !container->flag [FLAG_APPLIED] |
1747 | || (pl->contr->usekeys == keyrings && container->race != shstr_keys)) |
1747 | || (pl->contr->usekeys == keyrings && container->race != shstr_keys)) |
1748 | { |
1748 | { |
1749 | new_draw_info_format (NDI_UNIQUE | NDI_BROWN, 0, pl, |
1749 | new_draw_info_format (NDI_UNIQUE | NDI_BROWN, 0, pl, |
1750 | "The %s in your %s vibrates as you approach the door", query_name (tmp), query_name (container)); |
1750 | "The %s in your %s vibrates as you approach the door", query_name (tmp), query_name (container)); |
1751 | return NULL; |
1751 | return NULL; |
… | |
… | |
1902 | */ |
1902 | */ |
1903 | if (op->type == PLAYER |
1903 | if (op->type == PLAYER |
1904 | && ((mon->owner && mon->owner->contr |
1904 | && ((mon->owner && mon->owner->contr |
1905 | && same_party (mon->owner->contr->party, op->contr->party)) |
1905 | && same_party (mon->owner->contr->party, op->contr->party)) |
1906 | || mon->owner == op) |
1906 | || mon->owner == op) |
1907 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
1907 | && (mon->flag [FLAG_UNAGGRESSIVE] || mon->flag [FLAG_FRIENDLY])) |
1908 | { |
1908 | { |
1909 | /* If we're braced, we don't want to switch places with it */ |
1909 | /* If we're braced, we don't want to switch places with it */ |
1910 | if (op->contr->braced) |
1910 | if (op->contr->braced) |
1911 | return false; |
1911 | return false; |
1912 | |
1912 | |
… | |
… | |
1932 | * creatures. Note that if you are braced, you can't push |
1932 | * creatures. Note that if you are braced, you can't push |
1933 | * someone, but put it inside this loop so that you won't |
1933 | * someone, but put it inside this loop so that you won't |
1934 | * attack them either. |
1934 | * attack them either. |
1935 | */ |
1935 | */ |
1936 | if ((mon->type == PLAYER || mon->enemy != op) |
1936 | if ((mon->type == PLAYER || mon->enemy != op) |
1937 | && (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) |
1937 | && (mon->type == PLAYER || mon->flag [FLAG_UNAGGRESSIVE] || mon->flag [FLAG_FRIENDLY]) |
1938 | && ((op->contr->peaceful |
1938 | && ((op->contr->peaceful |
1939 | || (mon->type == PLAYER && mon->contr->peaceful)) |
1939 | || (mon->type == PLAYER && mon->contr->peaceful)) |
1940 | && !on_battleground)) |
1940 | && !on_battleground)) |
1941 | { |
1941 | { |
1942 | if (op->speed_left > 0.f) |
1942 | if (op->speed_left > 0.f) |
… | |
… | |
1958 | } |
1958 | } |
1959 | } |
1959 | } |
1960 | /* If the object is a boulder or other rollable object, then |
1960 | /* If the object is a boulder or other rollable object, then |
1961 | * roll it if not braced. You can't roll it if you are braced. |
1961 | * roll it if not braced. You can't roll it if you are braced. |
1962 | */ |
1962 | */ |
1963 | else if (QUERY_FLAG (mon, FLAG_CAN_ROLL) && (!op->contr->braced)) |
1963 | else if (mon->flag [FLAG_CAN_ROLL] && (!op->contr->braced)) |
1964 | { |
1964 | { |
1965 | if (op->speed_left > 0.f) |
1965 | if (op->speed_left > 0.f) |
1966 | { |
1966 | { |
1967 | --op->speed_left; |
1967 | --op->speed_left; |
1968 | |
1968 | |
… | |
… | |
1977 | * Way it works is like this: First, it must have some hit points |
1977 | * Way it works is like this: First, it must have some hit points |
1978 | * and be living. Then, it must be one of the following: |
1978 | * and be living. Then, it must be one of the following: |
1979 | * 1) Not a player, 2) A player, but of a different party. Note |
1979 | * 1) Not a player, 2) A player, but of a different party. Note |
1980 | * that party_number -1 is no party, so attacks can still happen. |
1980 | * that party_number -1 is no party, so attacks can still happen. |
1981 | */ |
1981 | */ |
1982 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
1982 | else if ((mon->stats.hp >= 0) && mon->flag [FLAG_ALIVE] && |
1983 | ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) |
1983 | ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) |
1984 | { |
1984 | { |
1985 | if (op->contr->weapon_sp_left > 0.f && !op->flag [FLAG_WIZPASS]) |
1985 | if (op->contr->weapon_sp_left > 0.f && !op->flag [FLAG_WIZPASS]) |
1986 | { |
1986 | { |
1987 | --op->contr->weapon_sp_left; |
1987 | --op->contr->weapon_sp_left; |
… | |
… | |
2010 | LOG (llevError, "move_player: invalid direction %d\n", dir); |
2010 | LOG (llevError, "move_player: invalid direction %d\n", dir); |
2011 | return 0; |
2011 | return 0; |
2012 | } |
2012 | } |
2013 | |
2013 | |
2014 | /* peterm: added following line */ |
2014 | /* peterm: added following line */ |
2015 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2015 | if (op->flag [FLAG_CONFUSED] && dir) |
2016 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2016 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2017 | |
2017 | |
2018 | op->facing = dir; |
2018 | op->facing = dir; |
2019 | |
2019 | |
2020 | if (op->flag [FLAG_HIDDEN]) |
2020 | if (op->flag [FLAG_HIDDEN]) |
… | |
… | |
2060 | * players. |
2060 | * players. |
2061 | */ |
2061 | */ |
2062 | bool |
2062 | bool |
2063 | handle_newcs_player (object *op) |
2063 | handle_newcs_player (object *op) |
2064 | { |
2064 | { |
2065 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2065 | if (op->flag [FLAG_SCARED]) |
2066 | { |
2066 | { |
2067 | if (op->speed_left > 0.f) |
2067 | if (op->speed_left > 0.f) |
2068 | { |
2068 | { |
2069 | --op->speed_left; |
2069 | --op->speed_left; |
2070 | flee_player (op); |
2070 | flee_player (op); |
… | |
… | |
2089 | } |
2089 | } |
2090 | |
2090 | |
2091 | static int |
2091 | static int |
2092 | save_life (object *op) |
2092 | save_life (object *op) |
2093 | { |
2093 | { |
2094 | if (!QUERY_FLAG (op, FLAG_LIFESAVE)) |
2094 | if (!op->flag [FLAG_LIFESAVE]) |
2095 | return 0; |
2095 | return 0; |
2096 | |
2096 | |
2097 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
2097 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
2098 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) |
2098 | if (tmp->flag [FLAG_APPLIED] && tmp->flag [FLAG_LIFESAVE]) |
2099 | { |
2099 | { |
2100 | op->play_sound (sound_find ("ob_evaporate")); |
2100 | op->play_sound (sound_find ("ob_evaporate")); |
2101 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2101 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); |
2102 | |
2102 | |
2103 | tmp->destroy (); |
2103 | tmp->destroy (); |
2104 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2104 | op->clr_flag (FLAG_LIFESAVE); |
2105 | |
2105 | |
2106 | if (op->stats.hp < 0) |
2106 | if (op->stats.hp < 0) |
2107 | op->stats.hp = op->stats.maxhp; |
2107 | op->stats.hp = op->stats.maxhp; |
2108 | |
2108 | |
2109 | if (op->stats.food < 0) |
2109 | if (op->stats.food < 0) |
… | |
… | |
2112 | op->update_stats (); |
2112 | op->update_stats (); |
2113 | return 1; |
2113 | return 1; |
2114 | } |
2114 | } |
2115 | |
2115 | |
2116 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2116 | LOG (llevError, "Error: LIFESAVE set without applied object.\n"); |
2117 | CLEAR_FLAG (op, FLAG_LIFESAVE); |
2117 | op->clr_flag (FLAG_LIFESAVE); |
2118 | enter_player_savebed (op); /* bring him home. */ |
2118 | enter_player_savebed (op); /* bring him home. */ |
2119 | return 0; |
2119 | return 0; |
2120 | } |
2120 | } |
2121 | |
2121 | |
2122 | /* This goes throws the inventory and removes unpaid objects, and puts them |
2122 | /* This goes throws the inventory and removes unpaid objects, and puts them |
… | |
… | |
2129 | { |
2129 | { |
2130 | while (op) |
2130 | while (op) |
2131 | { |
2131 | { |
2132 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2132 | object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ |
2133 | |
2133 | |
2134 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
2134 | if (op->flag [FLAG_UNPAID]) |
2135 | op->insert_at (env); |
2135 | op->insert_at (env); |
2136 | else if (op->inv) |
2136 | else if (op->inv) |
2137 | drop_unpaid_items (op->inv, env); |
2137 | drop_unpaid_items (op->inv, env); |
2138 | |
2138 | |
2139 | op = next; |
2139 | op = next; |
… | |
… | |
2169 | * alternate it here for it to work correctly. |
2169 | * alternate it here for it to work correctly. |
2170 | */ |
2170 | */ |
2171 | if (pticks & 2) |
2171 | if (pticks & 2) |
2172 | op->invisible--; |
2172 | op->invisible--; |
2173 | } |
2173 | } |
2174 | else if (op->invisible && !(QUERY_FLAG (op, FLAG_MAKE_INVIS))) |
2174 | else if (op->invisible && !(op->flag [FLAG_MAKE_INVIS])) |
2175 | { |
2175 | { |
2176 | if (!op->invisible--) |
2176 | if (!op->invisible--) |
2177 | { |
2177 | { |
2178 | make_visible (op); |
2178 | make_visible (op); |
2179 | new_draw_info (NDI_UNIQUE, 0, op, "Your invisibility spell runs out."); |
2179 | new_draw_info (NDI_UNIQUE, 0, op, "Your invisibility spell runs out."); |
… | |
… | |
2246 | if (op->stats.sp < op->stats.maxsp) |
2246 | if (op->stats.sp < op->stats.maxsp) |
2247 | { |
2247 | { |
2248 | op->stats.sp++; |
2248 | op->stats.sp++; |
2249 | |
2249 | |
2250 | /* dms do not consume food */ |
2250 | /* dms do not consume food */ |
2251 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2251 | if (!op->flag [FLAG_WIZ]) |
2252 | { |
2252 | { |
2253 | op->stats.food--; |
2253 | op->stats.food--; |
2254 | |
2254 | |
2255 | if (op->contr->digestion < 0) |
2255 | if (op->contr->digestion < 0) |
2256 | op->stats.food += op->contr->digestion; |
2256 | op->stats.food += op->contr->digestion; |
… | |
… | |
2290 | if (op->stats.hp < op->stats.maxhp) |
2290 | if (op->stats.hp < op->stats.maxhp) |
2291 | { |
2291 | { |
2292 | op->stats.hp++; |
2292 | op->stats.hp++; |
2293 | |
2293 | |
2294 | /* dms do not consume food */ |
2294 | /* dms do not consume food */ |
2295 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2295 | if (!op->flag [FLAG_WIZ]) |
2296 | { |
2296 | { |
2297 | op->stats.food--; |
2297 | op->stats.food--; |
2298 | |
2298 | |
2299 | if (op->contr->digestion < 0) |
2299 | if (op->contr->digestion < 0) |
2300 | op->stats.food += op->contr->digestion; |
2300 | op->stats.food += op->contr->digestion; |
… | |
… | |
2327 | penalty = max (0, -op->contr->digestion); |
2327 | penalty = max (0, -op->contr->digestion); |
2328 | |
2328 | |
2329 | op->last_eat = 25 * (1 + bonus) / (max (0, op->contr->gen_hp) + penalty + 1); |
2329 | op->last_eat = 25 * (1 + bonus) / (max (0, op->contr->gen_hp) + penalty + 1); |
2330 | |
2330 | |
2331 | /* dms do not consume food */ |
2331 | /* dms do not consume food */ |
2332 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2332 | if (!op->flag [FLAG_WIZ]) |
2333 | op->stats.food--; |
2333 | op->stats.food--; |
2334 | } |
2334 | } |
2335 | |
2335 | |
2336 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2336 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2337 | { |
2337 | { |
2338 | object *flesh = 0; |
2338 | object *flesh = 0; |
2339 | |
2339 | |
2340 | for_inv_removable (op, tmp) |
2340 | for_inv_removable (op, tmp) |
2341 | { |
2341 | { |
2342 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
2342 | if (tmp->flag [FLAG_UNPAID]) |
2343 | continue; |
2343 | continue; |
2344 | |
2344 | |
2345 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2345 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2346 | { |
2346 | { |
2347 | op->statusmsg ("You blindly grab for a bite of food. " |
2347 | op->statusmsg ("You blindly grab for a bite of food. " |
… | |
… | |
2382 | op->contr->killer->destroy (); |
2382 | op->contr->killer->destroy (); |
2383 | } |
2383 | } |
2384 | } |
2384 | } |
2385 | |
2385 | |
2386 | /* killer should be set here already */ |
2386 | /* killer should be set here already */ |
2387 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2387 | if (op->stats.hp < 0 && !op->flag [FLAG_WIZ]) |
2388 | kill_player (op); |
2388 | kill_player (op); |
2389 | } |
2389 | } |
2390 | } |
2390 | } |
2391 | |
2391 | |
2392 | /* If the player should die (lack of hp, food, etc), we call this. |
2392 | /* If the player should die (lack of hp, food, etc), we call this. |
… | |
… | |
2587 | * difference. |
2587 | * difference. |
2588 | */ |
2588 | */ |
2589 | if (this_stat >= -50) |
2589 | if (this_stat >= -50) |
2590 | { |
2590 | { |
2591 | change_attr_value (&(dep->stats), i, -1); |
2591 | change_attr_value (&(dep->stats), i, -1); |
2592 | SET_FLAG (dep, FLAG_APPLIED); |
2592 | dep->set_flag (FLAG_APPLIED); |
2593 | new_draw_info (NDI_UNIQUE, 0, op, lose_msg[i]); |
2593 | new_draw_info (NDI_UNIQUE, 0, op, lose_msg[i]); |
2594 | op->update_stats (); |
2594 | op->update_stats (); |
2595 | lost_a_stat = 1; |
2595 | lost_a_stat = 1; |
2596 | } |
2596 | } |
2597 | } |
2597 | } |
… | |
… | |
2668 | |
2668 | |
2669 | force = get_archetype (FORCE_NAME); |
2669 | force = get_archetype (FORCE_NAME); |
2670 | /* 50 ticks should be enough time for the spell to abate */ |
2670 | /* 50 ticks should be enough time for the spell to abate */ |
2671 | force->speed = 0.1f; |
2671 | force->speed = 0.1f; |
2672 | force->speed_left = -5.f; |
2672 | force->speed_left = -5.f; |
2673 | SET_FLAG (force, FLAG_APPLIED); |
2673 | force->set_flag (FLAG_APPLIED); |
2674 | for (at = 0; at < NROFATTACKS; at++) |
2674 | for (at = 0; at < NROFATTACKS; at++) |
2675 | if (will_kill_again & (1 << at)) |
2675 | if (will_kill_again & (1 << at)) |
2676 | force->resist[at] = 100; |
2676 | force->resist[at] = 100; |
2677 | |
2677 | |
2678 | insert_ob_in_ob (force, op); |
2678 | insert_ob_in_ob (force, op); |
… | |
… | |
2700 | tmp->x = op->x, tmp->y = op->y; |
2700 | tmp->x = op->x, tmp->y = op->y; |
2701 | |
2701 | |
2702 | if (tmp->type == CONTAINER) |
2702 | if (tmp->type == CONTAINER) |
2703 | loot_object (tmp); /* empty container to ground */ |
2703 | loot_object (tmp); /* empty container to ground */ |
2704 | |
2704 | |
2705 | if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) |
2705 | if (!tmp->flag [FLAG_UNIQUE] && (tmp->flag [FLAG_STARTEQUIP] || tmp->flag [FLAG_NO_DROP] || !(rndm (3)))) |
2706 | { |
2706 | { |
2707 | if (tmp->nrof > 1) |
2707 | if (tmp->nrof > 1) |
2708 | { |
2708 | { |
2709 | tmp->decrease (rndm (1, tmp->nrof - 1)); |
2709 | tmp->decrease (rndm (1, tmp->nrof - 1)); |
2710 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2710 | insert_ob_in_map (tmp, op->map, NULL, 0); |
… | |
… | |
2800 | } |
2800 | } |
2801 | |
2801 | |
2802 | int |
2802 | int |
2803 | is_true_undead (object *op) |
2803 | is_true_undead (object *op) |
2804 | { |
2804 | { |
2805 | if (QUERY_FLAG (op->arch, FLAG_UNDEAD)) |
2805 | if (op->arch->flag [FLAG_UNDEAD]) |
2806 | return 1; |
2806 | return 1; |
2807 | |
2807 | |
2808 | return 0; |
2808 | return 0; |
2809 | } |
2809 | } |
2810 | |
2810 | |
… | |
… | |
2908 | |
2908 | |
2909 | if (who->type == PLAYER) |
2909 | if (who->type == PLAYER) |
2910 | player = 1; |
2910 | player = 1; |
2911 | |
2911 | |
2912 | else |
2912 | else |
2913 | friendly = QUERY_FLAG (who, FLAG_FRIENDLY); |
2913 | friendly = who->flag [FLAG_FRIENDLY]; |
2914 | |
2914 | |
2915 | /* search adjacent squares */ |
2915 | /* search adjacent squares */ |
2916 | for (i = 1; i < 9; i++) |
2916 | for (i = 1; i < 9; i++) |
2917 | { |
2917 | { |
2918 | x = who->x + freearr_x[i]; |
2918 | x = who->x + freearr_x[i]; |
… | |
… | |
2927 | if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) |
2927 | if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) |
2928 | continue; |
2928 | continue; |
2929 | |
2929 | |
2930 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
2930 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
2931 | { |
2931 | { |
2932 | if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) |
2932 | if ((player ||friendly) &&tmp->flag [FLAG_MONSTER] && !tmp->flag [FLAG_UNAGGRESSIVE]) |
2933 | return 1; |
2933 | return 1; |
2934 | else if (tmp->type == PLAYER) |
2934 | else if (tmp->type == PLAYER) |
2935 | { |
2935 | { |
2936 | /*don't let a hidden DM prevent you from hiding */ |
2936 | /*don't let a hidden DM prevent you from hiding */ |
2937 | if (!QUERY_FLAG (tmp, FLAG_WIZ) || tmp->contr->hidden == 0) |
2937 | if (!tmp->flag [FLAG_WIZ] || tmp->contr->hidden == 0) |
2938 | return 1; |
2938 | return 1; |
2939 | } |
2939 | } |
2940 | } |
2940 | } |
2941 | } |
2941 | } |
2942 | return 0; |
2942 | return 0; |
… | |
… | |
3011 | * and the exit-coordinates sp/hp must both be > 0. |
3011 | * and the exit-coordinates sp/hp must both be > 0. |
3012 | * => The intention here is to prevent abuse of the battleground- |
3012 | * => The intention here is to prevent abuse of the battleground- |
3013 | * feature (like pickable or hidden battleground tiles). */ |
3013 | * feature (like pickable or hidden battleground tiles). */ |
3014 | for (object *tmp = op->below; tmp; tmp = tmp->below) |
3014 | for (object *tmp = op->below; tmp; tmp = tmp->below) |
3015 | { |
3015 | { |
3016 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
3016 | if (tmp->flag [FLAG_IS_FLOOR]) |
3017 | { |
3017 | { |
3018 | if (QUERY_FLAG (tmp, FLAG_NO_PICK) |
3018 | if (tmp->flag [FLAG_NO_PICK] |
3019 | && tmp->type == BATTLEGROUND |
3019 | && tmp->type == BATTLEGROUND |
3020 | && tmp->name == shstr_battleground |
3020 | && tmp->name == shstr_battleground |
3021 | && EXIT_X (tmp) && EXIT_Y (tmp)) |
3021 | && EXIT_X (tmp) && EXIT_Y (tmp)) |
3022 | { |
3022 | { |
3023 | /* before we assign the exit, check if this is a teambattle */ |
3023 | /* before we assign the exit, check if this is a teambattle */ |
… | |
… | |
3181 | strcat (buf, "."); |
3181 | strcat (buf, "."); |
3182 | new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, who, buf); |
3182 | new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, who, buf); |
3183 | } |
3183 | } |
3184 | |
3184 | |
3185 | /* evtl. adding flags: */ |
3185 | /* evtl. adding flags: */ |
3186 | if (QUERY_FLAG (item, FLAG_XRAYS)) |
3186 | if (item->flag [FLAG_XRAYS]) |
3187 | SET_FLAG (skin, FLAG_XRAYS); |
3187 | skin->set_flag (FLAG_XRAYS); |
3188 | if (QUERY_FLAG (item, FLAG_STEALTH)) |
3188 | if (item->flag [FLAG_STEALTH]) |
3189 | SET_FLAG (skin, FLAG_STEALTH); |
3189 | skin->set_flag (FLAG_STEALTH); |
3190 | if (QUERY_FLAG (item, FLAG_SEE_IN_DARK)) |
3190 | if (item->flag [FLAG_SEE_IN_DARK]) |
3191 | SET_FLAG (skin, FLAG_SEE_IN_DARK); |
3191 | skin->set_flag (FLAG_SEE_IN_DARK); |
3192 | |
3192 | |
3193 | /* print message if there is one */ |
3193 | /* print message if there is one */ |
3194 | if (item->msg != NULL) |
3194 | if (item->msg != NULL) |
3195 | new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, who, item->msg); |
3195 | new_draw_info (NDI_UNIQUE | NDI_BLUE, 0, who, item->msg); |
3196 | } |
3196 | } |
… | |
… | |
3238 | { |
3238 | { |
3239 | play_sound (sound_find ("generic_failure")); |
3239 | play_sound (sound_find ("generic_failure")); |
3240 | statusmsg (msg, color); |
3240 | statusmsg (msg, color); |
3241 | } |
3241 | } |
3242 | |
3242 | |
|
|
3243 | void |
|
|
3244 | object::failmsgf (const char *format, ...) |
|
|
3245 | { |
|
|
3246 | if (!contr) |
|
|
3247 | return; |
|
|
3248 | |
|
|
3249 | va_list ap; |
|
|
3250 | va_start (ap, format); |
|
|
3251 | contr->failmsg (vformat (format, ap)); |
|
|
3252 | va_end (ap); |
|
|
3253 | } |
|
|
3254 | |
|
|
3255 | void |
|
|
3256 | player::failmsgf (const char *format, ...) |
|
|
3257 | { |
|
|
3258 | va_list ap; |
|
|
3259 | va_start (ap, format); |
|
|
3260 | failmsg (vformat (format, ap)); |
|
|
3261 | va_end (ap); |
|
|
3262 | } |
|
|
3263 | |