Crossfire Server, Trunk  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 
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 
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 }
object::name_pl
sstring name_pl
The plural name of the object.
Definition: object.h:323
living::exp
int64_t exp
Experience.
Definition: living.h:47
PLAYER
@ PLAYER
Definition: object.h:112
object_get_owner
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
Definition: object.cpp:804
global.h
object_find_by_type_subtype
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Find object in inventory.
Definition: object.cpp:4301
settings
struct Settings settings
Server settings.
Definition: init.cpp:139
MSG_TYPE_SKILL_PRAY
#define MSG_TYPE_SKILL_PRAY
Praying related messages.
Definition: newclient.h:594
living::maxhp
int16_t maxhp
Max hit points.
Definition: living.h:41
object_find_by_type_applied
object * object_find_by_type_applied(const object *who, int type)
Find applied object in inventory.
Definition: object.cpp:4083
BOW
@ BOW
Definition: object.h:123
treasure::chance
uint8_t chance
Percent chance for this item.
Definition: treasure.h:73
llevError
@ llevError
Error, serious thing.
Definition: logger.h:11
follower_level_to_enchantments
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
find_skill_by_number
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::path_attuned
uint32_t path_attuned
Paths the object is attuned to.
Definition: object.h:353
WAND
@ WAND
Definition: object.h:225
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
GLOVES
@ GLOVES
Definition: object.h:218
object::inv
object * inv
Pointer to the first object in the inventory.
Definition: object.h:298
FLAG_STARTEQUIP
#define FLAG_STARTEQUIP
Object was given to player at start.
Definition: define.h:268
MSG_TYPE_SKILL
#define MSG_TYPE_SKILL
Messages related to skill use.
Definition: newclient.h:410
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
FLAG_REFL_MISSILE
#define FLAG_REFL_MISSILE
Arrows will reflect from object.
Definition: define.h:273
treasurelist::items
treasure * items
Items in this list, linked.
Definition: treasure.h:92
do_learn_spell
void do_learn_spell(object *op, object *spell, int special_prayer)
Actually makes op learn spell.
Definition: apply.cpp:484
FLAG_SEE_IN_DARK
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
Definition: define.h:337
determine_god
const char * determine_god(object *op)
Determines if op worships a god.
Definition: gods.cpp:55
object::item_power
int8_t item_power
Power rating of the object.
Definition: object.h:372
AT_PHYSICAL
#define AT_PHYSICAL
Definition: attack.h:76
object::arch
struct archetype * arch
Pointer to archetype.
Definition: object.h:424
absdir
int absdir(int d)
Computes an absolute direction.
Definition: object.cpp:3714
if
if(!(yy_init))
Definition: loader.cpp:36428
object::invisible
int16_t invisible
How much longer the object will be invis.
Definition: object.h:370
ARMOUR
@ ARMOUR
Definition: object.h:125
PREFER_LOW
#define PREFER_LOW
Definition: define.h:558
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
object::anim_suffix
sstring anim_suffix
Used to determine combined animations.
Definition: object.h:324
WEAPON
@ WEAPON
Definition: object.h:124
LOOSE_MANA
#define LOOSE_MANA
Definition: spells.h:162
find_treasurelist
treasurelist * find_treasurelist(const char *name)
Search for the given treasurelist by name.
Definition: assets.cpp:248
worship_forbids_use
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
SK_PRAYING
@ SK_PRAYING
Praying.
Definition: skills.h:49
MSG_TYPE_ATTRIBUTE
#define MSG_TYPE_ATTRIBUTE
Changes to attributes (stats, resistances, etc)
Definition: newclient.h:408
GT_ONLY_GOOD
@ GT_ONLY_GOOD
Don't generate bad/cursed items.
Definition: treasure.h:34
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
fix_generated_item
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:903
move_player
int move_player(object *op, int dir)
Move player in the given direction.
Definition: player.cpp:2965
SKILL
@ SKILL
Also see SKILL_TOOL (74) below.
Definition: object.h:148
object::last_grace
int16_t last_grace
As last_sp, except for grace.
Definition: object.h:369
NDI_NAVY
#define NDI_NAVY
Definition: newclient.h:247
remove_special_prayers
static void remove_special_prayers(object *op, const object *god)
Removes special prayers given by a god.
Definition: gods.cpp:350
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:17
HOLY_POSSESSION
#define HOLY_POSSESSION
Definition: spells.h:168
rndm
int rndm(int min, int max)
Returns a number between min and max.
Definition: utils.cpp:162
object::title
sstring title
Of foo, etc.
Definition: object.h:325
object_get_value
const char * object_get_value(const object *op, const char *const key)
Get an extra value by key.
Definition: object.cpp:4346
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
events_execute_object_event
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:308
GT_STARTEQUIP
@ GT_STARTEQUIP
Generated items have the FLAG_STARTEQUIP.
Definition: treasure.h:33
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:2857
HUGE_BUF
#define HUGE_BUF
Used for messages - some can be quite long.
Definition: define.h:37
MAX
#define MAX(x, y)
Definition: compat.h:24
object::resist
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:351
find_god
const object * find_god(const char *name)
Returns a god's object from its name.
Definition: holy.cpp:317
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
cast_magic_storm
void cast_magic_storm(object *op, object *tmp, int lvl)
This is really used mostly for spell fumbles and the like.
Definition: spell_effect.cpp:49
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
FLAG_ALIVE
#define FLAG_ALIVE
Object can fight (or be fought)
Definition: define.h:230
object::path_denied
uint32_t path_denied
Paths the object is denied access to.
Definition: object.h:355
object::path_repelled
uint32_t path_repelled
Paths the object is repelled from.
Definition: object.h:354
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:1560
object::contr
struct player * contr
Pointer to the player which control this object.
Definition: object.h:284
FMT64
#define FMT64
Definition: compat.h:16
pray_at_altar
void pray_at_altar(object *pl, object *altar, object *skill)
Player prays at altar.
Definition: gods.cpp:258
PREFER_HIGH
#define PREFER_HIGH
Definition: define.h:557
esrv_remove_spell
void esrv_remove_spell(player *pl, object *spell)
Definition: request.cpp:1812
cast_heal
int cast_heal(object *op, object *caster, object *spell, int dir)
Heals something.
Definition: spell_effect.cpp:1747
HELMET
@ HELMET
Definition: object.h:141
improve_weapon_magic
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
get_rand_god
const object * get_rand_god(void)
Returns a random god.
Definition: holy.cpp:73
object::last_heal
int32_t last_heal
Last healed.
Definition: object.h:367
treasure::name
sstring name
If non null, name of list to use instead.
Definition: treasure.h:66
object_present_in_ob_by_name
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:3203
query_name
void query_name(const object *op, char *buf, size_t size)
Describes an item.
Definition: item.cpp:588
FLAG_KNOWN_CURSED
#define FLAG_KNOWN_CURSED
The object is known to be cursed.
Definition: define.h:320
treasurelist
treasurelist represents one logical group of items to be generated together.
Definition: treasure.h:85
archetype::clone
object clone
An object from which to do object_copy()
Definition: object.h:487
add_string
sstring add_string(const char *str)
This will add 'str' to the hash table.
Definition: shstr.cpp:124
apply_anim_suffix
void apply_anim_suffix(object *who, const char *suffix)
Applies a compound animation to an object.
Definition: anim.cpp:150
ROD
@ ROD
Definition: object.h:114
random_roll64
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
query_short_name
void query_short_name(const object *op, char *buf, size_t size)
query_short_name(object) is similar to query_name(), but doesn't contain any information about object...
Definition: item.cpp:513
FLAG_BLIND
#define FLAG_BLIND
If set, object cannot see (visually)
Definition: define.h:336
MSG_TYPE_ITEM
#define MSG_TYPE_ITEM
Item related information.
Definition: newclient.h:415
SCRIPT_FIX_ALL
#define SCRIPT_FIX_ALL
Definition: global.h:387
AP_IGNORE_CURSE
#define AP_IGNORE_CURSE
Apply/unapply regardless of cursed/damned status.
Definition: define.h:576
FLAG_MAKE_INVIS
#define FLAG_MAKE_INVIS
(Item) gives invisibility when applied
Definition: define.h:328
object::last_eat
int32_t last_eat
How long since we last ate.
Definition: object.h:366
become_follower
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
FREE_AND_COPY
#define FREE_AND_COPY(sv, nv)
Release the shared string if not NULL, and make it a reference to nv.
Definition: global.h:206
object::type
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:348
FLAG_DAMNED
#define FLAG_DAMNED
The object is very cursed.
Definition: define.h:317
object::magic
int8_t magic
Any magical bonuses to this item.
Definition: object.h:358
treasure::item
struct archetype * item
Which item this link can be.
Definition: treasure.h:64
UPD_FLAGS
#define UPD_FLAGS
Definition: newclient.h:318
follower_has_similar_item
static int follower_has_similar_item(object *op, object *item)
Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively).
Definition: gods.cpp:169
FLAG_USE_SHIELD
#define FLAG_USE_SHIELD
Can this creature use a shield?
Definition: define.h:237
object_free
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects,...
Definition: object.cpp:1592
FOR_INV_FINISH
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
Definition: define.h:671
living::food
int32_t food
How much food in stomach.
Definition: living.h:48
change_exp
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Changes experience to a player/monster.
Definition: living.cpp:2179
archetype
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:483
get_god_for_race
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
ATNR_POISON
#define ATNR_POISON
Definition: attack.h:59
FLAG_USE_WEAPON
#define FLAG_USE_WEAPON
(Monster) can wield weapons
Definition: define.h:296
sproto.h
living::sp
int16_t sp
Spell points.
Definition: living.h:42
BOOK
@ BOOK
Definition: object.h:119
follower_remove_given_items
static void follower_remove_given_items(object *pl, object *op, const object *god)
Removes from a player's inventory all items bestowed by a particular god.
Definition: gods.cpp:133
random_roll
int random_roll(int min, int max, const object *op, int goodbad)
Roll a random number between min and max.
Definition: utils.cpp:42
object::race
sstring race
Human, goblin, dragon, etc.
Definition: object.h:326
object::facing
int8_t facing
Object is oriented/facing that way.
Definition: object.h:345
try_leave_cult
static bool try_leave_cult(object *pl, object *skill, int angry)
Try to leave a cult.
Definition: gods.cpp:232
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
treasure::next
treasure * next
Next treasure-item in a linked list.
Definition: treasure.h:69
MAX_BUF
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
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
free_string
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
Definition: shstr.cpp:280
ATNR_FIRE
#define ATNR_FIRE
Definition: attack.h:51
tailor_god_spell
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
living::maxgrace
int16_t maxgrace
Maximum grace.
Definition: living.h:45
MSG_TYPE_ITEM_ADD
#define MSG_TYPE_ITEM_ADD
Item added to inventory.
Definition: newclient.h:646
change_abil
int change_abil(object *op, object *tmp)
Permanently alters an object's stats/flags based on another object.
Definition: living.cpp:394
living::Wis
int8_t Wis
Definition: living.h:36
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:265
object::slaying
sstring slaying
Which race to do double damage to.
Definition: object.h:327
spells.h
object::name
sstring name
The name of the object, obviously...
Definition: object.h:319
FLAG_USE_ARMOUR
#define FLAG_USE_ARMOUR
(Monster) can wear armour/shield/helmet
Definition: define.h:295
MSG_TYPE_ITEM_REMOVE
#define MSG_TYPE_ITEM_REMOVE
Item removed from inv.
Definition: newclient.h:645
living::maxsp
int16_t maxsp
Max spell points.
Definition: living.h:43
create_archetype_by_object_name
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
exp_obj
struct obj * exp_obj
Definition: arch-handbook.txt:571
object::env
object * env
Pointer to the object which is the environment.
Definition: object.h:301
check_spell_known
object * check_spell_known(object *op, const char *name)
Checks to see if player knows the spell.
Definition: spell_util.cpp:394
object::last_sp
int32_t last_sp
As last_heal, but for spell points.
Definition: object.h:368
Settings::personalized_blessings
uint8_t personalized_blessings
If 1, blessed weapons get an owner and a willpower value.
Definition: global.h:314
object::skill
sstring skill
Name of the skill this object uses/grants.
Definition: object.h:329
MSG_TYPE_ATTRIBUTE_GOD
#define MSG_TYPE_ATTRIBUTE_GOD
changing god info
Definition: newclient.h:578
god_enchants_weapon
static int god_enchants_weapon(object *op, const object *god, object *tr, object *skill)
God wants to enchant weapon.
Definition: gods.cpp:821
esrv_update_item
void esrv_update_item(int flags, object *pl, object *op)
Updates object *op for player *pl.
Definition: main.cpp:359
SPELL_EFFECT
@ SPELL_EFFECT
Definition: object.h:220
object::msg
sstring msg
If this is a book/sign/magic mouth/etc.
Definition: object.h:330
NDI_WHITE
#define NDI_WHITE
Definition: newclient.h:246
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
god_examines_priest
static int god_examines_priest(object *op, const object *god)
Checks and maybe punishes someone praying.
Definition: gods.cpp:1135
SK_SUBTRACT_SKILL_EXP
#define SK_SUBTRACT_SKILL_EXP
Used when removing exp.
Definition: skills.h:81
god_intervention
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
apply_special
int apply_special(object *who, object *op, int aflags)
Apply an object.
Definition: apply.cpp:1156
god_removes_curse
static int god_removes_curse(object *op, int remove_damnation)
God helps player by removing curse and/or damnation.
Definition: gods.cpp:724
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
level
int level
Definition: readable.cpp:1563
UPD_NAME
#define UPD_NAME
Definition: newclient.h:321
update_priest_flag
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
object::randomitems
struct treasurelist * randomitems
Items to be generated.
Definition: object.h:395
AT_GODPOWER
#define AT_GODPOWER
Definition: attack.h:96
get_archetype_by_type_subtype
archetype * get_archetype_by_type_subtype(int type, int subtype)
Retrieves an archetype by type and subtype.
Definition: arch.cpp:97
skill
skill
Definition: arch-handbook.txt:585
object_remove
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:1833
cast_change_ability
int cast_change_ability(object *op, object *caster, object *spell_ob, int dir, int silent)
Cast some stat-improving spell.
Definition: spell_effect.cpp:1902
remove_depletion
int remove_depletion(object *op, int level)
Remove depletion from op, if present, and warn player of such restorations.
Definition: living.cpp:755
MSG_TYPE_ITEM_CHANGE
#define MSG_TYPE_ITEM_CHANGE
Item has changed in some way.
Definition: newclient.h:647
determine_holy_arch
archetype * determine_holy_arch(const object *god, const char *type)
Determines the archetype for holy servant and god avatar.
Definition: gods.cpp:676
ATNR_COLD
#define ATNR_COLD
Definition: attack.h:53
archetype::name
sstring name
More definite name, like "generate_kobold".
Definition: object.h:484
FLAG_XRAYS
#define FLAG_XRAYS
X-ray vision.
Definition: define.h:300
living::grace
int16_t grace
Grace.
Definition: living.h:44
object::stats
living stats
Str, Con, Dex, etc.
Definition: object.h:378
treasure
treasure is one element in a linked list, which together consist of a complete treasure-list.
Definition: treasure.h:63
GT_UPDATE_INV
@ GT_UPDATE_INV
When object has been generated, send its information to player.
Definition: treasure.h:35
object_set_value
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:4499
same_string
static int same_string(const char *s1, const char *s2)
Compares 2 strings.
Definition: gods.cpp:111
AP_UNAPPLY
#define AP_UNAPPLY
Item is to be remvoed.
Definition: define.h:569
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
BOOTS
@ BOOTS
Definition: object.h:217
MAX_WEAPON_ITEM_POWER
#define MAX_WEAPON_ITEM_POWER
Maximum item power an item can have.
Definition: define.h:453
TRUE
#define TRUE
Definition: compat.h:11
ATNR_ELECTRICITY
#define ATNR_ELECTRICITY
Definition: attack.h:52
AT_HOLYWORD
#define AT_HOLYWORD
Definition: attack.h:97
SPELL
@ SPELL
Definition: object.h:219
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
god_gives_present
static int god_gives_present(object *op, const object *god, treasure *tr)
God gives an item to the player.
Definition: gods.cpp:195
player_unready_range_ob
void player_unready_range_ob(player *pl, object *ob)
Unready an object for a player.
Definition: player.cpp:4470
SHIELD
@ SHIELD
Definition: object.h:140
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
living.h
SPELLBOOK
@ SPELLBOOK
Definition: object.h:208
MSG_TYPE_ITEM_INFO
#define MSG_TYPE_ITEM_INFO
Information related to items.
Definition: newclient.h:648
FOR_INV_PREPARE
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
Definition: define.h:664
living::hp
int16_t hp
Hit Points.
Definition: living.h:40
create_treasure
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
This calls the appropriate treasure creation function.
Definition: treasure.cpp:263
living::luck
int8_t luck
Affects thaco and ac from time to time.
Definition: living.h:39
FORCE
@ FORCE
Definition: object.h:229
object.h
god_examines_item
static int god_examines_item(const object *god, object *item)
God checks item the player is using.
Definition: gods.cpp:1182
stop_using_item
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
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
EVENT_APPLY
#define EVENT_APPLY
Object applied-unapplied.
Definition: events.h:20