Go to the documentation of this file.
53 #define num_resist_table 19
107 if (
t->change_arch.name) {
113 if (
t->change_arch.title) {
119 if (
t->change_arch.slaying) {
140 if (
t->item && (
t->item->clone.invisible != 0 || !(flag&
GT_INVISIBLE))) {
142 if (
t->nrof &&
tmp->nrof <= 1)
147 LOG(
llevError,
"Invalid artifact %s for treasure %s\n",
t->artifact,
tmp->arch->name);
176 if ((
int)
t->chance >= 100 || (
RANDOM()%100+1) <
t->chance) {
178 if (strcmp(
t->name,
"NONE") && difficulty >=
t->magic)
183 if (
t->next_yes != NULL)
186 if (
t->next_no != NULL)
215 LOG(
llevDebug,
"create_one_treasure: tries exceeded 100, returning without making treasure\n");
219 for (
t = tl->
items;
t != NULL;
t =
t->next) {
226 LOG(
llevError,
"create_one_treasure: got null object or not able to find treasure\n");
230 if (!strcmp(
t->name,
"NONE"))
232 if (difficulty >=
t->magic)
265 LOG(
llevDebug,
"createtreasure: tries exceeded 100, returning without making treasure\n");
305 LOG(
llevError,
"In generate treasure, created multiple objects.\n");
324 int level, mult, olevel;
327 LOG(
llevError,
"level_for_item: Object %s has no inventory!\n",
op->name);
336 mult =
op->inv->dam_modifier;
337 if (
op->inv->range_modifier && (
op->inv->range_modifier < mult || mult == 0))
338 mult =
op->inv->range_modifier;
339 if (
op->inv->duration_modifier && (
op->inv->duration_modifier < mult || mult == 0))
340 mult =
op->inv->duration_modifier;
346 olevel =
rndm(0, difficulty)+
rndm(0, difficulty);
352 else if (olevel <
level)
418 { 70, 2, 7, 11, 10 },
419 { 70, 2, 7, 11, 10 },
420 { 70, 2, 7, 11, 10 },
421 { 70, 2, 7, 11, 10 },
422 { 70, 2, 7, 11, 10 },
423 { 70, 2, 5, 12, 11 },
424 { 70, 2, 5, 12, 11 },
425 { 70, 2, 5, 12, 11 },
426 { 70, 2, 5, 12, 11 },
427 { 70, 2, 5, 12, 11 },
428 { 70, 2, 3, 13, 12 },
429 { 70, 2, 3, 13, 12 },
430 { 70, 2, 3, 13, 12 },
431 { 70, 2, 3, 13, 12 },
432 { 70, 2, 3, 13, 12 },
433 { 70, 2, 3, 12, 13 },
434 { 70, 2, 3, 12, 13 },
435 { 70, 2, 3, 12, 13 },
436 { 70, 2, 3, 12, 13 },
437 { 70, 2, 3, 12, 13 },
438 { 70, 2, 3, 11, 14 },
439 { 70, 2, 3, 11, 14 },
440 { 70, 2, 3, 11, 14 },
441 { 70, 2, 3, 11, 14 },
442 { 70, 2, 3, 11, 14 },
443 { 70, 2, 3, 10, 15 },
444 { 70, 2, 3, 10, 15 },
445 { 70, 2, 3, 10, 15 },
446 { 70, 2, 3, 10, 15 },
447 { 70, 2, 3, 10, 15 },
590 for (loop = 0; loop < (
MAXMAGIC+1); ++loop) {
596 LOG(
llevError,
"Warning, table for difficulty %d bad.\n", difficulty);
600 return (
RANDOM()%3) ? loop : -loop;
619 int32_t base_weight, base_speed;
625 base_weight =
op->arch->clone.weight;
629 base_weight =
op->weight;
642 if (magic < 0 && !(
RANDOM()%3))
696 int r =
RANDOM()%(bonus > 0 ? 25 : 11);
725 op->stats.dam += bonus;
729 op->stats.wc += bonus;
733 op->stats.food += bonus;
737 op->stats.ac += bonus;
798 op->stats.grace += bonus;
803 op->stats.exp += bonus;
804 op->value = (
op->value*2)/3;
808 op->value *= 2*bonus;
810 op->value = -(
op->value*2*bonus)/3;
826 for (i = 0; i < 4; i++)
864 for (i = 0; i < difficulty; i++)
880 #define DICE2 (get_magic(2) == 2 ? 2 : 1)
881 #define DICESPELL (RANDOM()%3+RANDOM()%3+RANDOM()%3+RANDOM()%3+RANDOM()%3)
910 int was_magic =
op->magic, num_enchantments = 0, save_item_power;
912 if (!creator || creator->
type ==
op->type)
916 save_item_power =
op->item_power;
919 if (
op->randomitems &&
op->type !=
SPELL) {
922 LOG(
llevDebug,
"fix_generated_item: Unable to generate treasure for %s\n",
op->name);
924 op->randomitems = NULL;
935 if (!
op->magic && max_magic)
940 || difficulty >= 999)
959 }
else if (save_item_power) {
965 op->item_power = save_item_power;
974 save_item_power =
op->item_power;
979 op->item_power = save_item_power;
988 if (
op->stats.sp && !
op->randomitems) {
996 }
else if (!
op->title) {
1016 int too_many_tries = 0, is_special = 0;
1019 if (
op->stats.sp && !
op->randomitems) {
1029 if (too_many_tries++ > 10)
1035 if (
op->inv &&
op->randomitems) {
1037 op->value = (
op->value*
op->inv->value);
1053 if (
op->arch == NULL) {
1092 if (
op->map &&
op->map->difficulty)
1101 if (
op->msg != NULL)
1102 op->value *= ((
op->level > 10 ?
op->level : (
op->level+1)/2)*((strlen(
op->msg)/250)+1));
1109 op->stats.exp =
op->value > 10000 ?
op->value/5 :
op->value/10;
1119 op->value =
op->value*
op->inv->value;
1121 op->level =
op->inv->level;
1122 op->stats.exp =
op->value;
1125 if (
rndm(1, 6) <= 1)
1129 }
else if (
rndm(1, 100) <= 1) {
1139 op->stats.food =
op->inv->nrof;
1146 if (
op->inv->duration_modifier
1147 ||
op->inv->dam_modifier
1148 ||
op->inv->range_modifier) {
1150 op->value =
op->value*
op->inv->value*(
op->level+50)/(
op->inv->level+50);
1152 op->level =
op->inv->level;
1153 op->value =
op->value*
op->inv->value;
1164 op->value =
op->value*
op->inv->value*(
op->level+50)/(
op->inv->level+50);
1166 op->stats.exp =
op->value/5;
1167 op->nrof =
op->inv->nrof;
1170 if (
rndm(1, 6) <= 1)
1174 }
else if (
rndm(1, 100) <= 2) {
1213 if (
t->name != NULL) {
1214 for (i = 0; i < depth; i++)
1216 fprintf(
logfile,
"{ (list: %s)\n",
t->name);
1219 for (i = 0; i < depth; i++)
1221 fprintf(
logfile,
"} (end of list: %s)\n",
t->name);
1223 for (i = 0; i < depth; i++)
1225 if (
t->item->clone.type ==
FLESH)
1226 fprintf(
logfile,
"%s's %s\n",
name,
t->item->clone.name);
1228 fprintf(
logfile,
"%s\n",
t->item->clone.name);
1230 if (
t->next_yes != NULL) {
1231 for (i = 0; i < depth; i++)
1233 fprintf(
logfile,
" (if yes)\n");
1236 if (
t->next_no != NULL) {
1237 for (i = 0; i < depth; i++)
1239 fprintf(
logfile,
" (if no)\n");
1256 if (!
strcasecmp(at->clone.name,
name) && at->clone.title == NULL) {
1257 fprintf(logfile,
"treasures for %s (arch: %s)\n", at->clone.name, at->name);
1258 if (at->clone.randomitems != NULL)
1259 dump_monster_treasure_rec(at->clone.name, at->clone.randomitems->items, 1);
1261 fprintf(logfile,
"(nothing)\n");
1262 fprintf(logfile,
"\n");
1268 fprintf(
logfile,
"No objects have the name %s!\n\n",
name);
1284 snprintf(tmpbuf,
sizeof(tmpbuf),
"%s's %s", donor->
name,
item->name);
1286 snprintf(tmpbuf,
sizeof(tmpbuf),
"%s's %s", donor->
name,
item->name_pl);
1290 if (!
item->other_arch) {
1304 item->other_arch = original;
1306 LOG(
llevError,
"could not find original archetype %s for custom monster!\n", donor->
arch->
name);
1313 if ((
item->weight = (
signed long)(((
double)
item->weight/(
double)100.0)*(
double)donor->
weight)) == 0)
1334 item->stats.hp = -1*
item->stats.food;
1338 if (
item->face != NULL) {
1339 snprintf(tmpbuf,
sizeof(tmpbuf),
"%s_%s", donor->
arch->
name,
item->face->name);
1430 if (
list->items == NULL || position <= 0) {
1432 list->items = added;
1437 while (position > 0 && prev->
next) {
1452 if (
list->items == 0 || position < 0) {
1455 if (position == 0) {
1457 list->items->next = NULL;
1464 while (prev && position > 0) {
static void set_magic(int difficulty, object *op, int max_magic, int flags)
#define FREE_OBJ_NO_DESTROY_CALLBACK
void set_abs_magic(object *op, int magic)
static void dump_monster_treasure_rec(const char *name, treasure *t, int depth)
const artifact * find_artifact(const object *op, const char *name)
void LOG(LogLevel logLevel, const char *format,...)
uint8_t armor_speed_linear
#define QUERY_FLAG(xyz, p)
#define FLAG_REFL_MISSILE
static int level_for_item(const object *op, int difficulty)
#define FLAG_OBJ_ORIGINAL
void give_artifact_abilities(object *op, const object *artifact)
#define SET_ANIMATION(ob, newanim)
void fix_generated_item(object *op, object *creator, int difficulty, int max_magic, int flags)
int get_power_from_ench(int ench)
static const flag_definition flags[]
void set_materialname(object *op)
#define MAX_SPELLITEM_LEVEL
treasurelist * find_treasurelist(const char *name)
void rod_adjust(object *rod)
#define ARMOUR_SPEED(xyz)
static int special_potion(object *op)
static void create_all_treasures(treasure *t, object *op, int flag, int difficulty, int tries)
int rndm(int min, int max)
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
static int get_magic(int diff)
AssetsManager * getManager()
object * object_insert_in_ob(object *op, object *where)
int16_t resist[NROFATTACKS]
void object_free_drop_inventory(object *ob)
static int magic_from_difficulty(int difficulty)
static void trap_adjust(object *trap, int difficulty)
void init_archetype_pointers(void)
static archetype * amulet_arch
static void do_single_item(treasure *t, object *op, int flag, int difficulty)
sstring add_string(const char *str)
void set_attr_value(living *stats, int attr, int8_t value)
void treasure_free(treasure *t)
void tailor_readable_ob(object *book, int msg_type)
static void change_treasure(treasure *t, object *op)
int armor_weight_reduction
#define FREE_AND_COPY(sv, nv)
void object_free(object *ob, int flags)
static int resist_table[]
void each(std::function< void(T *)> op)
static void set_ring_bonus(object *op, int bonus)
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
struct archetype * other_arch
void fatal(enum fatal_error err)
Archetypes * archetypes()
object * object_new(void)
void treasure_remove_item(treasurelist *list, int position)
object * create_archetype(const char *name)
void free_string(sstring str)
static const int difftomagic_list[DIFFLEVELS][MAXMAGIC+1]
static void put_treasure(object *op, object *creator, int flags)
treasure * get_empty_treasure(void)
archetype * find_archetype(const char *name)
const char *const spell_mapping[SPELL_MAPPINGS]
#define CHANCE_FOR_ARTIFACT
static void fix_flesh_item(object *item, const object *donor)
#define NUM_ANIMATIONS(ob)
treasure * treasure_insert(treasurelist *list, int position)
void dump_monster_treasure(const char *name)
object * arch_to_object(archetype *at)
uint8_t armor_weight_linear
int strcasecmp(const char *s1, const char *s2)
void object_remove(object *op)
const Face * try_find_face(const char *name, const Face *error)
static archetype * crown_arch
object * generate_treasure(treasurelist *t, int difficulty)
#define FREE_OBJ_FREE_INVENTORY
static void create_one_treasure(treasurelist *tl, object *op, int flag, int difficulty, int tries)
int8_t get_attr_value(const living *stats, int attr)
int calc_item_power(const object *op)
static archetype * ring_arch
#define ATNR_LIFE_STEALING
void generate_artifact(object *op, int difficulty)
int armor_speed_improvement
int legal_artifact_combination(const object *op, const artifact *art)