1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
3 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * This program 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 2 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, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
21 | * |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | */ |
23 | */ |
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. |
27 | */ |
28 | */ |
… | |
… | |
31 | #include <global.h> |
32 | #include <global.h> |
32 | #include <living.h> |
33 | #include <living.h> |
33 | #include <object.h> |
34 | #include <object.h> |
34 | #include <spells.h> |
35 | #include <spells.h> |
35 | #include <sounds.h> |
36 | #include <sounds.h> |
36 | #ifndef __CEXTRACT__ |
|
|
37 | # include <sproto.h> |
37 | #include <sproto.h> |
38 | #endif |
|
|
39 | |
38 | |
40 | /** |
39 | /** |
41 | * Returns the id of specified god. |
40 | * Returns the id of specified god. |
42 | */ |
41 | */ |
43 | int |
42 | int |
… | |
… | |
203 | else |
202 | else |
204 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumbles to dust!", query_short_name (tmp)); |
203 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumbles to dust!", query_short_name (tmp)); |
205 | |
204 | |
206 | tmp->remove (); /* remove obj from players inv. */ |
205 | tmp->remove (); /* remove obj from players inv. */ |
207 | esrv_del_item (op->contr, tmp->count); /* notify client */ |
206 | esrv_del_item (op->contr, tmp->count); /* notify client */ |
208 | tmp->destroy (0); /* free object */ |
207 | tmp->destroy (); /* free object */ |
209 | } |
208 | } |
|
|
209 | |
210 | if (tmp->inv) |
210 | if (tmp->inv) |
211 | follower_remove_similar_item (tmp, item); |
211 | follower_remove_similar_item (tmp, item); |
212 | } |
212 | } |
213 | } |
213 | } |
214 | } |
214 | } |
… | |
… | |
240 | static int |
240 | static int |
241 | god_gives_present (object *op, object *god, treasure *tr) |
241 | god_gives_present (object *op, object *god, treasure *tr) |
242 | { |
242 | { |
243 | object *tmp; |
243 | object *tmp; |
244 | |
244 | |
|
|
245 | if (!tr->item) |
|
|
246 | return 0; |
|
|
247 | |
245 | if (follower_has_similar_item (op, &tr->item->clone)) |
248 | if (follower_has_similar_item (op, &tr->item->clone)) |
246 | return 0; |
249 | return 0; |
247 | |
250 | |
248 | tmp = arch_to_object (tr->item); |
251 | tmp = arch_to_object (tr->item); |
249 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); |
252 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); |
250 | tmp = insert_ob_in_ob (tmp, op); |
253 | tmp = insert_ob_in_ob (tmp, op); |
251 | if (op->type == PLAYER) |
254 | if (op->type == PLAYER) |
252 | esrv_send_item (op, tmp); |
255 | esrv_send_item (op, tmp); |
|
|
256 | |
253 | return 1; |
257 | return 1; |
254 | } |
258 | } |
255 | |
259 | |
256 | /** |
260 | /** |
257 | * Player prays at altar. |
261 | * Player prays at altar. |
… | |
… | |
395 | remove = 1; |
399 | remove = 1; |
396 | for (tr = god->randomitems->items; tr; tr = tr->next) |
400 | for (tr = god->randomitems->items; tr; tr = tr->next) |
397 | { |
401 | { |
398 | object *item; |
402 | object *item; |
399 | |
403 | |
400 | if (tr->item == NULL) |
404 | if (!tr->item) |
401 | continue; |
405 | continue; |
402 | item = &tr->item->clone; |
406 | item = &tr->item->clone; |
403 | |
407 | |
404 | /* Basically, see if the matching spell is granted by this god. */ |
408 | /* Basically, see if the matching spell is granted by this god. */ |
405 | |
409 | |
… | |
… | |
414 | /* just do the work of removing the spell ourselves - we already |
418 | /* just do the work of removing the spell ourselves - we already |
415 | * know that the player knows the spell |
419 | * know that the player knows the spell |
416 | */ |
420 | */ |
417 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &tmp->name); |
421 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &tmp->name); |
418 | player_unready_range_ob (op->contr, tmp); |
422 | player_unready_range_ob (op->contr, tmp); |
419 | tmp->remove (); |
|
|
420 | tmp->destroy (0); |
423 | tmp->destroy (); |
421 | } |
424 | } |
422 | |
425 | |
423 | } |
426 | } |
424 | } |
427 | } |
425 | |
428 | |
… | |
… | |
442 | |
445 | |
443 | /* take away any special god-characteristic items. */ |
446 | /* take away any special god-characteristic items. */ |
444 | for (item = op->inv; item != NULL; item = next) |
447 | for (item = op->inv; item != NULL; item = next) |
445 | { |
448 | { |
446 | next = item->below; |
449 | next = item->below; |
447 | /* remove all invisible startequip items which are |
450 | // remove all invisible startequip items which are not skill, exp or force |
448 | * not skill, exp or force |
|
|
449 | */ |
|
|
450 | if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible && |
451 | if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible && |
451 | (item->type != SKILL) && (item->type != EXPERIENCE) && (item->type != FORCE)) |
452 | (item->type != SKILL) && (item->type != FORCE)) |
452 | { |
453 | { |
453 | |
454 | |
454 | if (item->type == SPELL) |
455 | if (item->type == SPELL) |
455 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); |
456 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); |
|
|
457 | |
456 | player_unready_range_ob (op->contr, item); |
458 | player_unready_range_ob (op->contr, item); |
457 | item->remove (); |
|
|
458 | item->destroy (0); |
459 | item->destroy (); |
459 | } |
460 | } |
460 | } |
461 | } |
461 | |
462 | |
462 | /* remove any godgiven items from the old god */ |
463 | /* remove any godgiven items from the old god */ |
463 | if (old_god) |
464 | if (old_god) |
… | |
… | |
686 | { |
687 | { |
687 | object *item; |
688 | object *item; |
688 | |
689 | |
689 | if (!tr->item) |
690 | if (!tr->item) |
690 | continue; |
691 | continue; |
|
|
692 | |
691 | item = &tr->item->clone; |
693 | item = &tr->item->clone; |
692 | |
694 | |
693 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
695 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
694 | return item->other_arch; |
696 | return item->other_arch; |
695 | } |
697 | } |
… | |
… | |
851 | create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0); |
853 | create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0); |
852 | return; |
854 | return; |
853 | } |
855 | } |
854 | |
856 | |
855 | if (!tr->item) |
857 | if (!tr->item) |
856 | { |
|
|
857 | LOG (llevError, "BUG: empty entry in %s's treasure list\n", &god->name); |
|
|
858 | continue; |
858 | continue; |
859 | } |
859 | |
860 | item = &tr->item->clone; |
860 | item = &tr->item->clone; |
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 | { |
… | |
… | |
869 | /* Follower lacks the required grace for the following |
869 | /* Follower lacks the required grace for the following |
870 | * treasure list items. */ |
870 | * treasure list items. */ |
871 | |
871 | |
872 | tmp = get_archetype (HOLY_POSSESSION); |
872 | tmp = get_archetype (HOLY_POSSESSION); |
873 | cast_change_ability (op, op, tmp, 0, 1); |
873 | cast_change_ability (op, op, tmp, 0, 1); |
874 | tmp->destroy (0); |
874 | tmp->destroy (); |
875 | return; |
875 | return; |
876 | } |
876 | } |
877 | continue; |
877 | continue; |
878 | } |
878 | } |
879 | |
879 | |
… | |
… | |
918 | int success; |
918 | int success; |
919 | |
919 | |
920 | tmp = get_archetype_by_object_name (item->slaying); |
920 | tmp = get_archetype_by_object_name (item->slaying); |
921 | |
921 | |
922 | success = cast_heal (op, op, tmp, 0); |
922 | success = cast_heal (op, op, tmp, 0); |
923 | tmp->destroy (0); |
923 | tmp->destroy (); |
924 | if (success) |
924 | if (success) |
925 | return; |
925 | return; |
926 | else |
926 | else |
927 | continue; |
927 | continue; |
928 | } |
928 | } |
… | |
… | |
956 | { |
956 | { |
957 | LOG (llevError, "Could not find archetype depletion.\n"); |
957 | LOG (llevError, "Could not find archetype depletion.\n"); |
958 | continue; |
958 | continue; |
959 | } |
959 | } |
960 | depl = present_arch_in_ob (at, op); |
960 | depl = present_arch_in_ob (at, op); |
|
|
961 | |
961 | if (depl == NULL) |
962 | if (depl == NULL) |
962 | continue; |
963 | continue; |
|
|
964 | |
963 | 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 | |
964 | for (i = 0; i < NUM_STATS; i++) |
967 | for (i = 0; i < NUM_STATS; i++) |
965 | if (get_attr_value (&depl->stats, i)) |
968 | if (get_attr_value (&depl->stats, i)) |
966 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
969 | new_draw_info (NDI_UNIQUE, 0, op, restore_msg[i]); |
967 | depl->remove (); |
970 | |
968 | depl->destroy (0); |
971 | depl->destroy (); |
969 | fix_player (op); |
972 | op->update_stats (); |
970 | return; |
973 | return; |
971 | } |
974 | } |
972 | |
975 | |
973 | /* Voices */ |
976 | /* Voices */ |
974 | if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) |
977 | if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) |
… | |
… | |
1147 | /** |
1150 | /** |
1148 | * Changes the attributes of cone, smite, and ball spells as needed by the code. |
1151 | * Changes the attributes of cone, smite, and ball spells as needed by the code. |
1149 | * Returns false if there was no race to assign to the slaying field of the spell, but |
1152 | * Returns false if there was no race to assign to the slaying field of the spell, but |
1150 | * the spell attacktype contains AT_HOLYWORD. -b.t. |
1153 | * the spell attacktype contains AT_HOLYWORD. -b.t. |
1151 | */ |
1154 | */ |
1152 | |
|
|
1153 | int |
1155 | int |
1154 | tailor_god_spell (object *spellop, object *caster) |
1156 | tailor_god_spell (object *spellop, object *caster) |
1155 | { |
1157 | { |
1156 | object *god = find_god (determine_god (caster)); |
1158 | object *god = find_god (determine_god (caster)); |
1157 | int caster_is_spell = 0; |
1159 | int caster_is_spell = 0; |
… | |
… | |
1161 | |
1163 | |
1162 | /* if caster is a rune or the like, it doesn't worship anything. However, |
1164 | /* if caster is a rune or the like, it doesn't worship anything. However, |
1163 | * if this object is owned by someone, then the god that they worship |
1165 | * if this object is owned by someone, then the god that they worship |
1164 | * is relevant, so use that. |
1166 | * is relevant, so use that. |
1165 | */ |
1167 | */ |
1166 | if (!god && get_owner (caster)) |
1168 | if (!god && caster->owner) |
1167 | god = find_god (determine_god (get_owner (caster))); |
1169 | god = find_god (determine_god (caster->owner)); |
1168 | |
1170 | |
1169 | if (!god || (spellop->attacktype & AT_HOLYWORD && !god->race)) |
1171 | if (!god || (spellop->attacktype & AT_HOLYWORD && !god->race)) |
1170 | { |
1172 | { |
1171 | if (!caster_is_spell) |
1173 | if (!caster_is_spell) |
1172 | new_draw_info (NDI_UNIQUE, 0, caster, "This prayer is useless unless you worship an appropriate god"); |
1174 | new_draw_info (NDI_UNIQUE, 0, caster, "This prayer is useless unless you worship an appropriate god"); |
1173 | else |
1175 | else |
1174 | LOG (llevError, "BUG: tailor_god_spell(): no god\n"); |
1176 | LOG (llevError, "BUG: tailor_god_spell(): no god\n"); |
|
|
1177 | |
1175 | spellop->destroy (0); |
1178 | spellop->destroy (); |
1176 | return 0; |
1179 | return 0; |
1177 | } |
1180 | } |
1178 | |
1181 | |
1179 | /* either holy word or godpower attacks will set the slaying field */ |
1182 | /* either holy word or godpower attacks will set the slaying field */ |
1180 | if (spellop->attacktype & AT_HOLYWORD || spellop->attacktype & AT_GODPOWER) |
1183 | if (spellop->attacktype & AT_HOLYWORD || spellop->attacktype & AT_GODPOWER) |