Crossfire Server, Branch 1.12
R12190
|
All this functions handle gods: give presents, punish, and so on. More...
#include <global.h>
#include <living.h>
#include <object.h>
#include <spells.h>
#include <sounds.h>
#include <sproto.h>
Go to the source code of this file.
Functions | |
void | become_follower (object *op, const object *new_god) |
This function is called whenever a player has switched to a new god. | |
static void | check_special_prayers (object *op, const object *god) |
Removes special prayers given by a god. | |
const char * | determine_god (object *op) |
Determines if op worships a god. | |
archetype * | determine_holy_arch (const object *god, const char *type) |
Determines the archetype for holy servant and god avatar. | |
const object * | find_god (const char *name) |
Returns pointer to specified god's object through pntr_to_god_obj(). | |
static int | follower_has_similar_item (object *op, object *item) |
Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively). | |
static int | follower_level_to_enchantments (int level, int difficulty) |
Converts a level and difficulty to a magic/enchantment value for eg weapons. | |
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. | |
static 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 has race *race if we can't find a god that is appropriate, we return NULL. | |
static int | god_enchants_weapon (object *op, const object *god, object *tr, object *skill) |
God wants to enchant weapon. | |
static int | god_examines_item (const object *god, object *item) |
God checks item the player is using. | |
static int | god_examines_priest (object *op, const object *god) |
Checks and maybe punishes someone praying. | |
static int | god_gives_present (object *op, const object *god, treasure *tr) |
God gives an item to the player. | |
static void | god_intervention (object *op, const object *god, object *skill) |
Every once in a while the god will intervene to help the worshiper. | |
static int | god_removes_curse (object *op, int remove_damnation) |
God helps player by removing curse and/or damnation. | |
static int | improve_weapon_magic (object *op, object *tr, object *weapon, object *skill) |
Utility function for improving the magic on a weapon. | |
static int | lookup_god_by_name (const char *name) |
Returns the id of specified god. | |
void | pray_at_altar (object *pl, object *altar, object *skill) |
Player prays at altar. | |
static int | same_string (const char *s1, const char *s2) |
Compares 2 strings. | |
static void | stop_using_item (object *op, int type, int number) |
Unapplies up to number worth of items of type type, ignoring curse status. | |
int | tailor_god_spell (object *spellop, object *caster) |
Changes the attributes of cone, smite, and ball spells as needed by the code. | |
static void | update_priest_flag (const object *god, object *exp_ob, uint32 flag) |
If the god does/doesnt have this flag, we give/remove it from the experience object if it doesnt/does already exist. | |
static int | worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) |
Forbids or let player use something item type. |
All this functions handle gods: give presents, punish, and so on.
Oct 3, 1995 - Code laid down for initial gods, priest alignment, and monster race initialization. b.t.
Sept 1996 - moved code over to object -oriented gods -b.t.
Definition in file gods.c.
void become_follower | ( | object * | op, |
const object * | new_god | ||
) |
This function is called whenever a player has switched to a new god.
It handles basically all the stat changes that happen to the player, including the removal of godgiven items (from the former cult).
op | player switching cults. |
new_god | new god to worship. |
Definition at line 502 of file gods.c.
References add_string(), ARMOUR, ATNR_COLD, ATNR_ELECTRICITY, ATNR_FIRE, ATNR_POISON, BOOK, BOOTS, cast_magic_storm(), change_abil(), check_special_prayers(), CLEAR_FLAG, create_archetype(), determine_god(), draw_ext_info_format(), EXPERIENCE, find_god(), FLAG_APPLIED, FLAG_BLIND, FLAG_MAKE_INVIS, FLAG_REFL_MISSILE, FLAG_REFL_SPELL, FLAG_SEE_IN_DARK, FLAG_STARTEQUIP, FLAG_STEALTH, FLAG_UNDEAD, FLAG_USE_ARMOUR, FLAG_USE_SHIELD, FLAG_USE_WEAPON, FLAG_XRAYS, follower_remove_given_items(), FORCE, free_object(), free_string(), get_archetype_by_type_subtype(), give_skill_by_name(), GLOVES, god_gives_present(), HELMET, treasurestruct::item, link_player_skills(), LOOSE_MANA, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, NDI_NAVY, NDI_UNIQUE, treasurestruct::next, NROFATTACKS, player_unready_range_ob(), PREFER_LOW, present_in_ob_by_name(), QUERY_FLAG, random_roll(), remove_ob(), SET_FLAG, SHIELD, SK_PRAYING, SKILL, SPELL, SPELLBOOK, stop_using_item(), update_priest_flag(), WEAPON, and worship_forbids_use().
Referenced by command_setgod(), and pray_at_altar().
static void check_special_prayers | ( | object * | op, |
const object * | god | ||
) | [static] |
Removes special prayers given by a god.
op | player to remove prayers from. |
god | god we're removing the prayers. |
Definition at line 431 of file gods.c.
References do_forget_spell(), draw_ext_info_format(), FLAG_STARTEQUIP, free_object(), treasurestruct::item, llevError, LOG(), MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, NDI_NAVY, NDI_UNIQUE, treasurestruct::next, player_unready_range_ob(), QUERY_FLAG, remove_ob(), and SPELL.
Referenced by become_follower(), and god_intervention().
const char* determine_god | ( | object * | op | ) |
Determines if op worships a god.
Returns the godname if they do or "none" if they have no god. In the case of an NPC, if they have no god, we try and guess who they should worship based on their race. If that fails we give them a random one.
op | object to get name of. |
Definition at line 118 of file gods.c.
References add_string(), first_god, FLAG_ALIVE, get_god_for_race(), glnk::id, lookup_god_by_name(), glnk::name, glnk::next, PLAYER, QUERY_FLAG, rndm(), SK_PRAYING, SKILL, SPELL, and SPELL_EFFECT.
Referenced by become_follower(), cast_bless(), cast_consecrate(), cast_curse(), cast_detection(), cast_smite_spell(), cast_spell(), cfapi_object_get_property(), hit_player(), hit_with_one_attacktype(), kill_player(), mood_change(), perceive_self(), pray_at_altar(), prayer_failure(), show_skills(), summon_golem(), summon_object(), and tailor_god_spell().
archetype* determine_holy_arch | ( | const object * | god, |
const char * | type | ||
) |
Determines the archetype for holy servant and god avatar.
Possible monsters are stored as invisible books in god's inventory, one having the right name is selected randomly.
god | god for which we want something. |
type | what the summon type is. Must be a shared string. |
Definition at line 782 of file gods.c.
References BOOK, treasurestruct::item, llevError, LOG(), treasurestruct::next, and rndm().
Referenced by summon_golem().
const object* find_god | ( | const char * | name | ) |
Returns pointer to specified god's object through pntr_to_god_obj().
name | god's name. |
Definition at line 92 of file gods.c.
References first_god, glnk::name, glnk::next, and pntr_to_god_obj().
Referenced by become_follower(), cast_bless(), cast_consecrate(), cast_curse(), cast_detection(), cast_smite_spell(), command_setgod(), hit_player(), hit_with_one_attacktype(), mood_change(), perceive_self(), pray_at_altar(), summon_golem(), summon_object(), and tailor_god_spell().
static int follower_has_similar_item | ( | object * | op, |
object * | item | ||
) | [static] |
Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively).
op | object to check. |
item | object to check for. |
Definition at line 252 of file gods.c.
References same_string().
Referenced by god_gives_present().
static int follower_level_to_enchantments | ( | int | level, |
int | difficulty | ||
) | [static] |
Converts a level and difficulty to a magic/enchantment value for eg weapons.
level | level |
difficulty | difficulty. Must be 1 or more. |
Definition at line 866 of file gods.c.
References llevError, and LOG().
Referenced by improve_weapon_magic().
static void follower_remove_given_items | ( | object * | pl, |
object * | op, | ||
const object * | god | ||
) | [static] |
Removes from a player's inventory all items bestowed by a particular god.
Intended mainly for use in punishing characters for switching gods.
pl | the player object |
op | the object to be searched for items |
god | the god whose objects to remove |
Definition at line 211 of file gods.c.
References draw_ext_info_format(), free_object(), get_ob_key_value(), HUGE_BUF, MSG_TYPE_ITEM, MSG_TYPE_ITEM_REMOVE, NDI_UNIQUE, query_short_name(), and remove_ob().
Referenced by become_follower().
static const char * get_god_for_race | ( | const char * | race | ) | [static] |
Returns a string that is the name of the god that should be natively worshipped by a creature of who has race *race if we can't find a god that is appropriate, we return NULL.
race | race we're getting the god of. |
Definition at line 1367 of file gods.c.
References glnk::arch, first_god, glnk::name, glnk::next, and strcasecmp().
Referenced by determine_god().
static int god_enchants_weapon | ( | object * | op, |
const object * | god, | ||
object * | tr, | ||
object * | skill | ||
) | [static] |
God wants to enchant weapon.
Affected weapon is the applied one (weapon or bow). It's checked to make sure it isn't a weapon for another god. If all is all right, update weapon with attacktype, slaying and such.
op | player |
god | god enchanting weapon. |
tr | treasure list item for enchanting weapon, contains the enchantment level. |
skill | praying skill of op. |
Definition at line 930 of file gods.c.
References add_string(), AT_PHYSICAL, BOW, draw_ext_info(), draw_ext_info_format(), esrv_update_item(), find_skill_by_number(), FLAG_APPLIED, get_ob_key_value(), god_examines_item(), improve_weapon_magic(), llevError, LOG(), MAX_BUF, MAX_WEAPON_ITEM_POWER, MSG_TYPE_ITEM, MSG_TYPE_ITEM_CHANGE, MSG_TYPE_ITEM_INFO, NDI_UNIQUE, Settings::personalized_blessings, PLAYER, QUERY_FLAG, set_ob_key_value(), settings, SK_PRAYING, snprintf(), TRUE, UPD_NAME, and WEAPON.
Referenced by god_intervention().
static int god_examines_item | ( | const object * | god, |
object * | item | ||
) | [static] |
God checks item the player is using.
If you are using the item of an enemy god, it can be bad...-b.t.
god | god checking. |
item | item to check. |
-1 | item is bad. |
0 | item is neutral. |
1 | item is good. |
Definition at line 1326 of file gods.c.
References draw_ext_info_format(), MAX_BUF, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, NDI_NAVY, NDI_UNIQUE, query_name(), and snprintf().
Referenced by god_enchants_weapon(), and god_examines_priest().
static int god_examines_priest | ( | object * | op, |
const object * | god | ||
) | [static] |
Checks and maybe punishes someone praying.
All applied items are examined, if player is using more items of other gods, s/he loses experience in praying or general experience if no praying.
op | player the god examines. |
god | god examining the player. |
Definition at line 1275 of file gods.c.
References cast_magic_storm(), change_exp(), create_archetype(), draw_ext_info_format(), FLAG_APPLIED, god_examines_item(), LOOSE_MANA, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, NDI_NAVY, NDI_UNIQUE, PREFER_LOW, QUERY_FLAG, random_roll(), SK_PRAYING, SK_SUBTRACT_SKILL_EXP, and SKILL.
Referenced by god_intervention().
static int god_gives_present | ( | object * | op, |
const object * | god, | ||
treasure * | tr | ||
) | [static] |
God gives an item to the player.
Inform player of the present.
op | who is getting the treasure. |
god | god giving the present. |
tr | object to give. Should be a single object on list. |
Mark what god gave it, so it can be taken vengefully later!
Definition at line 280 of file gods.c.
References arch_to_object(), draw_ext_info_format(), fix_generated_item(), follower_has_similar_item(), free_object2(), GT_ONLY_GOOD, HUGE_BUF, insert_ob_in_ob(), treasurestruct::item, MSG_TYPE_ITEM, MSG_TYPE_ITEM_ADD, NDI_UNIQUE, query_short_name(), ROD, set_ob_key_value(), TRUE, and WAND.
Referenced by become_follower(), and god_intervention().
static void god_intervention | ( | object * | op, |
const object * | god, | ||
object * | skill | ||
) | [static] |
Every once in a while the god will intervene to help the worshiper.
Later, this fctn can be used to supply quests, etc for the priest. -b.t. called from pray_at_altar() currently.
op | player praying. |
god | god player is praying to. |
skill | player's praying skill. |
Definition at line 1047 of file gods.c.
References BOOK, cast_change_ability(), cast_heal(), treasurestruct::chance, check_special_prayers(), check_spell_known(), create_archetype(), create_archetype_by_object_name(), create_treasure(), do_learn_spell(), draw_ext_info(), draw_ext_info_format(), find_archetype(), find_treasurelist(), fix_object(), free_object(), get_attr_value(), god_enchants_weapon(), god_examines_priest(), god_gives_present(), god_removes_curse(), GT_ONLY_GOOD, GT_STARTEQUIP, GT_UPDATE_INV, HOLY_POSSESSION, treasurestruct::item, llevError, LOG(), MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_END, MSG_TYPE_ITEM, MSG_TYPE_ITEM_ADD, MSG_TYPE_SKILL, MSG_TYPE_SKILL_PRAY, treasurestruct::name, NDI_UNIQUE, NDI_WHITE, treasurestruct::next, NUM_STATS, PREFER_HIGH, present_arch_in_ob(), random_roll(), remove_ob(), restore_msg, and SPELL.
Referenced by pray_at_altar().
static int god_removes_curse | ( | object * | op, |
int | remove_damnation | ||
) | [static] |
God helps player by removing curse and/or damnation.
op | player to help. |
remove_damnation | if set, also removes damned items. |
Definition at line 832 of file gods.c.
References CLEAR_FLAG, draw_ext_info(), esrv_update_item(), FLAG_CURSED, FLAG_DAMNED, FLAG_KNOWN_CURSED, MSG_TYPE_SKILL, MSG_TYPE_SKILL_PRAY, NDI_UNIQUE, PLAYER, QUERY_FLAG, and UPD_FLAGS.
Referenced by god_intervention().
static int improve_weapon_magic | ( | object * | op, |
object * | tr, | ||
object * | weapon, | ||
object * | skill | ||
) | [static] |
Utility function for improving the magic on a weapon.
Affected weapon is the applied one (weapon or bow). This utility function improves the weapon magic on a weapon being enchanted by a god. This was necessary because the same block of the code was being called from two places in the god_enchants_weapon(...) function.
op | player |
tr | treasure list item for enchanting weapon, contains the enchantment level. |
weapon | weapon being modified |
skill | praying skill of op. |
Definition at line 897 of file gods.c.
References draw_ext_info(), esrv_update_item(), follower_level_to_enchantments(), MSG_TYPE_ITEM, MSG_TYPE_ITEM_CHANGE, NDI_UNIQUE, PLAYER, and UPD_NAME.
Referenced by god_enchants_weapon().
static int lookup_god_by_name | ( | const char * | name | ) | [static] |
Returns the id of specified god.
name | god to search for. |
Definition at line 66 of file gods.c.
References first_god, glnk::id, MIN, glnk::name, and glnk::next.
Referenced by determine_god().
void pray_at_altar | ( | object * | pl, |
object * | altar, | ||
object * | skill | ||
) |
Player prays at altar.
Checks for god changing, divine intervention, and so on.
pl | player praying. |
altar | altar player's praying on. Doesn't need to be consecrated. |
skill | praying skill. |
Definition at line 325 of file gods.c.
References absdir(), become_follower(), cast_magic_storm(), change_exp(), create_archetype(), determine_god(), draw_ext_info(), draw_ext_info_format(), EVENT_APPLY, execute_event(), find_god(), god_intervention(), LOOSE_MANA, MAX, move_player(), MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, NDI_NAVY, NDI_UNIQUE, PREFER_LOW, random_roll(), random_roll64(), SCRIPT_FIX_ALL, and SK_SUBTRACT_SKILL_EXP.
Referenced by pray().
static int same_string | ( | const char * | s1, |
const char * | s2 | ||
) | [static] |
Compares 2 strings.
s1 | |
s2 | strings to compare. |
Definition at line 183 of file gods.c.
Referenced by follower_has_similar_item().
static void stop_using_item | ( | object * | op, |
int | type, | ||
int | number | ||
) | [static] |
Unapplies up to number worth of items of type type, ignoring curse status.
This is used when the player gets forbidden to use eg weapons.
op | player we're considering. |
type | item type to remove. |
number | maximum number of items to unapply. |
Definition at line 728 of file gods.c.
References AP_IGNORE_CURSE, AP_UNAPPLY, apply_special(), FLAG_APPLIED, and QUERY_FLAG.
Referenced by become_follower().
int tailor_god_spell | ( | object * | spellop, |
object * | caster | ||
) |
Changes the attributes of cone, smite, and ball spells as needed by the code.
spellop | spell object to change. |
caster | what is casting spellop (player, spell, ...). |
Definition at line 1394 of file gods.c.
References add_string(), AT_GODPOWER, AT_HOLYWORD, determine_god(), draw_ext_info(), find_god(), FREE_AND_COPY, free_object(), free_string(), get_owner(), llevError, LOG(), MAX_BUF, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, NDI_UNIQUE, snprintf(), SPELL, and SPELL_EFFECT.
Referenced by cast_cone(), cast_smite_spell(), explode_bullet(), fire_arch_from_position(), and fire_swarm().
static void update_priest_flag | ( | const object * | god, |
object * | exp_ob, | ||
uint32 | flag | ||
) | [static] |
If the god does/doesnt have this flag, we give/remove it from the experience object if it doesnt/does already exist.
god | god object. |
exp_ob | player's praying skill object. |
flag | flag to consider. |
Definition at line 750 of file gods.c.
References CLEAR_FLAG, QUERY_FLAG, and SET_FLAG.
Referenced by become_follower(), and worship_forbids_use().
static int worship_forbids_use | ( | object * | op, |
object * | exp_obj, | ||
uint32 | flag, | ||
const char * | string | ||
) | [static] |
Forbids or let player use something item type.
op | player. |
exp_obj | praying skill. |
flag | FLAG_xxx to check against. |
string | what flag corresponds to ("weapons", "shield", ...). |
Definition at line 696 of file gods.c.
References draw_ext_info_format(), MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, NDI_UNIQUE, QUERY_FLAG, and update_priest_flag().
Referenced by become_follower().