Go to the documentation of this file.
46 #define num_resist_table 19
100 if (
t->change_arch.name) {
106 if (
t->change_arch.title) {
112 if (
t->change_arch.slaying) {
137 if ((
int)
t->chance >= 100 || (
RANDOM()%100+1) <
t->chance) {
139 if (strcmp(
t->name,
"NONE") && difficulty >=
t->magic)
144 if (
t->nrof &&
tmp->nrof <= 1)
151 if (
t->next_yes != NULL)
154 if (
t->next_no != NULL)
183 LOG(
llevDebug,
"create_one_treasure: tries exceeded 100, returning without making treasure\n");
187 for (
t = tl->
items;
t != NULL;
t =
t->next) {
194 LOG(
llevError,
"create_one_treasure: got null object or not able to find treasure\n");
198 if (!strcmp(
t->name,
"NONE"))
200 if (difficulty >=
t->magic)
213 if ((
t->item &&
t->item->clone.invisible != 0) || flag !=
GT_INVISIBLE) {
218 if (
t->nrof &&
tmp->nrof <= 1)
243 LOG(
llevDebug,
"createtreasure: tries exceeded 100, returning without making treasure\n");
283 LOG(
llevError,
"In generate treasure, created multiple objects.\n");
302 int level, mult, olevel;
305 LOG(
llevError,
"level_for_item: Object %s has no inventory!\n",
op->name);
314 mult =
op->inv->dam_modifier;
315 if (
op->inv->range_modifier && (
op->inv->range_modifier < mult || mult == 0))
316 mult =
op->inv->range_modifier;
317 if (
op->inv->duration_modifier && (
op->inv->duration_modifier < mult || mult == 0))
318 mult =
op->inv->duration_modifier;
390 { 70, 2, 7, 11, 10 },
391 { 70, 2, 7, 11, 10 },
392 { 70, 2, 7, 11, 10 },
393 { 70, 2, 7, 11, 10 },
394 { 70, 2, 7, 11, 10 },
395 { 70, 2, 5, 12, 11 },
396 { 70, 2, 5, 12, 11 },
397 { 70, 2, 5, 12, 11 },
398 { 70, 2, 5, 12, 11 },
399 { 70, 2, 5, 12, 11 },
400 { 70, 2, 3, 13, 12 },
401 { 70, 2, 3, 13, 12 },
402 { 70, 2, 3, 13, 12 },
403 { 70, 2, 3, 13, 12 },
404 { 70, 2, 3, 13, 12 },
405 { 70, 2, 3, 12, 13 },
406 { 70, 2, 3, 12, 13 },
407 { 70, 2, 3, 12, 13 },
408 { 70, 2, 3, 12, 13 },
409 { 70, 2, 3, 12, 13 },
410 { 70, 2, 3, 11, 14 },
411 { 70, 2, 3, 11, 14 },
412 { 70, 2, 3, 11, 14 },
413 { 70, 2, 3, 11, 14 },
414 { 70, 2, 3, 11, 14 },
415 { 70, 2, 3, 10, 15 },
416 { 70, 2, 3, 10, 15 },
417 { 70, 2, 3, 10, 15 },
418 { 70, 2, 3, 10, 15 },
419 { 70, 2, 3, 10, 15 },
562 for (loop = 0; loop < (
MAXMAGIC+1); ++loop) {
568 LOG(
llevError,
"Warning, table for difficulty %d bad.\n", difficulty);
572 return (
RANDOM()%3) ? loop : -loop;
591 int32_t base_weight, base_speed;
597 base_weight =
op->arch->clone.weight;
601 base_weight =
op->weight;
614 if (magic < 0 && !(
RANDOM()%3))
668 int r =
RANDOM()%(bonus > 0 ? 25 : 11);
697 op->stats.dam += bonus;
701 op->stats.wc += bonus;
705 op->stats.food += bonus;
709 op->stats.ac += bonus;
770 op->stats.exp += bonus;
771 op->value = (
op->value*2)/3;
775 op->value *= 2*bonus;
777 op->value = -(
op->value*2*bonus)/3;
793 for (i = 0; i < 4; i++)
831 for (i = 0; i < difficulty; i++)
847 #define DICE2 (get_magic(2) == 2 ? 2 : 1)
848 #define DICESPELL (RANDOM()%3+RANDOM()%3+RANDOM()%3+RANDOM()%3+RANDOM()%3)
877 int was_magic =
op->magic, num_enchantments = 0, save_item_power;
879 if (!creator || creator->
type ==
op->type)
883 save_item_power =
op->item_power;
886 if (
op->randomitems &&
op->type !=
SPELL) {
889 LOG(
llevDebug,
"fix_generated_item: Unable to generate treasure for %s\n",
op->name);
891 op->randomitems = NULL;
902 if (!
op->magic && max_magic)
907 || difficulty >= 999)
926 }
else if (save_item_power) {
932 op->item_power = save_item_power;
941 save_item_power =
op->item_power;
946 op->item_power = save_item_power;
955 if (
op->stats.sp && !
op->randomitems) {
963 }
else if (!
op->title) {
983 int too_many_tries = 0, is_special = 0;
986 if (
op->stats.sp && !
op->randomitems) {
996 if (too_many_tries++ > 10)
1002 if (
op->inv &&
op->randomitems) {
1004 op->value = (
op->value*
op->inv->value);
1020 if (
op->arch == NULL) {
1059 if (
op->map &&
op->map->difficulty)
1068 if (
op->msg != NULL)
1069 op->value *= ((
op->level > 10 ?
op->level : (
op->level+1)/2)*((strlen(
op->msg)/250)+1));
1076 op->stats.exp =
op->value > 10000 ?
op->value/5 :
op->value/10;
1086 op->value =
op->value*
op->inv->value;
1088 op->level =
op->inv->level;
1089 op->stats.exp =
op->value;
1092 if (
rndm(1, 6) <= 1)
1096 }
else if (
rndm(1, 100) <= 1) {
1106 op->stats.food =
op->inv->nrof;
1113 if (
op->inv->duration_modifier
1114 ||
op->inv->dam_modifier
1115 ||
op->inv->range_modifier) {
1117 op->value =
op->value*
op->inv->value*(
op->level+50)/(
op->inv->level+50);
1119 op->level =
op->inv->level;
1120 op->value =
op->value*
op->inv->value;
1131 op->value =
op->value*
op->inv->value*(
op->level+50)/(
op->inv->level+50);
1133 op->stats.exp =
op->value/5;
1134 op->nrof =
op->inv->nrof;
1137 if (
rndm(1, 6) <= 1)
1141 }
else if (
rndm(1, 100) <= 2) {
1180 if (
t->name != NULL) {
1181 for (i = 0; i < depth; i++)
1183 fprintf(
logfile,
"{ (list: %s)\n",
t->name);
1186 for (i = 0; i < depth; i++)
1188 fprintf(
logfile,
"} (end of list: %s)\n",
t->name);
1190 for (i = 0; i < depth; i++)
1192 if (
t->item->clone.type ==
FLESH)
1193 fprintf(
logfile,
"%s's %s\n",
name,
t->item->clone.name);
1195 fprintf(
logfile,
"%s\n",
t->item->clone.name);
1197 if (
t->next_yes != NULL) {
1198 for (i = 0; i < depth; i++)
1200 fprintf(
logfile,
" (if yes)\n");
1203 if (
t->next_no != NULL) {
1204 for (i = 0; i < depth; i++)
1206 fprintf(
logfile,
" (if no)\n");
1229 fprintf(
logfile,
"(nothing)\n");
1235 fprintf(
logfile,
"No objects have the name %s!\n\n",
name);
1251 snprintf(tmpbuf,
sizeof(tmpbuf),
"%s's %s", donor->
name,
item->name);
1253 snprintf(tmpbuf,
sizeof(tmpbuf),
"%s's %s", donor->
name,
item->name_pl);
1257 if (!
item->other_arch) {
1271 item->other_arch = original;
1273 LOG(
llevError,
"could not find original archetype %s for custom monster!\n", donor->
arch->
name);
1280 if ((
item->weight = (
signed long)(((
double)
item->weight/(
double)100.0)*(
double)donor->
weight)) == 0)
1301 item->stats.hp = -1*
item->stats.food;
1305 if (
item->face != NULL) {
1306 snprintf(tmpbuf,
sizeof(tmpbuf),
"%s_%s", donor->
arch->
name,
item->face->name);
1393 if (
list->items == NULL || position <= 0) {
1395 list->items = added;
1400 while (position > 0 && prev->
next) {
1415 if (
list->items == 0 || position < 0) {
1418 if (position == 0) {
1420 list->items->next = NULL;
1427 while (prev && position > 0) {
static void fix_flesh_item(object *item, const object *donor)
sstring add_string(const char *str)
void object_remove(object *op)
uint8_t armor_speed_linear
static int level_for_item(const object *op, int difficulty)
#define QUERY_FLAG(xyz, p)
#define FLAG_REFL_MISSILE
archetype * get_next_archetype(archetype *current)
static void trap_adjust(object *trap, int difficulty)
object * object_new(void)
int calc_item_power(const object *op)
#define FLAG_OBJ_ORIGINAL
void set_materialname(object *op)
#define SET_ANIMATION(ob, newanim)
void treasure_free(treasure *t)
#define MAX_SPELLITEM_LEVEL
treasurelist * find_treasurelist(const char *name)
void rod_adjust(object *rod)
#define ARMOUR_SPEED(xyz)
static const flag_definition flags[]
static void create_all_treasures(treasure *t, object *op, int flag, int difficulty, int tries)
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
EXTERN archetype * amulet_arch
struct treasureliststruct * randomitems
void treasure_remove_item(treasurelist *list, int position)
void free_string(sstring str)
static int resist_table[]
static int special_potion(object *op)
void fatal(enum fatal_error err)
static int get_magic(int diff)
static const int difftomagic_list[DIFFLEVELS][MAXMAGIC+1]
void generate_artifact(object *op, int difficulty)
static void change_treasure(treasure *t, object *op)
int armor_weight_reduction
#define FREE_AND_COPY(sv, nv)
EXTERN archetype * crown_arch
struct archt * other_arch
int rndm(int min, int max)
static void set_magic(int difficulty, object *op, int max_magic, int flags)
void fix_generated_item(object *op, object *creator, int difficulty, int max_magic, int flags)
object * create_archetype(const char *name)
static void put_treasure(object *op, object *creator, int flags)
struct treasurestruct * items
void tailor_readable_ob(object *book, int msg_type)
treasure * treasure_insert(treasurelist *list, int position)
treasure * get_empty_treasure(void)
void LOG(LogLevel logLevel, const char *format,...)
int get_power_from_ench(int ench)
archetype * find_archetype(const char *name)
void dump_monster_treasure(const char *name)
static int magic_from_difficulty(int difficulty)
void set_attr_value(living *stats, int attr, int8_t value)
#define CHANCE_FOR_ARTIFACT
#define NUM_ANIMATIONS(ob)
object * object_insert_in_ob(object *op, object *where)
object * arch_to_object(archetype *at)
uint8_t armor_weight_linear
int strcasecmp(const char *s1, const char *s2)
struct treasurestruct * next
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
int8_t get_attr_value(const living *stats, int attr)
void object_free_drop_inventory(object *ob)
const Face * try_find_face(const char *name, const Face *error)
object * generate_treasure(treasurelist *t, int difficulty)
void set_abs_magic(object *op, int magic)
static void create_one_treasure(treasurelist *tl, object *op, int flag, int difficulty, int tries)
EXTERN archetype * ring_arch
void init_archetype_pointers(void)
const char *const spell_mapping[SPELL_MAPPINGS]
#define ATNR_LIFE_STEALING
int16_t resist[NROFATTACKS]
static void set_ring_bonus(object *op, int bonus)
int armor_speed_improvement
static void dump_monster_treasure_rec(const char *name, treasure *t, int depth)