… | |
… | |
122 | continue; |
122 | continue; |
123 | |
123 | |
124 | if (*buf == '%') |
124 | if (*buf == '%') |
125 | { /* send one news */ |
125 | { /* send one news */ |
126 | if (size > 0) |
126 | if (size > 0) |
127 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", (char *)"%s\n%s", subject, news); /*send previously read news */ |
127 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, |
|
|
128 | MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, |
|
|
129 | "INFORMATION: %s\n%s", (char *)"%s\n%s", |
|
|
130 | subject, news); /*send previously read news */ |
128 | |
131 | |
129 | strcpy (subject, buf + 1); |
132 | strcpy (subject, buf + 1); |
130 | strip_endline (subject); |
133 | strip_endline (subject); |
131 | size = 0; |
134 | size = 0; |
132 | news[0] = '\0'; |
135 | news[0] = '\0'; |
… | |
… | |
207 | ob->close_container (); //TODO: client-specific |
210 | ob->close_container (); //TODO: client-specific |
208 | |
211 | |
209 | ns->update_look = 0; |
212 | ns->update_look = 0; |
210 | ns->look_position = 0; |
213 | ns->look_position = 0; |
211 | |
214 | |
212 | clear_los (this); |
215 | clear_los (); |
213 | |
216 | |
214 | ns->reset_stats (); |
217 | ns->reset_stats (); |
215 | |
218 | |
216 | /* make sure he's a player -- needed because of class change. */ |
219 | /* make sure he's a player -- needed because of class change. */ |
217 | ob->type = PLAYER; // we are paranoid |
220 | ob->type = PLAYER; // we are paranoid |
218 | ob->race = ob->arch->race; |
221 | ob->race = ob->arch->race; |
219 | |
222 | |
220 | ob->update_weight (); |
223 | ob->update_weight (); |
221 | link_player_skills (ob); |
224 | link_skills (); |
222 | |
225 | |
223 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
226 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
224 | |
227 | |
225 | assign (title, ob->arch->object::name); |
228 | assign (title, ob->arch->object::name); |
226 | |
229 | |
… | |
… | |
321 | combat_ob = op; |
324 | combat_ob = op; |
322 | break; |
325 | break; |
323 | } |
326 | } |
324 | |
327 | |
325 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
328 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
326 | ob->deactivate (); // change_Weapon activates, fix this better |
329 | ob->deactivate (); // change_weapon activates, fix this better |
327 | } |
330 | } |
328 | |
331 | |
329 | void |
332 | void |
330 | player::set_observe (object *op) |
333 | player::set_observe (object *op) |
331 | { |
334 | { |
… | |
… | |
345 | savebed_map = first_map_path; /* Init. respawn position */ |
348 | savebed_map = first_map_path; /* Init. respawn position */ |
346 | |
349 | |
347 | gen_sp_armour = 10; |
350 | gen_sp_armour = 10; |
348 | bowtype = bow_normal; |
351 | bowtype = bow_normal; |
349 | petmode = pet_normal; |
352 | petmode = pet_normal; |
350 | listening = 10; |
|
|
351 | usekeys = containers; |
353 | usekeys = containers; |
352 | peaceful = 1; /* default peaceful */ |
354 | peaceful = 1; /* default peaceful */ |
353 | do_los = 1; |
355 | do_los = 1; |
354 | |
356 | |
355 | weapon_sp = 1.0f; |
357 | weapon_sp = 1.0f; |
… | |
… | |
726 | else /* lock all 'normal items by default */ |
728 | else /* lock all 'normal items by default */ |
727 | SET_FLAG (op, FLAG_INV_LOCKED); |
729 | SET_FLAG (op, FLAG_INV_LOCKED); |
728 | } /* for loop of objects in player inv */ |
730 | } /* for loop of objects in player inv */ |
729 | |
731 | |
730 | /* Need to set up the skill pointers */ |
732 | /* Need to set up the skill pointers */ |
731 | link_player_skills (pl); |
733 | pl->contr->link_skills (); |
732 | } |
734 | } |
733 | |
735 | |
734 | void |
736 | void |
735 | get_party_password (object *op, partylist *party) |
737 | get_party_password (object *op, partylist *party) |
736 | { |
738 | { |
… | |
… | |
865 | ob->contr->ns->state = ST_PLAYING; |
867 | ob->contr->ns->state = ST_PLAYING; |
866 | |
868 | |
867 | if (ob->msg) |
869 | if (ob->msg) |
868 | ob->msg = 0; |
870 | ob->msg = 0; |
869 | |
871 | |
870 | /* We create this now because some of the unique maps will need it |
|
|
871 | * to save here. |
|
|
872 | */ |
|
|
873 | { |
|
|
874 | char buf[MAX_BUF]; |
|
|
875 | sprintf (buf, "%s/%s/%s", settings.localdir, settings.playerdir, &ob->name); |
|
|
876 | make_path_to_file (buf); |
|
|
877 | } |
|
|
878 | |
|
|
879 | start_info (ob); |
872 | start_info (ob); |
880 | CLEAR_FLAG (ob, FLAG_WIZ); |
873 | CLEAR_FLAG (ob, FLAG_WIZ); |
881 | give_initial_items (ob, ob->randomitems); |
874 | give_initial_items (ob, ob->randomitems); |
882 | link_player_skills (ob); |
|
|
883 | esrv_send_inventory (ob, ob); |
875 | esrv_send_inventory (ob, ob); |
884 | ob->update_stats (); |
876 | ob->update_stats (); |
885 | |
877 | |
886 | /* This moves the player to a different start map, if there |
878 | /* This moves the player to a different start map, if there |
887 | * is one for this race |
879 | * is one for this race |
888 | */ |
880 | */ |
889 | if (*first_map_ext_path) |
881 | if (*first_map_ext_path) |
890 | { |
882 | ob->player_goto (format ("%s/%s", &first_map_ext_path, &ob->arch->archname), ob->x, ob->y); |
891 | object *tmp; |
|
|
892 | char mapname[MAX_BUF]; |
|
|
893 | |
|
|
894 | snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &ob->arch->archname); |
|
|
895 | tmp = object::create (); |
|
|
896 | EXIT_PATH (tmp) = mapname; |
|
|
897 | EXIT_X (tmp) = ob->x; |
|
|
898 | EXIT_Y (tmp) = ob->y; |
|
|
899 | ob->enter_exit (tmp); /* we don't really care if it succeeded; |
|
|
900 | * if the map isn't there, then stay on the |
|
|
901 | * default initial map */ |
|
|
902 | tmp->destroy (); |
|
|
903 | } |
|
|
904 | else |
883 | else |
905 | LOG (llevDebug, "first_map_ext_path not set\n"); |
884 | LOG (llevDebug, "first_map_ext_path not set\n"); |
906 | } |
885 | } |
907 | |
886 | |
908 | void |
887 | void |
… | |
… | |
952 | LOG (llevDebug, "Fleeing player is dead.\n"); |
931 | LOG (llevDebug, "Fleeing player is dead.\n"); |
953 | CLEAR_FLAG (op, FLAG_SCARED); |
932 | CLEAR_FLAG (op, FLAG_SCARED); |
954 | return; |
933 | return; |
955 | } |
934 | } |
956 | |
935 | |
957 | if (op->enemy == NULL) |
936 | if (!op->enemy) |
958 | { |
937 | { |
959 | LOG (llevDebug, "Fleeing player had no enemy.\n"); |
938 | LOG (llevDebug, "Fleeing player had no enemy.\n"); |
960 | CLEAR_FLAG (op, FLAG_SCARED); |
939 | CLEAR_FLAG (op, FLAG_SCARED); |
961 | return; |
940 | return; |
962 | } |
941 | } |
963 | |
942 | |
964 | /* Seen some crashes here. Since we don't store an |
|
|
965 | * op->enemy_count, it is possible that something destroys the |
|
|
966 | * actual enemy, and the object is recycled. |
|
|
967 | */ |
|
|
968 | if (op->enemy->map == NULL) |
|
|
969 | { |
|
|
970 | CLEAR_FLAG (op, FLAG_SCARED); |
|
|
971 | op->enemy = NULL; |
|
|
972 | return; |
|
|
973 | } |
|
|
974 | |
|
|
975 | if (!(random_roll (0, 4, op, PREFER_LOW)) && did_make_save (op, op->level, 0)) |
943 | if (!(random_roll (0, 4, op, PREFER_LOW)) && did_make_save (op, op->level, 0)) |
976 | { |
944 | { |
977 | op->enemy = NULL; |
945 | op->enemy = NULL; |
978 | CLEAR_FLAG (op, FLAG_SCARED); |
946 | CLEAR_FLAG (op, FLAG_SCARED); |
979 | return; |
947 | return; |
… | |
… | |
982 | get_rangevector (op, op->enemy, &rv, 0); |
950 | get_rangevector (op, op->enemy, &rv, 0); |
983 | |
951 | |
984 | dir = absdir (4 + rv.direction); |
952 | dir = absdir (4 + rv.direction); |
985 | for (diff = 0; diff < 3; diff++) |
953 | for (diff = 0; diff < 3; diff++) |
986 | { |
954 | { |
987 | int m = 1 - (RANDOM () & 2); |
955 | int m = 1 - rndm (2) * 2; |
988 | |
956 | |
989 | if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) |
957 | if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) |
990 | return; |
958 | return; |
991 | } |
959 | } |
992 | |
960 | |
… | |
… | |
1003 | check_pick (object *op) |
971 | check_pick (object *op) |
1004 | { |
972 | { |
1005 | object *tmp, *next; |
973 | object *tmp, *next; |
1006 | int stop = 0; |
974 | int stop = 0; |
1007 | int wvratio; |
975 | int wvratio; |
1008 | char putstring[128]; |
|
|
1009 | |
976 | |
1010 | /* if you're flying, you cna't pick up anything */ |
977 | /* if you're flying, you cna't pick up anything */ |
1011 | if (op->move_type & MOVE_FLYING) |
978 | if (op->move_type & MOVE_FLYING) |
1012 | return 1; |
979 | return 1; |
1013 | |
980 | |
… | |
… | |
1037 | |
1004 | |
1038 | if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) |
1005 | if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) |
1039 | { |
1006 | { |
1040 | if (item_matched_string (op, tmp, op->contr->search_str)) |
1007 | if (item_matched_string (op, tmp, op->contr->search_str)) |
1041 | CHK_PICK_PICKUP; |
1008 | CHK_PICK_PICKUP; |
|
|
1009 | |
1042 | continue; |
1010 | continue; |
1043 | } |
1011 | } |
1044 | |
1012 | |
1045 | /* high not bit set? We're using the old autopickup model */ |
1013 | /* pickup handling */ |
|
|
1014 | if (op->contr->mode & PU_DEBUG) |
|
|
1015 | { |
|
|
1016 | /* some debugging code to figure out item information */ |
|
|
1017 | const char *str = tmp->name |
|
|
1018 | ? format ("item name: %s item type: %d weight/value: %d", |
|
|
1019 | &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))) |
|
|
1020 | : format ("item name: %s item type: %d weight/value: %d", |
|
|
1021 | &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
|
|
1022 | |
|
|
1023 | new_draw_info (NDI_UNIQUE, 0, op, str); |
|
|
1024 | } |
|
|
1025 | |
|
|
1026 | if (op->contr->mode & PU_INHIBIT) |
|
|
1027 | return 1; |
|
|
1028 | |
|
|
1029 | if (!(op->contr->mode & PU_ENABLE)) // TODO: fix client |
|
|
1030 | return 1; |
|
|
1031 | |
|
|
1032 | /* philosophy: |
|
|
1033 | * It's easy to grab an item type from a pile, as long as it's |
|
|
1034 | * generic. This takes no game-time. For more detailed pickups |
|
|
1035 | * and selections, select-items should be used. This is a |
|
|
1036 | * grab-as-you-run type mode that's really useful for arrows for |
|
|
1037 | * example. |
|
|
1038 | * The drawback: right now it has no frontend, so you need to |
|
|
1039 | * stick the bits you want into a calculator in hex mode and then |
|
|
1040 | * convert to decimal and then 'pickup <#> |
|
|
1041 | */ |
|
|
1042 | |
|
|
1043 | /* the first two modes are exclusive: if NOTHING we return, if |
|
|
1044 | * STOP then we stop. All the rest are applied sequentially, |
|
|
1045 | * meaning if any test passes, the item gets picked up. */ |
|
|
1046 | |
|
|
1047 | /* if mode is set to pick nothing up, return */ |
|
|
1048 | if (op->contr->mode == PU_NOTHING) |
|
|
1049 | return 1; |
|
|
1050 | |
|
|
1051 | /* if mode is set to stop when encountering objects, return */ |
|
|
1052 | /* take STOP before INHIBIT since it doesn't actually pick |
|
|
1053 | * anything up */ |
|
|
1054 | if (op->contr->mode & PU_STOP) |
|
|
1055 | return 0; |
|
|
1056 | |
|
|
1057 | /* useful for going into stores and not losing your settings... */ |
|
|
1058 | /* and for battles wher you don't want to get loaded down while |
|
|
1059 | * fighting */ |
|
|
1060 | if (op->contr->mode & PU_INHIBIT) |
|
|
1061 | return 1; |
|
|
1062 | |
|
|
1063 | /* prevent us from turning into auto-thieves :) */ |
|
|
1064 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
|
|
1065 | continue; |
|
|
1066 | |
|
|
1067 | /* ignore known cursed objects */ |
|
|
1068 | if (QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) && op->contr->mode & PU_NOT_CURSED) |
|
|
1069 | continue; |
|
|
1070 | |
|
|
1071 | /* all food and drink if desired */ |
|
|
1072 | /* question: don't pick up known-poisonous stuff? */ |
1046 | if (!(op->contr->mode & PU_NEWMODE)) |
1073 | if (op->contr->mode & PU_FOOD) |
|
|
1074 | if (tmp->type == FOOD) |
1047 | { |
1075 | { |
1048 | switch (op->contr->mode) |
1076 | CHK_PICK_PICKUP; |
|
|
1077 | continue; |
|
|
1078 | } |
|
|
1079 | |
|
|
1080 | if (op->contr->mode & PU_DRINK) |
|
|
1081 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
|
|
1082 | { |
|
|
1083 | CHK_PICK_PICKUP; |
|
|
1084 | continue; |
|
|
1085 | } |
|
|
1086 | |
|
|
1087 | if (op->contr->mode & PU_POTION) |
|
|
1088 | if (tmp->type == POTION) |
|
|
1089 | { |
|
|
1090 | CHK_PICK_PICKUP; |
|
|
1091 | continue; |
|
|
1092 | } |
|
|
1093 | |
|
|
1094 | /* spellbooks, skillscrolls and normal books/scrolls */ |
|
|
1095 | if (op->contr->mode & PU_SPELLBOOK) |
|
|
1096 | if (tmp->type == SPELLBOOK) |
|
|
1097 | { |
|
|
1098 | CHK_PICK_PICKUP; |
|
|
1099 | continue; |
|
|
1100 | } |
|
|
1101 | |
|
|
1102 | if (op->contr->mode & PU_SKILLSCROLL) |
|
|
1103 | if (tmp->type == SKILLSCROLL) |
|
|
1104 | { |
|
|
1105 | CHK_PICK_PICKUP; |
|
|
1106 | continue; |
|
|
1107 | } |
|
|
1108 | |
|
|
1109 | if (op->contr->mode & PU_READABLES) |
|
|
1110 | if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE) |
|
|
1111 | { |
|
|
1112 | CHK_PICK_PICKUP; |
|
|
1113 | continue; |
|
|
1114 | } |
|
|
1115 | |
|
|
1116 | /* wands/staves/rods/horns */ |
|
|
1117 | if (op->contr->mode & PU_MAGIC_DEVICE) |
|
|
1118 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
|
|
1119 | { |
|
|
1120 | CHK_PICK_PICKUP; |
|
|
1121 | continue; |
|
|
1122 | } |
|
|
1123 | |
|
|
1124 | /* pick up all magical items */ |
|
|
1125 | if (op->contr->mode & PU_MAGICAL) |
|
|
1126 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
|
|
1127 | { |
|
|
1128 | CHK_PICK_PICKUP; |
|
|
1129 | continue; |
|
|
1130 | } |
|
|
1131 | |
|
|
1132 | if (op->contr->mode & PU_VALUABLES) |
|
|
1133 | { |
|
|
1134 | if (tmp->type == MONEY || tmp->type == GEM) |
1049 | { |
1135 | { |
1050 | case 0: |
|
|
1051 | return 1; /* don't pick up */ |
|
|
1052 | case 1: |
|
|
1053 | CHK_PICK_PICKUP; |
1136 | CHK_PICK_PICKUP; |
1054 | return 1; |
1137 | continue; |
1055 | case 2: |
|
|
1056 | CHK_PICK_PICKUP; |
|
|
1057 | return 0; |
|
|
1058 | case 3: |
|
|
1059 | return 0; /* stop before pickup */ |
|
|
1060 | case 4: |
|
|
1061 | CHK_PICK_PICKUP; |
|
|
1062 | break; |
|
|
1063 | case 5: |
|
|
1064 | CHK_PICK_PICKUP; |
|
|
1065 | stop = 1; |
|
|
1066 | break; |
|
|
1067 | case 6: |
|
|
1068 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) |
|
|
1069 | && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
|
|
1070 | CHK_PICK_PICKUP; |
|
|
1071 | break; |
|
|
1072 | |
|
|
1073 | case 7: |
|
|
1074 | if (tmp->type == MONEY || tmp->type == GEM) |
|
|
1075 | CHK_PICK_PICKUP; |
|
|
1076 | break; |
|
|
1077 | |
|
|
1078 | default: |
|
|
1079 | /* use value density */ |
|
|
1080 | if (!QUERY_FLAG (tmp, FLAG_UNPAID) |
|
|
1081 | && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) |
|
|
1082 | CHK_PICK_PICKUP; |
|
|
1083 | } |
1138 | } |
1084 | } |
1139 | } |
1085 | else |
1140 | |
1086 | { /* old model */ |
1141 | /* rings & amulets - talismans seems to be typed AMULET */ |
1087 | /* NEW pickup handling */ |
|
|
1088 | if (op->contr->mode & PU_DEBUG) |
1142 | if (op->contr->mode & PU_JEWELS) |
|
|
1143 | if (tmp->type == RING || tmp->type == AMULET) |
1089 | { |
1144 | { |
1090 | /* some debugging code to figure out item information */ |
1145 | CHK_PICK_PICKUP; |
1091 | if (tmp->name != NULL) |
|
|
1092 | sprintf (putstring, "item name: %s item type: %d weight/value: %d", |
|
|
1093 | &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
|
|
1094 | else |
|
|
1095 | sprintf (putstring, "item name: %s item type: %d weight/value: %d", |
|
|
1096 | &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
|
|
1097 | |
|
|
1098 | new_draw_info (NDI_UNIQUE, 0, op, putstring); |
|
|
1099 | } |
|
|
1100 | |
|
|
1101 | /* philosophy: |
|
|
1102 | * It's easy to grab an item type from a pile, as long as it's |
|
|
1103 | * generic. This takes no game-time. For more detailed pickups |
|
|
1104 | * and selections, select-items should be used. This is a |
|
|
1105 | * grab-as-you-run type mode that's really useful for arrows for |
|
|
1106 | * example. |
|
|
1107 | * The drawback: right now it has no frontend, so you need to |
|
|
1108 | * stick the bits you want into a calculator in hex mode and then |
|
|
1109 | * convert to decimal and then 'pickup <#> |
|
|
1110 | */ |
|
|
1111 | |
|
|
1112 | /* the first two modes are exclusive: if NOTHING we return, if |
|
|
1113 | * STOP then we stop. All the rest are applied sequentially, |
|
|
1114 | * meaning if any test passes, the item gets picked up. */ |
|
|
1115 | |
|
|
1116 | /* if mode is set to pick nothing up, return */ |
|
|
1117 | |
|
|
1118 | if (op->contr->mode & PU_NOTHING) |
|
|
1119 | return 1; |
|
|
1120 | |
|
|
1121 | /* if mode is set to stop when encountering objects, return */ |
|
|
1122 | /* take STOP before INHIBIT since it doesn't actually pick |
|
|
1123 | * anything up */ |
|
|
1124 | |
|
|
1125 | if (op->contr->mode & PU_STOP) |
|
|
1126 | return 0; |
|
|
1127 | |
|
|
1128 | /* useful for going into stores and not losing your settings... */ |
|
|
1129 | /* and for battles wher you don't want to get loaded down while |
|
|
1130 | * fighting */ |
|
|
1131 | if (op->contr->mode & PU_INHIBIT) |
|
|
1132 | return 1; |
|
|
1133 | |
|
|
1134 | /* prevent us from turning into auto-thieves :) */ |
|
|
1135 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
|
|
1136 | continue; |
1146 | continue; |
|
|
1147 | } |
1137 | |
1148 | |
1138 | /* ignore known cursed objects */ |
1149 | /* we don't forget dragon food */ |
1139 | if (QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) && op->contr->mode & PU_NOT_CURSED) |
1150 | if (op->contr->mode & PU_FLESH) |
|
|
1151 | if (tmp->type == FLESH) |
|
|
1152 | { |
|
|
1153 | CHK_PICK_PICKUP; |
1140 | continue; |
1154 | continue; |
|
|
1155 | } |
1141 | |
1156 | |
1142 | /* all food and drink if desired */ |
1157 | /* bows and arrows. Bows are good for selling! */ |
1143 | /* question: don't pick up known-poisonous stuff? */ |
1158 | if (op->contr->mode & PU_BOW) |
|
|
1159 | if (tmp->type == BOW) |
|
|
1160 | { |
|
|
1161 | CHK_PICK_PICKUP; |
|
|
1162 | continue; |
|
|
1163 | } |
|
|
1164 | |
|
|
1165 | if (op->contr->mode & PU_ARROW) |
|
|
1166 | if (tmp->type == ARROW) |
|
|
1167 | { |
|
|
1168 | CHK_PICK_PICKUP; |
|
|
1169 | continue; |
|
|
1170 | } |
|
|
1171 | |
|
|
1172 | /* all kinds of armor etc. */ |
|
|
1173 | if (op->contr->mode & PU_ARMOUR) |
|
|
1174 | if (tmp->type == ARMOUR) |
|
|
1175 | { |
|
|
1176 | CHK_PICK_PICKUP; |
|
|
1177 | continue; |
|
|
1178 | } |
|
|
1179 | |
|
|
1180 | if (op->contr->mode & PU_HELMET) |
|
|
1181 | if (tmp->type == HELMET) |
|
|
1182 | { |
|
|
1183 | CHK_PICK_PICKUP; |
|
|
1184 | continue; |
|
|
1185 | } |
|
|
1186 | |
|
|
1187 | if (op->contr->mode & PU_SHIELD) |
|
|
1188 | if (tmp->type == SHIELD) |
|
|
1189 | { |
|
|
1190 | CHK_PICK_PICKUP; |
|
|
1191 | continue; |
|
|
1192 | } |
|
|
1193 | |
1144 | if (op->contr->mode & PU_FOOD) |
1194 | if (op->contr->mode & PU_BOOTS) |
1145 | if (tmp->type == FOOD) |
1195 | if (tmp->type == BOOTS) |
|
|
1196 | { |
|
|
1197 | CHK_PICK_PICKUP; |
|
|
1198 | continue; |
|
|
1199 | } |
|
|
1200 | |
|
|
1201 | if (op->contr->mode & PU_GLOVES) |
|
|
1202 | if (tmp->type == GLOVES) |
|
|
1203 | { |
|
|
1204 | CHK_PICK_PICKUP; |
|
|
1205 | continue; |
|
|
1206 | } |
|
|
1207 | |
|
|
1208 | if (op->contr->mode & PU_CLOAK) |
|
|
1209 | if (tmp->type == CLOAK) |
|
|
1210 | { |
|
|
1211 | CHK_PICK_PICKUP; |
|
|
1212 | continue; |
|
|
1213 | } |
|
|
1214 | |
|
|
1215 | /* hoping to catch throwing daggers here */ |
|
|
1216 | if (op->contr->mode & PU_MISSILEWEAPON) |
|
|
1217 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
|
|
1218 | { |
|
|
1219 | CHK_PICK_PICKUP; |
|
|
1220 | continue; |
|
|
1221 | } |
|
|
1222 | |
|
|
1223 | /* careful: chairs and tables are weapons! */ |
|
|
1224 | if (op->contr->mode & PU_ALLWEAPON) |
|
|
1225 | { |
|
|
1226 | if (tmp->type == WEAPON) |
|
|
1227 | if (!tmp->arch->archname.contains ("table") && !tmp->arch->archname.contains ("chair")) |
1146 | { |
1228 | { |
1147 | CHK_PICK_PICKUP; |
1229 | CHK_PICK_PICKUP; |
1148 | continue; |
1230 | continue; |
1149 | } |
1231 | } |
|
|
1232 | } |
1150 | |
1233 | |
|
|
1234 | /* misc stuff that's useful */ |
1151 | if (op->contr->mode & PU_DRINK) |
1235 | if (op->contr->mode & PU_KEY) |
1152 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1236 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1153 | { |
1237 | { |
1154 | CHK_PICK_PICKUP; |
1238 | CHK_PICK_PICKUP; |
1155 | continue; |
1239 | continue; |
1156 | } |
1240 | } |
1157 | |
1241 | |
|
|
1242 | /* any of the last 4 bits set means we use the ratio for value |
|
|
1243 | * pickups */ |
1158 | if (op->contr->mode & PU_POTION) |
1244 | if (op->contr->mode & PU_RATIO) |
1159 | if (tmp->type == POTION) |
1245 | { |
|
|
1246 | /* use value density to decide what else to grab */ |
|
|
1247 | /* >=7 was >= op->contr->mode */ |
|
|
1248 | /* >=7 is the old standard setting. Now we take the last 4 bits |
1160 | { |
1249 | */ |
1161 | CHK_PICK_PICKUP; |
|
|
1162 | continue; |
|
|
1163 | } |
|
|
1164 | |
|
|
1165 | /* spellbooks, skillscrolls and normal books/scrolls */ |
|
|
1166 | if (op->contr->mode & PU_SPELLBOOK) |
|
|
1167 | if (tmp->type == SPELLBOOK) |
|
|
1168 | { |
|
|
1169 | CHK_PICK_PICKUP; |
|
|
1170 | continue; |
|
|
1171 | } |
|
|
1172 | |
|
|
1173 | if (op->contr->mode & PU_SKILLSCROLL) |
|
|
1174 | if (tmp->type == SKILLSCROLL) |
|
|
1175 | { |
|
|
1176 | CHK_PICK_PICKUP; |
|
|
1177 | continue; |
|
|
1178 | } |
|
|
1179 | |
|
|
1180 | if (op->contr->mode & PU_READABLES) |
|
|
1181 | if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE) |
|
|
1182 | { |
|
|
1183 | CHK_PICK_PICKUP; |
|
|
1184 | continue; |
|
|
1185 | } |
|
|
1186 | |
|
|
1187 | /* wands/staves/rods/horns */ |
|
|
1188 | if (op->contr->mode & PU_MAGIC_DEVICE) |
|
|
1189 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
|
|
1190 | { |
|
|
1191 | CHK_PICK_PICKUP; |
|
|
1192 | continue; |
|
|
1193 | } |
|
|
1194 | |
|
|
1195 | /* pick up all magical items */ |
|
|
1196 | if (op->contr->mode & PU_MAGICAL) |
1250 | wvratio = op->contr->mode & PU_RATIO; |
1197 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1251 | if (1000 * query_cost (tmp, op, F_TRUE) / tmp->total_weight () >= wvratio * 100) |
1198 | { |
|
|
1199 | CHK_PICK_PICKUP; |
|
|
1200 | continue; |
|
|
1201 | } |
|
|
1202 | |
|
|
1203 | if (op->contr->mode & PU_VALUABLES) |
|
|
1204 | { |
1252 | { |
1205 | if (tmp->type == MONEY || tmp->type == GEM) |
1253 | #if 0 |
|
|
1254 | fprintf (stderr, "HIGH WEIGHT/VALUE ["); |
|
|
1255 | if (tmp->name != NULL) |
1206 | { |
1256 | { |
1207 | CHK_PICK_PICKUP; |
1257 | fprintf (stderr, "%s", tmp->name); |
1208 | continue; |
|
|
1209 | } |
1258 | } |
1210 | } |
|
|
1211 | |
|
|
1212 | /* rings & amulets - talismans seems to be typed AMULET */ |
|
|
1213 | if (op->contr->mode & PU_JEWELS) |
|
|
1214 | if (tmp->type == RING || tmp->type == AMULET) |
|
|
1215 | { |
|
|
1216 | CHK_PICK_PICKUP; |
|
|
1217 | continue; |
|
|
1218 | } |
|
|
1219 | |
|
|
1220 | /* we don't forget dragon food */ |
|
|
1221 | if (op->contr->mode & PU_FLESH) |
|
|
1222 | if (tmp->type == FLESH) |
|
|
1223 | { |
|
|
1224 | CHK_PICK_PICKUP; |
|
|
1225 | continue; |
|
|
1226 | } |
|
|
1227 | |
|
|
1228 | /* bows and arrows. Bows are good for selling! */ |
|
|
1229 | if (op->contr->mode & PU_BOW) |
|
|
1230 | if (tmp->type == BOW) |
|
|
1231 | { |
|
|
1232 | CHK_PICK_PICKUP; |
|
|
1233 | continue; |
|
|
1234 | } |
|
|
1235 | |
|
|
1236 | if (op->contr->mode & PU_ARROW) |
|
|
1237 | if (tmp->type == ARROW) |
|
|
1238 | { |
|
|
1239 | CHK_PICK_PICKUP; |
|
|
1240 | continue; |
|
|
1241 | } |
|
|
1242 | |
|
|
1243 | /* all kinds of armor etc. */ |
|
|
1244 | if (op->contr->mode & PU_ARMOUR) |
|
|
1245 | if (tmp->type == ARMOUR) |
|
|
1246 | { |
|
|
1247 | CHK_PICK_PICKUP; |
|
|
1248 | continue; |
|
|
1249 | } |
|
|
1250 | |
|
|
1251 | if (op->contr->mode & PU_HELMET) |
|
|
1252 | if (tmp->type == HELMET) |
|
|
1253 | { |
|
|
1254 | CHK_PICK_PICKUP; |
|
|
1255 | continue; |
|
|
1256 | } |
|
|
1257 | |
|
|
1258 | if (op->contr->mode & PU_SHIELD) |
|
|
1259 | if (tmp->type == SHIELD) |
|
|
1260 | { |
|
|
1261 | CHK_PICK_PICKUP; |
|
|
1262 | continue; |
|
|
1263 | } |
|
|
1264 | |
|
|
1265 | if (op->contr->mode & PU_BOOTS) |
|
|
1266 | if (tmp->type == BOOTS) |
|
|
1267 | { |
|
|
1268 | CHK_PICK_PICKUP; |
|
|
1269 | continue; |
|
|
1270 | } |
|
|
1271 | |
|
|
1272 | if (op->contr->mode & PU_GLOVES) |
|
|
1273 | if (tmp->type == GLOVES) |
|
|
1274 | { |
|
|
1275 | CHK_PICK_PICKUP; |
|
|
1276 | continue; |
|
|
1277 | } |
|
|
1278 | |
|
|
1279 | if (op->contr->mode & PU_CLOAK) |
|
|
1280 | if (tmp->type == CLOAK) |
|
|
1281 | { |
|
|
1282 | CHK_PICK_PICKUP; |
|
|
1283 | continue; |
|
|
1284 | } |
|
|
1285 | |
|
|
1286 | /* hoping to catch throwing daggers here */ |
|
|
1287 | if (op->contr->mode & PU_MISSILEWEAPON) |
|
|
1288 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
|
|
1289 | { |
|
|
1290 | CHK_PICK_PICKUP; |
|
|
1291 | continue; |
|
|
1292 | } |
|
|
1293 | |
|
|
1294 | /* careful: chairs and tables are weapons! */ |
|
|
1295 | if (op->contr->mode & PU_ALLWEAPON) |
|
|
1296 | { |
|
|
1297 | if (tmp->type == WEAPON && tmp->name != NULL) |
|
|
1298 | { |
|
|
1299 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL && |
|
|
1300 | strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL) |
|
|
1301 | { |
|
|
1302 | CHK_PICK_PICKUP; |
|
|
1303 | continue; |
|
|
1304 | } |
|
|
1305 | } |
|
|
1306 | |
|
|
1307 | if (tmp->type == WEAPON && tmp->name == NULL) |
|
|
1308 | { |
|
|
1309 | if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL) |
|
|
1310 | { |
|
|
1311 | CHK_PICK_PICKUP; |
|
|
1312 | continue; |
|
|
1313 | } |
|
|
1314 | } |
|
|
1315 | } |
|
|
1316 | |
|
|
1317 | /* misc stuff that's useful */ |
|
|
1318 | if (op->contr->mode & PU_KEY) |
|
|
1319 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
|
|
1320 | { |
|
|
1321 | CHK_PICK_PICKUP; |
|
|
1322 | continue; |
|
|
1323 | } |
|
|
1324 | |
|
|
1325 | /* any of the last 4 bits set means we use the ratio for value |
|
|
1326 | * pickups */ |
|
|
1327 | if (op->contr->mode & PU_RATIO) |
|
|
1328 | { |
|
|
1329 | /* use value density to decide what else to grab */ |
|
|
1330 | /* >=7 was >= op->contr->mode */ |
|
|
1331 | /* >=7 is the old standard setting. Now we take the last 4 bits |
|
|
1332 | * and multiply them by 5, giving 0..15*5== 5..75 */ |
|
|
1333 | wvratio = (op->contr->mode & PU_RATIO) * 5; |
|
|
1334 | if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio) |
|
|
1335 | { |
|
|
1336 | CHK_PICK_PICKUP; |
|
|
1337 | #if 0 |
|
|
1338 | fprintf (stderr, "HIGH WEIGHT/VALUE ["); |
|
|
1339 | if (tmp->name != NULL) |
|
|
1340 | { |
|
|
1341 | fprintf (stderr, "%s", tmp->name); |
|
|
1342 | } |
|
|
1343 | else |
1259 | else |
1344 | fprintf (stderr, "%s", tmp->arch->archname); |
1260 | fprintf (stderr, "%s", tmp->arch->archname); |
1345 | fprintf (stderr, ",%d] = ", tmp->type); |
1261 | fprintf (stderr, ",%d] = ", tmp->type); |
1346 | fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1262 | fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1347 | #endif |
1263 | #endif |
|
|
1264 | CHK_PICK_PICKUP; |
1348 | continue; |
1265 | continue; |
1349 | } |
|
|
1350 | } |
1266 | } |
1351 | } /* the new pickup model */ |
1267 | } /* the new pickup model */ |
1352 | } |
1268 | } |
1353 | |
1269 | |
1354 | return !stop; |
1270 | return !stop; |
… | |
… | |
1382 | * against the target. A full test is not performed, simply a basic test |
1298 | * against the target. A full test is not performed, simply a basic test |
1383 | * of resistances. The archer is making a quick guess at what he sees down |
1299 | * of resistances. The archer is making a quick guess at what he sees down |
1384 | * the hall. Failing that it does it's best to pick the highest plus arrow. |
1300 | * the hall. Failing that it does it's best to pick the highest plus arrow. |
1385 | */ |
1301 | */ |
1386 | object * |
1302 | object * |
1387 | find_better_arrow (object *op, object *target, const char *type, int *better) |
1303 | find_better_arrow (object *op, object *target, shstr_cmp type, int *better) |
1388 | { |
1304 | { |
1389 | object *tmp = NULL, *arrow, *ntmp; |
1305 | object *tmp = NULL, *arrow, *ntmp; |
1390 | int attacknum, attacktype, betterby = 0, i; |
1306 | int attacknum, attacktype, betterby = 0, i; |
1391 | |
1307 | |
1392 | if (!type) |
1308 | if (!type) |
… | |
… | |
1396 | { |
1312 | { |
1397 | if (arrow->type == CONTAINER && arrow->race == type && QUERY_FLAG (arrow, FLAG_APPLIED)) |
1313 | if (arrow->type == CONTAINER && arrow->race == type && QUERY_FLAG (arrow, FLAG_APPLIED)) |
1398 | { |
1314 | { |
1399 | i = 0; |
1315 | i = 0; |
1400 | ntmp = find_better_arrow (arrow, target, type, &i); |
1316 | ntmp = find_better_arrow (arrow, target, type, &i); |
|
|
1317 | |
1401 | if (i > betterby) |
1318 | if (i > betterby) |
1402 | { |
1319 | { |
1403 | tmp = ntmp; |
1320 | tmp = ntmp; |
1404 | betterby = i; |
1321 | betterby = i; |
1405 | } |
1322 | } |
1406 | } |
1323 | } |
1407 | else if (arrow->type == ARROW && arrow->race == type) |
1324 | else if (arrow->type == ARROW && arrow->race == type) |
1408 | { |
1325 | { |
1409 | /* allways prefer assasination/slaying */ |
1326 | /* allways prefer assasination/slaying */ |
1410 | if (target->race && arrow->slaying && strstr (arrow->slaying, target->race)) |
1327 | if (target->race && arrow->slaying && arrow->slaying.contains (target->race)) |
1411 | { |
1328 | { |
1412 | if (arrow->attacktype & AT_DEATH) |
1329 | if (arrow->attacktype & AT_DEATH) |
1413 | { |
1330 | { |
1414 | *better = 100; |
1331 | *better = 100; |
1415 | return arrow; |
1332 | return arrow; |
… | |
… | |
1430 | { |
1347 | { |
1431 | tmp = arrow; |
1348 | tmp = arrow; |
1432 | betterby = (arrow->magic + arrow->stats.dam) * (100 - target->arch->resist[attacknum]) / 100; |
1349 | betterby = (arrow->magic + arrow->stats.dam) * (100 - target->arch->resist[attacknum]) / 100; |
1433 | } |
1350 | } |
1434 | } |
1351 | } |
|
|
1352 | |
1435 | if ((2 + arrow->magic + arrow->stats.dam) > betterby) |
1353 | if ((2 + arrow->magic + arrow->stats.dam) > betterby) |
1436 | { |
1354 | { |
1437 | tmp = arrow; |
1355 | tmp = arrow; |
1438 | betterby = 2 + arrow->magic + arrow->stats.dam; |
1356 | betterby = 2 + arrow->magic + arrow->stats.dam; |
1439 | } |
1357 | } |
|
|
1358 | |
1440 | if (arrow->title && (1 + arrow->magic + arrow->stats.dam) > betterby) |
1359 | if (arrow->title && (1 + arrow->magic + arrow->stats.dam) > betterby) |
1441 | { |
1360 | { |
1442 | tmp = arrow; |
1361 | tmp = arrow; |
1443 | betterby = 1 + arrow->magic + arrow->stats.dam; |
1362 | betterby = 1 + arrow->magic + arrow->stats.dam; |
1444 | } |
1363 | } |
1445 | } |
1364 | } |
1446 | } |
1365 | } |
1447 | } |
1366 | } |
|
|
1367 | |
1448 | if (tmp == NULL && arrow == NULL) |
1368 | if (tmp == NULL && arrow == NULL) |
1449 | return find_arrow (op, type); |
1369 | return find_arrow (op, type); |
1450 | |
1370 | |
1451 | *better = betterby; |
1371 | *better = betterby; |
1452 | return tmp; |
1372 | return tmp; |
… | |
… | |
1457 | * op = the shooter |
1377 | * op = the shooter |
1458 | * type = bow->race |
1378 | * type = bow->race |
1459 | * dir = fire direction |
1379 | * dir = fire direction |
1460 | */ |
1380 | */ |
1461 | object * |
1381 | object * |
1462 | pick_arrow_target (object *op, const char *type, int dir) |
1382 | pick_arrow_target (object *op, shstr_cmp type, int dir) |
1463 | { |
1383 | { |
1464 | object *tmp = NULL; |
1384 | object *tmp = NULL; |
1465 | maptile *m; |
1385 | maptile *m; |
1466 | int i, mflags, found, number; |
1386 | int i, mflags, found, number; |
1467 | sint16 x, y; |
1387 | sint16 x, y; |
… | |
… | |
1482 | for (i = 0, found = 0; i < 20; i++) |
1402 | for (i = 0, found = 0; i < 20; i++) |
1483 | { |
1403 | { |
1484 | x += freearr_x[dir]; |
1404 | x += freearr_x[dir]; |
1485 | y += freearr_y[dir]; |
1405 | y += freearr_y[dir]; |
1486 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
1406 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
|
|
1407 | |
1487 | if (mflags & P_OUT_OF_MAP || mflags & P_BLOCKSVIEW) |
1408 | if (mflags & P_OUT_OF_MAP || mflags & P_BLOCKSVIEW) |
1488 | { |
1409 | { |
1489 | tmp = NULL; |
1410 | tmp = 0; |
1490 | break; |
1411 | break; |
1491 | } |
1412 | } |
1492 | else if (GET_MAP_MOVE_BLOCK (m, x, y) == MOVE_FLY_LOW) |
1413 | else if (GET_MAP_MOVE_BLOCK (m, x, y) == MOVE_FLY_LOW) |
1493 | { |
1414 | { |
1494 | /* This block presumes arrows and the like are MOVE_FLY_SLOW - |
1415 | /* This block presumes arrows and the like are MOVE_FLY_SLOW - |
1495 | * perhaps a bad assumption. |
1416 | * perhaps a bad assumption. |
1496 | */ |
1417 | */ |
1497 | tmp = NULL; |
1418 | tmp = 0; |
1498 | break; |
1419 | break; |
1499 | } |
1420 | } |
|
|
1421 | |
1500 | if (mflags & P_IS_ALIVE) |
1422 | if (mflags & P_IS_ALIVE) |
1501 | { |
|
|
1502 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
1423 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
1503 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
1424 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
1504 | { |
|
|
1505 | found++; |
|
|
1506 | break; |
|
|
1507 | } |
|
|
1508 | if (found) |
|
|
1509 | break; |
1425 | break; |
1510 | } |
|
|
1511 | } |
1426 | } |
1512 | if (tmp == NULL) |
1427 | |
|
|
1428 | if (!tmp) |
1513 | return find_arrow (op, type); |
1429 | return find_arrow (op, type); |
1514 | |
1430 | |
1515 | if (tmp->head) |
1431 | if (tmp->head) |
1516 | tmp = tmp->head; |
1432 | tmp = tmp->head; |
1517 | |
1433 | |
… | |
… | |
1562 | if (bow->below) |
1478 | if (bow->below) |
1563 | { |
1479 | { |
1564 | bow->remove (); |
1480 | bow->remove (); |
1565 | op->insert (bow); |
1481 | op->insert (bow); |
1566 | } |
1482 | } |
1567 | |
|
|
1568 | } |
1483 | } |
1569 | |
1484 | |
1570 | if (!bow->race || !bow->skill) |
1485 | if (!bow->race || !bow->skill) |
1571 | { |
1486 | { |
1572 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1487 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
… | |
… | |
1598 | } |
1513 | } |
1599 | |
1514 | |
1600 | /* this should not happen, but sometimes does */ |
1515 | /* this should not happen, but sometimes does */ |
1601 | if (arrow->nrof == 0) |
1516 | if (arrow->nrof == 0) |
1602 | { |
1517 | { |
|
|
1518 | LOG (llevError | logBacktrace, "arrow (%s) has nrof 0\n", arrow->debug_desc ()); |
1603 | arrow->destroy (); |
1519 | arrow->destroy (); |
1604 | return 0; |
1520 | return 0; |
1605 | } |
1521 | } |
1606 | |
1522 | |
1607 | left = arrow; /* these are arrows left to the player */ |
1523 | left = arrow; /* these are arrows left to the player */ |
… | |
… | |
1694 | * hence the function name. |
1610 | * hence the function name. |
1695 | */ |
1611 | */ |
1696 | int |
1612 | int |
1697 | player_fire_bow (object *op, int dir) |
1613 | player_fire_bow (object *op, int dir) |
1698 | { |
1614 | { |
1699 | int ret = 0, wcmod = 0; |
1615 | int ret; |
1700 | |
1616 | |
1701 | if (op->contr->bowtype == bow_bestarrow) |
1617 | if (op->contr->bowtype == bow_bestarrow) |
1702 | { |
1618 | { |
1703 | ret = fire_bow (op, op, pick_arrow_target (op, op->contr->ranged_ob->race, dir), dir, 0, op->x, op->y); |
1619 | ret = fire_bow (op, op, pick_arrow_target (op, op->contr->ranged_ob->race, dir), dir, 0, op->x, op->y); |
1704 | } |
1620 | } |
1705 | else if (op->contr->bowtype >= bow_n && op->contr->bowtype <= bow_nw) |
1621 | else if (op->contr->bowtype >= bow_n && op->contr->bowtype <= bow_nw) |
1706 | { |
1622 | { |
1707 | if (!similar_direction (dir, op->contr->bowtype - bow_n + 1)) |
1623 | int wcmod = similar_direction (dir, op->contr->bowtype - bow_n + 1) ? 0 : -1; |
1708 | wcmod = -1; |
|
|
1709 | |
|
|
1710 | ret = fire_bow (op, op, NULL, op->contr->bowtype - bow_n + 1, wcmod, op->x, op->y); |
1624 | ret = fire_bow (op, op, NULL, op->contr->bowtype - bow_n + 1, wcmod, op->x, op->y); |
1711 | } |
1625 | } |
1712 | else if (op->contr->bowtype == bow_threewide) |
1626 | else if (op->contr->bowtype == bow_threewide) |
1713 | { |
1627 | { |
1714 | ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1628 | ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1715 | ret |= fire_bow (op, op, NULL, dir, -5, op->x + freearr_x[absdir (dir + 2)], op->y + freearr_y[absdir (dir + 2)]); |
1629 | ret |= fire_bow (op, op, NULL, dir, -5, op->x + freearr_x[absdir (dir + 2)], op->y + freearr_y[absdir (dir + 2)]); |
1716 | ret |= fire_bow (op, op, NULL, dir, -5, op->x + freearr_x[absdir (dir - 2)], op->y + freearr_y[absdir (dir - 2)]); |
1630 | ret |= fire_bow (op, op, NULL, dir, -5, op->x + freearr_x[absdir (dir - 2)], op->y + freearr_y[absdir (dir - 2)]); |
1717 | } |
1631 | } |
1718 | else if (op->contr->bowtype == bow_spreadshot) |
1632 | else if (op->contr->bowtype == bow_spreadshot) |
1719 | { |
1633 | { |
1720 | ret |= fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1634 | ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1721 | ret |= fire_bow (op, op, NULL, absdir (dir - 1), -5, op->x, op->y); |
1635 | ret |= fire_bow (op, op, NULL, absdir (dir - 1), -5, op->x, op->y); |
1722 | ret |= fire_bow (op, op, NULL, absdir (dir + 1), -5, op->x, op->y); |
1636 | ret |= fire_bow (op, op, NULL, absdir (dir + 1), -5, op->x, op->y); |
1723 | } |
1637 | } |
1724 | else |
1638 | else |
1725 | { |
1639 | { |
… | |
… | |
1782 | } |
1696 | } |
1783 | } |
1697 | } |
1784 | |
1698 | |
1785 | if (cast_spell (op, item, dir, item->inv, NULL)) |
1699 | if (cast_spell (op, item, dir, item->inv, NULL)) |
1786 | { |
1700 | { |
1787 | SET_FLAG (op, FLAG_BEEN_APPLIED); /* You now know something about it */ |
1701 | item->flag [FLAG_BEEN_APPLIED] = true; /* You now know something about it */ |
|
|
1702 | |
1788 | if (item->type == WAND) |
1703 | if (item->type == WAND) |
1789 | { |
1704 | { |
1790 | if (!(--item->stats.food)) |
1705 | if (!(--item->stats.food)) |
1791 | { |
1706 | { |
1792 | object *tmp; |
1707 | object *tmp; |
… | |
… | |
1812 | bool |
1727 | bool |
1813 | fire (object *op, int dir) |
1728 | fire (object *op, int dir) |
1814 | { |
1729 | { |
1815 | int spellcost = 0; |
1730 | int spellcost = 0; |
1816 | |
1731 | |
1817 | /* check for loss of invisiblity/hide */ |
|
|
1818 | if (action_makes_visible (op)) |
|
|
1819 | make_visible (op); |
|
|
1820 | |
|
|
1821 | player *pl = op->contr; |
1732 | player *pl = op->contr; |
1822 | |
1733 | |
1823 | if (pl->golem) |
1734 | if (pl->golem) |
1824 | { |
1735 | { |
1825 | control_golem (op->contr->golem, dir); |
1736 | control_golem (op->contr->golem, dir); |
… | |
… | |
1827 | } |
1738 | } |
1828 | |
1739 | |
1829 | object *ob = pl->ranged_ob; |
1740 | object *ob = pl->ranged_ob; |
1830 | |
1741 | |
1831 | if (!ob) |
1742 | if (!ob) |
1832 | return false; |
|
|
1833 | |
|
|
1834 | if (!op->change_weapon (ob)) |
|
|
1835 | return false; |
1743 | return false; |
1836 | |
1744 | |
1837 | if (op->speed_left > 0.f) |
1745 | if (op->speed_left > 0.f) |
1838 | --op->speed_left; |
1746 | --op->speed_left; |
1839 | else |
1747 | else |
1840 | return false; |
1748 | return false; |
|
|
1749 | |
|
|
1750 | if (!op->change_weapon (ob)) |
|
|
1751 | return false; |
|
|
1752 | |
|
|
1753 | /* check for loss of invisiblity/hide */ |
|
|
1754 | if (action_makes_visible (op)) |
|
|
1755 | make_visible (op); |
1841 | |
1756 | |
1842 | switch (ob->type) |
1757 | switch (ob->type) |
1843 | { |
1758 | { |
1844 | case BOW: |
1759 | case BOW: |
1845 | player_fire_bow (op, dir); |
1760 | player_fire_bow (op, dir); |
… | |
… | |
1938 | * Change the color so that the message doesn't disappear with |
1853 | * Change the color so that the message doesn't disappear with |
1939 | * all the others. |
1854 | * all the others. |
1940 | */ |
1855 | */ |
1941 | if (pl->contr->usekeys == key_inventory || |
1856 | if (pl->contr->usekeys == key_inventory || |
1942 | !QUERY_FLAG (container, FLAG_APPLIED) || |
1857 | !QUERY_FLAG (container, FLAG_APPLIED) || |
1943 | (pl->contr->usekeys == keyrings && (!container->race || strcmp (container->race, "keys")))) |
1858 | (pl->contr->usekeys == keyrings && container->race != shstr_keys)) |
1944 | { |
1859 | { |
1945 | new_draw_info_format (NDI_UNIQUE | NDI_BROWN, 0, pl, |
1860 | new_draw_info_format (NDI_UNIQUE | NDI_BROWN, 0, pl, |
1946 | "The %s in your %s vibrates as you approach the door", query_name (tmp), query_name (container)); |
1861 | "The %s in your %s vibrates as you approach the door", query_name (tmp), query_name (container)); |
1947 | return NULL; |
1862 | return NULL; |
1948 | } |
1863 | } |
… | |
… | |
2090 | --op->speed_left; |
2005 | --op->speed_left; |
2091 | |
2006 | |
2092 | op->play_sound (sound_find ("push_player")); |
2007 | op->play_sound (sound_find ("push_player")); |
2093 | push_ob (mon, dir, op); |
2008 | push_ob (mon, dir, op); |
2094 | |
2009 | |
2095 | if (op->contr->tmp_invis || op->hide) |
2010 | if (action_makes_visible (op)) |
2096 | make_visible (op); |
2011 | make_visible (op); |
2097 | |
2012 | |
2098 | return true; |
2013 | return true; |
2099 | } |
2014 | } |
2100 | else |
2015 | else |
… | |
… | |
2122 | push_ob (mon, dir, op); |
2037 | push_ob (mon, dir, op); |
2123 | } |
2038 | } |
2124 | else |
2039 | else |
2125 | op->statusmsg ("You withhold your attack"); |
2040 | op->statusmsg ("You withhold your attack"); |
2126 | |
2041 | |
2127 | if (op->contr->tmp_invis || op->hide) |
2042 | if (op->contr->tmp_invis || op->flag [FLAG_HIDDEN]) |
2128 | make_visible (op); |
2043 | make_visible (op); |
2129 | |
2044 | |
2130 | return true; |
2045 | return true; |
2131 | } |
2046 | } |
2132 | } |
2047 | } |
… | |
… | |
2190 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2105 | if (QUERY_FLAG (op, FLAG_CONFUSED) && dir) |
2191 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2106 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
2192 | |
2107 | |
2193 | op->facing = dir; |
2108 | op->facing = dir; |
2194 | |
2109 | |
2195 | if (op->hide) |
2110 | if (op->flag [FLAG_HIDDEN]) |
2196 | do_hidden_move (op); |
2111 | do_hidden_move (op); |
2197 | |
2112 | |
2198 | bool retval; |
2113 | bool retval; |
2199 | |
2114 | |
2200 | if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) |
2115 | if (INVOKE_PLAYER (MOVE, op->contr, ARG_INT (dir))) |
… | |
… | |
2331 | const char * |
2246 | const char * |
2332 | gravestone_text (object *op) |
2247 | gravestone_text (object *op) |
2333 | { |
2248 | { |
2334 | static dynbuf_text buf; |
2249 | static dynbuf_text buf; |
2335 | |
2250 | |
2336 | buf << "---- R.I.P. ----\n\n"; |
2251 | buf << "---- R.I.P. ----\n\n" |
2337 | op->name; |
2252 | << op->name; |
2338 | |
2253 | |
2339 | if (op->type == PLAYER) |
2254 | if (op->type == PLAYER) |
2340 | buf << " the " << op->contr->title; |
2255 | buf << " the " << op->contr->title; |
2341 | |
2256 | |
2342 | buf << "\n\n"; |
2257 | buf << "\n\n"; |
… | |
… | |
2518 | { |
2433 | { |
2519 | over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp; |
2434 | over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp; |
2520 | |
2435 | |
2521 | if (over_hp > 0) |
2436 | if (over_hp > 0) |
2522 | { |
2437 | { |
2523 | op->stats.sp += over_hp + (RANDOM () % rate_hp > ((gen_hp < 20 ? 30 : gen_hp + 10) % rate_hp)) ? -1 : 0; |
2438 | op->stats.sp += over_hp + (rndm (rate_hp) > ((gen_hp < 20 ? 30 : gen_hp + 10) % rate_hp)) ? -1 : 0; |
2524 | op->last_heal = 0; |
2439 | op->last_heal = 0; |
2525 | } |
2440 | } |
2526 | else |
2441 | else |
2527 | op->last_heal = rate_hp / (gen_hp < 20 ? 30 : gen_hp + 10); |
2442 | op->last_heal = rate_hp / (gen_hp < 20 ? 30 : gen_hp + 10); |
2528 | } |
2443 | } |
… | |
… | |
2544 | op->stats.food--; |
2459 | op->stats.food--; |
2545 | } |
2460 | } |
2546 | |
2461 | |
2547 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2462 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2548 | { |
2463 | { |
2549 | object *tmp, *flesh = 0; |
2464 | object *flesh = 0; |
2550 | |
2465 | |
2551 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2466 | for_inv_removable (op, tmp) |
2552 | { |
2467 | { |
2553 | if (!QUERY_FLAG (tmp, FLAG_UNPAID)) |
2468 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
|
|
2469 | continue; |
|
|
2470 | |
|
|
2471 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2554 | { |
2472 | { |
2555 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
2473 | op->statusmsg ("You blindly grab for a bite of food. " |
2556 | { |
2474 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2557 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
|
|
2558 | manual_apply (op, tmp, 0); |
2475 | manual_apply (op, tmp, 0); |
|
|
2476 | |
2559 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2477 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2560 | break; |
2478 | break; |
2561 | } |
2479 | } |
2562 | else if (tmp->type == FLESH) |
2480 | else if (tmp->type == FLESH) |
2563 | flesh = tmp; |
2481 | flesh = tmp; |
2564 | } /* End if paid for object */ |
2482 | } |
2565 | } /* end of for loop */ |
|
|
2566 | |
2483 | |
2567 | /* If player is still starving, it means they don't have any food, so |
2484 | /* If player is still starving, it means they don't have any food, so |
2568 | * eat flesh instead. |
2485 | * eat flesh instead. |
2569 | */ |
2486 | */ |
2570 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2487 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2571 | { |
2488 | { |
2572 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2489 | op->statusmsg ("You blindly grab for a bite of food. " |
|
|
2490 | "H<To prevent you from starving, you ate some random item from your backpack.>"); |
2573 | manual_apply (op, flesh, 0); |
2491 | manual_apply (op, flesh, 0); |
2574 | } |
2492 | } |
|
|
2493 | |
|
|
2494 | // If player is still starving, alert him! |
|
|
2495 | if (op->stats.food < 0) |
|
|
2496 | op->failmsg ("You are starving! " |
|
|
2497 | "H<Eat some food to increase your food and prevent you from an untimely death.>"); |
2575 | } |
2498 | } |
2576 | |
2499 | |
2577 | if (op->stats.food < 0) |
2500 | if (op->stats.food < 0) |
2578 | { |
2501 | { |
2579 | op->stats.hp += op->stats.food; |
2502 | op->stats.hp += op->stats.food; |
2580 | op->stats.food = 0; |
2503 | op->stats.food = 0; |
|
|
2504 | |
|
|
2505 | if (op->stats.hp < 0) |
|
|
2506 | { |
|
|
2507 | op->contr->killer = archetype::get ("killer_starvation"); |
|
|
2508 | op->contr->killer->destroy (); |
2581 | } |
2509 | } |
|
|
2510 | } |
2582 | |
2511 | |
|
|
2512 | /* killer should be set here already */ |
2583 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2513 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2584 | kill_player (op); |
2514 | kill_player (op); |
2585 | } |
2515 | } |
2586 | } |
2516 | } |
2587 | |
2517 | |
… | |
… | |
2601 | object *tmp; |
2531 | object *tmp; |
2602 | |
2532 | |
2603 | if (save_life (op)) |
2533 | if (save_life (op)) |
2604 | return; |
2534 | return; |
2605 | |
2535 | |
|
|
2536 | /* restore player */ |
|
|
2537 | at = archetype::find ("poisoning"); |
|
|
2538 | if (object *tmp = present_arch_in_ob (at, op)) |
|
|
2539 | { |
|
|
2540 | tmp->destroy (); |
|
|
2541 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
|
|
2542 | } |
|
|
2543 | |
|
|
2544 | at = archetype::find ("confusion"); |
|
|
2545 | if (object *tmp = present_arch_in_ob (at, op)) |
|
|
2546 | { |
|
|
2547 | tmp->destroy (); |
|
|
2548 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
|
|
2549 | } |
|
|
2550 | |
|
|
2551 | cure_disease (op, 0, 0); /* remove any disease */ |
|
|
2552 | |
|
|
2553 | max_it (op->stats.hp , op->stats.maxhp); |
|
|
2554 | max_it (op->stats.sp , op->stats.maxsp); |
|
|
2555 | max_it (op->stats.grace, op->stats.maxgrace); |
|
|
2556 | |
|
|
2557 | if (op->stats.food <= 0) |
|
|
2558 | op->stats.food = 999; |
|
|
2559 | |
|
|
2560 | // remove all spell effects that are active |
|
|
2561 | // to avoid long-term effects such as word-of-recall |
|
|
2562 | for (object *item = op->inv; item; ) |
|
|
2563 | { |
|
|
2564 | object *next = item->below; |
|
|
2565 | |
|
|
2566 | if (item->type == SPELL_EFFECT && item->active) |
|
|
2567 | item->destroy (); |
|
|
2568 | |
|
|
2569 | item = next; |
|
|
2570 | } |
|
|
2571 | |
2606 | /* If player dies on BATTLEGROUND, no stat/exp loss! For Combat-Arenas |
2572 | /* If player dies on BATTLEGROUND, no stat/exp loss! For Combat-Arenas |
2607 | * in cities ONLY!!! It is very important that this doesn't get abused. |
2573 | * in cities ONLY!!! It is very important that this doesn't get abused. |
2608 | * Look at op_on_battleground() for more info --AndreasV |
2574 | * Look at op_on_battleground() for more info --AndreasV |
2609 | */ |
2575 | */ |
2610 | if (op_on_battleground (op, &x, &y)) |
2576 | if (op_on_battleground (op, &x, &y)) |
2611 | { |
2577 | { |
2612 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2578 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); |
2613 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
2579 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); |
2614 | |
|
|
2615 | /* restore player */ |
|
|
2616 | at = archetype::find ("poisoning"); |
|
|
2617 | if (object *tmp = present_arch_in_ob (at, op)) |
|
|
2618 | { |
|
|
2619 | tmp->destroy (); |
|
|
2620 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
|
|
2621 | } |
|
|
2622 | |
|
|
2623 | at = archetype::find ("confusion"); |
|
|
2624 | if (object *tmp = present_arch_in_ob (at, op)) |
|
|
2625 | { |
|
|
2626 | tmp->destroy (); |
|
|
2627 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
|
|
2628 | } |
|
|
2629 | |
|
|
2630 | cure_disease (op, 0, 0); /* remove any disease */ |
|
|
2631 | op->stats.hp = op->stats.maxhp; |
|
|
2632 | if (op->stats.food <= 0) |
|
|
2633 | op->stats.food = 999; |
|
|
2634 | |
2580 | |
2635 | /* create a bodypart-trophy to make the winner happy */ |
2581 | /* create a bodypart-trophy to make the winner happy */ |
2636 | if (object *tmp = arch_to_object (archetype::find ("finger"))) |
2582 | if (object *tmp = arch_to_object (archetype::find ("finger"))) |
2637 | { |
2583 | { |
2638 | tmp->name = format ("%s's finger" , &op->name); |
2584 | tmp->name = format ("%s's finger" , &op->name); |
… | |
… | |
2656 | |
2602 | |
2657 | INVOKE_PLAYER (DEATH, op->contr); |
2603 | INVOKE_PLAYER (DEATH, op->contr); |
2658 | |
2604 | |
2659 | command_kill_pets (op, 0); |
2605 | command_kill_pets (op, 0); |
2660 | |
2606 | |
2661 | if (op->stats.food < 0) |
|
|
2662 | { |
|
|
2663 | op->contr->killer = archetype::get ("killer_starvation"); |
|
|
2664 | op->contr->killer->destroy (); |
|
|
2665 | } |
|
|
2666 | |
|
|
2667 | op->contr->play_sound (sound_find ("player_dies")); |
2607 | op->contr->play_sound (sound_find ("player_dies")); |
2668 | |
2608 | |
2669 | /* save the map location for corpse, gravestone */ |
2609 | /* save the map location for corpse, gravestone */ |
2670 | x = op->x; |
2610 | x = op->x; |
2671 | y = op->y; |
2611 | y = op->y; |
… | |
… | |
2700 | |
2640 | |
2701 | lost_a_stat = 0; |
2641 | lost_a_stat = 0; |
2702 | |
2642 | |
2703 | for (z = 0; z < num_stats_lose; z++) |
2643 | for (z = 0; z < num_stats_lose; z++) |
2704 | { |
2644 | { |
2705 | i = RANDOM () % NUM_STATS; |
2645 | i = rndm (NUM_STATS); |
2706 | |
2646 | |
2707 | if (settings.stat_loss_on_death) |
2647 | if (settings.stat_loss_on_death) |
2708 | { |
2648 | { |
2709 | /* Pick a random stat and take a point off it. Tell the player |
2649 | /* Pick a random stat and take a point off it. Tell the player |
2710 | * what he lost. |
2650 | * what he lost. |
… | |
… | |
2761 | } |
2701 | } |
2762 | } |
2702 | } |
2763 | |
2703 | |
2764 | if (lose_this_stat) |
2704 | if (lose_this_stat) |
2765 | { |
2705 | { |
2766 | this_stat = get_attr_value (&(dep->stats), i); |
2706 | this_stat = get_attr_value (&dep->stats, i); |
2767 | /* We could try to do something clever like find another |
2707 | /* We could try to do something clever like find another |
2768 | * stat to reduce if this fails. But chances are, if |
2708 | * stat to reduce if this fails. But chances are, if |
2769 | * stats have been depleted to -50, all are pretty low |
2709 | * stats have been depleted to -50, all are pretty low |
2770 | * and should be roughly the same, so it shouldn't make a |
2710 | * and should be roughly the same, so it shouldn't make a |
2771 | * difference. |
2711 | * difference. |
… | |
… | |
2779 | lost_a_stat = 1; |
2719 | lost_a_stat = 1; |
2780 | } |
2720 | } |
2781 | } |
2721 | } |
2782 | } |
2722 | } |
2783 | } |
2723 | } |
|
|
2724 | |
2784 | /* If no stat lost, tell the player. */ |
2725 | /* If no stat lost, tell the player. */ |
2785 | if (!lost_a_stat) |
2726 | if (!lost_a_stat) |
2786 | { |
2727 | { |
2787 | /* determine_god() seems to not work sometimes... why is this? |
2728 | /* determine_god() seems to not work sometimes... why is this? |
2788 | Should I be using something else? GD */ |
2729 | Should I be using something else? GD */ |
2789 | const char *god = determine_god (op); |
2730 | shstr_tmp god = determine_god (op); |
2790 | |
2731 | |
2791 | if (god && (strcmp (god, "none"))) |
2732 | if (god != shstr_none) |
2792 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god); |
2733 | new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", &god); |
2793 | else |
2734 | else |
2794 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
2735 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you."); |
2795 | } |
2736 | } |
2796 | #else |
2737 | #else |
2797 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely."); |
2738 | new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you from losing yourself completely."); |
2798 | #endif |
2739 | #endif |
2799 | |
2740 | |
2800 | /* Put a gravestone up where the character 'almost' died. List the |
2741 | /* Put a gravestone up where the character 'almost' died. List the |
2801 | * exp loss on the stone. |
2742 | * exp loss on the stone. |
2802 | */ |
2743 | */ |
2803 | tmp = arch_to_object (archetype::find ("gravestone")); |
2744 | tmp = arch_to_object (archetype::find ("gravestone")); |
2804 | sprintf (buf, "%s's gravestone", &op->name); |
2745 | tmp->name = format ("%s's gravestone", &op->name); |
2805 | tmp->name = buf; |
2746 | tmp->name_pl = format ("%s's gravestones", &op->name); |
2806 | sprintf (buf, "%s's gravestones", &op->name); |
2747 | tmp->msg = format ("T<RIP>\n\nHere rests the hero %s the %s,\rwho was killed\rby %s.\n", |
2807 | tmp->name_pl = buf; |
2748 | &op->name, op->contr->title, op->contr->killer_name ()); |
2808 | sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer_name ()); |
|
|
2809 | tmp->msg = buf; |
|
|
2810 | tmp->x = op->x, tmp->y = op->y; |
2749 | tmp->x = op->x, tmp->y = op->y; |
2811 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2750 | insert_ob_in_map (tmp, op->map, NULL, 0); |
2812 | |
2751 | |
2813 | /**************************************/ |
2752 | /**************************************/ |
2814 | /* */ |
2753 | /* */ |
2815 | /* Subtract the experience points, */ |
2754 | /* Subtract the experience points, */ |
2816 | /* if we died cause of food, give us */ |
|
|
2817 | /* food, and reset HP's... */ |
|
|
2818 | /* */ |
2755 | /* */ |
2819 | /**************************************/ |
2756 | /**************************************/ |
2820 | |
2757 | |
2821 | /* remove any poisoning and confusion the character may be suffering. */ |
|
|
2822 | /* restore player */ |
|
|
2823 | at = archetype::find ("poisoning"); |
|
|
2824 | tmp = present_arch_in_ob (at, op); |
|
|
2825 | |
|
|
2826 | if (tmp) |
|
|
2827 | { |
|
|
2828 | tmp->destroy (); |
|
|
2829 | new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); |
|
|
2830 | } |
|
|
2831 | |
|
|
2832 | at = archetype::find ("confusion"); |
|
|
2833 | tmp = present_arch_in_ob (at, op); |
|
|
2834 | if (tmp) |
|
|
2835 | { |
|
|
2836 | tmp->destroy (); |
|
|
2837 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
|
|
2838 | } |
|
|
2839 | |
|
|
2840 | cure_disease (op, 0, 0); /* remove any disease */ |
|
|
2841 | |
|
|
2842 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2758 | /*add_exp(op, (op->stats.exp * -0.20)); */ |
2843 | apply_death_exp_penalty (op); |
2759 | apply_death_exp_penalty (op); |
2844 | if (op->stats.food < 100) |
|
|
2845 | op->stats.food = 900; |
|
|
2846 | op->stats.hp = op->stats.maxhp; |
|
|
2847 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
|
|
2848 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
|
|
2849 | |
2760 | |
2850 | /* |
2761 | /* |
2851 | * Check to see if the player has any unpaid items. If so, remove them |
2762 | * Check to see if the player has any unpaid items. If so, remove them |
2852 | * and put them back in the map. |
2763 | * and put them back in the map. |
2853 | */ |
2764 | */ |
… | |
… | |
2888 | if (will_kill_again & (1 << at)) |
2799 | if (will_kill_again & (1 << at)) |
2889 | force->resist[at] = 100; |
2800 | force->resist[at] = 100; |
2890 | |
2801 | |
2891 | insert_ob_in_ob (force, op); |
2802 | insert_ob_in_ob (force, op); |
2892 | op->update_stats (); |
2803 | op->update_stats (); |
2893 | |
|
|
2894 | } |
2804 | } |
2895 | |
2805 | |
2896 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
2806 | new_draw_info (NDI_UNIQUE, 0, op, "YOU HAVE DIED."); |
2897 | } |
2807 | } |
2898 | |
2808 | |
… | |
… | |
2999 | } |
2909 | } |
3000 | |
2910 | |
3001 | void |
2911 | void |
3002 | make_visible (object *op) |
2912 | make_visible (object *op) |
3003 | { |
2913 | { |
3004 | op->hide = 0; |
2914 | op->flag [FLAG_HIDDEN] = 0; |
3005 | op->invisible = 0; |
2915 | op->invisible = 0; |
3006 | |
2916 | |
3007 | if (op->type == PLAYER) |
2917 | if (op->type == PLAYER) |
3008 | { |
2918 | { |
3009 | op->contr->tmp_invis = 0; |
2919 | op->contr->tmp_invis = 0; |
… | |
… | |
3034 | |
2944 | |
3035 | if (!ob || !ob->map) |
2945 | if (!ob || !ob->map) |
3036 | return 0; |
2946 | return 0; |
3037 | |
2947 | |
3038 | /* so, on normal lighted maps, its hard to hide */ |
2948 | /* so, on normal lighted maps, its hard to hide */ |
3039 | level = ob->map->darkness - 2; |
2949 | level = ob->map->darklevel () - 2; |
3040 | |
2950 | |
3041 | /* this also picks up whether the object is glowing. |
2951 | /* this also picks up whether the object is glowing. |
3042 | * If you carry a light on a non-dark map, its not |
2952 | * If you carry a light on a non-dark map, its not |
3043 | * as bad as carrying a light on a pitch dark map */ |
2953 | * as bad as carrying a light on a pitch dark map */ |
3044 | if (has_carried_lights (ob)) |
2954 | if (has_carried_lights (ob)) |
3045 | level = -(10 + (2 * ob->map->darkness)); |
2955 | level = -(10 + (2 * ob->map->darklevel ())); |
3046 | |
2956 | |
3047 | /* scan through all nearby squares for terrain to hide in */ |
2957 | /* scan through all nearby squares for terrain to hide in */ |
3048 | for (i = 0, x = ob->x, y = ob->y; |
2958 | for (i = 0, x = ob->x, y = ob->y; |
3049 | i <= SIZEOFFREE1; |
2959 | i <= SIZEOFFREE1; |
3050 | i++, x = ob->x + freearr_x[i], y = ob->y + freearr_y[i]) |
2960 | i++, x = ob->x + freearr_x[i], y = ob->y + freearr_y[i]) |
… | |
… | |
3071 | * spot (surrounded by clear terrain in broad daylight). -b.t. |
2981 | * spot (surrounded by clear terrain in broad daylight). -b.t. |
3072 | */ |
2982 | */ |
3073 | void |
2983 | void |
3074 | do_hidden_move (object *op) |
2984 | do_hidden_move (object *op) |
3075 | { |
2985 | { |
3076 | int hide = 0, num = random_roll (0, 19, op, PREFER_LOW); |
2986 | int hide = 0; |
3077 | object *skop; |
|
|
3078 | |
2987 | |
3079 | if (!op || !op->map) |
2988 | if (!op || !op->map) |
3080 | return; |
2989 | return; |
3081 | |
2990 | |
3082 | skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); |
2991 | object *skop = find_obj_by_type_subtype (op, SKILL, SK_HIDING); |
|
|
2992 | int num = random_roll (0, 19, op, PREFER_LOW); |
3083 | |
2993 | |
3084 | /* its *extremely* hard to run and sneak/hide at the same time! */ |
2994 | /* its *extremely* hard to run and sneak/hide at the same time! */ |
3085 | if (op->type == PLAYER && op->contr->run_on) |
2995 | if (op->type == PLAYER && op->contr->run_on) |
3086 | if (!skop || num >= skop->level) |
2996 | if (!skop || num >= skop->level) |
3087 | { |
2997 | { |
… | |
… | |
3097 | num -= hide; |
3007 | num -= hide; |
3098 | |
3008 | |
3099 | if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) |
3009 | if ((op->type == PLAYER && hide < -10) || ((op->invisible -= num) <= 0)) |
3100 | { |
3010 | { |
3101 | make_visible (op); |
3011 | make_visible (op); |
|
|
3012 | |
3102 | if (op->type == PLAYER) |
3013 | if (op->type == PLAYER) |
3103 | new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); |
3014 | new_draw_info (NDI_UNIQUE, 0, op, "You moved out of hiding! You are visible!"); |
3104 | } |
3015 | } |
3105 | else if (op->type == PLAYER && skop) |
3016 | else if (op->type == PLAYER && skop) |
3106 | change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); |
3017 | change_exp (op, calc_skill_exp (op, NULL, skop), skop->skill, 0); |
… | |
… | |
3196 | while (op) |
3107 | while (op) |
3197 | { |
3108 | { |
3198 | dx = rv.distance_x + op->arch->x; |
3109 | dx = rv.distance_x + op->arch->x; |
3199 | dy = rv.distance_y + op->arch->y; |
3110 | dy = rv.distance_y + op->arch->y; |
3200 | |
3111 | |
3201 | /* only the viewable area the player sees is updated by LOS |
3112 | if (pl->contr->blocked_los (dx, dy) != LOS_BLOCKED) |
3202 | * code, so we need to restrict ourselves to that range of values |
|
|
3203 | * for any meaningful values. |
|
|
3204 | */ |
|
|
3205 | if (abs (dx) <= (pl->contr->ns->mapx / 2) && |
|
|
3206 | abs (dy) <= (pl->contr->ns->mapy / 2) && |
|
|
3207 | !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)]) |
|
|
3208 | return 1; |
3113 | return 1; |
3209 | |
3114 | |
3210 | op = op->more; |
3115 | op = op->more; |
3211 | } |
3116 | } |
3212 | |
3117 | |
3213 | return 0; |
3118 | return 0; |
3214 | } |
3119 | } |
3215 | |
3120 | |
3216 | /* routine for both players and monsters. We call this when |
3121 | /* routine for both players and monsters. We call this when |
3217 | * there is a possibility for our action distrubing our hiding |
3122 | * there is a possibility for our action distrubing our hiding |
3218 | * place or invisiblity spell. Artefact invisiblity is not |
3123 | * place or invisiblity spell. Artefact invisiblity causes |
3219 | * effected by this. If we arent invisible to begin with, we |
3124 | * "noise" instead. If we arent invisible to begin with, we |
3220 | * return 0. |
3125 | * return 0. |
3221 | */ |
3126 | */ |
3222 | int |
3127 | int |
3223 | action_makes_visible (object *op) |
3128 | action_makes_visible (object *op) |
3224 | { |
3129 | { |
3225 | if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) |
3130 | if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) |
3226 | { |
3131 | { |
3227 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
3132 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
|
|
3133 | { |
|
|
3134 | // artefact invisibility is permanent, but we still make noise |
|
|
3135 | // this is important for game-balance. |
|
|
3136 | if (op->contr) |
|
|
3137 | op->make_noise (); |
|
|
3138 | |
3228 | return 0; |
3139 | return 0; |
|
|
3140 | } |
3229 | |
3141 | |
3230 | if (op->contr && op->contr->tmp_invis == 0) |
3142 | if (op->contr && op->contr->tmp_invis == 0) |
3231 | return 0; |
3143 | return 0; |
3232 | |
3144 | |
3233 | /* If monsters, they should become visible */ |
3145 | /* If monsters, they should become visible */ |
3234 | if (op->hide || !op->contr || (op->contr && op->contr->tmp_invis)) |
3146 | if (op->flag [FLAG_HIDDEN] || !op->contr || (op->contr && op->contr->tmp_invis)) |
3235 | { |
3147 | { |
3236 | new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->hide ? "unhidden" : "visible"); |
3148 | new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->flag [FLAG_HIDDEN] ? "unhidden" : "visible"); |
3237 | return 1; |
3149 | return 1; |
3238 | } |
3150 | } |
3239 | } |
3151 | } |
3240 | |
3152 | |
3241 | return 0; |
3153 | return 0; |
… | |
… | |
3469 | if (pl->ranged_ob == ob) |
3381 | if (pl->ranged_ob == ob) |
3470 | pl->ranged_ob = 0; |
3382 | pl->ranged_ob = 0; |
3471 | } |
3383 | } |
3472 | |
3384 | |
3473 | sint8 |
3385 | sint8 |
3474 | player::visibility_at (maptile *map, int x, int y) const |
3386 | player::darkness_at (maptile *map, int x, int y) const |
3475 | { |
3387 | { |
3476 | if (!ns) |
3388 | if (!ns) |
3477 | return 0; |
3389 | return LOS_BLOCKED; |
3478 | |
3390 | |
3479 | int dx, dy; |
3391 | int dx, dy; |
3480 | if (!adjacent_map (map, ns->current_map, &dx, &dy)) |
3392 | if (!adjacent_map (map, ns->current_map, &dx, &dy)) |
3481 | return 0; |
3393 | return LOS_BLOCKED; |
3482 | |
3394 | |
3483 | x += dx - ns->current_x + ns->mapx / 2; |
3395 | x += dx - ns->current_x; |
3484 | y += dy - ns->current_y + ns->mapy / 2; |
3396 | y += dy - ns->current_y; |
3485 | |
3397 | |
3486 | if (!IN_RANGE_EXC (x, 0, ns->mapx) || !IN_RANGE_EXC (y, 0, ns->mapy)) |
|
|
3487 | return 0; |
|
|
3488 | |
|
|
3489 | return 100 - blocked_los [x][y]; |
3398 | return blocked_los (x, y); |
3490 | } |
3399 | } |
3491 | |
3400 | |
3492 | void |
3401 | void |
3493 | player::infobox (const char *title, const char *msg, int color) |
3402 | player::infobox (const char *title, const char *msg, int color) |
3494 | { |
3403 | { |