35 static int worship_forbids_use(
object *op,
object *exp_obj, uint32_t flag,
const char *
string);
38 static void god_intervention(
object *op,
const object *god,
object *skill,
object *altar);
68 if (op->
race != NULL) {
70 if (godname != NULL) {
97 return tmp->
title != NULL ? tmp->
title :
"none";
115 return s2 != NULL && strcmp(s1, s2) == 0;
134 const char *given_by;
139 if (given_by == god->
name) {
146 "The %s crumble to dust!",
150 "The %s crumbles to dust!",
171 if (tmp->type == item->
type 174 && tmp->msg == item->
msg 218 "%s lets %s appear in your hands.",
233 const uint64_t loss = angry * (skill->
stats.
exp / 10);
315 "Foul Priest! %s punishes you!",
321 "Foolish heretic! %s is livid!",
325 "Heretic! %s is angered!",
333 "A divine force pushes you off the altar.");
355 LOG(
llevError,
"BUG: remove_special_prayers(): god %s without randomitems\n", god->
name);
373 if (tr->
item == NULL)
389 "You lose knowledge of %s.",
422 && (item->type !=
SKILL)
423 && (item->type !=
FORCE)
424 && (item->type !=
SPELL)) {
448 "Fool! %s detests your kind!",
460 && tr->item->clone.invisible
462 && tr->item->clone.type !=
BOOK 463 && tr->item->clone.type !=
SPELL)
468 "You become a follower of %s!",
496 "%s's blessing is withdrawn from you.",
500 if (sk_applied || undeadified) {
542 "You are bathed in %s's aura.",
597 "You may use %s again.",
601 "You are forbidden to use %s.",
682 LOG(
llevError,
"BUG: determine_holy_arch(): no god or god without randomitems\n");
698 count =
rndm(1, count);
744 "You feel like someone is helping you.");
758 if (difficulty < 1) {
759 LOG(
llevError,
"follower_level_to_enchantments(): difficulty %d is invalid\n", difficulty);
764 return level/difficulty;
766 return (20+(level-20)/2)/difficulty;
767 return (30+(level-40)/4)/difficulty;
791 if (weapon->
magic < tmp) {
793 "A phosphorescent glow envelops your weapon!");
834 "%s considers your %s is not worthy to be enchanted any more.",
848 const char *divine_owner =
object_get_value(weapon,
"divine_blessing_name");
850 object *skillop = NULL;
852 if (divine_owner != NULL && strcmp(divine_owner, god->
name) != 0) {
855 "Your %s already belongs to %s !",
856 weapon->
name, divine_owner);
860 if ((owner != NULL) && (strcmp(owner, op->
name) != 0)) {
863 "The %s is not yours, and is magically protected against such changes !",
868 if (skillop == NULL) {
869 LOG(
llevError,
"god_enchants_weapon: no praying skill object found ?!\n");
870 snprintf(buf,
sizeof(buf),
"%d", 1);
879 if (!weapon->
title) {
880 snprintf(buf,
sizeof(buf),
"of %s", god->
name);
885 "Your weapon quivers as if struck!");
892 "Your %s now hungers to slay enemies of your god!",
902 "Your weapon suddenly glows!");
927 static void god_intervention(
object *op,
const object *god,
object *skill,
object *altar) {
931 LOG(
llevError,
"BUG: god_intervention(): no god or god without randomitems\n");
940 "You feel a holy presence!");
958 "Something appears before your eyes. You catch it before it falls to the ground.");
972 && strcmp(item->
name,
"grace limit") == 0) {
990 && strcmp(item->
name,
"restore grace") == 0) {
995 "You are returned to a state of grace.");
1001 && strcmp(item->
name,
"restore hitpoints") == 0) {
1005 "A white light surrounds and heals you!");
1013 && strcmp(item->
name,
"restore spellpoints") == 0) {
1020 "A blue lightning strikes your head but doesn't hurt you!");
1026 && strcmp(item->
name,
"heal spell") == 0) {
1042 && strcmp(item->
name,
"remove curse") == 0) {
1051 && strcmp(item->
name,
"remove damnation") == 0) {
1060 && strcmp(item->
name,
"heal depletion") == 0) {
1063 "Shimmering light surrounds and restores you!");
1069 && strcmp(item->
name,
"voice_behind") == 0) {
1071 "You hear a voice from behind you, but you don't dare to " 1080 && strcmp(item->
name,
"message") == 0) {
1088 && strcmp(item->
name,
"enchant weapon") == 0) {
1103 "%s grants you use of a special prayer!",
1120 "You feel rapture.");
1147 int loss = 10000000;
1148 int angry = abs(reaction);
1152 loss = 0.05*(float)skop->
stats.
exp;
1160 "%s becomes angry and punishes you!",
1191 snprintf(buf,
sizeof(buf),
"of %s", god->
name);
1192 if (!strcmp(item->
title, buf))
1196 snprintf(buf,
sizeof(buf),
"of %s", god->
title);
1197 if (!strcmp(item->
title, buf)) {
1203 "Heretic! You are using %s!",
1225 int caster_is_spell = 0;
1228 caster_is_spell = 1;
1238 if (!caster_is_spell)
1240 "This prayer is useless unless you worship an appropriate god");
1253 if (!caster_is_spell)
1268 if (spellop->
title) {
1271 snprintf(buf,
sizeof(buf),
"%s of %s", spellop->
name, spellop->
title);
#define AP_UNAPPLY
Item is to be remvoed.
#define AT_HOLYWORD
Damage based on race and caster's god.
#define MSG_TYPE_SKILL_PRAY
Praying related messages.
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
int apply_special(object *who, object *op, int aflags)
Apply an object.
When object has been generated, send its information to player.
int become_follower(object *op, const object *new_god)
This function is called whenever a player has switched to a new god.
#define MSG_TYPE_ITEM_CHANGE
Item has changed in some way.
#define FLAG_DAMNED
The object is very cursed.
static int god_removes_curse(object *op, int remove_damnation)
God helps player by removing curse and/or damnation.
#define MSG_TYPE_ATTRIBUTE_GOD
changing god info
#define MSG_TYPE_ITEM
Item related information.
Spell-related defines: spellpath, subtypes, ...
int move_player(object *op, int dir)
Move player in the given direction.
int8_t item_power
Power rating of the object.
struct archetype * arch
Pointer to archetype.
const object * find_god(const char *name)
Returns a god's object from its name.
object * check_spell_known(object *op, const char *name)
Checks to see if player knows the spell.
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
int rndm(int min, int max)
Returns a number between min and max.
#define MSG_TYPE_ITEM_ADD
Item added to inventory.
static bool try_leave_cult(object *pl, object *skill, int angry)
Try to leave a cult.
int cast_change_ability(object *op, object *caster, object *spell_ob, int dir, int silent)
Cast some stat-improving spell.
#define MSG_TYPE_ITEM_INFO
Information related to items.
static int god_examines_priest(object *op, const object *god)
Checks and maybe punishes someone praying.
#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
static int same_string(const char *s1, const char *s2)
Compares 2 strings.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
int16_t maxgrace
Maximum grace.
int remove_depletion(object *op, int level)
Remove depletion from op, if present, and warn player of such restorations.
#define HUGE_BUF
Used for messages - some can be quite long.
sstring name
If non null, name of list to use instead.
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.
sstring add_string(const char *str)
Share a string.
int8_t luck
Affects thaco and ac from time to time.
#define FLAG_BLIND
If set, object cannot see (visually)
void link_player_skills(object *op)
This function goes through the player inventory and sets up the last_skills[] array in the player obj...
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Changes experience to a player/monster.
#define FLAG_STEALTH
Will wake monsters with less range.
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
archetype * determine_holy_arch(const object *god, const char *type)
Determines the archetype for holy servant and god avatar.
#define MSG_TYPE_ITEM_REMOVE
Item removed from inv.
static int god_gives_present(object *op, const object *god, treasure *tr)
God gives an item to the player.
uint32_t path_repelled
Paths the object is repelled from.
static int god_enchants_weapon(object *op, const object *god, object *tr, object *skill)
God wants to enchant weapon.
Global type definitions and header inclusions.
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).
static void follower_remove_given_items(object *pl, object *op, const object *god)
Removes from a player's inventory all items bestowed by a particular god.
#define FLAG_UNDEAD
Monster is undead.
int change_abil(object *op, object *tmp)
Permanently alters an object's stats/flags based on another object.
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
int16_t level
Level of creature or object.
#define AT_GODPOWER
Adds relevant god's attacktype (1048576) peterm@soda.berkeley.edu.
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.
const char * get_god_for_race(const char *race)
Returns a string that is the name of the god that should be natively worshipped by a creature of who ...
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)
#define AP_IGNORE_CURSE
Apply/unapply regardless of cursed/damned status.
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
#define FLAG_REFL_SPELL
Spells (some) will reflect from object.
const char * determine_god(object *op)
Determines if op worships a god.
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
This calls the appropriate treasure creation function.
static int follower_level_to_enchantments(int level, int difficulty)
Converts a level and difficulty to a magic/enchantment value for eg weapons.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
sstring name
More definite name, like "generate_kobold".
int64_t random_roll64(int64_t min, int64_t max, const object *op, int goodbad)
This is a 64 bit version of random_roll() above.
static int worship_forbids_use(object *op, object *exp_obj, uint32_t flag, const char *string)
Forbids or let player use something item type.
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
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.
int32_t last_sp
As last_heal, but for spell points.
#define QUERY_FLAG(xyz, p)
#define FLAG_USE_SHIELD
Can this creature use a shield?
static void update_priest_flag(const object *god, object *exp_ob, uint32_t flag)
If the god does/doesnt have this flag, we give/remove it from the experience object if it doesnt/does...
sstring anim_suffix
Used to determine combined animations.
#define MSG_TYPE_ATTRIBUTE
Changes to attributes (stats, resistances, etc)
void query_name(const object *op, char *buf, size_t size)
Describes an item.
uint8_t chance
Percent chance for this 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().
sstring msg
If this is a book/sign/magic mouth/etc.
sstring race
Human, goblin, dragon, etc.
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
static int god_examines_item(const object *god, object *item)
God checks item the player is using.
#define MAX_WEAPON_ITEM_POWER
Maximum item power an item can have.
static int improve_weapon_magic(object *op, object *tr, object *weapon, object *skill)
Utility function for improving the magic on a weapon.
const object * get_rand_god(void)
Returns a random god.
object * create_archetype_by_object_name(const char *name)
Creates an object given the name that appears during the game (for example, "writing pen" instead of ...
void do_learn_spell(object *op, object *spell, int special_prayer)
Actually makes op learn spell.
struct Settings settings
Global settings.
void player_unready_range_ob(player *pl, object *ob)
Unready an object for a player.
#define FLAG_XRAYS
X-ray vision.
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.
static void god_intervention(object *op, const object *god, object *skill, object *altar)
Every once in a while the god will intervene to help the worshiper.
#define AT_PHYSICAL
Basic attack (1)
uint32_t path_denied
Paths the object is denied access to.
living stats
Str, Con, Dex, etc.
#define MAX_BUF
Used for all kinds of things.
int16_t invisible
How much longer the object will be invis.
archetype * get_archetype_by_type_subtype(int type, int subtype)
Retrieves an archetype by type and subtype.
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...
treasurelist represents one logical group of items to be generated together.
int8_t facing
Object is oriented/facing that way.
#define FLAG_KNOWN_CURSED
The object is known to be cursed.
#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...
struct treasurelist * randomitems
Items to be generated.
sstring name_pl
The plural name of the object.
Object structure, the core of Crossfire.
void pray_at_altar(object *pl, object *altar, object *skill)
Player prays at altar.
int cast_heal(object *op, object *caster, object *spell, int dir)
Heals something.
#define FREE_AND_COPY(sv, nv)
Release the shared string if not NULL, and make it a reference to nv.
treasure * next
Next treasure-item in a linked list.
Also see SKILL_TOOL (74) below.
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...
sstring title
Of foo, etc.
static int follower_has_similar_item(object *op, object *item)
Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively).
void esrv_remove_spell(player *pl, object *spell)
#define CLEAR_FLAG(xyz, p)
treasure * items
Items in this list, linked.
uint8_t type
PLAYER, BULLET, etc.
int tailor_god_spell(object *spellop, object *caster)
Changes the attributes of cone, smite, and ball spells as needed by the code.
#define FLAG_APPLIED
Object is ready for use by living.
treasurelist * find_treasurelist(const char *name)
Search for the given treasurelist by name.
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
object * inv
Pointer to the first object in the inventory.
static void stop_using_item(object *op, int type, int number)
Unapplies up to number worth of items of type type, ignoring curse status.
#define FLAG_MAKE_INVIS
(Item) gives invisibility when applied
#define FLAG_STARTEQUIP
Object was given to player at start.
treasure is one element in a linked list, which together consist of a complete treasure-list.
Don't generate bad/cursed items.
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 MSG_TYPE_SKILL
Messages related to skill use.
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.
object * give_skill_by_name(object *op, const char *skill_name)
Given the skill name skill_name, we find the skill archetype/object, set appropriate values...
#define NDI_UNIQUE
Print immediately, don't buffer.
int32_t last_heal
Last healed.
#define EVENT_APPLY
Object applied-unapplied.
int absdir(int d)
Computes an absolute direction.
int32_t food
How much food in stomach.
Structure containing object statistics.
struct archetype * item
Which item this link can be.
int16_t maxhp
Max hit points.
#define SK_SUBTRACT_SKILL_EXP
Used when removing exp.
static void remove_special_prayers(object *op, const object *god)
Removes special prayers given by a god.
object * find_skill_by_number(object *who, int skillno)
This returns the first skill pointer of the given subtype (the one that accumulates exp...
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
#define FLAG_REFL_MISSILE
Arrows will reflect from object.
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.
object clone
An object from which to do object_copy()
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
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.
uint32_t path_attuned
Paths the object is attuned to.
Generated items have the FLAG_STARTEQUIP.
int32_t last_eat
How long since we last ate.