1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT 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 | * Crossfire TRT 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 <crossfire@schmorp.de> |
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.. |
… | |
… | |
124 | godnr = rndm (1, gl->id); |
124 | godnr = rndm (1, gl->id); |
125 | while (gl) |
125 | while (gl) |
126 | { |
126 | { |
127 | if (gl->id == godnr) |
127 | if (gl->id == godnr) |
128 | break; |
128 | break; |
|
|
129 | |
129 | gl = gl->next; |
130 | gl = gl->next; |
130 | } |
131 | } |
|
|
132 | |
131 | op->title = gl->name; |
133 | op->title = gl->name; |
132 | } |
134 | } |
133 | |
135 | |
134 | return op->title; |
136 | return op->title; |
135 | } |
137 | } |
… | |
… | |
171 | return 0; |
173 | return 0; |
172 | else |
174 | else |
173 | return strcmp (s1, s2) == 0; |
175 | return strcmp (s1, s2) == 0; |
174 | } |
176 | } |
175 | |
177 | |
176 | |
|
|
177 | /** |
178 | /** |
178 | * Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively). |
179 | * 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 |
180 | * Any matching items in the inventory are deleted, and a |
180 | * message is displayed to the player. |
181 | * message is displayed to the player. |
181 | */ |
182 | */ |
… | |
… | |
243 | object *tmp; |
244 | object *tmp; |
244 | |
245 | |
245 | if (!tr->item) |
246 | if (!tr->item) |
246 | return 0; |
247 | return 0; |
247 | |
248 | |
248 | if (follower_has_similar_item (op, &tr->item->clone)) |
249 | if (follower_has_similar_item (op, tr->item)) |
249 | return 0; |
250 | return 0; |
250 | |
251 | |
251 | tmp = arch_to_object (tr->item); |
252 | 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)); |
253 | 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); |
254 | tmp = insert_ob_in_ob (tmp, op); |
… | |
… | |
274 | return; |
275 | return; |
275 | |
276 | |
276 | /* hmm. what happend depends on pl's current god, level, etc */ |
277 | /* hmm. what happend depends on pl's current god, level, etc */ |
277 | if (!pl_god) |
278 | if (!pl_god) |
278 | { /*new convert */ |
279 | { /*new convert */ |
279 | become_follower (pl, &altar->other_arch->clone); |
280 | become_follower (pl, altar->other_arch); |
280 | return; |
281 | return; |
281 | |
282 | |
282 | } |
283 | } |
283 | else if (!strcmp (&pl_god->name, altar->other_arch->clone.name)) |
284 | else if (!strcmp (&pl_god->name, altar->other_arch->object::name)) |
284 | { |
285 | { |
285 | /* pray at your gods altar */ |
286 | /* pray at your gods altar */ |
286 | int bonus = (pl->stats.Wis + skill->level) / 10; |
287 | int bonus = (pl->stats.Wis + skill->level) / 10; |
287 | |
288 | |
288 | /* we can get neg grace up faster */ |
289 | /* we can get neg grace up faster */ |
… | |
… | |
317 | * points to the god of this altar (which we have |
318 | * points to the god of this altar (which we have |
318 | * already verified is non null). pl_god->other_arch |
319 | * already verified is non null). pl_god->other_arch |
319 | * is the opposing god - we need to verify that exists before |
320 | * is the opposing god - we need to verify that exists before |
320 | * using its values. |
321 | * using its values. |
321 | */ |
322 | */ |
322 | if (pl_god->other_arch && (altar->other_arch->name == pl_god->other_arch->name)) |
323 | if (pl_god->other_arch && (altar->other_arch->archname == pl_god->other_arch->archname)) |
323 | { |
324 | { |
324 | angry = 2; |
325 | angry = 2; |
325 | if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) |
326 | if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) |
326 | { |
327 | { |
327 | object *tmp; |
328 | object *tmp; |
… | |
… | |
348 | |
349 | |
349 | /* May switch Gods, but its random chance based on our current level |
350 | /* May switch Gods, but its random chance based on our current level |
350 | * note it gets harder to swap gods the higher we get |
351 | * note it gets harder to swap gods the higher we get |
351 | */ |
352 | */ |
352 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
353 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
353 | { |
|
|
354 | become_follower (pl, &altar->other_arch->clone); |
354 | become_follower (pl, altar->other_arch); |
355 | } |
|
|
356 | else |
355 | else |
357 | { |
356 | { |
358 | /* toss this player off the altar. He can try again. */ |
357 | /* 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."); |
358 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); |
|
|
359 | pl->contr->fire_on = 0; |
|
|
360 | pl->speed_left = 1.f; |
360 | move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ |
361 | move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ |
361 | } |
362 | } |
362 | } |
363 | } |
363 | } |
364 | } |
364 | |
365 | |
… | |
… | |
401 | { |
402 | { |
402 | object *item; |
403 | object *item; |
403 | |
404 | |
404 | if (!tr->item) |
405 | if (!tr->item) |
405 | continue; |
406 | continue; |
|
|
407 | |
406 | item = &tr->item->clone; |
408 | item = tr->item; |
407 | |
409 | |
408 | /* Basically, see if the matching spell is granted by this god. */ |
410 | /* Basically, see if the matching spell is granted by this god. */ |
409 | |
411 | |
410 | if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) |
412 | if (tr->item->type == SPELL && tr->item->object::name == tmp->name) |
411 | { |
413 | { |
412 | remove = 0; |
414 | remove = 0; |
413 | break; |
415 | break; |
414 | } |
416 | } |
415 | } |
417 | } |
… | |
… | |
460 | } |
462 | } |
461 | } |
463 | } |
462 | |
464 | |
463 | /* remove any godgiven items from the old god */ |
465 | /* remove any godgiven items from the old god */ |
464 | if (old_god) |
466 | if (old_god) |
465 | { |
|
|
466 | for (tr = old_god->randomitems->items; tr != NULL; tr = tr->next) |
467 | for (tr = old_god->randomitems->items; tr; tr = tr->next) |
467 | { |
|
|
468 | if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) |
468 | if (tr->item && QUERY_FLAG (tr->item, FLAG_STARTEQUIP)) |
469 | follower_remove_similar_item (op, &tr->item->clone); |
469 | follower_remove_similar_item (op, tr->item); |
470 | } |
|
|
471 | } |
|
|
472 | |
470 | |
473 | if (!op || !new_god) |
471 | if (!op || !new_god) |
474 | return; |
472 | return; |
475 | |
473 | |
476 | if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) |
474 | if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) |
477 | { |
475 | { |
478 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); |
476 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); |
|
|
477 | |
479 | if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) |
478 | if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) |
480 | { |
479 | { |
481 | object *tmp = get_archetype (LOOSE_MANA); |
480 | object *tmp = get_archetype (LOOSE_MANA); |
482 | |
481 | |
483 | cast_magic_storm (op, tmp, new_god->level + 10); |
482 | cast_magic_storm (op, tmp, new_god->level + 10); |
484 | } |
483 | } |
|
|
484 | |
485 | return; |
485 | return; |
486 | } |
486 | } |
487 | |
487 | |
488 | |
488 | |
489 | /* give the player any special god-characteristic-items. */ |
489 | /* give the player any special god-characteristic-items. */ |
490 | for (tr = new_god->randomitems->items; tr != NULL; tr = tr->next) |
490 | for (tr = new_god->randomitems->items; tr; tr = tr->next) |
491 | { |
491 | { |
492 | if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK && |
492 | if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK |
493 | tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) |
493 | && tr->item->type != BOOK && tr->item->type != SPELL) |
494 | god_gives_present (op, new_god, tr); |
494 | god_gives_present (op, new_god, tr); |
495 | } |
495 | } |
496 | |
496 | |
497 | |
497 | |
498 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); |
498 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); |
… | |
… | |
505 | if (!skop) |
505 | if (!skop) |
506 | { |
506 | { |
507 | /* The arhetype should always be defined - if we crash here because it doesn't, |
507 | /* The arhetype should always be defined - if we crash here because it doesn't, |
508 | * things are really messed up anyways. |
508 | * things are really messed up anyways. |
509 | */ |
509 | */ |
510 | skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->clone.skill); |
510 | skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill); |
511 | link_player_skills (op); |
511 | link_player_skills (op); |
512 | } |
512 | } |
513 | |
513 | |
514 | sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ |
514 | sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ |
515 | |
515 | |
… | |
… | |
610 | |
610 | |
611 | int |
611 | int |
612 | worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) |
612 | worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) |
613 | { |
613 | { |
614 | |
614 | |
615 | if (QUERY_FLAG (&op->arch->clone, flag)) |
615 | if (QUERY_FLAG (op->arch, flag)) |
616 | if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) |
616 | if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) |
617 | { |
617 | { |
618 | update_priest_flag (exp_obj, op, flag); |
618 | update_priest_flag (exp_obj, op, flag); |
619 | if (QUERY_FLAG (op, flag)) |
619 | if (QUERY_FLAG (op, flag)) |
620 | new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); |
620 | new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); |
… | |
… | |
681 | { |
681 | { |
682 | LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); |
682 | LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); |
683 | return NULL; |
683 | return NULL; |
684 | } |
684 | } |
685 | |
685 | |
686 | for (tr = god->randomitems->items; tr != NULL; tr = tr->next) |
686 | for (tr = god->randomitems->items; tr; tr = tr->next) |
687 | { |
687 | { |
688 | object *item; |
|
|
689 | |
|
|
690 | if (!tr->item) |
688 | if (!tr->item) |
691 | continue; |
689 | continue; |
692 | |
690 | |
693 | item = &tr->item->clone; |
691 | object *item = tr->item; |
694 | |
692 | |
695 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
693 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
696 | return item->other_arch; |
694 | return item->other_arch; |
697 | } |
695 | } |
698 | return NULL; |
696 | return NULL; |
… | |
… | |
740 | |
738 | |
741 | if (level <= 20) |
739 | if (level <= 20) |
742 | return level / difficulty; |
740 | return level / difficulty; |
743 | if (level <= 40) |
741 | if (level <= 40) |
744 | return (20 + (level - 20) / 2) / difficulty; |
742 | return (20 + (level - 20) / 2) / difficulty; |
|
|
743 | |
745 | return (30 + (level - 40) / 4) / difficulty; |
744 | return (30 + (level - 40) / 4) / difficulty; |
746 | } |
745 | } |
747 | |
746 | |
748 | /** |
747 | /** |
749 | * God wants to enchant weapon. |
748 | * God wants to enchant weapon. |
… | |
… | |
760 | int tmp; |
759 | int tmp; |
761 | |
760 | |
762 | for (weapon = op->inv; weapon; weapon = weapon->below) |
761 | for (weapon = op->inv; weapon; weapon = weapon->below) |
763 | if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) |
762 | if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) |
764 | break; |
763 | break; |
|
|
764 | |
765 | if (weapon == NULL || god_examines_item (god, weapon) <= 0) |
765 | if (weapon == NULL || god_examines_item (god, weapon) <= 0) |
766 | return 0; |
766 | return 0; |
767 | |
767 | |
768 | /* First give it a title, so other gods won't touch it */ |
768 | /* First give it a title, so other gods won't touch it */ |
769 | if (!weapon->title) |
769 | if (!weapon->title) |
… | |
… | |
831 | if (god_examines_priest (op, god) < 0) |
831 | if (god_examines_priest (op, god) < 0) |
832 | return; |
832 | return; |
833 | |
833 | |
834 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); |
834 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); |
835 | |
835 | |
836 | for (tr = god->randomitems->items; tr != NULL; tr = tr->next) |
836 | for (tr = god->randomitems->items; tr; tr = tr->next) |
837 | { |
837 | { |
838 | object *item; |
838 | object *item; |
839 | |
839 | |
840 | if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) |
840 | if (tr->chance <= random_roll (0, 99, op, PREFER_HIGH)) |
841 | continue; |
841 | continue; |
842 | |
842 | |
843 | /* Treasurelist - generate some treasure for the follower */ |
843 | /* Treasurelist - generate some treasure for the follower */ |
844 | if (tr->name) |
844 | if (tr->name) |
845 | { |
845 | { |
846 | treasurelist *tl = find_treasurelist (tr->name); |
846 | treasurelist *tl = treasurelist::find (tr->name); |
847 | |
847 | |
848 | if (tl == NULL) |
848 | if (tl == NULL) |
849 | continue; |
849 | continue; |
850 | |
850 | |
851 | new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground."); |
851 | new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground."); |
… | |
… | |
855 | } |
855 | } |
856 | |
856 | |
857 | if (!tr->item) |
857 | if (!tr->item) |
858 | continue; |
858 | continue; |
859 | |
859 | |
860 | item = &tr->item->clone; |
860 | item = tr->item; |
861 | |
861 | |
862 | /* Grace limit */ |
862 | /* Grace limit */ |
863 | if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) |
863 | if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) |
864 | { |
864 | { |
865 | if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) |
865 | if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) |
… | |
… | |
963 | continue; |
963 | continue; |
964 | |
964 | |
965 | new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!"); |
965 | new_draw_info (NDI_UNIQUE, 0, op, "Shimmering light surrounds and restores you!"); |
966 | |
966 | |
967 | for (i = 0; i < NUM_STATS; i++) |
967 | for (i = 0; i < NUM_STATS; i++) |
968 | if (get_attr_value (&depl->stats, i)) |
968 | if (depl->stats.stat (i)) |
969 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
969 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
970 | |
970 | |
971 | depl->destroy (); |
971 | depl->destroy (); |
972 | op->update_stats (); |
972 | op->update_stats (); |
973 | return; |
973 | return; |
… | |
… | |
1135 | |
1135 | |
1136 | if (race == NULL) |
1136 | if (race == NULL) |
1137 | return NULL; |
1137 | return NULL; |
1138 | while (gl) |
1138 | while (gl) |
1139 | { |
1139 | { |
1140 | if (!strcasecmp (gl->arch->clone.race, race)) |
1140 | if (!strcasecmp (gl->arch->race, race)) |
1141 | { |
1141 | { |
1142 | godname = gl->name; |
1142 | godname = gl->name; |
1143 | break; |
1143 | break; |
1144 | } |
1144 | } |
1145 | gl = gl->next; |
1145 | gl = gl->next; |