Crossfire Server, Trunk  R20590
gods.c
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 const char *get_god_for_race(const char *race);
42 static void remove_special_prayers(object *op, const object *god);
43 
54 static int lookup_god_by_name(const char *name) {
55  int godnr = -1;
56  size_t nmlen = strlen(name);
57 
58  if (name && strcmp(name, "none")) {
59  godlink *gl;
60  for (gl = first_god; gl; gl = gl->next)
61  if (!strncmp(name, gl->name, MIN(strlen(gl->name), nmlen)))
62  break;
63  if (gl)
64  godnr = gl->id;
65  }
66  return godnr;
67 }
68 
80 const object *find_god(const char *name) {
81  godlink *gl;
82 
83  if (!name)
84  return NULL;
85 
86  for (gl = first_god; gl; gl = gl->next) {
87  if (!strcmp(name, gl->name))
88  return pntr_to_god_obj(gl);
89  }
90 
91  return NULL;
92 }
93 
106 const char *determine_god(object *op) {
107  int godnr = -1;
108  const char *godname;
109 
110  /* spells */
111  if ((op->type == SPELL || op->type == SPELL_EFFECT)
112  && op->title) {
113  if (lookup_god_by_name(op->title) >= 0)
114  return op->title;
115  }
116 
117  if (op->type != PLAYER && QUERY_FLAG(op, FLAG_ALIVE)) {
118  /* find a god based on race */
119  if (!op->title) {
120  if (op->race != NULL) {
121  godname = get_god_for_race(op->race);
122  if (godname != NULL) {
123  op->title = add_string(godname);
124  }
125  }
126  }
127 
128  /* find a random god */
129  if (!op->title) {
130  godlink *gl = first_god;
131 
132  godnr = rndm(1, gl->id);
133  while (gl) {
134  if (gl->id == godnr)
135  {
136  // This used to be after the loop, but if we do not find a god,
137  // it would have made a null pointer dereference. Moved here
138  // for better clarity and (hopefully) fewer bugs.
139  // SilverNexus 2018-01-17
140  op->title = add_string(gl->name);
141 
142  break;
143  }
144  gl = gl->next;
145  }
146  }
147 
148  return op->title;
149  }
150 
151  /* The god the player worships is in the praying skill (native skill
152  * not skill tool). Since a player can only have one instance of
153  * that skill, once we find it, we can return, either with the
154  * title or "none".
155  */
156  if (op->type == PLAYER) {
157  object *tmp;
158 
160  if (tmp != NULL) {
161  return tmp->title != NULL ? tmp->title : "none";
162  }
163  }
164  return ("none");
165 }
166 
175 static int same_string(const char *s1, const char *s2) {
176  if (s1 == NULL)
177  return s2 == NULL;
178  else
179  return s2 != NULL && strcmp(s1, s2) == 0;
180 }
181 
197 static void follower_remove_given_items(object *pl, object *op, const object *god) {
198  const char *given_by;
199 
200  /* search the inventory */
201  FOR_INV_PREPARE(op, tmp) {
202  given_by = object_get_value(tmp, "divine_giver_name");
203  if (given_by == god->name) {
204  char name[HUGE_BUF];
205 
206  query_short_name(tmp, name, HUGE_BUF);
207  /* Send the client a message. */
208  if (tmp->nrof > 1)
210  "The %s crumble to dust!",
211  name);
212  else
214  "The %s crumbles to dust!",
215  name);
216 
217  object_remove(tmp); /* remove obj from players inv. */
219  } else if (tmp->inv)
220  follower_remove_given_items(pl, tmp, god);
221  } FOR_INV_FINISH();
222 }
223 
233 static int follower_has_similar_item(object *op, object *item) {
234  FOR_INV_PREPARE(op, tmp) {
235  if (tmp->type == item->type
236  && same_string(tmp->name, item->name)
237  && same_string(tmp->title, item->title)
238  && tmp->msg == item->msg
239  && same_string(tmp->slaying, item->slaying))
240  return 1;
241  if (tmp->inv && follower_has_similar_item(tmp, item))
242  return 1;
243  } FOR_INV_FINISH();
244  return 0;
245 }
246 
259 static int god_gives_present(object *op, const object *god, treasure *tr) {
260  object *tmp;
261  char name[HUGE_BUF];
262 
263  if (follower_has_similar_item(op, &tr->item->clone))
264  return 0;
265 
266  tmp = arch_to_object(tr->item);
267 
268  /*
269  * Give inventory if needed, for instance Lythander's pipe.
270  * Use high level and magic so something IS put in inventory.
271  */
272  fix_generated_item(tmp, NULL, 120, 120, GT_ONLY_GOOD);
273 
274  /* And just in case nothing was put and something is needed, bail out. */
275  if ((tmp->type == ROD || tmp->type == WAND) && (tmp->inv == NULL)) {
276  object_free2(tmp, 0);
277  return 0;
278  }
279 
280  query_short_name(tmp, name, HUGE_BUF);
282  "%s lets %s appear in your hands.",
283  god->name, name);
287  object_set_value(tmp, "divine_giver_name", god->name, TRUE);
288  object_insert_in_ob(tmp, op);
289  return 1;
290 }
291 
303 void pray_at_altar(object *pl, object *altar, object *skill) {
304  const object *pl_god = find_god(determine_god(pl));
305 
306  /* Lauwenmark: Handle for plugin altar-praying (apply) event */
307  if (execute_event(altar, EVENT_APPLY, pl, NULL, NULL, SCRIPT_FIX_ALL) != 0)
308  return;
309 
310  /* If non consecrate altar, don't do anything */
311  if (!altar->other_arch)
312  return;
313 
314  /* hmm. what happend depends on pl's current god, level, etc */
315  if (!pl_god) { /*new convert */
316  become_follower(pl, &altar->other_arch->clone);
317  return;
318  }
319 
320  if (!strcmp(pl_god->name, altar->other_arch->clone.name)) {
321  /* pray at your gods altar */
322  int bonus = (pl->stats.Wis+skill->level)/10;
323 
324  /* we can get neg grace up faster */
325  if (pl->stats.grace < 0)
326  pl->stats.grace += (bonus > -1*(pl->stats.grace/10) ? bonus : -1*(pl->stats.grace/10));
327  /* we can super-charge grace to 2x max */
328  if (pl->stats.grace < (2*pl->stats.maxgrace)) {
329  pl->stats.grace += bonus/2;
330  }
331  if (pl->stats.grace > (2*pl->stats.maxgrace)) {
332  pl->stats.grace = (2*pl->stats.maxgrace);
333  }
334 
335  /* Every once in a while, the god decides to checkup on their
336  * follower, and may intervene to help them out.
337  */
338  bonus = MAX(1, bonus+MAX(pl->stats.luck, -3)); /* -- DAMN -- */
339 
340  if (((random_roll(0, 399, pl, PREFER_LOW))-bonus) < 0)
341  god_intervention(pl, pl_god, skill, altar);
342  } else { /* praying to another god! */
343  uint64_t loss = 0;
344  int angry = 1;
345 
346  /* I believe the logic for detecting opposing gods was completely
347  * broken - I think it should work now. altar->other_arch
348  * points to the god of this altar (which we have
349  * already verified is non null). pl_god->other_arch
350  * is the opposing god - we need to verify that exists before
351  * using its values.
352  */
353  if (pl_god->other_arch
354  && (altar->other_arch->name == pl_god->other_arch->name)) {
355  angry = 2;
356  if (random_roll(0, skill->level+2, pl, PREFER_LOW)-5 > 0) {
357  object *tmp;
358 
359  /* you really screwed up */
360  angry = 3;
362  "Foul Priest! %s punishes you!",
363  pl_god->name);
365  cast_magic_storm(pl, tmp, pl_god->level+20);
366  } else
368  "Foolish heretic! %s is livid!",
369  pl_god->name);
370  } else
372  "Heretic! %s is angered!",
373  pl_god->name);
374 
375  /* whether we will be successfull in defecting or not -
376  * we lose experience from the clerical experience obj
377  */
378 
379  loss = angry*(skill->stats.exp/10);
380  if (loss)
381  change_exp(pl, -random_roll64(0, loss, pl, PREFER_LOW), skill ? skill->skill : "none", SK_SUBTRACT_SKILL_EXP);
382 
383  /* May switch Gods, but its random chance based on our current level
384  * note it gets harder to swap gods the higher we get
385  */
386  if ((angry == 1) && !(random_roll(0, skill->level, pl, PREFER_LOW))) {
387  if (become_follower(pl, &altar->other_arch->clone))
388  remove_special_prayers(pl, pl_god);
389  } else {
390  /* toss this player off the altar. He can try again. */
392  "A divine force pushes you off the altar.");
393 
394  move_player(pl, absdir(pl->facing+4)); /* back him off the way he came. */
395  }
396  }
397 }
398 
409 static void remove_special_prayers(object *op, const object *god) {
410  treasure *tr;
411  int remove = 0;
412 
413  if (god->randomitems == NULL) {
414  LOG(llevError, "BUG: remove_special_prayers(): god %s without randomitems\n", god->name);
415  return;
416  }
417 
418 
419  /* Outer loop iterates over all special prayer marks */
420  FOR_INV_PREPARE(op, tmp) {
421  /* we mark special prayers with the STARTEQUIP flag, so if it isn't
422  * in that category, not something we need to worry about.
423  */
424  if (tmp->type != SPELL || !QUERY_FLAG(tmp, FLAG_STARTEQUIP))
425  continue;
426 
427  /* Inner loop tries to find the special prayer in the god's treasure
428  * list. We default that the spell should not be removed.
429  */
430  remove = 0;
431  for (tr = god->randomitems->items; tr; tr = tr->next) {
432  if (tr->item == NULL)
433  continue;
434 
435  /* Basically, see if the matching spell is granted by this god. */
436 
437  if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) {
438  remove = 1;
439  break;
440  }
441  }
442  if (remove) {
443  /* just do the work of removing the spell ourselves - we already
444  * know that the player knows the spell
445  */
448  "You lose knowledge of %s.",
449  tmp->name);
450  player_unready_range_ob(op->contr, tmp);
451  object_remove(tmp);
453  }
454  } FOR_INV_FINISH();
455 }
456 
473 int become_follower(object *op, const object *new_god) {
474  const object *old_god = NULL; /* old god */
475  treasure *tr;
476  object *skop;
477  int i, sk_applied;
478  int undeadified = 0; /* Turns to true if changing god can changes the undead
479  * status of the player.*/
480  old_god = find_god(determine_god(op));
481 
482  /* take away any special god-characteristic items. */
483  FOR_INV_PREPARE(op, item) {
484  /* remove all invisible startequip items which are
485  * not skill, exp or force
486  */
487  if (QUERY_FLAG(item, FLAG_STARTEQUIP)
488  && item->invisible
489  && (item->type != SKILL)
490  && (item->type != FORCE)
491  && (item->type != SPELL)) {
492  player_unready_range_ob(op->contr, item);
493  object_remove(item);
495  }
496  } FOR_INV_FINISH();
497 
498  /* remove any items given by the old god */
499  if (old_god) {
500  /* Changed to use the new "divine_giver_name" key_value
501  * so it can reliably delete enchanted items. Now it loops
502  * through the player's inventory, instead of the god's
503  * treasure list.
504  */
505  follower_remove_given_items(op, op, old_god);
506  }
507 
508  if (!op || !new_god)
509  return 0;
510 
511  if (op->race && new_god->slaying && strstr(op->race, new_god->slaying)) {
513  "Fool! %s detests your kind!",
514  new_god->name);
515  if (random_roll(0, op->level-1, op, PREFER_LOW)-5 > 0) {
516  object *tmp = create_archetype(LOOSE_MANA);
517  cast_magic_storm(op, tmp, new_god->level+10);
518  }
519  return 0;
520  }
521 
522  /* give the player any special god-characteristic-items. */
523  for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) {
524  if (tr->item
525  && tr->item->clone.invisible
526  && tr->item->clone.type != SPELLBOOK
527  && tr->item->clone.type != BOOK
528  && tr->item->clone.type != SPELL)
529  god_gives_present(op, new_god, tr);
530  }
531 
533  "You become a follower of %s!",
534  new_god->name);
535 
537  /* Player has no skill - give them the skill */
538  if (!skop) {
539  /* The archetype should always be defined - if we crash here because it doesn't,
540  * things are really messed up anyways.
541  */
543  link_player_skills(op);
544  }
545 
546  sk_applied = QUERY_FLAG(skop, FLAG_APPLIED); /* save skill status */
547 
548  /* Clear the "undead" status. We also need to force a call to change_abil,
549  * so I set undeadified for that.
550  * - gros, 21th July 2006.
551  */
552  if ((old_god) && (QUERY_FLAG(old_god, FLAG_UNDEAD))) {
553  CLEAR_FLAG(skop, FLAG_UNDEAD);
554  undeadified = 1;
555  }
556 
557  if (skop->title) { /* get rid of old god */
559  "%s's blessing is withdrawn from you.",
560  skop->title);
561 
562  /* The point of this is to really show what abilities the player just lost */
563  if (sk_applied || undeadified) {
564  CLEAR_FLAG(skop, FLAG_APPLIED);
565  (void)change_abil(op, skop);
566  }
567  free_string(skop->title);
568  }
569 
570  /* now change to the new gods attributes to exp_obj */
571  skop->title = add_string(new_god->name);
572  skop->path_attuned = new_god->path_attuned;
573  skop->path_repelled = new_god->path_repelled;
574  skop->path_denied = new_god->path_denied;
575  /* copy god's resistances */
576  memcpy(skop->resist, new_god->resist, sizeof(new_god->resist));
577 
578  /* make sure that certain immunities do NOT get passed
579  * to the follower!
580  */
581  for (i = 0; i < NROFATTACKS; i++)
582  if (skop->resist[i] > 30
583  && (i == ATNR_FIRE || i == ATNR_COLD || i == ATNR_ELECTRICITY || i == ATNR_POISON))
584  skop->resist[i] = 30;
585 
586  skop->stats.hp = (int16_t)new_god->last_heal;
587  skop->stats.sp = (int16_t)new_god->last_sp;
588  skop->stats.grace = (int16_t)new_god->last_grace;
589  skop->stats.food = (int16_t)new_god->last_eat;
590  skop->stats.luck = (int8_t)new_god->stats.luck;
591  /* gods may pass on certain flag properties */
592  update_priest_flag(new_god, skop, FLAG_SEE_IN_DARK);
593  update_priest_flag(new_god, skop, FLAG_REFL_SPELL);
594  update_priest_flag(new_god, skop, FLAG_REFL_MISSILE);
595  update_priest_flag(new_god, skop, FLAG_STEALTH);
596  update_priest_flag(new_god, skop, FLAG_MAKE_INVIS);
597  update_priest_flag(new_god, skop, FLAG_UNDEAD);
598  update_priest_flag(new_god, skop, FLAG_BLIND);
599  update_priest_flag(new_god, skop, FLAG_XRAYS); /* better have this if blind! */
600  update_priest_flag(new_god, skop, FLAG_USE_WEAPON);
601  update_priest_flag(new_god, skop, FLAG_USE_ARMOUR);
602  update_priest_flag(new_god, skop, FLAG_USE_SHIELD);
603 
605  "You are bathed in %s's aura.",
606  new_god->name);
607 
608  /* Weapon/armour use are special...handle flag toggles here as this can
609  * only happen when gods are worshipped and if the new priest could
610  * have used armour/weapons in the first place.
611  *
612  * This also can happen for monks which cannot use weapons. In this case
613  * do not allow to use weapons even if the god otherwise would allow it.
614  */
615  if (!object_present_in_ob_by_name(FORCE, "no weapon force", op)) {
616  if (worship_forbids_use(op, skop, FLAG_USE_WEAPON, "weapons"))
617  stop_using_item(op, WEAPON, 2);
618  }
619  update_priest_flag(new_god, skop, FLAG_USE_ARMOUR);
620 
621  if (worship_forbids_use(op, skop, FLAG_USE_ARMOUR, "armour")) {
622  stop_using_item(op, ARMOUR, 1);
623  stop_using_item(op, HELMET, 1);
624  stop_using_item(op, BOOTS, 1);
625  stop_using_item(op, GLOVES, 1);
626  }
627 
628  if (worship_forbids_use(op, skop, FLAG_USE_SHIELD, "shield"))
629  stop_using_item(op, SHIELD, 1);
630 
631  SET_FLAG(skop, FLAG_APPLIED);
632  (void)change_abil(op, skop);
633 
634  /* return to previous skill status */
635  if (!sk_applied)
636  CLEAR_FLAG(skop, FLAG_APPLIED);
637 
638  // check is now done after converting
639  //remove_special_prayers(op, new_god);
640 
641  return 1;
642 }
643 
657 static int worship_forbids_use(object *op, object *exp_obj, uint32_t flag, const char *string) {
658  if (QUERY_FLAG(&op->arch->clone, flag)) {
659  if (QUERY_FLAG(op, flag) != QUERY_FLAG(exp_obj, flag)) {
660  update_priest_flag(exp_obj, op, flag);
661  if (QUERY_FLAG(op, flag))
663  "You may use %s again.",
664  string);
665  else {
667  "You are forbidden to use %s.",
668  string);
669  return 1;
670  }
671  }
672  }
673  return 0;
674 }
675 
687 static void stop_using_item(object *op, int type, int number) {
688  FOR_INV_PREPARE(op, tmp)
689  if (tmp->type == type && QUERY_FLAG(tmp, FLAG_APPLIED)) {
691  number--;
692  if (number <= 0)
693  break;
694  }
695  FOR_INV_FINISH();
696 }
697 
710 static void update_priest_flag(const object *god, object *exp_ob, uint32_t flag) {
711  if (QUERY_FLAG(god, flag) && !QUERY_FLAG(exp_ob, flag))
712  SET_FLAG(exp_ob, flag);
713  else if (QUERY_FLAG(exp_ob, flag) && !QUERY_FLAG(god, flag)) {
714  /* When this is called with the exp_ob set to the player,
715  * this check is broken, because most all players arch
716  * allow use of weapons. I'm not actually sure why this
717  * check is here - I guess if you had a case where the
718  * value in the archetype (wisdom) should over ride the restrictions
719  * the god places on it, this may make sense. But I don't think
720  * there is any case like that.
721  */
722 
723 /* if (!(QUERY_FLAG(&(exp_ob->arch->clone), flag)))*/
724  CLEAR_FLAG(exp_ob, flag);
725  }
726 }
727 
728 
742 archetype *determine_holy_arch(const object *god, const char *type) {
743  treasure *tr;
744  int count;
745  object *item;
746 
747  if (!god || !god->randomitems) {
748  LOG(llevError, "BUG: determine_holy_arch(): no god or god without randomitems\n");
749  return NULL;
750  }
751 
752  count = 0;
753  for (tr = god->randomitems->items; tr != NULL; tr = tr->next) {
754  if (!tr->item)
755  continue;
756  item = &tr->item->clone;
757  if (item->type == BOOK && item->invisible && item->name == type)
758  count++;
759  }
760  if (count == 0) {
761  return NULL;
762  }
763 
764  count = rndm(1, count);
765 
766  for (tr = god->randomitems->items; tr != NULL; tr = tr->next) {
767  if (!tr->item)
768  continue;
769  item = &tr->item->clone;
770  if (item->type == BOOK && item->invisible && item->name == type) {
771  count--;
772  if (count == 0)
773  return item->other_arch;
774  }
775  }
776 
777  return NULL;
778 }
779 
790 static int god_removes_curse(object *op, int remove_damnation) {
791  int success = 0;
792 
793  FOR_INV_PREPARE(op, tmp) {
794  if (tmp->invisible)
795  continue;
796  if (QUERY_FLAG(tmp, FLAG_DAMNED) && !remove_damnation)
797  continue;
798  if (QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED)) {
799  success = 1;
800  CLEAR_FLAG(tmp, FLAG_DAMNED);
801  CLEAR_FLAG(tmp, FLAG_CURSED);
803  if (op->type == PLAYER)
804  esrv_update_item(UPD_FLAGS, op, tmp);
805  }
806  } FOR_INV_FINISH();
807 
808  if (success)
810  "You feel like someone is helping you.");
811  return success;
812 }
813 
823 static int follower_level_to_enchantments(int level, int difficulty) {
824  if (difficulty < 1) {
825  LOG(llevError, "follower_level_to_enchantments(): difficulty %d is invalid\n", difficulty);
826  return 0;
827  }
828 
829  if (level <= 20)
830  return level/difficulty;
831  if (level <= 40)
832  return (20+(level-20)/2)/difficulty;
833  return (30+(level-40)/4)/difficulty;
834 }
835 
854 static int improve_weapon_magic(object *op, object *tr, object *weapon, object *skill) {
855  int tmp = follower_level_to_enchantments(skill->level, tr->level);
856 
857  if (weapon->magic < tmp) {
859  "A phosphorescent glow envelops your weapon!");
860  weapon->magic++;
861  if (op->type == PLAYER)
862  esrv_update_item(UPD_NAME, op, weapon);
863  weapon->item_power++;
864  return 1;
865  }
866 
867  return 0;
868 }
869 
887 static int god_enchants_weapon(object *op, const object *god, object *tr, object *skill) {
888  char buf[MAX_BUF];
889  object *weapon;
890  uint32_t attacktype;
891 
892  weapon = object_find_by_type_applied(op, WEAPON);
893  if (weapon == NULL)
894  weapon = object_find_by_type_applied(op, BOW);
895  if (weapon == NULL || god_examines_item(god, weapon) <= 0)
896  return 0;
897 
898  if (weapon->item_power >= MAX_WEAPON_ITEM_POWER) {
900  "%s considers your %s is not worthy to be enchanted any more.",
901  god->name,
902  weapon->name);
903  return 0;
904  }
905 
906  /* If personalized_blessings is activated, then the god's name is
907  * associated with the weapon, as well as the owner (the one who blesses it),
908  * and a "weapon willpower", which is equivalent to the owner's experience
909  * in praying when the weapon is blessed.
910  * Those values are used later, when another player attempts to wield the
911  * weapon - nasty things may happen to those who do not deserve to use it ! :)
912  */
914  const char *divine_owner = object_get_value(weapon, "divine_blessing_name");
915  const char *owner = object_get_value(weapon, "item_owner");
916  object *skillop = NULL;
917 
918  if (divine_owner != NULL && strcmp(divine_owner, god->name) != 0) {
919  /* Huho... Another god already blessed this one ! */
921  "Your %s already belongs to %s !",
922  weapon->name, divine_owner);
923  return 0;
924  }
925 
926  if ((owner != NULL) && (strcmp(owner, op->name) != 0)) {
927  /* Maybe the weapon itself will not agree ? */
929  "The %s is not yours, and is magically protected against such changes !",
930  weapon->name);
931  return 0;
932  }
933  skillop = find_skill_by_number(op, SK_PRAYING);
934  if (skillop == NULL) {
935  LOG(llevError, "god_enchants_weapon: no praying skill object found ?!\n");
936  snprintf(buf, sizeof(buf), "%d", 1);
937  } else
938  snprintf(buf, sizeof(buf), "%"FMT64, skillop->stats.exp);
939  object_set_value(weapon, "divine_blessing_name", god->name, TRUE);
940  object_set_value(weapon, "item_owner", op->name, TRUE);
941  object_set_value(weapon, "item_willpower", buf, TRUE);
942  }
943 
944  /* First give it a title, so other gods won't touch it */
945  if (!weapon->title) {
946  snprintf(buf, sizeof(buf), "of %s", god->name);
947  weapon->title = add_string(buf);
948  if (op->type == PLAYER)
949  esrv_update_item(UPD_NAME, op, weapon);
951  "Your weapon quivers as if struck!");
952  }
953 
954  /* Allow the weapon to slay enemies */
955  if (!weapon->slaying && god->slaying) {
956  weapon->slaying = add_string(god->slaying);
958  "Your %s now hungers to slay enemies of your god!",
959  weapon->name);
960  weapon->item_power++;
961  return 1;
962  }
963 
964  /* Add the gods attacktype */
965  attacktype = (weapon->attacktype == 0) ? AT_PHYSICAL : weapon->attacktype;
966  if ((attacktype&god->attacktype) != god->attacktype) {
968  "Your weapon suddenly glows!");
969  weapon->attacktype = attacktype|god->attacktype;
970  weapon->item_power++;
971  return 1;
972  }
973 
974  /* Higher magic value */
975  return improve_weapon_magic(op, tr, weapon, skill);
976 }
977 
993 static void god_intervention(object *op, const object *god, object *skill, object *altar) {
994  treasure *tr;
995 
996  if (!god || !god->randomitems) {
997  LOG(llevError, "BUG: god_intervention(): no god or god without randomitems\n");
998  return;
999  }
1000 
1001  // removed on 2009-12-12 because the function now removes prayers NOT from god.
1002  //remove_special_prayers(op, god);
1003 
1004  /* lets do some checks of whether we are kosher with our god */
1005  if (god_examines_priest(op, god) < 0)
1006  return;
1007 
1009  "You feel a holy presence!");
1010 
1011  if (altar->anim_suffix != NULL)
1012  apply_anim_suffix(altar, altar->anim_suffix);
1013 
1014  for (tr = god->randomitems->items; tr != NULL; tr = tr->next) {
1015  object *item;
1016 
1017  if (tr->chance <= random_roll(0, 99, op, PREFER_HIGH))
1018  continue;
1019 
1020  /* Treasurelist - generate some treasure for the follower */
1021  if (tr->name) {
1022  treasurelist *tl = find_treasurelist(tr->name);
1023  if (tl == NULL)
1024  continue;
1025 
1027  "Something appears before your eyes. You catch it before it falls to the ground.");
1028 
1030  return;
1031  }
1032 
1033  if (!tr->item) {
1034  LOG(llevError, "BUG: empty entry in %s's treasure list\n", god->name);
1035  continue;
1036  }
1037  item = &tr->item->clone;
1038 
1039  /* Grace limit */
1040  if (item->type == BOOK && item->invisible
1041  && strcmp(item->name, "grace limit") == 0) {
1042  if (op->stats.grace < item->stats.grace
1043  || op->stats.grace < op->stats.maxgrace) {
1044  object *tmp;
1045 
1046  /* Follower lacks the required grace for the following
1047  * treasure list items. */
1048 
1050  cast_change_ability(op, op, tmp, 0, 1);
1052  return;
1053  }
1054  continue;
1055  }
1056 
1057  /* Restore grace */
1058  if (item->type == BOOK && item->invisible
1059  && strcmp(item->name, "restore grace") == 0) {
1060  if (op->stats.grace >= 0)
1061  continue;
1062  op->stats.grace = random_roll(0, 9, op, PREFER_HIGH);
1064  "You are returned to a state of grace.");
1065  return;
1066  }
1067 
1068  /* Heal damage */
1069  if (item->type == BOOK && item->invisible
1070  && strcmp(item->name, "restore hitpoints") == 0) {
1071  if (op->stats.hp >= op->stats.maxhp)
1072  continue;
1074  "A white light surrounds and heals you!");
1075  op->stats.hp = op->stats.maxhp;
1076  return;
1077  }
1078 
1079  /* Restore spellpoints */
1080  if (item->type == BOOK
1081  && item->invisible
1082  && strcmp(item->name, "restore spellpoints") == 0) {
1083  int max = op->stats.maxsp*(item->stats.maxsp/100.0);
1084  /* Restore to 50 .. 100%, if sp < 50% */
1085  int new_sp = random_roll(1000, 1999, op, PREFER_HIGH)/2000.0*max;
1086  if (op->stats.sp >= max/2)
1087  continue;
1089  "A blue lightning strikes your head but doesn't hurt you!");
1090  op->stats.sp = new_sp;
1091  }
1092 
1093  /* Various heal spells */
1094  if (item->type == BOOK && item->invisible
1095  && strcmp(item->name, "heal spell") == 0) {
1096  object *tmp;
1097  int success;
1098 
1100 
1101  success = cast_heal(op, op, tmp, 0);
1103  if (success)
1104  return;
1105 
1106  continue;
1107  }
1108 
1109  /* Remove curse */
1110  if (item->type == BOOK && item->invisible
1111  && strcmp(item->name, "remove curse") == 0) {
1112  if (god_removes_curse(op, 0))
1113  return;
1114 
1115  continue;
1116  }
1117 
1118  /* Remove damnation */
1119  if (item->type == BOOK && item->invisible
1120  && strcmp(item->name, "remove damnation") == 0) {
1121  if (god_removes_curse(op, 1))
1122  return;
1123 
1124  continue;
1125  }
1126 
1127  /* Heal depletion */
1128  if (item->type == BOOK && item->invisible
1129  && strcmp(item->name, "heal depletion") == 0) {
1130  object *depl;
1131  archetype *at;
1132  int i;
1133 
1134  if ((at = find_archetype(ARCH_DEPLETION)) == NULL) {
1135  continue;
1136  }
1137  depl = arch_present_in_ob(at, op);
1138  if (depl == NULL)
1139  continue;
1141  "Shimmering light surrounds and restores you!");
1142  for (i = 0; i < NUM_STATS; i++)
1143  if (get_attr_value(&depl->stats, i))
1146  restore_msg[i]);
1147  object_remove(depl);
1149  fix_object(op);
1150  return;
1151  }
1152 
1153  /* Voices */
1154  if (item->type == BOOK && item->invisible
1155  && strcmp(item->name, "voice_behind") == 0) {
1157  "You hear a voice from behind you, but you don't dare to "
1158  "turn around:");
1160  item->msg);
1161  return;
1162  }
1163 
1164  /* Messages */
1165  if (item->type == BOOK && item->invisible
1166  && strcmp(item->name, "message") == 0) {
1168  item->msg);
1169  return;
1170  }
1171 
1172  /* Enchant weapon */
1173  if (item->type == BOOK && item->invisible
1174  && strcmp(item->name, "enchant weapon") == 0) {
1175  if (god_enchants_weapon(op, god, item, skill))
1176  return;
1177 
1178  continue;
1179  }
1180 
1181  /* Spellbooks - works correctly only for prayers */
1182  if (item->type == SPELL) {
1183  if (check_spell_known(op, item->name))
1184  continue;
1185  if (item->level > skill->level)
1186  continue;
1187 
1189  "%s grants you use of a special prayer!",
1190  god->name);
1191  do_learn_spell(op, item, 1);
1192  return;
1193  }
1194 
1195  /* Other gifts */
1196  if (!item->invisible) {
1197  if (god_gives_present(op, god, tr))
1198  return;
1199 
1200  continue;
1201  }
1202  /* else ignore it */
1203  }
1204 
1206  "You feel rapture.");
1207 }
1208 
1221 static int god_examines_priest(object *op, const object *god) {
1222  int reaction = 1;
1223  object *skop;
1224 
1225  FOR_INV_PREPARE(op, item)
1226  if (QUERY_FLAG(item, FLAG_APPLIED)) {
1227  reaction += god_examines_item(god, item)*(item->magic ? abs(item->magic) : 1);
1228  }
1229  FOR_INV_FINISH();
1230 
1231  /* well, well. Looks like we screwed up. Time for god's revenge */
1232  if (reaction < 0) {
1233  int loss = 10000000;
1234  int angry = abs(reaction);
1235 
1237  if (skop)
1238  loss = 0.05*(float)skop->stats.exp;
1239  change_exp(op, -random_roll(0, loss*angry-1, op, PREFER_LOW), skop ? skop->skill : "none", SK_SUBTRACT_SKILL_EXP);
1240  if (random_roll(0, angry, op, PREFER_LOW)) {
1241  object *tmp = create_archetype(LOOSE_MANA);
1242 
1243  cast_magic_storm(op, tmp, op->level+(angry*3));
1244  }
1246  "%s becomes angry and punishes you!",
1247  god->name);
1248  }
1249  return reaction;
1250 }
1251 
1268 static int god_examines_item(const object *god, object *item) {
1269  char buf[MAX_BUF];
1270 
1271  if (!god || !item)
1272  return 0;
1273 
1274  if (!item->title)
1275  return 1; /* unclaimed item are ok */
1276 
1277  snprintf(buf, sizeof(buf), "of %s", god->name);
1278  if (!strcmp(item->title, buf))
1279  return 1; /* belongs to that God */
1280 
1281  if (god->title) { /* check if we have any enemy blessed item*/
1282  snprintf(buf, sizeof(buf), "of %s", god->title);
1283  if (!strcmp(item->title, buf)) {
1284  if (item->env) {
1285  char name[MAX_BUF];
1286 
1287  query_name(item, name, MAX_BUF);
1289  "Heretic! You are using %s!",
1290  name);
1291  }
1292  return -1;
1293  }
1294  }
1295  return 0; /* item is sacred to a non-enemy god/or is otherwise magical */
1296 }
1297 
1308 static const char *get_god_for_race(const char *race) {
1309  godlink *gl = first_god;
1310  const char *godname = NULL;
1311 
1312  if (race == NULL)
1313  return NULL;
1314  while (gl) {
1315  if (gl->arch->clone.race && !strcasecmp(gl->arch->clone.race, race)) {
1316  godname = gl->name;
1317  break;
1318  }
1319  gl = gl->next;
1320  }
1321  return godname;
1322 }
1323 
1335 int tailor_god_spell(object *spellop, object *caster) {
1336  const object *god = find_god(determine_god(caster));
1337  int caster_is_spell = 0;
1338 
1339  if (caster->type == SPELL_EFFECT || caster->type == SPELL)
1340  caster_is_spell = 1;
1341 
1342  /* if caster is a rune or the like, it doesn't worship anything. However,
1343  * if this object is owned by someone, then the god that they worship
1344  * is relevant, so use that.
1345  */
1346  if (!god && object_get_owner(caster))
1347  god = find_god(determine_god(object_get_owner(caster)));
1348 
1349  if (!god || (spellop->attacktype&AT_HOLYWORD && !god->race)) {
1350  if (!caster_is_spell)
1352  "This prayer is useless unless you worship an appropriate god");
1353  else
1354  LOG(llevError, "BUG: tailor_god_spell(): no god\n");
1355  object_free_drop_inventory(spellop);
1356  return 0;
1357  }
1358 
1359  /* either holy word or godpower attacks will set the slaying field */
1360  if (spellop->attacktype&AT_HOLYWORD || spellop->attacktype&AT_GODPOWER) {
1361  if (spellop->slaying) {
1362  free_string(spellop->slaying);
1363  spellop->slaying = NULL;
1364  }
1365  if (!caster_is_spell)
1366  spellop->slaying = god->slaying ? add_string(god->slaying) : NULL;
1367  else if (caster->slaying)
1368  spellop->slaying = add_string(caster->slaying);
1369  }
1370 
1371  /* only the godpower attacktype adds the god's attack onto the spell */
1372  if (spellop->attacktype&AT_GODPOWER)
1373  spellop->attacktype = spellop->attacktype|god->attacktype;
1374 
1375  /* tack on the god's name to the spell */
1376  if (spellop->attacktype&AT_HOLYWORD || spellop->attacktype&AT_GODPOWER) {
1377  if (spellop->title)
1378  free_string(spellop->title);
1379  spellop->title = add_string(god->name);
1380  if (spellop->title) {
1381  char buf[MAX_BUF];
1382 
1383  snprintf(buf, sizeof(buf), "%s of %s", spellop->name, spellop->title);
1384  FREE_AND_COPY(spellop->name, buf);
1385  FREE_AND_COPY(spellop->name_pl, buf);
1386  }
1387  }
1388 
1389  return 1;
1390 }
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.c:77
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Sends message to player(s).
Definition: main.c:315
Error, serious thing.
Definition: logger.h:11
#define AP_UNAPPLY
Item is to be remvoed.
Definition: define.h:611
#define AT_HOLYWORD
Definition: attack.h:97
#define MSG_TYPE_SKILL_PRAY
Praying related messages.
Definition: newclient.h:586
One player.
Definition: player.h:92
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
Definition: define.h:338
int apply_special(object *who, object *op, int aflags)
Apply an object.
Definition: apply.c:1082
Sound-related defines.
archetype * find_archetype(const char *name)
Finds, using the hashtable, which archetype matches the given name.
Definition: arch.c:695
#define MSG_TYPE_ITEM_CHANGE
Item has changed in some way.
Definition: newclient.h:640
#define FLAG_DAMNED
The object is very cursed.
Definition: define.h:318
static int improve_weapon_magic(object *op, object *tr, object *weapon, object *skill)
Utility function for improving the magic on a weapon.
Definition: gods.c:854
#define MSG_TYPE_ATTRIBUTE_GOD
changing god info
Definition: newclient.h:570
#define MSG_TYPE_ITEM
Item related information.
Definition: newclient.h:388
Spell-related defines: spellpath, subtypes, ...
int move_player(object *op, int dir)
Player gave us a direction, check whether to move or fire.
Definition: player.c:3019
treasureliststruct represents one logical group of items to be generated together.
Definition: treasure.h:82
object * check_spell_known(object *op, const char *name)
Checks to see if player knows the spell.
Definition: spell_util.c:435
const char * race
Human, goblin, dragon, etc.
Definition: object.h:318
const char *const restore_msg[NUM_STATS]
Message when a player has a stat restored.
Definition: living.c:150
archetype * determine_holy_arch(const object *god, const char *type)
Determines the archetype for holy servant and god avatar.
Definition: gods.c:742
#define SET_FLAG(xyz, p)
Definition: define.h:223
object * object_find_by_type_applied(const object *who, int type)
Find applied object in inventory.
Definition: object.c:3974
#define HOLY_POSSESSION
Definition: spells.h:168
#define MSG_TYPE_ITEM_ADD
Item added to inventory.
Definition: newclient.h:639
int cast_change_ability(object *op, object *caster, object *spell_ob, int dir, int silent)
Cast some stat-improving spell.
#define NDI_WHITE
Definition: newclient.h:222
#define MSG_TYPE_ITEM_INFO
Information related to items.
Definition: newclient.h:641
#define FLAG_USE_ARMOUR
(Monster) can wear armour/shield/helmet
Definition: define.h:296
static int lookup_god_by_name(const char *name)
Returns the id of specified god.
Definition: gods.c:54
struct archt * arch
Pointer to the archetype of this god.
Definition: god.h:14
treasurelist * find_treasurelist(const char *name)
Searches for the given treasurelist in the globally linked list of treasurelists which has been built...
Definition: treasure.c:292
int32_t last_heal
Last healed.
Definition: object.h:357
int16_t maxgrace
Maximum grace.
Definition: living.h:44
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
Definition: shstr.c:280
#define HUGE_BUF
Used for messages - some can be quite long.
Definition: define.h:37
void esrv_update_item(int flags, object *pl, object *op)
Updates object *op for player *pl.
Definition: main.c:342
See Spellbook.
Definition: object.h:203
const char * object_get_value(const object *op, const char *const key)
Get an extra value by key.
Definition: object.c:4246
struct treasureliststruct * randomitems
Items to be generated.
Definition: object.h:385
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.c:710
object clone
An object from which to do object_copy()
Definition: object.h:470
int16_t invisible
How much longer the object will be invis.
Definition: object.h:360
#define PREFER_LOW
Definition: define.h:600
See Weapon.
Definition: object.h:119
See Helmet.
Definition: object.h:136
const char * slaying
Which race to do double damage to.
Definition: object.h:319
int32_t last_sp
As last_heal, but for spell points.
Definition: object.h:358
#define FLAG_STEALTH
Will wake monsters with less range.
Definition: define.h:313
See Rod.
Definition: object.h:109
Used to link together the gods.
Definition: god.h:12
#define FLAG_USE_WEAPON
(Monster) can wield weapons
Definition: define.h:297
int64_t exp
Experience.
Definition: living.h:46
treasure is one element in a linked list, which together consist of a complete treasure-list.
Definition: treasure.h:63
#define TRUE
Definition: compat.h:10
const char * name
Name of this god.
Definition: god.h:13
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.c:160
object * arch_present_in_ob(const archetype *at, const object *op)
Searches for any objects with a matching archetype in the inventory of the given object.
Definition: object.c:3061
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
Definition: living.c:313
uint32_t path_attuned
Paths the object is attuned to.
Definition: object.h:343
#define MAX(x, y)
Definition: compat.h:20
#define MSG_TYPE_ITEM_REMOVE
Item removed from inv.
Definition: newclient.h:638
int16_t sp
Spell points.
Definition: living.h:41
Global type definitions and header inclusions.
int become_follower(object *op, const object *new_god)
This function is called whenever a player has switched to a new god.
Definition: gods.c:473
uint32_t path_repelled
Paths the object is repelled from.
Definition: object.h:344
See Boots.
Definition: object.h:212
#define SCRIPT_FIX_ALL
Definition: global.h:361
struct archt * other_arch
Pointer used for various things - mostly used for what this objects turns into or what this object cr...
Definition: object.h:413
int absdir(int d)
Computes an absolute direction.
Definition: object.c:3637
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.c:310
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:465
See Wand & Staff.
Definition: object.h:220
struct archt * item
Which item this link can be.
Definition: treasure.h:64
int16_t maxsp
Max spell points.
Definition: living.h:42
#define MIN(x, y)
Definition: compat.h:17
int16_t hp
Hit Points.
Definition: living.h:39
#define NDI_NAVY
Definition: newclient.h:223
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
This calls the appropriate treasure creation function.
Definition: treasure.c:490
#define LOOSE_MANA
Definition: spells.h:162
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.c:1744
Don&#39;t generate bad/cursed items.
Definition: treasure.h:34
int rndm(int min, int max)
Returns a number between min and max.
Definition: utils.c:161
#define FLAG_UNDEAD
Monster is undead.
Definition: define.h:270
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
Definition: object.c:4375
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.c:1368
int change_abil(object *op, object *tmp)
Permanently alters an object&#39;s stats/flags based on another object.
Definition: living.c:394
const char * title
Of foo, etc.
Definition: object.h:317
int16_t maxhp
Max hit points.
Definition: living.h:40
#define AT_GODPOWER
Definition: attack.h:96
#define MSG_TYPE_ATTRIBUTE_BAD_EFFECT_END
End of a bad effect.
Definition: newclient.h:561
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.c:197
static int god_examines_priest(object *op, const object *god)
Checks and maybe punishes someone praying.
Definition: gods.c:1221
See Shooting Weapon.
Definition: object.h:118
uint32_t path_denied
Paths the object is denied access to.
Definition: object.h:345
#define FLAG_ALIVE
Object can fight (or be fought)
Definition: define.h:230
#define AP_IGNORE_CURSE
Apply/unapply regardless of cursed/damned status.
Definition: define.h:617
#define FLAG_REFL_SPELL
Spells (some) will reflect from object.
Definition: define.h:275
See Book.
Definition: object.h:114
const char * name_pl
The plural name of the object.
Definition: object.h:315
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.c:620
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.c:2690
signed short int16_t
Definition: win32.h:160
int tailor_god_spell(object *spellop, object *caster)
Changes the attributes of cone, smite, and ball spells as needed by the code.
Definition: gods.c:1335
const char * anim_suffix
Used to determine combined animations.
Definition: object.h:316
int8_t Wis
Definition: living.h:35
static 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: gods.c:1308
#define FLAG_USE_SHIELD
Can this creature use a shield?
Definition: define.h:237
#define snprintf
Definition: win32.h:46
#define ARCH_DEPLETION
Archetype for depletion.
Definition: object.h:579
#define MSG_TYPE_ATTRIBUTE
Changes to attributes (stats, resistances, etc)
Definition: newclient.h:380
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
Definition: define.h:712
#define FMT64
Definition: compat.h:12
const char * name
The name of the object, obviously...
Definition: object.h:311
struct obj * env
Pointer to the object which is the environment.
Definition: object.h:293
const char * determine_god(object *op)
Determines if op worships a god.
Definition: gods.c:106
int16_t last_grace
As last_sp, except for grace.
Definition: object.h:359
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.c:233
#define MAX_WEAPON_ITEM_POWER
Maximum item power an item can have.
Definition: define.h:475
const object * pntr_to_god_obj(godlink *godlnk)
Returns a pointer to the object We need to be VERY careful about using this, as we are returning a po...
Definition: holy.c:123
#define UPD_FLAGS
Definition: newclient.h:290
Number of statistics.
Definition: living.h:18
void do_learn_spell(object *op, object *spell, int special_prayer)
Actually makes op learn spell.
Definition: apply.c:391
struct pl * contr
Pointer to the player which control this object.
Definition: object.h:276
int8_t item_power
Power rating of the object.
Definition: object.h:362
static int god_examines_item(const object *god, object *item)
God checks item the player is using.
Definition: gods.c:1268
void player_unready_range_ob(player *pl, object *ob)
Unready an object for a player.
Definition: player.c:4451
#define FLAG_XRAYS
X-ray vision.
Definition: define.h:301
void cast_magic_storm(object *op, object *tmp, int lvl)
This is really used mostly for spell fumbles and the like.
Definition: spell_effect.c:44
EXTERN godlink * first_god
God list.
Definition: global.h:124
Praying.
Definition: skills.h:49
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.c:687
int8_t luck
Affects thaco and ac from time to time.
Definition: living.h:38
#define ATNR_ELECTRICITY
Definition: attack.h:52
#define ATNR_POISON
Definition: attack.h:59
#define AT_PHYSICAL
Definition: attack.h:76
unsigned __int64 uint64_t
Definition: win32.h:167
See Spell.
Definition: object.h:214
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
#define CLEAR_FLAG(xyz, p)
Definition: define.h:224
struct glnk * next
Next god.
Definition: god.h:16
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Changes experience to a player/monster.
Definition: living.c:2094
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.c:1110
static int god_removes_curse(object *op, int remove_damnation)
God helps player by removing curse and/or damnation.
Definition: gods.c:790
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
static int god_gives_present(object *op, const object *god, treasure *tr)
God gives an item to the player.
Definition: gods.c:259
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.c:823
struct treasurestruct * items
Items in this list, linked.
Definition: treasure.h:90
const char * skill
Name of the skill this object uses/grants.
Definition: object.h:321
int32_t last_eat
How long since we last ate.
Definition: object.h:356
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:341
#define FLAG_KNOWN_CURSED
The object is known to be cursed.
Definition: define.h:321
#define FLAG_CURSED
The object is cursed.
Definition: define.h:317
See Player.
Definition: object.h:107
unsigned int uint32_t
Definition: win32.h:162
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.c:993
See Shield.
Definition: object.h:135
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Find object in inventory.
Definition: object.c:4195
static int god_enchants_weapon(object *op, const object *god, object *tr, object *skill)
God wants to enchant weapon.
Definition: gods.c:887
uint8_t chance
Percent chance for this item.
Definition: treasure.h:70
Object structure, the core of Crossfire.
#define PREFER_HIGH
Definition: define.h:599
uint32_t attacktype
Bitmask of attacks this object does.
Definition: object.h:342
When object has been generated, send its information to player.
Definition: treasure.h:35
#define FLAG_BLIND
If set, object cannot see (visually)
Definition: define.h:337
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:213
int16_t grace
Grace.
Definition: living.h:43
signed char int8_t
Type definitions for fixed-size integer types.
Definition: win32.h:158
Also see SKILL_TOOL (74) below.
Definition: object.h:143
archetype * get_archetype_by_type_subtype(int type, int subtype)
Retrieves an archetype by type and subtype.
Definition: arch.c:136
#define EVENT_APPLY
Object applied-unapplied.
Definition: plugin.h:64
living stats
Str, Con, Dex, etc.
Definition: object.h:368
struct archt * arch
Pointer to archetype.
Definition: object.h:412
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:338
struct Settings settings
Server settings.
Definition: init.c:40
static void remove_special_prayers(object *op, const object *god)
Removes special prayers given by a god.
Definition: gods.c:409
void object_free2(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.c:1391
Generated items have the FLAG_STARTEQUIP.
Definition: treasure.h:33
#define FLAG_APPLIED
Object is ready for use by living.
Definition: define.h:235
#define NROFATTACKS
Definition: attack.h:17
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.c:548
int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
Definition: main.c:364
#define UPD_NAME
Definition: newclient.h:293
const char * msg
If this is a book/sign/magic mouth/etc.
Definition: object.h:322
#define FLAG_MAKE_INVIS
(Item) gives invisibility when applied
Definition: define.h:329
#define FLAG_STARTEQUIP
Object was given to player at start.
Definition: define.h:268
sstring add_string(const char *str)
This will add &#39;str&#39; to the hash table.
Definition: shstr.c:124
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: skill_util.c:112
int strcasecmp(const char *s1, const char *s2)
Case-insensitive comparaison of strings.
Definition: porting.c:256
#define MSG_TYPE_SKILL
Messages related to skill use.
Definition: newclient.h:383
struct obj * inv
Pointer to the first object in the inventory.
Definition: object.h:290
#define NDI_UNIQUE
Print immediately, don&#39;t buffer.
Definition: newclient.h:245
void apply_anim_suffix(object *who, sstring suffix)
Applies a compound animation to an object.
Definition: anim.c:318
See Gloves.
Definition: object.h:213
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.c:51
static int same_string(const char *s1, const char *s2)
Compares 2 strings.
Definition: gods.c:175
Structure containing object statistics.
#define ATNR_COLD
Definition: attack.h:53
void query_name(const object *op, char *buf, size_t size)
Describes an item.
Definition: item.c:626
#define SK_SUBTRACT_SKILL_EXP
Used when removing exp.
Definition: skills.h:82
object * find_skill_by_number(object *who, int skillno)
This returns the skill pointer of the given name (the one that accumulates exp, has the level...
Definition: main.c:351
int random_roll(int min, int max, const object *op, int goodbad)
Roll a random number between min and max.
Definition: utils.c:42
See Breastplate Armor.
Definition: object.h:120
struct treasurestruct * next
Next treasure-item in a linked list.
Definition: treasure.h:66
#define FLAG_REFL_MISSILE
Arrows will reflect from object.
Definition: define.h:273
int16_t level
Level of creature or object.
Definition: object.h:351
int8_t facing
Object is oriented/facing that way.
Definition: object.h:335
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
Definition: living.c:1118
const char * name
If non null, name of list to use instead.
Definition: treasure.h:65
int id
Id of the god.
Definition: god.h:15
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
Definition: arch.c:571
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
Definition: object.c:559
int8_t magic
Any magical bonuses to this item.
Definition: object.h:348
const char * name
More definite name, like "generate_kobold".
Definition: object.h:466
void pray_at_altar(object *pl, object *altar, object *skill)
Player prays at altar.
Definition: gods.c:303
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.c:3039
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
Definition: define.h:705
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.c:1654
const object * find_god(const char *name)
Returns pointer to specified god&#39;s object through pntr_to_god_obj().
Definition: gods.c:80
uint8_t personalized_blessings
If 1, blessed weapons get an owner and a willpower value.
Definition: global.h:310
int32_t food
How much food in stomach.
Definition: living.h:47
Definition: object.h:224
#define ATNR_FIRE
Definition: attack.h:51
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.c:657