20 #define _GNU_SOURCE // strcasestr() is a GNU extension in string.h 84 int recharge(
object *
op,
object *caster,
object *spell_ob) {
90 if (wand == NULL || wand->
type !=
WAND) {
92 "You need to mark the wand you want to recharge.");
98 "The %s vibrates violently, then explodes!",
120 "Your %s is broken.",
130 "The %s glows with power.",
163 int x = op->
x, y = op->
y, choice, friendly;
165 object *owner, *replacing;
172 if (op->
level >= level*2
179 std::vector<std::pair<archetype *, int>> candidates;
185 candidates.push_back(std::make_pair(at, pos));
189 if (candidates.empty()) {
195 choice =
rndm(0, candidates.size() - 1);
196 auto at = candidates[choice].first;
197 int pos = candidates[choice].second;
206 if (tmp->type ==
SPELL) {
259 "The %s glow red, melt and evaporate!",
263 "The %s glows red, melts and evaporates!",
282 int max_value, difficulty, tries = 0, choice, charges = op->
stats.
food;
288 max_value = op->
value*2;
289 if (max_value > 2000*(level/10))
290 max_value = 2000*(level/10)+(max_value-2000*(level/10))/3;
292 std::vector<archetype *> candidates;
305 candidates.push_back(at);
308 if (candidates.empty())
311 difficulty = op->
magic*5;
316 choice =
rndm(0, candidates.size() - 1);
317 at = candidates[choice];
322 }
while (new_ob->
value > max_value && tries < 10);
324 LOG(
llevError,
"polymorph_item: fix_generated_object made %s invisible?!\n", new_ob->
name);
339 if (new_ob->
nrof > 2)
427 int range, mflags, maxrange,
level;
435 for (range = 1; range < maxrange; range++) {
494 int missile_plus = 0, bonus_plus = 0;
495 const char *missile_name;
496 object *tmp, *missile;
500 missile_name = tmp != NULL ? tmp->
race :
"arrow";
504 if (!strcmp(missile_name,
"arrows"))
505 missile_name =
"arrow";
506 else if (!strcmp(missile_name,
"crossbow bolts"))
507 missile_name =
"bolt";
510 if ( stringarg && strncmp(stringarg,
"of ",3)==0 ) stringarg +=3;
511 if ( stringarg && strncmp(stringarg,
"bolt",4)==0 ) {
512 missile_name =
"bolt";
514 while ( isalpha(*stringarg) ) ++stringarg;
515 while ( *stringarg==
' ' ) ++stringarg;
517 if ( stringarg && strncmp(stringarg,
"arrow",5)==0 ) {
518 missile_name =
"arrow";
520 while ( isalpha(*stringarg) ) ++stringarg;
521 while ( *stringarg==
' ' ) ++stringarg;
525 LOG(
llevDebug,
"Cast create_missile: could not find archetype %s\n", missile_name);
530 if ( stringarg && strncmp(stringarg,
"of ",3)==0 ) stringarg +=3;
533 if (isalpha(*stringarg)) {
535 auto ial = std::find_if(items.cbegin(), items.cend(), [&] (
const auto al) {
return !
strcasecmp(al->item->name, stringarg); });
536 if (ial == items.cend()) {
539 "No such object %ss of %s",
540 missile_name, stringarg);
547 "You are not allowed to create %ss of %s",
548 missile_name, stringarg);
558 }
else if (atoi(stringarg) < missile_plus)
559 missile_plus = atoi(stringarg);
561 if (missile_plus > 4)
563 else if (missile_plus < -4)
567 if (missile->
nrof <= (uint32_t)3 * (missile_plus + bonus_plus)) {
570 "This item is too powerful for you to create!");
573 missile->
nrof -= 3*(missile_plus+bonus_plus);
574 if (missile->
nrof < 1)
577 missile->
magic = missile_plus;
582 tag = missile->
count;
660 "You don't have enough experience to create any food.");
667 new_op->
nrof = food_value;
670 if (new_op->
nrof < 1)
700 int r, mflags, maxrange;
708 for (r = 1; r < maxrange; r++) {
719 "Something blocks your magic.");
726 "You detect something.");
734 "You detect nothing.");
806 "You can not extend the duration of your invisibility any further");
832 "You can't see your hands!");
835 "You feel more transparent!");
856 int range, i, j, mflags;
865 for (i = -range; i < range; i++)
866 for (j = -range; j < range; j++) {
915 "You feel a force starting to build up inside you.");
922 "Oops, program error!");
923 LOG(
llevError,
"cast_word_of_recall: create_archetype(force) failed!\n");
934 dummy->
speed = 0.002;
949 "You feel a force starting to build up inside you.");
972 return cast_cone(op, caster, dir, spell_ob);
977 LOG(
llevError,
"cast_wonder: Unable to get a spell!\n");
981 LOG(
llevError,
"cast_wonder: spell returned is not a spell (%d, %s)!\n", newspell->
type, newspell->
name);
986 LOG(
llevError,
"cast_wonder: spell returned is another wonder spell!\n");
989 return cast_spell(op, caster, dir, newspell, NULL);
1020 "You worship no god");
1026 if (*cp ==
'\0' && tmp == NULL)
1028 "You feel very mundane");
1038 "Your %s is depleted by %d",
1048 "You glow in the dark.");
1051 for (tmp = op->
inv; tmp; tmp = tmp->
below) {
1053 if (immunity == NULL) {
1060 if (tmp->
level > 100)
1062 else if (tmp->
level > 70)
1064 else if (tmp->
level > 20)
1069 if (immunity != NULL) {
1083 snprintf(buf,
sizeof(buf),
"Your metabolism isn't focused on anything.");
1092 if (levels == NULL) {
1100 if (levels != NULL) {
1111 object *dummy, *force;
1117 if (dummy == NULL) {
1119 "Oops, program error!");
1120 LOG(
llevError,
"object_new failed (force in cast_create_town_portal for %s!\n", op->
name);
1125 if (force == NULL) {
1138 "You fix this place in your mind and feel that you " 1139 "can come here from anywhere.");
1152 if (dummy == NULL) {
1154 "Oops, program error!");
1155 LOG(
llevError,
"object_new failed (force) in cast_create_town_portal for %s!\n", op->
name);
1160 if (perm_portal == NULL) {
1162 "Oops, program error!");
1174 int16_t exitx =
EXIT_X(old_force);
1175 int16_t exity =
EXIT_Y(old_force);
1176 LOG(
llevDebug,
"Trying to kill a portal in %s (%d,%d)\n", old_force->
race, exitx, exity);
1187 if (tmp->
name == old_force->
name) {
1199 if (tmp->
name == old_force->
name) {
1242 object *dummy, *force, *tmp;
1243 char portal_name [2 *
HUGE_BUF], portal_message [1024];
1254 "You can't cast that here.");
1262 "You need to exit the transport to cast that.");
1267 if (force == NULL) {
1307 if (exitmap == NULL) {
1309 "Something strange happens. You can't remember where to go!?");
1316 "The spell effect has expired.");
1325 snprintf(portal_message, 1024,
"The air moves around you and a huge smell of ammonia surrounds you as you pass through %s's tiny portal. Pouah!", op->
name);
1326 else if (op_level < 30)
1327 snprintf(portal_message, 1024,
"%s's portal smells of ozone. You do a lot of movements and finally pass through the small hole in the air.", op->
name);
1328 else if (op_level < 60)
1329 snprintf(portal_message, 1024,
"A shining door opens in the air in front of you, showing you the path to another place.");
1331 snprintf(portal_message, 1024,
"As you walk through %s's portal, flowers come out from the ground around you. You feel awed.", op->
name);
1338 snprintf(portal_name,
sizeof(portal_name),
"%s's portal to %s", op->
name, force->
name);
1340 if (dummy == NULL) {
1342 "Oops, program error!");
1343 LOG(
llevError,
"object_new failed (perm_magic_portal) in cast_create_town_portal for %s!\n", op->
name);
1371 "Oops, program error!");
1372 LOG(
llevError,
"object_new failed (force) in cast_create_town_portal for %s!\n", op->
name);
1387 snprintf(portal_name,
sizeof(portal_name),
"%s's portal to %s", op->
name, op->
map->
path);
1389 if (dummy == NULL) {
1391 "Oops, program error!");
1392 LOG(
llevError,
"object_new failed (perm_magic_portal) in cast_create_town_portal for %s!\n", op->
name);
1419 "Oops, program error!");
1420 LOG(
llevError,
"object_new failed (force) in cast_create_town_portal for %s!\n", op->
name);
1432 "You see air moving and showing you the way home.");
1458 int i, posblocked, negblocked, maxrange;
1478 "Something is in the way.");
1483 }
else if (spell_ob->
race) {
1486 snprintf(buf1,
sizeof(buf1), spell_ob->
race, dir);
1489 LOG(
llevError,
"summon_wall: Unable to find archetype %s\n", buf1);
1491 "This spell is broken.");
1532 "Something destroys your %s",
1550 for (i = 1; i <= maxrange; i++) {
1553 dir2 = (dir < 4) ? (dir+2) : dir-2;
1571 x = tmp->
x-i*freearr_x[dir2];
1572 y = tmp->
y-i*freearr_y[dir2];
1610 uint32_t dist, maxdist;
1620 "In what direction?");
1632 "You can't dimension door that far!");
1636 for (dist = 0; dist < op->
contr->
count; dist++) {
1650 if (dist < op->contr->count) {
1652 "Something blocks the magic of the spell.");
1670 "You cast your spell, but nothing happens.");
1679 for (dist = 0; dist < maxdist; dist++) {
1696 for (; dist > 0; dist--) {
1705 "Your spell failed!");
1714 "Your spell failed!");
1751 int heal = 0, success = 0;
1768 "You are already fully healed.");
1780 "You feel just fine!");
1781 }
else if (heal > 50) {
1783 "Your wounds close!");
1784 }
else if (heal > 25) {
1786 "Your wounds mostly close.");
1787 }
else if (heal > 10) {
1789 "Your wounds start to fade.");
1792 "Your wounds start to close.");
1808 "Your body feels cleansed");
1818 "Your mind feels clearer");
1829 "Your vision begins to return.");
1840 "Magical energies surge through your body!");
1848 "You feel redeemed with you god!");
1857 "You feel your belly fill with food");
1874 "You grow no stronger.",
1875 "You grow no more agile.",
1876 "You don't feel any healthier.",
1878 "You are no easier to look at.",
1904 object *force = NULL;
1920 if (tmp2->name == spell_ob->
name) {
1923 }
else if (spell_ob->
race && spell_ob->
race == tmp2->name) {
1926 "You can not cast %s while %s is in effect",
1927 spell_ob->
name, tmp2->name_pl);
1932 if (force == NULL) {
1949 "You recast the spell while in effect.");
1957 "Recasting the spell had no effect.");
1970 if (spell_ob->
resist[i]) {
1972 if (force->
resist[i] > 100)
1986 for (k = 0; k < stat; k++)
2012 if (op->
speed > 0.5)
2053 object *force = NULL, *tmp;
2065 if (tmp2->name == spell_ob->
name) {
2068 }
else if (spell_ob->
race && spell_ob->
race == tmp2->name) {
2070 "You can not cast %s while %s is in effect",
2071 spell_ob->
name, tmp2->name_pl);
2076 if (force == NULL) {
2093 "You recast the spell while in effect.");
2096 "Recasting the spell had no effect.");
2106 "Your blessing seems empty.");
2111 if (god->
resist[i] > 0) {
2133 "You are blessed by %s!",
2145 if (spell_ob->
other_arch != NULL && tmp->map != NULL) {
2175 #define SMALL_NUGGET "smallnugget" 2176 #define LARGE_NUGGET "largenugget" 2192 static void alchemy_object(
float value_adj,
object *obj,
int *small_nuggets,
int *large_nuggets,
int *weight) {
2198 uint64_t small_value, large_value;
2209 if (small_nugget_arch == NULL) {
2214 if (large_nugget_arch == NULL) {
2229 assert(large_value != 0 && small_value != 0);
2230 count = value/large_value;
2231 *large_nuggets += count;
2232 value -= (uint64_t)count*large_value;
2233 count = value/small_value;
2234 *small_nuggets += count;
2241 if (*small_nuggets*small_value >= large_value) {
2242 assert(small_value != 0);
2244 *small_nuggets -= large_value/small_value;
2245 if (*small_nuggets && large_value%small_value)
2249 if (weight != NULL) {
2277 if (x == op->
x && y == op->
y && op->
map == m)
2280 if (small_nuggets) {
2282 tmp-> nrof = small_nuggets;
2285 if (large_nuggets) {
2287 tmp-> nrof = large_nuggets;
2307 int x, y, weight = 0, weight_max, large_nuggets, small_nuggets, mflags;
2328 if (value_adj > 0.40)
2331 for (y = op->
y-1; y <= op->y+1; y++) {
2332 for (x = op->
x-1; x <= op->x+1; x++) {
2364 alchemy_object(value_adj, tmp1, &small_nuggets, &large_nuggets, &weight);
2367 alchemy_object(value_adj, tmp, &small_nuggets, &large_nuggets, &weight);
2369 if (weight > weight_max) {
2407 int success = 0, was_one = 0;
2431 "You feel like some of your items are looser now.");
2435 "You failed to remove the curse.");
2438 "You are not using any cursed items.");
2460 "You need to mark an item first!");
2467 "The spell has no effect");
2474 "Your %s emits a dark light for a few seconds.", name);
2483 "Your %s glows blue for a few seconds.", name);
2506 int success = 0, num_ident;
2523 "The item has a story:\n%s",
2543 "On the ground is %s.",
2547 "The item has a story:\n%s",
2561 "You can't reach anything unidentified.");
2581 object *tmp, *last, *detect;
2583 int done_one, range, mflags, floor,
level;
2584 int16_t x, y, nx, ny;
2596 for (x = op->
x-range; x <= op->x+range; x++)
2597 for (y = op->
y-range; y <= op->y+range; y++) {
2658 if (spell_detect_magic
2700 int dx = nx, dy = ny;
2703 if (done_one == 2 && detect) {
2713 dx =
HEAD(detect)->x;
2714 dy =
HEAD(detect)->y;
2717 for (part = detect_ob; part != NULL; part = part->
more) {
2722 for (flag = 0; flag < 4; flag++) {
2756 if (spell_detect_magic
2791 "You feel energy course through you.");
2797 "Your head explodes!");
2807 "You feel like your head is going to explode.");
2810 "You get a splitting headache!");
2813 "Chaos fills your world.");
2817 "You start hearing voices.");
2839 object *plyr = NULL;
2869 "There is no one there.");
2879 }
else if (op != plyr) {
2887 sucked = (plyr->
stats.
sp*rate)/100;
2891 sucked = (sucked*rate)/100;
2949 }
else switch (head->
type) {
2961 if (
rndm(0, 149) == 0) {
2993 "You can't consecrate anything if you don't worship a god!");
3003 "You are not powerful enough to reconsecrate the %s",
3012 snprintf(buf,
MAX_BUF,
"altar_");
3013 letter = strlen(buf);
3015 for (; letter < strlen(buf); letter++)
3016 buf[letter] =
tolower(buf[letter]);
3020 "You fail to consecrate the altar.");
3021 LOG(
llevError,
"cast_consecrate: can't find altar %s for god %s\n", buf, god->
name);
3025 new_altar->
level = tmp->level;
3031 "You consecrated the altar to %s!",
3038 "You are not standing over an altar!");
3066 object *weapon, *tmp;
3075 "Oops, program error!");
3076 LOG(
llevError,
"animate_weapon failed: spell %s missing other_arch!\n", spell->
name);
3095 "There is something in the way.");
3109 "There is something in the way.");
3118 "You must mark a weapon to use with this spell!");
3123 "The spell fails to transform your weapon.");
3128 "You need to mark a weapon to animate it.");
3133 "You need to pay for the weapon to animate it.");
3141 "You need to unequip %s before using it in this spell",
3146 if (weapon->
nrof > 1) {
3252 if (tmp->
speed > 3.33)
3256 snprintf(buf,
sizeof(buf),
"animated %s", weapon->
name);
3305 "It can be no brighter here.");
3308 "It can be no darker here.");
3392 "You recast the spell while in effect.");
3417 if (!msg || msg[0] == 0) {
3425 "Trying to cheat are we?");
3426 LOG(
llevInfo,
"write_rune: player %s tried to write bogus rune %s\n", op->
name, msg);
const char *const change_resist_msg[NROFATTACKS]
These are the descriptions of the resistances displayed when a player puts on/takes off an item...
int cast_transfer(object *op, object *caster, object *spell, int dir)
This spell transfers sp from the player to another person.
#define FLAG_KNOWN_BLESSED
Item is known to be blessed.
int cast_bless(object *op, object *caster, object *spell_ob, int dir)
Improve statistics of some living object.
#define FLAG_NO_DROP
Object can't be dropped.
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
int apply_manual(object *op, object *tmp, int aflag)
Main apply handler.
uint16_t attack_movement
What kind of attack movement.
object * ranges[range_size]
Object for each range.
const char * determine_god(object *op)
Determines if op worships a god.
int cast_invisible(object *op, object *caster, object *spell_ob)
Makes the player or character invisible.
#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.
uint8_t create_home_portals
If 1, can create portals in unique maps (apartments)
#define FORCE_CHANGE_ABILITY
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
bool map_path_unique(const char *path)
Return true if the given map path leads to a unique map.
see doc/Developers/objects
#define INS_BELOW_ORIGINATOR
Insert new object immediately below originator.
#define MSG_TYPE_ITEM
Item related information.
Spell-related defines: spellpath, subtypes, ...
#define AT_COUNTERSPELL
Cancels magic spells (524288) peterm@soda.berkeley.edu.
int did_make_save(const object *op, int level, int bonus)
This function takes an object (monster/player, op), and determines if it makes a basic save throw by ...
struct archetype * arch
Pointer to archetype.
int cast_consecrate(object *op, object *caster, object *spell)
A spell to make an altar your god's.
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Describes an item, in all its details.
const object * find_god(const char *name)
Returns a god's object from its name.
#define FLAG_IS_BUILDABLE
Can build on item.
int dimension_door(object *op, object *caster, object *spob, int dir)
Teleport through some doors and space.
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.
int caster_level(const object *caster, const object *spell)
This function returns the effective level the spell is being cast at.
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
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 LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
int8_t direction
Means the object is moving that way.
#define FABS(x)
Decstations have trouble with fabs()...
int rndm(int min, int max)
Returns a number between min and max.
int cure_disease(object *sufferer, object *caster, sstring skill)
Do the cure disease stuff, from the spell "cure disease".
#define OB_TYPE_MOVE_BLOCK(ob1, type)
Basic macro to see if if ob1 can not move onto a space based on the 'type' move_block parameter Add c...
int cast_heal(object *op, object *caster, object *spell, int dir)
Heals something.
int create_aura(object *op, object *caster, object *spell)
Create an aura spell object and put it in the player's inventory.
#define MSG_TYPE_ITEM_INFO
Information related to items.
uint32_t weapontype
Type of weapon.
materialtype_t * name_to_material(const char *name)
Convert materialname to materialtype_t.
int write_mark(object *op, object *spell, const char *msg)
This writes a rune that contains the appropriate message.
uint8_t map_layer
What level to draw this on the map.
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
uint16_t look_position
Start of drawing of look window.
#define FLAG_FRIENDLY
Will help players.
#define FLAG_IS_FLOOR
Can't see what's underneath this object.
#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.
void object_set_msg(object *op, const char *msg)
Set the message field of an object.
int cast_change_ability(object *op, object *caster, object *spell_ob, int dir, int silent)
Cast some stat-improving spell.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
#define MSG_TYPE_SPELL
Spell related info.
void archetypes_for_each(arch_op op)
#define FLAG_NO_FIX_PLAYER
fix_object() won't be called
int16_t maxgrace
Maximum grace.
#define EXPLODING_FIREBALL
This is used for fumbles - this arch is all set up to do the right just by inserting it...
object * below
Pointer to the object stacked below this one.
static int food_value_choice
#define MSG_TYPE_SPELL_FAILURE
Spell failure messages.
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...
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.
int cast_item_curse_or_bless(object *op, object *spell_ob)
This alters player's marked item's cursed or blessed status, based on the spell_ob's fields...
void examine_monster(object *op, object *tmp, int level)
Player examine a monster.
object * more
Pointer to the rest of a large body of objects.
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)
object * above
Pointer to the object stacked above this one.
int cast_detection(object *op, object *caster, object *spell)
Detect magic or invisible items.
void remove_friendly_object(object *op)
Removes the specified object from the linked list of friendly objects.
void polymorph(object *op, object *who, int level)
Handles polymorphing an object, living or not.
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.
int cast_word_of_recall(object *op, object *caster, object *spell_ob)
Word of recall causes the player to return 'home'.
int cast_change_map_lightlevel(object *op, object *spell)
This changes the light level for the entire map.
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 FLAG_USE_WEAPON
(Monster) can wield weapons
int is_dragon_pl(const object *op)
Checks if player is a dragon.
int SP_level_dam_adjust(const object *caster, const object *spob)
Returns adjusted damage based on the caster.
int recharge(object *op, object *caster, object *spell_ob)
Recharge wands.
#define FLAG_BLESSED
Item has a blessing, opposite of cursed/damned.
#define FREE_OBJ_NO_DESTROY_CALLBACK
Do not run the destroy callback.
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.
#define object_was_destroyed(op, old_tag)
Checks if an object still exists.
artifactlist * find_artifactlist(int type)
Finds the artifact list for a certain item type.
int16_t duration
Number of moves (see 'speed') spell lasts.
int magic_wall(object *op, object *caster, int dir, object *spell_ob)
This creates magic walls.
#define FLAG_TEAR_DOWN
at->faces[hp*animations/maxhp] at hit
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...
#define AT_BLIND
Blinds victim (4194304) thomas@astro.psu.edu.
Global type definitions and header inclusions.
#define PETMOVE
If the upper four bits of attack_movement are set to this number, the monster follows a player until ...
struct player * contr
Pointer to the player which control this object.
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
uint8_t anim_speed
Ticks between animation-frames.
#define MSG_TYPE_VICTIM_SPELL
Someone cast a bad spell on the player.
#define SP_WORD_OF_RECALL
#define FOR_OB_AND_BELOW_FINISH()
Finishes FOR_OB_AND_BELOW_PREPARE().
static archetype * food_choice
void set_attr_value(living *stats, int attr, int8_t value)
Sets Str/Dex/con/Wis/Cha/Int/Pow in stats to value, depending on what attr is (STR to POW)...
archetype * try_find_archetype(const char *name)
#define FLAG_REMOVED
Object is not in any map or invenory.
int cast_cone(object *op, object *caster, int dir, object *spell)
Casts a cone spell.
int32_t weight
Attributes of the object.
object * transport
Transport the player is in.
void counterspell(object *op, int dir)
Nullifies spell effects.
#define FLAG_KNOWN_MAGICAL
The object is known to be magical.
archetype * find_archetype_by_object_type_name(int type, const char *name)
This function retrieves an archetype by type and name that appears during the game.
rangetype shoottype
Which range-attack is being used by player.
#define FLAG_IS_USED_UP
When (–food<0) the object will exit.
AssetsManager * getManager()
void pets_control_golem(object *op, int dir)
Makes the golem go in specified direction.
#define FLAG_UNDEAD
Monster is undead.
int change_abil(object *op, object *tmp)
Permanently alters an object's stats/flags based on another object.
#define MSG_TYPE_SPELL_TARGET
Target of non attack spell.
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
int is_magical(const object *op)
Checks whether object is magical.
int cast_earth_to_dust(object *op, object *caster, object *spell_ob)
Basically destroys earthwalls in the area.
static void place_alchemy_objects(object *op, mapstruct *m, int small_nuggets, int large_nuggets, int x, int y)
Place gold nuggets on the map.
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 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.
#define FREE_OBJ_FREE_INVENTORY
Free inventory objects; if not set, drop inventory.
std::vector< artifact * > items
Artifacts for this type.
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Find object in inventory.
#define FLAG_ALIVE
Object can fight (or be fought)
void confuse_living(object *op, object *hitter, int dam)
Confuse a living thing.
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
int8_t save[NROFATTACKS]
Save chances for the attacks.
#define MSG_TYPE_VICTIM
Something bad is happening to the player.
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
This calls the appropriate treasure creation function.
object * identify(object *op)
Identifies an item.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
#define FOR_OB_AND_ABOVE_FINISH()
Finishes FOR_OB_AND_ABOVE_PREPARE().
#define AT_DISEASE
33554432 disease attacktypes
sstring materialname
Specific material name.
static object * town_portal_find_force(object *op, object *spell)
sstring name
More definite name, like "generate_kobold".
uint32_t unique
If set, this is a per player unique map.
#define MSG_TYPE_SPELL_SUCCESS
Spell succeeded messages.
#define INS_ON_TOP
Always put object on top.
#define MSG_TYPE_SPELL_HEAL
Healing related spells.
static int town_portal_destroy_existing(object *op, object *spell)
Remove op's existing town portals.
int8_t range
Range of the spell.
float speed
Frequency of object 'moves' relative to server tick rate.
char * ob_describe(const object *op, const object *observer, int use_media_tags, char *buf, size_t size)
Returns the description (short item name) of an object, as seen by the given observer.
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.
object * find_target_for_friendly_spell(object *op, int dir)
This function is commonly used to find a friendly target for spells such as heal or protection or arm...
object * create_archetype(const char *name)
Finds which archetype matches the given name, and returns a new object containing a copy of the arche...
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)
void monster_check_apply_all(object *monster)
Calls monster_check_apply() for all inventory objects.
#define ARCH_DEPLETION
Archetype for depletion.
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-...
int cast_create_obj(object *op, object *new_op, int dir)
Creates object new_op in direction dir or if that is blocked, beneath the player (op).
void query_name(const object *op, char *buf, size_t size)
Describes an item.
int strcasecmp(const char *s1, const char *s2)
#define FLAG_IDENTIFIED
Item is identifiable (e.g.
int64_t * levels
Number of levels for which we have experience.
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
#define MSG_TYPE_SPELL_PERCEIVE_SELF
Perceive self messages.
int SP_level_duration_adjust(const object *caster, const object *spob)
Adjust the duration of the spell based on level.
socket_struct * socket
Socket information for this player.
uint32_t golem_count
To track the golem.
#define MSG_TYPE_SPELL_ERROR
Spell failure messages.
sstring race
Human, goblin, dragon, etc.
const Animations * animation
Animation of this item, NULL if not animated.
#define FLAG_BLOCKSVIEW
Object blocks view.
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...
int atnr_is_dragon_enabled(int attacknr)
Determine if the attacktype represented by the specified attack-number is enabled for dragon players...
int cast_create_missile(object *op, object *caster, object *spell, int dir, const char *stringarg)
Create a missile (nonmagic - magic +4).
void spell_effect(object *spob, int x, int y, mapstruct *map, object *originator)
Inserts into map a spell effect based on other_arch.
int change_map_light(mapstruct *m, int change)
Used to change map light level (darkness) up or down.
ob_flags flags
Various flags.
int is_true_undead(object *op)
Is the object a true undead?
Archetypes * archetypes()
Get archetypes.
#define INS_NO_WALK_ON
Don't call check_walk_on against the originator.
#define GET_MAP_TOP(M, X, Y)
Gets the top object on a map.
const Face * face
Face with colors.
int8_t glow_radius
indicates the glow radius of the object
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...
uint8_t dam_modifier
How going up in level affects damage.
#define FLAG_IS_CAULDRON
container can make alchemical stuff
#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.
uint8_t last_anim
Last sequence used to draw face.
struct Settings settings
Global settings.
uint8_t state
How the object was last drawn (animation)
int animate_weapon(object *op, object *caster, object *spell, int dir)
Generalization of staff_to_snake().
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.
object * find_marked_object(object *op)
Return the object the player has marked with the 'mark' command below.
#define FREE_AND_CLEAR_STR(xyz)
Release the shared string, and set it to NULL.
int16_t bed_y
x,y - coordinates of respawn (savebed).
int random_roll(int min, int max, const object *op, int goodbad)
Roll a random number between min and max.
uint32_t tag_t
Object tag, unique during the whole game.
int16_t dam
How much damage this object does when hitting.
#define AT_PHYSICAL
Basic attack (1)
char savebed_map[MAX_BUF]
Map where player will respawn after death.
#define HEAD(op)
Returns the head part of an object.
#define FLAG_WIZ
Object has special privilegies.
living stats
Str, Con, Dex, etc.
#define MAX_BUF
Used for all kinds of things.
int cast_wonder(object *op, object *caster, int dir, object *spell_ob)
wonder is really just a spell that will likely cast another spell.
int16_t invisible
How much longer the object will be invis.
void add_friendly_object(object *op)
Add a new friendly object to the list of friendly objects.
uint64_t price_base(const object *obj)
Price an item based on its value or archetype value, type, identification/BUC status, and other heuristics.
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.
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.
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.
int cast_identify(object *op, object *caster, object *spell)
Identifies objects in the players inventory/on the ground.
void esrv_map_scroll(socket_struct *ns, int dx, int dy)
static const char *const no_gain_msgs[NUM_STATS]
This is used for the spells that gain stats.
static void polymorph_item(object *who, object *op, int level)
Changes an item to another item of similar type.
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
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...
object * object_create_arch(archetype *at)
Create a full object using the given archetype.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
int8_t facing
Object is oriented/facing that way.
int cast_create_town_portal(object *op, object *caster, object *spell)
This function cast the spell of town portal for op.
#define FLAG_KNOWN_CURSED
The object is known to be cursed.
int makes_invisible_to(object *pl, object *mon)
This checks to see if 'pl' is invisible to 'mon'.
#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...
void store_spell_expiry(object *spell)
Stores in the spell when to warn player of expiration.
struct treasurelist * randomitems
Items to be generated.
#define AT_POISON
Some damage each turn thereafter (1024)
#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.
static void food_each(archetype *arch)
#define FLAG_GENERATOR
Will generate type ob->stats.food.
int perceive_self(object *op)
Living thing wants to know information.
#define INS_NO_MERGE
Don't try to merge with other items.
static event_registration m
#define FREE_AND_COPY(sv, nv)
Release the shared string if not NULL, and make it a reference to nv.
long last_reset_time
A timestamp of the last original map loading.
object * generate_treasure(treasurelist *t, int difficulty)
Generate a treasure from a list generating a single item.
int SP_level_range_adjust(const object *caster, const object *spob)
Adjust the range of the spell based on level.
static void alchemy_object(float value_adj, object *obj, int *small_nuggets, int *large_nuggets, int *weight)
Compute how many nuggets an object is worth, and remove it.
#define MAP_PLAYER_UNIQUE
This map is player-specific.
MoveType move_type
Type of movement this object uses.
#define FLAG_WIZCAST
The wizard can cast spells in no-magic area.
void fix_generated_item(object *op, object *creator, int difficulty, int max_magic, int flags)
fix_generated_item(): This is called after an item is generated, in order to set it up right...
sstring name
The name of the object, obviously...
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
void set_spell_skill(object *op, object *caster, object *spob, object *dest)
Utility function to assign the correct skill when casting.
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_...
MoveType move_allow
What movement types explicitly allowed.
const char *const statname[NUM_STATS]
Name of stats.
#define CLEAR_FLAG(xyz, p)
uint8_t type
PLAYER, BULLET, etc.
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.
void object_update_speed(object *op)
Updates the speed of an object.
object * inv
Pointer to the first object in the inventory.
#define FLAG_MAKE_INVIS
(Item) gives invisibility when applied
#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.
method_ret ob_apply(object *op, object *applier, int aflags)
Apply an object by running an event hook or an object method.
#define AT_MAGIC
All magic spells, but not prayers (2)
#define ARCH_PORTAL_FAILED
Archetype for town portal failure.
static const int32_t MAX_FOOD
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
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.
#define FLAG_MONSTER
Will attack players.
static void charge_mana_effect(object *victim, int caster_level)
Checks if victim has overcharged mana, and if so does some fireball.
#define NDI_UNIQUE
Print immediately, don't buffer.
uint32_t tmp_invis
Will invis go away when we attack?
static void polymorph_melt(object *who, object *op)
Destroys item from polymorph failure.
bool pick_up(object *op, object *alt)
Try to pick up an item.
C function wrappers to interact with assets.
void player_update_bg_music(object *player)
static void polymorph_living(object *op, int level)
Takes a living object (op) and turns it into another monster of some sort.
int cast_create_food(object *op, object *caster, object *spell_ob, int dir, const char *stringarg)
Create food.
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
void play_sound_map(int8_t sound_type, object *emitter, int dir, const char *action)
Plays a sound on a map.
int32_t food
How much food in stomach.
const char * invis_race
What race invisible to?
Structure containing object statistics.
#define P_BLOCKSVIEW
This spot blocks the player's view.
A buffer that will be expanded as content is added to it.
int16_t maxhp
Max hit points.
uint8_t subtype
Subtype of object.
uint16_t difficulty
What level the player should be to play here.
#define FOR_BELOW_PREPARE(op_, it_)
Constructs a loop iterating over all objects below an object.
#define P_IS_ALIVE
Something alive is on this space.
int probe(object *op, object *caster, object *spell_ob, int dir, int level)
Try to get information about a living thing.
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.
#define AT_CONFUSION
Movement/attack directions become random (32)
void object_update(object *op, int action)
object_update() updates the array which represents the map.
tag_t count
Unique object number for this object.
int cast_polymorph(object *op, object *caster, object *spell_ob, int dir)
Polymorph spell casting.
#define FLAG_NO_PICK
Object can't be picked up.
mapstruct * ready_map_name(const char *name, int flags)
Makes sure the given map is loaded and swapped in.
int hit_player(object *op, int dam, object *hitter, uint32_t type, int full_hit)
Object is attacked by something.
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...
#define tolower(C)
Simple macro to convert a letter to lowercase.
int remove_curse(object *op, object *caster, object *spell)
This function removes the cursed/damned status on equipped items.
int16_t last_grace
As last_sp, except for grace.
This is one artifact, ie one special item.
void cast_magic_storm(object *op, object *tmp, int lvl)
This is really used mostly for spell fumbles and the like.
object clone
An object from which to do object_copy()
int alchemy(object *op, object *caster, object *spell_ob)
Change items to gold nuggets.
bool object_value_set(const object *op, const char *const key)
Determine if an extra value is set.
#define FOR_BELOW_FINISH()
Finishes FOR_BELOW_PREPARE().
#define HAS_RANDOM_ITEMS(op)
This return TRUE if object has still randomitems which could be expanded.
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Main dispatch when someone casts a spell.
object * item
Special values of the artifact.
uint32_t path_attuned
Paths the object is attuned to.
static bool CAN_PROBE(const object *ob)
Determine whether the given object can have an HP bar.
void each(std::function< void(T *)> op)
Apply a function to each asset.