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.49 by root, Tue Apr 17 18:59:05 2007 UTC vs.
Revision 1.50 by root, Thu Apr 19 16:23:46 2007 UTC

145 coroapi::cede_to_tick_every (10); 145 coroapi::cede_to_tick_every (10);
146 146
147 switch (f.kw) 147 switch (f.kw)
148 { 148 {
149 case KW_arch: 149 case KW_arch:
150 if (!(t->item = archetype::find (f.get_str ()))) 150 t->item = archetype::get (f.get_str ());
151 LOG (llevError, "%s:%d treasure references unknown archetype '%s', skipping.\n", f.name, f.linenum, f.get_str ());
152 break; 151 break;
153 152
154 case KW_list: f.get (t->name); break; 153 case KW_list: f.get (t->name); break;
155 case KW_change_name: f.get (t->change_arch.name); break; 154 case KW_change_name: f.get (t->change_arch.name); break;
156 case KW_change_title: f.get (t->change_arch.title); break; 155 case KW_change_title: f.get (t->change_arch.title); break;
397object * 396object *
398generate_treasure (treasurelist *tl, int difficulty) 397generate_treasure (treasurelist *tl, int difficulty)
399{ 398{
400 difficulty = clamp (difficulty, 1, settings.max_level); 399 difficulty = clamp (difficulty, 1, settings.max_level);
401 400
402 object *ob = object::create (), *tmp; 401 object *ob = object::create ();
403 402
404 create_treasure (tl, ob, 0, difficulty, 0); 403 create_treasure (tl, ob, 0, difficulty, 0);
405 404
406 /* Don't want to free the object we are about to return */ 405 /* Don't want to free the object we are about to return */
407 tmp = ob->inv; 406 object *tmp = ob->inv;
408 if (tmp != NULL) 407 if (tmp)
409 tmp->remove (); 408 tmp->remove ();
410 409
411 if (ob->inv) 410 if (ob->inv)
412 LOG (llevError, "In generate treasure, created multiple objects.\n"); 411 LOG (llevError, "In generate treasure, created multiple objects.\n");
413 412
421 * The array has two arguments, the difficulty of the level, and the 420 * The array has two arguments, the difficulty of the level, and the
422 * magical bonus "wanted". 421 * magical bonus "wanted".
423 */ 422 */
424 423
425static int difftomagic_list[DIFFLEVELS][MAXMAGIC + 1] = { 424static int difftomagic_list[DIFFLEVELS][MAXMAGIC + 1] = {
426
427// chance of magic difficulty 425// chance of magic difficulty
428// +0 +1 +2 +3 +4 426// +0 +1 +2 +3 +4
429 {95, 2, 2, 1, 0}, // 1 427 {95, 2, 2, 1, 0}, // 1
430 {92, 5, 2, 1, 0}, // 2 428 {92, 5, 2, 1, 0}, // 2
431 {85, 10, 4, 1, 0}, // 3 429 {85, 10, 4, 1, 0}, // 3
457 { 0, 0, 0, 3, 97}, // 29 455 { 0, 0, 0, 3, 97}, // 29
458 { 0, 0, 0, 0, 100}, // 30 456 { 0, 0, 0, 0, 100}, // 30
459 { 0, 0, 0, 0, 100}, // 31 457 { 0, 0, 0, 0, 100}, // 31
460}; 458};
461 459
462
463/* calculate the appropriate level for wands staves and scrolls. 460/* calculate the appropriate level for wands staves and scrolls.
464 * This code presumes that op has had its spell object created (in op->inv) 461 * This code presumes that op has had its spell object created (in op->inv)
465 * 462 *
466 * elmex Wed Aug 9 17:44:59 CEST 2006: 463 * elmex Wed Aug 9 17:44:59 CEST 2006:
467 * Removed multiplicator, too many high-level items were generated on low-difficulty maps. 464 * Removed multiplicator, too many high-level items were generated on low-difficulty maps.
468 */ 465 */
469
470int 466int
471level_for_item (const object *op, int difficulty) 467level_for_item (const object *op, int difficulty)
472{ 468{
473 int olevel = 0; 469 int olevel = 0;
474 470
784 save_item_power = op->item_power; 780 save_item_power = op->item_power;
785 op->item_power = 0; 781 op->item_power = 0;
786 782
787 if (op->randomitems && op->type != SPELL) 783 if (op->randomitems && op->type != SPELL)
788 { 784 {
789 create_treasure (op->randomitems, op, flags, difficulty, 0); 785 create_treasure (op->randomitems, op, flags & ~GT_ENVIRONMENT, difficulty, 0);
790 if (!op->inv)
791 LOG (llevDebug, "fix_generated_item: Unable to generate treasure for %s\n", op->debug_desc ());
792
793 /* So the treasure doesn't get created again */ 786 /* So the treasure doesn't get created again */
794 op->randomitems = 0; 787 op->randomitems = 0;
795 } 788 }
796 789
797 if (difficulty < 1) 790 if (difficulty < 1)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines