ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/gods.C
(Generate patch)

Comparing deliantra/server/server/gods.C (file contents):
Revision 1.12 by elmex, Wed Dec 20 10:31:00 2006 UTC vs.
Revision 1.35 by root, Sun May 4 18:46:01 2008 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 *
20 21 * The authors can be reached via e-mail to <support@deliantra.net>
21 The authors can be reached via e-mail at <crossfire@schmorp.de>
22*/ 22 */
23
24 23
25/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and 24/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and
26 * monster race initialization. b.t. 25 * monster race initialization. b.t.
27 */ 26 */
28 27
31#include <global.h> 30#include <global.h>
32#include <living.h> 31#include <living.h>
33#include <object.h> 32#include <object.h>
34#include <spells.h> 33#include <spells.h>
35#include <sounds.h> 34#include <sounds.h>
36#ifndef __CEXTRACT__
37# include <sproto.h> 35#include <sproto.h>
38#endif
39 36
40/** 37/**
41 * Returns the id of specified god. 38 * Returns the id of specified god.
42 */ 39 */
43int 40int
51 godlink *gl; 48 godlink *gl;
52 49
53 for (gl = first_god; gl; gl = gl->next) 50 for (gl = first_god; gl; gl = gl->next)
54 if (!strncmp (name, gl->name, MIN ((size_t) strlen (gl->name), nmlen))) 51 if (!strncmp (name, gl->name, MIN ((size_t) strlen (gl->name), nmlen)))
55 break; 52 break;
53
56 if (gl) 54 if (gl)
57 godnr = gl->id; 55 godnr = gl->id;
58 } 56 }
57
59 return godnr; 58 return godnr;
60} 59}
61 60
62/** 61/**
63 * Returns pointer to specified god's object through pntr_to_god_obj.. 62 * Returns pointer to specified god's object through pntr_to_god_obj..
105 { 104 {
106 105
107 /* find a god based on race */ 106 /* find a god based on race */
108 if (!op->title) 107 if (!op->title)
109 { 108 {
110 if (op->race != NULL) 109 if (op->race)
111 { 110 {
112 godname = get_god_for_race (op->race); 111 godname = get_god_for_race (op->race);
112
113 if (godname != NULL) 113 if (godname)
114 {
115 op->title = godname; 114 op->title = godname;
116 }
117 } 115 }
118 } 116 }
119 117
120 /* find a random god */ 118 /* find a random god */
121 if (!op->title) 119 if (!op->title)
125 godnr = rndm (1, gl->id); 123 godnr = rndm (1, gl->id);
126 while (gl) 124 while (gl)
127 { 125 {
128 if (gl->id == godnr) 126 if (gl->id == godnr)
129 break; 127 break;
128
130 gl = gl->next; 129 gl = gl->next;
131 } 130 }
131
132 op->title = gl->name; 132 op->title = gl->name;
133 } 133 }
134 134
135 return op->title; 135 return op->title;
136 } 136 }
141 * that skill, once we find it, we can return, either with the 141 * that skill, once we find it, we can return, either with the
142 * title or "none". 142 * title or "none".
143 */ 143 */
144 if (op->type == PLAYER) 144 if (op->type == PLAYER)
145 { 145 {
146 object *tmp;
147
148 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 146 for (object *tmp = op->inv; tmp; tmp = tmp->below)
149 if (tmp->type == SKILL && tmp->subtype == SK_PRAYING) 147 if (tmp->type == SKILL && tmp->subtype == SK_PRAYING)
150 { 148 {
151 if (tmp->title) 149 if (tmp->title)
152 return (tmp->title); 150 return tmp->title;
153 else 151 else
154 return ("none"); 152 return "none";
155 } 153 }
156 } 154 }
155
157 return ("none"); 156 return "none";
158} 157}
159 158
160/** 159/**
161 * Returns 1 if s1 and s2 are the same - either both NULL, or strcmp( ) == 0 160 * Returns 1 if s1 and s2 are the same - either both NULL, or strcmp( ) == 0
162 */ 161 */
172 return 0; 171 return 0;
173 else 172 else
174 return strcmp (s1, s2) == 0; 173 return strcmp (s1, s2) == 0;
175} 174}
176 175
177
178/** 176/**
179 * Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively). 177 * Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively).
180 * Any matching items in the inventory are deleted, and a 178 * Any matching items in the inventory are deleted, and a
181 * message is displayed to the player. 179 * message is displayed to the player.
182 */ 180 */
201 if (tmp->nrof > 1) 199 if (tmp->nrof > 1)
202 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumble to dust!", query_short_name (tmp)); 200 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumble to dust!", query_short_name (tmp));
203 else 201 else
204 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumbles to dust!", query_short_name (tmp)); 202 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumbles to dust!", query_short_name (tmp));
205 203
206 tmp->remove (); /* remove obj from players inv. */ 204 tmp->destroy ();
207 esrv_del_item (op->contr, tmp->count); /* notify client */
208 tmp->destroy (); /* free object */
209 } 205 }
210 206
211 if (tmp->inv) 207 if (tmp->inv)
212 follower_remove_similar_item (tmp, item); 208 follower_remove_similar_item (tmp, item);
213 } 209 }
239 * God gives an item to the player. 235 * God gives an item to the player.
240 */ 236 */
241static int 237static int
242god_gives_present (object *op, object *god, treasure *tr) 238god_gives_present (object *op, object *god, treasure *tr)
243{ 239{
244 object *tmp; 240 if (!tr->item)
245
246 if (follower_has_similar_item (op, &tr->item->clone))
247 return 0; 241 return 0;
248 242
243 if (follower_has_similar_item (op, tr->item))
244 return 0;
245
249 tmp = arch_to_object (tr->item); 246 object *tmp = arch_to_object (tr->item);
250 new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); 247 new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp));
251 tmp = insert_ob_in_ob (tmp, op); 248 op->insert (tmp);
252 if (op->type == PLAYER) 249
253 esrv_send_item (op, tmp);
254 return 1; 250 return 1;
255} 251}
256 252
257/** 253/**
258 * Player prays at altar. 254 * Player prays at altar.
271 return; 267 return;
272 268
273 /* hmm. what happend depends on pl's current god, level, etc */ 269 /* hmm. what happend depends on pl's current god, level, etc */
274 if (!pl_god) 270 if (!pl_god)
275 { /*new convert */ 271 { /*new convert */
276 become_follower (pl, &altar->other_arch->clone); 272 become_follower (pl, altar->other_arch);
277 return; 273 return;
278
279 } 274 }
280 else if (!strcmp (&pl_god->name, altar->other_arch->clone.name)) 275 else if (!strcmp (&pl_god->name, altar->other_arch->object::name))
281 { 276 {
282 /* pray at your gods altar */ 277 /* pray at your gods altar */
283 int bonus = (pl->stats.Wis + skill->level) / 10; 278 int bonus = (pl->stats.Wis + skill->level) / 10;
284 279
285 /* we can get neg grace up faster */ 280 /* we can get neg grace up faster */
286 if (pl->stats.grace < 0) 281 if (pl->stats.grace < 0)
287 pl->stats.grace += (bonus > -1 * (pl->stats.grace / 10) ? bonus : -1 * (pl->stats.grace / 10)); 282 pl->stats.grace += (bonus > -1 * (pl->stats.grace / 10) ? bonus : -1 * (pl->stats.grace / 10));
283
288 /* we can super-charge grace to 2x max */ 284 /* we can super-charge grace to 2x max */
289 if (pl->stats.grace < (2 * pl->stats.maxgrace)) 285 if (pl->stats.grace < 2 * pl->stats.maxgrace)
290 {
291 pl->stats.grace += bonus / 2; 286 pl->stats.grace += bonus / 2;
292 } 287 else
293 if (pl->stats.grace > (2 * pl->stats.maxgrace))
294 {
295 pl->stats.grace = (2 * pl->stats.maxgrace); 288 pl->stats.grace = 2 * pl->stats.maxgrace;
296 }
297 289
298 /* Every once in a while, the god decides to checkup on their 290 /* Every once in a while, the god decides to checkup on their
299 * follower, and may intervene to help them out. 291 * follower, and may intervene to help them out.
300 */ 292 */
301 bonus = MAX (1, bonus + MAX (pl->stats.luck, -3)); /* -- DAMN -- */ 293 bonus = MAX (1, bonus + MAX (pl->stats.luck, -3)); /* -- DAMN -- */
302 294
303 if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0) 295 if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0)
304 god_intervention (pl, pl_god, skill); 296 god_intervention (pl, pl_god, skill);
305
306 } 297 }
307 else 298 else
308 { /* praying to another god! */ 299 { /* praying to another god! */
309 uint64 loss = 0; 300 uint64 loss = 0;
310 int angry = 1; 301 int angry = 1;
314 * points to the god of this altar (which we have 305 * points to the god of this altar (which we have
315 * already verified is non null). pl_god->other_arch 306 * already verified is non null). pl_god->other_arch
316 * is the opposing god - we need to verify that exists before 307 * is the opposing god - we need to verify that exists before
317 * using its values. 308 * using its values.
318 */ 309 */
319 if (pl_god->other_arch && (altar->other_arch->name == pl_god->other_arch->name)) 310 if (pl_god->other_arch && (altar->other_arch->archname == pl_god->other_arch->archname))
320 { 311 {
321 angry = 2; 312 angry = 2;
322 if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) 313 if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0)
323 { 314 {
324 object *tmp; 315 object *tmp;
345 336
346 /* May switch Gods, but its random chance based on our current level 337 /* May switch Gods, but its random chance based on our current level
347 * note it gets harder to swap gods the higher we get 338 * note it gets harder to swap gods the higher we get
348 */ 339 */
349 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) 340 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW)))
350 {
351 become_follower (pl, &altar->other_arch->clone); 341 become_follower (pl, altar->other_arch);
352 }
353 else 342 else
354 { 343 {
355 /* toss this player off the altar. He can try again. */ 344 /* toss this player off the altar. He can try again. */
356 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); 345 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar.");
346 pl->contr->fire_on = 0;
347 pl->speed_left = 1.f;
357 move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ 348 move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */
358 } 349 }
359 } 350 }
360} 351}
361 352
396 remove = 1; 387 remove = 1;
397 for (tr = god->randomitems->items; tr; tr = tr->next) 388 for (tr = god->randomitems->items; tr; tr = tr->next)
398 { 389 {
399 object *item; 390 object *item;
400 391
401 if (tr->item == NULL) 392 if (!tr->item)
402 continue; 393 continue;
394
403 item = &tr->item->clone; 395 item = tr->item;
404 396
405 /* Basically, see if the matching spell is granted by this god. */ 397 /* Basically, see if the matching spell is granted by this god. */
406 398
407 if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) 399 if (tr->item->type == SPELL && tr->item->object::name == tmp->name)
408 { 400 {
409 remove = 0; 401 remove = 0;
410 break; 402 break;
411 } 403 }
412 } 404 }
457 } 449 }
458 } 450 }
459 451
460 /* remove any godgiven items from the old god */ 452 /* remove any godgiven items from the old god */
461 if (old_god) 453 if (old_god)
462 {
463 for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) 454 for (tr = old_god->randomitems->items; tr; tr = tr->next)
464 {
465 if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) 455 if (tr->item && QUERY_FLAG (tr->item, FLAG_STARTEQUIP))
466 follower_remove_similar_item (op, &tr->item->clone); 456 follower_remove_similar_item (op, tr->item);
467 }
468 }
469 457
470 if (!op || !new_god) 458 if (!op || !new_god)
471 return; 459 return;
472 460
473 if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) 461 if (op->race && new_god->slaying && strstr (op->race, new_god->slaying))
474 { 462 {
475 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); 463 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name);
464
476 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) 465 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0)
477 { 466 {
478 object *tmp = get_archetype (LOOSE_MANA); 467 object *tmp = get_archetype (LOOSE_MANA);
479 468
480 cast_magic_storm (op, tmp, new_god->level + 10); 469 cast_magic_storm (op, tmp, new_god->level + 10);
481 } 470 }
471
482 return; 472 return;
483 } 473 }
484 474
485 475
486 /* give the player any special god-characteristic-items. */ 476 /* give the player any special god-characteristic-items. */
487 for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) 477 for (tr = new_god->randomitems->items; tr; tr = tr->next)
488 { 478 {
489 if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK && 479 if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK
490 tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) 480 && tr->item->type != BOOK && tr->item->type != SPELL)
491 god_gives_present (op, new_god, tr); 481 god_gives_present (op, new_god, tr);
492 } 482 }
493 483
494 484
495 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); 485 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name);
502 if (!skop) 492 if (!skop)
503 { 493 {
504 /* The arhetype should always be defined - if we crash here because it doesn't, 494 /* The arhetype should always be defined - if we crash here because it doesn't,
505 * things are really messed up anyways. 495 * things are really messed up anyways.
506 */ 496 */
507 skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->clone.skill); 497 skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill);
508 link_player_skills (op); 498 link_player_skills (op);
509 } 499 }
510 500
511 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ 501 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */
512 502
519 CLEAR_FLAG (skop, FLAG_UNDEAD); 509 CLEAR_FLAG (skop, FLAG_UNDEAD);
520 undeadified = 1; 510 undeadified = 1;
521 } 511 }
522 512
523 if (skop->title) 513 if (skop->title)
524 { /* get rid of old god */ 514 {
515 /* get rid of old god */
525 new_draw_info_format (NDI_UNIQUE, 0, op, "%s's blessing is withdrawn from you.", &skop->title); 516 new_draw_info_format (NDI_UNIQUE, 0, op, "%s's blessing is withdrawn from you.", &skop->title);
517
526 /* The point of this is to really show what abilities the player just lost */ 518 /* The point of this is to really show what abilities the player just lost */
527 if (sk_applied || undeadified) 519 if (sk_applied || undeadified)
528 { 520 {
529
530 CLEAR_FLAG (skop, FLAG_APPLIED); 521 CLEAR_FLAG (skop, FLAG_APPLIED);
531 (void) change_abil (op, skop); 522 change_abil (op, skop);
532 } 523 }
533 } 524 }
534 525
535 /* now change to the new gods attributes to exp_obj */ 526 /* now change to the new gods attributes to exp_obj */
536 skop->title = new_god->name; 527 skop->title = new_god->name;
607 598
608int 599int
609worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) 600worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string)
610{ 601{
611 602
612 if (QUERY_FLAG (&op->arch->clone, flag)) 603 if (QUERY_FLAG (op->arch, flag))
613 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) 604 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag))
614 { 605 {
615 update_priest_flag (exp_obj, op, flag); 606 update_priest_flag (exp_obj, op, flag);
616 if (QUERY_FLAG (op, flag)) 607 if (QUERY_FLAG (op, flag))
617 new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); 608 new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string);
665/* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/ 656/* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/
666 CLEAR_FLAG (exp_ob, flag); 657 CLEAR_FLAG (exp_ob, flag);
667 }; 658 };
668} 659}
669 660
670
671
672archetype * 661archetype *
673determine_holy_arch (object *god, const char *type) 662determine_holy_arch (object *god, const char *type)
674{ 663{
675 treasure *tr; 664 treasure *tr;
676 665
677 if (!god || !god->randomitems) 666 if (!god || !god->randomitems)
678 { 667 {
679 LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); 668 LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n");
680 return NULL; 669 return 0;
681 } 670 }
682 671
683 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 672 for (tr = god->randomitems->items; tr; tr = tr->next)
684 { 673 {
685 object *item;
686
687 if (!tr->item) 674 if (!tr->item)
688 continue; 675 continue;
689 item = &tr->item->clone; 676
677 object *item = tr->item;
690 678
691 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) 679 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0)
692 return item->other_arch; 680 return item->other_arch;
693 } 681 }
682
694 return NULL; 683 return 0;
695} 684}
696 685
697/** 686/**
698 * God helps player by removing curse and/or damnation. 687 * God helps player by removing curse and/or damnation.
699 */ 688 */
700static int 689static int
701god_removes_curse (object *op, int remove_damnation) 690god_removes_curse (object *op, int remove_damnation)
702{ 691{
703 object *tmp;
704 int success = 0; 692 int success = 0;
705 693
706 for (tmp = op->inv; tmp; tmp = tmp->below) 694 for (object *tmp = op->inv; tmp; tmp = tmp->below)
707 { 695 {
708 if (tmp->invisible) 696 if (tmp->invisible)
709 continue; 697 continue;
698
710 if (QUERY_FLAG (tmp, FLAG_DAMNED) && !remove_damnation) 699 if (QUERY_FLAG (tmp, FLAG_DAMNED) && !remove_damnation)
711 continue; 700 continue;
701
712 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 702 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
713 { 703 {
714 success = 1; 704 success = 1;
715 CLEAR_FLAG (tmp, FLAG_DAMNED); 705 CLEAR_FLAG (tmp, FLAG_DAMNED);
716 CLEAR_FLAG (tmp, FLAG_CURSED); 706 CLEAR_FLAG (tmp, FLAG_CURSED);
717 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED); 707 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED);
718 if (op->type == PLAYER) 708
709 if (object *pl = tmp->visible_to ())
719 esrv_send_item (op, tmp); 710 esrv_update_item (UPD_FLAGS, pl, tmp);
720 } 711 }
721 } 712 }
722 713
723 if (success) 714 if (success)
724 new_draw_info (NDI_UNIQUE, 0, op, "You feel like someone is helping you."); 715 new_draw_info (NDI_UNIQUE, 0, op, "You feel like someone is helping you.");
716
725 return success; 717 return success;
726} 718}
727 719
728static int 720static int
729follower_level_to_enchantments (int level, int difficulty) 721follower_level_to_enchantments (int level, int difficulty)
734 return 0; 726 return 0;
735 } 727 }
736 728
737 if (level <= 20) 729 if (level <= 20)
738 return level / difficulty; 730 return level / difficulty;
731
739 if (level <= 40) 732 if (level <= 40)
740 return (20 + (level - 20) / 2) / difficulty; 733 return (20 + (level - 20) / 2) / difficulty;
734
741 return (30 + (level - 40) / 4) / difficulty; 735 return (30 + (level - 40) / 4) / difficulty;
742} 736}
743 737
744/** 738/**
745 * God wants to enchant weapon. 739 * God wants to enchant weapon.
748 * attacktype, slaying and such. 742 * attacktype, slaying and such.
749 */ 743 */
750static int 744static int
751god_enchants_weapon (object *op, object *god, object *tr, object *skill) 745god_enchants_weapon (object *op, object *god, object *tr, object *skill)
752{ 746{
753 char buf[MAX_BUF];
754 object *weapon; 747 object *weapon;
755 uint32 attacktype; 748 uint32 attacktype;
756 int tmp; 749 int tmp;
757 750
758 for (weapon = op->inv; weapon; weapon = weapon->below) 751 for (weapon = op->inv; weapon; weapon = weapon->below)
759 if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) 752 if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED))
760 break; 753 break;
754
761 if (weapon == NULL || god_examines_item (god, weapon) <= 0) 755 if (!weapon || god_examines_item (god, weapon) <= 0)
762 return 0; 756 return 0;
763 757
764 /* First give it a title, so other gods won't touch it */ 758 /* First give it a title, so other gods won't touch it */
765 if (!weapon->title) 759 if (!weapon->title)
766 { 760 {
767 sprintf (buf, "of %s", &god->name); 761 weapon->title = format ("of %s", &god->name);
768 weapon->title = buf; 762
769 if (op->type == PLAYER) 763 if (object *pl = weapon->visible_to ())
770 esrv_update_item (UPD_NAME, op, weapon); 764 esrv_update_item (UPD_NAME, pl, weapon);
765
771 new_draw_info (NDI_UNIQUE, 0, op, "Your weapon quivers as if struck!"); 766 new_draw_info (NDI_UNIQUE, 0, op, "Your weapon quivers as if struck!");
772 } 767 }
773 768
774 /* Allow the weapon to slay enemies */ 769 /* Allow the weapon to slay enemies */
775 if (!weapon->slaying && god->slaying) 770 if (!weapon->slaying && god->slaying)
792 tmp = follower_level_to_enchantments (skill->level, tr->level); 787 tmp = follower_level_to_enchantments (skill->level, tr->level);
793 if (weapon->magic < tmp) 788 if (weapon->magic < tmp)
794 { 789 {
795 new_draw_info (NDI_UNIQUE, 0, op, "A phosphorescent glow envelops your weapon!"); 790 new_draw_info (NDI_UNIQUE, 0, op, "A phosphorescent glow envelops your weapon!");
796 weapon->magic++; 791 weapon->magic++;
797 if (op->type == PLAYER) 792
793 if (object *pl = weapon->visible_to ())
798 esrv_update_item (UPD_NAME, op, weapon); 794 esrv_update_item (UPD_NAME, pl, weapon);
795
799 return 1; 796 return 1;
800 } 797 }
801 798
802 return 0; 799 return 0;
803} 800}
804
805 801
806/** 802/**
807 * Every once in a while the god will intervene to help the worshiper. 803 * Every once in a while the god will intervene to help the worshiper.
808 * Later, this fctn can be used to supply quests, etc for the 804 * Later, this fctn can be used to supply quests, etc for the
809 * priest. -b.t. 805 * priest. -b.t.
810 * called from pray_at_altar() currently. 806 * called from pray_at_altar() currently.
811 */ 807 */
812
813void 808void
814god_intervention (object *op, object *god, object *skill) 809god_intervention (object *op, object *god, object *skill)
815{ 810{
816 treasure *tr; 811 treasure *tr;
817 812
825 820
826 /* lets do some checks of whether we are kosher with our god */ 821 /* lets do some checks of whether we are kosher with our god */
827 if (god_examines_priest (op, god) < 0) 822 if (god_examines_priest (op, god) < 0)
828 return; 823 return;
829 824
825 op->play_sound (sound_find ("god_intervention"));
830 new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); 826 new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!");
831 827
832 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 828 for (tr = god->randomitems->items; tr; tr = tr->next)
833 { 829 {
834 object *item; 830 object *item;
835 831
836 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) 832 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH))
837 continue; 833 continue;
838 834
839 /* Treasurelist - generate some treasure for the follower */ 835 /* Treasurelist - generate some treasure for the follower */
840 if (tr->name) 836 if (tr->name)
841 { 837 {
842 treasurelist *tl = find_treasurelist (tr->name); 838 treasurelist *tl = treasurelist::find (tr->name);
843 839
844 if (tl == NULL) 840 if (tl == NULL)
845 continue; 841 continue;
846 842
847 new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground."); 843 new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your eyes. You catch it before it falls to the ground.");
848 844
849 create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0); 845 create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD, skill->level, 0);
850 return; 846 return;
851 } 847 }
852 848
853 if (!tr->item) 849 if (!tr->item)
854 {
855 LOG (llevError, "BUG: empty entry in %s's treasure list\n", &god->name);
856 continue; 850 continue;
857 } 851
858 item = &tr->item->clone; 852 item = tr->item;
859 853
860 /* Grace limit */ 854 /* Grace limit */
861 if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) 855 if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0)
862 { 856 {
863 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) 857 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace)
870 tmp = get_archetype (HOLY_POSSESSION); 864 tmp = get_archetype (HOLY_POSSESSION);
871 cast_change_ability (op, op, tmp, 0, 1); 865 cast_change_ability (op, op, tmp, 0, 1);
872 tmp->destroy (); 866 tmp->destroy ();
873 return; 867 return;
874 } 868 }
869
875 continue; 870 continue;
876 } 871 }
877 872
878 /* Restore grace */ 873 /* Restore grace */
879 if (item->type == BOOK && item->invisible && strcmp (item->name, "restore grace") == 0) 874 if (item->type == BOOK && item->invisible && strcmp (item->name, "restore grace") == 0)
903 /* Restore to 50 .. 100%, if sp < 50% */ 898 /* Restore to 50 .. 100%, if sp < 50% */
904 int new_sp = (int) (random_roll (1000, 1999, op, PREFER_HIGH) / 2000.0 * max); 899 int new_sp = (int) (random_roll (1000, 1999, op, PREFER_HIGH) / 2000.0 * max);
905 900
906 if (op->stats.sp >= max / 2) 901 if (op->stats.sp >= max / 2)
907 continue; 902 continue;
903
908 new_draw_info (NDI_UNIQUE, 0, op, "A blue lightning strikes " "your head but doesn't hurt you!"); 904 new_draw_info (NDI_UNIQUE, 0, op, "A blue lightning strikes your head but doesn't hurt you!");
909 op->stats.sp = new_sp; 905 op->stats.sp = new_sp;
910 } 906 }
911 907
912 /* Various heal spells */ 908 /* Various heal spells */
913 if (item->type == BOOK && item->invisible && strcmp (item->name, "heal spell") == 0) 909 if (item->type == BOOK && item->invisible && strcmp (item->name, "heal spell") == 0)
914 { 910 {
915 object *tmp;
916 int success;
917
918 tmp = get_archetype_by_object_name (item->slaying); 911 object *tmp = archetype::get (item->slaying);
919
920 success = cast_heal (op, op, tmp, 0); 912 int success = cast_heal (op, op, tmp, 0);
921 tmp->destroy (); 913 tmp->destroy ();
914
922 if (success) 915 if (success)
923 return; 916 return;
924 else 917 else
925 continue; 918 continue;
926 } 919 }
961 continue; 954 continue;
962 955
963 new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!"); 956 new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!");
964 957
965 for (i = 0; i < NUM_STATS; i++) 958 for (i = 0; i < NUM_STATS; i++)
966 if (get_attr_value (&depl->stats, i)) 959 if (depl->stats.stat (i))
967 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); 960 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]);
968 961
969 depl->destroy (); 962 depl->destroy ();
970 fix_player (op); 963 op->update_stats ();
971 return; 964 return;
972 } 965 }
973 966
974 /* Voices */ 967 /* Voices */
975 if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) 968 if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0)
976 { 969 {
977 new_draw_info (NDI_UNIQUE, 0, op, "You hear a voice from behind you, but you don't dare to " "turn around:"); 970 new_draw_info (NDI_UNIQUE, 0, op, "You hear a voice from behind you, but you don't dare to turn around:");
978 new_draw_info (NDI_WHITE, 0, op, item->msg); 971 new_draw_info (NDI_WHITE, 0, op, item->msg);
979 return; 972 return;
980 } 973 }
981 974
982 /* Messages */ 975 /* Messages */
1133 1126
1134 if (race == NULL) 1127 if (race == NULL)
1135 return NULL; 1128 return NULL;
1136 while (gl) 1129 while (gl)
1137 { 1130 {
1138 if (!strcasecmp (gl->arch->clone.race, race)) 1131 if (!strcasecmp (gl->arch->race, race))
1139 { 1132 {
1140 godname = gl->name; 1133 godname = gl->name;
1141 break; 1134 break;
1142 } 1135 }
1143 gl = gl->next; 1136 gl = gl->next;
1148/** 1141/**
1149 * Changes the attributes of cone, smite, and ball spells as needed by the code. 1142 * Changes the attributes of cone, smite, and ball spells as needed by the code.
1150 * Returns false if there was no race to assign to the slaying field of the spell, but 1143 * Returns false if there was no race to assign to the slaying field of the spell, but
1151 * the spell attacktype contains AT_HOLYWORD. -b.t. 1144 * the spell attacktype contains AT_HOLYWORD. -b.t.
1152 */ 1145 */
1153
1154int 1146int
1155tailor_god_spell (object *spellop, object *caster) 1147tailor_god_spell (object *spellop, object *caster)
1156{ 1148{
1157 object *god = find_god (determine_god (caster)); 1149 object *god = find_god (determine_god (caster));
1158 int caster_is_spell = 0; 1150 int caster_is_spell = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines