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

Comparing deliantra/server/common/treasure.C (file contents):
Revision 1.22 by root, Sun Dec 10 20:15:57 2006 UTC vs.
Revision 1.28 by root, Tue Dec 26 08:54:59 2006 UTC

258 shstr_cmp name_ (name); 258 shstr_cmp name_ (name);
259 259
260 if (!name_) 260 if (!name_)
261 return 0; 261 return 0;
262 262
263 for (treasurelist * tl = first_treasurelist; tl != 0; tl = tl->next) 263 for (treasurelist *tl = first_treasurelist; tl != 0; tl = tl->next)
264 if (name_ == tl->name) 264 if (name_ == tl->name)
265 return tl; 265 return tl;
266 266
267 if (first_treasurelist) 267 if (first_treasurelist)
268 LOG (llevError, "Couldn't find treasurelist %s\n", name); 268 LOG (llevError, "Couldn't find treasurelist %s\n", name);
280 * being generated. 280 * being generated.
281 * If flag is GT_INVISIBLE, only invisible objects are generated (ie, only 281 * If flag is GT_INVISIBLE, only invisible objects are generated (ie, only
282 * abilities. This is used by summon spells, thus no summoned monsters 282 * abilities. This is used by summon spells, thus no summoned monsters
283 * start with equipment, but only their abilities). 283 * start with equipment, but only their abilities).
284 */ 284 */
285
286
287static void 285static void
288put_treasure (object *op, object *creator, int flags) 286put_treasure (object *op, object *creator, int flags)
289{ 287{
290 object *tmp; 288 object *tmp;
291 289
302 insert_ob_in_map (op, creator->map, op, INS_NO_MERGE | INS_NO_WALK_ON); 300 insert_ob_in_map (op, creator->map, op, INS_NO_MERGE | INS_NO_WALK_ON);
303 } 301 }
304 else 302 else
305 { 303 {
306 op = insert_ob_in_ob (op, creator); 304 op = insert_ob_in_ob (op, creator);
305
307 if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) 306 if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER))
308 monster_check_apply (creator, op); 307 monster_check_apply (creator, op);
308
309 if ((flags & GT_UPDATE_INV) && (tmp = is_player_inv (creator)) != NULL) 309 if ((flags & GT_UPDATE_INV) && (tmp = creator->in_player ()))
310 esrv_send_item (tmp, op); 310 esrv_send_item (tmp, op);
311 } 311 }
312} 312}
313 313
314/* if there are change_xxx commands in the treasure, we include the changes 314/* if there are change_xxx commands in the treasure, we include the changes
339 if ((int) t->chance >= 100 || (RANDOM () % 100 + 1) < (int) t->chance) 339 if ((int) t->chance >= 100 || (RANDOM () % 100 + 1) < (int) t->chance)
340 { 340 {
341 if (t->name) 341 if (t->name)
342 { 342 {
343 if (strcmp (t->name, "NONE") && difficulty >= t->magic) 343 if (strcmp (t->name, "NONE") && difficulty >= t->magic)
344 {
345 treasurelist *tl = find_treasurelist (t->name);
346 if (tl)
344 create_treasure (find_treasurelist (t->name), op, flag, difficulty, tries); 347 create_treasure (tl, op, flag, difficulty, tries);
348 }
345 } 349 }
346 else 350 else
347 { 351 {
348 if (t->item->clone.invisible != 0 || !(flag & GT_INVISIBLE)) 352 if (t->item->clone.invisible != 0 || !(flag & GT_INVISIBLE))
349 { 353 {
397 { 401 {
398 if (!strcmp (t->name, "NONE")) 402 if (!strcmp (t->name, "NONE"))
399 return; 403 return;
400 404
401 if (difficulty >= t->magic) 405 if (difficulty >= t->magic)
406 {
407 treasurelist *tl = find_treasurelist (t->name);
408 if (tl)
402 create_treasure (find_treasurelist (t->name), op, flag, difficulty, tries); 409 create_treasure (tl, op, flag, difficulty, tries);
410 }
403 else if (t->nrof) 411 else if (t->nrof)
404 create_one_treasure (tl, op, flag, difficulty, tries); 412 create_one_treasure (tl, op, flag, difficulty, tries);
405 413
406 return; 414 return;
407 } 415 }
448 * it instead takes a treasurelist. It is really just a wrapper around 456 * it instead takes a treasurelist. It is really just a wrapper around
449 * create_treasure. We create a dummy object that the treasure gets 457 * create_treasure. We create a dummy object that the treasure gets
450 * inserted into, and then return that treausre 458 * inserted into, and then return that treausre
451 */ 459 */
452object * 460object *
453generate_treasure (treasurelist * t, int difficulty) 461generate_treasure (treasurelist *t, int difficulty)
454{ 462{
463 difficulty = clamp (difficulty, 1, settings.max_level);
464
455 object *ob = get_object (), *tmp; 465 object *ob = object::create (), *tmp;
456 466
457 create_treasure (t, ob, 0, difficulty, 0); 467 create_treasure (t, ob, 0, difficulty, 0);
458 468
459 /* Don't want to free the object we are about to return */ 469 /* Don't want to free the object we are about to return */
460 tmp = ob->inv; 470 tmp = ob->inv;
461 if (tmp != NULL) 471 if (tmp != NULL)
462 remove_ob (tmp); 472 tmp->remove ();
463 473
464 if (ob->inv) 474 if (ob->inv)
465 LOG (llevError, "In generate treasure, created multiple objects.\n"); 475 LOG (llevError, "In generate treasure, created multiple objects.\n");
466 476
467 free_object (ob); 477 ob->destroy ();
468 return tmp; 478 return tmp;
469} 479}
470 480
471/* 481/*
472 * This is a new way of calculating the chance for an item to have 482 * This is a new way of calculating the chance for an item to have
999 op->value *= 5; /* Since it's not just decoration */ 1009 op->value *= 5; /* Since it's not just decoration */
1000 1010
1001 case RING: 1011 case RING:
1002 if (op->arch == NULL) 1012 if (op->arch == NULL)
1003 { 1013 {
1004 remove_ob (op); 1014 op->destroy ();
1005 free_object (op);
1006 op = NULL; 1015 op = 0;
1007 break; 1016 break;
1008 } 1017 }
1009 1018
1010 if (op->arch != ring_arch && op->arch != amulet_arch) /* It's a special artifact! */ 1019 if (op->arch != ring_arch && op->arch != amulet_arch) /* It's a special artifact! */
1011 break; 1020 break;
1263 { 1272 {
1264 for (i = 0; i < depth; i++) 1273 for (i = 0; i < depth; i++)
1265 fprintf (logfile, " "); 1274 fprintf (logfile, " ");
1266 fprintf (logfile, "{ (list: %s)\n", &t->name); 1275 fprintf (logfile, "{ (list: %s)\n", &t->name);
1267 tl = find_treasurelist (t->name); 1276 tl = find_treasurelist (t->name);
1277 if (tl)
1268 dump_monster_treasure_rec (name, tl->items, depth + 2); 1278 dump_monster_treasure_rec (name, tl->items, depth + 2);
1269 for (i = 0; i < depth; i++) 1279 for (i = 0; i < depth; i++)
1270 fprintf (logfile, " "); 1280 fprintf (logfile, " ");
1271 fprintf (logfile, "} (end of list: %s)\n", &t->name); 1281 fprintf (logfile, "} (end of list: %s)\n", &t->name);
1272 } 1282 }
1273 else 1283 else
1390 art->chance = (uint16) value; 1400 art->chance = (uint16) value;
1391 else if (sscanf (cp, "difficulty %d", &value)) 1401 else if (sscanf (cp, "difficulty %d", &value))
1392 art->difficulty = (uint8) value; 1402 art->difficulty = (uint8) value;
1393 else if (!strncmp (cp, "Object", 6)) 1403 else if (!strncmp (cp, "Object", 6))
1394 { 1404 {
1395 art->item = get_object (); 1405 art->item = object::create ();
1396 1406
1397 if (!load_object (thawer, art->item, 0)) 1407 if (!load_object (thawer, art->item, 0))
1398 LOG (llevError, "Init_Artifacts: Could not load object.\n"); 1408 LOG (llevError, "Init_Artifacts: Could not load object.\n");
1399 1409
1400 art->item->name = strchr (cp, ' ') + 1; 1410 art->item->name = strchr (cp, ' ') + 1;
1489 CLEAR_FLAG (op, FLAG_ANIMATE); 1499 CLEAR_FLAG (op, FLAG_ANIMATE);
1490 /* so artifacts will join */ 1500 /* so artifacts will join */
1491 if (!QUERY_FLAG (op, FLAG_ALIVE)) 1501 if (!QUERY_FLAG (op, FLAG_ALIVE))
1492 op->speed = 0.0; 1502 op->speed = 0.0;
1493 1503
1494 update_ob_speed (op); 1504 op->set_speed (op->speed);
1495 } 1505 }
1496 1506
1497 if (change->nrof) 1507 if (change->nrof)
1498 op->nrof = RANDOM () % ((int) change->nrof) + 1; 1508 op->nrof = RANDOM () % ((int) change->nrof) + 1;
1499 1509
1511 { 1521 {
1512 object *tmp_obj; 1522 object *tmp_obj;
1513 1523
1514 /* Remove any spells this object currently has in it */ 1524 /* Remove any spells this object currently has in it */
1515 while (op->inv) 1525 while (op->inv)
1516 { 1526 op->inv->destroy ();
1517 tmp_obj = op->inv;
1518 remove_ob (tmp_obj);
1519 free_object (tmp_obj);
1520 }
1521 1527
1522 tmp_obj = arch_to_object (change->other_arch); 1528 tmp_obj = arch_to_object (change->other_arch);
1523 insert_ob_in_ob (tmp_obj, op); 1529 insert_ob_in_ob (tmp_obj, op);
1524 } 1530 }
1525 /* No harm setting this for potions/horns */ 1531 /* No harm setting this for potions/horns */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines