… | |
… | |
54 | > tl_map_t; |
54 | > tl_map_t; |
55 | |
55 | |
56 | static tl_map_t tl_map; |
56 | static tl_map_t tl_map; |
57 | |
57 | |
58 | /* |
58 | /* |
59 | * Initialize global archtype pointers: |
|
|
60 | */ |
|
|
61 | void |
|
|
62 | init_archetype_pointers () |
|
|
63 | { |
|
|
64 | int prev_warn = warn_archetypes; |
|
|
65 | |
|
|
66 | warn_archetypes = 1; |
|
|
67 | |
|
|
68 | if (ring_arch == NULL) |
|
|
69 | ring_arch = archetype::find ("ring"); |
|
|
70 | if (amulet_arch == NULL) |
|
|
71 | amulet_arch = archetype::find ("amulet"); |
|
|
72 | if (staff_arch == NULL) |
|
|
73 | staff_arch = archetype::find ("staff"); |
|
|
74 | if (crown_arch == NULL) |
|
|
75 | crown_arch = archetype::find ("crown"); |
|
|
76 | |
|
|
77 | warn_archetypes = prev_warn; |
|
|
78 | } |
|
|
79 | |
|
|
80 | /* |
|
|
81 | * Searches for the given treasurelist |
59 | * Searches for the given treasurelist |
82 | */ |
60 | */ |
83 | treasurelist * |
61 | treasurelist * |
84 | treasurelist::find (const char *name) |
62 | treasurelist::find (const char *name) |
85 | { |
63 | { |
… | |
… | |
167 | coroapi::cede_to_tick_every (10); |
145 | coroapi::cede_to_tick_every (10); |
168 | |
146 | |
169 | switch (f.kw) |
147 | switch (f.kw) |
170 | { |
148 | { |
171 | case KW_arch: |
149 | case KW_arch: |
172 | if (!(t->item = archetype::find (f.get_str ()))) |
150 | t->item = archetype::get (f.get_str ()); |
173 | LOG (llevError, "%s:%d treasure references unknown archetype '%s', skipping.\n", f.name, f.linenum, f.get_str ()); |
|
|
174 | break; |
151 | break; |
175 | |
152 | |
176 | case KW_list: f.get (t->name); break; |
153 | case KW_list: f.get (t->name); break; |
177 | case KW_change_name: f.get (t->change_arch.name); break; |
154 | case KW_change_name: f.get (t->change_arch.name); break; |
178 | case KW_change_title: f.get (t->change_arch.title); break; |
155 | case KW_change_title: f.get (t->change_arch.title); break; |
… | |
… | |
419 | object * |
396 | object * |
420 | generate_treasure (treasurelist *tl, int difficulty) |
397 | generate_treasure (treasurelist *tl, int difficulty) |
421 | { |
398 | { |
422 | difficulty = clamp (difficulty, 1, settings.max_level); |
399 | difficulty = clamp (difficulty, 1, settings.max_level); |
423 | |
400 | |
424 | object *ob = object::create (), *tmp; |
401 | object *ob = object::create (); |
425 | |
402 | |
426 | create_treasure (tl, ob, 0, difficulty, 0); |
403 | create_treasure (tl, ob, 0, difficulty, 0); |
427 | |
404 | |
428 | /* 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 */ |
429 | tmp = ob->inv; |
406 | object *tmp = ob->inv; |
430 | if (tmp != NULL) |
407 | if (tmp) |
431 | tmp->remove (); |
408 | tmp->remove (); |
432 | |
409 | |
433 | if (ob->inv) |
410 | if (ob->inv) |
434 | LOG (llevError, "In generate treasure, created multiple objects.\n"); |
411 | LOG (llevError, "In generate treasure, created multiple objects.\n"); |
435 | |
412 | |
… | |
… | |
443 | * 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 |
444 | * magical bonus "wanted". |
421 | * magical bonus "wanted". |
445 | */ |
422 | */ |
446 | |
423 | |
447 | static int difftomagic_list[DIFFLEVELS][MAXMAGIC + 1] = { |
424 | static int difftomagic_list[DIFFLEVELS][MAXMAGIC + 1] = { |
448 | |
|
|
449 | // chance of magic difficulty |
425 | // chance of magic difficulty |
450 | // +0 +1 +2 +3 +4 |
426 | // +0 +1 +2 +3 +4 |
451 | {95, 2, 2, 1, 0}, // 1 |
427 | {95, 2, 2, 1, 0}, // 1 |
452 | {92, 5, 2, 1, 0}, // 2 |
428 | {92, 5, 2, 1, 0}, // 2 |
453 | {85, 10, 4, 1, 0}, // 3 |
429 | {85, 10, 4, 1, 0}, // 3 |
… | |
… | |
479 | { 0, 0, 0, 3, 97}, // 29 |
455 | { 0, 0, 0, 3, 97}, // 29 |
480 | { 0, 0, 0, 0, 100}, // 30 |
456 | { 0, 0, 0, 0, 100}, // 30 |
481 | { 0, 0, 0, 0, 100}, // 31 |
457 | { 0, 0, 0, 0, 100}, // 31 |
482 | }; |
458 | }; |
483 | |
459 | |
484 | |
|
|
485 | /* calculate the appropriate level for wands staves and scrolls. |
460 | /* calculate the appropriate level for wands staves and scrolls. |
486 | * 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) |
487 | * |
462 | * |
488 | * elmex Wed Aug 9 17:44:59 CEST 2006: |
463 | * elmex Wed Aug 9 17:44:59 CEST 2006: |
489 | * 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. |
490 | */ |
465 | */ |
491 | |
|
|
492 | int |
466 | int |
493 | level_for_item (const object *op, int difficulty) |
467 | level_for_item (const object *op, int difficulty) |
494 | { |
468 | { |
495 | int olevel = 0; |
469 | int olevel = 0; |
496 | |
470 | |
… | |
… | |
806 | save_item_power = op->item_power; |
780 | save_item_power = op->item_power; |
807 | op->item_power = 0; |
781 | op->item_power = 0; |
808 | |
782 | |
809 | if (op->randomitems && op->type != SPELL) |
783 | if (op->randomitems && op->type != SPELL) |
810 | { |
784 | { |
811 | create_treasure (op->randomitems, op, flags, difficulty, 0); |
785 | create_treasure (op->randomitems, op, flags & ~GT_ENVIRONMENT, difficulty, 0); |
812 | if (!op->inv) |
|
|
813 | LOG (llevDebug, "fix_generated_item: Unable to generate treasure for %s\n", op->debug_desc ()); |
|
|
814 | |
|
|
815 | /* So the treasure doesn't get created again */ |
786 | /* So the treasure doesn't get created again */ |
816 | op->randomitems = 0; |
787 | op->randomitems = 0; |
817 | } |
788 | } |
818 | |
789 | |
819 | if (difficulty < 1) |
790 | if (difficulty < 1) |
… | |
… | |
1349 | break; |
1320 | break; |
1350 | |
1321 | |
1351 | case KW_object: |
1322 | case KW_object: |
1352 | { |
1323 | { |
1353 | art->item = object::create (); |
1324 | art->item = object::create (); |
|
|
1325 | f.get (art->item->name); |
|
|
1326 | f.next (); |
1354 | |
1327 | |
1355 | if (!art->item->parse_kv (f)) |
1328 | if (!art->item->parse_kv (f)) |
1356 | LOG (llevError, "Init_Artifacts: Could not load object.\n"); |
1329 | LOG (llevError, "Init_Artifacts: Could not load object.\n"); |
1357 | |
1330 | |
1358 | al = find_artifactlist (art->item->type); |
1331 | al = find_artifactlist (art->item->type); |