Crossfire Server  1.75.0
gods.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 
24 #include "global.h"
25 
26 #include <stdlib.h>
27 #include <string.h>
28 
29 #include "living.h"
30 #include "object.h"
31 #include "sounds.h"
32 #include "spells.h"
33 #include "sproto.h"
34 
35 static int worship_forbids_use(object *op, object *exp_obj, uint32_t flag, const char *string);
36 static void stop_using_item(object *op, int type, int number);
37 static void update_priest_flag(const object *god, object *exp_ob, uint32_t flag);
38 static void god_intervention(object *op, const object *god, object *skill, object *altar);
39 static int god_examines_priest(object *op, const object *god);
40 static int god_examines_item(const object *god, object *item);
41 static void remove_special_prayers(object *op, const object *god);
42 
55 const char *determine_god(object *op) {
56  const char *godname;
57 
58  /* spells */
59  if ((op->type == SPELL || op->type == SPELL_EFFECT)
60  && op->title) {
61  if (find_god(op->title) != NULL)
62  return op->title;
63  }
64 
65  if (op->type != PLAYER && QUERY_FLAG(op, FLAG_ALIVE)) {
66  /* find a god based on race */
67  if (!op->title) {
68  if (op->race != NULL) {
69  godname = get_god_for_race(op->race);
70  if (godname != NULL) {
71  op->title = add_string(godname);
72  }
73  }
74  }
75 
76  /* find a random god */
77  if (!op->title) {
78  const object *god = get_rand_god();
79  if (god) {
80  op->title = add_string(god->name);
81  }
82  }
83 
84  return op->title;
85  }
86 
87  /* The god the player worships is in the praying skill (native skill
88  * not skill tool). Since a player can only have one instance of
89  * that skill, once we find it, we can return, either with the
90  * title or "none".
91  */
92  if (op->type == PLAYER) {
93  object *tmp;
94 
96  if (tmp != NULL) {
97  return tmp->title != NULL ? tmp->title : "none";
98  }
99  }
100  return ("none");
101 }
102 
111 static int same_string(const char *s1, const char *s2) {
112  if (s1 == NULL)
113  return s2 == NULL;
114  else
115  return s2 != NULL && strcmp(s1, s2) == 0;
116 }
117 
133 static void follower_remove_given_items(object *pl, object *op, const object *god) {
134  const char *given_by;
135 
136  /* search the inventory */
137  FOR_INV_PREPARE(op, tmp) {
138  given_by = object_get_value(tmp, "divine_giver_name");
139  if (given_by == god->name) {
140  char name[HUGE_BUF];
141 
142  query_short_name(tmp, name, HUGE_BUF);
143  /* Send the client a message. */
144  if (tmp->nrof > 1)
146  "The %s crumble to dust!",
147  name);
148  else
150  "The %s crumbles to dust!",
151  name);
152 
153  object_remove(tmp); /* remove obj from players inv. */
155  } else if (tmp->inv)
156  follower_remove_given_items(pl, tmp, god);
157  } FOR_INV_FINISH();
158 }
159 
169 static int follower_has_similar_item(object *op, object *item) {
170  FOR_INV_PREPARE(op, tmp) {
171  if (tmp->type == item->type
172  && same_string(tmp->name, item->name)
173  && same_string(tmp->title, item->title)
174  && tmp->msg == item->msg
175  && same_string(tmp->slaying, item->slaying))
176  return 1;
177  if (tmp->inv && follower_has_similar_item(tmp, item))
178  return 1;
179  } FOR_INV_FINISH();
180  return 0;
181 }
182 
195 static int god_gives_present(object *op, const object *god, treasure *tr) {
196  object *tmp;
197  char name[HUGE_BUF];
198 
199  if (follower_has_similar_item(op, &tr->item->clone))
200  return 0;
201 
202  tmp = arch_to_object(tr->item);
203 
204  /*
205  * Give inventory if needed, for instance Lythander's pipe.
206  * Use high level and magic so something IS put in inventory.
207  */
208  fix_generated_item(tmp, NULL, 120, 120, GT_ONLY_GOOD);
209 
210  /* And just in case nothing was put and something is needed, bail out. */
211  if ((tmp->type == ROD || tmp->type == WAND) && (tmp->inv == NULL)) {
212  object_free(tmp, 0);
213  return 0;
214  }
215 
216  query_short_name(tmp, name, HUGE_BUF);
218  "%s lets %s appear in your hands.",
219  god->name, name);
223  object_set_value(tmp, "divine_giver_name", god->name, TRUE);
224  object_insert_in_ob(tmp, op);
225  return 1;
226 }
227 
232 static bool try_leave_cult(object* pl, object* skill, int angry) {
233  const uint64_t loss = angry * (skill->stats.exp / 10);
234  if (loss)
235  change_exp(pl, -random_roll64(0, loss, pl, PREFER_LOW), skill->skill, SK_SUBTRACT_SKILL_EXP);
236 
237  /* random chance based on our current level
238  * note it gets harder the higher we get
239  */
240  if ((angry == 1) && !(random_roll(0, skill->level, pl, PREFER_LOW))) {
241  return true;
242  } else {
243  return false;
244  }
245 }
246 
258 void pray_at_altar(object *pl, object *altar, object *skill) {
259  const object *pl_god = find_god(determine_god(pl));
260 
261  if (events_execute_object_event(altar, EVENT_APPLY, pl, NULL, NULL, SCRIPT_FIX_ALL) != 0)
262  return;
263 
264  /* If non consecrate altar, don't do anything */
265  if (!altar->other_arch)
266  return;
267 
268  /* hmm. what happend depends on pl's current god, level, etc */
269  if (!pl_god) { /*new convert */
270  become_follower(pl, &altar->other_arch->clone);
271  return;
272  }
273 
274  if (!strcmp(pl_god->name, altar->other_arch->clone.name)) {
275  /* pray at your gods altar */
276  int bonus = (pl->stats.Wis+skill->level)/10;
277 
278  /* we can get neg grace up faster */
279  if (pl->stats.grace < 0)
280  pl->stats.grace += (bonus > -1*(pl->stats.grace/10) ? bonus : -1*(pl->stats.grace/10));
281  /* we can super-charge grace to 2x max */
282  if (pl->stats.grace < (2*pl->stats.maxgrace)) {
283  pl->stats.grace += bonus/2;
284  }
285  if (pl->stats.grace > (2*pl->stats.maxgrace)) {
286  pl->stats.grace = (2*pl->stats.maxgrace);
287  }
288 
289  /* Every once in a while, the god decides to checkup on their
290  * follower, and may intervene to help them out.
291  */
292  bonus = MAX(1, bonus+MAX(pl->stats.luck, -3)); /* -- DAMN -- */
293 
294  if (((random_roll(0, 399, pl, PREFER_LOW))-bonus) < 0)
295  god_intervention(pl, pl_god, skill, altar);
296  } else { /* praying to another god! */
297  int angry = 1;
298 
299  /* I believe the logic for detecting opposing gods was completely
300  * broken - I think it should work now. altar->other_arch
301  * points to the god of this altar (which we have
302  * already verified is non null). pl_god->other_arch
303  * is the opposing god - we need to verify that exists before
304  * using its values.
305  */
306  if (pl_god->other_arch
307  && (altar->other_arch->name == pl_god->other_arch->name)) {
308  angry = 2;
309  if (random_roll(0, skill->level+2, pl, PREFER_LOW)-5 > 0) {
310  object *tmp;
311 
312  /* you really screwed up */
313  angry = 3;
315  "Foul Priest! %s punishes you!",
316  pl_god->name);
318  cast_magic_storm(pl, tmp, pl_god->level+20);
319  } else
321  "Foolish heretic! %s is livid!",
322  pl_god->name);
323  } else
325  "Heretic! %s is angered!",
326  pl_god->name);
327 
328  if (try_leave_cult(pl, skill, angry)) {
329  become_follower(pl, &altar->other_arch->clone);
330  } else {
331  /* toss this player off the altar. He can try again. */
333  "A divine force pushes you off the altar.");
334 
335  move_player(pl, absdir(pl->facing+4)); /* back him off the way he came. */
336  }
337  }
338 }
339 
350 static void remove_special_prayers(object *op, const object *god) {
351  treasure *tr;
352  int remove = 0;
353 
354  if (god->randomitems == NULL) {
355  LOG(llevError, "BUG: remove_special_prayers(): god %s without randomitems\n", god->name);
356  return;
357  }
358 
359 
360  /* Outer loop iterates over all special prayer marks */
361  FOR_INV_PREPARE(op, tmp) {
362  /* we mark special prayers with the STARTEQUIP flag, so if it isn't
363  * in that category, not something we need to worry about.
364  */
365  if (tmp->type != SPELL || !QUERY_FLAG(tmp, FLAG_STARTEQUIP))
366  continue;
367 
368  /* Inner loop tries to find the special prayer in the god's treasure
369  * list. We default that the spell should not be removed.
370  */
371  remove = 0;
372  for (tr = god->randomitems->items; tr; tr = tr->next) {
373  if (tr->item == NULL)
374  continue;
375 
376  /* Basically, see if the matching spell is granted by this god. */
377 
378  if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) {
379  remove = 1;
380  break;
381  }
382  }
383  if (remove) {
384  /* just do the work of removing the spell ourselves - we already
385  * know that the player knows the spell
386  */
389  "You lose knowledge of %s.",
390  tmp->name);
391  player_unready_range_ob(op->contr, tmp);
392  esrv_remove_spell(op->contr, tmp);
393  object_remove(tmp);
395  }
396  } FOR_INV_FINISH();
397 }
398 
414 int become_follower(object *op, const object *new_god) {
415  /* take away any special god-characteristic items. */
416  FOR_INV_PREPARE(op, item) {
417  /* remove all invisible startequip items which are
418  * not skill, exp or force
419  */
420  if (QUERY_FLAG(item, FLAG_STARTEQUIP)
421  && item->invisible
422  && (item->type != SKILL)
423  && (item->type != FORCE)
424  && (item->type != SPELL)) {
425  player_unready_range_ob(op->contr, item);
426  object_remove(item);
428  }
429  } FOR_INV_FINISH();
430 
431  /* remove any items given by the old god */
432  const object *old_god = find_god(determine_god(op));
433  if (old_god) {
434  /* Changed to use the new "divine_giver_name" key_value
435  * so it can reliably delete enchanted items. Now it loops
436  * through the player's inventory, instead of the god's
437  * treasure list.
438  */
439  follower_remove_given_items(op, op, old_god);
440  remove_special_prayers(op, old_god);
441  }
442 
443  if (!op || !new_god)
444  return 0;
445 
446  if (op->race && new_god->slaying && strstr(op->race, new_god->slaying)) {
448  "Fool! %s detests your kind!",
449  new_god->name);
450  if (random_roll(0, op->level-1, op, PREFER_LOW)-5 > 0) {
451  object *tmp = create_archetype(LOOSE_MANA);
452  cast_magic_storm(op, tmp, new_god->level+10);
453  }
454  return 0;
455  }
456 
457  /* give the player any special god-characteristic-items. */
458  for (treasure *tr = new_god->randomitems->items; tr != NULL; tr = tr->next) {
459  if (tr->item
460  && tr->item->clone.invisible
461  && tr->item->clone.type != SPELLBOOK
462  && tr->item->clone.type != BOOK
463  && tr->item->clone.type != SPELL)
464  god_gives_present(op, new_god, tr);
465  }
466 
468  "You become a follower of %s!",
469  new_god->name);
470 
471  object *skop = object_find_by_type_subtype(op, SKILL, SK_PRAYING);
472  /* Player has no skill - give them the skill */
473  if (!skop) {
474  /* The archetype should always be defined - if we crash here because it doesn't,
475  * things are really messed up anyways.
476  */
478  link_player_skills(op);
479  }
480 
481  int sk_applied = QUERY_FLAG(skop, FLAG_APPLIED); /* save skill status */
482 
483  int undeadified = 0; /* Turns to true if changing god can changes the undead
484  * status of the player.*/
485  /* Clear the "undead" status. We also need to force a call to change_abil,
486  * so I set undeadified for that.
487  * - gros, 21th July 2006.
488  */
489  if ((old_god) && (QUERY_FLAG(old_god, FLAG_UNDEAD))) {
490  CLEAR_FLAG(skop, FLAG_UNDEAD);
491  undeadified = 1;
492  }
493 
494  if (skop->title) { /* get rid of old god */
496  "%s's blessing is withdrawn from you.",
497  skop->title);
498 
499  /* The point of this is to really show what abilities the player just lost */
500  if (sk_applied || undeadified) {
501  CLEAR_FLAG(skop, FLAG_APPLIED);
502  (void)change_abil(op, skop);
503  }
504  free_string(skop->title);
505  }
506 
507  /* now change to the new gods attributes to exp_obj */
508  skop->title = add_string(new_god->name);
509  skop->path_attuned = new_god->path_attuned;
510  skop->path_repelled = new_god->path_repelled;
511  skop->path_denied = new_god->path_denied;
512  /* copy god's resistances */
513  memcpy(skop->resist, new_god->resist, sizeof(new_god->resist));
514 
515  /* make sure that certain immunities do NOT get passed
516  * to the follower!
517  */
518  for (int i = 0; i < NROFATTACKS; i++)
519  if (skop->resist[i] > 30
520  && (i == ATNR_FIRE || i == ATNR_COLD || i == ATNR_ELECTRICITY || i == ATNR_POISON))
521  skop->resist[i] = 30;
522 
523  skop->stats.hp = (int16_t)new_god->last_heal;
524  skop->stats.sp = (int16_t)new_god->last_sp;
525  skop->stats.grace = (int16_t)new_god->last_grace;
526  skop->stats.food = (int16_t)new_god->last_eat;
527  skop->stats.luck = (int8_t)new_god->stats.luck;
528  /* gods may pass on certain flag properties */
529  update_priest_flag(new_god, skop, FLAG_SEE_IN_DARK);
530  update_priest_flag(new_god, skop, FLAG_REFL_SPELL);
531  update_priest_flag(new_god, skop, FLAG_REFL_MISSILE);
532  update_priest_flag(new_god, skop, FLAG_STEALTH);
533  update_priest_flag(new_god, skop, FLAG_MAKE_INVIS);
534  update_priest_flag(new_god, skop, FLAG_UNDEAD);
535  update_priest_flag(new_god, skop, FLAG_BLIND);
536  update_priest_flag(new_god, skop, FLAG_XRAYS); /* better have this if blind! */
537  update_priest_flag(new_god, skop, FLAG_USE_WEAPON);
538  update_priest_flag(new_god, skop, FLAG_USE_ARMOUR);
539  update_priest_flag(new_god, skop, FLAG_USE_SHIELD);
540 
542  "You are bathed in %s's aura.",
543  new_god->name);
544 
545  /* Weapon/armour use are special...handle flag toggles here as this can
546  * only happen when gods are worshipped and if the new priest could
547  * have used armour/weapons in the first place.
548  *
549  * This also can happen for monks which cannot use weapons. In this case
550  * do not allow to use weapons even if the god otherwise would allow it.
551  */
552  if (!object_present_in_ob_by_name(FORCE, "no weapon force", op)) {
553  if (worship_forbids_use(op, skop, FLAG_USE_WEAPON, "weapons"))
554  stop_using_item(op, WEAPON, 2);
555  }
556  update_priest_flag(new_god, skop, FLAG_USE_ARMOUR);
557 
558  if (worship_forbids_use(op, skop, FLAG_USE_ARMOUR, "armour")) {
559  stop_using_item(op, ARMOUR, 1);
560  stop_using_item(op, HELMET, 1);
561  stop_using_item(op, BOOTS, 1);
562  stop_using_item(op, GLOVES, 1);
563  }
564 
565  if (worship_forbids_use(op, skop, FLAG_USE_SHIELD, "shield"))
566  stop_using_item(op, SHIELD, 1);
567 
568  SET_FLAG(skop, FLAG_APPLIED);
569  (void)change_abil(op, skop);
570 
571  /* return to previous skill status */
572  if (!sk_applied)
573  CLEAR_FLAG(skop, FLAG_APPLIED);
574 
575  return 1;
576 }
577 
591 static int worship_forbids_use(object *op, object *exp_obj, uint32_t flag, const char *string) {
592  if (QUERY_FLAG(&op->arch->clone, flag)) {
593  if (QUERY_FLAG(op, flag) != QUERY_FLAG(exp_obj, flag)) {
594  update_priest_flag(exp_obj, op, flag);
595  if (QUERY_FLAG(op, flag))
597  "You may use %s again.",
598  string);
599  else {
601  "You are forbidden to use %s.",
602  string);
603  return 1;
604  }
605  }
606  }
607  return 0;
608 }
609 
621 static void stop_using_item(object *op, int type, int number) {
622  FOR_INV_PREPARE(op, tmp)
623  if (tmp->type == type && QUERY_FLAG(tmp, FLAG_APPLIED)) {
625  number--;
626  if (number <= 0)
627  break;
628  }
629  FOR_INV_FINISH();
630 }
631 
644 static void update_priest_flag(const object *god, object *exp_ob, uint32_t flag) {
645  if (QUERY_FLAG(god, flag) && !QUERY_FLAG(exp_ob, flag))
646  SET_FLAG(exp_ob, flag);
647  else if (QUERY_FLAG(exp_ob, flag) && !QUERY_FLAG(god, flag)) {
648  /* When this is called with the exp_ob set to the player,
649  * this check is broken, because most all players arch
650  * allow use of weapons. I'm not actually sure why this
651  * check is here - I guess if you had a case where the
652  * value in the archetype (wisdom) should over ride the restrictions
653  * the god places on it, this may make sense. But I don't think
654  * there is any case like that.
655  */
656 
657 /* if (!(QUERY_FLAG(&(exp_ob->arch->clone), flag)))*/
658  CLEAR_FLAG(exp_ob, flag);
659  }
660 }
661 
662 
676 archetype *determine_holy_arch(const object *god, const char *type) {
677  treasure *tr;
678  int count;
679  object *item;
680 
681  if (!god || !god->randomitems) {
682  LOG(llevError, "BUG: determine_holy_arch(): no god or god without randomitems\n");
683  return NULL;
684  }
685 
686  count = 0;
687  for (tr = god->randomitems->items; tr != NULL; tr = tr->next) {
688  if (!tr->item)
689  continue;
690  item = &tr->item->clone;
691  if (item->type == BOOK && item->invisible && item->name == type)
692  count++;
693  }
694  if (count == 0) {
695  return NULL;
696  }
697 
698  count = rndm(1, count);
699 
700  for (tr = god->randomitems->items; tr != NULL; tr = tr->next) {
701  if (!tr->item)
702  continue;
703  item = &tr->item->clone;
704  if (item->type == BOOK && item->invisible && item->name == type) {
705  count--;
706  if (count == 0)
707  return item->other_arch;
708  }
709  }
710 
711  return NULL;
712 }
713 
724 static int god_removes_curse(object *op, int remove_damnation) {
725  int success = 0;
726 
727  FOR_INV_PREPARE(op, tmp) {
728  if (tmp->invisible)
729  continue;
730  if (QUERY_FLAG(tmp, FLAG_DAMNED) && !remove_damnation)
731  continue;
732  if (QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED)) {
733  success = 1;
734  CLEAR_FLAG(tmp, FLAG_DAMNED);
735  CLEAR_FLAG(tmp, FLAG_CURSED);
737  if (op->type == PLAYER)
738  esrv_update_item(UPD_FLAGS, op, tmp);
739  }
740  } FOR_INV_FINISH();
741 
742  if (success)
744  "You feel like someone is helping you.");
745  return success;
746 }
747 
757 static int follower_level_to_enchantments(int level, int difficulty) {
758  if (difficulty < 1) {
759  LOG(llevError, "follower_level_to_enchantments(): difficulty %d is invalid\n", difficulty);
760  return 0;
761  }
762 
763  if (level <= 20)
764  return level/difficulty;
765  if (level <= 40)
766  return (20+(level-20)/2)/difficulty;
767  return (30+(level-40)/4)/difficulty;
768 }
769 
788 static int improve_weapon_magic(object *op, object *tr, object *weapon, object *skill) {
789  int tmp = follower_level_to_enchantments(skill->level, tr->level);
790 
791  if (weapon->magic < tmp) {
793  "A phosphorescent glow envelops your weapon!");
794  weapon->magic++;
795  if (op->type == PLAYER)
796  esrv_update_item(UPD_NAME, op, weapon);
797  weapon->item_power++;
798  return 1;
799  }
800 
801  return 0;
802 }
803 
821 static int god_enchants_weapon(object *op, const object *god, object *tr, object *skill) {
822  char buf[MAX_BUF];
823  object *weapon;
824  uint32_t attacktype;
825 
826  weapon = object_find_by_type_applied(op, WEAPON);
827  if (weapon == NULL)
828  weapon = object_find_by_type_applied(op, BOW);
829  if (weapon == NULL || god_examines_item(god, weapon) <= 0)
830  return 0;
831 
832  if (weapon->item_power >= MAX_WEAPON_ITEM_POWER) {
834  "%s considers your %s is not worthy to be enchanted any more.",
835  god->name,
836  weapon->name);
837  return 0;
838  }
839 
840  /* If personalized_blessings is activated, then the god's name is
841  * associated with the weapon, as well as the owner (the one who blesses it),
842  * and a "weapon willpower", which is equivalent to the owner's experience
843  * in praying when the weapon is blessed.
844  * Those values are used later, when another player attempts to wield the
845  * weapon - nasty things may happen to those who do not deserve to use it ! :)
846  */
848  const char *divine_owner = object_get_value(weapon, "divine_blessing_name");
849  const char *owner = object_get_value(weapon, "item_owner");
850  object *skillop = NULL;
851 
852  if (divine_owner != NULL && strcmp(divine_owner, god->name) != 0) {
853  /* Huho... Another god already blessed this one ! */
855  "Your %s already belongs to %s !",
856  weapon->name, divine_owner);
857  return 0;
858  }
859 
860  if ((owner != NULL) && (strcmp(owner, op->name) != 0)) {
861  /* Maybe the weapon itself will not agree ? */
863  "The %s is not yours, and is magically protected against such changes !",
864  weapon->name);
865  return 0;
866  }
867  skillop = find_skill_by_number(op, SK_PRAYING);
868  if (skillop == NULL) {
869  LOG(llevError, "god_enchants_weapon: no praying skill object found ?!\n");
870  snprintf(buf, sizeof(buf), "%d", 1);
871  } else
872  snprintf(buf, sizeof(buf), "%" FMT64, skillop->stats.exp);
873  object_set_value(weapon, "divine_blessing_name", god->name, TRUE);
874  object_set_value(weapon, "item_owner", op->name, TRUE);
875  object_set_value(weapon, "item_willpower", buf, TRUE);
876  }
877 
878  /* First give it a title, so other gods won't touch it */
879  if (!weapon->title) {
880  snprintf(buf, sizeof(buf), "of %s", god->name);
881  weapon->title = add_string(buf);
882  if (op->type == PLAYER)
883  esrv_update_item(UPD_NAME, op, weapon);
885  "Your weapon quivers as if struck!");
886  }
887 
888  /* Allow the weapon to slay enemies */
889  if (!weapon->slaying && god->slaying) {
890  weapon->slaying = add_string(god->slaying);
892  "Your %s now hungers to slay enemies of your god!",
893  weapon->name);
894  weapon->item_power++;
895  return 1;
896  }
897 
898  /* Add the gods attacktype */
899  attacktype = (weapon->attacktype == 0) ? AT_PHYSICAL : weapon->attacktype;
900  if ((attacktype&god->attacktype) != god->attacktype) {
902  "Your weapon suddenly glows!");
903  weapon->attacktype = attacktype|god->attacktype;
904  weapon->item_power++;
905  return 1;
906  }
907 
908  /* Higher magic value */
909  return improve_weapon_magic(op, tr, weapon, skill);
910 }
911 
927 static void god_intervention(object *op, const object *god, object *skill, object *altar) {
928  treasure *tr;
929 
930  if (!god || !god->randomitems) {
931  LOG(llevError, "BUG: god_intervention(): no god or god without randomitems\n");
932  return;
933  }
934 
935  /* lets do some checks of whether we are kosher with our god */
936  if (god_examines_priest(op, god) < 0)
937  return;
938 
940  "You feel a holy presence!");
941 
942  if (altar->anim_suffix != NULL)
943  apply_anim_suffix(altar, altar->anim_suffix);
944 
945  for (tr = god->randomitems->items; tr != NULL; tr = tr->next) {
946  object *item;
947 
948  if (tr->chance <= random_roll(0, 99, op, PREFER_HIGH))
949  continue;
950 
951  /* Treasurelist - generate some treasure for the follower */
952  if (tr->name) {
954  if (tl == NULL)
955  continue;
956 
958  "Something appears before your eyes. You catch it before it falls to the ground.");
959 
961  return;
962  }
963 
964  if (!tr->item) {
965  LOG(llevError, "BUG: empty entry in %s's treasure list\n", god->name);
966  continue;
967  }
968  item = &tr->item->clone;
969 
970  /* Grace limit */
971  if (item->type == BOOK && item->invisible
972  && strcmp(item->name, "grace limit") == 0) {
973  if (op->stats.grace < item->stats.grace
974  || op->stats.grace < op->stats.maxgrace) {
975  object *tmp;
976 
977  /* Follower lacks the required grace for the following
978  * treasure list items. */
979 
981  cast_change_ability(op, op, tmp, 0, 1);
983  return;
984  }
985  continue;
986  }
987 
988  /* Restore grace */
989  if (item->type == BOOK && item->invisible
990  && strcmp(item->name, "restore grace") == 0) {
991  if (op->stats.grace >= 0)
992  continue;
993  op->stats.grace = random_roll(0, 9, op, PREFER_HIGH);
995  "You are returned to a state of grace.");
996  return;
997  }
998 
999  /* Heal damage */
1000  if (item->type == BOOK && item->invisible
1001  && strcmp(item->name, "restore hitpoints") == 0) {
1002  if (op->stats.hp >= op->stats.maxhp)
1003  continue;
1005  "A white light surrounds and heals you!");
1006  op->stats.hp = op->stats.maxhp;
1007  return;
1008  }
1009 
1010  /* Restore spellpoints */
1011  if (item->type == BOOK
1012  && item->invisible
1013  && strcmp(item->name, "restore spellpoints") == 0) {
1014  int max = op->stats.maxsp*(item->stats.maxsp/100.0);
1015  /* Restore to 50 .. 100%, if sp < 50% */
1016  int new_sp = random_roll(1000, 1999, op, PREFER_HIGH)/2000.0*max;
1017  if (op->stats.sp >= max/2)
1018  continue;
1020  "A blue lightning strikes your head but doesn't hurt you!");
1021  op->stats.sp = new_sp;
1022  }
1023 
1024  /* Various heal spells */
1025  if (item->type == BOOK && item->invisible
1026  && strcmp(item->name, "heal spell") == 0) {
1027  object *tmp;
1028  int success;
1029 
1031 
1032  success = cast_heal(op, op, tmp, 0);
1034  if (success)
1035  return;
1036 
1037  continue;
1038  }
1039 
1040  /* Remove curse */
1041  if (item->type == BOOK && item->invisible
1042  && strcmp(item->name, "remove curse") == 0) {
1043  if (god_removes_curse(op, 0))
1044  return;
1045 
1046  continue;
1047  }
1048 
1049  /* Remove damnation */
1050  if (item->type == BOOK && item->invisible
1051  && strcmp(item->name, "remove damnation") == 0) {
1052  if (god_removes_curse(op, 1))
1053  return;
1054 
1055  continue;
1056  }
1057 
1058  /* Heal depletion */
1059  if (item->type == BOOK && item->invisible
1060  && strcmp(item->name, "heal depletion") == 0) {
1061  if (remove_depletion(op, -1)) {
1063  "Shimmering light surrounds and restores you!");
1064  }
1065  }
1066 
1067  /* Voices */
1068  if (item->type == BOOK && item->invisible
1069  && strcmp(item->name, "voice_behind") == 0) {
1071  "You hear a voice from behind you, but you don't dare to "
1072  "turn around:");
1074  item->msg);
1075  return;
1076  }
1077 
1078  /* Messages */
1079  if (item->type == BOOK && item->invisible
1080  && strcmp(item->name, "message") == 0) {
1082  item->msg);
1083  return;
1084  }
1085 
1086  /* Enchant weapon */
1087  if (item->type == BOOK && item->invisible
1088  && strcmp(item->name, "enchant weapon") == 0) {
1089  if (god_enchants_weapon(op, god, item, skill))
1090  return;
1091 
1092  continue;
1093  }
1094 
1095  /* Spellbooks - works correctly only for prayers */
1096  if (item->type == SPELL) {
1097  if (check_spell_known(op, item->name))
1098  continue;
1099  if (item->level > skill->level)
1100  continue;
1101 
1103  "%s grants you use of a special prayer!",
1104  god->name);
1105  do_learn_spell(op, item, 1);
1106  return;
1107  }
1108 
1109  /* Other gifts */
1110  if (!item->invisible) {
1111  if (god_gives_present(op, god, tr))
1112  return;
1113 
1114  continue;
1115  }
1116  /* else ignore it */
1117  }
1118 
1120  "You feel rapture.");
1121 }
1122 
1135 static int god_examines_priest(object *op, const object *god) {
1136  int reaction = 1;
1137  object *skop;
1138 
1139  FOR_INV_PREPARE(op, item)
1140  if (QUERY_FLAG(item, FLAG_APPLIED)) {
1141  reaction += god_examines_item(god, item)*(item->magic ? abs(item->magic) : 1);
1142  }
1143  FOR_INV_FINISH();
1144 
1145  /* well, well. Looks like we screwed up. Time for god's revenge */
1146  if (reaction < 0) {
1147  int loss = 10000000;
1148  int angry = abs(reaction);
1149 
1151  if (skop)
1152  loss = 0.05*(float)skop->stats.exp;
1153  change_exp(op, -random_roll(0, loss*angry-1, op, PREFER_LOW), skop ? skop->skill : "none", SK_SUBTRACT_SKILL_EXP);
1154  if (random_roll(0, angry, op, PREFER_LOW)) {
1155  object *tmp = create_archetype(LOOSE_MANA);
1156 
1157  cast_magic_storm(op, tmp, op->level+(angry*3));
1158  }
1160  "%s becomes angry and punishes you!",
1161  god->name);
1162  }
1163  return reaction;
1164 }
1165 
1182 static int god_examines_item(const object *god, object *item) {
1183  char buf[MAX_BUF];
1184 
1185  if (!god || !item)
1186  return 0;
1187 
1188  if (!item->title)
1189  return 1; /* unclaimed item are ok */
1190 
1191  snprintf(buf, sizeof(buf), "of %s", god->name);
1192  if (!strcmp(item->title, buf))
1193  return 1; /* belongs to that God */
1194 
1195  if (god->title) { /* check if we have any enemy blessed item*/
1196  snprintf(buf, sizeof(buf), "of %s", god->title);
1197  if (!strcmp(item->title, buf)) {
1198  if (item->env) {
1199  char name[MAX_BUF];
1200 
1201  query_name(item, name, MAX_BUF);
1203  "Heretic! You are using %s!",
1204  name);
1205  }
1206  return -1;
1207  }
1208  }
1209  return 0; /* item is sacred to a non-enemy god/or is otherwise magical */
1210 }
1211 
1223 int tailor_god_spell(object *spellop, object *caster) {
1224  const object *god = find_god(determine_god(caster));
1225  int caster_is_spell = 0;
1226 
1227  if (caster->type == SPELL_EFFECT || caster->type == SPELL)
1228  caster_is_spell = 1;
1229 
1230  /* if caster is a rune or the like, it doesn't worship anything. However,
1231  * if this object is owned by someone, then the god that they worship
1232  * is relevant, so use that.
1233  */
1234  if (!god && object_get_owner(caster))
1235  god = find_god(determine_god(object_get_owner(caster)));
1236 
1237  if (!god || (spellop->attacktype&AT_HOLYWORD && !god->race)) {
1238  if (!caster_is_spell)
1240  "This prayer is useless unless you worship an appropriate god");
1241  else
1242  LOG(llevError, "BUG: tailor_god_spell(): no god\n");
1243  object_free_drop_inventory(spellop);
1244  return 0;
1245  }
1246 
1247  /* either holy word or godpower attacks will set the slaying field */
1248  if (spellop->attacktype&AT_HOLYWORD || spellop->attacktype&AT_GODPOWER) {
1249  if (spellop->slaying) {
1250  free_string(spellop->slaying);
1251  spellop->slaying = NULL;
1252  }
1253  if (!caster_is_spell)
1254  spellop->slaying = god->slaying ? add_string(god->slaying) : NULL;
1255  else if (caster->slaying)
1256  spellop->slaying = add_string(caster->slaying);
1257  }
1258 
1259  /* only the godpower attacktype adds the god's attack onto the spell */
1260  if (spellop->attacktype&AT_GODPOWER)
1261  spellop->attacktype = spellop->attacktype|god->attacktype;
1262 
1263  /* tack on the god's name to the spell */
1264  if (spellop->attacktype&AT_HOLYWORD || spellop->attacktype&AT_GODPOWER) {
1265  if (spellop->title)
1266  free_string(spellop->title);
1267  spellop->title = add_string(god->name);
1268  if (spellop->title) {
1269  char buf[MAX_BUF];
1270 
1271  snprintf(buf, sizeof(buf), "%s of %s", spellop->name, spellop->title);
1272  FREE_AND_COPY(spellop->name, buf);
1273  FREE_AND_COPY(spellop->name_pl, buf);
1274  }
1275  }
1276 
1277  return 1;
1278 }
Error, serious thing.
Definition: logger.h:11
#define AP_UNAPPLY
Item is to be remvoed.
Definition: define.h:596
#define AT_HOLYWORD
Damage based on race and caster&#39;s god.
Definition: attack.h:99
#define MSG_TYPE_SKILL_PRAY
Praying related messages.
Definition: newclient.h:627
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
Definition: define.h:325
int apply_special(object *who, object *op, int aflags)
Apply an object.
Definition: apply.cpp:818
Sound-related defines.
When object has been generated, send its information to player.
Definition: treasure.h:35
int become_follower(object *op, const object *new_god)
This function is called whenever a player has switched to a new god.
Definition: gods.cpp:414
#define MSG_TYPE_ITEM_CHANGE
Item has changed in some way.
Definition: newclient.h:681
#define FLAG_DAMNED
The object is very cursed.
Definition: define.h:305
static int god_removes_curse(object *op, int remove_damnation)
God helps player by removing curse and/or damnation.
Definition: gods.cpp:724
#define MSG_TYPE_ATTRIBUTE_GOD
changing god info
Definition: newclient.h:611
#define ATNR_ELECTRICITY
Definition: attack.h:50
#define MSG_TYPE_ITEM
Item related information.
Definition: newclient.h:429
Spell-related defines: spellpath, subtypes, ...
int move_player(object *op, int dir)
Move player in the given direction.
Definition: player.cpp:2962
int8_t item_power
Power rating of the object.
Definition: object.h:372
struct archetype * arch
Pointer to archetype.
Definition: object.h:424
const object * find_god(const char *name)
Returns a god&#39;s object from its name.
Definition: holy.cpp:317
object * check_spell_known(object *op, const char *name)
Checks to see if player knows the spell.
Definition: spell_util.cpp:394
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
Definition: object.cpp:789
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:58
int rndm(int min, int max)
Returns a number between min and max.
Definition: utils.cpp:162
#define HOLY_POSSESSION
Definition: spells.h:168
#define MSG_TYPE_ITEM_ADD
Item added to inventory.
Definition: newclient.h:680
static bool try_leave_cult(object *pl, object *skill, int angry)
Try to leave a cult.
Definition: gods.cpp:232
int cast_change_ability(object *op, object *caster, object *spell_ob, int dir, int silent)
Cast some stat-improving spell.
#define ATNR_FIRE
Definition: attack.h:49
#define NDI_WHITE
Definition: newclient.h:247
#define MSG_TYPE_ITEM_INFO
Information related to items.
Definition: newclient.h:682
static int god_examines_priest(object *op, const object *god)
Checks and maybe punishes someone praying.
Definition: gods.cpp:1135
#define FLAG_USE_ARMOUR
(Monster) can wear armour/shield/helmet
Definition: define.h:283
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
int16_t grace
Grace.
Definition: living.h:44
static int same_string(const char *s1, const char *s2)
Compares 2 strings.
Definition: gods.cpp:111
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
Definition: object.cpp:1818
int16_t maxgrace
Maximum grace.
Definition: living.h:45
int level
Definition: readable.cpp:1561
int remove_depletion(object *op, int level)
Remove depletion from op, if present, and warn player of such restorations.
Definition: living.cpp:755
#define HUGE_BUF
Used for messages - some can be quite long.
Definition: define.h:37
sstring name
If non null, name of list to use instead.
Definition: treasure.h:66
void esrv_update_item(int flags, object *pl, object *op)
Updates object *op for player *pl.
Definition: main.cpp:359
See Spellbook.
Definition: object.h:208
sstring slaying
Which race to do double damage to.
Definition: object.h:327
sstring add_string(const char *str)
Share a string.
Definition: shstr.cpp:137
int8_t luck
Affects thaco and ac from time to time.
Definition: living.h:39
#define FLAG_BLIND
If set, object cannot see (visually)
Definition: define.h:324
#define PREFER_LOW
Definition: define.h:585
See Weapon.
Definition: object.h:124
See Helmet.
Definition: object.h:141
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:288
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Changes experience to a player/monster.
Definition: living.cpp:2179
#define FLAG_STEALTH
Will wake monsters with less range.
Definition: define.h:300
See Rod.
Definition: object.h:114
object * object_find_by_type_applied(const object *who, int type)
Find applied object in inventory.
Definition: object.cpp:4068
int8_t magic
Any magical bonuses to this item.
Definition: object.h:358
#define FLAG_USE_WEAPON
(Monster) can wield weapons
Definition: define.h:284
archetype * determine_holy_arch(const object *god, const char *type)
Determines the archetype for holy servant and god avatar.
Definition: gods.cpp:676
#define TRUE
Definition: compat.h:11
#define MAX(x, y)
Definition: compat.h:24
#define MSG_TYPE_ITEM_REMOVE
Item removed from inv.
Definition: newclient.h:679
static int god_gives_present(object *op, const object *god, treasure *tr)
God gives an item to the player.
Definition: gods.cpp:195
uint32_t path_repelled
Paths the object is repelled from.
Definition: object.h:354
static int god_enchants_weapon(object *op, const object *god, object *tr, object *skill)
God wants to enchant weapon.
Definition: gods.cpp:821
Global type definitions and header inclusions.
See Boots.
Definition: object.h:217
struct player * contr
Pointer to the player which control this object.
Definition: object.h:284
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
Definition: main.cpp:308
static void follower_remove_given_items(object *pl, object *op, const object *god)
Removes from a player&#39;s inventory all items bestowed by a particular god.
Definition: gods.cpp:133
See Wand & Staff.
Definition: object.h:225
#define NDI_NAVY
Definition: newclient.h:248
#define LOOSE_MANA
Definition: spells.h:162
#define NROFATTACKS
Definition: attack.h:15
#define FLAG_UNDEAD
Monster is undead.
Definition: define.h:257
int change_abil(object *op, object *tmp)
Permanently alters an object&#39;s stats/flags based on another object.
Definition: living.cpp:394
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
Definition: shstr.cpp:294
int16_t level
Level of creature or object.
Definition: object.h:361
int16_t sp
Spell points.
Definition: living.h:42
#define AT_GODPOWER
Adds relevant god&#39;s attacktype (1048576) peterm@soda.berkeley.edu.
Definition: attack.h:98
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
Definition: object.cpp:1577
const char * get_god_for_race(const char *race)
Returns a string that is the name of the god that should be natively worshipped by a creature of who ...
Definition: holy.cpp:90
See Shooting Weapon.
Definition: object.h:123
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Find object in inventory.
Definition: object.cpp:4286
#define FLAG_ALIVE
Object can fight (or be fought)
Definition: define.h:217
#define AP_IGNORE_CURSE
Apply/unapply regardless of cursed/damned status.
Definition: define.h:603
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:351
#define FLAG_REFL_SPELL
Spells (some) will reflect from object.
Definition: define.h:262
See Book.
Definition: object.h:119
const char * determine_god(object *op)
Determines if op worships a god.
Definition: gods.cpp:55
#define ATNR_COLD
Definition: attack.h:51
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
This calls the appropriate treasure creation function.
Definition: treasure.cpp:287
static int follower_level_to_enchantments(int level, int difficulty)
Converts a level and difficulty to a magic/enchantment value for eg weapons.
Definition: gods.cpp:757
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:483
sstring name
More definite name, like "generate_kobold".
Definition: object.h:484
int64_t random_roll64(int64_t min, int64_t max, const object *op, int goodbad)
This is a 64 bit version of random_roll() above.
Definition: utils.cpp:77
static int worship_forbids_use(object *op, object *exp_obj, uint32_t flag, const char *string)
Forbids or let player use something item type.
Definition: gods.cpp:591
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
Definition: arch.cpp:227
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
object * env
Pointer to the object which is the environment.
Definition: object.h:301
#define SET_FLAG(xyz, p)
Definition: define.h:384
int32_t last_sp
As last_heal, but for spell points.
Definition: object.h:368
#define QUERY_FLAG(xyz, p)
Definition: define.h:386
#define FLAG_USE_SHIELD
Can this creature use a shield?
Definition: define.h:224
int8_t Wis
Use
Definition: living.h:36
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...
Definition: gods.cpp:644
sstring anim_suffix
Used to determine combined animations.
Definition: object.h:324
#define MSG_TYPE_ATTRIBUTE
Changes to attributes (stats, resistances, etc)
Definition: newclient.h:421
void query_name(const object *op, char *buf, size_t size)
Describes an item.
Definition: item.cpp:594
uint8_t chance
Percent chance for this item.
Definition: treasure.h:73
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
Definition: object.cpp:1545
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
Definition: define.h:700
sstring msg
If this is a book/sign/magic mouth/etc.
Definition: object.h:330
#define FMT64
Definition: compat.h:16
sstring race
Human, goblin, dragon, etc.
Definition: object.h:326
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
Definition: object.cpp:4331
static int god_examines_item(const object *god, object *item)
God checks item the player is using.
Definition: gods.cpp:1182
#define MAX_WEAPON_ITEM_POWER
Maximum item power an item can have.
Definition: define.h:459
static int improve_weapon_magic(object *op, object *tr, object *weapon, object *skill)
Utility function for improving the magic on a weapon.
Definition: gods.cpp:788
const object * get_rand_god(void)
Returns a random god.
Definition: holy.cpp:73
object * create_archetype_by_object_name(const char *name)
Creates an object given the name that appears during the game (for example, "writing pen" instead of ...
Definition: arch.cpp:114
#define UPD_FLAGS
Definition: newclient.h:331
void do_learn_spell(object *op, object *spell, int special_prayer)
Actually makes op learn spell.
Definition: apply.cpp:146
struct Settings settings
Global settings.
Definition: init.cpp:139
void player_unready_range_ob(player *pl, object *ob)
Unready an object for a player.
Definition: player.cpp:4475
#define FLAG_XRAYS
X-ray vision.
Definition: define.h:288
void cast_magic_storm(object *op, object *tmp, int lvl)
This is really used mostly for spell fumbles and the like.
int random_roll(int min, int max, const object *op, int goodbad)
Roll a random number between min and max.
Definition: utils.cpp:42
Praying.
Definition: skills.h:49
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.
Definition: gods.cpp:927
#define AT_PHYSICAL
Basic attack (1)
Definition: attack.h:78
See Spell.
Definition: object.h:219
uint32_t path_denied
Paths the object is denied access to.
Definition: object.h:355
living stats
Str, Con, Dex, etc.
Definition: object.h:378
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
#define ATNR_POISON
Definition: attack.h:57
int16_t invisible
How much longer the object will be invis.
Definition: object.h:370
archetype * get_archetype_by_type_subtype(int type, int subtype)
Retrieves an archetype by type and subtype.
Definition: arch.cpp:97
object * object_present_in_ob_by_name(int type, const char *str, const object *op)
Searches for any objects with a matching type & name variable in the inventory of the given object...
Definition: object.cpp:3188
treasurelist represents one logical group of items to be generated together.
Definition: treasure.h:85
int8_t facing
Object is oriented/facing that way.
Definition: object.h:345
#define FLAG_KNOWN_CURSED
The object is known to be cursed.
Definition: define.h:308
#define FLAG_CURSED
The object is cursed.
Definition: define.h:304
See Player.
Definition: object.h:112
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
See Shield.
Definition: object.h:140
struct treasurelist * randomitems
Items to be generated.
Definition: object.h:395
sstring name_pl
The plural name of the object.
Definition: object.h:323
Object structure, the core of Crossfire.
void pray_at_altar(object *pl, object *altar, object *skill)
Player prays at altar.
Definition: gods.cpp:258
#define PREFER_HIGH
Definition: define.h:584
int cast_heal(object *op, object *caster, object *spell, int dir)
Heals something.
#define FREE_AND_COPY(sv, nv)
Release the shared string if not NULL, and make it a reference to nv.
Definition: global.h:206
treasure * next
Next treasure-item in a linked list.
Definition: treasure.h:69
Also see SKILL_TOOL (74) below.
Definition: object.h:148
void fix_generated_item(object *op, object *creator, int difficulty, int max_magic, int flags)
fix_generated_item(): This is called after an item is generated, in order to set it up right...
Definition: treasure.cpp:927
sstring name
The name of the object, obviously...
Definition: object.h:319
#define SCRIPT_FIX_ALL
Definition: global.h:380
sstring title
Of foo, etc.
Definition: object.h:325
static int follower_has_similar_item(object *op, object *item)
Checks for any occurrence of the given &#39;item&#39; in the inventory of &#39;op&#39; (recursively).
Definition: gods.cpp:169
void esrv_remove_spell(player *pl, object *spell)
Definition: request.cpp:1857
#define CLEAR_FLAG(xyz, p)
Definition: define.h:385
treasure * items
Items in this list, linked.
Definition: treasure.h:92
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:348
int tailor_god_spell(object *spellop, object *caster)
Changes the attributes of cone, smite, and ball spells as needed by the code.
Definition: gods.cpp:1223
#define FLAG_APPLIED
Object is ready for use by living.
Definition: define.h:222
treasurelist * find_treasurelist(const char *name)
Search for the given treasurelist by name.
Definition: assets.cpp:253
#define UPD_NAME
Definition: newclient.h:334
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
Definition: object.cpp:4484
object * inv
Pointer to the first object in the inventory.
Definition: object.h:298
static void stop_using_item(object *op, int type, int number)
Unapplies up to number worth of items of type type, ignoring curse status.
Definition: gods.cpp:621
#define FLAG_MAKE_INVIS
(Item) gives invisibility when applied
Definition: define.h:316
#define FLAG_STARTEQUIP
Object was given to player at start.
Definition: define.h:255
treasure is one element in a linked list, which together consist of a complete treasure-list.
Definition: treasure.h:63
Don&#39;t generate bad/cursed items.
Definition: treasure.h:34
int64_t exp
Experience.
Definition: living.h:47
sstring skill
Name of the skill this object uses/grants.
Definition: object.h:329
int16_t maxsp
Max spell points.
Definition: living.h:43
uint32_t attacktype
Bitmask of attacks this object does.
Definition: object.h:352
#define MSG_TYPE_SKILL
Messages related to skill use.
Definition: newclient.h:424
int events_execute_object_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
Execute an event on the specified object.
Definition: events.cpp:309
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
#define NDI_UNIQUE
Print immediately, don&#39;t buffer.
Definition: newclient.h:270
int32_t last_heal
Last healed.
Definition: object.h:367
See Gloves.
Definition: object.h:218
#define EVENT_APPLY
Object applied-unapplied.
Definition: events.h:28
int absdir(int d)
Computes an absolute direction.
Definition: object.cpp:3699
int32_t food
How much food in stomach.
Definition: living.h:48
StringBuffer * buf
Definition: readable.cpp:1563
Structure containing object statistics.
struct archetype * item
Which item this link can be.
Definition: treasure.h:64
int16_t maxhp
Max hit points.
Definition: living.h:41
#define SK_SUBTRACT_SKILL_EXP
Used when removing exp.
Definition: skills.h:81
static void remove_special_prayers(object *op, const object *god)
Removes special prayers given by a god.
Definition: gods.cpp:350
object * find_skill_by_number(object *who, int skillno)
This returns the first skill pointer of the given subtype (the one that accumulates exp...
Definition: main.cpp:375
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
See Breastplate Armor.
Definition: object.h:125
#define FLAG_REFL_MISSILE
Arrows will reflect from object.
Definition: define.h:260
void query_short_name(const object *op, char *buf, size_t size)
query_short_name(object) is similar to query_name(), but doesn&#39;t contain any information about object...
Definition: item.cpp:518
int16_t last_grace
As last_sp, except for grace.
Definition: object.h:369
object clone
An object from which to do object_copy()
Definition: object.h:487
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
Definition: define.h:693
void apply_anim_suffix(object *who, const char *suffix)
Applies a compound animation to an object.
Definition: anim.cpp:150
uint8_t personalized_blessings
If 1, blessed weapons get an owner and a willpower value.
Definition: global.h:313
int16_t hp
Hit Points.
Definition: living.h:40
uint32_t path_attuned
Paths the object is attuned to.
Definition: object.h:353
Generated items have the FLAG_STARTEQUIP.
Definition: treasure.h:33
int32_t last_eat
How long since we last ate.
Definition: object.h:366
Definition: object.h:229