Crossfire Server, Trunk  R20513
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  break;
136  gl = gl->next;
137  }
138  op->title = add_string(gl->name);
139  }
140 
141  return op->title;
142  }
143 
144  /* The god the player worships is in the praying skill (native skill
145  * not skill tool). Since a player can only have one instance of
146  * that skill, once we find it, we can return, either with the
147  * title or "none".
148  */
149  if (op->type == PLAYER) {
150  object *tmp;
151 
153  if (tmp != NULL) {
154  return tmp->title != NULL ? tmp->title : "none";
155  }
156  }
157  return ("none");
158 }
159 
168 static int same_string(const char *s1, const char *s2) {
169  if (s1 == NULL)
170  return s2 == NULL;
171  else
172  return s2 != NULL && strcmp(s1, s2) == 0;
173 }
174 
190 static void follower_remove_given_items(object *pl, object *op, const object *god) {
191  const char *given_by;
192 
193  /* search the inventory */
194  FOR_INV_PREPARE(op, tmp) {
195  given_by = object_get_value(tmp, "divine_giver_name");
196  if (given_by == god->name) {
197  char name[HUGE_BUF];
198 
199  query_short_name(tmp, name, HUGE_BUF);
200  /* Send the client a message. */
201  if (tmp->nrof > 1)
203  "The %s crumble to dust!",
204  name);
205  else
207  "The %s crumbles to dust!",
208  name);
209 
210  object_remove(tmp); /* remove obj from players inv. */
212  } else if (tmp->inv)
213  follower_remove_given_items(pl, tmp, god);
214  } FOR_INV_FINISH();
215 }
216 
226 static int follower_has_similar_item(object *op, object *item) {
227  FOR_INV_PREPARE(op, tmp) {
228  if (tmp->type == item->type
229  && same_string(tmp->name, item->name)
230  && same_string(tmp->title, item->title)
231  && tmp->msg == item->msg
232  && same_string(tmp->slaying, item->slaying))
233  return 1;
234  if (tmp->inv && follower_has_similar_item(tmp, item))
235  return 1;
236  } FOR_INV_FINISH();
237  return 0;
238 }
239 
252 static int god_gives_present(object *op, const object *god, treasure *tr) {
253  object *tmp;
254  char name[HUGE_BUF];
255 
256  if (follower_has_similar_item(op, &tr->item->clone))
257  return 0;
258 
259  tmp = arch_to_object(tr->item);
260 
261  /*
262  * Give inventory if needed, for instance Lythander's pipe.
263  * Use high level and magic so something IS put in inventory.
264  */
265  fix_generated_item(tmp, NULL, 120, 120, GT_ONLY_GOOD);
266 
267  /* And just in case nothing was put and something is needed, bail out. */
268  if ((tmp->type == ROD || tmp->type == WAND) && (tmp->inv == NULL)) {
269  object_free2(tmp, 0);
270  return 0;
271  }
272 
273  query_short_name(tmp, name, HUGE_BUF);
275  "%s lets %s appear in your hands.",
276  god->name, name);
280  object_set_value(tmp, "divine_giver_name", god->name, TRUE);
281  object_insert_in_ob(tmp, op);
282  return 1;
283 }
284 
296 void pray_at_altar(object *pl, object *altar, object *skill) {
297  const object *pl_god = find_god(determine_god(pl));
298 
299  /* Lauwenmark: Handle for plugin altar-praying (apply) event */
300  if (execute_event(altar, EVENT_APPLY, pl, NULL, NULL, SCRIPT_FIX_ALL) != 0)
301  return;
302 
303  /* If non consecrate altar, don't do anything */
304  if (!altar->other_arch)
305  return;
306 
307  /* hmm. what happend depends on pl's current god, level, etc */
308  if (!pl_god) { /*new convert */
309  become_follower(pl, &altar->other_arch->clone);
310  return;
311  }
312 
313  if (!strcmp(pl_god->name, altar->other_arch->clone.name)) {
314  /* pray at your gods altar */
315  int bonus = (pl->stats.Wis+skill->level)/10;
316 
317  /* we can get neg grace up faster */
318  if (pl->stats.grace < 0)
319  pl->stats.grace += (bonus > -1*(pl->stats.grace/10) ? bonus : -1*(pl->stats.grace/10));
320  /* we can super-charge grace to 2x max */
321  if (pl->stats.grace < (2*pl->stats.maxgrace)) {
322  pl->stats.grace += bonus/2;
323  }
324  if (pl->stats.grace > (2*pl->stats.maxgrace)) {
325  pl->stats.grace = (2*pl->stats.maxgrace);
326  }
327 
328  /* Every once in a while, the god decides to checkup on their
329  * follower, and may intervene to help them out.
330  */
331  bonus = MAX(1, bonus+MAX(pl->stats.luck, -3)); /* -- DAMN -- */
332 
333  if (((random_roll(0, 399, pl, PREFER_LOW))-bonus) < 0)
334  god_intervention(pl, pl_god, skill, altar);
335  } else { /* praying to another god! */
336  uint64_t loss = 0;
337  int angry = 1;
338 
339  /* I believe the logic for detecting opposing gods was completely
340  * broken - I think it should work now. altar->other_arch
341  * points to the god of this altar (which we have
342  * already verified is non null). pl_god->other_arch
343  * is the opposing god - we need to verify that exists before
344  * using its values.
345  */
346  if (pl_god->other_arch
347  && (altar->other_arch->name == pl_god->other_arch->name)) {
348  angry = 2;
349  if (random_roll(0, skill->level+2, pl, PREFER_LOW)-5 > 0) {
350  object *tmp;
351 
352  /* you really screwed up */
353  angry = 3;
355  "Foul Priest! %s punishes you!",
356  pl_god->name);
358  cast_magic_storm(pl, tmp, pl_god->level+20);
359  } else
361  "Foolish heretic! %s is livid!",
362  pl_god->name);
363  } else
365  "Heretic! %s is angered!",
366  pl_god->name);
367 
368  /* whether we will be successfull in defecting or not -
369  * we lose experience from the clerical experience obj
370  */
371 
372  loss = angry*(skill->stats.exp/10);
373  if (loss)
374  change_exp(pl, -random_roll64(0, loss, pl, PREFER_LOW), skill ? skill->skill : "none", SK_SUBTRACT_SKILL_EXP);
375 
376  /* May switch Gods, but its random chance based on our current level
377  * note it gets harder to swap gods the higher we get
378  */
379  if ((angry == 1) && !(random_roll(0, skill->level, pl, PREFER_LOW))) {
380  if (become_follower(pl, &altar->other_arch->clone))
381  remove_special_prayers(pl, pl_god);
382  } else {
383  /* toss this player off the altar. He can try again. */
385  "A divine force pushes you off the altar.");
386 
387  move_player(pl, absdir(pl->facing+4)); /* back him off the way he came. */
388  }
389  }
390 }
391 
402 static void remove_special_prayers(object *op, const object *god) {
403  treasure *tr;
404  int remove = 0;
405 
406  if (god->randomitems == NULL) {
407  LOG(llevError, "BUG: remove_special_prayers(): god %s without randomitems\n", god->name);
408  return;
409  }
410 
411 
412  /* Outer loop iterates over all special prayer marks */
413  FOR_INV_PREPARE(op, tmp) {
414  /* we mark special prayers with the STARTEQUIP flag, so if it isn't
415  * in that category, not something we need to worry about.
416  */
417  if (tmp->type != SPELL || !QUERY_FLAG(tmp, FLAG_STARTEQUIP))
418  continue;
419 
420  /* Inner loop tries to find the special prayer in the god's treasure
421  * list. We default that the spell should not be removed.
422  */
423  remove = 0;
424  for (tr = god->randomitems->items; tr; tr = tr->next) {
425  if (tr->item == NULL)
426  continue;
427 
428  /* Basically, see if the matching spell is granted by this god. */
429 
430  if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) {
431  remove = 1;
432  break;
433  }
434  }
435  if (remove) {
436  /* just do the work of removing the spell ourselves - we already
437  * know that the player knows the spell
438  */
441  "You lose knowledge of %s.",
442  tmp->name);
443  player_unready_range_ob(op->contr, tmp);
444  object_remove(tmp);
446  }
447  } FOR_INV_FINISH();
448 }
449 
466 int become_follower(object *op, const object *new_god) {
467  const object *old_god = NULL; /* old god */
468  treasure *tr;
469  object *skop;
470  int i, sk_applied;
471  int undeadified = 0; /* Turns to true if changing god can changes the undead
472  * status of the player.*/
473  old_god = find_god(determine_god(op));
474 
475  /* take away any special god-characteristic items. */
476  FOR_INV_PREPARE(op, item) {
477  /* remove all invisible startequip items which are
478  * not skill, exp or force
479  */
480  if (QUERY_FLAG(item, FLAG_STARTEQUIP)
481  && item->invisible
482  && (item->type != SKILL)
483  && (item->type != FORCE)
484  && (item->type != SPELL)) {
485  player_unready_range_ob(op->contr, item);
486  object_remove(item);
488  }
489  } FOR_INV_FINISH();
490 
491  /* remove any items given by the old god */
492  if (old_god) {
493  /* Changed to use the new "divine_giver_name" key_value
494  * so it can reliably delete enchanted items. Now it loops
495  * through the player's inventory, instead of the god's
496  * treasure list.
497  */
498  follower_remove_given_items(op, op, old_god);
499  }
500 
501  if (!op || !new_god)
502  return 0;
503 
504  if (op->race && new_god->slaying && strstr(op->race, new_god->slaying)) {
506  "Fool! %s detests your kind!",
507  new_god->name);
508  if (random_roll(0, op->level-1, op, PREFER_LOW)-5 > 0) {
509  object *tmp = create_archetype(LOOSE_MANA);
510  cast_magic_storm(op, tmp, new_god->level+10);
511  }
512  return 0;
513  }
514 
515  /* give the player any special god-characteristic-items. */
516  for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) {
517  if (tr->item
518  && tr->item->clone.invisible
519  && tr->item->clone.type != SPELLBOOK
520  && tr->item->clone.type != BOOK
521  && tr->item->clone.type != SPELL)
522  god_gives_present(op, new_god, tr);
523  }
524 
526  "You become a follower of %s!",
527  new_god->name);
528 
530  /* Player has no skill - give them the skill */
531  if (!skop) {
532  /* The archetype should always be defined - if we crash here because it doesn't,
533  * things are really messed up anyways.
534  */
536  link_player_skills(op);
537  }
538 
539  sk_applied = QUERY_FLAG(skop, FLAG_APPLIED); /* save skill status */
540 
541  /* Clear the "undead" status. We also need to force a call to change_abil,
542  * so I set undeadified for that.
543  * - gros, 21th July 2006.
544  */
545  if ((old_god) && (QUERY_FLAG(old_god, FLAG_UNDEAD))) {
546  CLEAR_FLAG(skop, FLAG_UNDEAD);
547  undeadified = 1;
548  }
549 
550  if (skop->title) { /* get rid of old god */
552  "%s's blessing is withdrawn from you.",
553  skop->title);
554 
555  /* The point of this is to really show what abilities the player just lost */
556  if (sk_applied || undeadified) {
557  CLEAR_FLAG(skop, FLAG_APPLIED);
558  (void)change_abil(op, skop);
559  }
560  free_string(skop->title);
561  }
562 
563  /* now change to the new gods attributes to exp_obj */
564  skop->title = add_string(new_god->name);
565  skop->path_attuned = new_god->path_attuned;
566  skop->path_repelled = new_god->path_repelled;
567  skop->path_denied = new_god->path_denied;
568  /* copy god's resistances */
569  memcpy(skop->resist, new_god->resist, sizeof(new_god->resist));
570 
571  /* make sure that certain immunities do NOT get passed
572  * to the follower!
573  */
574  for (i = 0; i < NROFATTACKS; i++)
575  if (skop->resist[i] > 30
576  && (i == ATNR_FIRE || i == ATNR_COLD || i == ATNR_ELECTRICITY || i == ATNR_POISON))
577  skop->resist[i] = 30;
578 
579  skop->stats.hp = (int16_t)new_god->last_heal;
580  skop->stats.sp = (int16_t)new_god->last_sp;
581  skop->stats.grace = (int16_t)new_god->last_grace;
582  skop->stats.food = (int16_t)new_god->last_eat;
583  skop->stats.luck = (int8_t)new_god->stats.luck;
584  /* gods may pass on certain flag properties */
585  update_priest_flag(new_god, skop, FLAG_SEE_IN_DARK);
586  update_priest_flag(new_god, skop, FLAG_REFL_SPELL);
587  update_priest_flag(new_god, skop, FLAG_REFL_MISSILE);
588  update_priest_flag(new_god, skop, FLAG_STEALTH);
589  update_priest_flag(new_god, skop, FLAG_MAKE_INVIS);
590  update_priest_flag(new_god, skop, FLAG_UNDEAD);
591  update_priest_flag(new_god, skop, FLAG_BLIND);
592  update_priest_flag(new_god, skop, FLAG_XRAYS); /* better have this if blind! */
593  update_priest_flag(new_god, skop, FLAG_USE_WEAPON);
594  update_priest_flag(new_god, skop, FLAG_USE_ARMOUR);
595  update_priest_flag(new_god, skop, FLAG_USE_SHIELD);
596 
598  "You are bathed in %s's aura.",
599  new_god->name);
600 
601  /* Weapon/armour use are special...handle flag toggles here as this can
602  * only happen when gods are worshipped and if the new priest could
603  * have used armour/weapons in the first place.
604  *
605  * This also can happen for monks which cannot use weapons. In this case
606  * do not allow to use weapons even if the god otherwise would allow it.
607  */
608  if (!object_present_in_ob_by_name(FORCE, "no weapon force", op)) {
609  if (worship_forbids_use(op, skop, FLAG_USE_WEAPON, "weapons"))
610  stop_using_item(op, WEAPON, 2);
611  }
612  update_priest_flag(new_god, skop, FLAG_USE_ARMOUR);
613 
614  if (worship_forbids_use(op, skop, FLAG_USE_ARMOUR, "armour")) {
615  stop_using_item(op, ARMOUR, 1);
616  stop_using_item(op, HELMET, 1);
617  stop_using_item(op, BOOTS, 1);
618  stop_using_item(op, GLOVES, 1);
619  }
620 
621  if (worship_forbids_use(op, skop, FLAG_USE_SHIELD, "shield"))
622  stop_using_item(op, SHIELD, 1);
623 
624  SET_FLAG(skop, FLAG_APPLIED);
625  (void)change_abil(op, skop);
626 
627  /* return to previous skill status */
628  if (!sk_applied)
629  CLEAR_FLAG(skop, FLAG_APPLIED);
630 
631  // check is now done after converting
632  //remove_special_prayers(op, new_god);
633 
634  return 1;
635 }
636 
650 static int worship_forbids_use(object *op, object *exp_obj, uint32_t flag, const char *string) {
651  if (QUERY_FLAG(&op->arch->clone, flag)) {
652  if (QUERY_FLAG(op, flag) != QUERY_FLAG(exp_obj, flag)) {
653  update_priest_flag(exp_obj, op, flag);
654  if (QUERY_FLAG(op, flag))
656  "You may use %s again.",
657  string);
658  else {
660  "You are forbidden to use %s.",
661  string);
662  return 1;
663  }
664  }
665  }
666  return 0;
667 }
668 
680 static void stop_using_item(object *op, int type, int number) {
681  FOR_INV_PREPARE(op, tmp)
682  if (tmp->type == type && QUERY_FLAG(tmp, FLAG_APPLIED)) {
684  number--;
685  if (number <= 0)
686  break;
687  }
688  FOR_INV_FINISH();
689 }
690 
703 static void update_priest_flag(const object *god, object *exp_ob, uint32_t flag) {
704  if (QUERY_FLAG(god, flag) && !QUERY_FLAG(exp_ob, flag))
705  SET_FLAG(exp_ob, flag);
706  else if (QUERY_FLAG(exp_ob, flag) && !QUERY_FLAG(god, flag)) {
707  /* When this is called with the exp_ob set to the player,
708  * this check is broken, because most all players arch
709  * allow use of weapons. I'm not actually sure why this
710  * check is here - I guess if you had a case where the
711  * value in the archetype (wisdom) should over ride the restrictions
712  * the god places on it, this may make sense. But I don't think
713  * there is any case like that.
714  */
715 
716 /* if (!(QUERY_FLAG(&(exp_ob->arch->clone), flag)))*/
717  CLEAR_FLAG(exp_ob, flag);
718  }
719 }
720 
721 
735 archetype *determine_holy_arch(const object *god, const char *type) {
736  treasure *tr;
737  int count;
738  object *item;
739 
740  if (!god || !god->randomitems) {
741  LOG(llevError, "BUG: determine_holy_arch(): no god or god without randomitems\n");
742  return NULL;
743  }
744 
745  count = 0;
746  for (tr = god->randomitems->items; tr != NULL; tr = tr->next) {
747  if (!tr->item)
748  continue;
749  item = &tr->item->clone;
750  if (item->type == BOOK && item->invisible && item->name == type)
751  count++;
752  }
753  if (count == 0) {
754  return NULL;
755  }
756 
757  count = rndm(1, count);
758 
759  for (tr = god->randomitems->items; tr != NULL; tr = tr->next) {
760  if (!tr->item)
761  continue;
762  item = &tr->item->clone;
763  if (item->type == BOOK && item->invisible && item->name == type) {
764  count--;
765  if (count == 0)
766  return item->other_arch;
767  }
768  }
769 
770  return NULL;
771 }
772 
783 static int god_removes_curse(object *op, int remove_damnation) {
784  int success = 0;
785 
786  FOR_INV_PREPARE(op, tmp) {
787  if (tmp->invisible)
788  continue;
789  if (QUERY_FLAG(tmp, FLAG_DAMNED) && !remove_damnation)
790  continue;
791  if (QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED)) {
792  success = 1;
793  CLEAR_FLAG(tmp, FLAG_DAMNED);
794  CLEAR_FLAG(tmp, FLAG_CURSED);
796  if (op->type == PLAYER)
797  esrv_update_item(UPD_FLAGS, op, tmp);
798  }
799  } FOR_INV_FINISH();
800 
801  if (success)
803  "You feel like someone is helping you.");
804  return success;
805 }
806 
816 static int follower_level_to_enchantments(int level, int difficulty) {
817  if (difficulty < 1) {
818  LOG(llevError, "follower_level_to_enchantments(): difficulty %d is invalid\n", difficulty);
819  return 0;
820  }
821 
822  if (level <= 20)
823  return level/difficulty;
824  if (level <= 40)
825  return (20+(level-20)/2)/difficulty;
826  return (30+(level-40)/4)/difficulty;
827 }
828 
847 static int improve_weapon_magic(object *op, object *tr, object *weapon, object *skill) {
848  int tmp = follower_level_to_enchantments(skill->level, tr->level);
849 
850  if (weapon->magic < tmp) {
852  "A phosphorescent glow envelops your weapon!");
853  weapon->magic++;
854  if (op->type == PLAYER)
855  esrv_update_item(UPD_NAME, op, weapon);
856  weapon->item_power++;
857  return 1;
858  }
859 
860  return 0;
861 }
862 
880 static int god_enchants_weapon(object *op, const object *god, object *tr, object *skill) {
881  char buf[MAX_BUF];
882  object *weapon;
883  uint32_t attacktype;
884 
885  weapon = object_find_by_type_applied(op, WEAPON);
886  if (weapon == NULL)
887  weapon = object_find_by_type_applied(op, BOW);
888  if (weapon == NULL || god_examines_item(god, weapon) <= 0)
889  return 0;
890 
891  if (weapon->item_power >= MAX_WEAPON_ITEM_POWER) {
893  "%s considers your %s is not worthy to be enchanted any more.",
894  god->name,
895  weapon->name);
896  return 0;
897  }
898 
899  /* If personalized_blessings is activated, then the god's name is
900  * associated with the weapon, as well as the owner (the one who blesses it),
901  * and a "weapon willpower", which is equivalent to the owner's experience
902  * in praying when the weapon is blessed.
903  * Those values are used later, when another player attempts to wield the
904  * weapon - nasty things may happen to those who do not deserve to use it ! :)
905  */
907  const char *divine_owner = object_get_value(weapon, "divine_blessing_name");
908  const char *owner = object_get_value(weapon, "item_owner");
909  object *skillop = NULL;
910 
911  if (divine_owner != NULL && strcmp(divine_owner, god->name) != 0) {
912  /* Huho... Another god already blessed this one ! */
914  "Your %s already belongs to %s !",
915  weapon->name, divine_owner);
916  return 0;
917  }
918 
919  if ((owner != NULL) && (strcmp(owner, op->name) != 0)) {
920  /* Maybe the weapon itself will not agree ? */
922  "The %s is not yours, and is magically protected against such changes !",
923  weapon->name);
924  return 0;
925  }
926  skillop = find_skill_by_number(op, SK_PRAYING);
927  if (skillop == NULL) {
928  LOG(llevError, "god_enchants_weapon: no praying skill object found ?!\n");
929  snprintf(buf, sizeof(buf), "%d", 1);
930  } else
931  snprintf(buf, sizeof(buf), "%"FMT64, skillop->stats.exp);
932  object_set_value(weapon, "divine_blessing_name", god->name, TRUE);
933  object_set_value(weapon, "item_owner", op->name, TRUE);
934  object_set_value(weapon, "item_willpower", buf, TRUE);
935  }
936 
937  /* First give it a title, so other gods won't touch it */
938  if (!weapon->title) {
939  snprintf(buf, sizeof(buf), "of %s", god->name);
940  weapon->title = add_string(buf);
941  if (op->type == PLAYER)
942  esrv_update_item(UPD_NAME, op, weapon);
944  "Your weapon quivers as if struck!");
945  }
946 
947  /* Allow the weapon to slay enemies */
948  if (!weapon->slaying && god->slaying) {
949  weapon->slaying = add_string(god->slaying);
951  "Your %s now hungers to slay enemies of your god!",
952  weapon->name);
953  weapon->item_power++;
954  return 1;
955  }
956 
957  /* Add the gods attacktype */
958  attacktype = (weapon->attacktype == 0) ? AT_PHYSICAL : weapon->attacktype;
959  if ((attacktype&god->attacktype) != god->attacktype) {
961  "Your weapon suddenly glows!");
962  weapon->attacktype = attacktype|god->attacktype;
963  weapon->item_power++;
964  return 1;
965  }
966 
967  /* Higher magic value */
968  return improve_weapon_magic(op, tr, weapon, skill);
969 }
970 
986 static void god_intervention(object *op, const object *god, object *skill, object *altar) {
987  treasure *tr;
988 
989  if (!god || !god->randomitems) {
990  LOG(llevError, "BUG: god_intervention(): no god or god without randomitems\n");
991  return;
992  }
993 
994  // removed on 2009-12-12 because the function now removes prayers NOT from god.
995  //remove_special_prayers(op, god);
996 
997  /* lets do some checks of whether we are kosher with our god */
998  if (god_examines_priest(op, god) < 0)
999  return;
1000 
1002  "You feel a holy presence!");
1003 
1004  if (altar->anim_suffix != NULL)
1005  apply_anim_suffix(altar, altar->anim_suffix);
1006 
1007  for (tr = god->randomitems->items; tr != NULL; tr = tr->next) {
1008  object *item;
1009 
1010  if (tr->chance <= random_roll(0, 99, op, PREFER_HIGH))
1011  continue;
1012 
1013  /* Treasurelist - generate some treasure for the follower */
1014  if (tr->name) {
1015  treasurelist *tl = find_treasurelist(tr->name);
1016  if (tl == NULL)
1017  continue;
1018 
1020  "Something appears before your eyes. You catch it before it falls to the ground.");
1021 
1023  return;
1024  }
1025 
1026  if (!tr->item) {
1027  LOG(llevError, "BUG: empty entry in %s's treasure list\n", god->name);
1028  continue;
1029  }
1030  item = &tr->item->clone;
1031 
1032  /* Grace limit */
1033  if (item->type == BOOK && item->invisible
1034  && strcmp(item->name, "grace limit") == 0) {
1035  if (op->stats.grace < item->stats.grace
1036  || op->stats.grace < op->stats.maxgrace) {
1037  object *tmp;
1038 
1039  /* Follower lacks the required grace for the following
1040  * treasure list items. */
1041 
1043  cast_change_ability(op, op, tmp, 0, 1);
1045  return;
1046  }
1047  continue;
1048  }
1049 
1050  /* Restore grace */
1051  if (item->type == BOOK && item->invisible
1052  && strcmp(item->name, "restore grace") == 0) {
1053  if (op->stats.grace >= 0)
1054  continue;
1055  op->stats.grace = random_roll(0, 9, op, PREFER_HIGH);
1057  "You are returned to a state of grace.");
1058  return;
1059  }
1060 
1061  /* Heal damage */
1062  if (item->type == BOOK && item->invisible
1063  && strcmp(item->name, "restore hitpoints") == 0) {
1064  if (op->stats.hp >= op->stats.maxhp)
1065  continue;
1067  "A white light surrounds and heals you!");
1068  op->stats.hp = op->stats.maxhp;
1069  return;
1070  }
1071 
1072  /* Restore spellpoints */
1073  if (item->type == BOOK
1074  && item->invisible
1075  && strcmp(item->name, "restore spellpoints") == 0) {
1076  int max = op->stats.maxsp*(item->stats.maxsp/100.0);
1077  /* Restore to 50 .. 100%, if sp < 50% */
1078  int new_sp = random_roll(1000, 1999, op, PREFER_HIGH)/2000.0*max;
1079  if (op->stats.sp >= max/2)
1080  continue;
1082  "A blue lightning strikes your head but doesn't hurt you!");
1083  op->stats.sp = new_sp;
1084  }
1085 
1086  /* Various heal spells */
1087  if (item->type == BOOK && item->invisible
1088  && strcmp(item->name, "heal spell") == 0) {
1089  object *tmp;
1090  int success;
1091 
1093 
1094  success = cast_heal(op, op, tmp, 0);
1096  if (success)
1097  return;
1098 
1099  continue;
1100  }
1101 
1102  /* Remove curse */
1103  if (item->type == BOOK && item->invisible
1104  && strcmp(item->name, "remove curse") == 0) {
1105  if (god_removes_curse(op, 0))
1106  return;
1107 
1108  continue;
1109  }
1110 
1111  /* Remove damnation */
1112  if (item->type == BOOK && item->invisible
1113  && strcmp(item->name, "remove damnation") == 0) {
1114  if (god_removes_curse(op, 1))
1115  return;
1116 
1117  continue;
1118  }
1119 
1120  /* Heal depletion */
1121  if (item->type == BOOK && item->invisible
1122  && strcmp(item->name, "heal depletion") == 0) {
1123  object *depl;
1124  archetype *at;
1125  int i;
1126 
1127  if ((at = find_archetype(ARCH_DEPLETION)) == NULL) {
1128  continue;
1129  }
1130  depl = arch_present_in_ob(at, op);
1131  if (depl == NULL)
1132  continue;
1134  "Shimmering light surrounds and restores you!");
1135  for (i = 0; i < NUM_STATS; i++)
1136  if (get_attr_value(&depl->stats, i))
1139  restore_msg[i]);
1140  object_remove(depl);
1142  fix_object(op);
1143  return;
1144  }
1145 
1146  /* Voices */
1147  if (item->type == BOOK && item->invisible
1148  && strcmp(item->name, "voice_behind") == 0) {
1150  "You hear a voice from behind you, but you don't dare to "
1151  "turn around:");
1153  item->msg);
1154  return;
1155  }
1156 
1157  /* Messages */
1158  if (item->type == BOOK && item->invisible
1159  && strcmp(item->name, "message") == 0) {
1161  item->msg);
1162  return;
1163  }
1164 
1165  /* Enchant weapon */
1166  if (item->type == BOOK && item->invisible
1167  && strcmp(item->name, "enchant weapon") == 0) {
1168  if (god_enchants_weapon(op, god, item, skill))
1169  return;
1170 
1171  continue;
1172  }
1173 
1174  /* Spellbooks - works correctly only for prayers */
1175  if (item->type == SPELL) {
1176  if (check_spell_known(op, item->name))
1177  continue;
1178  if (item->level > skill->level)
1179  continue;
1180 
1182  "%s grants you use of a special prayer!",
1183  god->name);
1184  do_learn_spell(op, item, 1);
1185  return;
1186  }
1187 
1188  /* Other gifts */
1189  if (!item->invisible) {
1190  if (god_gives_present(op, god, tr))
1191  return;
1192 
1193  continue;
1194  }
1195  /* else ignore it */
1196  }
1197 
1199  "You feel rapture.");
1200 }
1201 
1214 static int god_examines_priest(object *op, const object *god) {
1215  int reaction = 1;
1216  object *skop;
1217 
1218  FOR_INV_PREPARE(op, item)
1219  if (QUERY_FLAG(item, FLAG_APPLIED)) {
1220  reaction += god_examines_item(god, item)*(item->magic ? abs(item->magic) : 1);
1221  }
1222  FOR_INV_FINISH();
1223 
1224  /* well, well. Looks like we screwed up. Time for god's revenge */
1225  if (reaction < 0) {
1226  int loss = 10000000;
1227  int angry = abs(reaction);
1228 
1230  if (skop)
1231  loss = 0.05*(float)skop->stats.exp;
1232  change_exp(op, -random_roll(0, loss*angry-1, op, PREFER_LOW), skop ? skop->skill : "none", SK_SUBTRACT_SKILL_EXP);
1233  if (random_roll(0, angry, op, PREFER_LOW)) {
1234  object *tmp = create_archetype(LOOSE_MANA);
1235 
1236  cast_magic_storm(op, tmp, op->level+(angry*3));
1237  }
1239  "%s becomes angry and punishes you!",
1240  god->name);
1241  }
1242  return reaction;
1243 }
1244 
1261 static int god_examines_item(const object *god, object *item) {
1262  char buf[MAX_BUF];
1263 
1264  if (!god || !item)
1265  return 0;
1266 
1267  if (!item->title)
1268  return 1; /* unclaimed item are ok */
1269 
1270  snprintf(buf, sizeof(buf), "of %s", god->name);
1271  if (!strcmp(item->title, buf))
1272  return 1; /* belongs to that God */
1273 
1274  if (god->title) { /* check if we have any enemy blessed item*/
1275  snprintf(buf, sizeof(buf), "of %s", god->title);
1276  if (!strcmp(item->title, buf)) {
1277  if (item->env) {
1278  char name[MAX_BUF];
1279 
1280  query_name(item, name, MAX_BUF);
1282  "Heretic! You are using %s!",
1283  name);
1284  }
1285  return -1;
1286  }
1287  }
1288  return 0; /* item is sacred to a non-enemy god/or is otherwise magical */
1289 }
1290 
1301 static const char *get_god_for_race(const char *race) {
1302  godlink *gl = first_god;
1303  const char *godname = NULL;
1304 
1305  if (race == NULL)
1306  return NULL;
1307  while (gl) {
1308  if (gl->arch->clone.race && !strcasecmp(gl->arch->clone.race, race)) {
1309  godname = gl->name;
1310  break;
1311  }
1312  gl = gl->next;
1313  }
1314  return godname;
1315 }
1316 
1328 int tailor_god_spell(object *spellop, object *caster) {
1329  const object *god = find_god(determine_god(caster));
1330  int caster_is_spell = 0;
1331 
1332  if (caster->type == SPELL_EFFECT || caster->type == SPELL)
1333  caster_is_spell = 1;
1334 
1335  /* if caster is a rune or the like, it doesn't worship anything. However,
1336  * if this object is owned by someone, then the god that they worship
1337  * is relevant, so use that.
1338  */
1339  if (!god && object_get_owner(caster))
1340  god = find_god(determine_god(object_get_owner(caster)));
1341 
1342  if (!god || (spellop->attacktype&AT_HOLYWORD && !god->race)) {
1343  if (!caster_is_spell)
1345  "This prayer is useless unless you worship an appropriate god");
1346  else
1347  LOG(llevError, "BUG: tailor_god_spell(): no god\n");
1348  object_free_drop_inventory(spellop);
1349  return 0;
1350  }
1351 
1352  /* either holy word or godpower attacks will set the slaying field */
1353  if (spellop->attacktype&AT_HOLYWORD || spellop->attacktype&AT_GODPOWER) {
1354  if (spellop->slaying) {
1355  free_string(spellop->slaying);
1356  spellop->slaying = NULL;
1357  }
1358  if (!caster_is_spell)
1359  spellop->slaying = god->slaying ? add_string(god->slaying) : NULL;
1360  else if (caster->slaying)
1361  spellop->slaying = add_string(caster->slaying);
1362  }
1363 
1364  /* only the godpower attacktype adds the god's attack onto the spell */
1365  if (spellop->attacktype&AT_GODPOWER)
1366  spellop->attacktype = spellop->attacktype|god->attacktype;
1367 
1368  /* tack on the god's name to the spell */
1369  if (spellop->attacktype&AT_HOLYWORD || spellop->attacktype&AT_GODPOWER) {
1370  if (spellop->title)
1371  free_string(spellop->title);
1372  spellop->title = add_string(god->name);
1373  if (spellop->title) {
1374  char buf[MAX_BUF];
1375 
1376  snprintf(buf, sizeof(buf), "%s of %s", spellop->name, spellop->title);
1377  FREE_AND_COPY(spellop->name, buf);
1378  FREE_AND_COPY(spellop->name_pl, buf);
1379  }
1380  }
1381 
1382  return 1;
1383 }
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:847
#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:3007
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:735
#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:703
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:466
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:1727
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:190
static int god_examines_priest(object *op, const object *god)
Checks and maybe punishes someone praying.
Definition: gods.c:1214
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:1328
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:1301
#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:226
#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:1261
void player_unready_range_ob(player *pl, object *ob)
Unready an object for a player.
Definition: player.c:4439
#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:680
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:2076
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:783
#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:252
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:816
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:986
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:880
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:402
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:547
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:292
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:168
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:625
#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:1120
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:296
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:650