Crossfire Server, Trunk
food.cpp File Reference
#include "global.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "ob_methods.h"
#include "ob_types.h"
#include "sounds.h"
#include "sproto.h"
+ Include dependency graph for food.cpp:

Go to the source code of this file.

Functions

static void check_heal_and_mana (object *who, object *food)
 
static int dragon_eat_flesh (object *op, object *meal)
 
static void eat_common (object *applier, object *food)
 
static void eat_special_food (object *who, object *food)
 
static method_ret food_type_apply (object *food, object *applier, int aflags)
 
void init_type_food (void)
 

Detailed Description

The implementation of the Food class of objects.

Definition in file food.cpp.

Function Documentation

◆ check_heal_and_mana()

static void check_heal_and_mana ( object who,
object food 
)
static

Definition at line 43 of file food.cpp.

References AT_POISON, draw_ext_info(), FLAG_CURSED, hit_player(), living::hp, is_wraith_pl(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_CURSED, MSG_TYPE_APPLY_SUCCESS, object::name, NDI_UNIQUE, QUERY_FLAG, safe_strncpy, living::sp, object::stats, and autojail::who.

Referenced by food_type_apply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dragon_eat_flesh()

static int dragon_eat_flesh ( object op,
object meal 
)
static

A dragon is eating some flesh. If the flesh contains resistances, there is a chance for the dragon's skin to get improved.

Parameters
opobject (dragon player) eating the flesh.
mealflesh item, getting chewed in dragon's mouth.
Returns
1 if meal was eaten, 0 else.
Note
meal's nrof isn't decreased, caller is responsible for that.

Definition at line 357 of file food.cpp.

References atnr_is_dragon_enabled(), buf, change_resist_msg, draw_ext_info(), draw_ext_info_format(), living::exp, fix_object(), FLESH, FORCE, is_dragon_pl(), object::last_eat, object::level, MAX_BUF, Settings::max_level, MIN, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_PROTECTION_GAIN, MSG_TYPE_ATTRIBUTE_RACE, object::name, NDI_RED, NDI_UNIQUE, NROFATTACKS, object_find_by_type_and_arch_name(), give::op, RANDOM, object::resist, settings, object::stats, and object::type.

Referenced by food_type_apply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eat_common()

static void eat_common ( object applier,
object food 
)
static

Definition at line 78 of file food.cpp.

References buf, draw_ext_info(), DRINK, living::food, living::hp, MAX_BUF, MAX_FOOD, living::maxhp, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_START, object::name, NDI_UNIQUE, slow_living_by(), object::stats, and object::type.

Referenced by food_type_apply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eat_special_food()

static void eat_special_food ( object who,
object food 
)
static

Handles player eating food that temporarily changes status (resistances, stats). This used to call cast_change_attr(), but that doesn't work with the new spell code. Since we know what the food changes, just grab a force and use that instead.

Parameters
wholiving eating food.
foodeaten food.

Definition at line 203 of file food.cpp.

References living::ac, arch_to_object(), object::attacktype, change_abil(), create_archetype(), fix_object(), FLAG_APPLIED, FLAG_BLIND, FLAG_IS_USED_UP, FLAG_LIFESAVE, FLAG_MAKE_INVIS, FLAG_REFL_MISSILE, FLAG_REFL_SPELL, FLAG_SEE_IN_DARK, FLAG_STEALTH, FLAG_UNDEAD, FLAG_XRAYS, living::food, dragon_attune::force, FORCE_NAME, get_attr_value(), INS_ON_TOP, living::luck, living::maxgrace, living::maxhp, living::maxsp, MOVE_PER_SECOND, object::move_type, NROFATTACKS, NUM_STATS, object_free_drop_inventory(), object_insert_in_map_at(), object_insert_in_ob(), object_update_speed(), object::other_arch, object::path_attuned, object::path_denied, object::path_repelled, QUERY_FLAG, object::resist, set_attr_value(), SET_FLAG, object::stats, living::wc, and autojail::who.

Referenced by food_type_apply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ food_type_apply()

static method_ret food_type_apply ( object food,
object applier,
int  aflags 
)
static

Handles applying food. If player is applying, takes care of messages and dragon special food.

Parameters
foodThe food to apply
applierThe object attempting to apply the food
aflagsSpecial flags (always apply/unapply)
Returns
METHOD_OK unless failure for some reason.

Definition at line 121 of file food.cpp.

References apply_handle_yield(), buf, check_heal_and_mana(), dragon_eat_flesh(), draw_ext_info(), draw_ext_info_format(), DRINK, eat_common(), eat_special_food(), FLAG_CAN_USE_SKILL, FLAG_CURSED, FLAG_NO_PICK, FLESH, give_skill_by_name(), living::hp, is_dragon_pl(), is_old_wraith_pl(), is_wraith_pl(), link_player_skills(), llevError, LOG(), MAX_BUF, living::maxhp, METHOD_OK, MSG_TYPE_APPLY, MSG_TYPE_APPLY_FAILURE, MSG_TYPE_APPLY_SUCCESS, object::name, NDI_UNIQUE, object_decrease_nrof_by_one, play_sound_map(), PLAYER, QUERY_FLAG, SET_FLAG, SOUND_TYPE_ITEM, object::stats, object::title, object::type, and nlohmann::detail::void().

Referenced by init_type_food().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_type_food()

void init_type_food ( void  )

Initializer for the food object type.

Definition at line 37 of file food.cpp.

References DRINK, FLESH, FOOD, food_type_apply(), and register_apply().

Referenced by register_all_ob_types().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: