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.45 by root, Thu Jan 1 16:05:13 2009 UTC vs.
Revision 1.58 by root, Fri Apr 2 03:41:25 2010 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 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 (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 11 * 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 Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 23 */
23 24
24/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and 25/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and
35#include <sproto.h> 36#include <sproto.h>
36 37
37/** 38/**
38 * Returns the id of specified god. 39 * Returns the id of specified god.
39 */ 40 */
40int 41static int
41lookup_god_by_name (shstr_cmp name) 42lookup_god_by_name (shstr_cmp name)
42{ 43{
43 if (name) 44 if (name)
44 for (godlink *gl = first_god; gl; gl = gl->next) 45 for (godlink *gl = first_god; gl; gl = gl->next)
45 if (gl->name == name) 46 if (gl->name == name)
102 /* find a random god */ 103 /* find a random god */
103 if (!op->title) 104 if (!op->title)
104 { 105 {
105 int godnr = rndm (1, first_god->id); 106 int godnr = rndm (1, first_god->id);
106 107
107 for (godlink *gl = first_god; gl && gl->id != godnr; gl = gl->next) 108 for (godlink *gl = first_god; gl; gl = gl->next)
108 if (gl->id == godnr) 109 if (gl->id == godnr)
109 { 110 {
110 op->title = gl->name; 111 op->title = gl->name;
111 break; 112 break;
112 } 113 }
213 return 0; 214 return 0;
214 215
215 if (follower_has_similar_item (op, tr->item)) 216 if (follower_has_similar_item (op, tr->item))
216 return 0; 217 return 0;
217 218
218 object *tmp = arch_to_object (tr->item); 219 object *tmp = tr->item->instance ();
219 new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); 220 new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp));
220 op->insert (tmp); 221 op->insert (tmp);
221 222
222 return 1; 223 return 1;
223}
224
225/**
226 * Player prays at altar.
227 * Checks for god changing, divine intervention, and so on.
228 */
229void
230pray_at_altar (object *pl, object *altar, object *skill)
231{
232 object *pl_god = find_god (determine_god (pl));
233
234 if (INVOKE_PLAYER (PRAY_ALTAR, pl->contr, ARG_OBJECT (altar), ARG_OBJECT (skill)))
235 return;
236
237 /* If non consecrate altar, don't do anything */
238 if (!altar->other_arch)
239 return;
240
241 /* hmm. what happend depends on pl's current god, level, etc */
242 if (!pl_god)
243 { /*new convert */
244 become_follower (pl, altar->other_arch);
245 return;
246 }
247 else if (!strcmp (&pl_god->name, altar->other_arch->object::name))
248 {
249 /* pray at your gods altar */
250 int bonus = (pl->stats.Wis + skill->level) / 10;
251
252 /* we can get neg grace up faster */
253 if (pl->stats.grace < 0)
254 pl->stats.grace += (bonus > -1 * (pl->stats.grace / 10) ? bonus : -1 * (pl->stats.grace / 10));
255
256 /* we can super-charge grace to 2x max */
257 if (pl->stats.grace < 2 * pl->stats.maxgrace)
258 pl->stats.grace += bonus / 2;
259 else
260 pl->stats.grace = 2 * pl->stats.maxgrace;
261
262 /* Every once in a while, the god decides to checkup on their
263 * follower, and may intervene to help them out.
264 */
265 bonus = MAX (1, bonus + MAX (pl->stats.luck, -3)); /* -- DAMN -- */
266
267 if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0)
268 god_intervention (pl, pl_god, skill);
269 }
270 else
271 { /* praying to another god! */
272 uint64 loss = 0;
273 int angry = 1;
274
275 /* I believe the logic for detecting opposing gods was completely
276 * broken - I think it should work now. altar->other_arch
277 * points to the god of this altar (which we have
278 * already verified is non null). pl_god->other_arch
279 * is the opposing god - we need to verify that exists before
280 * using its values.
281 */
282 if (pl_god->other_arch && (altar->other_arch->archname == pl_god->other_arch->archname))
283 {
284 angry = 2;
285 if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0)
286 {
287 object *tmp;
288
289 /* you really screwed up */
290 angry = 3;
291 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foul Priest! %s punishes you!", &pl_god->name);
292 tmp = get_archetype (LOOSE_MANA);
293 cast_magic_storm (pl, tmp, pl_god->level + 20);
294 }
295 else
296 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foolish heretic! %s is livid!", &pl_god->name);
297 }
298 else
299 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Heretic! %s is angered!", &pl_god->name);
300
301 /* whether we will be successfull in defecting or not -
302 * we lose experience from the clerical experience obj
303 */
304
305 loss = angry * (skill->stats.exp / 10);
306 if (loss)
307 change_exp (pl, -random_roll64 (0, loss, pl, PREFER_LOW), skill ? &skill->skill : "none", SK_SUBTRACT_SKILL_EXP);
308
309 /* May switch Gods, but its random chance based on our current level
310 * note it gets harder to swap gods the higher we get
311 */
312 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW)))
313 become_follower (pl, altar->other_arch);
314 else
315 {
316 /* toss this player off the altar. He can try again. */
317 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar.");
318 pl->contr->fire_on = 0;
319 pl->speed_left = 1.f;
320 move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */
321 }
322 }
323} 224}
324 225
325/** 226/**
326 * Removes special prayers given by a god. 227 * Removes special prayers given by a god.
327 */ 228 */
379 do_forget_spell (op, tmp->name); 280 do_forget_spell (op, tmp->name);
380 } 281 }
381} 282}
382 283
383/** 284/**
285 * Unapplies up to number worth of items of type
286 */
287static void
288stop_using_item (object *op, int type, int number)
289{
290 object *tmp;
291
292 for (tmp = op->inv; tmp && number; tmp = tmp->below)
293 if (tmp->type == type && QUERY_FLAG (tmp, FLAG_APPLIED))
294 {
295 apply_special (op, tmp, AP_UNAPPLY | AP_IGNORE_CURSE);
296 number--;
297 }
298}
299
300/**
301 * If the god does/doesnt have this flag, we
302 * give/remove it from the experience object if it doesnt/does
303 * already exist. For players only!
304 */
305static void
306update_priest_flag (object *god, object *exp_ob, uint32 flag)
307{
308 if (QUERY_FLAG (god, flag) && !QUERY_FLAG (exp_ob, flag))
309 SET_FLAG (exp_ob, flag);
310 else if (QUERY_FLAG (exp_ob, flag) && !QUERY_FLAG (god, flag))
311 {
312 /* When this is called with the exp_ob set to the player,
313 * this check is broken, because most all players arch
314 * allow use of weapons. I'm not actually sure why this
315 * check is here - I guess if you had a case where the
316 * value in the archetype (wisdom) should over ride the restrictions
317 * the god places on it, this may make sense. But I don't think
318 * there is any case like that.
319 */
320
321/* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/
322 CLEAR_FLAG (exp_ob, flag);
323 };
324}
325
326/**
327 * Forbids or let player use something item type.
328 * op is the player.
329 * exp_obj is the widsom experience.
330 * flag is the flag to check against.
331 * string is the string to print out.
332 */
333static int
334worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string)
335{
336 if (QUERY_FLAG (op->arch, flag))
337 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag))
338 {
339 update_priest_flag (exp_obj, op, flag);
340 if (QUERY_FLAG (op, flag))
341 new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string);
342 else
343 {
344 new_draw_info_format (NDI_UNIQUE, 0, op, "You are forbidden to use %s.", string);
345 return 1;
346 }
347 }
348
349 return 0;
350}
351
352/**
384 * This function is called whenever a player has 353 * This function is called whenever a player has
385 * switched to a new god. It handles basically all the stat changes 354 * switched to a new god. It handles basically all the stat changes
386 * that happen to the player, including the removal of godgiven 355 * that happen to the player, including the removal of godgiven
387 * items (from the former cult). 356 * items (from the former cult).
388 */ 357 */
409 { 378 {
410 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); 379 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name);
411 esrv_remove_spell (op->contr, item); 380 esrv_remove_spell (op->contr, item);
412 } 381 }
413 382
414 player_unready_range_ob (op->contr, item);
415 item->destroy (); 383 item->destroy ();
416 } 384 }
417 } 385 }
418 386
419 /* remove any godgiven items from the old god */ 387 /* remove any godgiven items from the old god */
423 follower_remove_similar_item (op, tr->item); 391 follower_remove_similar_item (op, tr->item);
424 392
425 if (!op || !new_god) 393 if (!op || !new_god)
426 return; 394 return;
427 395
428 if (op->race && new_god->slaying && op->race.contains (new_god->slaying)) 396 if (new_god->slaying && op->race.contains (new_god->slaying))
429 { 397 {
430 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); 398 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name);
431 399
432 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) 400 if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0)
433 { 401 {
540 stop_using_item (op, GLOVES, 1); 508 stop_using_item (op, GLOVES, 1);
541 stop_using_item (op, SHIELD, 1); 509 stop_using_item (op, SHIELD, 1);
542 } 510 }
543 511
544 SET_FLAG (skop, FLAG_APPLIED); 512 SET_FLAG (skop, FLAG_APPLIED);
545 (void) change_abil (op, skop); 513 change_abil (op, skop);
546 514
547 /* return to previous skill status */ 515 /* return to previous skill status */
548 if (!sk_applied) 516 if (!sk_applied)
549 CLEAR_FLAG (skop, FLAG_APPLIED); 517 CLEAR_FLAG (skop, FLAG_APPLIED);
550 518
551 check_special_prayers (op, new_god); 519 check_special_prayers (op, new_god);
552}
553
554/**
555 * Forbids or let player use something item type.
556 * op is the player.
557 * exp_obj is the widsom experience.
558 * flag is the flag to check against.
559 * string is the string to print out.
560 */
561
562int
563worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string)
564{
565 if (QUERY_FLAG (op->arch, flag))
566 if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag))
567 {
568 update_priest_flag (exp_obj, op, flag);
569 if (QUERY_FLAG (op, flag))
570 new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string);
571 else
572 {
573 new_draw_info_format (NDI_UNIQUE, 0, op, "You are forbidden to use %s.", string);
574 return 1;
575 }
576 }
577
578 return 0;
579}
580
581/**
582 * Unapplies up to number worth of items of type
583 */
584void
585stop_using_item (object *op, int type, int number)
586{
587 object *tmp;
588
589 for (tmp = op->inv; tmp && number; tmp = tmp->below)
590 if (tmp->type == type && QUERY_FLAG (tmp, FLAG_APPLIED))
591 {
592 apply_special (op, tmp, AP_UNAPPLY | AP_IGNORE_CURSE);
593 number--;
594 }
595}
596
597/**
598 * If the god does/doesnt have this flag, we
599 * give/remove it from the experience object if it doesnt/does
600 * already exist. For players only!
601 */
602
603void
604update_priest_flag (object *god, object *exp_ob, uint32 flag)
605{
606 if (QUERY_FLAG (god, flag) && !QUERY_FLAG (exp_ob, flag))
607 SET_FLAG (exp_ob, flag);
608 else if (QUERY_FLAG (exp_ob, flag) && !QUERY_FLAG (god, flag))
609 {
610 /* When this is called with the exp_ob set to the player,
611 * this check is broken, because most all players arch
612 * allow use of weapons. I'm not actually sure why this
613 * check is here - I guess if you had a case where the
614 * value in the archetype (wisdom) should over ride the restrictions
615 * the god places on it, this may make sense. But I don't think
616 * there is any case like that.
617 */
618
619/* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/
620 CLEAR_FLAG (exp_ob, flag);
621 };
622} 520}
623 521
624archetype * 522archetype *
625determine_holy_arch (object *god, shstr_cmp type) 523determine_holy_arch (object *god, shstr_cmp type)
626{ 524{
697 595
698 return (30 + (level - 40) / 4) / difficulty; 596 return (30 + (level - 40) / 4) / difficulty;
699} 597}
700 598
701/** 599/**
600 * God checks item the player is using.
601 * Return either -1 (bad), 0 (neutral) or
602 * 1 (item is ok). If you are using the item of an enemy
603 * god, it can be bad...-b.t.
604 */
605static int
606god_examines_item (object *god, object *item)
607{
608 char buf[MAX_BUF];
609
610 if (!god || !item)
611 return 0;
612
613 if (!item->title)
614 return 1; /* unclaimed item are ok */
615
616 sprintf (buf, "of %s", &god->name);
617 if (!strcmp (&item->title, buf))
618 return 1; /* belongs to that God */
619
620 if (god->title)
621 { /* check if we have any enemy blessed item */
622 sprintf (buf, "of %s", &god->title);
623 if (!strcmp (&item->title, buf))
624 {
625 if (item->env)
626 {
627 char buf[MAX_BUF];
628
629 sprintf (buf, "Heretic! You are using %s!", query_name (item));
630 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, item->env, buf);
631 }
632
633 return -1;
634 }
635 }
636
637 return 0; /* item is sacred to a non-enemy god/or is otherwise magical */
638}
639
640/**
702 * God wants to enchant weapon. 641 * God wants to enchant weapon.
703 * Affected weapon is the applied one (weapon or bow). It's checked to make sure 642 * Affected weapon is the applied one (weapon or bow). It's checked to make sure
704 * it isn't a weapon for another god. If all is all right, update weapon with 643 * it isn't a weapon for another god. If all is all right, update weapon with
705 * attacktype, slaying and such. 644 * attacktype, slaying and such.
706 */ 645 */
761 700
762 return 0; 701 return 0;
763} 702}
764 703
765/** 704/**
705 * Checks and maybe punishes someone praying.
706 * All applied items are examined, if player is using more items of other gods,
707 * s/he loses experience in praying or general experience if no praying.
708 */
709static int
710god_examines_priest (object *op, object *god)
711{
712 int reaction = 1;
713 object *item = NULL, *skop;
714
715 for (item = op->inv; item; item = item->below)
716 if (QUERY_FLAG (item, FLAG_APPLIED))
717 reaction += god_examines_item (god, item) * (item->magic ? abs (item->magic) : 1);
718
719 /* well, well. Looks like we screwed up. Time for god's revenge */
720 if (reaction < 0)
721 {
722 int loss = 10000000;
723 int angry = abs (reaction);
724
725 for (skop = op->inv; skop; skop = skop->below)
726 if (skop->type == SKILL && skop->subtype == SK_PRAYING)
727 break;
728
729 if (skop)
730 loss = 0.05f * skop->stats.exp;
731
732 change_exp (op, -random_roll (0, loss * angry - 1, op, PREFER_LOW), skop ? &skop->skill : "none", SK_SUBTRACT_SKILL_EXP);
733
734 if (random_roll (0, angry, op, PREFER_LOW))
735 {
736 object *tmp = get_archetype (LOOSE_MANA);
737
738 cast_magic_storm (op, tmp, op->level + (angry * 3));
739 }
740
741 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "%s becomes angry and punishes you!", &god->name);
742 }
743
744 return reaction;
745}
746
747/**
766 * Every once in a while the god will intervene to help the worshiper. 748 * Every once in a while the god will intervene to help the worshiper.
767 * Later, this fctn can be used to supply quests, etc for the 749 * Later, this fctn can be used to supply quests, etc for the
768 * priest. -b.t. 750 * priest. -b.t.
769 * called from pray_at_altar() currently. 751 * called from pray_at_altar() currently.
770 */ 752 */
771void 753static void
772god_intervention (object *op, object *god, object *skill) 754god_intervention (object *op, object *god, object *skill)
773{ 755{
774 treasure *tr; 756 treasure *tr;
775 757
776 if (!god || !god->randomitems) 758 if (!god || !god->randomitems)
904 { 886 {
905 object *depl; 887 object *depl;
906 archetype *at; 888 archetype *at;
907 int i; 889 int i;
908 890
909 if ((at = archetype::find (ARCH_DEPLETION)) == NULL) 891 if ((at = archetype::find (shstr_depletion)) == NULL)
910 { 892 {
911 LOG (llevError, "Could not find archetype depletion.\n"); 893 LOG (llevError, "Could not find archetype depletion.\n");
912 continue; 894 continue;
913 } 895 }
914 896
979 961
980 new_draw_info (NDI_UNIQUE, 0, op, "You feel rapture."); 962 new_draw_info (NDI_UNIQUE, 0, op, "You feel rapture.");
981} 963}
982 964
983/** 965/**
984 * Checks and maybe punishes someone praying. 966 * Player prays at altar.
985 * All applied items are examined, if player is using more items of other gods, 967 * Checks for god changing, divine intervention, and so on.
986 * s/he loses experience in praying or general experience if no praying.
987 */ 968 */
988int 969void
989god_examines_priest (object *op, object *god) 970pray_at_altar (object *pl, object *altar, object *skill)
990{ 971{
991 int reaction = 1; 972 object *pl_god = find_god (determine_god (pl));
992 object *item = NULL, *skop;
993 973
994 for (item = op->inv; item; item = item->below) 974 if (INVOKE_PLAYER (PRAY_ALTAR, pl->contr, ARG_OBJECT (altar), ARG_OBJECT (skill)))
995 if (QUERY_FLAG (item, FLAG_APPLIED))
996 reaction += god_examines_item (god, item) * (item->magic ? abs (item->magic) : 1);
997
998 /* well, well. Looks like we screwed up. Time for god's revenge */
999 if (reaction < 0)
1000 {
1001 int loss = 10000000;
1002 int angry = abs (reaction);
1003
1004 for (skop = op->inv; skop; skop = skop->below)
1005 if (skop->type == SKILL && skop->subtype == SK_PRAYING)
1006 break;
1007
1008 if (skop)
1009 loss = 0.05f * skop->stats.exp;
1010
1011 change_exp (op, -random_roll (0, loss * angry - 1, op, PREFER_LOW), skop ? &skop->skill : "none", SK_SUBTRACT_SKILL_EXP);
1012
1013 if (random_roll (0, angry, op, PREFER_LOW))
1014 {
1015 object *tmp = get_archetype (LOOSE_MANA);
1016
1017 cast_magic_storm (op, tmp, op->level + (angry * 3));
1018 }
1019
1020 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "%s becomes angry and punishes you!", &god->name);
1021 }
1022
1023 return reaction;
1024}
1025
1026/**
1027 * God checks item the player is using.
1028 * Return either -1 (bad), 0 (neutral) or
1029 * 1 (item is ok). If you are using the item of an enemy
1030 * god, it can be bad...-b.t.
1031 */
1032int
1033god_examines_item (object *god, object *item)
1034{
1035 char buf[MAX_BUF];
1036
1037 if (!god || !item)
1038 return 0; 975 return;
1039 976
1040 if (!item->title) 977 /* If non consecrate altar, don't do anything */
1041 return 1; /* unclaimed item are ok */ 978 if (!altar->other_arch)
979 return;
1042 980
1043 sprintf (buf, "of %s", &god->name); 981 /* hmm. what happend depends on pl's current god, level, etc */
1044 if (!strcmp (&item->title, buf)) 982 if (!pl_god)
1045 return 1; /* belongs to that God */ 983 { /*new convert */
984 become_follower (pl, altar->other_arch);
985 return;
986 }
987 else if (pl_god->name == altar->other_arch->object::name)
988 {
989 /* pray at your gods altar */
990 /* this leads to very low levels of wis and pray to result in no doubling! */
991 int bonus = (pl->stats.Wis + skill->level) / 10;
1046 992
1047 if (god->title) 993 /* we can get neg grace up faster */
1048 { /* check if we have any enemy blessed item */ 994 if (pl->stats.grace < 0)
1049 sprintf (buf, "of %s", &god->title); 995 pl->stats.grace += (bonus > -1 * (pl->stats.grace / 10) ? bonus : -1 * (pl->stats.grace / 10));
1050 if (!strcmp (&item->title, buf)) 996
997 /* we can super-charge grace to 2x max */
998 if (pl->stats.grace < 2 * pl->stats.maxgrace)
999 pl->stats.grace += bonus / 2;
1000 else
1001 pl->stats.grace = 2 * pl->stats.maxgrace;
1002
1003 /* Every once in a while, the god decides to checkup on their
1004 * follower, and may intervene to help them out.
1051 { 1005 */
1052 if (item->env) 1006 bonus = max (1, bonus + max (pl->stats.luck, -3)); /* -- DAMN -- */
1007
1008 if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0)
1009 god_intervention (pl, pl_god, skill);
1010 }
1011 else
1012 { /* praying to another god! */
1013 uint64 loss = 0;
1014 int angry = 1;
1015
1016 /* I believe the logic for detecting opposing gods was completely
1017 * broken - I think it should work now. altar->other_arch
1018 * points to the god of this altar (which we have
1019 * already verified is non null). pl_god->other_arch
1020 * is the opposing god - we need to verify that exists before
1021 * using its values.
1022 */
1023 if (pl_god->other_arch && (altar->other_arch->archname == pl_god->other_arch->archname))
1024 {
1025 angry = 2;
1026 if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0)
1053 { 1027 {
1054 char buf[MAX_BUF]; 1028 object *tmp;
1055 1029
1056 sprintf (buf, "Heretic! You are using %s!", query_name (item)); 1030 /* you really screwed up */
1057 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, item->env, buf); 1031 angry = 3;
1032 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foul Priest! %s punishes you!", &pl_god->name);
1033 tmp = get_archetype (LOOSE_MANA);
1034 cast_magic_storm (pl, tmp, pl_god->level + 20);
1058 } 1035 }
1036 else
1037 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foolish heretic! %s is livid!", &pl_god->name);
1038 }
1039 else
1040 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Heretic! %s is angered!", &pl_god->name);
1059 1041
1060 return -1; 1042 /* whether we will be successfull in defecting or not -
1043 * we lose experience from the clerical experience obj
1044 */
1045
1046 loss = angry * (skill->stats.exp / 10);
1047 if (loss)
1048 change_exp (pl, -random_roll64 (0, loss, pl, PREFER_LOW), skill ? &skill->skill : "none", SK_SUBTRACT_SKILL_EXP);
1049
1050 /* May switch Gods, but its random chance based on our current level
1051 * note it gets harder to swap gods the higher we get
1052 */
1053 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW)))
1054 become_follower (pl, altar->other_arch);
1055 else
1061 } 1056 {
1057 /* toss this player off the altar. He can try again. */
1058 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar.");
1059 pl->contr->fire_on = 0;
1060 pl->speed_left = 1.f;
1061 move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */
1062 }
1062 } 1063 }
1063
1064 return 0; /* item is sacred to a non-enemy god/or is otherwise magical */
1065}
1066
1067/**
1068 * Returns priest's god's id.
1069 * Straight calls lookup_god_by_name
1070 */
1071int
1072get_god (object *priest)
1073{
1074 return lookup_god_by_name (determine_god (priest));
1075} 1064}
1076 1065
1077/** 1066/**
1078 * Changes the attributes of cone, smite, and ball spells as needed by the code. 1067 * Changes the attributes of cone, smite, and ball spells as needed by the code.
1079 * Returns false if there was no race to assign to the slaying field of the spell, but 1068 * Returns false if there was no race to assign to the slaying field of the spell, but

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines