![]() |
Crossfire Server, Trunk
1.75.0
|
#include "global.h"
#include <stdlib.h>
#include <string.h>
#include "living.h"
#include "object.h"
#include "sounds.h"
#include "spells.h"
#include "sproto.h"
Go to the source code of this file.
Functions | |
int | become_follower (object *op, const object *new_god) |
This function is called whenever a player has switched to a new god. More... | |
const char * | determine_god (object *op) |
Determines if op worships a god. More... | |
archetype * | determine_holy_arch (const object *god, const char *type) |
Determines the archetype for holy servant and god avatar. More... | |
static int | follower_has_similar_item (object *op, object *item) |
Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively). More... | |
static int | follower_level_to_enchantments (int level, int difficulty) |
Converts a level and difficulty to a magic/enchantment value for eg weapons. More... | |
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. More... | |
static int | god_enchants_weapon (object *op, const object *god, object *tr, object *skill) |
God wants to enchant weapon. More... | |
static int | god_examines_item (const object *god, object *item) |
God checks item the player is using. More... | |
static int | god_examines_priest (object *op, const object *god) |
Checks and maybe punishes someone praying. More... | |
static int | god_gives_present (object *op, const object *god, treasure *tr) |
God gives an item to the player. More... | |
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. More... | |
static int | god_removes_curse (object *op, int remove_damnation) |
God helps player by removing curse and/or damnation. More... | |
static int | improve_weapon_magic (object *op, object *tr, object *weapon, object *skill) |
Utility function for improving the magic on a weapon. More... | |
void | pray_at_altar (object *pl, object *altar, object *skill) |
Player prays at altar. More... | |
static void | remove_special_prayers (object *op, const object *god) |
Removes special prayers given by a god. More... | |
static int | same_string (const char *s1, const char *s2) |
Compares 2 strings. More... | |
static void | stop_using_item (object *op, int type, int number) |
Unapplies up to number worth of items of type type, ignoring curse status. More... | |
int | tailor_god_spell (object *spellop, object *caster) |
Changes the attributes of cone, smite, and ball spells as needed by the code. More... | |
static bool | try_leave_cult (object *pl, object *skill, int angry) |
Try to leave a cult. More... | |
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 already exist. More... | |
static int | worship_forbids_use (object *op, object *exp_obj, uint32_t flag, const char *string) |
Forbids or let player use something item type. More... | |
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.cpp.
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). Handles race restrictions on god, and will punish player if needed.
op | player switching cults. |
new_god | new god to worship. |
Definition at line 414 of file gods.cpp.
References add_string(), ARMOUR, ATNR_COLD, ATNR_ELECTRICITY, ATNR_FIRE, ATNR_POISON, BOOK, BOOTS, cast_magic_storm(), change_abil(), CLEAR_FLAG, object::contr, create_archetype(), determine_god(), draw_ext_info_format(), 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(), living::food, FOR_INV_FINISH, FOR_INV_PREPARE, FORCE, free_string(), get_archetype_by_type_subtype(), give_skill_by_name(), GLOVES, god_gives_present(), living::grace, HELMET, living::hp, treasurelist::items, object::last_eat, object::last_grace, object::last_heal, object::last_sp, object::level, link_player_skills(), LOOSE_MANA, living::luck, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, object::name, NDI_NAVY, NDI_UNIQUE, treasure::next, NROFATTACKS, object_find_by_type_subtype(), object_free_drop_inventory(), object_present_in_ob_by_name(), object_remove(), object::path_attuned, object::path_denied, object::path_repelled, player_unready_range_ob(), PREFER_LOW, QUERY_FLAG, object::race, random_roll(), object::randomitems, remove_special_prayers(), object::resist, SET_FLAG, SHIELD, SK_PRAYING, SKILL, object::slaying, living::sp, SPELL, SPELLBOOK, object::stats, stop_using_item(), object::title, update_priest_flag(), WEAPON, and worship_forbids_use().
Referenced by command_setgod(), and pray_at_altar().
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 55 of file gods.cpp.
References add_string(), find_god(), FLAG_ALIVE, get_god_for_race(), get_rand_god(), object::name, object_find_by_type_subtype(), PLAYER, QUERY_FLAG, object::race, SK_PRAYING, SKILL, SPELL, SPELL_EFFECT, object::title, and object::type.
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_not_permadeath(), mood_change(), perceive_self(), pets_summon_golem(), pets_summon_object(), pray_at_altar(), prayer_failure(), ring_bell(), show_skills(), and tailor_god_spell().
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 676 of file gods.cpp.
References BOOK, archetype::clone, object::invisible, treasure::item, treasurelist::items, llevError, LOG(), object::name, treasure::next, object::other_arch, object::randomitems, rndm(), is_valid_types_gen::type, and object::type.
Referenced by pets_summon_golem().
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 169 of file gods.cpp.
References FOR_INV_FINISH, FOR_INV_PREPARE, object::msg, object::name, same_string(), object::slaying, object::title, and object::type.
Referenced by god_gives_present().
|
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 757 of file gods.cpp.
References level, llevError, and LOG().
Referenced by improve_weapon_magic().
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 133 of file gods.cpp.
References draw_ext_info_format(), FOR_INV_FINISH, FOR_INV_PREPARE, HUGE_BUF, MSG_TYPE_ITEM, MSG_TYPE_ITEM_REMOVE, name, object::name, NDI_UNIQUE, object_free_drop_inventory(), object_get_value(), object_remove(), and query_short_name().
Referenced by become_follower().
|
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 821 of file gods.cpp.
References add_string(), AT_PHYSICAL, object::attacktype, BOW, buf, draw_ext_info, draw_ext_info_format(), esrv_update_item(), living::exp, find_skill_by_number(), FMT64, god_examines_item(), if(), improve_weapon_magic(), object::item_power, llevError, LOG(), MAX_BUF, MAX_WEAPON_ITEM_POWER, MSG_TYPE_ITEM, MSG_TYPE_ITEM_CHANGE, MSG_TYPE_ITEM_INFO, object::name, NDI_UNIQUE, object_find_by_type_applied(), object_get_value(), object_set_value(), Settings::personalized_blessings, PLAYER, settings, SK_PRAYING, skill, object::slaying, object::stats, object::title, TRUE, object::type, UPD_NAME, and WEAPON.
Referenced by god_intervention().
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 1182 of file gods.cpp.
References buf, draw_ext_info_format(), object::env, MAX_BUF, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, name, object::name, NDI_NAVY, NDI_UNIQUE, query_name(), and object::title.
Referenced by god_enchants_weapon(), and god_examines_priest().
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 1135 of file gods.cpp.
References cast_magic_storm(), change_exp(), create_archetype(), draw_ext_info_format(), living::exp, FLAG_APPLIED, FOR_INV_FINISH, FOR_INV_PREPARE, god_examines_item(), object::level, LOOSE_MANA, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, object::name, NDI_NAVY, NDI_UNIQUE, object_find_by_type_subtype(), PREFER_LOW, QUERY_FLAG, random_roll(), SK_PRAYING, SK_SUBTRACT_SKILL_EXP, SKILL, object::skill, and object::stats.
Referenced by god_intervention().
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 195 of file gods.cpp.
References arch_to_object(), archetype::clone, draw_ext_info_format(), fix_generated_item(), follower_has_similar_item(), GT_ONLY_GOOD, HUGE_BUF, object::inv, treasure::item, MSG_TYPE_ITEM, MSG_TYPE_ITEM_ADD, name, object::name, NDI_UNIQUE, object_free(), object_insert_in_ob(), object_set_value(), query_short_name(), ROD, TRUE, object::type, and WAND.
Referenced by become_follower(), and god_intervention().
|
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. |
altar | where the player is praying. |
Definition at line 927 of file gods.cpp.
References object::anim_suffix, apply_anim_suffix(), BOOK, cast_change_ability(), cast_heal(), treasure::chance, check_spell_known(), archetype::clone, create_archetype(), create_archetype_by_object_name(), create_treasure(), do_learn_spell(), draw_ext_info, draw_ext_info_format(), find_treasurelist(), god_enchants_weapon(), god_examines_priest(), god_gives_present(), god_removes_curse(), living::grace, GT_ONLY_GOOD, GT_STARTEQUIP, GT_UPDATE_INV, HOLY_POSSESSION, living::hp, object::invisible, treasure::item, treasurelist::items, object::level, llevError, LOG(), living::maxgrace, living::maxhp, living::maxsp, object::msg, MSG_TYPE_ITEM, MSG_TYPE_ITEM_ADD, MSG_TYPE_SKILL, MSG_TYPE_SKILL_PRAY, treasure::name, object::name, NDI_UNIQUE, NDI_WHITE, treasure::next, object_free_drop_inventory(), PREFER_HIGH, random_roll(), object::randomitems, remove_depletion(), skill, object::slaying, living::sp, SPELL, object::stats, and object::type.
Referenced by pray_at_altar().
|
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 724 of file gods.cpp.
References CLEAR_FLAG, draw_ext_info, esrv_update_item(), FLAG_CURSED, FLAG_DAMNED, FLAG_KNOWN_CURSED, FOR_INV_FINISH, FOR_INV_PREPARE, MSG_TYPE_SKILL, MSG_TYPE_SKILL_PRAY, NDI_UNIQUE, PLAYER, QUERY_FLAG, object::type, and UPD_FLAGS.
Referenced by god_intervention().
|
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 788 of file gods.cpp.
References draw_ext_info, esrv_update_item(), follower_level_to_enchantments(), object::item_power, object::level, object::magic, MSG_TYPE_ITEM, MSG_TYPE_ITEM_CHANGE, NDI_UNIQUE, PLAYER, skill, object::type, and UPD_NAME.
Referenced by god_enchants_weapon().
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 258 of file gods.cpp.
References absdir(), become_follower(), bonus, cast_magic_storm(), archetype::clone, create_archetype(), determine_god(), draw_ext_info, draw_ext_info_format(), EVENT_APPLY, events_execute_object_event(), object::facing, find_god(), god_intervention(), living::grace, object::level, LOOSE_MANA, living::luck, MAX, living::maxgrace, move_player(), MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, object::name, archetype::name, NDI_NAVY, NDI_UNIQUE, object::other_arch, PREFER_LOW, random_roll(), SCRIPT_FIX_ALL, skill, object::stats, try_leave_cult(), and living::Wis.
Referenced by pray().
Removes special prayers given by a god.
After this function, op shouldn't know any prayer granted by god. Prayers will be given when player prays on god's altar, so not handled now.
op | player to remove prayers from. |
god | god we're removing the prayers. |
Definition at line 350 of file gods.cpp.
References archetype::clone, object::contr, draw_ext_info_format(), esrv_remove_spell(), FLAG_STARTEQUIP, FOR_INV_FINISH, FOR_INV_PREPARE, treasure::item, treasurelist::items, llevError, LOG(), MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, object::name, NDI_NAVY, NDI_UNIQUE, treasure::next, object_free_drop_inventory(), object_remove(), player_unready_range_ob(), QUERY_FLAG, object::randomitems, SPELL, and object::type.
Referenced by become_follower().
|
static |
Compares 2 strings.
s1 | |
s2 | strings to compare. |
Definition at line 111 of file gods.cpp.
Referenced by follower_has_similar_item().
|
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. Must be positive. |
Definition at line 621 of file gods.cpp.
References AP_IGNORE_CURSE, AP_UNAPPLY, apply_special(), FLAG_APPLIED, FOR_INV_FINISH, FOR_INV_PREPARE, QUERY_FLAG, and is_valid_types_gen::type.
Referenced by become_follower().
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 1223 of file gods.cpp.
References add_string(), AT_GODPOWER, AT_HOLYWORD, object::attacktype, buf, determine_god(), draw_ext_info, find_god(), FREE_AND_COPY, free_string(), llevError, LOG(), MAX_BUF, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, object::name, object::name_pl, NDI_UNIQUE, object_free_drop_inventory(), object_get_owner(), object::race, object::slaying, SPELL, SPELL_EFFECT, object::title, and object::type.
Referenced by cast_cone(), cast_smite_spell(), explode_bullet(), fire_arch_from_position(), and fire_swarm().
Try to leave a cult.
Deducts experience from 'skill' proportional to 'angry'. Returns true if successful (only when 'angry' is 1) or false otherwise.
Definition at line 232 of file gods.cpp.
References change_exp(), PREFER_LOW, random_roll(), random_roll64(), SK_SUBTRACT_SKILL_EXP, and skill.
Referenced by pray_at_altar().
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 644 of file gods.cpp.
References CLEAR_FLAG, QUERY_FLAG, and SET_FLAG.
Referenced by become_follower(), and worship_forbids_use().
|
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 591 of file gods.cpp.
References object::arch, archetype::clone, draw_ext_info_format(), exp_obj, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, NDI_UNIQUE, QUERY_FLAG, and update_priest_flag().
Referenced by become_follower().