Crossfire Server, Trunk  1.75.0
food.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
19 #include "global.h"
20 
21 #include <math.h>
22 #include <stdlib.h>
23 #include <string.h>
24 
25 #include "ob_methods.h"
26 #include "ob_types.h"
27 #include "sounds.h"
28 #include "sproto.h"
29 
30 static method_ret food_type_apply(object *food, object *applier, int aflags);
31 static void eat_special_food(object *who, object *food);
32 static int dragon_eat_flesh(object *op, object *meal);
33 
37 void init_type_food(void) {
41 }
42 
43 static void check_heal_and_mana(object *who, object *food) {
44  /* check for hp, sp change */
45  if (food->stats.hp != 0 && !is_wraith_pl(who)) {
46  if (QUERY_FLAG(food, FLAG_CURSED)) {
47  safe_strncpy(who->contr->killer, food->name,
48  sizeof(who->contr->killer));
49  hit_player(who, food->stats.hp, food, AT_POISON, 1);
51  "Eck!...that was poisonous!");
52  } else {
53  if (food->stats.hp > 0)
55  "You begin to feel better.");
56  else
58  "Eck!...that was poisonous!");
59  who->stats.hp += food->stats.hp;
60  }
61  }
62  if (food->stats.sp != 0) {
63  if (QUERY_FLAG(food, FLAG_CURSED)) {
65  "You are drained of mana!");
66  who->stats.sp -= food->stats.sp;
67  if (who->stats.sp < 0)
68  who->stats.sp = 0;
69  } else {
70  if (food->stats.sp > 0)
72  "You feel a rush of magical energy!");
73  else
75  "You are drained of mana!");
76  who->stats.sp += food->stats.sp;
77  /* place limit on max sp from food? */
78  }
79  }
80 }
81 
82 static void eat_common(object* applier, object* food) {
83  char buf[MAX_BUF];
84  int capacity_remaining = MAX_FOOD - applier->stats.food;
85  applier->stats.food += food->stats.food;
86  if (capacity_remaining < food->stats.food)
87  applier->stats.hp += capacity_remaining / 50;
88  else
89  applier->stats.hp += food->stats.food / 50;
90  if (applier->stats.hp > applier->stats.maxhp)
91  applier->stats.hp = applier->stats.maxhp;
92  if (applier->stats.food > MAX_FOOD)
93  applier->stats.food = MAX_FOOD;
94  const int wasted_food = food->stats.food - capacity_remaining;
95  if (wasted_food > 0) {
96  const int thresh = MAX_FOOD/4;
97  int speed_penalty;
98  if (wasted_food > thresh) {
99  speed_penalty = 10;
100  } else {
101  speed_penalty = 5;
102  }
103 
104  if (slow_living_by(applier, speed_penalty)) {
105  snprintf(buf, sizeof(buf),
106  "%s the %s makes you %s full. You feel yourself moving %s "
107  "slower.",
108  food->type == DRINK ? "Drinking" : "Eating", food->name,
109  wasted_food > thresh ? "very" : "rather",
110  wasted_food > thresh ? "much" : "somewhat");
113  }
114  }
115 }
116 
125 static method_ret food_type_apply(object *food, object *applier, int aflags) {
126  (void)aflags;
127  if (QUERY_FLAG(food, FLAG_NO_PICK)) {
129  MSG_TYPE_APPLY_FAILURE, "You can't %s that!",
130  food->type == DRINK ? "drink" : "eat");
131  return METHOD_OK;
132  }
133 
134  if (applier->type != PLAYER) {
135  applier->stats.hp = applier->stats.maxhp;
136  } else {
137  char buf[MAX_BUF];
138  if (food->type == FLESH && is_dragon_pl(applier)) {
139  /* check if this is a dragon (player), eating some flesh */
140  if (!QUERY_FLAG(food, FLAG_CURSED)) {
141  dragon_eat_flesh(applier, food);
142  eat_common(applier, food);
143  }
144  check_heal_and_mana(applier, food);
145  } else if (is_old_wraith_pl(applier)) {
146  /* Check for old wraith player, give them the feeding skill */
147  object *skill = give_skill_by_name(applier, "wraith feed");
148  if (skill) {
150  link_player_skills(applier);
151  applier->contr->is_wraith = true;
152 
153  snprintf(buf, sizeof(buf), "You have been dead for too long to taste %s, ", food->name);
155  buf);
157  "and seem to have obtained a taste for living flesh.");
158  } else
159  LOG(llevError, "wraith feed skill not found\n");
160  } else if (is_wraith_pl(applier)) {
161  /* Wraith player gets no food from eating. */
162  snprintf(buf, sizeof(buf), "You can no longer taste %s, and do not feel less hungry after %s it.", food->name, food->type == DRINK ? "drinking" : "eating");
164  buf);
165  } else {
166  /* usual case - not a wraith or a dragon eating non-flesh */
167  if (!QUERY_FLAG(food, FLAG_CURSED)) {
168  if (!is_dragon_pl(applier)) {
169  /* eating message for normal players*/
170  if (food->type == DRINK)
171  snprintf(buf, sizeof(buf), "Ahhh...that %s tasted good.", food->name);
172  else
173  snprintf(buf, sizeof(buf), "The %s tasted %s", food->name, food->type == FLESH ? "terrible!" : "good.");
174  } else {
175  /* eating message for dragon players*/
176  snprintf(buf, sizeof(buf), "The %s tasted terrible!", food->name);
177  }
179  eat_common(applier, food);
180  }
181  check_heal_and_mana(applier, food);
182 
183  /* special food hack -b.t. */
184  if (food->title)
185  eat_special_food(applier, food);
186  }
187  }
188  if (food->type == DRINK) {
189  play_sound_map(SOUND_TYPE_ITEM, applier, 0, "drink");
190  }
191  apply_handle_yield(food);
193  return METHOD_OK;
194 }
195 
208 static void eat_special_food(object *who, object *food) {
209  object *force;
210  int i, did_one = 0;
211  int8_t k;
212 
213  force = create_archetype(FORCE_NAME);
214 
215  for (i = 0; i < NUM_STATS; i++) {
216  k = get_attr_value(&food->stats, i);
217  if (k) {
218  set_attr_value(&force->stats, i, k);
219  did_one = 1;
220  }
221  }
222 
223  /* check if we can protect the eater */
224  for (i = 0; i < NROFATTACKS; i++) {
225  if (food->resist[i] > 0) {
226  force->resist[i] = food->resist[i]/2;
227  did_one = 1;
228  }
229  }
230 
231  /* Check to affect hp/sp/grace regen. Since sp and hp do direct heals, we use maxhp/maxsp/maxgrace */
232  if (food->stats.maxgrace != 0) {
233  force->stats.grace = food->stats.maxgrace;
234  did_one = 1;
235  }
236  if (food->stats.maxsp != 0) {
237  force->stats.sp = food->stats.maxsp;
238  did_one = 1;
239  }
240  if (food->stats.maxhp != 0) {
241  force->stats.hp = food->stats.maxhp;
242  did_one = 1;
243  }
244  /* Allow for food to attune/repel/deny a spell path for a duration */
245  if (food->path_attuned != 0) {
246  force->path_attuned = food->path_attuned;
247  did_one = 1;
248  }
249  if (food->path_repelled != 0) {
250  force->path_repelled = food->path_repelled;
251  did_one = 1;
252  }
253  if (food->path_denied != 0) {
254  force->path_denied = food->path_denied;
255  did_one = 1;
256  }
257 
258  /* Allow for some flags on the food item to transfer to the force, too. */
259  /* Set of transferrable flags from the food to the force, as these print a message in change_abil:
260  FLAG_BLIND
261  FLAG_SEE_IN_DARK
262  FLAG_STEALTH
263  FLAG_MAKE_INVIS
264  FLAG_XRAYS
265  FLAG_UNDEAD
266  FLAG_LIFESAVE
267  FLAG_REFL_MISSILE
268  FLAG_REFL_SPELL
269  */
270  if (QUERY_FLAG(food, FLAG_BLIND)) {
271  SET_FLAG(force, FLAG_BLIND);
272  did_one = 1;
273  }
274  if (QUERY_FLAG(food, FLAG_SEE_IN_DARK)) {
275  SET_FLAG(force, FLAG_SEE_IN_DARK);
276  did_one = 1;
277  }
278  if (QUERY_FLAG(food, FLAG_STEALTH)) {
279  SET_FLAG(force, FLAG_STEALTH);
280  did_one = 1;
281  }
282  if (QUERY_FLAG(food, FLAG_MAKE_INVIS)) {
283  SET_FLAG(force, FLAG_MAKE_INVIS);
284  did_one = 1;
285  }
286  if (QUERY_FLAG(food, FLAG_XRAYS)) {
287  SET_FLAG(force, FLAG_XRAYS);
288  did_one = 1;
289  }
290  if (QUERY_FLAG(food, FLAG_UNDEAD)) {
291  SET_FLAG(force, FLAG_UNDEAD);
292  did_one = 1;
293  }
294  if (QUERY_FLAG(food, FLAG_LIFESAVE)) {
295  SET_FLAG(force, FLAG_LIFESAVE);
296  did_one = 1;
297  }
298  if (QUERY_FLAG(food, FLAG_REFL_MISSILE)) {
299  SET_FLAG(force, FLAG_REFL_MISSILE);
300  did_one = 1;
301  }
302  if (QUERY_FLAG(food, FLAG_REFL_SPELL)) {
303  SET_FLAG(force, FLAG_REFL_SPELL);
304  did_one = 1;
305  }
306  /* Allow for food to temporarily grant move types */
307  if (food->move_type != 0) {
308  force->move_type = food->move_type;
309  did_one = 1;
310  }
311  /* And to grant atacktypes */
312  if (food->attacktype != 0) {
313  force->attacktype = food->attacktype;
314  did_one = 1;
315  }
316  /* And luck, wc, and ac */
317  if (food->stats.wc != 0) {
318  force->stats.wc = food->stats.wc;
319  did_one = 1;
320  }
321  if (food->stats.ac != 0) {
322  force->stats.ac = food->stats.ac;
323  did_one = 1;
324  }
325  if (food->stats.luck != 0) {
326  force->stats.luck = food->stats.luck;
327  did_one = 1;
328  }
329 
330  if (did_one) {
331  force->speed = MOVE_PER_SECOND;
332  object_update_speed(force);
333  /* bigger morsel of food = longer effect time */
334  force->duration = food->stats.food/4;
335  SET_FLAG(force, FLAG_IS_USED_UP);
336  object_insert_in_ob(force, who);
337  SET_FLAG(force, FLAG_APPLIED);
338  change_abil(who, force);
339  if (food->other_arch != NULL && who->map != NULL) {
340  object_insert_in_map_at(arch_to_object(food->other_arch), who->map, NULL, INS_ON_TOP, who->x, who->y);
341  }
342  } else {
344  }
345 
346  fix_object(who);
347 }
348 
362 static int dragon_eat_flesh(object *op, object *meal) {
363  object *skin = NULL; /* pointer to dragon skin force*/
364  object *abil = NULL; /* pointer to dragon ability force*/
365 
366  char buf[MAX_BUF]; /* tmp. string buffer */
367  double chance; /* improvement-chance of one resist type */
368  double totalchance = 1; /* total chance of gaining one resistance */
369  double bonus = 0; /* level bonus (improvement is easier at lowlevel) */
370  double mbonus = 0; /* monster bonus */
371  int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */
372  int winners = 0; /* number of winners */
373  int i; /* index */
374 
375  /* let's make sure and doublecheck the parameters */
376  if (meal->type != FLESH || !is_dragon_pl(op))
377  return 0;
378 
379  /* now grab the 'dragon_skin'- and 'dragon_ability'-forces
380  * from the player's inventory
381  */
382  skin = object_find_by_type_and_arch_name(op, FORCE, "dragon_skin_force");
383  abil = object_find_by_type_and_arch_name(op, FORCE, "dragon_ability_force");
384 
385  /* if either skin or ability are missing, this is an old player
386  * which is not to be considered a dragon -> bail out
387  */
388  if (skin == NULL || abil == NULL)
389  return 0;
390 
391  /*LOG(llevDebug, "-> player: %d, flesh: %d\n", op->level, meal->level);*/
392 
393  /* on to the interesting part: chances for adding resistance */
394  for (i = 0; i < NROFATTACKS; i++) {
395  if (meal->resist[i] > 0 && atnr_is_dragon_enabled(i)) {
396  /* got positive resistance, now calculate improvement chance (0-100) */
397 
398  /* this bonus makes resistance increase easier at lower levels */
399  bonus = (settings.max_level-op->level)*30./((double)settings.max_level);
400  if (i == abil->stats.exp)
401  bonus += 5; /* additional bonus for resistance of ability-focus */
402 
403  /* monster bonus increases with level, because high-level
404  * flesh is too rare
405  */
406  mbonus = op->level*20./((double)settings.max_level);
407 
408  chance = (((double)MIN(op->level+bonus, meal->level+bonus+mbonus))*100./((double)settings.max_level))-skin->resist[i];
409 
410  if (chance >= 0.)
411  chance += 1.;
412  else
413  chance = (chance < -12) ? 0. : 1./pow(2., -chance);
414 
415  /* chance is proportional to amount of resistance (max. 50) */
416  chance *= ((double)(MIN(meal->resist[i], 50)))/50.;
417 
418  /* doubled chance for resistance of ability-focus */
419  if (i == abil->stats.exp)
420  chance = MIN(100., chance*2.);
421 
422  /* now make the throw and save all winners (Don't insert luck bonus here!) */
423  if (RANDOM()%10000 < (unsigned int)(chance*100)) {
424  atnr_winner[winners] = i;
425  winners++;
426  }
427 
428  if (chance >= 0.01)
429  totalchance *= 1-chance/100;
430 
431  /*LOG(llevDebug, " %s: bonus %.1f, chance %.1f\n", attacks[i], bonus, chance);*/
432  }
433  }
434 
435  /* inverse totalchance as until now we have the failure-chance */
436  totalchance = 100-totalchance*100;
437  /* print message according to totalchance */
438  if (totalchance > 50.)
439  snprintf(buf, sizeof(buf), "Hmm! The %s tasted delicious!", meal->name);
440  else if (totalchance > 10.)
441  snprintf(buf, sizeof(buf), "The %s tasted very good.", meal->name);
442  else if (totalchance > 1.)
443  snprintf(buf, sizeof(buf), "The %s tasted good.", meal->name);
444  else if (totalchance > 0.1)
445  snprintf(buf, sizeof(buf), "The %s tasted bland.", meal->name);
446  else if (totalchance >= 0.01)
447  snprintf(buf, sizeof(buf), "The %s had a boring taste.", meal->name);
448  else if (meal->last_eat > 0 && atnr_is_dragon_enabled(meal->last_eat))
449  snprintf(buf, sizeof(buf), "The %s tasted strange.", meal->name);
450  else
451  snprintf(buf, sizeof(buf), "The %s had no taste.", meal->name);
453  buf);
454 
455  /* now choose a winner if we have any */
456  i = -1;
457  if (winners > 0)
458  i = atnr_winner[RANDOM()%winners];
459 
460  if (i >= 0 && i < NROFATTACKS && skin->resist[i] < 95) {
461  /* resistance increased! */
462  skin->resist[i]++;
463  fix_object(op);
464 
466  "Your skin is now more resistant to %s!",
467  change_resist_msg[i]);
468  }
469 
470  /* if this flesh contains a new ability focus, we mark it
471  * into the ability_force and it will take effect on next level
472  */
473  if (meal->last_eat > 0
475  && meal->last_eat != abil->last_eat) {
476  abil->last_eat = meal->last_eat; /* write:last_eat <new attnr focus> */
477 
478  if (meal->last_eat != abil->stats.exp) {
480  "Your metabolism prepares to focus on %s!",
481  change_resist_msg[meal->last_eat]);
483  "The change will happen at level %d",
484  abil->level+1);
485  } else {
487  "Your metabolism will continue to focus on %s.",
488  change_resist_msg[meal->last_eat]);
489  abil->last_eat = 0;
490  }
491  }
492  return 1;
493 }
living::exp
int64_t exp
Experience.
Definition: living.h:47
PLAYER
@ PLAYER
Definition: object.h:112
global.h
settings
struct Settings settings
Global settings.
Definition: init.cpp:139
SOUND_TYPE_ITEM
#define SOUND_TYPE_ITEM
Definition: newclient.h:339
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
living::maxhp
int16_t maxhp
Max hit points.
Definition: living.h:41
Settings::max_level
int16_t max_level
This is read out of exp_table.
Definition: global.h:303
AT_POISON
#define AT_POISON
Definition: attack.h:86
init_type_food
void init_type_food(void)
Initializer for the food object type.
Definition: food.cpp:37
llevError
@ llevError
Error, serious thing.
Definition: logger.h:11
object::path_attuned
uint32_t path_attuned
Paths the object is attuned to.
Definition: object.h:353
LOG
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:58
FLAG_UNDEAD
#define FLAG_UNDEAD
Monster is undead.
Definition: define.h:270
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
FLESH
@ FLESH
animal 'body parts' -b.t.
Definition: object.h:192
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
player::is_wraith
bool is_wraith
Whether this player is a wraith or not, initialized at load time.
Definition: player.h:227
FLAG_REFL_MISSILE
#define FLAG_REFL_MISSILE
Arrows will reflect from object.
Definition: define.h:273
FLAG_SEE_IN_DARK
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
Definition: define.h:337
dragon_eat_flesh
static int dragon_eat_flesh(object *op, object *meal)
A dragon is eating some flesh.
Definition: food.cpp:362
register_apply
void register_apply(int ob_type, apply_func method)
Registers the apply method for the given type.
Definition: ob_types.cpp:62
object::speed
float speed
Frequency of object 'moves' relative to server tick rate.
Definition: object.h:337
METHOD_OK
#define METHOD_OK
Definition: ob_methods.h:15
object::x
int16_t x
Definition: object.h:335
object::map
struct mapstruct * map
Pointer to the map in which this object is present.
Definition: object.h:305
give_skill_by_name
object * give_skill_by_name(object *op, const char *skill_name)
Given the skill name skill_name, we find the skill archetype/object, set appropriate values,...
Definition: living.cpp:1788
MSG_TYPE_APPLY_CURSED
#define MSG_TYPE_APPLY_CURSED
Applied a cursed object (BAD)
Definition: newclient.h:609
MSG_TYPE_ATTRIBUTE
#define MSG_TYPE_ATTRIBUTE
Changes to attributes (stats, resistances, etc)
Definition: newclient.h:409
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
MIN
#define MIN(x, y)
Definition: compat.h:21
play_sound_map
void play_sound_map(int8_t sound_type, object *emitter, int dir, const char *action)
Plays a sound on a map.
Definition: sounds.cpp:113
fix_object
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
Definition: living.cpp:1132
NDI_RED
#define NDI_RED
Definition: newclient.h:249
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:17
object::title
sstring title
Of foo, etc.
Definition: object.h:325
FLAG_APPLIED
#define FLAG_APPLIED
Object is ready for use by living.
Definition: define.h:235
object::level
int16_t level
Level of creature or object.
Definition: object.h:361
FLAG_STEALTH
#define FLAG_STEALTH
Will wake monsters with less range.
Definition: define.h:312
buf
StringBuffer * buf
Definition: readable.cpp:1565
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
Definition: object.cpp:2842
eat_special_food
static void eat_special_food(object *who, object *food)
Handles player eating food that temporarily changes status (resistances, stats).
Definition: food.cpp:208
object::resist
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:351
FLAG_NO_PICK
#define FLAG_NO_PICK
Object can't be picked up.
Definition: define.h:239
draw_ext_info
vs only yadda is in because all tags get reset on the next draw_ext_info In the second since it is all in one draw_ext_info
Definition: media-tags.txt:61
object::path_denied
uint32_t path_denied
Paths the object is denied access to.
Definition: object.h:355
object::y
int16_t y
Position in the map for this object.
Definition: object.h:335
object::path_repelled
uint32_t path_repelled
Paths the object is repelled from.
Definition: object.h:354
food_type_apply
static method_ret food_type_apply(object *food, object *applier, int aflags)
Handles applying food.
Definition: food.cpp:125
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects,...
Definition: object.cpp:1545
object::contr
struct player * contr
Pointer to the player which control this object.
Definition: object.h:284
slow_living_by
int slow_living_by(object *op, const int speed_penalty)
Definition: attack.cpp:2231
object_decrease_nrof_by_one
#define object_decrease_nrof_by_one(xyz)
Definition: compat.h:32
player::killer
char killer[BIG_NAME]
Who killed this player.
Definition: player.h:190
MSG_TYPE_ATTRIBUTE_RACE
#define MSG_TYPE_ATTRIBUTE_RACE
Race-related changes.
Definition: newclient.h:568
MSG_TYPE_ATTRIBUTE_BAD_EFFECT_START
#define MSG_TYPE_ATTRIBUTE_BAD_EFFECT_START
Start of a bad effect to the player.
Definition: newclient.h:569
MSG_TYPE_APPLY_SUCCESS
#define MSG_TYPE_APPLY_SUCCESS
Was able to apply object.
Definition: newclient.h:607
MSG_TYPE_ATTRIBUTE_PROTECTION_GAIN
#define MSG_TYPE_ATTRIBUTE_PROTECTION_GAIN
Protections in this.
Definition: newclient.h:559
object::move_type
MoveType move_type
Type of movement this object uses.
Definition: object.h:436
set_attr_value
void set_attr_value(living *stats, int attr, int8_t value)
Sets Str/Dex/con/Wis/Cha/Int/Pow in stats to value, depending on what attr is (STR to POW).
Definition: living.cpp:218
FLAG_BLIND
#define FLAG_BLIND
If set, object cannot see (visually)
Definition: define.h:336
FLAG_MAKE_INVIS
#define FLAG_MAKE_INVIS
(Item) gives invisibility when applied
Definition: define.h:328
change_resist_msg
const char *const change_resist_msg[NROFATTACKS]
These are the descriptions of the resistances displayed when a player puts on/takes off an item.
Definition: init.cpp:70
object::last_eat
int32_t last_eat
How long since we last ate.
Definition: object.h:366
object_update_speed
void object_update_speed(object *op)
Updates the speed of an object.
Definition: object.cpp:1334
object::type
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:348
living::food
int32_t food
How much food in stomach.
Definition: living.h:48
eat_common
static void eat_common(object *applier, object *food)
Definition: food.cpp:82
sproto.h
living::sp
int16_t sp
Spell points.
Definition: living.h:42
FLAG_CAN_USE_SKILL
#define FLAG_CAN_USE_SKILL
The monster can use skills.
Definition: define.h:321
object_insert_in_map_at
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...
Definition: object.cpp:2085
object::other_arch
struct archetype * other_arch
Pointer used for various things - mostly used for what this objects turns into or what this object cr...
Definition: object.h:425
MAX_BUF
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
INS_ON_TOP
#define INS_ON_TOP
Always put object on top.
Definition: object.h:583
is_wraith_pl
int is_wraith_pl(object *op)
Tests if a player is a wraith.
Definition: player.cpp:173
create_archetype
object * create_archetype(const char *name)
Finds which archetype matches the given name, and returns a new object containing a copy of the arche...
Definition: arch.cpp:276
living::wc
int8_t wc
Weapon Class, lower WC increases probability of hitting.
Definition: living.h:37
RANDOM
#define RANDOM()
Definition: define.h:638
living::maxgrace
int16_t maxgrace
Maximum grace.
Definition: living.h:45
change_abil
int change_abil(object *op, object *tmp)
Permanently alters an object's stats/flags based on another object.
Definition: living.cpp:394
method_ret
char method_ret
Define some standard return values for callbacks which don't need to return any other results.
Definition: ob_methods.h:14
ob_types.h
sounds.h
FLAG_REFL_SPELL
#define FLAG_REFL_SPELL
Spells (some) will reflect from object.
Definition: define.h:275
NDI_UNIQUE
#define NDI_UNIQUE
Print immediately, don't buffer.
Definition: newclient.h:266
apply_handle_yield
void apply_handle_yield(object *tmp)
This checks whether the object has a "on_use_yield" field, and if so generated and drops matching ite...
Definition: apply.cpp:122
object::name
sstring name
The name of the object, obviously...
Definition: object.h:319
is_dragon_pl
int is_dragon_pl(const object *op)
Checks if player is a dragon.
Definition: player.cpp:122
living::maxsp
int16_t maxsp
Max spell points.
Definition: living.h:43
hit_player
int hit_player(object *op, int dam, object *hitter, uint32_t type, int full_hit)
Object is attacked by something.
Definition: attack.cpp:1907
living::ac
int8_t ac
Armor Class, lower AC increases probability of not getting hit.
Definition: living.h:38
object::duration
int16_t duration
Number of moves (see 'speed') spell lasts.
Definition: object.h:415
atnr_is_dragon_enabled
int atnr_is_dragon_enabled(int attacknr)
Determine if the attacktype represented by the specified attack-number is enabled for dragon players.
Definition: player.cpp:103
object_find_by_type_and_arch_name
object * object_find_by_type_and_arch_name(const object *who, int type, const char *name)
Find object in inventory by type and archetype name.
Definition: object.cpp:4262
arch_to_object
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
Definition: arch.cpp:227
stats
Player Stats effect how well a character can survie and interact inside the crossfire world This section discusses the various stats
Definition: stats.txt:2
MSG_TYPE_APPLY_FAILURE
#define MSG_TYPE_APPLY_FAILURE
Apply OK, but no/bad result.
Definition: newclient.h:608
FLAG_IS_USED_UP
#define FLAG_IS_USED_UP
When (–food<0) the object will exit.
Definition: define.h:260
FOOD
@ FOOD
Definition: object.h:117
check_heal_and_mana
static void check_heal_and_mana(object *who, object *food)
Definition: food.cpp:43
skill
skill
Definition: arch-handbook.txt:585
DRINK
@ DRINK
Definition: object.h:162
FLAG_XRAYS
#define FLAG_XRAYS
X-ray vision.
Definition: define.h:300
ob_methods.h
is_old_wraith_pl
int is_old_wraith_pl(object *op)
Checks if player is a wraith without the 'wraith feed' skill.
Definition: player.cpp:185
chance
bool chance(int a, int b)
Return true with a probability of a/b.
Definition: treasure.cpp:890
living::grace
int16_t grace
Grace.
Definition: living.h:44
object::stats
living stats
Str, Con, Dex, etc.
Definition: object.h:378
get_attr_value
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
Definition: living.cpp:313
bonus
Player Stats effect how well a character can survie and interact inside the crossfire world This section discusses the various what they and how they effect the player s actions Also in this section are the stat modifiers that specific classes professions bring Player and sps the current and maximum the Current and Maximum The Current Sp can go somewhat negative When Sp is negative not all spells can be and a more negative Sp makes spell casting less likey to succeed can affect Damage and how the characters as well as how often the character can attack this affects the prices when buying and selling items if this drops the player will start losing hit points wd Cleric or Dwarf sm Elf wd Fireborn ft Human ra Mage C Monk se Ninja hi Priest C Quetzalcoatl mw Swashbuckler si Thief st Viking ba Warrior or Wizard C Wraith C Class Prof Str Dex Con Wis Cha Int Pow Net Skills Enclosed are codes used for the skills above The ones in and fighting should all be pretty self explanatory For the other a brief description is for a more detailed look at the skills doc file Skill remove use magic items phys no fire cold Fireborns are supposed to be fire spirits They re closely in tune with magic and are powerful and learn magic easily Being fire they are immune to fire and and vulnerable to cold They are vulnerable to ghosthit and drain because being mostly non anything which strikes directly at the spirit hits them harder race attacktype restrictions immunities prot vuln Quetzalcoatl physical no armour fire cold Quetzalcoatl s are now born knowing the spell of burning but because of their negative wisdom bonus
Definition: stats.txt:176
link_player_skills
void link_player_skills(object *op)
This function goes through the player inventory and sets up the last_skills[] array in the player obj...
Definition: player.cpp:287
MSG_TYPE_APPLY
#define MSG_TYPE_APPLY
Applying objects.
Definition: newclient.h:412
object::attacktype
uint32_t attacktype
Bitmask of attacks this object does.
Definition: object.h:352
FLAG_CURSED
#define FLAG_CURSED
The object is cursed.
Definition: define.h:316
MOVE_PER_SECOND
static const float MOVE_PER_SECOND
Speed of an object that gives it one move per second, real time.
Definition: tod.h:54
NUM_STATS
@ NUM_STATS
Number of statistics.
Definition: living.h:18
MAX_FOOD
static const int32_t MAX_FOOD
Definition: define.h:455
living::hp
int16_t hp
Hit Points.
Definition: living.h:40
living::luck
int8_t luck
Affects thaco and ac from time to time.
Definition: living.h:39
FORCE
@ FORCE
Definition: object.h:229
FLAG_LIFESAVE
#define FLAG_LIFESAVE
Saves a players' life once, then destr.
Definition: define.h:305
FORCE_NAME
#define FORCE_NAME
Definition: spells.h:169