Crossfire Server, Trunk  R20513
Functions
food.c File Reference

The implementation of the Food class of objects. More...

#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.c:

Go to the source code of this file.

Functions

static int dragon_eat_flesh (object *op, object *meal)
 A dragon is eating some flesh. More...
 
static void eat_special_food (object *who, object *food)
 Handles player eating food that temporarily changes status (resistances, stats). More...
 
static method_ret food_type_apply (ob_methods *context, object *food, object *applier, int aflags)
 Handles applying food. More...
 
void init_type_food (void)
 Initializer for the food object type. More...
 

Detailed Description

The implementation of the Food class of objects.

Definition in file food.c.

Function Documentation

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 235 of file food.c.

References atnr_is_dragon_enabled(), change_resist_msg, draw_ext_info(), draw_ext_info_format(), liv::exp, fix_object(), FLESH, liv::food, FORCE, liv::hp, is_dragon_pl(), obj::last_eat, obj::level, MAX_BUF, Settings::max_level, liv::maxhp, MIN, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_PROTECTION_GAIN, MSG_TYPE_ATTRIBUTE_RACE, obj::name, NDI_RED, NDI_UNIQUE, NROFATTACKS, object_find_by_type_and_arch_name(), RANDOM, obj::resist, settings, snprintf, obj::stats, and obj::type.

Referenced by food_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

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 152 of file food.c.

References AT_POISON, change_abil(), obj::contr, create_archetype(), draw_ext_info(), obj::duration, fix_object(), FLAG_APPLIED, FLAG_CURSED, FLAG_IS_USED_UP, liv::food, FORCE_NAME, get_attr_value(), hit_player(), liv::hp, is_wraith_pl(), pl::killer, MSG_TYPE_APPLY, MSG_TYPE_APPLY_CURSED, MSG_TYPE_APPLY_SUCCESS, obj::name, NDI_UNIQUE, NROFATTACKS, NUM_STATS, object_free_drop_inventory(), object_insert_in_ob(), object_update_speed(), QUERY_FLAG, obj::resist, safe_strncpy, set_attr_value(), SET_FLAG, liv::sp, obj::speed, and obj::stats.

Referenced by food_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Handles applying food.

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

Parameters
contextThe method context
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 52 of file food.c.

References apply_handle_yield(), dragon_eat_flesh(), draw_ext_info(), draw_ext_info_format(), DRINK, eat_special_food(), FLAG_CAN_USE_SKILL, FLAG_CURSED, FLAG_NO_PICK, FLESH, liv::food, FOOD, give_skill_by_name(), liv::hp, is_dragon_pl(), is_old_wraith_pl(), is_wraith_pl(), link_player_skills(), llevError, LOG(), MAX_BUF, liv::maxhp, METHOD_OK, MSG_TYPE_APPLY, MSG_TYPE_APPLY_FAILURE, MSG_TYPE_APPLY_SUCCESS, obj::name, NDI_UNIQUE, object_decrease_nrof_by_one, PLAYER, QUERY_FLAG, SET_FLAG, snprintf, obj::stats, obj::title, and obj::type.

Referenced by init_type_food().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_type_food ( void  )

Initializer for the food object type.

Definition at line 37 of file food.c.

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: