… | |
… | |
321 | combat_ob = op; |
321 | combat_ob = op; |
322 | break; |
322 | break; |
323 | } |
323 | } |
324 | |
324 | |
325 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
325 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
|
|
326 | ob->deactivate (); // change_Weapon activates, fix this better |
326 | } |
327 | } |
327 | |
328 | |
328 | void |
329 | void |
329 | player::set_observe (object *op) |
330 | player::set_observe (object *op) |
330 | { |
331 | { |
… | |
… | |
631 | |
632 | |
632 | return firstdir; |
633 | return firstdir; |
633 | } |
634 | } |
634 | |
635 | |
635 | void |
636 | void |
636 | give_initial_items (object *pl, treasurelist * items) |
637 | give_initial_items (object *pl, treasurelist *items) |
637 | { |
638 | { |
638 | object *op, *next = NULL; |
|
|
639 | |
|
|
640 | if (pl->randomitems != NULL) |
639 | if (pl->randomitems) |
641 | create_treasure (items, pl, GT_STARTEQUIP | GT_ONLY_GOOD, 1, 0); |
640 | create_treasure (items, pl, GT_STARTEQUIP | GT_ONLY_GOOD, 1, 0); |
642 | |
641 | |
643 | for (op = pl->inv; op; op = next) |
642 | for (object *next, *op = pl->inv; op; op = next) |
644 | { |
643 | { |
645 | next = op->below; |
644 | next = op->below; |
646 | |
645 | |
647 | /* Forces get applied per default, unless they have the |
646 | /* Forces get applied per default, unless they have the |
648 | * flag "neutral" set. Sorry but I can't think of a better way |
647 | * flag "neutral" set. Sorry but I can't think of a better way |
… | |
… | |
653 | /* we never give weapons/armour if these cannot be used |
652 | /* we never give weapons/armour if these cannot be used |
654 | * by this player due to race restrictions |
653 | * by this player due to race restrictions |
655 | */ |
654 | */ |
656 | if (pl->type == PLAYER) |
655 | if (pl->type == PLAYER) |
657 | { |
656 | { |
658 | if ((!QUERY_FLAG (pl, FLAG_USE_ARMOUR) && |
657 | if ((!QUERY_FLAG (pl, FLAG_USE_ARMOUR) |
|
|
658 | && |
659 | (op->type == ARMOUR || op->type == BOOTS || |
659 | (op->type == ARMOUR || op->type == BOOTS |
660 | op->type == CLOAK || op->type == HELMET || |
660 | || op->type == CLOAK || op->type == HELMET |
661 | op->type == SHIELD || op->type == GLOVES || |
661 | || op->type == SHIELD || op->type == GLOVES |
|
|
662 | || op->type == BRACERS || op->type == GIRDLE)) |
662 | op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
663 | || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) |
663 | { |
664 | { |
664 | op->destroy (); |
665 | op->destroy (); |
665 | continue; |
666 | continue; |
666 | } |
667 | } |
667 | } |
668 | } |
… | |
… | |
690 | if (op->nrof > 1) |
691 | if (op->nrof > 1) |
691 | op->nrof = 1; |
692 | op->nrof = 1; |
692 | } |
693 | } |
693 | |
694 | |
694 | if (op->type == SPELLBOOK && op->inv) |
695 | if (op->type == SPELLBOOK && op->inv) |
695 | { |
|
|
696 | CLEAR_FLAG (op->inv, FLAG_STARTEQUIP); |
696 | CLEAR_FLAG (op->inv, FLAG_STARTEQUIP); |
697 | } |
|
|
698 | |
697 | |
699 | /* Give starting characters identified, uncursed, and undamned |
698 | /* Give starting characters identified, uncursed, and undamned |
700 | * items. Just don't identify gold or silver, or it won't be |
699 | * items. Just don't identify gold or silver, or it won't be |
701 | * merged properly. |
700 | * merged properly. |
702 | */ |
701 | */ |
703 | if (need_identify (op)) |
702 | if (need_identify (op)) |
704 | { |
703 | { |
705 | SET_FLAG (op, FLAG_IDENTIFIED); |
704 | SET_FLAG (op, FLAG_IDENTIFIED); |
706 | CLEAR_FLAG (op, FLAG_CURSED); |
705 | CLEAR_FLAG (op, FLAG_CURSED); |
707 | CLEAR_FLAG (op, FLAG_DAMNED); |
706 | CLEAR_FLAG (op, FLAG_DAMNED); |
708 | } |
707 | } |
|
|
708 | |
709 | if (op->type == SPELL) |
709 | if (op->type == SPELL) |
710 | { |
710 | { |
711 | op->destroy (); |
711 | op->destroy (); |
712 | continue; |
712 | continue; |
713 | } |
713 | } |
… | |
… | |
715 | { |
715 | { |
716 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
716 | SET_FLAG (op, FLAG_CAN_USE_SKILL); |
717 | op->stats.exp = 0; |
717 | op->stats.exp = 0; |
718 | op->level = 1; |
718 | op->level = 1; |
719 | } |
719 | } |
720 | /* lock all 'normal items by default */ |
720 | else /* lock all 'normal items by default */ |
721 | else |
|
|
722 | SET_FLAG (op, FLAG_INV_LOCKED); |
721 | SET_FLAG (op, FLAG_INV_LOCKED); |
723 | } /* for loop of objects in player inv */ |
722 | } /* for loop of objects in player inv */ |
724 | |
723 | |
725 | /* Need to set up the skill pointers */ |
724 | /* Need to set up the skill pointers */ |
726 | link_player_skills (pl); |
725 | link_player_skills (pl); |
… | |
… | |
832 | static void |
831 | static void |
833 | start_info (object *op) |
832 | start_info (object *op) |
834 | { |
833 | { |
835 | char buf[MAX_BUF]; |
834 | char buf[MAX_BUF]; |
836 | |
835 | |
837 | sprintf (buf, "Welcome to Crossfire v%s!", VERSION); |
836 | sprintf (buf, "Welcome to Deliantra v%s!", VERSION); |
838 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
837 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
839 | //new_draw_info (NDI_UNIQUE, 0, op, "Press `?' for help"); |
|
|
840 | //new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
841 | } |
838 | } |
842 | |
839 | |
843 | /* This function takes the key that is passed, and does the |
840 | /* This function takes the key that is passed, and does the |
844 | * appropriate action with it (change race, or other things). |
841 | * appropriate action with it (change race, or other things). |
845 | * The function name is for historical reasons - now we have |
842 | * The function name is for historical reasons - now we have |
… | |
… | |
1008 | if (op->move_type & MOVE_FLYING) |
1005 | if (op->move_type & MOVE_FLYING) |
1009 | return 1; |
1006 | return 1; |
1010 | |
1007 | |
1011 | next = op->below; |
1008 | next = op->below; |
1012 | |
1009 | |
|
|
1010 | int cnt = MAX_ITEM_PER_DROP; |
|
|
1011 | #define CHK_PICK_PICKUP do { pick_up (op, tmp); cnt--; } while (0) |
|
|
1012 | |
1013 | /* loop while there are items on the floor that are not marked as |
1013 | /* loop while there are items on the floor that are not marked as |
1014 | * destroyed */ |
1014 | * destroyed */ |
1015 | while (next && !next->destroyed ()) |
1015 | while (next && !next->destroyed ()) |
1016 | { |
1016 | { |
1017 | tmp = next; |
1017 | tmp = next; |
1018 | next = tmp->below; |
1018 | next = tmp->below; |
1019 | |
1019 | |
|
|
1020 | if (cnt <= 0) |
|
|
1021 | { |
|
|
1022 | op->failmsg ("Couldn't pickup all items at once."); |
|
|
1023 | return 0; |
|
|
1024 | } |
|
|
1025 | |
1020 | if (op->destroyed ()) |
1026 | if (op->destroyed ()) |
1021 | return 0; |
1027 | return 0; |
1022 | |
1028 | |
1023 | if (!can_pick (op, tmp)) |
1029 | if (!can_pick (op, tmp)) |
1024 | continue; |
1030 | continue; |
1025 | |
1031 | |
1026 | if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) |
1032 | if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) |
1027 | { |
1033 | { |
1028 | if (item_matched_string (op, tmp, op->contr->search_str)) |
1034 | if (item_matched_string (op, tmp, op->contr->search_str)) |
1029 | pick_up (op, tmp); |
1035 | CHK_PICK_PICKUP; |
1030 | continue; |
1036 | continue; |
1031 | } |
1037 | } |
1032 | |
1038 | |
1033 | /* high not bit set? We're using the old autopickup model */ |
1039 | /* high not bit set? We're using the old autopickup model */ |
1034 | if (!(op->contr->mode & PU_NEWMODE)) |
1040 | if (!(op->contr->mode & PU_NEWMODE)) |
… | |
… | |
1036 | switch (op->contr->mode) |
1042 | switch (op->contr->mode) |
1037 | { |
1043 | { |
1038 | case 0: |
1044 | case 0: |
1039 | return 1; /* don't pick up */ |
1045 | return 1; /* don't pick up */ |
1040 | case 1: |
1046 | case 1: |
1041 | pick_up (op, tmp); |
1047 | CHK_PICK_PICKUP; |
1042 | return 1; |
1048 | return 1; |
1043 | case 2: |
1049 | case 2: |
1044 | pick_up (op, tmp); |
1050 | CHK_PICK_PICKUP; |
1045 | return 0; |
1051 | return 0; |
1046 | case 3: |
1052 | case 3: |
1047 | return 0; /* stop before pickup */ |
1053 | return 0; /* stop before pickup */ |
1048 | case 4: |
1054 | case 4: |
1049 | pick_up (op, tmp); |
1055 | CHK_PICK_PICKUP; |
1050 | break; |
1056 | break; |
1051 | case 5: |
1057 | case 5: |
1052 | pick_up (op, tmp); |
1058 | CHK_PICK_PICKUP; |
1053 | stop = 1; |
1059 | stop = 1; |
1054 | break; |
1060 | break; |
1055 | case 6: |
1061 | case 6: |
1056 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1062 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) |
1057 | pick_up (op, tmp); |
1063 | && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
|
|
1064 | CHK_PICK_PICKUP; |
1058 | break; |
1065 | break; |
1059 | |
1066 | |
1060 | case 7: |
1067 | case 7: |
1061 | if (tmp->type == MONEY || tmp->type == GEM) |
1068 | if (tmp->type == MONEY || tmp->type == GEM) |
1062 | pick_up (op, tmp); |
1069 | CHK_PICK_PICKUP; |
1063 | break; |
1070 | break; |
1064 | |
1071 | |
1065 | default: |
1072 | default: |
1066 | /* use value density */ |
1073 | /* use value density */ |
1067 | if (!QUERY_FLAG (tmp, FLAG_UNPAID) |
1074 | if (!QUERY_FLAG (tmp, FLAG_UNPAID) |
1068 | && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) |
1075 | && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) |
1069 | pick_up (op, tmp); |
1076 | CHK_PICK_PICKUP; |
1070 | } |
1077 | } |
1071 | } |
1078 | } |
1072 | else |
1079 | else |
1073 | { /* old model */ |
1080 | { /* old model */ |
1074 | /* NEW pickup handling */ |
1081 | /* NEW pickup handling */ |
… | |
… | |
1129 | /* all food and drink if desired */ |
1136 | /* all food and drink if desired */ |
1130 | /* question: don't pick up known-poisonous stuff? */ |
1137 | /* question: don't pick up known-poisonous stuff? */ |
1131 | if (op->contr->mode & PU_FOOD) |
1138 | if (op->contr->mode & PU_FOOD) |
1132 | if (tmp->type == FOOD) |
1139 | if (tmp->type == FOOD) |
1133 | { |
1140 | { |
1134 | pick_up (op, tmp); |
1141 | CHK_PICK_PICKUP; |
1135 | continue; |
1142 | continue; |
1136 | } |
1143 | } |
1137 | |
1144 | |
1138 | if (op->contr->mode & PU_DRINK) |
1145 | if (op->contr->mode & PU_DRINK) |
1139 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1146 | if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) |
1140 | { |
1147 | { |
1141 | pick_up (op, tmp); |
1148 | CHK_PICK_PICKUP; |
1142 | continue; |
1149 | continue; |
1143 | } |
1150 | } |
1144 | |
1151 | |
1145 | if (op->contr->mode & PU_POTION) |
1152 | if (op->contr->mode & PU_POTION) |
1146 | if (tmp->type == POTION) |
1153 | if (tmp->type == POTION) |
1147 | { |
1154 | { |
1148 | pick_up (op, tmp); |
1155 | CHK_PICK_PICKUP; |
1149 | continue; |
1156 | continue; |
1150 | } |
1157 | } |
1151 | |
1158 | |
1152 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1159 | /* spellbooks, skillscrolls and normal books/scrolls */ |
1153 | if (op->contr->mode & PU_SPELLBOOK) |
1160 | if (op->contr->mode & PU_SPELLBOOK) |
1154 | if (tmp->type == SPELLBOOK) |
1161 | if (tmp->type == SPELLBOOK) |
1155 | { |
1162 | { |
1156 | pick_up (op, tmp); |
1163 | CHK_PICK_PICKUP; |
1157 | continue; |
1164 | continue; |
1158 | } |
1165 | } |
1159 | |
1166 | |
1160 | if (op->contr->mode & PU_SKILLSCROLL) |
1167 | if (op->contr->mode & PU_SKILLSCROLL) |
1161 | if (tmp->type == SKILLSCROLL) |
1168 | if (tmp->type == SKILLSCROLL) |
1162 | { |
1169 | { |
1163 | pick_up (op, tmp); |
1170 | CHK_PICK_PICKUP; |
1164 | continue; |
1171 | continue; |
1165 | } |
1172 | } |
1166 | |
1173 | |
1167 | if (op->contr->mode & PU_READABLES) |
1174 | if (op->contr->mode & PU_READABLES) |
1168 | if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE) |
1175 | if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE) |
1169 | { |
1176 | { |
1170 | pick_up (op, tmp); |
1177 | CHK_PICK_PICKUP; |
1171 | continue; |
1178 | continue; |
1172 | } |
1179 | } |
1173 | |
1180 | |
1174 | /* wands/staves/rods/horns */ |
1181 | /* wands/staves/rods/horns */ |
1175 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1182 | if (op->contr->mode & PU_MAGIC_DEVICE) |
1176 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1183 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) |
1177 | { |
1184 | { |
1178 | pick_up (op, tmp); |
1185 | CHK_PICK_PICKUP; |
1179 | continue; |
1186 | continue; |
1180 | } |
1187 | } |
1181 | |
1188 | |
1182 | /* pick up all magical items */ |
1189 | /* pick up all magical items */ |
1183 | if (op->contr->mode & PU_MAGICAL) |
1190 | if (op->contr->mode & PU_MAGICAL) |
1184 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1191 | if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) |
1185 | { |
1192 | { |
1186 | pick_up (op, tmp); |
1193 | CHK_PICK_PICKUP; |
1187 | continue; |
1194 | continue; |
1188 | } |
1195 | } |
1189 | |
1196 | |
1190 | if (op->contr->mode & PU_VALUABLES) |
1197 | if (op->contr->mode & PU_VALUABLES) |
1191 | { |
1198 | { |
1192 | if (tmp->type == MONEY || tmp->type == GEM) |
1199 | if (tmp->type == MONEY || tmp->type == GEM) |
1193 | { |
1200 | { |
1194 | pick_up (op, tmp); |
1201 | CHK_PICK_PICKUP; |
1195 | continue; |
1202 | continue; |
1196 | } |
1203 | } |
1197 | } |
1204 | } |
1198 | |
1205 | |
1199 | /* rings & amulets - talismans seems to be typed AMULET */ |
1206 | /* rings & amulets - talismans seems to be typed AMULET */ |
1200 | if (op->contr->mode & PU_JEWELS) |
1207 | if (op->contr->mode & PU_JEWELS) |
1201 | if (tmp->type == RING || tmp->type == AMULET) |
1208 | if (tmp->type == RING || tmp->type == AMULET) |
1202 | { |
1209 | { |
1203 | pick_up (op, tmp); |
1210 | CHK_PICK_PICKUP; |
1204 | continue; |
1211 | continue; |
1205 | } |
1212 | } |
1206 | |
1213 | |
1207 | /* we don't forget dragon food */ |
1214 | /* we don't forget dragon food */ |
1208 | if (op->contr->mode & PU_FLESH) |
1215 | if (op->contr->mode & PU_FLESH) |
1209 | if (tmp->type == FLESH) |
1216 | if (tmp->type == FLESH) |
1210 | { |
1217 | { |
1211 | pick_up (op, tmp); |
1218 | CHK_PICK_PICKUP; |
1212 | continue; |
1219 | continue; |
1213 | } |
1220 | } |
1214 | |
1221 | |
1215 | /* bows and arrows. Bows are good for selling! */ |
1222 | /* bows and arrows. Bows are good for selling! */ |
1216 | if (op->contr->mode & PU_BOW) |
1223 | if (op->contr->mode & PU_BOW) |
1217 | if (tmp->type == BOW) |
1224 | if (tmp->type == BOW) |
1218 | { |
1225 | { |
1219 | pick_up (op, tmp); |
1226 | CHK_PICK_PICKUP; |
1220 | continue; |
1227 | continue; |
1221 | } |
1228 | } |
1222 | |
1229 | |
1223 | if (op->contr->mode & PU_ARROW) |
1230 | if (op->contr->mode & PU_ARROW) |
1224 | if (tmp->type == ARROW) |
1231 | if (tmp->type == ARROW) |
1225 | { |
1232 | { |
1226 | pick_up (op, tmp); |
1233 | CHK_PICK_PICKUP; |
1227 | continue; |
1234 | continue; |
1228 | } |
1235 | } |
1229 | |
1236 | |
1230 | /* all kinds of armor etc. */ |
1237 | /* all kinds of armor etc. */ |
1231 | if (op->contr->mode & PU_ARMOUR) |
1238 | if (op->contr->mode & PU_ARMOUR) |
1232 | if (tmp->type == ARMOUR) |
1239 | if (tmp->type == ARMOUR) |
1233 | { |
1240 | { |
1234 | pick_up (op, tmp); |
1241 | CHK_PICK_PICKUP; |
1235 | continue; |
1242 | continue; |
1236 | } |
1243 | } |
1237 | |
1244 | |
1238 | if (op->contr->mode & PU_HELMET) |
1245 | if (op->contr->mode & PU_HELMET) |
1239 | if (tmp->type == HELMET) |
1246 | if (tmp->type == HELMET) |
1240 | { |
1247 | { |
1241 | pick_up (op, tmp); |
1248 | CHK_PICK_PICKUP; |
1242 | continue; |
1249 | continue; |
1243 | } |
1250 | } |
1244 | |
1251 | |
1245 | if (op->contr->mode & PU_SHIELD) |
1252 | if (op->contr->mode & PU_SHIELD) |
1246 | if (tmp->type == SHIELD) |
1253 | if (tmp->type == SHIELD) |
1247 | { |
1254 | { |
1248 | pick_up (op, tmp); |
1255 | CHK_PICK_PICKUP; |
1249 | continue; |
1256 | continue; |
1250 | } |
1257 | } |
1251 | |
1258 | |
1252 | if (op->contr->mode & PU_BOOTS) |
1259 | if (op->contr->mode & PU_BOOTS) |
1253 | if (tmp->type == BOOTS) |
1260 | if (tmp->type == BOOTS) |
1254 | { |
1261 | { |
1255 | pick_up (op, tmp); |
1262 | CHK_PICK_PICKUP; |
1256 | continue; |
1263 | continue; |
1257 | } |
1264 | } |
1258 | |
1265 | |
1259 | if (op->contr->mode & PU_GLOVES) |
1266 | if (op->contr->mode & PU_GLOVES) |
1260 | if (tmp->type == GLOVES) |
1267 | if (tmp->type == GLOVES) |
1261 | { |
1268 | { |
1262 | pick_up (op, tmp); |
1269 | CHK_PICK_PICKUP; |
1263 | continue; |
1270 | continue; |
1264 | } |
1271 | } |
1265 | |
1272 | |
1266 | if (op->contr->mode & PU_CLOAK) |
1273 | if (op->contr->mode & PU_CLOAK) |
1267 | if (tmp->type == CLOAK) |
1274 | if (tmp->type == CLOAK) |
1268 | { |
1275 | { |
1269 | pick_up (op, tmp); |
1276 | CHK_PICK_PICKUP; |
1270 | continue; |
1277 | continue; |
1271 | } |
1278 | } |
1272 | |
1279 | |
1273 | /* hoping to catch throwing daggers here */ |
1280 | /* hoping to catch throwing daggers here */ |
1274 | if (op->contr->mode & PU_MISSILEWEAPON) |
1281 | if (op->contr->mode & PU_MISSILEWEAPON) |
1275 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1282 | if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) |
1276 | { |
1283 | { |
1277 | pick_up (op, tmp); |
1284 | CHK_PICK_PICKUP; |
1278 | continue; |
1285 | continue; |
1279 | } |
1286 | } |
1280 | |
1287 | |
1281 | /* careful: chairs and tables are weapons! */ |
1288 | /* careful: chairs and tables are weapons! */ |
1282 | if (op->contr->mode & PU_ALLWEAPON) |
1289 | if (op->contr->mode & PU_ALLWEAPON) |
… | |
… | |
1284 | if (tmp->type == WEAPON && tmp->name != NULL) |
1291 | if (tmp->type == WEAPON && tmp->name != NULL) |
1285 | { |
1292 | { |
1286 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL && |
1293 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL && |
1287 | strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL) |
1294 | strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL) |
1288 | { |
1295 | { |
1289 | pick_up (op, tmp); |
1296 | CHK_PICK_PICKUP; |
1290 | continue; |
1297 | continue; |
1291 | } |
1298 | } |
1292 | } |
1299 | } |
1293 | |
1300 | |
1294 | if (tmp->type == WEAPON && tmp->name == NULL) |
1301 | if (tmp->type == WEAPON && tmp->name == NULL) |
1295 | { |
1302 | { |
1296 | if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL) |
1303 | if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL) |
1297 | { |
1304 | { |
1298 | pick_up (op, tmp); |
1305 | CHK_PICK_PICKUP; |
1299 | continue; |
1306 | continue; |
1300 | } |
1307 | } |
1301 | } |
1308 | } |
1302 | } |
1309 | } |
1303 | |
1310 | |
1304 | /* misc stuff that's useful */ |
1311 | /* misc stuff that's useful */ |
1305 | if (op->contr->mode & PU_KEY) |
1312 | if (op->contr->mode & PU_KEY) |
1306 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1313 | if (tmp->type == KEY || tmp->type == SPECIAL_KEY) |
1307 | { |
1314 | { |
1308 | pick_up (op, tmp); |
1315 | CHK_PICK_PICKUP; |
1309 | continue; |
1316 | continue; |
1310 | } |
1317 | } |
1311 | |
1318 | |
1312 | /* any of the last 4 bits set means we use the ratio for value |
1319 | /* any of the last 4 bits set means we use the ratio for value |
1313 | * pickups */ |
1320 | * pickups */ |
… | |
… | |
1318 | /* >=7 is the old standard setting. Now we take the last 4 bits |
1325 | /* >=7 is the old standard setting. Now we take the last 4 bits |
1319 | * and multiply them by 5, giving 0..15*5== 5..75 */ |
1326 | * and multiply them by 5, giving 0..15*5== 5..75 */ |
1320 | wvratio = (op->contr->mode & PU_RATIO) * 5; |
1327 | wvratio = (op->contr->mode & PU_RATIO) * 5; |
1321 | if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio) |
1328 | if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio) |
1322 | { |
1329 | { |
1323 | pick_up (op, tmp); |
1330 | CHK_PICK_PICKUP; |
1324 | #if 0 |
1331 | #if 0 |
1325 | fprintf (stderr, "HIGH WEIGHT/VALUE ["); |
1332 | fprintf (stderr, "HIGH WEIGHT/VALUE ["); |
1326 | if (tmp->name != NULL) |
1333 | if (tmp->name != NULL) |
1327 | { |
1334 | { |
1328 | fprintf (stderr, "%s", tmp->name); |
1335 | fprintf (stderr, "%s", tmp->name); |
… | |
… | |
1347 | * found object is returned. |
1354 | * found object is returned. |
1348 | */ |
1355 | */ |
1349 | object * |
1356 | object * |
1350 | find_arrow (object *op, const char *type) |
1357 | find_arrow (object *op, const char *type) |
1351 | { |
1358 | { |
1352 | object *tmp = 0; |
|
|
1353 | |
|
|
1354 | for (op = op->inv; op; op = op->below) |
1359 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
1355 | if (!tmp && op->type == CONTAINER && op->race == type && QUERY_FLAG (op, FLAG_APPLIED)) |
|
|
1356 | tmp = find_arrow (splay (op), type); |
|
|
1357 | else if (op->type == ARROW && op->race == type) |
1360 | if (tmp->type == ARROW && !strcmp (&tmp->race, type)) |
1358 | return splay (op); |
1361 | return splay (tmp); |
1359 | |
1362 | |
|
|
1363 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
|
|
1364 | if (tmp->type == CONTAINER && QUERY_FLAG (tmp, FLAG_APPLIED) && !strcmp (&tmp->race, type)) |
|
|
1365 | if (object *arrow = find_arrow (tmp, type)) |
|
|
1366 | { |
|
|
1367 | splay (tmp); |
|
|
1368 | return arrow; |
|
|
1369 | } |
|
|
1370 | |
1360 | return tmp; |
1371 | return 0; |
1361 | } |
1372 | } |
1362 | |
1373 | |
1363 | /* |
1374 | /* |
1364 | * Similar to find_arrow, but looks for (roughly) the best arrow to use |
1375 | * Similar to find_arrow, but looks for (roughly) the best arrow to use |
1365 | * against the target. A full test is not performed, simply a basic test |
1376 | * against the target. A full test is not performed, simply a basic test |
… | |
… | |
2164 | bool |
2175 | bool |
2165 | move_player (object *op, int dir) |
2176 | move_player (object *op, int dir) |
2166 | { |
2177 | { |
2167 | int pick; |
2178 | int pick; |
2168 | |
2179 | |
2169 | if (!op->map || op->map->in_memory != MAP_IN_MEMORY) |
2180 | if (!op->map || op->map->in_memory != MAP_ACTIVE) |
2170 | return 0; |
2181 | return 0; |
2171 | |
2182 | |
2172 | /* Sanity check: make sure dir is valid */ |
2183 | /* Sanity check: make sure dir is valid */ |
2173 | if ((dir < 0) || (dir >= 9)) |
2184 | if ((dir < 0) || (dir >= 9)) |
2174 | { |
2185 | { |
… | |
… | |
3040 | * as bad as carrying a light on a pitch dark map */ |
3051 | * as bad as carrying a light on a pitch dark map */ |
3041 | if (has_carried_lights (ob)) |
3052 | if (has_carried_lights (ob)) |
3042 | level = -(10 + (2 * ob->map->darkness)); |
3053 | level = -(10 + (2 * ob->map->darkness)); |
3043 | |
3054 | |
3044 | /* scan through all nearby squares for terrain to hide in */ |
3055 | /* scan through all nearby squares for terrain to hide in */ |
3045 | for (i = 0, x = ob->x, y = ob->y; i < 9; i++, x = ob->x + freearr_x[i], y = ob->y + freearr_y[i]) |
3056 | for (i = 0, x = ob->x, y = ob->y; |
|
|
3057 | i <= SIZEOFFREE1; |
|
|
3058 | i++, x = ob->x + freearr_x[i], y = ob->y + freearr_y[i]) |
3046 | { |
3059 | { |
3047 | mflag = get_map_flags (ob->map, NULL, x, y, NULL, NULL); |
3060 | mflag = get_map_flags (ob->map, NULL, x, y, NULL, NULL); |
3048 | if (mflag & P_OUT_OF_MAP) |
3061 | if (mflag & P_OUT_OF_MAP) |
3049 | { |
|
|
3050 | continue; |
3062 | continue; |
3051 | } |
3063 | |
3052 | if (mflag & P_BLOCKSVIEW) /* something to hide near! */ |
3064 | if (mflag & P_BLOCKSVIEW) /* something to hide near! */ |
3053 | level += 2; |
3065 | level += 2; |
3054 | else /* open terrain! */ |
3066 | else /* open terrain! */ |
3055 | level -= 1; |
3067 | level -= 1; |
3056 | } |
3068 | } |