69 int arch_flag, name_flag, race_flag;
99 && (!(victim->
name && name_flag) || strcmp(op->
race, victim->
name))
100 && (!(victim->
race && race_flag) || strcmp(op->
race, victim->
race)))
150 LOG(
llevError,
"BUG: do_learn_spell(): not a player\n");
158 LOG(
llevError,
"BUG: do_learn_spell(): spell already known, but not marked as startequip\n");
173 "Type 'bind cast %s to store the spell in a key.",
191 LOG(
llevError,
"BUG: do_forget_spell(): not a player\n");
196 LOG(
llevError,
"BUG: do_forget_spell(): spell not known\n");
201 "You lose knowledge of %s.",
230 snprintf(buf,
sizeof(buf),
":%s:", who->
race);
231 buf[
sizeof(
buf)-1] =
'\0';
233 if (strstr(restriction, buf) != NULL)
265 "You should pay for it first.");
306 "But you are floating high above the ground!");
319 "The object disappears in a puff of smoke!");
321 "It must have been an illusion.");
334 "I don't know how to apply the %s.",
338 "You must get it first!\n");
434 LOG(
llevError,
"BUG: unapply_special(): applied skill is not a chosen skill\n");
439 if (!(aflags&AP_NOPRINT))
441 "You stop using the %s.",
444 if (!(aflags&AP_NOPRINT))
446 "You can no longer use the skill: %s.",
465 if (!(aflags&AP_NOPRINT))
476 if (!(aflags&AP_NOPRINT))
489 if (!(aflags&AP_NOPRINT))
498 if (!(aflags&AP_NOPRINT))
579 object *tmp = NULL, *last;
599 "No matter how hard you try, you just can't remove %s.",
605 if (aflags&AP_PRINT) {
632 if (aflags&AP_PRINT) {
647 "The %s just won't come off",
680 object *tmp = NULL, *ws = NULL;
736 else if (tmp != tmp1)
794 return (who->
level/5)+5 >= improves;
824 LOG(
llevError,
"apply_special() from object without environment.\n");
842 "No matter how hard you try, you just can't remove %s.",
861 "You need the %s skill to use this item!",
893 "That weapon is too powerful for you to use. It would consume your soul!");
932 if (!(aflags&AP_NOPRINT)) {
945 LOG(
llevError,
"BUG: apply_special(): can't apply two skills\n");
958 if (!(aflags&AP_NOPRINT))
960 "That weapon is too powerful for you to use. It would consume your soul!");
978 if (!(aflags&AP_NOPRINT)) {
987 if (!(aflags&AP_NOPRINT)) {
990 "You will now fire %s with %s.",
1010 if (!(aflags&AP_NOPRINT)) {
1013 "You ready your %s.",
1043 "Oops, it feels deadly cold!");
1131 while (invtmp->stats.hp-- > 0)
1133 invtmp->randomitems = NULL;
1134 }
else if (invtmp && invtmp->arch
1136 && invtmp->type !=
SPELL 1137 && invtmp->type !=
CLASS 1143 invtmp->randomitems = NULL;
1196 while (tmp->stats.hp-- > 0)
1198 tmp->randomitems = NULL;
1200 object *head =
HEAD(tmp);
1219 && tmp->type !=
SPELL 1221 && tmp->type !=
CLASS 1224 tmp->randomitems = NULL;
1255 if (abs(failure/4) > power)
1256 power = abs(failure/4);
1258 if (failure <= -1 && failure > -15) {
1262 "Your spell warps!");
1273 if (failure <= -35 && failure > -60) {
1275 "The magic recoils on you!");
1280 if (failure <= -60 && failure > -70) {
1282 "The magic recoils and paralyzes you!");
1287 if (failure <= -70 && failure > -80) {
1289 "The magic recoils on you!");
1294 if (failure <= -80) {
1300 "You unleash uncontrolled mana!");
1308 "Your mana is drained!");
1327 int excess_stat = 0;
1345 if (stat > 20+race_bonus) {
1347 stat = 20+race_bonus;
1348 }
else if (stat < 1) {
1356 excess_stat += stat;
1366 if (excess_stat < 0) excess_stat = 0;
1372 for (j = 0; excess_stat > 0 && j < 100; j++) {
1374 int i =
rndm(0, NUM_STATS-1);
1382 if (stat < 20+race_bonus) {
1422 if ((!has_noclassfacechange) && anim == 0) {
1468 "You don't have the body to use a %s",
1480 "You have a prohibition against using a %s",
1495 "You need to unapply some item(s):");
1530 "Equipping that combined with other items would consume your soul!");
1555 int damage_percentile;
1562 if (owner == NULL || strcmp(owner, who->
name) == 0)
1566 item_will = will != NULL ? atol(will) : 0;
1569 "This %s refuses to serve you - it keeps evading your hand !",
1575 random_effect =
random_roll(0, 100, who, 1)-margin*20;
1576 if (random_effect > 80) {
1577 msg =
"You don't know why, but you have the feeling that the %s is angry at you !";
1578 damage_percentile = 60;
1579 }
else if (random_effect > 60) {
1580 msg =
"The %s seems to look at you nastily !";
1581 damage_percentile = 45;
1582 }
else if (random_effect > 40) {
1583 msg =
"You have the strange feeling that the %s is annoyed...";
1584 damage_percentile = 30;
1585 }
else if (random_effect > 20) {
1586 msg =
"The %s seems tired, or bored, in a way. Very strange !";
1587 damage_percentile = 15;
1588 }
else if (random_effect > 0) {
1589 msg =
"You hear the %s sighing !";
1590 damage_percentile = 0;
1593 damage_percentile = 0;
1598 if (damage_percentile > 0) {
1599 int weapon_bite = (who->
stats.
hp*damage_percentile)/100;
1600 if (weapon_bite < 1)
1604 "You get a nasty bite in the hand !");
1625 const char *quotepos;
1630 quotepos = strstr(op->
name,
"'");
1631 if (quotepos == NULL || strncmp(op->
name, who->
name, quotepos-op->
name) == 0)
1636 "The weapon does not recognize you as its owner.");
1660 "Readied skill: %s.",
1671 "You can now use the skill: %s.",
#define AP_UNAPPLY
Item is to be remvoed.
Will unapply whatever is necessary - this goes beyond no choice - if there are multiple ojbect of the...
#define NUM_BODY_LOCATIONS
Number of body locations.
object * ranges[range_size]
Object for each range.
living orig_stats
Permanent real stats of player.
#define FLAG_DAMNED
The object is very cursed.
#define FLAG_UNPAID
Object hasn't been paid for yet.
#define FLAG_IS_LINKED
The object is linked with other objects.
see doc/Developers/objects
#define INS_BELOW_ORIGINATOR
Insert new object immediately below originator.
int change_skill(object *who, object *new_skill, int flag)
This changes the object's skill to new_skill.
Spell-related defines: spellpath, subtypes, ...
int8_t item_power
Power rating of the object.
#define CAN_APPLY_UNAPPLY_CHOICE
This represents one animation.
struct archetype * arch
Pointer to archetype.
static int apply_check_apply_restrictions(object *who, object *op, int aflags)
Checks for general apply restrictions (no body, prohibited by god, conflicts with other items...
object * check_spell_known(object *op, const char *name)
Checks to see if player knows the spell.
#define MSG_TYPE_APPLY_PROHIBITION
Class/god prohibiiton on obj.
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 LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
#define FABS(x)
Decstations have trouble with fabs()...
int rndm(int min, int max)
Returns a number between min and max.
#define MSG_TYPE_APPLY_FAILURE
Apply OK, but no/bad result.
Defines for the ingame clock, ticks management and weather system.
#define MSG_TYPE_APPLY_BADBODY
Don't have body to use object.
#define FLAG_USE_ARMOUR
(Monster) can wear armour/shield/helmet
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
int apply_can_apply_object(const object *who, const object *op)
Checks to see if 'who' can apply object 'op'.
#define FLAG_IS_FLOOR
Can't see what's underneath this object.
static void auto_apply_fix_inventory(mapstruct *m, object *tmp)
Go through one object on a map and process any special treasure creation or such for anything in it's...
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
void apply_changes_to_player(object *pl, object *change, int limit_stats)
Applies (race) changes to a player.
object * below
Pointer to the object stacked below this one.
#define FLAG_READY_RANGE
(Monster) has a range attack readied...
object * object_find_by_name(const object *who, const char *name)
Finds an object in inventory name.
void esrv_update_item(int flags, object *pl, object *op)
Updates object *op for player *pl.
sstring slaying
Which race to do double damage to.
#define MAP_HEIGHT(m)
Map height.
#define AC_PLAYER_STAT_LIMIT
Limit stats to racial maximum.
Object for applying character class modifications to someone.
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.
#define FLAG_USE_WEAPON
(Monster) can wield weapons
#define FLAG_BLESSED
Item has a blessing, opposite of cursed/damned.
#define FREE_OBJ_NO_DESTROY_CALLBACK
Do not run the destroy callback.
void blind_living(object *op, object *hitter, int dam)
Blind a living thing.
void scroll_failure(object *op, int failure, int power)
op made some mistake with a scroll, this takes care of punishment.
MoveType move_on
Move types affected moving on to this space.
object * chosen_skill
The skill chosen to use.
Global type definitions and header inclusions.
#define AP_APPLY
Item is to be applied.
struct player * contr
Pointer to the player which control this object.
static int apply_check_race_restrictions(object *who, object *item)
Checks if an item is restricted to a race.
Will not unapply objects automatically.
#define FLAG_USE_RING
(Monster) can use rings, boots, gauntlets, etc
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.
static int unapply_for_ob(object *who, object *op, int aflags)
Remove equipment so an object can be applied.
#define MSG_TYPE_APPLY
Applying objects.
#define FOR_OB_AND_BELOW_FINISH()
Finishes FOR_OB_AND_BELOW_PREPARE().
void esrv_add_spells(player *pl, object *spell)
This tells the client to add the spell *spell, if spell is NULL, then add all spells in the player's ...
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)...
int transport_can_hold(const object *transport, const object *op, int nrof)
Can transport hold object op? This is a pretty trivial function, but in the future, possible transport may have more restrictions or weight reduction like containers.
int apply_check_weapon_power(const object *who, int improves)
This checks to see of the player (who) is sufficient level to use a weapon with improves improvements...
int32_t weight
Attributes of the object.
object * transport
Transport the player is in.
rangetype shoottype
Which range-attack is being used by player.
#define CAN_APPLY_UNAPPLY_MULT
static int apply_check_owner(const object *who, const object *op, int aflags)
Checks that the item's owner matches the applier.
Allows the use of a skill.
int change_abil(object *op, object *tmp)
Permanently alters an object's stats/flags based on another object.
Generic item builder, see subtypes below.
#define FLAG_READY_SKILL
(Monster or Player) has a skill readied
int16_t level
Level of creature or object.
#define CAN_APPLY_UNAPPLY
int apply_manual(object *op, object *tmp, int aflag)
Main apply handler.
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.
void confuse_living(object *op, object *hitter, int dam)
Confuse a living thing.
#define AP_IGNORE_CURSE
Apply/unapply regardless of cursed/damned status.
#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.
#define CAN_APPLY_RESTRICTION
object * identify(object *op)
Identifies an item.
sstring name
More definite name, like "generate_kobold".
int32_t carrying
How much weight this object contains.
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.
#define AP_PRINT
Print what to do, don't actually do it Note this is supported in all the functions.
#define QUERY_FLAG(xyz, p)
int should_director_abort(const object *op, const object *victim)
Check if op should abort moving victim because of it's race or slaying.
#define FLAG_USE_SHIELD
Can this creature use a shield?
#define FLAG_USE_RANGE
(Monster) can apply and use range items
void monster_check_apply_all(object *monster)
Calls monster_check_apply() for all inventory objects.
sstring anim_suffix
Used to determine combined animations.
#define MSG_TYPE_APPLY_ERROR
void query_name(const object *op, char *buf, size_t size)
Describes an item.
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
#define MOVE_FLYING
Combo of fly_low and fly_high.
sstring race
Human, goblin, dragon, etc.
const Animations * animation
Animation of this item, NULL if not animated.
int apply_special(object *who, object *op, int aflags)
Apply an object.
#define MSG_TYPE_VICTIM_WAS_HIT
Player was hit by something.
#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 FLAG_IS_A_TEMPLATE
Object has no ingame life until instantiated.
const Face * face
Face with colors.
#define AP_NOPRINT
Don't print messages - caller will do that may be some that still print.
void paralyze_living(object *op, int dam)
Paralyze a living thing.
struct Settings settings
Global settings.
void apply_auto_fix(mapstruct *m)
Go through the entire map (only the first time when an original map is loaded) and performs special a...
void player_unready_range_ob(player *pl, object *ob)
Unready an object for a player.
object * object_new(void)
Grabs an object from the list of unused objects, makes sure it is initialised, and returns it...
void cast_magic_storm(object *op, object *tmp, int lvl)
This is really used mostly for spell fumbles and the like.
int random_roll(int min, int max, const object *op, int goodbad)
Roll a random number between min and max.
unapplymode unapply
Method for auto unapply.
int cast_wonder(object *op, object *caster, int dir, object *spell_ob)
wonder is really just a spell that will likely cast another spell.
int apply_auto(object *op)
Map was just loaded, handle op's initialization.
#define HEAD(op)
Returns the head part of an object.
#define MSG_TYPE_APPLY_UNAPPLY
Unapply an object.
#define FLAG_WIZ
Object has special privilegies.
#define FLAG_BEEN_APPLIED
Object was ever applied, for identification purposes.
living stats
Str, Con, Dex, etc.
#define MAX_BUF
Used for all kinds of things.
void give_initial_items(object *pl, treasurelist *items)
Gives a new player her initial items.
int16_t invisible
How much longer the object will be invis.
void drop(object *op, object *tmp)
Drop an item, either on the floor or in a container.
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.
#define FLAG_READY_WEAPON
(Monster or Player) has a weapon readied
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...
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
int8_t facing
Object is oriented/facing that way.
#define FLAG_KNOWN_CURSED
The object is known to be cursed.
static int unapply_special(object *who, object *op, int aflags)
Unapplies specified item.
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 FLAG_CURSED
The object is cursed.
#define AP_NO_MERGE
Don't try to merge object after (un)applying it.
struct treasurelist * randomitems
Items to be generated.
int8_t body_info[NUM_BODY_LOCATIONS]
Body info as loaded from the file.
#define FLAG_ANIMATE
The object looks at archetype for faces.
#define FLAG_AUTO_APPLY
Will be applied when created.
static event_registration m
object * container
Current container being used.
void do_forget_spell(object *op, const char *spell)
Erases spell from player's inventory.
void play_sound_player_only(player *pl, int8_t sound_type, object *emitter, int dir, const char *action)
Plays a sound for specified player only.
Also see SKILL_TOOL (74) below.
Animations * try_find_animation(const char *name)
MoveType move_type
Type of movement this object uses.
sstring name
The name of the object, obviously...
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
#define MAP_WIDTH(m)
Map width.
uint32_t nrof
Number of objects.
void clear_skill(object *who)
This function just clears the chosen_skill and range_skill values in the player.
static int apply_check_item_power(const object *who, const object *op, int aflags)
Checks for item power restrictions when applying an item.
#define AC_PLAYER_STAT_NO_CHANGE
Do not make any stat adjustments.
static void apply_update_ranged_skill(const object *who, object *op, int aflags)
Updates ranged skill information.
void esrv_remove_spell(player *pl, object *spell)
#define CLEAR_FLAG(xyz, p)
uint8_t type
PLAYER, BULLET, etc.
#define METHOD_SILENT_ERROR
Player was warned she can't use the item for now.
#define FLAG_APPLIED
Object is ready for use by living.
void change_attr_value(living *stats, int attr, int8_t value)
Like set_attr_value(), but instead the value (which can be negative) is added to the specified stat...
void object_update_speed(object *op)
Updates the speed of an object.
#define MSG_TYPE_APPLY_SUCCESS
Was able to apply object.
object * inv
Pointer to the first object in the inventory.
void do_learn_spell(object *op, object *spell, int special_prayer)
Actually makes op learn spell.
#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.
sstring name
Name of the animation sequence.
Don't generate bad/cursed items.
int apply_by_living(object *pl, object *op, int aflag, int quiet)
Living thing is applying an object.
#define MSG_TYPE_APPLY_CURSED
Applied a cursed object (BAD)
sstring skill
Name of the skill this object uses/grants.
#define FLAG_MONSTER
Will attack players.
Will unapply objects when there no choice to unapply.
#define NDI_UNIQUE
Print immediately, don't buffer.
void apply_by_living_below(object *pl)
Attempt to apply the object 'below' the player.
#define FLAG_READY_BOW
not implemented yet
#define FLAG_WAS_WIZ
Player was once a wiz.
#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.
object * current_weapon
Pointer to the weapon currently used.
Structure containing object statistics.
uint8_t subtype
Subtype of object.
uint16_t difficulty
What level the player should be to play here.
int32_t weight_limit
Weight-limit of object.
int16_t item_power
Total item power of objects equipped.
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...
static object * get_item_from_body_location(object *start, int loc)
Returns the object that is using body location 'loc'.
uint8_t spell_failure_effects
Nasty backlash to spell failures.
void apply_handle_yield(object *tmp)
This checks whether the object has a "on_use_yield" field, and if so generated and drops matching ite...
object * find_skill_by_name(object *who, const char *name)
This returns the skill pointer of the given name (the one that accumulates exp, has the level...
float item_power_factor
See note in setings file.
object clone
An object from which to do object_copy()
#define FLAG_USE_BOW
(Monster) can apply and fire bows
#define HAS_RANDOM_ITEMS(op)
This return TRUE if object has still randomitems which could be expanded.
static int apply_check_personalized_blessings(object *who, const object *op)
If personalized blessings are activated, the weapon can bite the wielder if he/she is not the one who...
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
int8_t body_used[NUM_BODY_LOCATIONS]
Calculated value based on items equipped.
void apply_anim_suffix(object *who, const char *suffix)
Applies a compound animation to an object.
uint8_t personalized_blessings
If 1, blessed weapons get an owner and a willpower value.
int32_t last_eat
How long since we last ate.