ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/player.C
(Generate patch)

Comparing deliantra/server/server/player.C (file contents):
Revision 1.174 by root, Thu Nov 8 19:43:27 2007 UTC vs.
Revision 1.178 by root, Sat Jan 5 06:11:28 2008 UTC

633} 633}
634 634
635void 635void
636give_initial_items (object *pl, treasurelist * items) 636give_initial_items (object *pl, treasurelist * items)
637{ 637{
638 object *op, *next = NULL;
639
640 if (pl->randomitems != NULL) 638 if (pl->randomitems)
641 create_treasure (items, pl, GT_STARTEQUIP | GT_ONLY_GOOD, 1, 0); 639 create_treasure (items, pl, GT_STARTEQUIP | GT_ONLY_GOOD, 1, 0);
642 640
643 for (op = pl->inv; op; op = next) 641 for (object *next, *op = pl->inv; op; op = next)
644 { 642 {
645 next = op->below; 643 next = op->below;
646 644
647 /* Forces get applied per default, unless they have the 645 /* Forces get applied per default, unless they have the
648 * flag "neutral" set. Sorry but I can't think of a better way 646 * flag "neutral" set. Sorry but I can't think of a better way
690 if (op->nrof > 1) 688 if (op->nrof > 1)
691 op->nrof = 1; 689 op->nrof = 1;
692 } 690 }
693 691
694 if (op->type == SPELLBOOK && op->inv) 692 if (op->type == SPELLBOOK && op->inv)
695 {
696 CLEAR_FLAG (op->inv, FLAG_STARTEQUIP); 693 CLEAR_FLAG (op->inv, FLAG_STARTEQUIP);
697 }
698 694
699 /* Give starting characters identified, uncursed, and undamned 695 /* Give starting characters identified, uncursed, and undamned
700 * items. Just don't identify gold or silver, or it won't be 696 * items. Just don't identify gold or silver, or it won't be
701 * merged properly. 697 * merged properly.
702 */ 698 */
832static void 828static void
833start_info (object *op) 829start_info (object *op)
834{ 830{
835 char buf[MAX_BUF]; 831 char buf[MAX_BUF];
836 832
837 sprintf (buf, "Welcome to Crossfire v%s!", VERSION); 833 sprintf (buf, "Welcome to Deliantra v%s!", VERSION);
838 new_draw_info (NDI_UNIQUE, 0, op, buf); 834 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} 835}
842 836
843/* This function takes the key that is passed, and does the 837/* This function takes the key that is passed, and does the
844 * appropriate action with it (change race, or other things). 838 * appropriate action with it (change race, or other things).
845 * The function name is for historical reasons - now we have 839 * The function name is for historical reasons - now we have
1008 if (op->move_type & MOVE_FLYING) 1002 if (op->move_type & MOVE_FLYING)
1009 return 1; 1003 return 1;
1010 1004
1011 next = op->below; 1005 next = op->below;
1012 1006
1007 int cnt = MAX_ITEM_PER_DROP;
1008#define CHK_PICK_PICKUP do { pick_up (op, tmp); cnt--; } while (0)
1009
1013 /* loop while there are items on the floor that are not marked as 1010 /* loop while there are items on the floor that are not marked as
1014 * destroyed */ 1011 * destroyed */
1015 while (next && !next->destroyed ()) 1012 while (next && !next->destroyed ())
1016 { 1013 {
1017 tmp = next; 1014 tmp = next;
1018 next = tmp->below; 1015 next = tmp->below;
1019 1016
1017 if (cnt <= 0)
1018 {
1019 op->failmsg ("Couldn't pickup all items at once.");
1020 return 0;
1021 }
1022
1020 if (op->destroyed ()) 1023 if (op->destroyed ())
1021 return 0; 1024 return 0;
1022 1025
1023 if (!can_pick (op, tmp)) 1026 if (!can_pick (op, tmp))
1024 continue; 1027 continue;
1025 1028
1026 if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE) 1029 if (op->contr->search_str[0] != '\0' && settings.search_items == TRUE)
1027 { 1030 {
1028 if (item_matched_string (op, tmp, op->contr->search_str)) 1031 if (item_matched_string (op, tmp, op->contr->search_str))
1029 pick_up (op, tmp); 1032 CHK_PICK_PICKUP;
1030 continue; 1033 continue;
1031 } 1034 }
1032 1035
1033 /* high not bit set? We're using the old autopickup model */ 1036 /* high not bit set? We're using the old autopickup model */
1034 if (!(op->contr->mode & PU_NEWMODE)) 1037 if (!(op->contr->mode & PU_NEWMODE))
1036 switch (op->contr->mode) 1039 switch (op->contr->mode)
1037 { 1040 {
1038 case 0: 1041 case 0:
1039 return 1; /* don't pick up */ 1042 return 1; /* don't pick up */
1040 case 1: 1043 case 1:
1041 pick_up (op, tmp); 1044 CHK_PICK_PICKUP;
1042 return 1; 1045 return 1;
1043 case 2: 1046 case 2:
1044 pick_up (op, tmp); 1047 CHK_PICK_PICKUP;
1045 return 0; 1048 return 0;
1046 case 3: 1049 case 3:
1047 return 0; /* stop before pickup */ 1050 return 0; /* stop before pickup */
1048 case 4: 1051 case 4:
1049 pick_up (op, tmp); 1052 CHK_PICK_PICKUP;
1050 break; 1053 break;
1051 case 5: 1054 case 5:
1052 pick_up (op, tmp); 1055 CHK_PICK_PICKUP;
1053 stop = 1; 1056 stop = 1;
1054 break; 1057 break;
1055 case 6: 1058 case 6:
1056 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) 1059 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL)
1057 pick_up (op, tmp); 1060 && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1061 CHK_PICK_PICKUP;
1058 break; 1062 break;
1059 1063
1060 case 7: 1064 case 7:
1061 if (tmp->type == MONEY || tmp->type == GEM) 1065 if (tmp->type == MONEY || tmp->type == GEM)
1062 pick_up (op, tmp); 1066 CHK_PICK_PICKUP;
1063 break; 1067 break;
1064 1068
1065 default: 1069 default:
1066 /* use value density */ 1070 /* use value density */
1067 if (!QUERY_FLAG (tmp, FLAG_UNPAID) 1071 if (!QUERY_FLAG (tmp, FLAG_UNPAID)
1068 && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode) 1072 && (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= op->contr->mode)
1069 pick_up (op, tmp); 1073 CHK_PICK_PICKUP;
1070 } 1074 }
1071 } 1075 }
1072 else 1076 else
1073 { /* old model */ 1077 { /* old model */
1074 /* NEW pickup handling */ 1078 /* NEW pickup handling */
1129 /* all food and drink if desired */ 1133 /* all food and drink if desired */
1130 /* question: don't pick up known-poisonous stuff? */ 1134 /* question: don't pick up known-poisonous stuff? */
1131 if (op->contr->mode & PU_FOOD) 1135 if (op->contr->mode & PU_FOOD)
1132 if (tmp->type == FOOD) 1136 if (tmp->type == FOOD)
1133 { 1137 {
1134 pick_up (op, tmp); 1138 CHK_PICK_PICKUP;
1135 continue; 1139 continue;
1136 } 1140 }
1137 1141
1138 if (op->contr->mode & PU_DRINK) 1142 if (op->contr->mode & PU_DRINK)
1139 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) 1143 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)))
1140 { 1144 {
1141 pick_up (op, tmp); 1145 CHK_PICK_PICKUP;
1142 continue; 1146 continue;
1143 } 1147 }
1144 1148
1145 if (op->contr->mode & PU_POTION) 1149 if (op->contr->mode & PU_POTION)
1146 if (tmp->type == POTION) 1150 if (tmp->type == POTION)
1147 { 1151 {
1148 pick_up (op, tmp); 1152 CHK_PICK_PICKUP;
1149 continue; 1153 continue;
1150 } 1154 }
1151 1155
1152 /* spellbooks, skillscrolls and normal books/scrolls */ 1156 /* spellbooks, skillscrolls and normal books/scrolls */
1153 if (op->contr->mode & PU_SPELLBOOK) 1157 if (op->contr->mode & PU_SPELLBOOK)
1154 if (tmp->type == SPELLBOOK) 1158 if (tmp->type == SPELLBOOK)
1155 { 1159 {
1156 pick_up (op, tmp); 1160 CHK_PICK_PICKUP;
1157 continue; 1161 continue;
1158 } 1162 }
1159 1163
1160 if (op->contr->mode & PU_SKILLSCROLL) 1164 if (op->contr->mode & PU_SKILLSCROLL)
1161 if (tmp->type == SKILLSCROLL) 1165 if (tmp->type == SKILLSCROLL)
1162 { 1166 {
1163 pick_up (op, tmp); 1167 CHK_PICK_PICKUP;
1164 continue; 1168 continue;
1165 } 1169 }
1166 1170
1167 if (op->contr->mode & PU_READABLES) 1171 if (op->contr->mode & PU_READABLES)
1168 if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE) 1172 if (tmp->type == BOOK || tmp->type == SCROLL || tmp->type == INSCRIBABLE)
1169 { 1173 {
1170 pick_up (op, tmp); 1174 CHK_PICK_PICKUP;
1171 continue; 1175 continue;
1172 } 1176 }
1173 1177
1174 /* wands/staves/rods/horns */ 1178 /* wands/staves/rods/horns */
1175 if (op->contr->mode & PU_MAGIC_DEVICE) 1179 if (op->contr->mode & PU_MAGIC_DEVICE)
1176 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1180 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN)
1177 { 1181 {
1178 pick_up (op, tmp); 1182 CHK_PICK_PICKUP;
1179 continue; 1183 continue;
1180 } 1184 }
1181 1185
1182 /* pick up all magical items */ 1186 /* pick up all magical items */
1183 if (op->contr->mode & PU_MAGICAL) 1187 if (op->contr->mode & PU_MAGICAL)
1184 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) 1188 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1185 { 1189 {
1186 pick_up (op, tmp); 1190 CHK_PICK_PICKUP;
1187 continue; 1191 continue;
1188 } 1192 }
1189 1193
1190 if (op->contr->mode & PU_VALUABLES) 1194 if (op->contr->mode & PU_VALUABLES)
1191 { 1195 {
1192 if (tmp->type == MONEY || tmp->type == GEM) 1196 if (tmp->type == MONEY || tmp->type == GEM)
1193 { 1197 {
1194 pick_up (op, tmp); 1198 CHK_PICK_PICKUP;
1195 continue; 1199 continue;
1196 } 1200 }
1197 } 1201 }
1198 1202
1199 /* rings & amulets - talismans seems to be typed AMULET */ 1203 /* rings & amulets - talismans seems to be typed AMULET */
1200 if (op->contr->mode & PU_JEWELS) 1204 if (op->contr->mode & PU_JEWELS)
1201 if (tmp->type == RING || tmp->type == AMULET) 1205 if (tmp->type == RING || tmp->type == AMULET)
1202 { 1206 {
1203 pick_up (op, tmp); 1207 CHK_PICK_PICKUP;
1204 continue; 1208 continue;
1205 } 1209 }
1206 1210
1207 /* we don't forget dragon food */ 1211 /* we don't forget dragon food */
1208 if (op->contr->mode & PU_FLESH) 1212 if (op->contr->mode & PU_FLESH)
1209 if (tmp->type == FLESH) 1213 if (tmp->type == FLESH)
1210 { 1214 {
1211 pick_up (op, tmp); 1215 CHK_PICK_PICKUP;
1212 continue; 1216 continue;
1213 } 1217 }
1214 1218
1215 /* bows and arrows. Bows are good for selling! */ 1219 /* bows and arrows. Bows are good for selling! */
1216 if (op->contr->mode & PU_BOW) 1220 if (op->contr->mode & PU_BOW)
1217 if (tmp->type == BOW) 1221 if (tmp->type == BOW)
1218 { 1222 {
1219 pick_up (op, tmp); 1223 CHK_PICK_PICKUP;
1220 continue; 1224 continue;
1221 } 1225 }
1222 1226
1223 if (op->contr->mode & PU_ARROW) 1227 if (op->contr->mode & PU_ARROW)
1224 if (tmp->type == ARROW) 1228 if (tmp->type == ARROW)
1225 { 1229 {
1226 pick_up (op, tmp); 1230 CHK_PICK_PICKUP;
1227 continue; 1231 continue;
1228 } 1232 }
1229 1233
1230 /* all kinds of armor etc. */ 1234 /* all kinds of armor etc. */
1231 if (op->contr->mode & PU_ARMOUR) 1235 if (op->contr->mode & PU_ARMOUR)
1232 if (tmp->type == ARMOUR) 1236 if (tmp->type == ARMOUR)
1233 { 1237 {
1234 pick_up (op, tmp); 1238 CHK_PICK_PICKUP;
1235 continue; 1239 continue;
1236 } 1240 }
1237 1241
1238 if (op->contr->mode & PU_HELMET) 1242 if (op->contr->mode & PU_HELMET)
1239 if (tmp->type == HELMET) 1243 if (tmp->type == HELMET)
1240 { 1244 {
1241 pick_up (op, tmp); 1245 CHK_PICK_PICKUP;
1242 continue; 1246 continue;
1243 } 1247 }
1244 1248
1245 if (op->contr->mode & PU_SHIELD) 1249 if (op->contr->mode & PU_SHIELD)
1246 if (tmp->type == SHIELD) 1250 if (tmp->type == SHIELD)
1247 { 1251 {
1248 pick_up (op, tmp); 1252 CHK_PICK_PICKUP;
1249 continue; 1253 continue;
1250 } 1254 }
1251 1255
1252 if (op->contr->mode & PU_BOOTS) 1256 if (op->contr->mode & PU_BOOTS)
1253 if (tmp->type == BOOTS) 1257 if (tmp->type == BOOTS)
1254 { 1258 {
1255 pick_up (op, tmp); 1259 CHK_PICK_PICKUP;
1256 continue; 1260 continue;
1257 } 1261 }
1258 1262
1259 if (op->contr->mode & PU_GLOVES) 1263 if (op->contr->mode & PU_GLOVES)
1260 if (tmp->type == GLOVES) 1264 if (tmp->type == GLOVES)
1261 { 1265 {
1262 pick_up (op, tmp); 1266 CHK_PICK_PICKUP;
1263 continue; 1267 continue;
1264 } 1268 }
1265 1269
1266 if (op->contr->mode & PU_CLOAK) 1270 if (op->contr->mode & PU_CLOAK)
1267 if (tmp->type == CLOAK) 1271 if (tmp->type == CLOAK)
1268 { 1272 {
1269 pick_up (op, tmp); 1273 CHK_PICK_PICKUP;
1270 continue; 1274 continue;
1271 } 1275 }
1272 1276
1273 /* hoping to catch throwing daggers here */ 1277 /* hoping to catch throwing daggers here */
1274 if (op->contr->mode & PU_MISSILEWEAPON) 1278 if (op->contr->mode & PU_MISSILEWEAPON)
1275 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) 1279 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN))
1276 { 1280 {
1277 pick_up (op, tmp); 1281 CHK_PICK_PICKUP;
1278 continue; 1282 continue;
1279 } 1283 }
1280 1284
1281 /* careful: chairs and tables are weapons! */ 1285 /* careful: chairs and tables are weapons! */
1282 if (op->contr->mode & PU_ALLWEAPON) 1286 if (op->contr->mode & PU_ALLWEAPON)
1284 if (tmp->type == WEAPON && tmp->name != NULL) 1288 if (tmp->type == WEAPON && tmp->name != NULL)
1285 { 1289 {
1286 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL && 1290 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL &&
1287 strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL) 1291 strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL)
1288 { 1292 {
1289 pick_up (op, tmp); 1293 CHK_PICK_PICKUP;
1290 continue; 1294 continue;
1291 } 1295 }
1292 } 1296 }
1293 1297
1294 if (tmp->type == WEAPON && tmp->name == NULL) 1298 if (tmp->type == WEAPON && tmp->name == NULL)
1295 { 1299 {
1296 if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL) 1300 if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL)
1297 { 1301 {
1298 pick_up (op, tmp); 1302 CHK_PICK_PICKUP;
1299 continue; 1303 continue;
1300 } 1304 }
1301 } 1305 }
1302 } 1306 }
1303 1307
1304 /* misc stuff that's useful */ 1308 /* misc stuff that's useful */
1305 if (op->contr->mode & PU_KEY) 1309 if (op->contr->mode & PU_KEY)
1306 if (tmp->type == KEY || tmp->type == SPECIAL_KEY) 1310 if (tmp->type == KEY || tmp->type == SPECIAL_KEY)
1307 { 1311 {
1308 pick_up (op, tmp); 1312 CHK_PICK_PICKUP;
1309 continue; 1313 continue;
1310 } 1314 }
1311 1315
1312 /* any of the last 4 bits set means we use the ratio for value 1316 /* any of the last 4 bits set means we use the ratio for value
1313 * pickups */ 1317 * pickups */
1318 /* >=7 is the old standard setting. Now we take the last 4 bits 1322 /* >=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 */ 1323 * and multiply them by 5, giving 0..15*5== 5..75 */
1320 wvratio = (op->contr->mode & PU_RATIO) * 5; 1324 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) 1325 if ((query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1))) >= (unsigned int) wvratio)
1322 { 1326 {
1323 pick_up (op, tmp); 1327 CHK_PICK_PICKUP;
1324#if 0 1328#if 0
1325 fprintf (stderr, "HIGH WEIGHT/VALUE ["); 1329 fprintf (stderr, "HIGH WEIGHT/VALUE [");
1326 if (tmp->name != NULL) 1330 if (tmp->name != NULL)
1327 { 1331 {
1328 fprintf (stderr, "%s", tmp->name); 1332 fprintf (stderr, "%s", tmp->name);
1347 * found object is returned. 1351 * found object is returned.
1348 */ 1352 */
1349object * 1353object *
1350find_arrow (object *op, const char *type) 1354find_arrow (object *op, const char *type)
1351{ 1355{
1352 object *tmp = 0;
1353
1354 for (op = op->inv; op; op = op->below) 1356 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) 1357 if (tmp->type == ARROW && !strcmp (tmp->race, type))
1358 return splay (op); 1358 return splay (tmp);
1359 1359
1360 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1361 if (tmp->type == CONTAINER && QUERY_FLAG (tmp, FLAG_APPLIED) && !strcmp (tmp->race, type))
1362 if (object *arrow = find_arrow (tmp, type))
1363 {
1364 splay (tmp);
1365 return arrow;
1366 }
1367
1360 return tmp; 1368 return 0;
1361} 1369}
1362 1370
1363/* 1371/*
1364 * Similar to find_arrow, but looks for (roughly) the best arrow to use 1372 * 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 1373 * against the target. A full test is not performed, simply a basic test

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines