77 for (
auto allowed : at->
allowed)
105 for (; al != NULL; al = nextal) {
107 for (
auto art : al->
items) {
123 #define ARTIFACT_TRIES 2 141 int chance_of_invalid_item = 0;
142 for (
auto check : list->
items) {
144 chance_of_invalid_item += check->chance;
191 for (
auto r : al->
items) {
199 if (art == NULL || roll >= 0) {
200 LOG(
llevError,
"Got null entry and non zero roll in generate_artifact, type %d\n", op->
type);
203 if (!strcmp(art->
item->
name,
"NONE"))
209 if (difficulty < art->difficulty)
213 #ifdef TREASURE_VERBOSE 233 snprintf(new_name,
sizeof(new_name),
"of %s", artifact->
name);
253 int neg, success = 0;
258 for (
auto tmp : art->
allowed) {
259 #ifdef TREASURE_VERBOSE 292 const char* dot = name + strlen(name) - 1;
293 while (dot > name && (isdigit(*dot) || (*dot ==
'x')))
301 strlcpy(buf, name, dot - name + 1);
302 snprintf(buf + strlen(buf), size - strlen(buf),
"_%s%s", suffix, dot);
306 snprintf(buf, size,
"%s_%s", name, suffix);
311 #define KEY_FACE_SUFFIX "face_suffix" 312 #define KEY_ANIMATION_SUFFIX "animation_suffix" 326 #ifdef TREASURE_VERBOSE 341 snprintf(buf,
sizeof(buf),
"%d", change->
anim_speed);
349 snprintf(buf,
sizeof(buf),
"%s_%s", op->
animation->
name, key);
473 if (change->
level < 0)
574 if (al->
type == type)
596 for (
const auto at : list->
items) {
616 for (
const auto art : al->
items) {
617 fprintf(
logfile,
"Artifact %-30s Difficulty %3d Chance %5d\n", art->item->name, art->difficulty, art->chance);
618 if (!art->allowed.empty()) {
619 fprintf(
logfile,
"\tAllowed combinations:");
620 for (
auto allowed : art->allowed)
621 fprintf(
logfile,
"%s,", allowed);
644 bool allowed = std::none_of(art->
allowed.cbegin(), art->
allowed.cend(),
645 [&] (
const auto name) {
return strcmp(arch->
name, name + 1) == 0; });
646 if (allowed && arch->
clone.
face != NULL) {
664 while (arch != NULL) {
682 al->total_chance = 0;
683 for (
auto art : al->items) {
685 al->total_chance += art->chance;
void object_free_key_values(object *op)
Zero the key_values on op, decrementing the shared-string refcounts and freeing the links...
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
#define FLAG_DAMNED
The object is very cursed.
int8_t item_power
Power rating of the object.
This represents one animation.
static void free_artifact(artifact *at)
Totally frees an artifact, its next items, and such.
struct archetype * arch
Pointer to archetype.
FILE * logfile
Used by server/daemon.c.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
#define FABS(x)
Decstations have trouble with fabs()...
#define FLAG_STAND_STILL
NPC will not (ever) move.
void object_set_msg(object *op, const char *msg)
Set the message field of an object.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
int16_t maxgrace
Maximum grace.
New face structure - this enforces the notion that data is face by face only - you can not change the...
sstring slaying
Which race to do double damage to.
sstring add_string(const char *str)
Share a string.
int32_t value
How much money it is worth (or contains)
int8_t luck
Affects thaco and ac from time to time.
#define FLAG_BLIND
If set, object cannot see (visually)
Each object (this also means archetypes!) could have a few of these "dangling" from it; this could al...
sstring find_string(const char *str)
Searches a string in the shared strings.
void generate_artifact(object *op, int difficulty)
Decides randomly which artifact the object should be turned into.
#define FLAG_CONFUSED
Will also be unable to cast spells.
#define FLAG_STEALTH
Will wake monsters with less range.
static void free_artifactlist(artifactlist *al)
Free specified list and its items.
int8_t magic
Any magical bonuses to this item.
#define ARTIFACT_TRIES
Give 1 re-roll attempt per artifact.
uint16_t material
What materials this object consist of.
sstring add_refcount(sstring str)
Like add_string(), but the string is already a shared string.
object * next
Pointer to the next object in the free/used list.
void artifact_compute_chance_for_item(const object *op, const artifact *art, int *numerator, int *denominator)
Compute the chance for a specified item to become the specified artifact.
artifactlist * find_artifactlist(int type)
Finds the artifact list for a certain item type.
artifact * get_empty_artifact(void)
Allocate and return the pointer to an empty artifact structure.
uint32_t path_repelled
Paths the object is repelled from.
#define FLAG_REFLECTING
Object reflects from walls (lightning)
Global type definitions and header inclusions.
void free_all_artifacts(void)
Free all artifact-related information.
uint8_t anim_speed
Ticks between animation-frames.
archetype * try_find_archetype(const char *name)
static void compute_face_name(char *buf, size_t size, const char *name, const char *suffix)
Compute the name of a face with a suffix, taking into account names like '.123' or '...
int32_t weight
Attributes of the object.
archetype * head
The main part of a linked object.
#define KEY_ANIMATION_SUFFIX
const Face * blank_face
Following can just as easily be pointers, but it is easier to keep them like this.
uint16_t total_chance
Sum of chance for are artifacts on this list.
const Face * try_find_face(const char *name, const Face *error)
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
int16_t level
Level of creature or object.
uint16_t artifact_get_face(const artifact *art)
Get a suitable face number for representing an artifact.
int legal_artifact_combination(const object *op, const artifact *art)
Checks if op can be combined with art.
sstring key
Name of the key.
void dump_artifacts(void)
For debugging purposes.
std::vector< artifact * > items
Artifacts for this type.
#define FLAG_ALIVE
Object can fight (or be fought)
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
#define FLAG_REFL_SPELL
Spells (some) will reflect from object.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
sstring materialname
Specific material name.
sstring name
More definite name, like "generate_kobold".
Defines for loader.l / loader.c.
float speed
Frequency of object 'moves' relative to server tick rate.
uint8_t difficulty
Minimum map difficulty for the artifact to happen.
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
int32_t last_sp
As last_heal, but for spell points.
#define QUERY_FLAG(xyz, p)
const artifact * find_artifact(const object *op, const char *name)
Searches and returns a specific artifact compatible with an object, NULL if not found.
artifactlist * next
Next list of artifacts.
#define FLAG_NO_SAVE
If set (through plugins), the object is not saved on maps.
void give_artifact_abilities(object *op, const object *artifact)
Fixes the given object, giving it the abilities and titles it should have due to the second artifact-...
void object_give_identified_properties(object *op)
Ensure op has all its "identified" properties set.
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
sstring msg
If this is a book/sign/magic mouth/etc.
void set_abs_magic(object *op, int magic)
Sets magical bonus in an object, and recalculates the effect on the armour variable, and the effect on speed of armour.
void artifact_check(const artifact *art)
sstring race
Human, goblin, dragon, etc.
const Animations * animation
Animation of this item, NULL if not animated.
artifactlist * first_artifactlist
First artifact.
key_value * key_values
Fields not explictly known by the loader.
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
key_value * next
Next key in the list.
const Face * face
Face with colors.
This represents all archetypes for one particular object type.
int is_identified(const object *op)
Return true if the item is identified, either because it is of a type that doesn't ever need identifi...
archetype * get_next_archetype(archetype *current)
void artifact_post_load()
object * object_new(void)
Grabs an object from the list of unused objects, makes sure it is initialised, and returns it...
#define FLAG_XRAYS
X-ray vision.
uint16_t number
This is the image unique identifier.
int16_t dam
How much damage this object does when hitting.
uint32_t path_denied
Paths the object is denied access to.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
living stats
Str, Con, Dex, etc.
#define MAX_BUF
Used for all kinds of things.
size_t strlcpy(char *dst, const char *src, size_t size)
Portable implementation of strlcpy(3).
void object_copy(const object *src_ob, object *dest_ob)
Copy object first frees everything allocated by the second object, and then copies the contents of th...
#define FLAG_CURSED
The object is cursed.
struct archetype * other_arch
Pointer used for various things - mostly used for what this objects turns into or what this object cr...
#define FLAG_ANIMATE
The object looks at archetype for faces.
sstring name_pl
The plural name of the object.
Animations * try_find_animation(const char *name)
MoveType move_type
Type of movement this object uses.
sstring name
The name of the object, obviously...
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
sstring title
Of foo, etc.
Only for debugging purposes.
uint32_t nrof
Number of objects.
#define CLEAR_FLAG(xyz, p)
uint8_t type
PLAYER, BULLET, etc.
void add_abilities(object *op, const object *change)
Apply artifact properties to an object.
int8_t ac
Armor Class, lower AC increases probability of not getting hit.
void change_attr_value(living *stats, int attr, int8_t value)
Like set_attr_value(), but instead the value (which can be negative) is added to the specified stat...
sstring value
Key's value.
#define FLAG_LIFESAVE
Saves a players' life once, then destr.
void object_update_speed(object *op)
Updates the speed of an object.
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
object * inv
Pointer to the first object in the inventory.
#define FLAG_MAKE_INVIS
(Item) gives invisibility when applied
sstring name
Name of the animation sequence.
int8_t gen_sp_armour
Sp regen penalty this object has (was last_heal)
archetype * find_archetype_by_object_name(const char *name)
This function retrieves an archetype given the name that appears during the game (for example...
int16_t maxsp
Max spell points.
uint32_t attacktype
Bitmask of attacks this object does.
#define FLAG_CLIENT_ANIM_RANDOM
Client animate this, randomized.
int32_t food
How much food in stomach.
int16_t maxhp
Max hit points.
artifactlist * get_empty_artifactlist(void)
Allocate and return the pointer to an empty artifactlist structure.
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
int8_t wc
Weapon Class, lower WC increases probability of hitting.
#define FLAG_REFL_MISSILE
Arrows will reflect from object.
This is one artifact, ie one special item.
sstring name
Face name, as used by archetypes and such.
sstring artifact
If set, the item is the artifact with this name and the matching type.
object clone
An object from which to do object_copy()
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
object * item
Special values of the artifact.
uint16_t chance
Chance of the artifact to happen.
std::vector< sstring > allowed
List of archetypes the artifact can affect.
uint8_t type
Object type that this list represents.
uint32_t path_attuned
Paths the object is attuned to.