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.65 by root, Thu Jun 10 06:03:18 2010 UTC vs.
Revision 1.74 by root, Sat Nov 17 23:40:03 2018 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 (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 6 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 9 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 10 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 11 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 12 * option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 17 * GNU General Public License for more details.
17 * 18 *
18 * You should have received a copy of the Affero GNU General Public License 19 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 20 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 21 * <http://www.gnu.org/licenses/>.
21 * 22 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 23 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 24 */
24 25
25/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and 26/* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and
26 * monster race initialization. b.t. 27 * monster race initialization. b.t.
62 63
63 return 0; 64 return 0;
64} 65}
65 66
66/** 67/**
67 * Returns a string that is the name of the god that should be natively worshipped by a 68 * Returns a string that is the name of the god that should be natively worshipped by a
68 * creature of who has race *race 69 * creature of who has race *race
69 * if we can't find a god that is appropriate, we return NULL 70 * if we can't find a god that is appropriate, we return NULL
70 */ 71 */
71static shstr_tmp 72static shstr_tmp
72get_god_for_race (shstr_cmp race) 73get_god_for_race (shstr_cmp race)
80} 81}
81 82
82/** 83/**
83 * Determines if op worships a god. 84 * Determines if op worships a god.
84 * Returns the godname if they do or "none" if they have no god. 85 * Returns the godname if they do or "none" if they have no god.
85 * In the case of an NPC, if they have no god, we try and guess 86 * In the case of an NPC, if they have no god, we try and guess
86 * who they should worship based on their race. If that fails we 87 * who they should worship based on their race. If that fails we
87 * give them a random one. 88 * give them a random one.
88 */ 89 */
89shstr_tmp 90shstr_tmp
90determine_god (object *op) 91determine_god (object *op)
91{ 92{
397 follower_remove_similar_item (this, tr->item); 398 follower_remove_similar_item (this, tr->item);
398 399
399 if (!new_god) 400 if (!new_god)
400 return; 401 return;
401 402
402 if (new_god->slaying && race.contains (new_god->slaying)) 403 if (new_god->slaying && new_god->slaying.contains (race))
403 { 404 {
404 failmsgf ("Fool! %s detests your kind! H<This god does not accept followers of your race.>", &new_god->name); 405 failmsgf ("Fool! %s detests your kind! H<This god does not accept followers of your race.>", &new_god->name);
405 406
406 if (random_roll (0, level - 1, this, PREFER_LOW) - 5 > 0) 407 if (random_roll (0, level - 1, this, PREFER_LOW) - 5 > 0)
407 { 408 {
408 object *tmp = get_archetype (LOOSE_MANA); 409 object *tmp = archetype::get (LOOSE_MANA);
409 410
410 cast_magic_storm (this, tmp, new_god->level + 10); 411 cast_magic_storm (this, tmp, new_god->level + 10);
411 } 412 }
412 413
413 return; 414 return;
464 skop->path_denied = new_god->path_denied; 465 skop->path_denied = new_god->path_denied;
465 /* copy god's resistances */ 466 /* copy god's resistances */
466 memcpy (skop->resist, new_god->resist, sizeof (new_god->resist)); 467 memcpy (skop->resist, new_god->resist, sizeof (new_god->resist));
467 468
468 /* make sure that certain immunities do NOT get passed 469 /* make sure that certain immunities do NOT get passed
469 * to the follower! 470 * to the follower!
470 */ 471 */
471 for (i = 0; i < NROFATTACKS; i++) 472 for (i = 0; i < NROFATTACKS; i++)
472 if (skop->resist[i] > 30 && (i == ATNR_FIRE || i == ATNR_COLD || i == ATNR_ELECTRICITY || i == ATNR_POISON)) 473 if (skop->resist[i] > 30 && (i == ATNR_FIRE || i == ATNR_COLD || i == ATNR_ELECTRICITY || i == ATNR_POISON))
473 skop->resist[i] = 30; 474 skop->resist[i] = 30;
474 475
656 if (!op->contr) 657 if (!op->contr)
657 return 0; 658 return 0;
658 659
659 object *weapon = op->contr->combat_ob; 660 object *weapon = op->contr->combat_ob;
660 661
662 if (!weapon)
663 return 0;
664
661 if (weapon->type != WEAPON && weapon->type != BOW) 665 if (weapon->type != WEAPON && weapon->type != BOW)
662 return 0; 666 return 0;
663 667
664 if (god_examines_item (god, weapon) <= 0) 668 if (god_examines_item (god, weapon) <= 0)
665 return 0; 669 return 0;
738 742
739 change_exp (op, -random_roll (0, loss * angry - 1, op, PREFER_LOW), skop ? skop->skill : shstr_none, SK_SUBTRACT_SKILL_EXP); 743 change_exp (op, -random_roll (0, loss * angry - 1, op, PREFER_LOW), skop ? skop->skill : shstr_none, SK_SUBTRACT_SKILL_EXP);
740 744
741 if (random_roll (0, angry, op, PREFER_LOW)) 745 if (random_roll (0, angry, op, PREFER_LOW))
742 { 746 {
743 object *tmp = get_archetype (LOOSE_MANA); 747 object *tmp = archetype::get (LOOSE_MANA);
744 748
745 cast_magic_storm (op, tmp, op->level + (angry * 3)); 749 cast_magic_storm (op, tmp, op->level + (angry * 3));
746 } 750 }
747 751
748 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "%s becomes angry and punishes you!", &god->name); 752 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "%s becomes angry and punishes you!", &god->name);
751 return reaction; 755 return reaction;
752} 756}
753 757
754/** 758/**
755 * Every once in a while the god will intervene to help the worshiper. 759 * Every once in a while the god will intervene to help the worshiper.
756 * Later, this fctn can be used to supply quests, etc for the 760 * Later, this fctn can be used to supply quests, etc for the
757 * priest. -b.t. 761 * priest. -b.t.
758 * called from pray_at_altar() currently. 762 * called from pray_at_altar() currently.
759 */ 763 */
760static void 764static void
761god_intervention (object *op, object *god, object *skill) 765god_intervention (object *op, object *god, object *skill)
762{ 766{
763 treasure *tr; 767 treasure *tr;
809 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) 813 if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace)
810 { 814 {
811 /* Follower lacks the required grace for the following 815 /* Follower lacks the required grace for the following
812 * treasure list items. */ 816 * treasure list items. */
813 817
814 object *tmp = get_archetype (HOLY_POSSESSION); 818 object *tmp = archetype::get (HOLY_POSSESSION);
815 cast_change_ability (op, op, tmp, 0, 1); 819 cast_change_ability (op, op, tmp, 0, 1);
816 tmp->destroy (); 820 tmp->destroy ();
817 return; 821 return;
818 } 822 }
819 823
1035 object *tmp; 1039 object *tmp;
1036 1040
1037 /* you really screwed up */ 1041 /* you really screwed up */
1038 angry = 3; 1042 angry = 3;
1039 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foul Priest! %s punishes you!", &pl_god->name); 1043 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foul Priest! %s punishes you!", &pl_god->name);
1040 tmp = get_archetype (LOOSE_MANA); 1044 tmp = archetype::get (LOOSE_MANA);
1041 cast_magic_storm (pl, tmp, pl_god->level + 20); 1045 cast_magic_storm (pl, tmp, pl_god->level + 20);
1042 } 1046 }
1043 else 1047 else
1044 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foolish heretic! %s is livid!", &pl_god->name); 1048 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Foolish heretic! %s is livid!", &pl_god->name);
1045 } 1049 }
1046 else 1050 else
1047 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Heretic! %s is angered!", &pl_god->name); 1051 new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, pl, "Heretic! %s is angered!", &pl_god->name);
1048 1052
1049 /* whether we will be successfull in defecting or not - 1053 /* whether we will be successfull in defecting or not -
1050 * we lose experience from the clerical experience obj 1054 * we lose experience from the clerical experience obj
1051 */ 1055 */
1052 1056
1053 loss = angry * (skill->stats.exp / 10); 1057 loss = angry * (skill->stats.exp / 10);
1054 if (loss) 1058 if (loss)
1055 change_exp (pl, -random_roll64 (0, loss, pl, PREFER_LOW), skill ? skill->skill : shstr_none, SK_SUBTRACT_SKILL_EXP); 1059 change_exp (pl, -random_roll64 (0, loss, pl, PREFER_LOW), skill ? skill->skill : shstr_none, SK_SUBTRACT_SKILL_EXP);
1056 1060
1057 /* May switch Gods, but its random chance based on our current level 1061 /* May switch Gods, but its random chance based on our current level
1058 * note it gets harder to swap gods the higher we get 1062 * note it gets harder to swap gods the higher we get
1059 */ 1063 */
1060 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) 1064 if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW)))
1061 pl->become_follower (altar->other_arch); 1065 pl->become_follower (altar->other_arch);
1062 else 1066 else
1063 { 1067 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines