1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_spell_effect_c = |
|
|
4 | * "$Id: spell_effect.C,v 1.9 2006/09/12 19:20:08 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->remove (); |
87 | free_object (wand); |
80 | wand->destroy (0); |
88 | tmp = get_archetype ("fireball"); |
81 | tmp = get_archetype ("fireball"); |
89 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
82 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
90 | if (!tmp->stats.dam) |
83 | if (!tmp->stats.dam) |
91 | tmp->stats.dam = 1; |
84 | tmp->stats.dam = 1; |
92 | tmp->stats.hp = tmp->stats.dam / 2; |
85 | tmp->stats.hp = tmp->stats.dam / 2; |
… | |
… | |
135 | cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg) |
128 | cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg) |
136 | { |
129 | { |
137 | int missile_plus = 0, bonus_plus = 0; |
130 | int missile_plus = 0, bonus_plus = 0; |
138 | const char *missile_name; |
131 | const char *missile_name; |
139 | object *tmp, *missile; |
132 | object *tmp, *missile; |
140 | tag_t tag; |
|
|
141 | |
133 | |
142 | missile_name = "arrow"; |
134 | missile_name = "arrow"; |
143 | |
135 | |
144 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
136 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
145 | if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) |
137 | if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) |
146 | { |
|
|
147 | missile_name = tmp->race; |
138 | missile_name = tmp->race; |
148 | } |
|
|
149 | |
139 | |
150 | missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
140 | missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
151 | |
141 | |
152 | if (find_archetype (missile_name) == NULL) |
142 | if (archetype::find (missile_name) == NULL) |
153 | { |
143 | { |
154 | LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name); |
144 | LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name); |
155 | return 0; |
145 | return 0; |
156 | } |
146 | } |
|
|
147 | |
157 | missile = get_archetype (missile_name); |
148 | missile = get_archetype (missile_name); |
158 | |
149 | |
159 | if (stringarg) |
150 | if (stringarg) |
160 | { |
151 | { |
161 | /* If it starts with a letter, presume it is a description */ |
152 | /* If it starts with a letter, presume it is a description */ |
… | |
… | |
167 | if (!strcasecmp (al->item->name, stringarg)) |
158 | if (!strcasecmp (al->item->name, stringarg)) |
168 | break; |
159 | break; |
169 | |
160 | |
170 | if (!al) |
161 | if (!al) |
171 | { |
162 | { |
172 | free_object (missile); |
163 | missile->destroy (0); |
173 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such object %ss of %s", missile_name, stringarg); |
164 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such object %ss of %s", missile_name, stringarg); |
174 | return 0; |
165 | return 0; |
175 | } |
166 | } |
|
|
167 | |
176 | if (al->item->slaying) |
168 | if (al->item->slaying) |
177 | { |
169 | { |
178 | free_object (missile); |
170 | missile->destroy (0); |
179 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); |
171 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); |
180 | return 0; |
172 | return 0; |
181 | } |
173 | } |
|
|
174 | |
182 | give_artifact_abilities (missile, al->item); |
175 | give_artifact_abilities (missile, al->item); |
183 | /* These special arrows cost something extra. Don't have them also be magical - |
176 | /* 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 |
177 | * 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. |
178 | * the parsing of having to do both plus and type. |
186 | */ |
179 | */ |
… | |
… | |
188 | missile_plus = 0; |
181 | missile_plus = 0; |
189 | } |
182 | } |
190 | else if (atoi (stringarg) < missile_plus) |
183 | else if (atoi (stringarg) < missile_plus) |
191 | missile_plus = atoi (stringarg); |
184 | missile_plus = atoi (stringarg); |
192 | } |
185 | } |
|
|
186 | |
193 | if (missile_plus > 4) |
187 | if (missile_plus > 4) |
194 | missile_plus = 4; |
188 | missile_plus = 4; |
195 | else if (missile_plus < -4) |
189 | else if (missile_plus < -4) |
196 | missile_plus = -4; |
190 | missile_plus = -4; |
197 | |
191 | |
198 | missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell); |
192 | missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell); |
199 | missile->nrof -= 3 * (missile_plus + bonus_plus); |
193 | missile->nrof -= 3 * (missile_plus + bonus_plus); |
|
|
194 | |
200 | if (missile->nrof < 1) |
195 | if (missile->nrof < 1) |
201 | missile->nrof = 1; |
196 | missile->nrof = 1; |
202 | |
197 | |
203 | missile->magic = missile_plus; |
198 | missile->magic = missile_plus; |
204 | /* Can't get any money for these objects */ |
199 | /* Can't get any money for these objects */ |
205 | missile->value = 0; |
200 | missile->value = 0; |
206 | |
201 | |
207 | SET_FLAG (missile, FLAG_IDENTIFIED); |
202 | SET_FLAG (missile, FLAG_IDENTIFIED); |
208 | tag = missile->count; |
|
|
209 | |
203 | |
210 | if (!cast_create_obj (op, caster, missile, dir) && op->type == PLAYER && !was_destroyed (missile, tag)) |
204 | if (!cast_create_obj (op, caster, missile, dir) && op->type == PLAYER && !missile->destroyed ()) |
211 | { |
|
|
212 | pick_up (op, missile); |
205 | pick_up (op, missile); |
213 | } |
206 | |
214 | return 1; |
207 | return 1; |
215 | } |
208 | } |
216 | |
209 | |
217 | |
210 | |
218 | /* allows the choice of what sort of food object to make. |
211 | /* allows the choice of what sort of food object to make. |
… | |
… | |
284 | int |
277 | int |
285 | probe (object *op, object *caster, object *spell_ob, int dir) |
278 | probe (object *op, object *caster, object *spell_ob, int dir) |
286 | { |
279 | { |
287 | int r, mflags, maxrange; |
280 | int r, mflags, maxrange; |
288 | object *tmp; |
281 | object *tmp; |
289 | mapstruct *m; |
282 | maptile *m; |
290 | |
283 | |
291 | |
284 | |
292 | if (!dir) |
285 | if (!dir) |
293 | { |
286 | { |
294 | examine_monster (op, op); |
287 | examine_monster (op, op); |
… | |
… | |
429 | cast_earth_to_dust (object *op, object *caster, object *spell_ob) |
422 | cast_earth_to_dust (object *op, object *caster, object *spell_ob) |
430 | { |
423 | { |
431 | object *tmp, *next; |
424 | object *tmp, *next; |
432 | int range, i, j, mflags; |
425 | int range, i, j, mflags; |
433 | sint16 sx, sy; |
426 | sint16 sx, sy; |
434 | mapstruct *m; |
427 | maptile *m; |
435 | |
428 | |
436 | if (op->type != PLAYER) |
429 | if (op->type != PLAYER) |
437 | return 0; |
430 | return 0; |
438 | |
431 | |
439 | range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
432 | range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); |
… | |
… | |
468 | |
461 | |
469 | while (op != NULL && op->type != PLAYER) |
462 | while (op != NULL && op->type != PLAYER) |
470 | op = op->env; |
463 | op = op->env; |
471 | |
464 | |
472 | if (op != NULL && op->map) |
465 | 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))) |
466 | 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."); |
467 | new_draw_info (NDI_UNIQUE, 0, op, "You feel something fizzle inside you."); |
476 | else |
468 | else |
477 | enter_exit (op, wor); |
469 | enter_exit (op, wor); |
478 | } |
470 | |
479 | remove_ob (wor); |
471 | wor->remove (); |
480 | free_object (wor); |
472 | wor->destroy (0); |
481 | } |
473 | } |
482 | |
474 | |
483 | /* Word of recall causes the player to return 'home'. |
475 | /* Word of recall causes the player to return 'home'. |
484 | * we put a force into the player object, so that there is a |
476 | * we put a force into the player object, so that there is a |
485 | * time delay effect. |
477 | * time delay effect. |
… | |
… | |
571 | |
563 | |
572 | int |
564 | int |
573 | perceive_self (object *op) |
565 | perceive_self (object *op) |
574 | { |
566 | { |
575 | char *cp = describe_item (op, op), buf[MAX_BUF]; |
567 | char *cp = describe_item (op, op), buf[MAX_BUF]; |
576 | archetype *at = find_archetype (ARCH_DEPLETION); |
568 | archetype *at = archetype::find (ARCH_DEPLETION); |
577 | object *tmp; |
569 | object *tmp; |
578 | int i; |
570 | int i; |
579 | |
571 | |
580 | tmp = find_god (determine_god (op)); |
572 | tmp = find_god (determine_god (op)); |
581 | if (tmp) |
573 | if (tmp) |
… | |
… | |
648 | { |
640 | { |
649 | object *dummy, *force, *old_force, *tmp; |
641 | object *dummy, *force, *old_force, *tmp; |
650 | archetype *perm_portal; |
642 | archetype *perm_portal; |
651 | char portal_name[1024], portal_message[1024]; |
643 | char portal_name[1024], portal_message[1024]; |
652 | sint16 exitx, exity; |
644 | sint16 exitx, exity; |
653 | mapstruct *exitmap; |
645 | maptile *exitmap; |
654 | int op_level; |
646 | int op_level; |
655 | |
647 | |
656 | |
648 | |
657 | /* Check to see if the map the player is currently on is a per player unique |
649 | /* 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 |
650 | * map. This can be determined in that per player unique maps have the |
… | |
… | |
688 | EXIT_Y (dummy) = op->y; |
680 | EXIT_Y (dummy) = op->y; |
689 | insert_ob_in_ob (dummy, op); |
681 | 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."); |
682 | 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; |
683 | return 1; |
692 | } |
684 | } |
693 | free_object (dummy); |
685 | dummy->destroy (0); |
694 | |
686 | |
695 | /* Here we know where the town portal should go to |
687 | /* Here we know where the town portal should go to |
696 | * We should kill any existing portal associated with the player. |
688 | * We should kill any existing portal associated with the player. |
697 | * Than we should create the 2 portals. |
689 | * Than we should create the 2 portals. |
698 | * For each of them, we need: |
690 | * For each of them, we need: |
… | |
… | |
714 | { |
706 | { |
715 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
707 | 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); |
708 | LOG (llevError, "get_object failed (force) in cast_create_town_portal for %s!\n", &op->name); |
717 | return 0; |
709 | return 0; |
718 | } |
710 | } |
719 | perm_portal = find_archetype (spell->slaying); |
711 | perm_portal = archetype::find (spell->slaying); |
720 | |
712 | |
721 | /* To kill a town portal, we go trough the player's inventory, |
713 | /* To kill a town portal, we go trough the player's inventory, |
722 | * for each marked portal in player's inventory, |
714 | * for each marked portal in player's inventory, |
723 | * -We try load the associated map (if impossible, consider the portal destructed) |
715 | * -We try load the associated map (if impossible, consider the portal destructed) |
724 | * -We find any portal in the specified location. |
716 | * -We find any portal in the specified location. |
… | |
… | |
741 | tmp = present_arch (perm_portal, exitmap, exitx, exity); |
733 | tmp = present_arch (perm_portal, exitmap, exitx, exity); |
742 | while (tmp) |
734 | while (tmp) |
743 | { |
735 | { |
744 | if (tmp->name == old_force->name) |
736 | if (tmp->name == old_force->name) |
745 | { |
737 | { |
746 | remove_ob (tmp); |
738 | tmp->remove (); |
747 | free_object (tmp); |
739 | tmp->destroy (0); |
748 | break; |
740 | break; |
749 | } |
741 | } |
750 | else |
742 | else |
751 | { |
743 | { |
752 | tmp = tmp->above; |
744 | tmp = tmp->above; |
753 | } |
745 | } |
754 | } |
746 | } |
755 | } |
747 | } |
756 | remove_ob (old_force); |
748 | old_force->remove (); |
757 | free_object (old_force); |
749 | old_force->destroy (0); |
758 | LOG (llevDebug, "\n"); |
750 | LOG (llevDebug, "\n"); |
759 | } |
751 | } |
760 | free_object (dummy); |
752 | dummy->destroy (0); |
761 | |
753 | |
762 | /* Creating the portals. |
754 | /* Creating the portals. |
763 | * The very first thing to do is to ensure |
755 | * The very first thing to do is to ensure |
764 | * access to the destination map. |
756 | * access to the destination map. |
765 | * If we can't, don't fizzle. Simply warn player. |
757 | * If we can't, don't fizzle. Simply warn player. |
… | |
… | |
777 | |
769 | |
778 | /* If we were unable to load (ex. random map deleted), warn player */ |
770 | /* If we were unable to load (ex. random map deleted), warn player */ |
779 | if (exitmap == NULL) |
771 | if (exitmap == NULL) |
780 | { |
772 | { |
781 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); |
773 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); |
782 | remove_ob (force); |
774 | force->remove (); |
783 | free_object (force); |
775 | force->destroy (0); |
784 | return 1; |
776 | return 1; |
785 | } |
777 | } |
786 | |
778 | |
787 | op_level = caster_level (caster, spell); |
779 | op_level = caster_level (caster, spell); |
788 | if (op_level < 15) |
780 | if (op_level < 15) |
… | |
… | |
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->remove (); /* Delete the force inside the player */ |
883 | free_object (force); |
875 | force->destroy (0); |
884 | return 1; |
876 | return 1; |
885 | } |
877 | } |
886 | |
878 | |
887 | |
879 | |
888 | /* This creates magic walls. Really, it can create most any object, |
880 | /* This creates magic walls. Really, it can create most any object, |
… | |
… | |
893 | magic_wall (object *op, object *caster, int dir, object *spell_ob) |
885 | magic_wall (object *op, object *caster, int dir, object *spell_ob) |
894 | { |
886 | { |
895 | object *tmp, *tmp2; |
887 | object *tmp, *tmp2; |
896 | int i, posblocked, negblocked, maxrange; |
888 | int i, posblocked, negblocked, maxrange; |
897 | sint16 x, y; |
889 | sint16 x, y; |
898 | mapstruct *m; |
890 | maptile *m; |
899 | const char *name; |
891 | const char *name; |
900 | archetype *at; |
892 | archetype *at; |
901 | |
893 | |
902 | if (!dir) |
894 | if (!dir) |
903 | { |
895 | { |
… | |
… | |
926 | else if (spell_ob->race) |
918 | else if (spell_ob->race) |
927 | { |
919 | { |
928 | char buf1[MAX_BUF]; |
920 | char buf1[MAX_BUF]; |
929 | |
921 | |
930 | sprintf (buf1, spell_ob->race, dir); |
922 | sprintf (buf1, spell_ob->race, dir); |
931 | at = find_archetype (buf1); |
923 | at = archetype::find (buf1); |
932 | if (!at) |
924 | if (!at) |
933 | { |
925 | { |
934 | LOG (llevError, "summon_wall: Unable to find archetype %s\n", buf1); |
926 | LOG (llevError, "summon_wall: Unable to find archetype %s\n", buf1); |
935 | new_draw_info (NDI_UNIQUE, 0, op, "This spell is broken."); |
927 | new_draw_info (NDI_UNIQUE, 0, op, "This spell is broken."); |
936 | return 0; |
928 | return 0; |
… | |
… | |
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."); |
… | |
… | |
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->remove (); |
1635 | free_object (obj); |
1627 | obj->destroy (0); |
1636 | } |
1628 | } |
1637 | |
1629 | |
1638 | static void |
1630 | static void |
1639 | update_map (object *op, mapstruct *m, int small_nuggets, int large_nuggets, int x, int y) |
1631 | update_map (object *op, maptile *m, int small_nuggets, int large_nuggets, int x, int y) |
1640 | { |
1632 | { |
1641 | object *tmp; |
1633 | object *tmp; |
1642 | int flag = 0; |
1634 | int flag = 0; |
1643 | |
1635 | |
1644 | /* Put any nuggets below the player, but we can only pass this |
1636 | /* Put any nuggets below the player, but we can only pass this |
… | |
… | |
1671 | alchemy (object *op, object *caster, object *spell_ob) |
1663 | alchemy (object *op, object *caster, object *spell_ob) |
1672 | { |
1664 | { |
1673 | int x, y, weight = 0, weight_max, large_nuggets, small_nuggets, mflags; |
1665 | int x, y, weight = 0, weight_max, large_nuggets, small_nuggets, mflags; |
1674 | sint16 nx, ny; |
1666 | sint16 nx, ny; |
1675 | object *next, *tmp; |
1667 | object *next, *tmp; |
1676 | mapstruct *mp; |
1668 | maptile *mp; |
1677 | |
1669 | |
1678 | if (op->type != PLAYER) |
1670 | if (op->type != PLAYER) |
1679 | return 0; |
1671 | return 0; |
1680 | |
1672 | |
1681 | /* Put a maximum weight of items that can be alchemied. Limits the power |
1673 | /* Put a maximum weight of items that can be alchemied. Limits the power |
… | |
… | |
1732 | alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight); |
1724 | alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight); |
1733 | |
1725 | |
1734 | if (weight > weight_max) |
1726 | if (weight > weight_max) |
1735 | { |
1727 | { |
1736 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1728 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1737 | free_object (large); |
1729 | large->destroy (0); |
1738 | free_object (small); |
1730 | small->destroy (0); |
1739 | return 1; |
1731 | return 1; |
1740 | } |
1732 | } |
1741 | } /* is alchemable object */ |
1733 | } /* is alchemable object */ |
1742 | } /* process all objects on this space */ |
1734 | } /* process all objects on this space */ |
1743 | |
1735 | |
… | |
… | |
1746 | * with this spell. |
1738 | * with this spell. |
1747 | */ |
1739 | */ |
1748 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1740 | update_map (op, mp, small_nuggets, large_nuggets, nx, ny); |
1749 | } |
1741 | } |
1750 | } |
1742 | } |
1751 | free_object (large); |
1743 | large->destroy (0); |
1752 | free_object (small); |
1744 | small->destroy (0); |
1753 | /* reset this so that if player standing on a big pile of stuff, |
1745 | /* reset this so that if player standing on a big pile of stuff, |
1754 | * it is redrawn properly. |
1746 | * it is redrawn properly. |
1755 | */ |
1747 | */ |
1756 | op->contr->socket.look_position = 0; |
1748 | op->contr->socket.look_position = 0; |
1757 | return 1; |
1749 | return 1; |
… | |
… | |
1880 | cast_detection (object *op, object *caster, object *spell, object *skill) |
1872 | cast_detection (object *op, object *caster, object *spell, object *skill) |
1881 | { |
1873 | { |
1882 | object *tmp, *last, *god, *detect; |
1874 | object *tmp, *last, *god, *detect; |
1883 | int done_one, range, mflags, floor, level; |
1875 | int done_one, range, mflags, floor, level; |
1884 | sint16 x, y, nx, ny; |
1876 | sint16 x, y, nx, ny; |
1885 | mapstruct *m; |
1877 | maptile *m; |
1886 | |
1878 | |
1887 | /* We precompute some values here so that we don't have to keep |
1879 | /* We precompute some values here so that we don't have to keep |
1888 | * doing it over and over again. |
1880 | * doing it over and over again. |
1889 | */ |
1881 | */ |
1890 | god = find_god (determine_god (op)); |
1882 | god = find_god (determine_god (op)); |
… | |
… | |
2108 | int |
2100 | int |
2109 | cast_transfer (object *op, object *caster, object *spell, int dir) |
2101 | cast_transfer (object *op, object *caster, object *spell, int dir) |
2110 | { |
2102 | { |
2111 | object *plyr = NULL; |
2103 | object *plyr = NULL; |
2112 | sint16 x, y; |
2104 | sint16 x, y; |
2113 | mapstruct *m; |
2105 | maptile *m; |
2114 | int mflags; |
2106 | int mflags; |
2115 | |
2107 | |
2116 | m = op->map; |
2108 | m = op->map; |
2117 | x = op->x + freearr_x[dir]; |
2109 | x = op->x + freearr_x[dir]; |
2118 | y = op->y + freearr_y[dir]; |
2110 | y = op->y + freearr_y[dir]; |
… | |
… | |
2184 | void |
2176 | void |
2185 | counterspell (object *op, int dir) |
2177 | counterspell (object *op, int dir) |
2186 | { |
2178 | { |
2187 | object *tmp, *head, *next; |
2179 | object *tmp, *head, *next; |
2188 | int mflags; |
2180 | int mflags; |
2189 | mapstruct *m; |
2181 | maptile *m; |
2190 | sint16 sx, sy; |
2182 | sint16 sx, sy; |
2191 | |
2183 | |
2192 | sx = op->x + freearr_x[dir]; |
2184 | sx = op->x + freearr_x[dir]; |
2193 | sy = op->y + freearr_y[dir]; |
2185 | sy = op->y + freearr_y[dir]; |
2194 | m = op->map; |
2186 | m = op->map; |
… | |
… | |
2219 | */ |
2211 | */ |
2220 | |
2212 | |
2221 | if (head->attacktype & AT_MAGIC && |
2213 | if (head->attacktype & AT_MAGIC && |
2222 | !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level)) |
2214 | !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level)) |
2223 | { |
2215 | { |
2224 | remove_ob (head); |
2216 | head->remove (); |
2225 | free_object (head); |
2217 | head->destroy (0); |
2226 | } |
2218 | } |
2227 | else |
2219 | else |
2228 | switch (head->type) |
2220 | switch (head->type) |
2229 | { |
2221 | { |
2230 | case SPELL_EFFECT: |
2222 | case SPELL_EFFECT: |
2231 | if (op->level > head->level) |
2223 | if (op->level > head->level) |
2232 | { |
2224 | { |
2233 | remove_ob (head); |
2225 | head->remove (); |
2234 | free_object (head); |
2226 | head->destroy (0); |
2235 | } |
2227 | } |
2236 | break; |
2228 | break; |
2237 | |
2229 | |
2238 | /* I really don't get this rune code that much - that |
2230 | /* I really don't get this rune code that much - that |
2239 | * random chance seems really low. |
2231 | * random chance seems really low. |
… | |
… | |
2242 | if (rndm (0, 149) == 0) |
2234 | if (rndm (0, 149) == 0) |
2243 | { |
2235 | { |
2244 | head->stats.hp--; /* weaken the rune */ |
2236 | head->stats.hp--; /* weaken the rune */ |
2245 | if (!head->stats.hp) |
2237 | if (!head->stats.hp) |
2246 | { |
2238 | { |
2247 | remove_ob (head); |
2239 | head->remove (); |
2248 | free_object (head); |
2240 | head->destroy (0); |
2249 | } |
2241 | } |
2250 | } |
2242 | } |
2251 | break; |
2243 | break; |
2252 | } |
2244 | } |
2253 | } |
2245 | } |
… | |
… | |
2315 | { |
2307 | { |
2316 | object *weapon, *tmp; |
2308 | object *weapon, *tmp; |
2317 | char buf[MAX_BUF]; |
2309 | char buf[MAX_BUF]; |
2318 | int a, i; |
2310 | int a, i; |
2319 | sint16 x, y; |
2311 | sint16 x, y; |
2320 | mapstruct *m; |
2312 | maptile *m; |
2321 | materialtype_t *mt; |
2313 | materialtype_t *mt; |
2322 | |
2314 | |
2323 | if (!spell->other_arch) |
2315 | if (!spell->other_arch) |
2324 | { |
2316 | { |
2325 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
2317 | new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); |
… | |
… | |
2329 | /* exit if it's not a player using this spell. */ |
2321 | /* exit if it's not a player using this spell. */ |
2330 | if (op->type != PLAYER) |
2322 | if (op->type != PLAYER) |
2331 | return 0; |
2323 | return 0; |
2332 | |
2324 | |
2333 | /* if player already has a golem, abort */ |
2325 | /* 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) |
2326 | if (op->contr->ranges[range_golem]) |
2335 | { |
2327 | { |
2336 | control_golem (op->contr->ranges[range_golem], dir); |
2328 | control_golem (op->contr->ranges[range_golem], dir); |
2337 | return 0; |
2329 | return 0; |
2338 | } |
2330 | } |
2339 | |
2331 | |
… | |
… | |
2395 | tmp->type = GOLEM; |
2387 | tmp->type = GOLEM; |
2396 | set_owner (tmp, op); |
2388 | set_owner (tmp, op); |
2397 | set_spell_skill (op, caster, spell, tmp); |
2389 | set_spell_skill (op, caster, spell, tmp); |
2398 | op->contr->ranges[range_golem] = tmp; |
2390 | op->contr->ranges[range_golem] = tmp; |
2399 | op->contr->shoottype = range_golem; |
2391 | op->contr->shoottype = range_golem; |
2400 | op->contr->golem_count = tmp->count; |
|
|
2401 | |
2392 | |
2402 | /* Give the weapon to the golem now. A bit of a hack to check the |
2393 | /* 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 |
2394 | * removed flag - it should only be set if get_split_object was |
2404 | * used above. |
2395 | * used above. |
2405 | */ |
2396 | */ |
2406 | if (!QUERY_FLAG (weapon, FLAG_REMOVED)) |
2397 | if (!QUERY_FLAG (weapon, FLAG_REMOVED)) |
2407 | remove_ob (weapon); |
2398 | weapon->remove (); |
2408 | insert_ob_in_ob (weapon, tmp); |
2399 | insert_ob_in_ob (weapon, tmp); |
2409 | esrv_send_item (op, weapon); |
2400 | esrv_send_item (op, weapon); |
2410 | /* To do everything necessary to let a golem use the weapon is a pain, |
2401 | /* 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 |
2402 | * so instead, just set it as equipped (otherwise, we need to update |
2412 | * body_info, skills, etc) |
2403 | * body_info, skills, etc) |
… | |
… | |
2587 | void |
2578 | void |
2588 | move_aura (object *aura) |
2579 | move_aura (object *aura) |
2589 | { |
2580 | { |
2590 | int i, mflags; |
2581 | int i, mflags; |
2591 | object *env; |
2582 | object *env; |
2592 | mapstruct *m; |
2583 | maptile *m; |
2593 | |
2584 | |
2594 | /* auras belong in inventories */ |
2585 | /* auras belong in inventories */ |
2595 | env = aura->env; |
2586 | env = aura->env; |
2596 | |
2587 | |
2597 | /* no matter what we've gotta remove the aura... |
2588 | /* no matter what we've gotta remove the aura... |
2598 | * we'll put it back if its time isn't up. |
2589 | * we'll put it back if its time isn't up. |
2599 | */ |
2590 | */ |
2600 | remove_ob (aura); |
2591 | aura->remove (); |
2601 | |
2592 | |
2602 | /* exit if we're out of gas */ |
2593 | /* exit if we're out of gas */ |
2603 | if (aura->duration-- < 0) |
2594 | if (aura->duration-- < 0) |
2604 | { |
2595 | { |
2605 | free_object (aura); |
2596 | aura->destroy (0); |
2606 | return; |
2597 | return; |
2607 | } |
2598 | } |
2608 | |
2599 | |
2609 | /* auras only exist in inventories */ |
2600 | /* auras only exist in inventories */ |
2610 | if (env == NULL || env->map == NULL) |
2601 | if (env == NULL || env->map == NULL) |
2611 | { |
2602 | { |
2612 | free_object (aura); |
2603 | aura->destroy (0); |
2613 | return; |
2604 | return; |
2614 | } |
2605 | } |
2615 | aura->x = env->x; |
2606 | aura->x = env->x; |
2616 | aura->y = env->y; |
2607 | aura->y = env->y; |
2617 | |
2608 | |
… | |
… | |
2646 | insert_ob_in_map (new_ob, m, aura, 0); |
2637 | insert_ob_in_map (new_ob, m, aura, 0); |
2647 | } |
2638 | } |
2648 | } |
2639 | } |
2649 | } |
2640 | } |
2650 | /* put the aura back in the player's inventory */ |
2641 | /* put the aura back in the player's inventory */ |
2651 | remove_ob (aura); |
2642 | aura->remove (); |
2652 | insert_ob_in_ob (aura, env); |
2643 | insert_ob_in_ob (aura, env); |
2653 | } |
2644 | } |
2654 | |
2645 | |
2655 | /* moves the peacemaker spell. |
2646 | /* moves the peacemaker spell. |
2656 | * op is the piece object. |
2647 | * op is the piece object. |