Atrinik Server 2.5
Defines | Functions
server/gods.c File Reference
#include <global.h>

Go to the source code of this file.

Functions

static int lookup_god_by_name (const char *name)
static int worship_forbids_use (object *op, object *exp_obj, uint32 flag, char *string)
static void stop_using_item (object *op, int type, int number)
static void update_priest_flag (object *god, object *exp_ob, uint32 flag)
static int god_gives_present (object *op, object *god, treasure *tr)
static int god_examines_priest (object *op, object *god)
static int god_examines_item (object *god, object *item)
static void lose_priest_exp (object *pl, int loss)
static void god_intervention (object *op, object *god)
objectfind_god (const char *name)
void pray_at_altar (object *pl, object *altar)
static int get_spell_number (object *op)
static void check_special_prayers (object *op, object *god)
void become_follower (object *op, object *new_god)
const char * determine_god (object *op)
archetypedetermine_holy_arch (object *god, const char *type)
static int god_removes_curse (object *op, int remove_damnation)
static int follower_level_to_enchantments (int level, int difficulty)
static int god_enchants_weapon (object *op, object *god, object *tr)
static int same_string (const char *s1, const char *s2)
static int follower_has_similar_item (object *op, object *item)

Detailed Description

Handles god related code.

Definition in file gods.c.


Function Documentation

void become_follower ( object op,
object new_god 
)

This function is called whenever a player has switched to a new god. It basically handles all the stat changes that happen to the player, including the removal of god-given items (from the former cult).

Parameters:
opPlayer switching cults.
new_godNew god to worship.

Definition at line 301 of file gods.c.

static void check_special_prayers ( object op,
object god 
) [static]

Ensure that 'op' doesn't know any special prayers that are not granted by 'god'.

Parameters:
opThe object.
godThe god.

Definition at line 242 of file gods.c.

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 give them a random one.

Parameters:
opObject to get name of.
Returns:
God name, "none" if nothing suitable.

Definition at line 488 of file gods.c.

archetype* determine_holy_arch ( 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.

Parameters:
godGod for which we want something.
typeWhat the summon type is.
Returns:
Archetype matching the type, NULL if none found.

Definition at line 559 of file gods.c.

object* find_god ( const char *  name)

Returns pointer to specified god's object through pntr_to_god_obj().

Parameters:
nameGod's name.
Returns:
Pointer to god's object, NULL if doesn't match any god.

Definition at line 80 of file gods.c.

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).

Parameters:
opObject to check.
itemObject to check for.
Returns:
1 if found, 0 otherwise.

Definition at line 763 of file gods.c.

static int follower_level_to_enchantments ( int  level,
int  difficulty 
) [static]

Converts a level and difficulty to a magic/enchantment value for eg weapons.

Parameters:
levelLevel.
difficultyDifficulty. Must be 1 or more.
Returns:
Number of enchantments for level and difficulty.

Definition at line 633 of file gods.c.

static int get_spell_number ( object op) [static]

Get spell number from an object's slaying or liv::sp field.

Parameters:
opThe object to get the spell number from.
Returns:
The spell number.

Definition at line 223 of file gods.c.

static int god_enchants_weapon ( object op,
object god,
object tr 
) [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.

Parameters:
opPlayer.
godGod enchanting weapon.
trTreasure list item for enchanting weapon, contains the enchantment level.
Returns:
0 if weapon wasn't changed, 1 if changed.

Definition at line 665 of file gods.c.

static int god_examines_item ( 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...

Parameters:
godGod checking.
itemItem to check.
Return values:
-1Item is bad.
0Item is neutral.
1Item is good.

Definition at line 1135 of file gods.c.

static int god_examines_priest ( object op,
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.

Parameters:
opPlayer the god examines.
godGod examining the player.
Returns:
Negative value if god is not pleased, otherwise positive value, the higher the better.

Definition at line 1091 of file gods.c.

static int god_gives_present ( object op,
object god,
treasure tr 
) [static]

God gives an item to the player. Inform player of the present.

Parameters:
opWho is getting the treasure.
godGod giving the present.
trObject to give. Should be a single object on list.
Returns:
0 if nothing was given, 1 otherwise.

Definition at line 789 of file gods.c.

static void god_intervention ( object op,
object god 
) [static]

Every once in a while the god will intervene to help the worshiper. Later, this function can be used to supply quests, etc for the priest.

Parameters:
opPlayer praying.
godGod player is praying to.

Definition at line 815 of file gods.c.

static int god_removes_curse ( object op,
int  remove_damnation 
) [static]

God helps player by removing curse and/or damnation.

Parameters:
opPlayer to help.
remove_damnationIf set, also removes damned items.
Returns:
1 if at least one item was uncursed, 0 otherwise.

Definition at line 594 of file gods.c.

static int lookup_god_by_name ( const char *  name) [static]

Returns the ID of specified god.

Parameters:
nameGod to search for.
Returns:
Identifier of god, -1 if not found.

Definition at line 50 of file gods.c.

static void lose_priest_exp ( object pl,
int  loss 
) [static]

Lose some priest experience.

Parameters:
plPlayer.
lossHow much to lose.
Todo:
Make work again?

Definition at line 1183 of file gods.c.

void pray_at_altar ( object pl,
object altar 
)

Player prays at altar.

Checks for god changing, divine intervention, and so on.

Parameters:
plPlayer praying.
altarAltar player's praying on. Doesn't need to be consecrated.

Definition at line 112 of file gods.c.

static int same_string ( const char *  s1,
const char *  s2 
) [static]

Compares two strings.

Parameters:
s1The first string to compare.
s2The second string to compare.
Returns:
1 if s1 and s2 are the same - either both NULL, or strcmp() == 0.

Definition at line 731 of file gods.c.

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.

Parameters:
opPlayer we're considering.
typeItem type to remove.
numberMaximum number of items to unapply.

Definition at line 450 of file gods.c.

static void update_priest_flag ( object god,
object exp_ob,
uint32  flag 
) [static]

If the god does/doesn't have this flag, we give/remove it from the experience object if it doesn't/does already exist.

Parameters:
godGod object.
exp_obPlayer's praying skill object.
flagFlag to consider.

Definition at line 470 of file gods.c.

static int worship_forbids_use ( object op,
object exp_obj,
uint32  flag,
char *  string 
) [static]

Forbids or lets player use something item type.

Parameters:
opPlayer.
exp_objPraying skill.
flagFLAG_xxx to check against.
stringWhat flag corresponds to ("weapons", "shield", ...).
Returns:
1 if player was changed, 0 if no change.

Definition at line 419 of file gods.c.