40 const object *book,
const object *observer,
41 const int use_media_tags,
char *
buf,
const size_t size);
104 const object *book,
const object *observer,
105 const int use_media_tags,
char *
buf,
size_t size) {
123 const object *spell = book->
inv;
125 snprintf(buf+len, size-len,
" (blank)");
157 object *skapplier, *spell, *spell_skill;
164 "You are unable to read while blind.");
170 LOG(
llevError,
"apply_spellbook: Book %s has no spell in it!\n", book->
name);
172 "The spellbook symbols make no sense.");
182 failure = -
rndm(35, 100);
218 "You already know the spell %s.\n", spell->
name);
227 "You lack the skill %s to use this spell",
232 int skill_lev_diff = spell->
level - spell_skill->
level;
233 if (skill_lev_diff > 0) {
234 if (skill_lev_diff < 2)
236 "The spell described in this book is just beyond your skill in %s.", spell->
skill);
237 else if (skill_lev_diff < 3)
239 "The spell described in this book is slightly beyond your skill in %s.", spell->
skill);
240 else if (skill_lev_diff < 5)
242 "The spell described in this book is beyond your skill in %s.", spell->
skill);
243 else if (skill_lev_diff < 8)
245 "The spell described in this book is quite a bit beyond your skill in %s.", spell->
skill);
246 else if (skill_lev_diff < 15)
248 "The spell described in this book is way beyond your skill in %s.", spell->
skill);
251 "The spell described in this book is totally beyond your skill in %s.", spell->
skill);
261 "You can't read! You will need this skill before you can comprehend the ideas written within.");
267 read_level = skapplier->
level;
275 lev_diff = spell->
level - (read_level+10);
279 "You recognise most of the words but this book is just beyond your comprehension.");
280 else if (lev_diff < 3)
282 "You recognise many of the words but this book is slightly beyond your comprehension.");
283 else if (lev_diff < 5)
285 "You recognise some of the words but this book is slightly beyond your comprehension.");
286 else if (lev_diff < 8)
288 "You recognise some of the words but this book is beyond your comprehension.");
289 else if (lev_diff < 15)
291 "You recognise a few of the words but this book is beyond your comprehension.");
294 "You recognise a few of the words but this book is totally beyond your comprehension.");
313 "The spellbook contains %s %s.", spell->
name, desc);
334 "In your confused state you flub the wording of the text!");
341 "You open the %s and start reading.", desc);
342 if (spell->
msg != NULL) {
351 "You succeed in learning the spell!");
360 "You fail to learn the spell.\n");
#define FLAG_DAMNED
The object is very cursed.
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
static void stringbuffer_append_spelldesc(StringBuffer *sb, const object *spell)
Append a terse description of the spell's name, level, discipline, and paths to a stringbuffer...
int64_t calc_skill_exp(const object *who, const object *op, const object *skill)
Calculates amount of experience can be gained for successful use of a skill.
object * check_spell_known(object *op, const char *name)
Checks to see if player knows the spell.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
void do_forget_spell(object *op, const char *spell)
Erases spell from player's inventory.
int rndm(int min, int max)
Returns a number between min and max.
#define MSG_TYPE_APPLY_FAILURE
Apply OK, but no/bad result.
void register_describe(int ob_type, describe_func method)
Registers the describe method for the given type.
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
#define MSG_TYPE_SPELL
Spell related info.
void esrv_update_item(int flags, object *pl, object *op)
Updates object *op for player *pl.
#define MSG_TYPE_SPELL_INFO
random info about spell, not related to failure/success
#define NDI_BLUE
Actually, it is Dodger Blue.
#define FLAG_BLIND
If set, object cannot see (visually)
static void spellbook_type_describe(const object *book, const object *observer, const int use_media_tags, char *buf, const size_t size)
Describe a spellbook.
void stringbuffer_trim_whitespace(StringBuffer *sb)
Trim trailing whitespace from a stringbuffer.
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Changes experience to a player/monster.
#define FLAG_CONFUSED
Will also be unable to cast spells.
#define FLAG_BLESSED
Item has a blessing, opposite of cursed/damned.
uint8_t message_type
Message type to be sent to the client.
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
Global type definitions and header inclusions.
struct player * contr
Pointer to the player which control this object.
StringBuffer * describe_spellpath_attenuation(const char *attenuation, int value, StringBuffer *buf)
Describe the specified path attenuation.
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).
#define MSG_TYPE_APPLY
Applying objects.
char method_ret
Define some standard return values for callbacks which don't need to return any other results...
uint32_t update_look
If true, we need to send the look window.
int16_t level
Level of creature or object.
object * identify(object *op)
Identifies an item.
void safe_strcat(char *dest, const char *orig, size_t *curlen, size_t maxlen)
Simple function we use below to keep adding to the same string but also make sure we don't overwrite ...
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Append a formatted string to a string buffer instance.
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.
#define QUERY_FLAG(xyz, p)
#define MSG_TYPE_APPLY_ERROR
void query_name(const object *op, char *buf, size_t size)
Describes an item.
#define FLAG_IDENTIFIED
Item is identifiable (e.g.
socket_struct * socket
Socket information for this player.
sstring msg
If this is a book/sign/magic mouth/etc.
void common_ob_describe(const object *op, const object *observer, int use_media_tags, char *buf, size_t size)
Describes an object, seen by a given observer.
Struct to store the message_type and message_subtype for signs and books used by the player...
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...
void do_learn_spell(object *op, object *spell, int special_prayer)
Actually makes op learn spell.
struct Settings settings
Global settings.
void init_type_spellbook(void)
Initializer for the SPELLBOOK object type.
int random_roll(int min, int max, const object *op, int goodbad)
Roll a random number between min and max.
int get_learn_spell(int stat)
#define FLAG_WIZ
Object has special privilegies.
living stats
Str, Con, Dex, etc.
#define MAX_BUF
Used for all kinds of things.
#define FLAG_CURSED
The object is cursed.
#define object_decrease_nrof_by_one(xyz)
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.
sstring name
The name of the object, obviously...
uint8_t type
PLAYER, BULLET, etc.
void scroll_failure(object *op, int failure, int power)
op made some mistake with a scroll, this takes care of punishment.
#define MSG_TYPE_APPLY_SUCCESS
Was able to apply object.
object * inv
Pointer to the first object in the inventory.
#define FLAG_STARTEQUIP
Object was given to player at start.
sstring skill
Name of the skill this object uses/grants.
#define NDI_UNIQUE
Print immediately, don't buffer.
uint8_t message_subtype
Message subtype to be sent to the client.
Structure containing object statistics.
A buffer that will be expanded as content is added to it.
Object type functions and variables.
const readable_message_type * get_readable_message_type(object *readable)
Get the readable type for an object (hopefully book).
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...
uint8_t spell_failure_effects
Nasty backlash to spell failures.
int die_roll(int num, int size, const object *op, int goodbad)
Roll a number of dice (2d3, 4d6).
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...
static method_ret spellbook_type_apply(object *book, object *applier, int aflags)
Applies a spellbook.
uint32_t path_attuned
Paths the object is attuned to.
void register_apply(int ob_type, apply_func method)
Registers the apply method for the given type.