1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_spell_effect_c = |
|
|
4 | * "$Id: spell_effect.C,v 1.8 2006/09/10 15:59:57 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | |
|
|
8 | /* |
1 | /* |
9 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
10 | |
3 | |
11 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
12 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
23 | |
16 | |
24 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
25 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
26 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
27 | |
20 | |
28 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
29 | */ |
22 | */ |
30 | |
23 | |
31 | #include <global.h> |
24 | #include <global.h> |
32 | #include <object.h> |
25 | #include <object.h> |
33 | #include <living.h> |
26 | #include <living.h> |
… | |
… | |
81 | if (!(random_roll (0, 3, op, PREFER_HIGH))) |
74 | if (!(random_roll (0, 3, op, PREFER_HIGH))) |
82 | { |
75 | { |
83 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand)); |
76 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand)); |
84 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EXPLODE); |
77 | play_sound_map (op->map, op->x, op->y, SOUND_OB_EXPLODE); |
85 | esrv_del_item (op->contr, wand->count); |
78 | esrv_del_item (op->contr, wand->count); |
86 | remove_ob (wand); |
79 | wand->destroy (); |
87 | free_object (wand); |
|
|
88 | tmp = get_archetype ("fireball"); |
80 | tmp = get_archetype ("fireball"); |
89 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
81 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
90 | if (!tmp->stats.dam) |
82 | if (!tmp->stats.dam) |
91 | tmp->stats.dam = 1; |
83 | tmp->stats.dam = 1; |
92 | tmp->stats.hp = tmp->stats.dam / 2; |
84 | tmp->stats.hp = tmp->stats.dam / 2; |
… | |
… | |
135 | cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg) |
127 | cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg) |
136 | { |
128 | { |
137 | int missile_plus = 0, bonus_plus = 0; |
129 | int missile_plus = 0, bonus_plus = 0; |
138 | const char *missile_name; |
130 | const char *missile_name; |
139 | object *tmp, *missile; |
131 | object *tmp, *missile; |
140 | tag_t tag; |
|
|
141 | |
132 | |
142 | missile_name = "arrow"; |
133 | missile_name = "arrow"; |
143 | |
134 | |
144 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
135 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
145 | if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) |
136 | if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) |
146 | { |
|
|
147 | missile_name = tmp->race; |
137 | missile_name = tmp->race; |
148 | } |
|
|
149 | |
138 | |
150 | missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
139 | missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
151 | |
140 | |
152 | if (find_archetype (missile_name) == NULL) |
141 | if (archetype::find (missile_name) == NULL) |
153 | { |
142 | { |
154 | LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name); |
143 | LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name); |
155 | return 0; |
144 | return 0; |
156 | } |
145 | } |
|
|
146 | |
157 | missile = get_archetype (missile_name); |
147 | missile = get_archetype (missile_name); |
158 | |
148 | |
159 | if (stringarg) |
149 | if (stringarg) |
160 | { |
150 | { |
161 | /* If it starts with a letter, presume it is a description */ |
151 | /* If it starts with a letter, presume it is a description */ |
… | |
… | |
167 | if (!strcasecmp (al->item->name, stringarg)) |
157 | if (!strcasecmp (al->item->name, stringarg)) |
168 | break; |
158 | break; |
169 | |
159 | |
170 | if (!al) |
160 | if (!al) |
171 | { |
161 | { |
172 | free_object (missile); |
162 | missile->destroy (); |
173 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such object %ss of %s", missile_name, stringarg); |
163 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such object %ss of %s", missile_name, stringarg); |
174 | return 0; |
164 | return 0; |
175 | } |
165 | } |
|
|
166 | |
176 | if (al->item->slaying) |
167 | if (al->item->slaying) |
177 | { |
168 | { |
178 | free_object (missile); |
169 | missile->destroy (); |
179 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); |
170 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); |
180 | return 0; |
171 | return 0; |
181 | } |
172 | } |
|
|
173 | |
182 | give_artifact_abilities (missile, al->item); |
174 | give_artifact_abilities (missile, al->item); |
183 | /* These special arrows cost something extra. Don't have them also be magical - |
175 | /* These special arrows cost something extra. Don't have them also be magical - |
184 | * otherwise, in most cases, not enough will be created. I don't want to get into |
176 | * otherwise, in most cases, not enough will be created. I don't want to get into |
185 | * the parsing of having to do both plus and type. |
177 | * the parsing of having to do both plus and type. |
186 | */ |
178 | */ |
… | |
… | |
188 | missile_plus = 0; |
180 | missile_plus = 0; |
189 | } |
181 | } |
190 | else if (atoi (stringarg) < missile_plus) |
182 | else if (atoi (stringarg) < missile_plus) |
191 | missile_plus = atoi (stringarg); |
183 | missile_plus = atoi (stringarg); |
192 | } |
184 | } |
|
|
185 | |
193 | if (missile_plus > 4) |
186 | if (missile_plus > 4) |
194 | missile_plus = 4; |
187 | missile_plus = 4; |
195 | else if (missile_plus < -4) |
188 | else if (missile_plus < -4) |
196 | missile_plus = -4; |
189 | missile_plus = -4; |
197 | |
190 | |
198 | missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell); |
191 | missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell); |
199 | missile->nrof -= 3 * (missile_plus + bonus_plus); |
192 | missile->nrof -= 3 * (missile_plus + bonus_plus); |
|
|
193 | |
200 | if (missile->nrof < 1) |
194 | if (missile->nrof < 1) |
201 | missile->nrof = 1; |
195 | missile->nrof = 1; |
202 | |
196 | |
203 | missile->magic = missile_plus; |
197 | missile->magic = missile_plus; |
204 | /* Can't get any money for these objects */ |
198 | /* Can't get any money for these objects */ |
205 | missile->value = 0; |
199 | missile->value = 0; |
206 | |
200 | |
207 | SET_FLAG (missile, FLAG_IDENTIFIED); |
201 | SET_FLAG (missile, FLAG_IDENTIFIED); |
208 | tag = missile->count; |
|
|
209 | |
202 | |
210 | if (!cast_create_obj (op, caster, missile, dir) && op->type == PLAYER && !was_destroyed (missile, tag)) |
203 | if (!cast_create_obj (op, caster, missile, dir) && op->type == PLAYER && !missile->destroyed ()) |
211 | { |
|
|
212 | pick_up (op, missile); |
204 | pick_up (op, missile); |
213 | } |
205 | |
214 | return 1; |
206 | return 1; |
215 | } |
207 | } |
216 | |
208 | |
217 | |
209 | |
218 | /* allows the choice of what sort of food object to make. |
210 | /* allows the choice of what sort of food object to make. |
… | |
… | |
284 | int |
276 | int |
285 | probe (object *op, object *caster, object *spell_ob, int dir) |
277 | probe (object *op, object *caster, object *spell_ob, int dir) |
286 | { |
278 | { |
287 | int r, mflags, maxrange; |
279 | int r, mflags, maxrange; |
288 | object *tmp; |
280 | object *tmp; |
289 | mapstruct *m; |
281 | maptile *m; |
290 | |
282 | |
291 | |
283 | |
292 | if (!dir) |
284 | if (!dir) |
293 | { |
285 | { |
294 | examine_monster (op, op); |
286 | examine_monster (op, op); |
… | |
… | |
310 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your magic."); |
302 | new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your magic."); |
311 | return 0; |
303 | return 0; |
312 | } |
304 | } |
313 | if (mflags & P_IS_ALIVE) |
305 | if (mflags & P_IS_ALIVE) |
314 | { |
306 | { |
315 | for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) |
307 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
316 | if (QUERY_FLAG (tmp, FLAG_ALIVE) && (tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER))) |
308 | if (QUERY_FLAG (tmp, FLAG_ALIVE) && (tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER))) |
317 | { |
309 | { |
318 | new_draw_info (NDI_UNIQUE, 0, op, "You detect something."); |
310 | new_draw_info (NDI_UNIQUE, 0, op, "You detect something."); |
319 | if (tmp->head != NULL) |
311 | if (tmp->head != NULL) |
320 | tmp = tmp->head; |
312 | tmp = tmp->head; |
… | |
… | |
429 | cast_earth_to_dust (object *op, object *caster, object *spell_ob) |
421 | cast_earth_to_dust (object *op, object *caster, object *spell_ob) |
430 | { |
422 | { |
431 | object *tmp, *next; |
423 | object *tmp, *next; |
432 | int range, i, j, mflags; |
424 | int range, i, j, mflags; |
433 | sint16 sx, sy; |
425 | sint16 sx, sy; |
434 | mapstruct *m; |
426 | maptile *m; |
435 | |
427 | |
436 | if (op->type != PLAYER) |
428 | if (op->type != PLAYER) |
437 | return 0; |
429 | return 0; |
438 | |
430 | |
439 | range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
431 | range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
… | |
… | |
448 | |
440 | |
449 | if (mflags & P_OUT_OF_MAP) |
441 | if (mflags & P_OUT_OF_MAP) |
450 | continue; |
442 | continue; |
451 | |
443 | |
452 | // earth to dust tears down everything that can be teared down |
444 | // earth to dust tears down everything that can be teared down |
453 | for (tmp = get_map_ob (m, sx, sy); tmp != NULL; tmp = next) |
445 | for (tmp = GET_MAP_OB (m, sx, sy); tmp != NULL; tmp = next) |
454 | { |
446 | { |
455 | next = tmp->above; |
447 | next = tmp->above; |
456 | if (QUERY_FLAG (tmp, FLAG_TEAR_DOWN)) |
448 | if (QUERY_FLAG (tmp, FLAG_TEAR_DOWN)) |
457 | hit_player (tmp, 9998, op, AT_PHYSICAL, 0); |
449 | hit_player (tmp, 9998, op, AT_PHYSICAL, 0); |
458 | } |
450 | } |
… | |
… | |
468 | |
460 | |
469 | while (op != NULL && op->type != PLAYER) |
461 | while (op != NULL && op->type != PLAYER) |
470 | op = op->env; |
462 | op = op->env; |
471 | |
463 | |
472 | if (op != NULL && op->map) |
464 | if (op != NULL && op->map) |
473 | { |
|
|
474 | if ((get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) && (!QUERY_FLAG (op, FLAG_WIZCAST))) |
465 | if ((get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) && (!QUERY_FLAG (op, FLAG_WIZCAST))) |
475 | new_draw_info (NDI_UNIQUE, 0, op, "You feel something fizzle inside you."); |
466 | new_draw_info (NDI_UNIQUE, 0, op, "You feel something fizzle inside you."); |
476 | else |
467 | else |
477 | enter_exit (op, wor); |
468 | enter_exit (op, wor); |
478 | } |
469 | |
479 | remove_ob (wor); |
470 | wor->destroy (); |
480 | free_object (wor); |
|
|
481 | } |
471 | } |
482 | |
472 | |
483 | /* Word of recall causes the player to return 'home'. |
473 | /* Word of recall causes the player to return 'home'. |
484 | * we put a force into the player object, so that there is a |
474 | * we put a force into the player object, so that there is a |
485 | * time delay effect. |
475 | * time delay effect. |
… | |
… | |
566 | return cast_spell (op, caster, dir, newspell, NULL); |
556 | return cast_spell (op, caster, dir, newspell, NULL); |
567 | } |
557 | } |
568 | return 1; |
558 | return 1; |
569 | } |
559 | } |
570 | |
560 | |
571 | |
|
|
572 | int |
561 | int |
573 | perceive_self (object *op) |
562 | perceive_self (object *op) |
574 | { |
563 | { |
575 | char *cp = describe_item (op, op), buf[MAX_BUF]; |
564 | char *cp = describe_item (op, op), buf[MAX_BUF]; |
576 | archetype *at = find_archetype (ARCH_DEPLETION); |
565 | archetype *at = archetype::find (ARCH_DEPLETION); |
577 | object *tmp; |
566 | object *tmp; |
578 | int i; |
567 | int i; |
579 | |
568 | |
580 | tmp = find_god (determine_god (op)); |
569 | tmp = find_god (determine_god (op)); |
581 | if (tmp) |
570 | if (tmp) |
… | |
… | |
648 | { |
637 | { |
649 | object *dummy, *force, *old_force, *tmp; |
638 | object *dummy, *force, *old_force, *tmp; |
650 | archetype *perm_portal; |
639 | archetype *perm_portal; |
651 | char portal_name[1024], portal_message[1024]; |
640 | char portal_name[1024], portal_message[1024]; |
652 | sint16 exitx, exity; |
641 | sint16 exitx, exity; |
653 | mapstruct *exitmap; |
642 | maptile *exitmap; |
654 | int op_level; |
643 | int op_level; |
655 | |
|
|
656 | |
644 | |
657 | /* Check to see if the map the player is currently on is a per player unique |
645 | /* Check to see if the map the player is currently on is a per player unique |
658 | * map. This can be determined in that per player unique maps have the |
646 | * map. This can be determined in that per player unique maps have the |
659 | * full pathname listed. |
647 | * full pathname listed. |
660 | */ |
648 | */ |
… | |
… | |
669 | */ |
657 | */ |
670 | dummy = arch_to_object (spell->other_arch); |
658 | dummy = arch_to_object (spell->other_arch); |
671 | if (dummy == NULL) |
659 | if (dummy == NULL) |
672 | { |
660 | { |
673 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
661 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
674 | LOG (llevError, "get_object failed (force in cast_create_town_portal for %s!\n", &op->name); |
662 | LOG (llevError, "object::create failed (force in cast_create_town_portal for %s!\n", &op->name); |
675 | return 0; |
663 | return 0; |
676 | } |
664 | } |
|
|
665 | |
677 | force = check_inv_recursive (op, dummy); |
666 | force = check_inv_recursive (op, dummy); |
678 | |
667 | |
679 | if (force == NULL) |
668 | if (force == NULL) |
680 | { |
669 | { |
681 | /* Here we know there is no destination marked up. |
670 | /* Here we know there is no destination marked up. |
… | |
… | |
688 | EXIT_Y (dummy) = op->y; |
677 | EXIT_Y (dummy) = op->y; |
689 | insert_ob_in_ob (dummy, op); |
678 | insert_ob_in_ob (dummy, op); |
690 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You fix this place in your mind.\nYou feel you are able to come here from anywhere."); |
679 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You fix this place in your mind.\nYou feel you are able to come here from anywhere."); |
691 | return 1; |
680 | return 1; |
692 | } |
681 | } |
693 | free_object (dummy); |
682 | |
|
|
683 | dummy->destroy (); |
694 | |
684 | |
695 | /* Here we know where the town portal should go to |
685 | /* Here we know where the town portal should go to |
696 | * We should kill any existing portal associated with the player. |
686 | * We should kill any existing portal associated with the player. |
697 | * Than we should create the 2 portals. |
687 | * Than we should create the 2 portals. |
698 | * For each of them, we need: |
688 | * For each of them, we need: |
… | |
… | |
711 | /* First step: killing existing town portals */ |
701 | /* First step: killing existing town portals */ |
712 | dummy = get_archetype (spell->race); |
702 | dummy = get_archetype (spell->race); |
713 | if (dummy == NULL) |
703 | if (dummy == NULL) |
714 | { |
704 | { |
715 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
705 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
716 | LOG (llevError, "get_object failed (force) in cast_create_town_portal for %s!\n", &op->name); |
706 | LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name); |
717 | return 0; |
707 | return 0; |
718 | } |
708 | } |
|
|
709 | |
719 | perm_portal = find_archetype (spell->slaying); |
710 | perm_portal = archetype::find (spell->slaying); |
720 | |
711 | |
721 | /* To kill a town portal, we go trough the player's inventory, |
712 | /* To kill a town portal, we go trough the player's inventory, |
722 | * for each marked portal in player's inventory, |
713 | * for each marked portal in player's inventory, |
723 | * -We try load the associated map (if impossible, consider the portal destructed) |
714 | * -We try load the associated map (if impossible, consider the portal destructed) |
724 | * -We find any portal in the specified location. |
715 | * -We find any portal in the specified location. |
… | |
… | |
741 | tmp = present_arch (perm_portal, exitmap, exitx, exity); |
732 | tmp = present_arch (perm_portal, exitmap, exitx, exity); |
742 | while (tmp) |
733 | while (tmp) |
743 | { |
734 | { |
744 | if (tmp->name == old_force->name) |
735 | if (tmp->name == old_force->name) |
745 | { |
736 | { |
746 | remove_ob (tmp); |
737 | tmp->destroy (); |
747 | free_object (tmp); |
|
|
748 | break; |
738 | break; |
749 | } |
739 | } |
750 | else |
740 | |
751 | { |
|
|
752 | tmp = tmp->above; |
741 | tmp = tmp->above; |
753 | } |
|
|
754 | } |
742 | } |
755 | } |
743 | } |
756 | remove_ob (old_force); |
744 | |
757 | free_object (old_force); |
745 | old_force->destroy (); |
758 | LOG (llevDebug, "\n"); |
746 | LOG (llevDebug, "\n"); |
759 | } |
747 | } |
760 | free_object (dummy); |
748 | |
|
|
749 | dummy->destroy (); |
761 | |
750 | |
762 | /* Creating the portals. |
751 | /* Creating the portals. |
763 | * The very first thing to do is to ensure |
752 | * The very first thing to do is to ensure |
764 | * access to the destination map. |
753 | * access to the destination map. |
765 | * If we can't, don't fizzle. Simply warn player. |
754 | * If we can't, don't fizzle. Simply warn player. |
… | |
… | |
777 | |
766 | |
778 | /* If we were unable to load (ex. random map deleted), warn player */ |
767 | /* If we were unable to load (ex. random map deleted), warn player */ |
779 | if (exitmap == NULL) |
768 | if (exitmap == NULL) |
780 | { |
769 | { |
781 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); |
770 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); |
782 | remove_ob (force); |
771 | force->destroy (); |
783 | free_object (force); |
|
|
784 | return 1; |
772 | return 1; |
785 | } |
773 | } |
786 | |
774 | |
787 | op_level = caster_level (caster, spell); |
775 | op_level = caster_level (caster, spell); |
788 | if (op_level < 15) |
776 | if (op_level < 15) |
… | |
… | |
806 | snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &force->name); |
794 | snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &force->name); |
807 | dummy = get_archetype (spell->slaying); /*The portal */ |
795 | dummy = get_archetype (spell->slaying); /*The portal */ |
808 | if (dummy == NULL) |
796 | if (dummy == NULL) |
809 | { |
797 | { |
810 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
798 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
811 | LOG (llevError, "get_object failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name); |
799 | LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name); |
812 | return 0; |
800 | return 0; |
813 | } |
801 | } |
|
|
802 | |
814 | EXIT_PATH (dummy) = force->name; |
803 | EXIT_PATH (dummy) = force->name; |
815 | EXIT_X (dummy) = EXIT_X (force); |
804 | EXIT_X (dummy) = EXIT_X (force); |
816 | EXIT_Y (dummy) = EXIT_Y (force); |
805 | EXIT_Y (dummy) = EXIT_Y (force); |
817 | dummy->name = dummy->name_pl = portal_name; |
806 | dummy->name = dummy->name_pl = portal_name; |
818 | dummy->msg = portal_message; |
807 | dummy->msg = portal_message; |
… | |
… | |
825 | */ |
814 | */ |
826 | tmp = get_archetype (spell->race); |
815 | tmp = get_archetype (spell->race); |
827 | if (tmp == NULL) |
816 | if (tmp == NULL) |
828 | { |
817 | { |
829 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
818 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
830 | LOG (llevError, "get_object failed (force) in cast_create_town_portal for %s!\n", &op->name); |
819 | LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name); |
831 | return 0; |
820 | return 0; |
832 | } |
821 | } |
|
|
822 | |
833 | tmp->race = op->map->path; |
823 | tmp->race = op->map->path; |
834 | tmp->name = portal_name; |
824 | tmp->name = portal_name; |
835 | EXIT_X (tmp) = dummy->x; |
825 | EXIT_X (tmp) = dummy->x; |
836 | EXIT_Y (tmp) = dummy->y; |
826 | EXIT_Y (tmp) = dummy->y; |
837 | insert_ob_in_ob (tmp, op); |
827 | insert_ob_in_ob (tmp, op); |
… | |
… | |
845 | snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path); |
835 | snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path); |
846 | dummy = get_archetype (spell->slaying); /*The portal */ |
836 | dummy = get_archetype (spell->slaying); /*The portal */ |
847 | if (dummy == NULL) |
837 | if (dummy == NULL) |
848 | { |
838 | { |
849 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
839 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
850 | LOG (llevError, "get_object failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name); |
840 | LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name); |
851 | return 0; |
841 | return 0; |
852 | } |
842 | } |
|
|
843 | |
853 | EXIT_PATH (dummy) = op->map->path; |
844 | EXIT_PATH (dummy) = op->map->path; |
854 | EXIT_X (dummy) = op->x; |
845 | EXIT_X (dummy) = op->x; |
855 | EXIT_Y (dummy) = op->y; |
846 | EXIT_Y (dummy) = op->y; |
856 | dummy->name = dummy->name_pl = portal_name; |
847 | dummy->name = dummy->name_pl = portal_name; |
857 | dummy->msg = portal_message; |
848 | dummy->msg = portal_message; |
… | |
… | |
865 | */ |
856 | */ |
866 | tmp = get_archetype (spell->race); |
857 | tmp = get_archetype (spell->race); |
867 | if (tmp == NULL) |
858 | if (tmp == NULL) |
868 | { |
859 | { |
869 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
860 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
870 | LOG (llevError, "get_object failed (force) in cast_create_town_portal for %s!\n", &op->name); |
861 | LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name); |
871 | return 0; |
862 | return 0; |
872 | } |
863 | } |
|
|
864 | |
873 | tmp->race = force->name; |
865 | tmp->race = force->name; |
874 | tmp->name = portal_name; |
866 | tmp->name = portal_name; |
875 | EXIT_X (tmp) = dummy->x; |
867 | EXIT_X (tmp) = dummy->x; |
876 | EXIT_Y (tmp) = dummy->y; |
868 | EXIT_Y (tmp) = dummy->y; |
877 | insert_ob_in_ob (tmp, op); |
869 | insert_ob_in_ob (tmp, op); |
878 | |
870 | |
879 | /* Describe the player what happened |
871 | /* Describe the player what happened |
880 | */ |
872 | */ |
881 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You see air moving and showing you the way home."); |
873 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You see air moving and showing you the way home."); |
882 | remove_ob (force); /* Delete the force inside the player */ |
874 | force->destroy (); |
883 | free_object (force); |
875 | |
884 | return 1; |
876 | return 1; |
885 | } |
877 | } |
886 | |
|
|
887 | |
878 | |
888 | /* This creates magic walls. Really, it can create most any object, |
879 | /* This creates magic walls. Really, it can create most any object, |
889 | * within some reason. |
880 | * within some reason. |
890 | */ |
881 | */ |
891 | |
|
|
892 | int |
882 | int |
893 | magic_wall (object *op, object *caster, int dir, object *spell_ob) |
883 | magic_wall (object *op, object *caster, int dir, object *spell_ob) |
894 | { |
884 | { |
895 | object *tmp, *tmp2; |
885 | object *tmp, *tmp2; |
896 | int i, posblocked, negblocked, maxrange; |
886 | int i, posblocked, negblocked, maxrange; |
897 | sint16 x, y; |
887 | sint16 x, y; |
898 | mapstruct *m; |
888 | maptile *m; |
899 | const char *name; |
889 | const char *name; |
900 | archetype *at; |
890 | archetype *at; |
901 | |
891 | |
902 | if (!dir) |
892 | if (!dir) |
903 | { |
893 | { |
… | |
… | |
908 | else |
898 | else |
909 | { |
899 | { |
910 | x = op->x + freearr_x[dir]; |
900 | x = op->x + freearr_x[dir]; |
911 | y = op->y + freearr_y[dir]; |
901 | y = op->y + freearr_y[dir]; |
912 | } |
902 | } |
|
|
903 | |
913 | m = op->map; |
904 | m = op->map; |
914 | |
905 | |
915 | if ((spell_ob->move_block || x != op->x || y != op->y) && |
906 | if ((spell_ob->move_block || x != op->x || y != op->y) && |
916 | (get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE) || |
907 | (get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE) || |
917 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block))) |
908 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block))) |
918 | { |
909 | { |
919 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
910 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
920 | return 0; |
911 | return 0; |
921 | } |
912 | } |
|
|
913 | |
922 | if (spell_ob->other_arch) |
914 | if (spell_ob->other_arch) |
923 | { |
|
|
924 | tmp = arch_to_object (spell_ob->other_arch); |
915 | tmp = arch_to_object (spell_ob->other_arch); |
925 | } |
|
|
926 | else if (spell_ob->race) |
916 | else if (spell_ob->race) |
927 | { |
917 | { |
928 | char buf1[MAX_BUF]; |
918 | char buf1[MAX_BUF]; |
929 | |
919 | |
930 | sprintf (buf1, spell_ob->race, dir); |
920 | sprintf (buf1, spell_ob->race, dir); |
931 | at = find_archetype (buf1); |
921 | at = archetype::find (buf1); |
932 | if (!at) |
922 | if (!at) |
933 | { |
923 | { |
934 | LOG (llevError, "summon_wall: Unable to find archetype %s\n", buf1); |
924 | LOG (llevError, "summon_wall: Unable to find archetype %s\n", buf1); |
935 | new_draw_info (NDI_UNIQUE, 0, op, "This spell is broken."); |
925 | new_draw_info (NDI_UNIQUE, 0, op, "This spell is broken."); |
936 | return 0; |
926 | return 0; |
… | |
… | |
952 | } |
942 | } |
953 | else if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
943 | else if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
954 | { |
944 | { |
955 | tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
945 | tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
956 | tmp->stats.maxhp = tmp->stats.hp; |
946 | tmp->stats.maxhp = tmp->stats.hp; |
957 | set_owner (tmp, op); |
|
|
958 | set_spell_skill (op, caster, spell_ob, tmp); |
|
|
959 | } |
947 | } |
|
|
948 | |
960 | if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP)) |
949 | if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP)) |
961 | { |
950 | { |
962 | tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
951 | tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); |
963 | SET_FLAG (tmp, FLAG_IS_USED_UP); |
952 | SET_FLAG (tmp, FLAG_IS_USED_UP); |
964 | } |
953 | } |
|
|
954 | |
965 | if (QUERY_FLAG (spell_ob, FLAG_TEAR_DOWN)) |
955 | if (QUERY_FLAG (spell_ob, FLAG_TEAR_DOWN)) |
966 | { |
956 | { |
967 | tmp->stats.hp = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); |
957 | tmp->stats.hp = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); |
968 | tmp->stats.maxhp = tmp->stats.hp; |
958 | tmp->stats.maxhp = tmp->stats.hp; |
969 | SET_FLAG (tmp, FLAG_TEAR_DOWN); |
959 | SET_FLAG (tmp, FLAG_TEAR_DOWN); |
970 | SET_FLAG (tmp, FLAG_ALIVE); |
960 | SET_FLAG (tmp, FLAG_ALIVE); |
971 | } |
961 | } |
972 | |
962 | |
973 | /* This can't really hurt - if the object doesn't kill anything, |
963 | /* This can't really hurt - if the object doesn't kill anything, |
974 | * these fields just won't be used. |
964 | * these fields just won't be used. Do not set the owner for |
|
|
965 | * earthwalls, though, so they survive restarts. |
975 | */ |
966 | */ |
976 | set_owner (tmp, op); |
967 | if (tmp->type != EARTHWALL) //TODO |
|
|
968 | tmp->set_owner (op); |
|
|
969 | |
977 | set_spell_skill (op, caster, spell_ob, tmp); |
970 | set_spell_skill (op, caster, spell_ob, tmp); |
978 | tmp->x = x; |
971 | tmp->x = x; |
979 | tmp->y = y; |
972 | tmp->y = y; |
980 | tmp->level = caster_level (caster, spell_ob) / 2; |
973 | tmp->level = caster_level (caster, spell_ob) / 2; |
981 | |
974 | |
… | |
… | |
983 | if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL) |
976 | if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL) |
984 | { |
977 | { |
985 | new_draw_info_format (NDI_UNIQUE, 0, op, "Something destroys your %s", name); |
978 | new_draw_info_format (NDI_UNIQUE, 0, op, "Something destroys your %s", name); |
986 | return 0; |
979 | return 0; |
987 | } |
980 | } |
|
|
981 | |
988 | /* If this is a spellcasting wall, need to insert the spell object */ |
982 | /* If this is a spellcasting wall, need to insert the spell object */ |
989 | if (tmp->other_arch && tmp->other_arch->clone.type == SPELL) |
983 | if (tmp->other_arch && tmp->other_arch->clone.type == SPELL) |
990 | insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp); |
984 | insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp); |
991 | |
985 | |
992 | /* This code causes the wall to extend some distance in |
986 | /* This code causes the wall to extend some distance in |
… | |
… | |
1010 | m = tmp->map; |
1004 | m = tmp->map; |
1011 | |
1005 | |
1012 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
1006 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
1013 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked) |
1007 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked) |
1014 | { |
1008 | { |
1015 | tmp2 = get_object (); |
1009 | tmp2 = tmp->clone (); |
1016 | copy_object (tmp, tmp2); |
|
|
1017 | tmp2->x = x; |
1010 | tmp2->x = x; |
1018 | tmp2->y = y; |
1011 | tmp2->y = y; |
1019 | insert_ob_in_map (tmp2, m, op, 0); |
1012 | insert_ob_in_map (tmp2, m, op, 0); |
1020 | /* If this is a spellcasting wall, need to insert the spell object */ |
1013 | /* If this is a spellcasting wall, need to insert the spell object */ |
1021 | if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) |
1014 | if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) |
… | |
… | |
1030 | m = tmp->map; |
1023 | m = tmp->map; |
1031 | |
1024 | |
1032 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
1025 | if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && |
1033 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked) |
1026 | ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked) |
1034 | { |
1027 | { |
1035 | tmp2 = get_object (); |
1028 | tmp2 = tmp->clone (); |
1036 | copy_object (tmp, tmp2); |
|
|
1037 | tmp2->x = x; |
1029 | tmp2->x = x; |
1038 | tmp2->y = y; |
1030 | tmp2->y = y; |
1039 | insert_ob_in_map (tmp2, m, op, 0); |
1031 | insert_ob_in_map (tmp2, m, op, 0); |
1040 | if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) |
1032 | if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) |
1041 | insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2); |
1033 | insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2); |
… | |
… | |
1053 | int |
1045 | int |
1054 | dimension_door (object *op, object *caster, object *spob, int dir) |
1046 | dimension_door (object *op, object *caster, object *spob, int dir) |
1055 | { |
1047 | { |
1056 | uint32 dist, maxdist; |
1048 | uint32 dist, maxdist; |
1057 | int mflags; |
1049 | int mflags; |
1058 | mapstruct *m; |
1050 | maptile *m; |
1059 | sint16 sx, sy; |
1051 | sint16 sx, sy; |
1060 | |
1052 | |
1061 | if (op->type != PLAYER) |
1053 | if (op->type != PLAYER) |
1062 | return 0; |
1054 | return 0; |
1063 | |
1055 | |
… | |
… | |
1153 | return 0; |
1145 | return 0; |
1154 | } |
1146 | } |
1155 | } |
1147 | } |
1156 | |
1148 | |
1157 | /* Actually move the player now */ |
1149 | /* Actually move the player now */ |
1158 | remove_ob (op); |
1150 | op->remove (); |
1159 | op->x += freearr_x[dir] * dist; |
1151 | op->x += freearr_x[dir] * dist; |
1160 | op->y += freearr_y[dir] * dist; |
1152 | op->y += freearr_y[dir] * dist; |
1161 | if ((op = insert_ob_in_map (op, op->map, op, 0)) == NULL) |
1153 | if ((op = insert_ob_in_map (op, op->map, op, 0)) == NULL) |
1162 | return 1; |
1154 | return 1; |
1163 | |
1155 | |
… | |
… | |
1234 | if (cure_disease (tmp, op)) |
1226 | if (cure_disease (tmp, op)) |
1235 | success = 1; |
1227 | success = 1; |
1236 | |
1228 | |
1237 | if (spell->attacktype & AT_POISON) |
1229 | if (spell->attacktype & AT_POISON) |
1238 | { |
1230 | { |
1239 | at = find_archetype ("poisoning"); |
1231 | at = archetype::find ("poisoning"); |
1240 | poison = present_arch_in_ob (at, tmp); |
1232 | poison = present_arch_in_ob (at, tmp); |
1241 | if (poison) |
1233 | if (poison) |
1242 | { |
1234 | { |
1243 | success = 1; |
1235 | success = 1; |
1244 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your body feels cleansed"); |
1236 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your body feels cleansed"); |
… | |
… | |
1255 | poison->duration = 1; |
1247 | poison->duration = 1; |
1256 | } |
1248 | } |
1257 | } |
1249 | } |
1258 | if (spell->attacktype & AT_BLIND) |
1250 | if (spell->attacktype & AT_BLIND) |
1259 | { |
1251 | { |
1260 | at = find_archetype ("blindness"); |
1252 | at = archetype::find ("blindness"); |
1261 | poison = present_arch_in_ob (at, tmp); |
1253 | poison = present_arch_in_ob (at, tmp); |
1262 | if (poison) |
1254 | if (poison) |
1263 | { |
1255 | { |
1264 | success = 1; |
1256 | success = 1; |
1265 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your vision begins to return."); |
1257 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your vision begins to return."); |
… | |
… | |
1440 | force->stats.ac = spell_ob->stats.ac; |
1432 | force->stats.ac = spell_ob->stats.ac; |
1441 | force->attacktype = spell_ob->attacktype; |
1433 | force->attacktype = spell_ob->attacktype; |
1442 | |
1434 | |
1443 | insert_ob_in_ob (force, tmp); |
1435 | insert_ob_in_ob (force, tmp); |
1444 | change_abil (tmp, force); /* Mostly to display any messages */ |
1436 | change_abil (tmp, force); /* Mostly to display any messages */ |
1445 | fix_player (tmp); |
1437 | tmp->update_stats (); |
1446 | return 1; |
1438 | return 1; |
1447 | } |
1439 | } |
1448 | |
1440 | |
1449 | /* This used to be part of cast_change_ability, but it really didn't make |
1441 | /* This used to be part of cast_change_ability, but it really didn't make |
1450 | * a lot of sense, since most of the values it derives are from the god |
1442 | * a lot of sense, since most of the values it derives are from the god |
… | |
… | |
1549 | force->stats.wc = spell_ob->stats.wc; |
1541 | force->stats.wc = spell_ob->stats.wc; |
1550 | force->stats.ac = spell_ob->stats.ac; |
1542 | force->stats.ac = spell_ob->stats.ac; |
1551 | |
1543 | |
1552 | change_abil (tmp, force); /* Mostly to display any messages */ |
1544 | change_abil (tmp, force); /* Mostly to display any messages */ |
1553 | insert_ob_in_ob (force, tmp); |
1545 | insert_ob_in_ob (force, tmp); |
1554 | fix_player (tmp); |
1546 | tmp->update_stats (); |
1555 | return 1; |
1547 | return 1; |
1556 | } |
1548 | } |
1557 | |
1549 | |
1558 | |
1550 | |
1559 | |
1551 | |
… | |
… | |
1629 | *small_nuggets -= large->value / small->value; |
1621 | *small_nuggets -= large->value / small->value; |
1630 | if (*small_nuggets && large->value % small->value) |
1622 | if (*small_nuggets && large->value % small->value) |
1631 | (*small_nuggets)--; |
1623 | (*small_nuggets)--; |
1632 | } |
1624 | } |
1633 | weight += obj->weight; |
1625 | weight += obj->weight; |
1634 | remove_ob (obj); |
1626 | obj->destroy (); |
1635 | free_object (obj); |
|
|
1636 | } |
1627 | } |
1637 | |
1628 | |
1638 | static void |
1629 | static void |
1639 | update_map (object *op, mapstruct *m, int small_nuggets, int large_nuggets, int x, int y) |
1630 | update_map (object *op, maptile *m, int small_nuggets, int large_nuggets, int x, int y) |
1640 | { |
1631 | { |
1641 | object *tmp; |
1632 | object *tmp; |
1642 | int flag = 0; |
1633 | int flag = 0; |
1643 | |
1634 | |
1644 | /* Put any nuggets below the player, but we can only pass this |
1635 | /* Put any nuggets below the player, but we can only pass this |
… | |
… | |
1647 | if (x == op->x && y == op->y && op->map == m) |
1638 | if (x == op->x && y == op->y && op->map == m) |
1648 | flag = INS_BELOW_ORIGINATOR; |
1639 | flag = INS_BELOW_ORIGINATOR; |
1649 | |
1640 | |
1650 | if (small_nuggets) |
1641 | if (small_nuggets) |
1651 | { |
1642 | { |
1652 | tmp = get_object (); |
1643 | tmp = small->clone (); |
1653 | copy_object (small, tmp); |
|
|
1654 | tmp->nrof = small_nuggets; |
1644 | tmp->nrof = small_nuggets; |
1655 | tmp->x = x; |
1645 | tmp->x = x; |
1656 | tmp->y = y; |
1646 | tmp->y = y; |
1657 | insert_ob_in_map (tmp, m, op, flag); |
1647 | insert_ob_in_map (tmp, m, op, flag); |
1658 | } |
1648 | } |
|
|
1649 | |
1659 | if (large_nuggets) |
1650 | if (large_nuggets) |
1660 | { |
1651 | { |
1661 | tmp = get_object (); |
1652 | tmp = large->clone (); |
1662 | copy_object (large, tmp); |
|
|
1663 | tmp->nrof = large_nuggets; |
1653 | tmp->nrof = large_nuggets; |
1664 | tmp->x = x; |
1654 | tmp->x = x; |
1665 | tmp->y = y; |
1655 | tmp->y = y; |
1666 | insert_ob_in_map (tmp, m, op, flag); |
1656 | insert_ob_in_map (tmp, m, op, flag); |
1667 | } |
1657 | } |
… | |
… | |
1671 | alchemy (object *op, object *caster, object *spell_ob) |
1661 | alchemy (object *op, object *caster, object *spell_ob) |
1672 | { |
1662 | { |
1673 | int x, y, weight = 0, weight_max, large_nuggets, small_nuggets, mflags; |
1663 | int x, y, weight = 0, weight_max, large_nuggets, small_nuggets, mflags; |
1674 | sint16 nx, ny; |
1664 | sint16 nx, ny; |
1675 | object *next, *tmp; |
1665 | object *next, *tmp; |
1676 | mapstruct *mp; |
1666 | maptile *mp; |
1677 | |
1667 | |
1678 | if (op->type != PLAYER) |
1668 | if (op->type != PLAYER) |
1679 | return 0; |
1669 | return 0; |
1680 | |
1670 | |
1681 | /* Put a maximum weight of items that can be alchemied. Limits the power |
1671 | /* Put a maximum weight of items that can be alchemied. Limits the power |
… | |
… | |
1708 | continue; |
1698 | continue; |
1709 | |
1699 | |
1710 | small_nuggets = 0; |
1700 | small_nuggets = 0; |
1711 | large_nuggets = 0; |
1701 | large_nuggets = 0; |
1712 | |
1702 | |
1713 | for (tmp = get_map_ob (mp, nx, ny); tmp != NULL; tmp = next) |
1703 | for (tmp = GET_MAP_OB (mp, nx, ny); tmp != NULL; tmp = next) |
1714 | { |
1704 | { |
1715 | next = tmp->above; |
1705 | next = tmp->above; |
1716 | if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) && |
1706 | if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) && |
1717 | !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) |
1707 | !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) |
1718 | { |
1708 | { |
… | |
… | |
1732 | alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight); |
1722 | alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight); |
1733 | |
1723 | |
1734 | if (weight > weight_max) |
1724 | if (weight > weight_max) |
1735 | { |
1725 | { |
1736 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1726 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1737 | free_object (large); |
1727 | large->destroy (); |
1738 | free_object (small); |
1728 | small->destroy (); |
1739 | return 1; |
1729 | return 1; |
1740 | } |
1730 | } |
1741 | } /* is alchemable object */ |
1731 | } /* is alchemable object */ |
1742 | } /* process all objects on this space */ |
1732 | } /* process all objects on this space */ |
1743 | |
1733 | |
… | |
… | |
1746 | * with this spell. |
1736 | * with this spell. |
1747 | */ |
1737 | */ |
1748 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1738 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1749 | } |
1739 | } |
1750 | } |
1740 | } |
1751 | free_object (large); |
1741 | |
1752 | free_object (small); |
1742 | large->destroy (); |
|
|
1743 | small->destroy (); |
1753 | /* reset this so that if player standing on a big pile of stuff, |
1744 | /* reset this so that if player standing on a big pile of stuff, |
1754 | * it is redrawn properly. |
1745 | * it is redrawn properly. |
1755 | */ |
1746 | */ |
1756 | op->contr->socket.look_position = 0; |
1747 | op->contr->ns->look_position = 0; |
1757 | return 1; |
1748 | return 1; |
1758 | } |
1749 | } |
1759 | |
1750 | |
1760 | |
1751 | |
1761 | /* This function removes the cursed/damned status on equipped |
1752 | /* This function removes the cursed/damned status on equipped |
… | |
… | |
1770 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1761 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1771 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && |
1762 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && |
1772 | ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) || |
1763 | ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) || |
1773 | (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED)))) |
1764 | (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED)))) |
1774 | { |
1765 | { |
1775 | |
|
|
1776 | was_one++; |
1766 | was_one++; |
1777 | if (tmp->level <= caster_level (caster, spell)) |
1767 | if (tmp->level <= caster_level (caster, spell)) |
1778 | { |
1768 | { |
1779 | success++; |
1769 | success++; |
1780 | if (QUERY_FLAG (spell, FLAG_DAMNED)) |
1770 | if (QUERY_FLAG (spell, FLAG_DAMNED)) |
… | |
… | |
1800 | new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse."); |
1790 | new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse."); |
1801 | else |
1791 | else |
1802 | new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items."); |
1792 | new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items."); |
1803 | } |
1793 | } |
1804 | } |
1794 | } |
|
|
1795 | |
1805 | return success; |
1796 | return success; |
1806 | } |
1797 | } |
1807 | |
1798 | |
1808 | /* Identifies objects in the players inventory/on the ground */ |
1799 | /* Identifies objects in the players inventory/on the ground */ |
1809 | |
1800 | |
… | |
… | |
1816 | num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1807 | num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1817 | |
1808 | |
1818 | if (num_ident < 1) |
1809 | if (num_ident < 1) |
1819 | num_ident = 1; |
1810 | num_ident = 1; |
1820 | |
1811 | |
1821 | |
|
|
1822 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1812 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1823 | { |
1813 | { |
1824 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) |
1814 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) |
1825 | { |
1815 | { |
1826 | identify (tmp); |
1816 | identify (tmp); |
|
|
1817 | |
1827 | if (op->type == PLAYER) |
1818 | if (op->type == PLAYER) |
1828 | { |
1819 | { |
1829 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have %s.", long_desc (tmp, op)); |
1820 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have %s.", long_desc (tmp, op)); |
|
|
1821 | |
1830 | if (tmp->msg) |
1822 | if (tmp->msg) |
1831 | { |
1823 | { |
1832 | new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); |
1824 | new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); |
1833 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
1825 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
1834 | } |
1826 | } |
1835 | } |
1827 | } |
|
|
1828 | |
1836 | num_ident--; |
1829 | num_ident--; |
1837 | success = 1; |
1830 | success = 1; |
1838 | if (!num_ident) |
1831 | if (!num_ident) |
1839 | break; |
1832 | break; |
1840 | } |
1833 | } |
1841 | } |
1834 | } |
|
|
1835 | |
1842 | /* If all the power of the spell has been used up, don't go and identify |
1836 | /* If all the power of the spell has been used up, don't go and identify |
1843 | * stuff on the floor. Only identify stuff on the floor if the spell |
1837 | * stuff on the floor. Only identify stuff on the floor if the spell |
1844 | * was not fully used. |
1838 | * was not fully used. |
1845 | */ |
1839 | */ |
1846 | if (num_ident) |
1840 | if (num_ident) |
1847 | { |
1841 | { |
1848 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
1842 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
1849 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) |
1843 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) |
1850 | { |
1844 | { |
1851 | |
|
|
1852 | identify (tmp); |
1845 | identify (tmp); |
|
|
1846 | |
1853 | if (op->type == PLAYER) |
1847 | if (op->type == PLAYER) |
1854 | { |
1848 | { |
1855 | new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground is %s.", long_desc (tmp, op)); |
1849 | new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground is %s.", long_desc (tmp, op)); |
|
|
1850 | |
1856 | if (tmp->msg) |
1851 | if (tmp->msg) |
1857 | { |
1852 | { |
1858 | new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); |
1853 | new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); |
1859 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
1854 | new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); |
1860 | } |
1855 | } |
|
|
1856 | |
1861 | esrv_send_item (op, tmp); |
1857 | esrv_send_item (op, tmp); |
1862 | } |
1858 | } |
|
|
1859 | |
1863 | num_ident--; |
1860 | num_ident--; |
1864 | success = 1; |
1861 | success = 1; |
1865 | if (!num_ident) |
1862 | if (!num_ident) |
1866 | break; |
1863 | break; |
1867 | } |
1864 | } |
1868 | } |
1865 | } |
|
|
1866 | |
1869 | if (!success) |
1867 | if (!success) |
1870 | new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified."); |
1868 | new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified."); |
1871 | else |
1869 | else |
1872 | { |
|
|
1873 | spell_effect (spell, op->x, op->y, op->map, op); |
1870 | spell_effect (spell, op->x, op->y, op->map, op); |
1874 | } |
1871 | |
1875 | return success; |
1872 | return success; |
1876 | } |
1873 | } |
1877 | |
|
|
1878 | |
1874 | |
1879 | int |
1875 | int |
1880 | cast_detection (object *op, object *caster, object *spell, object *skill) |
1876 | cast_detection (object *op, object *caster, object *spell, object *skill) |
1881 | { |
1877 | { |
1882 | object *tmp, *last, *god, *detect; |
1878 | object *tmp, *last, *god, *detect; |
1883 | int done_one, range, mflags, floor, level; |
1879 | int done_one, range, mflags, floor, level; |
1884 | sint16 x, y, nx, ny; |
1880 | sint16 x, y, nx, ny; |
1885 | mapstruct *m; |
1881 | maptile *m; |
1886 | |
1882 | |
1887 | /* We precompute some values here so that we don't have to keep |
1883 | /* We precompute some values here so that we don't have to keep |
1888 | * doing it over and over again. |
1884 | * doing it over and over again. |
1889 | */ |
1885 | */ |
1890 | god = find_god (determine_god (op)); |
1886 | god = find_god (determine_god (op)); |
… | |
… | |
1895 | skill = caster; |
1891 | skill = caster; |
1896 | |
1892 | |
1897 | for (x = op->x - range; x <= op->x + range; x++) |
1893 | for (x = op->x - range; x <= op->x + range; x++) |
1898 | for (y = op->y - range; y <= op->y + range; y++) |
1894 | for (y = op->y - range; y <= op->y + range; y++) |
1899 | { |
1895 | { |
1900 | |
|
|
1901 | m = op->map; |
1896 | m = op->map; |
1902 | mflags = get_map_flags (m, &m, x, y, &nx, &ny); |
1897 | mflags = get_map_flags (m, &m, x, y, &nx, &ny); |
1903 | if (mflags & P_OUT_OF_MAP) |
1898 | if (mflags & P_OUT_OF_MAP) |
1904 | continue; |
1899 | continue; |
1905 | |
1900 | |
… | |
… | |
1907 | * floor. But this is not true for show invisible. |
1902 | * floor. But this is not true for show invisible. |
1908 | * Basically, we just go and find the top object and work |
1903 | * Basically, we just go and find the top object and work |
1909 | * down - that is easier than working up. |
1904 | * down - that is easier than working up. |
1910 | */ |
1905 | */ |
1911 | |
1906 | |
1912 | for (last = NULL, tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) |
1907 | for (last = NULL, tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above) |
1913 | last = tmp; |
1908 | last = tmp; |
|
|
1909 | |
1914 | /* Shouldn't happen, but if there are no objects on a space, this |
1910 | /* Shouldn't happen, but if there are no objects on a space, this |
1915 | * would happen. |
1911 | * would happen. |
1916 | */ |
1912 | */ |
1917 | if (!last) |
1913 | if (!last) |
1918 | continue; |
1914 | continue; |
… | |
… | |
1920 | done_one = 0; |
1916 | done_one = 0; |
1921 | floor = 0; |
1917 | floor = 0; |
1922 | detect = NULL; |
1918 | detect = NULL; |
1923 | for (tmp = last; tmp; tmp = tmp->below) |
1919 | for (tmp = last; tmp; tmp = tmp->below) |
1924 | { |
1920 | { |
1925 | |
|
|
1926 | /* show invisible */ |
1921 | /* show invisible */ |
1927 | if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && |
1922 | if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && |
1928 | /* Might there be other objects that we can make visibile? */ |
1923 | /* Might there be other objects that we can make visible? */ |
1929 | (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) || |
1924 | (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) || |
1930 | (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) || |
1925 | (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) || |
1931 | tmp->type == CF_HANDLE || |
1926 | tmp->type == CF_HANDLE || |
1932 | tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE || |
1927 | tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE || |
1933 | tmp->type == BUTTON || tmp->type == TELEPORTER || |
1928 | tmp->type == BUTTON || tmp->type == TELEPORTER || |
… | |
… | |
1940 | { |
1935 | { |
1941 | tmp->invisible = 0; |
1936 | tmp->invisible = 0; |
1942 | done_one = 1; |
1937 | done_one = 1; |
1943 | } |
1938 | } |
1944 | } |
1939 | } |
|
|
1940 | |
1945 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
1941 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) |
1946 | floor = 1; |
1942 | floor = 1; |
1947 | |
1943 | |
1948 | /* All detections below this point don't descend beneath the floor, |
1944 | /* All detections below this point don't descend beneath the floor, |
1949 | * so just continue on. We could be clever and look at the type of |
1945 | * so just continue on. We could be clever and look at the type of |
… | |
… | |
2108 | int |
2104 | int |
2109 | cast_transfer (object *op, object *caster, object *spell, int dir) |
2105 | cast_transfer (object *op, object *caster, object *spell, int dir) |
2110 | { |
2106 | { |
2111 | object *plyr = NULL; |
2107 | object *plyr = NULL; |
2112 | sint16 x, y; |
2108 | sint16 x, y; |
2113 | mapstruct *m; |
2109 | maptile *m; |
2114 | int mflags; |
2110 | int mflags; |
2115 | |
2111 | |
2116 | m = op->map; |
2112 | m = op->map; |
2117 | x = op->x + freearr_x[dir]; |
2113 | x = op->x + freearr_x[dir]; |
2118 | y = op->y + freearr_y[dir]; |
2114 | y = op->y + freearr_y[dir]; |
2119 | |
2115 | |
2120 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
2116 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
2121 | |
2117 | |
2122 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) |
2118 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) |
2123 | { |
2119 | { |
2124 | for (plyr = get_map_ob (m, x, y); plyr != NULL; plyr = plyr->above) |
2120 | for (plyr = GET_MAP_OB (m, x, y); plyr != NULL; plyr = plyr->above) |
2125 | if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) |
2121 | if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) |
2126 | break; |
2122 | break; |
2127 | } |
2123 | } |
2128 | |
2124 | |
2129 | |
2125 | |
2130 | /* If we did not find a player in the specified direction, transfer |
2126 | /* If we did not find a player in the specified direction, transfer |
2131 | * to anyone on top of us. This is used for the rune of transference mostly. |
2127 | * to anyone on top of us. This is used for the rune of transference mostly. |
2132 | */ |
2128 | */ |
2133 | if (plyr == NULL) |
2129 | if (plyr == NULL) |
2134 | for (plyr = get_map_ob (op->map, op->x, op->y); plyr != NULL; plyr = plyr->above) |
2130 | for (plyr = GET_MAP_OB (op->map, op->x, op->y); plyr != NULL; plyr = plyr->above) |
2135 | if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) |
2131 | if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) |
2136 | break; |
2132 | break; |
2137 | |
2133 | |
2138 | if (!plyr) |
2134 | if (!plyr) |
2139 | { |
2135 | { |
… | |
… | |
2184 | void |
2180 | void |
2185 | counterspell (object *op, int dir) |
2181 | counterspell (object *op, int dir) |
2186 | { |
2182 | { |
2187 | object *tmp, *head, *next; |
2183 | object *tmp, *head, *next; |
2188 | int mflags; |
2184 | int mflags; |
2189 | mapstruct *m; |
2185 | maptile *m; |
2190 | sint16 sx, sy; |
2186 | sint16 sx, sy; |
2191 | |
2187 | |
2192 | sx = op->x + freearr_x[dir]; |
2188 | sx = op->x + freearr_x[dir]; |
2193 | sy = op->y + freearr_y[dir]; |
2189 | sy = op->y + freearr_y[dir]; |
2194 | m = op->map; |
2190 | m = op->map; |
2195 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
2191 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
2196 | if (mflags & P_OUT_OF_MAP) |
2192 | if (mflags & P_OUT_OF_MAP) |
2197 | return; |
2193 | return; |
2198 | |
2194 | |
2199 | for (tmp = get_map_ob (m, sx, sy); tmp != NULL; tmp = next) |
2195 | for (tmp = GET_MAP_OB (m, sx, sy); tmp != NULL; tmp = next) |
2200 | { |
2196 | { |
2201 | next = tmp->above; |
2197 | next = tmp->above; |
2202 | |
2198 | |
2203 | /* Need to look at the head object - otherwise, if tmp |
2199 | /* Need to look at the head object - otherwise, if tmp |
2204 | * points to a monster, we don't have all the necessary |
2200 | * points to a monster, we don't have all the necessary |
… | |
… | |
2218 | * monsters either. |
2214 | * monsters either. |
2219 | */ |
2215 | */ |
2220 | |
2216 | |
2221 | if (head->attacktype & AT_MAGIC && |
2217 | if (head->attacktype & AT_MAGIC && |
2222 | !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level)) |
2218 | !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level)) |
2223 | { |
2219 | head->destroy (); |
2224 | remove_ob (head); |
|
|
2225 | free_object (head); |
|
|
2226 | } |
|
|
2227 | else |
2220 | else |
2228 | switch (head->type) |
2221 | switch (head->type) |
2229 | { |
2222 | { |
2230 | case SPELL_EFFECT: |
2223 | case SPELL_EFFECT: |
2231 | if (op->level > head->level) |
2224 | if (op->level > head->level) |
2232 | { |
2225 | head->destroy (); |
2233 | remove_ob (head); |
2226 | |
2234 | free_object (head); |
|
|
2235 | } |
|
|
2236 | break; |
2227 | break; |
2237 | |
2228 | |
2238 | /* I really don't get this rune code that much - that |
2229 | /* I really don't get this rune code that much - that |
2239 | * random chance seems really low. |
2230 | * random chance seems really low. |
2240 | */ |
2231 | */ |
2241 | case RUNE: |
2232 | case RUNE: |
2242 | if (rndm (0, 149) == 0) |
2233 | if (rndm (0, 149) == 0) |
2243 | { |
2234 | { |
2244 | head->stats.hp--; /* weaken the rune */ |
2235 | head->stats.hp--; /* weaken the rune */ |
2245 | if (!head->stats.hp) |
2236 | if (!head->stats.hp) |
2246 | { |
2237 | head->destroy (); |
2247 | remove_ob (head); |
|
|
2248 | free_object (head); |
|
|
2249 | } |
|
|
2250 | } |
2238 | } |
2251 | break; |
2239 | break; |
2252 | } |
2240 | } |
2253 | } |
2241 | } |
2254 | } |
2242 | } |
… | |
… | |
2315 | { |
2303 | { |
2316 | object *weapon, *tmp; |
2304 | object *weapon, *tmp; |
2317 | char buf[MAX_BUF]; |
2305 | char buf[MAX_BUF]; |
2318 | int a, i; |
2306 | int a, i; |
2319 | sint16 x, y; |
2307 | sint16 x, y; |
2320 | mapstruct *m; |
2308 | maptile *m; |
2321 | materialtype_t *mt; |
2309 | materialtype_t *mt; |
2322 | |
2310 | |
2323 | if (!spell->other_arch) |
2311 | if (!spell->other_arch) |
2324 | { |
2312 | { |
2325 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
2313 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
… | |
… | |
2329 | /* exit if it's not a player using this spell. */ |
2317 | /* exit if it's not a player using this spell. */ |
2330 | if (op->type != PLAYER) |
2318 | if (op->type != PLAYER) |
2331 | return 0; |
2319 | return 0; |
2332 | |
2320 | |
2333 | /* if player already has a golem, abort */ |
2321 | /* if player already has a golem, abort */ |
2334 | if (op->contr->ranges[range_golem] != NULL && op->contr->golem_count == op->contr->ranges[range_golem]->count) |
2322 | if (op->contr->ranges[range_golem]) |
2335 | { |
2323 | { |
2336 | control_golem (op->contr->ranges[range_golem], dir); |
2324 | control_golem (op->contr->ranges[range_golem], dir); |
2337 | return 0; |
2325 | return 0; |
2338 | } |
2326 | } |
2339 | |
2327 | |
… | |
… | |
2391 | CLEAR_FLAG (tmp, FLAG_MONSTER); |
2379 | CLEAR_FLAG (tmp, FLAG_MONSTER); |
2392 | SET_FLAG (tmp, FLAG_FRIENDLY); |
2380 | SET_FLAG (tmp, FLAG_FRIENDLY); |
2393 | tmp->stats.exp = 0; |
2381 | tmp->stats.exp = 0; |
2394 | add_friendly_object (tmp); |
2382 | add_friendly_object (tmp); |
2395 | tmp->type = GOLEM; |
2383 | tmp->type = GOLEM; |
2396 | set_owner (tmp, op); |
2384 | tmp->set_owner (op); |
2397 | set_spell_skill (op, caster, spell, tmp); |
2385 | set_spell_skill (op, caster, spell, tmp); |
2398 | op->contr->ranges[range_golem] = tmp; |
2386 | op->contr->ranges[range_golem] = tmp; |
2399 | op->contr->shoottype = range_golem; |
2387 | op->contr->shoottype = range_golem; |
2400 | op->contr->golem_count = tmp->count; |
|
|
2401 | |
2388 | |
2402 | /* Give the weapon to the golem now. A bit of a hack to check the |
2389 | /* Give the weapon to the golem now. A bit of a hack to check the |
2403 | * removed flag - it should only be set if get_split_object was |
2390 | * removed flag - it should only be set if get_split_object was |
2404 | * used above. |
2391 | * used above. |
2405 | */ |
2392 | */ |
2406 | if (!QUERY_FLAG (weapon, FLAG_REMOVED)) |
2393 | if (!QUERY_FLAG (weapon, FLAG_REMOVED)) |
2407 | remove_ob (weapon); |
2394 | weapon->remove (); |
2408 | insert_ob_in_ob (weapon, tmp); |
2395 | insert_ob_in_ob (weapon, tmp); |
2409 | esrv_send_item (op, weapon); |
2396 | esrv_send_item (op, weapon); |
2410 | /* To do everything necessary to let a golem use the weapon is a pain, |
2397 | /* To do everything necessary to let a golem use the weapon is a pain, |
2411 | * so instead, just set it as equipped (otherwise, we need to update |
2398 | * so instead, just set it as equipped (otherwise, we need to update |
2412 | * body_info, skills, etc) |
2399 | * body_info, skills, etc) |
2413 | */ |
2400 | */ |
2414 | SET_FLAG (tmp, FLAG_USE_WEAPON); |
2401 | SET_FLAG (tmp, FLAG_USE_WEAPON); |
2415 | SET_FLAG (weapon, FLAG_APPLIED); |
2402 | SET_FLAG (weapon, FLAG_APPLIED); |
2416 | fix_player (tmp); |
2403 | tmp->update_stats (); |
2417 | |
2404 | |
2418 | /* There used to be 'odd' code that basically seemed to take the absolute |
2405 | /* There used to be 'odd' code that basically seemed to take the absolute |
2419 | * value of the weapon->magic an use that. IMO, that doesn't make sense - |
2406 | * value of the weapon->magic an use that. IMO, that doesn't make sense - |
2420 | * if you're using a crappy weapon, it shouldn't be as good. |
2407 | * if you're using a crappy weapon, it shouldn't be as good. |
2421 | */ |
2408 | */ |
… | |
… | |
2559 | |
2546 | |
2560 | new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); |
2547 | new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); |
2561 | |
2548 | |
2562 | new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
2549 | new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
2563 | |
2550 | |
2564 | set_owner (new_aura, op); |
2551 | new_aura->set_owner (op); |
2565 | set_spell_skill (op, caster, spell, new_aura); |
2552 | set_spell_skill (op, caster, spell, new_aura); |
2566 | new_aura->attacktype = spell->attacktype; |
2553 | new_aura->attacktype = spell->attacktype; |
2567 | |
2554 | |
2568 | new_aura->level = caster_level (caster, spell); |
2555 | new_aura->level = caster_level (caster, spell); |
2569 | if (refresh) |
2556 | if (refresh) |
… | |
… | |
2587 | void |
2574 | void |
2588 | move_aura (object *aura) |
2575 | move_aura (object *aura) |
2589 | { |
2576 | { |
2590 | int i, mflags; |
2577 | int i, mflags; |
2591 | object *env; |
2578 | object *env; |
2592 | mapstruct *m; |
2579 | maptile *m; |
2593 | |
2580 | |
2594 | /* auras belong in inventories */ |
2581 | /* auras belong in inventories */ |
2595 | env = aura->env; |
2582 | env = aura->env; |
2596 | |
2583 | |
2597 | /* no matter what we've gotta remove the aura... |
2584 | /* no matter what we've gotta remove the aura... |
2598 | * we'll put it back if its time isn't up. |
2585 | * we'll put it back if its time isn't up. |
2599 | */ |
2586 | */ |
2600 | remove_ob (aura); |
2587 | aura->remove (); |
2601 | |
2588 | |
2602 | /* exit if we're out of gas */ |
2589 | /* exit if we're out of gas */ |
2603 | if (aura->duration-- < 0) |
2590 | if (aura->duration-- < 0) |
2604 | { |
2591 | { |
2605 | free_object (aura); |
2592 | aura->destroy (); |
2606 | return; |
2593 | return; |
2607 | } |
2594 | } |
2608 | |
2595 | |
2609 | /* auras only exist in inventories */ |
2596 | /* auras only exist in inventories */ |
2610 | if (env == NULL || env->map == NULL) |
2597 | if (env == NULL || env->map == NULL) |
2611 | { |
2598 | { |
2612 | free_object (aura); |
2599 | aura->destroy (); |
2613 | return; |
2600 | return; |
2614 | } |
2601 | } |
|
|
2602 | |
2615 | aura->x = env->x; |
2603 | aura->x = env->x; |
2616 | aura->y = env->y; |
2604 | aura->y = env->y; |
2617 | |
2605 | |
2618 | /* we need to jump out of the inventory for a bit |
2606 | /* we need to jump out of the inventory for a bit |
2619 | * in order to hit the map conveniently. |
2607 | * in order to hit the map conveniently. |
… | |
… | |
2646 | insert_ob_in_map (new_ob, m, aura, 0); |
2634 | insert_ob_in_map (new_ob, m, aura, 0); |
2647 | } |
2635 | } |
2648 | } |
2636 | } |
2649 | } |
2637 | } |
2650 | /* put the aura back in the player's inventory */ |
2638 | /* put the aura back in the player's inventory */ |
2651 | remove_ob (aura); |
2639 | aura->remove (); |
2652 | insert_ob_in_ob (aura, env); |
2640 | insert_ob_in_ob (aura, env); |
2653 | } |
2641 | } |
2654 | |
2642 | |
2655 | /* moves the peacemaker spell. |
2643 | /* moves the peacemaker spell. |
2656 | * op is the piece object. |
2644 | * op is the piece object. |
… | |
… | |
2659 | void |
2647 | void |
2660 | move_peacemaker (object *op) |
2648 | move_peacemaker (object *op) |
2661 | { |
2649 | { |
2662 | object *tmp; |
2650 | object *tmp; |
2663 | |
2651 | |
2664 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
2652 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
2665 | { |
2653 | { |
2666 | int atk_lev, def_lev; |
2654 | int atk_lev, def_lev; |
2667 | object *victim = tmp; |
2655 | object *victim = tmp; |
2668 | |
2656 | |
2669 | if (tmp->head) |
2657 | if (tmp->head) |
… | |
… | |
2680 | |
2668 | |
2681 | if (rndm (0, atk_lev - 1) > def_lev) |
2669 | if (rndm (0, atk_lev - 1) > def_lev) |
2682 | { |
2670 | { |
2683 | /* make this sucker peaceful. */ |
2671 | /* make this sucker peaceful. */ |
2684 | |
2672 | |
2685 | change_exp (get_owner (op), victim->stats.exp, op->skill, 0); |
2673 | change_exp (op->owner, victim->stats.exp, op->skill, 0); |
2686 | victim->stats.exp = 0; |
2674 | victim->stats.exp = 0; |
2687 | #if 0 |
2675 | #if 0 |
2688 | /* No idea why these were all set to zero - if something |
2676 | /* No idea why these were all set to zero - if something |
2689 | * makes this creature agressive, he should still do damage. |
2677 | * makes this creature agressive, he should still do damage. |
2690 | */ |
2678 | */ |
… | |
… | |
2730 | return 0; |
2718 | return 0; |
2731 | } |
2719 | } |
2732 | if (!spell->other_arch) |
2720 | if (!spell->other_arch) |
2733 | return 0; |
2721 | return 0; |
2734 | tmp = arch_to_object (spell->other_arch); |
2722 | tmp = arch_to_object (spell->other_arch); |
2735 | strncpy (rune, msg, HUGE_BUF - 2); |
2723 | |
2736 | rune[HUGE_BUF - 2] = 0; |
2724 | snprintf (rune, sizeof (rune), "%s\n", msg); |
2737 | strcat (rune, "\n"); |
2725 | |
2738 | tmp->race = op->name; /*Save the owner of the rune */ |
2726 | tmp->race = op->name; /*Save the owner of the rune */ |
2739 | tmp->msg = rune; |
2727 | tmp->msg = rune; |
2740 | tmp->x = op->x; |
2728 | tmp->x = op->x; |
2741 | tmp->y = op->y; |
2729 | tmp->y = op->y; |
2742 | insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR); |
2730 | insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR); |