32 #include <sys/types.h> 42 #ifdef CF_MXE_CROSS_COMPILE 43 # define ffs(word) (__builtin_constant_p (word) \ 44 ? __builtin_ffs (word) \ 45 : ({ int __cnt, __tmp; \ 46 __asm__ __volatile__ \ 49 : "=&r" (__cnt), "=r" (__tmp) \ 50 : "rm" (word), "1" (-1)); \ 56 static void permute(
int *,
int,
int);
76 "spell_small_fireball",
77 "spell_medium_fireball",
78 "spell_large_fireball",
79 "spell_burning_hands",
81 "spell_large_lightning",
82 "spell_magic_missile",
85 "spell_summon_fire_elemental",
86 "spell_summon_earth_elemental",
87 "spell_summon_water_elemental",
88 "spell_summon_air_elemental",
89 "spell_dimension_door",
90 "spell_create_earth_wall",
93 "spell_magic_mapping",
99 "spell_perceive_self",
100 "spell_word_of_recall",
102 "spell_invisible_to_undead",
104 "spell_lg_magic_bullet",
105 "spell_improved_invisibility",
107 "spell_minor_healing",
108 "spell_medium_healing",
109 "spell_major_healing",
112 "spell_earth_to_dust",
116 "spell_constitution",
118 "spell_create_fire_wall",
119 "spell_create_frost_wall",
120 "spell_protection_from_cold",
121 "spell_protection_from_electricity",
122 "spell_protection_from_fire",
123 "spell_protection_from_poison",
124 "spell_protection_from_slow",
125 "spell_protection_from_paralysis",
126 "spell_protection_from_draining",
127 "spell_protection_from_magic",
128 "spell_protection_from_attack",
130 "spell_small_speedball",
131 "spell_large_speedball",
133 "spell_dragonbreath",
134 "spell_large_icestorm",
137 "spell_cancellation",
139 "spell_mass_confusion",
140 "spell_summon_pet_monster",
142 "spell_regenerate_spellpoints",
144 "spell_protection_from_confusion",
145 "spell_protection_from_cancellation",
146 "spell_protection_from_depletion",
148 "spell_remove_curse",
149 "spell_remove_damnation",
151 "spell_detect_magic",
152 "spell_detect_monster",
154 "spell_detect_curse",
162 "spell_face_of_death",
163 "spell_ball_lightning",
164 "spell_meteor_swarm",
168 "spell_resurrection",
169 "spell_reincarnation",
179 "spell_invulnerability",
181 "spell_rune_of_fire",
182 "spell_rune_of_frost",
183 "spell_rune_of_shocking",
184 "spell_rune_of_blasting",
185 "spell_rune_of_death",
186 "spell_marking_rune",
187 "spell_build_director",
188 "spell_create_pool_of_chaos",
189 "spell_build_bullet_wall",
190 "spell_build_lightning_wall",
191 "spell_build_fireball_wall",
193 "spell_rune_of_magic_drain",
194 "spell_antimagic_rune",
195 "spell_rune_of_transference",
196 "spell_transference",
198 "spell_counterspell",
200 "spell_cure_confusion",
204 "spell_cause_light_wounds",
205 "spell_cause_medium_wounds",
206 "spell_cause_heavy_wounds",
207 "spell_charm_monsters",
209 "spell_create_missile",
210 "spell_show_invisible",
215 "spell_command_undead",
217 "spell_summon_avatar",
218 "spell_holy_possession",
221 "spell_regeneration",
223 "spell_summon_cult_monsters",
224 "spell_cause_critical_wounds",
226 "spell_retributive_strike",
227 "spell_finger_of_death",
228 "spell_insect_plague",
229 "spell_call_holy_servant",
230 "spell_wall_of_thorns",
231 "spell_staff_to_snake",
238 "spell_cure_blindness",
240 "spell_bullet_swarm",
241 "spell_bullet_storm",
242 "spell_cause_many_wounds",
243 "spell_small_snowstorm",
244 "spell_medium_snowstorm",
245 "spell_large_snowstorm",
246 "spell_cure_disease",
247 "spell_cause_red_death",
249 "spell_cause_black_death",
250 "spell_cause_leprosy",
251 "spell_cause_smallpox",
252 "spell_cause_white_death",
253 "spell_cause_anthrax",
254 "spell_cause_typhoid",
256 "spell_small_manaball",
257 "spell_medium_manaball",
258 "spell_large_manaball",
260 "spell_dancing_sword",
261 "spell_animate_weapon",
263 "spell_divine_shock",
270 "spell_forked_lightning",
272 "spell_flaming_aura",
274 "spell_vitriol_splash",
276 "spell_wrathful_eye",
278 "spell_missile_swarm",
279 "spell_cause_rabies",
300 0, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1,
301 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1
306 0, -1, -1, 0, 1, 1, 1, 0, -1, -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2,
307 -3, -3, -3, -3, -2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3
312 0, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 27, 30, 31, 32, 33, 36, 37, 39, 39, 42, 43, 44, 45,
313 48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49
318 0, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 2, 2, 3, 4, 4, 4, 5, 6, 6, 6, 7, 8, 8, 8,
319 1, 2, 2, 2, 2, 2, 3, 4, 4, 4, 4, 4, 5, 6, 6, 6, 6, 6, 7, 8, 8, 8, 8, 8
330 active_objects = NULL;
336 objarray[0].
prev = NULL,
337 objarray[0].
next = &objarray[1],
340 for (
int i = 1; i <
STARTMAX-1; i++) {
341 objarray[i].
next = &objarray[i+1];
342 objarray[i].
prev = &objarray[i-1];
346 objarray[STARTMAX-1].
next = NULL;
347 objarray[STARTMAX-1].
prev = &objarray[STARTMAX-2];
372 for (wants_field = wants->
key_values; wants_field != NULL; wants_field = wants_field->
next) {
378 if (has_field == NULL) {
435 if (ob1 == ob2 || ob1->
type != ob2->
type)
459 if (ob1->
inv || ob2->
inv) {
478 || ((ob1->
flags[3]&~0x84) != (ob2->
flags[3]&~0x84))
560 sum += inv->carrying+inv->weight*
NROF(inv);
563 sum = (sum*(100-op->
stats.
Str))/100;
576 while (op->
env != NULL)
610 if (op->
owner == NULL)
638 if (op->
arch != NULL) {
692 for (op = objects; op != NULL; op = op->
next) {
715 for (op = objects; op != NULL; op = op->
next)
736 for (op = objects; op != NULL; op = op->
next)
737 if (op->
name == name)
756 for (op = free_objects; op != NULL; ) {
765 for (op = objects; op != NULL; ) {
790 if (op->
owner == NULL)
855 if (op->
owner != NULL)
901 if (op->
enemy == enemy) {
907 LOG(
llevDebug,
"object_set_enemy: %s(%lu)->enemy=%s(%lu)\n", op->
name, op->
count, enemy == NULL ?
"NONE" : enemy->
name, enemy == NULL ? 0 : enemy->
count);
946 for (i = op->
key_values; i != NULL; i = next) {
981 if (op->
name != NULL)
985 if (op->
title != NULL)
987 if (op->
race != NULL)
991 if (op->
skill != NULL)
995 if (op->
lore != NULL)
1004 memset((
void *)((
char *)op+
offsetof(
object, name)), 0,
sizeof(
object)-
offsetof(
object, name));
1053 if (dest_ob->
name != NULL)
1059 if (dest_ob->
title != NULL)
1061 if (dest_ob->
race != NULL)
1065 if (dest_ob->
skill != NULL)
1067 if (dest_ob->
msg != NULL)
1069 if (dest_ob->
lore != NULL)
1082 (void)memcpy((
void *)((
char *)dest_ob+
offsetof(
object, name)),
1083 (
void *)((
char *)src_ob+
offsetof(
object, name)),
1084 sizeof(
object)-
offsetof(
object, name));
1092 if (dest_ob->
name != NULL)
1098 if (dest_ob->
title != NULL)
1100 if (dest_ob->
race != NULL)
1104 if (dest_ob->
skill != NULL)
1106 if (dest_ob->
lore != NULL)
1108 if (dest_ob->
msg != NULL)
1121 if (dest_ob->
arch != NULL) {
1126 if (src_ob->
speed < 0)
1139 new_link->
next = NULL;
1144 new_link->
value = NULL;
1151 tail->
next = new_link;
1208 #ifndef MEMORY_DEBUG 1226 add[0].
next = &add[1],
1231 add[i].
next = &add[i+1],
1232 add[i].
prev = &add[i-1],
1236 add[OBJ_EXPAND-1].
prev = &add[OBJ_EXPAND-2],
1237 add[OBJ_EXPAND-1].
next = NULL,
1266 op =
static_cast<object *
>(calloc(1,
sizeof(
object)));
1270 if (free_objects == NULL) {
1280 free_objects = op->
next;
1281 if (free_objects != NULL)
1282 free_objects->
prev = NULL;
1301 if (objects != NULL)
1359 active_objects = op;
1420 int update_now = 0,
flags;
1421 MoveType move_on, move_off, move_block, move_slow;
1426 LOG(
llevDebug,
"object_update() called for NULL object.\n");
1430 if (op->
env != NULL) {
1446 LOG(
llevError,
"object_update() called for object out of map!\n");
1473 if ((move_on|op->
move_on) != move_on)
1475 if ((move_off|op->
move_off) != move_off)
1482 if ((move_slow|op->
move_slow) != move_slow)
1521 LOG(
llevError,
"object_update called with invalid action: %d\n", action);
1529 if (op->
more != NULL)
1555 object *inv = ob->
inv;
1582 LOG(
llevError,
"Free object called with non removed object\n");
1603 LOG(
llevError,
"Trying to free freed object.\n%s\n", diff);
1644 for (part = ob; part; part = part->
more) {
1648 partcount =
RANDOM()%partcount;
1649 for (part = ob; partcount > 0; partcount--) {
1669 if (ob->
more != NULL) {
1682 if (ob->
prev == NULL) {
1684 if (objects != NULL)
1685 objects->
prev = NULL;
1688 if (ob->
next != NULL)
1723 if (free_objects != NULL)
1724 free_objects->
prev = ob;
1793 while (op != NULL) {
1795 weight = (
signed long)(weight*(100-op->
stats.
Str)/100);
1819 object *last = NULL;
1833 LOG(
llevError,
"Trying to remove removed object.\n%s\n", diff);
1837 if (op->
more != NULL)
1847 if (op->
env != NULL) {
1867 while (above && !above->
contr)
1868 above = above->
above;
1884 if (op->
above != NULL)
1889 if (op->
below != NULL)
1916 if (op->
map == NULL)
1927 LOG(
llevError,
"object_remove called when object was on map but appears to not be within valid coordinates? %s (%d,%d)\n", op->
map->
path, op->
x, op->
y);
1931 LOG(
llevError,
"object_remove: Object not really on map it claimed to be on? %s != %s, %d,%d != %d,%d\n", op->
map->
path, m->
path, op->
x, op->
y, x, y);
1956 LOG(
llevError,
"object_remove: GET_MAP_OB on %s does not return object to be removed even though it appears to be on the bottom?\n%s\n", m->
path, diff);
1980 if (tmp->type ==
PLAYER && tmp != op) {
1985 if (tmp->container == op) {
1987 tmp->container = NULL;
1991 tmp->contr->socket->update_look = 1;
1995 && ((op->
move_type&tmp->move_off) && (op->
move_type&~tmp->move_off&~tmp->move_block) == 0)) {
1998 LOG(
llevError,
"BUG: object_remove(): name %s, archname %s destroyed leaving object\n", tmp->name, tmp->arch->name);
2003 if (tmp->above == tmp)
2041 for (top = op; top != NULL && top->
above != NULL; top = top->
above)
2089 for (tmp = op; tmp; tmp = tmp->
more) {
2132 if (op->
type == tmp->type
2133 && op->
subtype == tmp->subtype
2136 && op->
range == tmp->range
2137 && op->
stats.
wc == tmp->stats.wc
2138 && op->
level == tmp->level
2140 && op->
speed == tmp->speed
2142 && (tmp->speed_left+tmp->speed) < 0.0
2183 && op->
spell_tags[i] != tmp->spell_tags[i]) {
2191 if ((!op->
spell_tags[i] && tmp->spell_tags[i])
2192 || (op->
spell_tags[i] && !tmp->spell_tags[i])) {
2201 if (i <= SPELL_TAG_SIZE)
2212 && tmp->spell_tags[i]
2222 tmp->spell_tags = NULL;
2259 if (tmp->duration != op->
duration) {
2263 int tmp_dam = tmp->stats.dam*(tmp->duration+1)+
2283 object *floor = NULL;
2299 object *last = NULL;
2347 object *tmp, *top, *floor = NULL;
2361 LOG(
llevError,
"Trying to insert in null-map!\n%s\n", diff);
2372 LOG(
llevError,
"Trying to insert object outside the map.\n%s\n", diff);
2390 LOG(
llevError,
"Trying to insert (map) inserted object.\n%s\n", diff);
2394 if (op->
more != NULL) {
2397 object *more = op->
more;
2409 }
else if (!more->
map) {
2418 LOG(
llevError,
"BUG: object_insert_in_map(): inserting op->more killed op\n");
2430 if (op->
map == NULL) {
2441 op->
nrof += spot->nrof;
2480 if (originator->
map != op->
map 2481 || originator->
x != op->
x 2482 || originator->
y != op->
y) {
2483 LOG(
llevError,
"object_insert_in_map called with INS_BELOW_ORIGINATOR when originator not on same space!\n");
2486 op->
above = originator;
2493 originator->
below = op;
2512 if (op->
above == NULL)
2566 for (tmp = op->
more; tmp != NULL; tmp = tmp->
more)
2588 if (!strcmp(tmp->arch->name, arch_string)) {
2622 object *
object_split(
object *orig_ob, uint32_t nr,
char *err,
size_t size) {
2625 if (
MAX(1, orig_ob->
nrof) < nr) {
2628 snprintf(err, size,
"There are only %u %ss.",
NROF(orig_ob), orig_ob->
name);
2634 if (orig_ob->
nrof == 0) {
2672 }
else if (op->
env != NULL) {
2720 pl->contr->socket->update_look = 1;
2756 }
else if (op->
env != NULL) {
2797 pl->contr->socket->update_look = 1;
2819 while (op != NULL) {
2821 weight = (
signed long)(weight*(100-op->
stats.
Str)/100);
2852 LOG(
llevError,
"Trying to insert (ob) inserted object.\n%s\n", diff);
2857 if (where == NULL) {
2864 LOG(
llevError,
"Trying to put object in NULL.\n%s\n", diff);
2869 LOG(
llevDebug,
"Warning: Tried to insert object wrong part of multipart object.\n");
2871 where =
HEAD(where);
2916 if (where->
inv == NULL)
2930 if (where->
contr != NULL)
2952 if (otmp && otmp->
contr != NULL) {
2963 LOG(
llevDebug,
" object_insert_in_ob(): got %s to insert in map/op\n", op->
name);
3001 int x = op->
x, y = op->
y;
3002 MoveType move_on, move_slow, move_block;
3028 if ((op->
move_type&~move_on&~move_block) != 0
3029 && (op->
move_type&~move_slow&~move_block) != 0)
3038 if (tmp->
above == NULL)
3084 if (op->
map != m || op->
x != x || op->
y != y)
3110 if (tmp->arch == at)
3136 if (tmp->type == type)
3156 for (tmp = op->
inv; tmp != NULL; tmp = tmp->
below)
3157 if (tmp->
type == type)
3191 for (tmp = op->
inv; tmp != NULL; tmp = tmp->
below) {
3192 if ((type == -1 || tmp->
type == type) && !strcmp(str, tmp->
name))
3210 for (tmp = op->
inv; tmp != NULL; tmp = tmp->
below)
3211 if (tmp->
arch == at)
3227 for (tmp = op->
inv; tmp != NULL; tmp = tmp->
below) {
3244 for (tmp = op->
inv; tmp != NULL; tmp = tmp->
below) {
3282 int genx, geny, genx2, geny2, sx, sy, sx2, sy2, ix, iy, nx, ny, i, flag;
3305 ix = gen->
x-sx-genx2;
3306 iy = gen->
y-sy-geny2;
3318 for (i = 0; i < (sx+sx+sy+sy); i++) {
3322 }
else if (i <= sx+sy) {
3325 }
else if (i <= sx+sy+sx) {
3326 nx = ix+sx-(i-(sx+sy));
3330 ny = iy+sy-(i-(sx+sy+sx));
3343 freecount =
RANDOM()%freecount;
3344 for (i = 0; i < sx+sx+sy+sy; i++) {
3348 }
else if (i <= sx+sy) {
3351 }
else if (i <= sx+sy+sx) {
3352 nx = ix+sx-(i-(sx+sy));
3356 ny = iy+sy-(i-(sx+sy+sx));
3368 if (freecount <= 0) {
3398 int genx, geny, genx2, geny2, sx, sy, sx2, sy2, ix, iy, nx, ny, i, flag;
3399 int8_t x, y, radius;
3400 int freecount = 0, freecountstop = 0;
3408 radius = (int8_t)strtol(value, NULL, 10);
3440 ix = gen->
x-sx-genx2-radius+1;
3441 iy = gen->
y-sy-geny2-radius+1;
3442 sx += genx+sx2+radius*2-1;
3443 sy += geny+sy2+radius*2-1;
3453 x_array =
static_cast<int8_t *
>(malloc(sx*sy*
sizeof(int8_t)));
3454 y_array =
static_cast<int8_t *
>(malloc(sx*sy*
sizeof(int8_t)));
3459 for (x = 0; x < sx; x++) {
3460 for (y = 0; y < sy; y++) {
3473 x_array[freecount] = nx;
3474 y_array[freecount] = ny;
3487 freecountstop =
RANDOM()%freecount;
3488 for (i = 0; i < freecount; i++) {
3496 if (freecountstop <= 0) {
3545 int i, index = 0, flag;
3548 for (i = start; i < stop; i++) {
3551 altern[index++] = i;
3566 return altern[
RANDOM()%index];
3603 static void permute(
int *arr,
int begin,
int end) {
3607 for (i = begin; i < end; i++) {
3649 i = (ob1->
x-ob2->
x)*(ob1->
x-ob2->
x)+
3650 (ob1->
y-ob2->
y)*(ob1->
y-ob2->
y);
3895 object *dst = NULL, *tmp, *src, *part, *prev;
3902 for (part = src; part; part = part->more) {
3909 tmp->carrying = tmp->arch->clone.carrying;
3945 for (tmp = who->
inv; tmp; tmp = tmp->
below)
3946 if (tmp->
name == name_shared)
3968 for (tmp = who->
inv; tmp; tmp = tmp->
below)
3969 if (tmp->
type == type)
3991 for (
object *tmp = who->
inv; tmp; tmp = tmp->
below)
3992 if (tmp->type == type) {
3994 for (
int i = 0; i < num_flags; ++i) {
4025 for (tmp = who->
inv; tmp; tmp = tmp->
below)
4026 if (tmp->
type == type1 || tmp->
type == type2)
4048 for (tmp = who->
inv; tmp; tmp = tmp->
below)
4049 if (tmp->
count == tag)
4071 for (tmp = who->
inv; tmp != NULL; tmp = tmp->
below)
4096 for (tmp = who->
inv; tmp != NULL; tmp = tmp->
below)
4097 if (tmp->
type == type && strcmp(tmp->
name, name) == 0)
4121 for (tmp = who->
inv; tmp != NULL; tmp = tmp->
below)
4122 if (tmp->
type == type && strcmp(tmp->
race, race) == 0)
4146 for (tmp = who->
inv; tmp != NULL; tmp = tmp->
below)
4171 for (tmp = who->
inv; tmp != NULL; tmp = tmp->
below)
4172 if (tmp->
type == type && tmp->
skill != NULL && strcmp(tmp->
skill, skill) == 0)
4194 for (tmp = who->
inv; tmp != NULL; tmp = tmp->
below)
4217 for (tmp = who->
inv; tmp != NULL; tmp = tmp->
below)
4240 for (tmp = who->
inv; tmp != NULL; tmp = tmp->
below)
4241 if (strcmp(tmp->
arch->
name, name) == 0)
4265 for (tmp = who->
inv; tmp != NULL; tmp = tmp->
below)
4266 if (tmp->
type == type && strcmp(tmp->
arch->
name, name) == 0)
4289 for (tmp = who->
inv; tmp; tmp = tmp->
below)
4310 if (link->
key == key) {
4333 const char *canonical_key;
4337 if (canonical_key == NULL) {
4350 if (link->
key == canonical_key) {
4363 if (ret == NULL || (strcmp(ret,
"") == 0) || (strcmp(ret,
"0") == 0)) {
4377 if (link->key == key) {
4378 if ((strcmp(link->value,
"") == 0) || (strcmp(link->value,
"0") == 0)) {
4404 for (field = op->
key_values; field != NULL; field = field->
next) {
4405 if (field->
key != canonical_key) {
4421 field->
value = NULL;
4429 last->next = field->
next;
4485 const char *canonical_key = NULL;
4486 int floating_ref =
FALSE;
4494 if (canonical_key == NULL) {
4496 floating_ref =
TRUE;
4561 int count, retval = 0;
4566 for (cp = strtok(local_name,
","); cp; cp = strtok(NULL,
",")) {
4567 while (cp[0] ==
' ')
4572 if (!strcmp(cp,
"all"))
4578 if (!strcmp(cp,
"cursed")
4588 if (*cp ==
'+' || *cp ==
'-')
4591 cp = strchr(cp,
' ');
4592 while (cp && cp[0] ==
' ')
4601 if (!cp || cp[0] ==
'\0' || count < 0)
4623 else if (custom_name && !
strcasecmp(cp, custom_name))
4625 else if (!strncasecmp(cp, bname_s, strlen(cp)))
4627 else if (!strncasecmp(cp, bname_p, strlen(cp)))
4634 else if (strstr(bname_p, cp))
4636 else if (strstr(bname_s, cp))
4638 else if (strstr(name_short, cp))
4650 else if (custom_name && strstr(custom_name, cp))
4675 LOG(
llevError,
"object_fix_multipart: not on a map!\n");
4686 for (at = tmp->
arch->
more, last = tmp; at != NULL; at = at->
more, last = op) {
4731 int maxx = 0, maxy = 0, minx = 0, miny = 0;
4737 for (part = ob->
arch; part; part = part->
more) {
4738 if (part->
clone.
x > maxx)
4740 if (part->
clone.
y > maxy)
4742 if (part->
clone.
x < minx)
4744 if (part->
clone.
y < miny)
4797 if (op->
msg != NULL) {
4803 if (*msg !=
'\0' && strchr(msg,
'\0')[-1] !=
'\n') {
4837 "alive",
"wiz", NULL, NULL,
"was_wiz",
"applied",
"unpaid",
4838 "can_use_shield",
"no_pick",
"client_anim_sync",
"client_anim_random",
4839 "is_animated", NULL ,
4840 NULL ,
"monster",
"friendly",
"generator",
4841 "is_thrown",
"auto_apply",
"treasure",
"player sold",
4842 "see_invisible",
"can_roll",
"overlay_floor",
4843 "is_turnable", NULL , NULL ,
4844 NULL ,
"is_used_up",
"identified",
"reflecting",
4845 "changing",
"splitting",
"hitback",
"startequip",
4846 "blocksview",
"undead",
"scared",
"unaggressive",
4847 "reflect_missile",
"reflect_spell",
4848 "no_magic",
"no_fix_player",
"is_lightable",
"tear_down",
4849 "run_away", NULL , NULL ,
4850 NULL ,
"unique",
"no_drop",
4851 NULL ,
"can_cast_spell",
"can_use_scroll",
"can_use_range",
4852 "can_use_bow",
"can_use_armour",
"can_use_weapon",
4853 "can_use_ring",
"has_ready_range",
"has_ready_bow",
4854 "xrays", NULL,
"is_floor",
"lifesave",
"no_strength",
"sleep",
4855 "stand_still",
"random_movement",
"only_attack",
"confused",
4856 "stealth", NULL, NULL,
"cursed",
"damned",
4857 "see_anywhere",
"known_magical",
"known_cursed",
4858 "can_use_skill",
"been_applied",
4859 "has_ready_scroll", NULL, NULL,
4860 NULL,
"make_invisible",
"inv_locked",
"is_wooded",
4861 "is_hilly",
"has_ready_skill",
"has_ready_weapon",
4862 "no_skill_ident",
"is_blind",
"can_see_in_dark",
"is_cauldron",
4863 NULL,
"no_steal",
"one_hit", NULL,
"berserk",
"neutral",
4864 "no_attack",
"no_damage", NULL, NULL,
"activate_on_push",
4865 "activate_on_release",
"is_water",
"use_content_on_gen", NULL,
"is_buildable",
4866 NULL,
"blessed",
"known_blessed" 4880 int i, all_count = 0, count;
4883 strcpy(retbuf_all,
" all");
4899 for (i =
MOVE_ALL, count = 0; i != 0; i >>= 1, count++) {
4900 if (mt&(1<<count)) {
4901 strcat(retbuf,
" ");
4904 strcat(retbuf_all,
" -");
4946 for (
int i = 0; i < 4; i++) {
4947 int idx = ffs((*diff)[i]);
4951 (*diff)[i] &= ~(1 << bit);
4972 static char buf2[64];
4981 for (my_field = op->
key_values; my_field != NULL; my_field = my_field->
next) {
4986 if (arch_field == NULL || my_field->
value != arch_field->
value) {
4992 if (my_field->
value)
5098 if (op->
x != op2->
x)
5100 if (op->
y != op2->
y)
5328 LOG(
llevError,
"could not find original archetype %s for custom monster!\n", at->
name);
5348 if (artifact == NULL) {
5386 if (fputs(cp, fp) == EOF) {
5398 if (death_animation != NULL && strcmp(death_animation,
"NONE")) {
5401 if (death != NULL) {
5415 object *
add_force(
object *op,
const char *name,
int duration) {
5418 if (force == NULL) {
5424 if (duration != 0) {
5425 force->
speed = 0.01;
object * object_find_by_flag_applied(const object *who, int flag)
Find applied object in inventory by flag.
#define FLAG_NO_MAGIC
Spells (some) can't pass this object.
#define SET_MAP_OB(M, X, Y, tmp)
Sets the bottom object on a map.
#define FLAG_NO_DROP
Object can't be dropped.
void object_free_key_values(object *op)
Zero the key_values on op, decrementing the shared-string refcounts and freeing the links...
signed long object_sum_weight(object *op)
object_sum_weight() is a recursive function which calculates the weight an object is carrying...
#define NUM_BODY_LOCATIONS
Number of body locations.
uint16_t attack_movement
What kind of attack movement.
#define FLAG_DAMNED
The object is very cursed.
#define FLAG_UNPAID
Object hasn't been paid for yet.
#define MOVE_WALK
Object walks.
#define UP_OBJ_FACE
Only thing that changed was the face.
void update_position(mapstruct *m, int x, int y)
This function updates various attributes about a specific space on the map (what it looks like...
int object_check_move_on(object *op, object *originator)
Checks if any objects has a move_type that matches objects that effect this object on this space...
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
int maxfree[SIZEOFFREE]
Number of spots around a location, including that location (except for 0)
#define FLAG_IS_LINKED
The object is linked with other objects.
see doc/Developers/objects
tag_t ownercount
What count the owner had (in case owner has been freed)
#define INS_BELOW_ORIGINATOR
Insert new object immediately below originator.
#define GET_MAP_MOVE_OFF(M, X, Y)
Gets the move_off state of a square.
void free_dialog_information(object *op)
Frees obj::dialog_information.
int8_t item_power
Power rating of the object.
struct archetype * arch
Pointer to archetype.
static void expand_objects(void)
Allocates more objects for the list of unused objects.
#define P_PLAYER
There is a player on this space.
#define SAVE_ERROR_OK
No error.
object * active_objects
List of active objects that need to be processed.
#define P_NEED_UPDATE
This space is out of date.
void object_add_weight(object *op, signed long weight)
object_add_weight(object, weight) adds the specified weight to an object, and also updates how much t...
const char *const spell_mapping[SPELL_MAPPINGS]
This table is only necessary to convert objects that existed before the spell object conversion to th...
uint32_t hidden
If True, player (DM) is hidden from view.
#define FOR_OB_AND_ABOVE_PREPARE(op_)
Constructs a loop iterating over an object and all objects above it in the same pile.
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
#define OBJ_EXPAND
How big steps to use when expanding array.
int16_t players
How many players are on this level right now.
void object_set_flag_inv(object *op, int flag)
Activate recursively a flag on an object's inventory.
void esrv_send_item(object *pl, object *op)
Sends item's info to player.
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
object_split(ob,nr) splits up ob into two parts.
void animate_object(object *op, int dir)
Updates the face-variable of an object.
void object_unset_flag_inv(object *op, int flag)
Desactivate recursively a flag on an object inventory.
void init_objects(void)
Sets up and initialises the linked list of free and used objects.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
float weapon_speed_left
How much speed is left to spend this round.
key_value * object_get_key_value(const object *ob, const char *key)
Search for a field by key.
int8_t direction
Means the object is moving that way.
#define FABS(x)
Decstations have trouble with fabs()...
void object_handle_death_animation(object *op)
uint32_t weapontype
Type of weapon.
int nroffreeobjects
How many OBs allocated and free (free)
uint8_t map_layer
What level to draw this on the map.
uint64_t spell_merges
Number of spell merges done.
float move_slow_penalty
How much this slows down the object.
#define FLAG_FRIENDLY
Will help players.
#define FLAG_IS_FLOOR
Can't see what's underneath this object.
archetype * find_archetype(const char *name)
object * object_find_by_flag(const object *who, int flag)
Find object in inventory by flag.
#define P_NO_MAGIC
Spells (some) can't pass this object.
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
object * object_find_by_type2(const object *who, int type1, int type2)
Find object in inventory.
void object_set_msg(object *op, const char *msg)
Set the message field of an object.
object * prev
Pointer to the previous object in the free/used list.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
void object_update_turn_face(object *op)
If an object with the IS_TURNABLE() flag needs to be turned due to the closest player being on the ot...
player * first_player
First player.
#define FLAG_NO_FIX_PLAYER
fix_object() won't be called
object * object_find_by_type_without_flags(const object *who, int type, int *flags, int num_flags)
Find an object in inventory that does not have any of the provided flags set.
int16_t maxgrace
Maximum grace.
#define LOOK_OBJ(ob)
This returns TRUE if the object is something that should be displayed in the look window...
object * below
Pointer to the object stacked below this one.
#define UP_OBJ_INSERT
Object was inserted.
int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
object_find_free_spot(object, map, x, y, start, stop) will search for a spot at the given map and coo...
object * object_find_by_name(const object *who, const char *name)
Finds an object in inventory name.
uint32_t count
Any numbers typed before a command.
#define HUGE_BUF
Used for messages - some can be quite long.
void esrv_update_item(int flags, object *pl, object *op)
Updates object *op for player *pl.
object * more
Pointer to the rest of a large body of objects.
sstring slaying
Which race to do double damage to.
static uint32_t NROF(const object *const ob)
Returns ob->nrof, unless it is 0, in which case return 1.
void object_sub_weight(object *op, signed long weight)
Recursively (outwards) subtracts a number from the weight of an object (and what is carried by it's e...
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.
struct Statistics statistics
Merged spell statistics.
#define MAP_HEIGHT(m)
Map height.
#define FREE_AND_CLEAR_STR_IF(xyz)
uint8_t will_apply
See crossfire.doc and What monsters apply.
object * above
Pointer to the object stacked above this one.
Each object (this also means archetypes!) could have a few of these "dangling" from it; this could al...
void remove_friendly_object(object *op)
Removes the specified object from the linked list of friendly objects.
sstring find_string(const char *str)
Searches a string in the shared strings.
int object_find_first_free_spot(const object *ob, mapstruct *m, int x, int y)
object_find_first_free_spot(archetype, mapstruct, x, y) works like object_find_free_spot(), but it will search max number of squares.
void object_free_all_data(void)
Destroys all allocated objects.
unsigned char MoveType
Typdef here to define type large enough to hold bitmask of all movement types.
static void FAST_SAVE_LONG(StringBuffer *sb, const char *name, const long value)
Adds a long to the buffer.
int16_t y
Position in the map for this object.
object * object_find_by_type_applied(const object *who, int type)
Find applied object in inventory.
int8_t magic
Any magical bonuses to this item.
#define FREE_OBJ_NO_DESTROY_CALLBACK
Do not run the destroy callback.
uint16_t material
What materials this object consist of.
uint32_t get_weight_limit(int stat)
sstring add_refcount(sstring str)
Like add_string(), but the string is already a shared string.
MoveType move_block
What movement types this blocks.
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
object * next
Pointer to the next object in the free/used list.
#define OUT_OF_REAL_MAP(M, X, Y)
Checks if a square is out of the map.
#define object_was_destroyed(op, old_tag)
Checks if an object still exists.
object * attacked_by
This object start to attack us! only player & monster.
static void ADD_STRINGLINE_ENTRY(StringBuffer *sb, const char *name, const char *value)
Adds a line to the buffer.
int16_t duration
Number of moves (see 'speed') spell lasts.
MoveType move_on
Move types affected moving on to this space.
int object_count_used(void)
Object statistics.
void object_set_owner(object *op, object *owner)
Sets the owner and sets the skill and exp pointers to owner's current skill and experience objects...
int object_distance(const object *ob1, const object *ob2)
Return the square of the distance between the two given objects.
uint32_t path_repelled
Paths the object is repelled from.
Global type definitions and header inclusions.
struct player * contr
Pointer to the player which control this object.
double expmul
needed experience = (calc_exp*expmul) - means some races/classes can need less/more exp to gain level...
object * object_find_by_arch_name(const object *who, const char *name)
Find object in inventory by archetype name.
object * object_find_by_type_and_slaying(const object *who, int type, const char *slaying)
Find object in inventory by type and slaying.
uint8_t casting_time
It takes awhile to cast a spell.
uint64_t spell_hash_full
Number of times spell hash was full.
tag_t * spell_tags
Tags used for spell effect merging.
#define FOR_OB_AND_BELOW_FINISH()
Finishes FOR_OB_AND_BELOW_PREPARE().
sstring stringbuffer_finish_shared(StringBuffer *sb)
Deallocate the string buffer instance and return the string as a shared string.
#define FLAG_REMOVED
Object is not in any map or invenory.
static int compare_ob_value_lists(const object *, const object *)
Compares two object lists.
int32_t weight
Attributes of the object.
float weapon_speed
The overall speed of this object.
object * transport
Transport the player is in.
static int compare_ob_value_lists_one(const object *, const object *)
Compares value lists.
#define SAVE_ERROR_WRITE
Write error.
object * owner
Pointer to the object which controls this one.
uint8_t run_away
Monster runs away if it's hp goes below this percentage.
#define MOVE_ALL
Mask of all movement types.
const Face * blank_face
Following can just as easily be pointers, but it is easier to keep them like this.
object * object_create_clone(object *asrc)
Create clone from object to another.
void object_dump_all(void)
Dumps all objects to console.
void esrv_del_item(player *pl, object *ob)
Tells the client to delete an item.
void object_copy_no_speed(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 SCRIPT_FIX_NOTHING
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
#define SAVE_FLAG_SAVE_UNPAID
If set, unpaid items will be saved.
#define MAP_IN_MEMORY
Map is fully loaded.
uint32_t update_look
If true, we need to send the look window.
int16_t level
Level of creature or object.
object * object_find_by_type_and_arch_name(const object *who, int type, const char *name)
Find object in inventory by type and archetype name.
void stringbuffer_append_char(StringBuffer *sb, const char c)
Append a character to a string buffer instance.
object * object_decrease_nrof(object *op, uint32_t i)
Decreases a specified number from the amount of an object.
int object_matches_string(object *pl, object *op, const char *name)
This is a subset of the parse_id command.
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
player * next
Pointer to next player, NULL if this is last.
#define FREE_OBJ_FREE_INVENTORY
Free inventory objects; if not set, drop inventory.
sstring key
Name of the key.
int16_t casting_time
Time left before spell goes off.
#define FLAG_CLIENT_ANIM_SYNC
Let client animate this, synchronized.
void save_object_in_sb(StringBuffer *sb, object *op, const int flag)
Store a string representation of op in sb.
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Find object in inventory.
#define BITMASK_VALID
Bit indicating if the event bitmask is valid or not.
#define STARTMAX
How big array of objects to start with.
#define FLAG_ALIVE
Object can fight (or be fought)
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
static void permute(int *, int, int)
Randomly permutes an array.
uint32_t do_los
If true, need to call update_los() in draw(), and clear.
void stringbuffer_append_int64(StringBuffer *sb, int64_t x)
Append a signed integer to a string buffer instance.
#define FLAG_OBJ_ORIGINAL
NEVER SET THIS.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
void object_get_multi_size(const object *ob, int *sx, int *sy, int *hx, int *hy)
Computes the size of a multitile object.
#define FOR_OB_AND_ABOVE_FINISH()
Finishes FOR_OB_AND_ABOVE_PREPARE().
sstring materialname
Specific material name.
object * object_find_by_tag(const object *who, tag_t tag)
Find object in inventory.
sstring name
More definite name, like "generate_kobold".
object * object_insert_in_map(object *op, mapstruct *m, object *originator, int flag)
This function inserts the object in the two-way linked list which represents what is on a map...
#define MAP_DARKNESS(m)
Map darkness level (0-MAX_DARKNESS)
#define INS_ON_TOP
Always put object on top.
#define FLAG_NO_STEAL
Item can't be stolen.
Defines for loader.l / loader.c.
int8_t range
Range of the spell.
float speed
Frequency of object 'moves' relative to server tick rate.
int32_t carrying
How much weight this object contains.
object * object_find_by_name_global(const char *str)
Finds an object by name.
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Append a formatted string to a string buffer instance.
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
#define MOVE_FLY_LOW
Low flying object.
char path[HUGE_BUF]
Filename of the map.
#define FOR_ABOVE_FINISH()
Finishes FOR_ABOVE_PREPARE().
object * create_archetype(const char *name)
Finds which archetype matches the given name, and returns a new object containing a copy of the arche...
object * env
Pointer to the object which is the environment.
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Append a string to a string buffer instance.
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.
sstring anim_suffix
Used to determine combined animations.
void object_free_inventory(object *ob)
Frees the inventory of an object, without any callback.
#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-...
uint8_t pick_up
See crossfire.doc.
static void FAST_SAVE_DOUBLE(StringBuffer *sb, const char *name, const double value)
Adds a double to the buffer.
void query_name(const object *op, char *buf, size_t size)
Describes an item.
int strcasecmp(const char *s1, const char *s2)
void object_set_cheat(object *op)
object_set_cheat(object) sets the cheat flag (WAS_WIZ) in the object and in all it's inventory (recur...
void object_fix_multipart(object *tmp)
Ensures specified object has its more parts correctly inserted in map.
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.
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
tag_t attacked_by_count
The tag of attacker, so we can be sure.
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
socket_struct * socket
Socket information for this player.
sstring msg
If this is a book/sign/magic mouth/etc.
uint8_t smoothlevel
how to smooth this square around
object * head
Points to the main object of a large body.
sstring race
Human, goblin, dragon, etc.
void object_reset(object *op)
Totally resets the specified object, without freeing associated memory.
const Animations * animation
Animation of this item, NULL if not animated.
#define FLAG_BLOCKSVIEW
Object blocks view.
void object_dump(const object *op, StringBuffer *sb)
Dumps an object.
void get_search_arr(int *search_arr)
New function to make monster searching more efficient, and effective! This basically returns a random...
int ob_blocked(const object *ob, mapstruct *m, int16_t x, int16_t y)
Returns true if the given object can't fit in the given spot.
void update_all_los(const mapstruct *map, int x, int y)
This function makes sure that update_los() will be called for all players on the given map within the...
#define FOR_ABOVE_PREPARE(op_, it_)
Constructs a loop iterating over all objects above an object.
int object_find_multi_free_spot_around(const object *ob, const object *gen, int16_t *hx, int16_t *hy)
Sets hx and hy to the coords to insert a possibly multi-tile ob at, around gen.
uint8_t range_modifier
How going up in level affects range.
#define OB_SPELL_TAG_MATCH(op, count)
Check whether a tag matches in the tags.
ob_flags flags
Various flags.
key_value * key_values
Fields not explictly known by the loader.
#define EVENT_DESTROY
Object destroyed (includes map reset/swapout)
int out_of_map(mapstruct *m, int x, int y)
Return 1 if coordinates X and Y are out of the map M, taking into account tiling. ...
#define INS_NO_WALK_ON
Don't call check_walk_on against the originator.
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
#define offsetof(type, member)
The offsetof macro is part of ANSI C, but many compilers lack it, for example "gcc -ansi"...
#define FLAG_IS_A_TEMPLATE
Object has no ingame life until instantiated.
static const object * object_get_owner_const(const object *op)
Returns the object which this object marks as being the owner, constant version.
key_value * next
Next key in the list.
#define GET_MAP_TOP(M, X, Y)
Gets the top object on a map.
object * ob
The object representing the player.
uint64_t event_bitmask
Bitmask of events this object has a handler for, see events.h.
#define NUM_FLAGS
Should always be equal to the last defined flag.
const Face * face
Face with colors.
method_ret ob_move_on(object *op, object *victim, object *originator)
Makes an object move on top of another one.
int8_t glow_radius
indicates the glow radius of the object
uint8_t dam_modifier
How going up in level affects damage.
#define GET_MAP_MOVE_ON(M, X, Y)
Gets the move_on state of a square.
int find_dir_2(int x, int y)
Computes a direction which you should travel to move of x and y.
#define FLAG_OVERLAY_FLOOR
Object is an overlay floor.
#define P_OUT_OF_MAP
This space is outside the map.
#define GET_MAP_MOVE_BLOCK(M, X, Y)
Gets the blocking state of a square.
object * find_force(object *op, const char *name)
Find a force with the given 'name' in the slaying field.
struct Settings settings
Global settings.
uint8_t state
How the object was last drawn (animation)
sstring lore
Obscure information about this object, to get put into books and the like.
void object_copy_with_inv(const object *src_ob, object *dest_ob, bool update_speed)
Copy an object with an inventory, duplicate the inv too.
object * object_get_env_recursive(object *op)
Utility function.
object * object_new(void)
Grabs an object from the list of unused objects, makes sure it is initialised, and returns it...
object * object_present_in_ob(uint8_t type, const object *op)
Searches for any objects with a matching type variable in the inventory of the given object...
object * add_force(object *op, const char *name, int duration)
Add or return an existing force inside 'op' with the given 'name' and 'duration' in units of 100 tick...
#define FREE_AND_CLEAR_STR(xyz)
Release the shared string, and set it to NULL.
#define MAP_SAVING
Map being saved.
uint32_t tag_t
Object tag, unique during the whole game.
int16_t dam
How much damage this object does when hitting.
void object_replace_insert_in_map(const char *arch_string, object *op)
This function inserts an object of a specified archetype in the map, but if it finds objects of its o...
#define HEAD(op)
Returns the head part of an object.
uint32_t path_denied
Paths the object is denied access to.
int freedir[SIZEOFFREE]
Direction we're pointing on this spot.
#define INS_ABOVE_FLOOR_ONLY
Put object immediatly above the floor.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
int object_find_multi_free_spot_within_radius(const object *ob, const object *gen, int *hx, int *hy)
Sets hx and hy to the coords to insert a possibly multi-tile ob at, within radius of generator...
living stats
Str, Con, Dex, etc.
#define MAX_BUF
Used for all kinds of things.
static void compare_flags(ob_flags *ret, const object *p, const object *q)
int16_t invisible
How much longer the object will be invis.
object * map_find_by_archetype(mapstruct *m, int x, int y, const archetype *at)
Searches for any objects with a matching archetype at the given map and coordinates.
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
This is basically the same as out_of_map above(), but instead we return NULL if no map is valid (coor...
float speed_left
How much speed is left to spend this round.
object * arch_present_in_ob(const archetype *at, const object *op)
Searches for any objects with a matching archetype in the inventory of the given object.
int save_object(FILE *fp, object *op, int flag)
Dumps all variables in an object to a file.
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...
struct mapstruct * map
Pointer to the map in which this object is present.
Skill-related defines, including subtypes.
void object_remove_from_active_list(object *op)
This function removes object 'op' from the list of active objects.
object * object_find_by_tag_global(tag_t i)
Returns the object which has the count-variable equal to the argument.
int object_can_pick(const object *who, const object *item)
Finds out if an object can be picked up.
uint32_t in_memory
Combination of IN_MEMORY_xxx flags.
Implements a general string buffer: it builds a string by concatenating.
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
static const char *const flag_names[NUM_FLAGS+1]
This is a list of pointers that correspond to the FLAG_.
object * object_present_in_ob_by_name(int type, const char *str, const object *op)
Searches for any objects with a matching type & name variable in the inventory of the given object...
static const flag_definition flags[]
Flag mapping.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
MoveType move_slow
Movement types this slows down.
#define FLAG_NO_APPLY
Avoids step_on/fly_on to this object.
object * object_find_by_type_and_name(const object *who, int type, const char *name)
Find object in inventory by type and name.
#define FLAG_KNOWN_CURSED
The object is known to be cursed.
#define GET_MAP_FLAGS(M, X, Y)
Gets map flags.
#define FLAG_IS_HILLY
Item is hilly/mountain terrain.
object * object_merge(object *op, object *top)
This function goes through all objects below and including top, and merges op to the first matching o...
#define SPELL_TAG_SIZE
Defines default size of the *spell_tags pointer.
#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...
static void object_increase_nrof(object *op, uint32_t i)
Increase the count of an object.
struct treasurelist * randomitems
Items to be generated.
#define SET_MAP_FLAGS(M, X, Y, C)
Sets map flags.
int8_t body_info[NUM_BODY_LOCATIONS]
Body info as loaded from the file.
#define FLAG_ANIMATE
The object looks at archetype for faces.
sstring name_pl
The plural name of the object.
Object structure, the core of Crossfire.
void query_base_name(const object *op, int plural, char *buf, size_t size)
Query a short name for the item.
const char *const move_name[]
Maps the MOVE_* values to names.
object * active_next
Next object in the 'active' list This is used in process_events so that the entire object list does n...
int object_count_active(void)
Objects statistics.
#define INS_NO_MERGE
Don't try to merge with other items.
int dirdiff(int dir1, int dir2)
Computes a direction difference.
static event_registration m
object * container
Current container being used.
#define UP_OBJ_CHANGE
Object changed.
void object_merge_spell(object *op, int16_t x, int16_t y)
This sees if there are any objects on the space that can merge with op.
int nrofallocobjects
How many OBs allocated (free + used)
Also see SKILL_TOOL (74) below.
#define GET_MAP_PLAYER(M, X, Y)
#define UP_OBJ_REMOVE
Object was removed.
MoveType move_type
Type of movement this object uses.
object * object_find_by_type_and_skill(const object *who, int type, const char *skill)
Find object in inventory by type and skill.
static const int reduction_dir[SIZEOFFREE][3]
Basically, this is a table of directions, and what directions one could go to go back to us...
sstring name
The name of the object, obviously...
sstring title
Of foo, etc.
#define MAP_WIDTH(m)
Map width.
Only for debugging purposes.
uint32_t nrof
Number of objects.
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_...
sstring name
Usually monster-name/combination.
MoveType move_off
Move types affected moving off this space.
MoveType move_allow
What movement types explicitly allowed.
bool object_value_set_shared(const object *op, sstring key)
Determine if an extra value is set to a non empty or 0 value.
const char *const map_layer_name[MAP_LAYERS]
These correspond to the layer names in map.h - since some of the types can be on multiple layers...
archetype * empty_archetype
Nice to have fast access to it.
static object * find_insert_pos(object *op, const int flag)
void object_set_enemy(object *op, object *enemy)
Sets the enemy of an object.
#define CLEAR_FLAG(xyz, p)
uint8_t type
PLAYER, BULLET, etc.
#define BITMASK_EVENT(evt)
Convert an event to its bit.
int8_t ac
Armor Class, lower AC increases probability of not getting hit.
int reference_count
How many times this temporary archetype is used.
#define FLAG_APPLIED
Object is ready for use by living.
sstring value
Key's value.
void get_ob_diff(StringBuffer *sb, const object *op, const object *op2)
Returns a pointer to a static string which contains all variables which are different in the two give...
object * active_prev
Previous object in the 'active list This is used in process_events so that the entire object list doe...
void object_update_speed(object *op)
Updates the speed of an object.
int can_see_monsterP(mapstruct *m, int x, int y, int dir)
Recursive routine to see if we can find a path to a certain point.
#define OB_SPELL_TAG_HASH(op, count)
Get the hash on an object for a specified count.
body_locations_struct body_locations[NUM_BODY_LOCATIONS]
The ordering of this is actually doesn't make a difference However, for ease of use, new entries should go at the end so those people that debug the code that get used to something being in the location 4 don't get confused.
uint16_t client_type
Public type information.
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
static object objarray[STARTMAX]
All objects, allocated this way at first.
object * inv
Pointer to the first object in the inventory.
#define FOR_OB_AND_BELOW_PREPARE(op_)
Constructs a loop iterating over an object and all objects below it in the same pile.
#define FLAG_STARTEQUIP
Object was given to player at start.
object * objects
Pointer to the list of used objects.
sstring name
Name of the animation sequence.
void free_arch(archetype *at)
Frees archetype.
Lauwenmark: an invisible object holding a plugin event hook.
void object_copy_owner(object *op, object *clone)
Set the owner to clone's current owner and set the skill and experience objects to clone's objects (t...
#define MIN_ACTIVE_SPEED
Cut off point of when an object is put on the active list or not.
int64_t total_exp
All exp ever earned (used to calc perm_exp)
int8_t gen_sp_armour
Sp regen penalty this object has (was last_heal)
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
uint8_t sound_chance
Probability, 1 to 100, of the object emitting a sound.
sstring skill
Name of the skill this object uses/grants.
int16_t maxsp
Max spell points.
uint32_t attacktype
Bitmask of attacks this object does.
void object_clear_owner(object *op)
Clears the owner of specified object.
int events_execute_object_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
Execute an event on the specified object.
int32_t last_heal
Last healed.
static void get_string_move_type(StringBuffer *sb, MoveType mt)
This returns a string of the integer movement type.
const char *const resist_save[NROFATTACKS]
Attack types.
#define MOVE_FLY_HIGH
High flying object.
object * object_find_by_type_and_race(const object *who, int type, const char *race)
Find object in inventory by type and race.
#define FLAG_CLIENT_ANIM_RANDOM
Client animate this, randomized.
archetype * more
Next part of a linked object.
#define SET_MAP_TOP(M, X, Y, tmp)
Sets the top object on a map.
#define FLAG_WAS_WIZ
Player was once a wiz.
int absdir(int d)
Computes an absolute direction.
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
#define FREE_OBJ_DROP_ABOVE_FLOOR
If FREE_OBJ_FREE_INVENTORY is not set, drop inventory just above ground instead on top...
int32_t food
How much food in stomach.
static int object_set_value_s(object *, const char *, const char *, int)
Updates or sets a key value.
#define GET_MAP_MOVE_SLOW(M, X, Y)
Gets the slowing state of a square.
#define P_BLOCKSVIEW
This spot blocks the player's view.
int16_t oy
For debugging: Where it was last inserted.
#define FLAG_DIALOG_PARSED
Was the object::msg field parsed? Temporary flag not saved.
#define P_NO_ERROR
Purely temporary - if set, update_position does not complain if the flags are different.
A buffer that will be expanded as content is added to it.
int16_t maxhp
Max hit points.
uint8_t subtype
Subtype of object.
object * object_get_player_container(object *op)
Finds the player carrying an object.
object * find_skill_by_number(object *who, int skillno)
This returns the first skill pointer of the given subtype (the one that accumulates exp...
int32_t weight_limit
Weight-limit of object.
int object_count_free(void)
Objects statistics.
#define P_IS_ALIVE
Something alive is on this space.
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...
int8_t wc
Weapon Class, lower WC increases probability of hitting.
void object_update(object *op, int action)
object_update() updates the array which represents the map.
#define FREE_AND_CLEAR(xyz)
Free the pointer and then set it to NULL.
tag_t count
Unique object number for this object.
#define FLAG_IS_WOODED
Item is wooded terrain.
#define FLAG_NO_PICK
Object can't be picked up.
static object * free_objects
Pointer to the list of unused objects.
#define FLAG_WIZPASS
The wizard can go through walls.
int32_t move_status
What stage in attack mode.
void object_insert_to_free_spot_or_free(object *op, mapstruct *map, int x, int y, int start, int stop, object *originator)
Inserts an object into its map.
void query_short_name(const object *op, char *buf, size_t size)
query_short_name(object) is similar to query_name(), but doesn't contain any information about object...
int16_t last_grace
As last_sp, except for grace.
#define FLAG_INV_LOCKED
Item will not be dropped from inventory.
This is one artifact, ie one special item.
int object_can_merge(object *ob1, object *ob2)
Examines the 2 objects given to it, and returns true if they can be merged together, including inventory.
object * map_find_by_type(mapstruct *m, int x, int y, uint8_t type)
Searches for any objects with a matching type variable at the given map and coordinates.
sstring name
Face name, as used by archetypes and such.
void object_clear(object *op)
Frees everything allocated by an object, and also clears all variables and flags to default settings...
sstring artifact
If set, the item is the artifact with this name and the matching type.
object * object_find_by_type(const object *who, int type)
Find object in inventory.
object clone
An object from which to do object_copy()
uint8_t duration_modifier
how level modifies duration
bool object_value_set(const object *op, const char *const key)
Determine if an extra value is set.
#define P_NO_CLERIC
No clerical spells cast here.
#define CUSTOM_NAME_FIELD
Key in an object for the player-assigned custom name.
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
int flags_differ(ob_flags *diff)
Return the index of the first difference in the given object flag difference set (computed by compare...
object * item
Special values of the artifact.
uint32_t path_attuned
Paths the object is attuned to.
#define INS_MAP_LOAD
Disable lots of checkings.
int32_t last_eat
How long since we last ate.
#define FLAG_FREED
Object is in the list of free objects.
object * enemy
Monster/player to follow even if not closest.
#define FLAG_IS_TURNABLE
Object can change face with direction.