1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_spell_effect_c = |
|
|
4 | * "$Id: spell_effect.C,v 1.10 2006/09/14 21:16:13 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> |
… | |
… | |
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 (archetype::find (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 */ |
… | |
… | |
171 | { |
162 | { |
172 | free_object (missile); |
163 | free_object (missile); |
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 | free_object (missile); |
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 | remove_ob (wor); |
480 | free_object (wor); |
472 | free_object (wor); |
481 | } |
473 | } |
482 | |
474 | |
483 | /* Word of recall causes the player to return 'home'. |
475 | /* Word of recall causes the player to return 'home'. |
… | |
… | |
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 |
… | |
… | |
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 | { |
… | |
… | |
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 | |
… | |
… | |
1634 | remove_ob (obj); |
1626 | remove_ob (obj); |
1635 | free_object (obj); |
1627 | free_object (obj); |
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 |
… | |
… | |
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; |
… | |
… | |
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!"); |
… | |
… | |
2587 | void |
2579 | void |
2588 | move_aura (object *aura) |
2580 | move_aura (object *aura) |
2589 | { |
2581 | { |
2590 | int i, mflags; |
2582 | int i, mflags; |
2591 | object *env; |
2583 | object *env; |
2592 | mapstruct *m; |
2584 | maptile *m; |
2593 | |
2585 | |
2594 | /* auras belong in inventories */ |
2586 | /* auras belong in inventories */ |
2595 | env = aura->env; |
2587 | env = aura->env; |
2596 | |
2588 | |
2597 | /* no matter what we've gotta remove the aura... |
2589 | /* no matter what we've gotta remove the aura... |