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.181 by root, Tue Apr 15 14:21:04 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines