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.18 by pippijn, Mon Jan 15 21:06:20 2007 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 (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * 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
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * 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,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * 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
19 * along with this program; if not, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * 20 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 22 */
24
25 23
26/* 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
27 * monster race initialization. b.t. 25 * monster race initialization. b.t.
28 */ 26 */
29 27
50 godlink *gl; 48 godlink *gl;
51 49
52 for (gl = first_god; gl; gl = gl->next) 50 for (gl = first_god; gl; gl = gl->next)
53 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)))
54 break; 52 break;
53
55 if (gl) 54 if (gl)
56 godnr = gl->id; 55 godnr = gl->id;
57 } 56 }
57
58 return godnr; 58 return godnr;
59} 59}
60 60
61/** 61/**
62 * 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..
104 { 104 {
105 105
106 /* find a god based on race */ 106 /* find a god based on race */
107 if (!op->title) 107 if (!op->title)
108 { 108 {
109 if (op->race != NULL) 109 if (op->race)
110 { 110 {
111 godname = get_god_for_race (op->race); 111 godname = get_god_for_race (op->race);
112
112 if (godname != NULL) 113 if (godname)
113 {
114 op->title = godname; 114 op->title = godname;
115 }
116 } 115 }
117 } 116 }
118 117
119 /* find a random god */ 118 /* find a random god */
120 if (!op->title) 119 if (!op->title)
124 godnr = rndm (1, gl->id); 123 godnr = rndm (1, gl->id);
125 while (gl) 124 while (gl)
126 { 125 {
127 if (gl->id == godnr) 126 if (gl->id == godnr)
128 break; 127 break;
128
129 gl = gl->next; 129 gl = gl->next;
130 } 130 }
131
131 op->title = gl->name; 132 op->title = gl->name;
132 } 133 }
133 134
134 return op->title; 135 return op->title;
135 } 136 }
140 * 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
141 * title or "none". 142 * title or "none".
142 */ 143 */
143 if (op->type == PLAYER) 144 if (op->type == PLAYER)
144 { 145 {
145 object *tmp;
146
147 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 146 for (object *tmp = op->inv; tmp; tmp = tmp->below)
148 if (tmp->type == SKILL && tmp->subtype == SK_PRAYING) 147 if (tmp->type == SKILL && tmp->subtype == SK_PRAYING)
149 { 148 {
150 if (tmp->title) 149 if (tmp->title)
151 return (tmp->title); 150 return tmp->title;
152 else 151 else
153 return ("none"); 152 return "none";
154 } 153 }
155 } 154 }
155
156 return ("none"); 156 return "none";
157} 157}
158 158
159/** 159/**
160 * 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
161 */ 161 */
171 return 0; 171 return 0;
172 else 172 else
173 return strcmp (s1, s2) == 0; 173 return strcmp (s1, s2) == 0;
174} 174}
175 175
176
177/** 176/**
178 * 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).
179 * Any matching items in the inventory are deleted, and a 178 * Any matching items in the inventory are deleted, and a
180 * message is displayed to the player. 179 * message is displayed to the player.
181 */ 180 */
200 if (tmp->nrof > 1) 199 if (tmp->nrof > 1)
201 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));
202 else 201 else
203 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));
204 203
205 tmp->remove (); /* remove obj from players inv. */ 204 tmp->destroy ();
206 esrv_del_item (op->contr, tmp->count); /* notify client */
207 tmp->destroy (); /* free object */
208 } 205 }
209 206
210 if (tmp->inv) 207 if (tmp->inv)
211 follower_remove_similar_item (tmp, item); 208 follower_remove_similar_item (tmp, item);
212 } 209 }
238 * God gives an item to the player. 235 * God gives an item to the player.
239 */ 236 */
240static int 237static int
241god_gives_present (object *op, object *god, treasure *tr) 238god_gives_present (object *op, object *god, treasure *tr)
242{ 239{
243 object *tmp;
244
245 if (!tr->item) 240 if (!tr->item)
246 return 0; 241 return 0;
247 242
248 if (follower_has_similar_item (op, &tr->item->clone)) 243 if (follower_has_similar_item (op, tr->item))
249 return 0; 244 return 0;
250 245
251 tmp = arch_to_object (tr->item); 246 object *tmp = arch_to_object (tr->item);
252 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));
253 tmp = insert_ob_in_ob (tmp, op); 248 op->insert (tmp);
254 if (op->type == PLAYER)
255 esrv_send_item (op, tmp);
256 249
257 return 1; 250 return 1;
258} 251}
259 252
260/** 253/**
274 return; 267 return;
275 268
276 /* hmm. what happend depends on pl's current god, level, etc */ 269 /* hmm. what happend depends on pl's current god, level, etc */
277 if (!pl_god) 270 if (!pl_god)
278 { /*new convert */ 271 { /*new convert */
279 become_follower (pl, &altar->other_arch->clone); 272 become_follower (pl, altar->other_arch);
280 return; 273 return;
281
282 } 274 }
283 else if (!strcmp (&pl_god->name, altar->other_arch->clone.name)) 275 else if (!strcmp (&pl_god->name, altar->other_arch->object::name))
284 { 276 {
285 /* pray at your gods altar */ 277 /* pray at your gods altar */
286 int bonus = (pl->stats.Wis + skill->level) / 10; 278 int bonus = (pl->stats.Wis + skill->level) / 10;
287 279
288 /* we can get neg grace up faster */ 280 /* we can get neg grace up faster */
289 if (pl->stats.grace < 0) 281 if (pl->stats.grace < 0)
290 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
291 /* we can super-charge grace to 2x max */ 284 /* we can super-charge grace to 2x max */
292 if (pl->stats.grace < (2 * pl->stats.maxgrace)) 285 if (pl->stats.grace < 2 * pl->stats.maxgrace)
293 {
294 pl->stats.grace += bonus / 2; 286 pl->stats.grace += bonus / 2;
295 } 287 else
296 if (pl->stats.grace > (2 * pl->stats.maxgrace))
297 {
298 pl->stats.grace = (2 * pl->stats.maxgrace); 288 pl->stats.grace = 2 * pl->stats.maxgrace;
299 }
300 289
301 /* 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
302 * follower, and may intervene to help them out. 291 * follower, and may intervene to help them out.
303 */ 292 */
304 bonus = MAX (1, bonus + MAX (pl->stats.luck, -3)); /* -- DAMN -- */ 293 bonus = MAX (1, bonus + MAX (pl->stats.luck, -3)); /* -- DAMN -- */
305 294
306 if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0) 295 if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0)
307 god_intervention (pl, pl_god, skill); 296 god_intervention (pl, pl_god, skill);
308
309 } 297 }
310 else 298 else
311 { /* praying to another god! */ 299 { /* praying to another god! */
312 uint64 loss = 0; 300 uint64 loss = 0;
313 int angry = 1; 301 int angry = 1;
317 * points to the god of this altar (which we have 305 * points to the god of this altar (which we have
318 * already verified is non null). pl_god->other_arch 306 * already verified is non null). pl_god->other_arch
319 * is the opposing god - we need to verify that exists before 307 * is the opposing god - we need to verify that exists before
320 * using its values. 308 * using its values.
321 */ 309 */
322 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))
323 { 311 {
324 angry = 2; 312 angry = 2;
325 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)
326 { 314 {
327 object *tmp; 315 object *tmp;
348 336
349 /* 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
350 * note it gets harder to swap gods the higher we get 338 * note it gets harder to swap gods the higher we get
351 */ 339 */
352 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) 340 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW)))
353 {
354 become_follower (pl, &altar->other_arch->clone); 341 become_follower (pl, altar->other_arch);
355 }
356 else 342 else
357 { 343 {
358 /* toss this player off the altar. He can try again. */ 344 /* toss this player off the altar. He can try again. */
359 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;
360 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. */
361 } 349 }
362 } 350 }
363} 351}
364 352
401 { 389 {
402 object *item; 390 object *item;
403 391
404 if (!tr->item) 392 if (!tr->item)
405 continue; 393 continue;
394
406 item = &tr->item->clone; 395 item = tr->item;
407 396
408 /* Basically, see if the matching spell is granted by this god. */ 397 /* Basically, see if the matching spell is granted by this god. */
409 398
410 if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) 399 if (tr->item->type == SPELL && tr->item->object::name == tmp->name)
411 { 400 {
412 remove = 0; 401 remove = 0;
413 break; 402 break;
414 } 403 }
415 } 404 }
460 } 449 }
461 } 450 }
462 451
463 /* remove any godgiven items from the old god */ 452 /* remove any godgiven items from the old god */
464 if (old_god) 453 if (old_god)
465 {
466 for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) 454 for (tr = old_god->randomitems->items; tr; tr = tr->next)
467 {
468 if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) 455 if (tr->item && QUERY_FLAG (tr->item, FLAG_STARTEQUIP))
469 follower_remove_similar_item (op, &tr->item->clone); 456 follower_remove_similar_item (op, tr->item);
470 }
471 }
472 457
473 if (!op || !new_god) 458 if (!op || !new_god)
474 return; 459 return;
475 460
476 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))
477 { 462 {
478 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
479 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)
480 { 466 {
481 object *tmp = get_archetype (LOOSE_MANA); 467 object *tmp = get_archetype (LOOSE_MANA);
482 468
483 cast_magic_storm (op, tmp, new_god->level + 10); 469 cast_magic_storm (op, tmp, new_god->level + 10);
484 } 470 }
471
485 return; 472 return;
486 } 473 }
487 474
488 475
489 /* give the player any special god-characteristic-items. */ 476 /* give the player any special god-characteristic-items. */
490 for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) 477 for (tr = new_god->randomitems->items; tr; tr = tr->next)
491 { 478 {
492 if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK && 479 if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK
493 tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) 480 && tr->item->type != BOOK && tr->item->type != SPELL)
494 god_gives_present (op, new_god, tr); 481 god_gives_present (op, new_god, tr);
495 } 482 }
496 483
497 484
498 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);
505 if (!skop) 492 if (!skop)
506 { 493 {
507 /* 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,
508 * things are really messed up anyways. 495 * things are really messed up anyways.
509 */ 496 */
510 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);
511 link_player_skills (op); 498 link_player_skills (op);
512 } 499 }
513 500
514 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ 501 sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */
515 502
522 CLEAR_FLAG (skop, FLAG_UNDEAD); 509 CLEAR_FLAG (skop, FLAG_UNDEAD);
523 undeadified = 1; 510 undeadified = 1;
524 } 511 }
525 512
526 if (skop->title) 513 if (skop->title)
527 { /* get rid of old god */ 514 {
515 /* get rid of old god */
528 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
529 /* 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 */
530 if (sk_applied || undeadified) 519 if (sk_applied || undeadified)
531 { 520 {
532
533 CLEAR_FLAG (skop, FLAG_APPLIED); 521 CLEAR_FLAG (skop, FLAG_APPLIED);
534 (void) change_abil (op, skop); 522 change_abil (op, skop);
535 } 523 }
536 } 524 }
537 525
538 /* now change to the new gods attributes to exp_obj */ 526 /* now change to the new gods attributes to exp_obj */
539 skop->title = new_god->name; 527 skop->title = new_god->name;
610 598
611int 599int
612worship_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)
613{ 601{
614 602
615 if (QUERY_FLAG (&op->arch->clone, flag)) 603 if (QUERY_FLAG (op->arch, flag))
616 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) 604 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag))
617 { 605 {
618 update_priest_flag (exp_obj, op, flag); 606 update_priest_flag (exp_obj, op, flag);
619 if (QUERY_FLAG (op, flag)) 607 if (QUERY_FLAG (op, flag))
620 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);
668/* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/ 656/* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/
669 CLEAR_FLAG (exp_ob, flag); 657 CLEAR_FLAG (exp_ob, flag);
670 }; 658 };
671} 659}
672 660
673
674
675archetype * 661archetype *
676determine_holy_arch (object *god, const char *type) 662determine_holy_arch (object *god, const char *type)
677{ 663{
678 treasure *tr; 664 treasure *tr;
679 665
680 if (!god || !god->randomitems) 666 if (!god || !god->randomitems)
681 { 667 {
682 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");
683 return NULL; 669 return 0;
684 } 670 }
685 671
686 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 672 for (tr = god->randomitems->items; tr; tr = tr->next)
687 { 673 {
688 object *item;
689
690 if (!tr->item) 674 if (!tr->item)
691 continue; 675 continue;
692 676
693 item = &tr->item->clone; 677 object *item = tr->item;
694 678
695 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) 679 if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0)
696 return item->other_arch; 680 return item->other_arch;
697 } 681 }
682
698 return NULL; 683 return 0;
699} 684}
700 685
701/** 686/**
702 * God helps player by removing curse and/or damnation. 687 * God helps player by removing curse and/or damnation.
703 */ 688 */
704static int 689static int
705god_removes_curse (object *op, int remove_damnation) 690god_removes_curse (object *op, int remove_damnation)
706{ 691{
707 object *tmp;
708 int success = 0; 692 int success = 0;
709 693
710 for (tmp = op->inv; tmp; tmp = tmp->below) 694 for (object *tmp = op->inv; tmp; tmp = tmp->below)
711 { 695 {
712 if (tmp->invisible) 696 if (tmp->invisible)
713 continue; 697 continue;
698
714 if (QUERY_FLAG (tmp, FLAG_DAMNED) && !remove_damnation) 699 if (QUERY_FLAG (tmp, FLAG_DAMNED) && !remove_damnation)
715 continue; 700 continue;
701
716 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 702 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
717 { 703 {
718 success = 1; 704 success = 1;
719 CLEAR_FLAG (tmp, FLAG_DAMNED); 705 CLEAR_FLAG (tmp, FLAG_DAMNED);
720 CLEAR_FLAG (tmp, FLAG_CURSED); 706 CLEAR_FLAG (tmp, FLAG_CURSED);
721 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED); 707 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED);
722 if (op->type == PLAYER) 708
709 if (object *pl = tmp->visible_to ())
723 esrv_send_item (op, tmp); 710 esrv_update_item (UPD_FLAGS, pl, tmp);
724 } 711 }
725 } 712 }
726 713
727 if (success) 714 if (success)
728 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
729 return success; 717 return success;
730} 718}
731 719
732static int 720static int
733follower_level_to_enchantments (int level, int difficulty) 721follower_level_to_enchantments (int level, int difficulty)
738 return 0; 726 return 0;
739 } 727 }
740 728
741 if (level <= 20) 729 if (level <= 20)
742 return level / difficulty; 730 return level / difficulty;
731
743 if (level <= 40) 732 if (level <= 40)
744 return (20 + (level - 20) / 2) / difficulty; 733 return (20 + (level - 20) / 2) / difficulty;
734
745 return (30 + (level - 40) / 4) / difficulty; 735 return (30 + (level - 40) / 4) / difficulty;
746} 736}
747 737
748/** 738/**
749 * God wants to enchant weapon. 739 * God wants to enchant weapon.
752 * attacktype, slaying and such. 742 * attacktype, slaying and such.
753 */ 743 */
754static int 744static int
755god_enchants_weapon (object *op, object *god, object *tr, object *skill) 745god_enchants_weapon (object *op, object *god, object *tr, object *skill)
756{ 746{
757 char buf[MAX_BUF];
758 object *weapon; 747 object *weapon;
759 uint32 attacktype; 748 uint32 attacktype;
760 int tmp; 749 int tmp;
761 750
762 for (weapon = op->inv; weapon; weapon = weapon->below) 751 for (weapon = op->inv; weapon; weapon = weapon->below)
763 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))
764 break; 753 break;
754
765 if (weapon == NULL || god_examines_item (god, weapon) <= 0) 755 if (!weapon || god_examines_item (god, weapon) <= 0)
766 return 0; 756 return 0;
767 757
768 /* 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 */
769 if (!weapon->title) 759 if (!weapon->title)
770 { 760 {
771 sprintf (buf, "of %s", &god->name); 761 weapon->title = format ("of %s", &god->name);
772 weapon->title = buf; 762
773 if (op->type == PLAYER) 763 if (object *pl = weapon->visible_to ())
774 esrv_update_item (UPD_NAME, op, weapon); 764 esrv_update_item (UPD_NAME, pl, weapon);
765
775 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!");
776 } 767 }
777 768
778 /* Allow the weapon to slay enemies */ 769 /* Allow the weapon to slay enemies */
779 if (!weapon->slaying && god->slaying) 770 if (!weapon->slaying && god->slaying)
796 tmp = follower_level_to_enchantments (skill->level, tr->level); 787 tmp = follower_level_to_enchantments (skill->level, tr->level);
797 if (weapon->magic < tmp) 788 if (weapon->magic < tmp)
798 { 789 {
799 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!");
800 weapon->magic++; 791 weapon->magic++;
801 if (op->type == PLAYER) 792
793 if (object *pl = weapon->visible_to ())
802 esrv_update_item (UPD_NAME, op, weapon); 794 esrv_update_item (UPD_NAME, pl, weapon);
795
803 return 1; 796 return 1;
804 } 797 }
805 798
806 return 0; 799 return 0;
807} 800}
808
809 801
810/** 802/**
811 * 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.
812 * 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
813 * priest. -b.t. 805 * priest. -b.t.
814 * called from pray_at_altar() currently. 806 * called from pray_at_altar() currently.
815 */ 807 */
816
817void 808void
818god_intervention (object *op, object *god, object *skill) 809god_intervention (object *op, object *god, object *skill)
819{ 810{
820 treasure *tr; 811 treasure *tr;
821 812
829 820
830 /* 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 */
831 if (god_examines_priest (op, god) < 0) 822 if (god_examines_priest (op, god) < 0)
832 return; 823 return;
833 824
825 op->play_sound (sound_find ("god_intervention"));
834 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!");
835 827
836 for (tr = god->randomitems->items; tr != NULL; tr = tr->next) 828 for (tr = god->randomitems->items; tr; tr = tr->next)
837 { 829 {
838 object *item; 830 object *item;
839 831
840 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) 832 if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH))
841 continue; 833 continue;
842 834
843 /* Treasurelist - generate some treasure for the follower */ 835 /* Treasurelist - generate some treasure for the follower */
844 if (tr->name) 836 if (tr->name)
845 { 837 {
846 treasurelist *tl = find_treasurelist (tr->name); 838 treasurelist *tl = treasurelist::find (tr->name);
847 839
848 if (tl == NULL) 840 if (tl == NULL)
849 continue; 841 continue;
850 842
851 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.");
852 844
853 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);
854 return; 846 return;
855 } 847 }
856 848
857 if (!tr->item) 849 if (!tr->item)
858 continue; 850 continue;
859 851
860 item = &tr->item->clone; 852 item = tr->item;
861 853
862 /* Grace limit */ 854 /* Grace limit */
863 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)
864 { 856 {
865 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)
872 tmp = get_archetype (HOLY_POSSESSION); 864 tmp = get_archetype (HOLY_POSSESSION);
873 cast_change_ability (op, op, tmp, 0, 1); 865 cast_change_ability (op, op, tmp, 0, 1);
874 tmp->destroy (); 866 tmp->destroy ();
875 return; 867 return;
876 } 868 }
869
877 continue; 870 continue;
878 } 871 }
879 872
880 /* Restore grace */ 873 /* Restore grace */
881 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)
905 /* Restore to 50 .. 100%, if sp < 50% */ 898 /* Restore to 50 .. 100%, if sp < 50% */
906 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);
907 900
908 if (op->stats.sp >= max / 2) 901 if (op->stats.sp >= max / 2)
909 continue; 902 continue;
903
910 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!");
911 op->stats.sp = new_sp; 905 op->stats.sp = new_sp;
912 } 906 }
913 907
914 /* Various heal spells */ 908 /* Various heal spells */
915 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)
916 { 910 {
917 object *tmp;
918 int success;
919
920 tmp = get_archetype_by_object_name (item->slaying); 911 object *tmp = archetype::get (item->slaying);
921
922 success = cast_heal (op, op, tmp, 0); 912 int success = cast_heal (op, op, tmp, 0);
923 tmp->destroy (); 913 tmp->destroy ();
914
924 if (success) 915 if (success)
925 return; 916 return;
926 else 917 else
927 continue; 918 continue;
928 } 919 }
963 continue; 954 continue;
964 955
965 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!");
966 957
967 for (i = 0; i < NUM_STATS; i++) 958 for (i = 0; i < NUM_STATS; i++)
968 if (get_attr_value (&depl->stats, i)) 959 if (depl->stats.stat (i))
969 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); 960 new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]);
970 961
971 depl->destroy (); 962 depl->destroy ();
972 op->update_stats (); 963 op->update_stats ();
973 return; 964 return;
974 } 965 }
975 966
976 /* Voices */ 967 /* Voices */
977 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)
978 { 969 {
979 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:");
980 new_draw_info (NDI_WHITE, 0, op, item->msg); 971 new_draw_info (NDI_WHITE, 0, op, item->msg);
981 return; 972 return;
982 } 973 }
983 974
984 /* Messages */ 975 /* Messages */
1135 1126
1136 if (race == NULL) 1127 if (race == NULL)
1137 return NULL; 1128 return NULL;
1138 while (gl) 1129 while (gl)
1139 { 1130 {
1140 if (!strcasecmp (gl->arch->clone.race, race)) 1131 if (!strcasecmp (gl->arch->race, race))
1141 { 1132 {
1142 godname = gl->name; 1133 godname = gl->name;
1143 break; 1134 break;
1144 } 1135 }
1145 gl = gl->next; 1136 gl = gl->next;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines