1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <spells.h> |
26 | #include <spells.h> |
… | |
… | |
338 | |
338 | |
339 | /* cast_create_object: creates object new_op in direction dir |
339 | /* cast_create_object: creates object new_op in direction dir |
340 | * or if that is blocked, beneath the player (op). |
340 | * or if that is blocked, beneath the player (op). |
341 | * we pass 'caster', but don't use it for anything. |
341 | * we pass 'caster', but don't use it for anything. |
342 | * This is really just a simple wrapper function . |
342 | * This is really just a simple wrapper function . |
343 | * returns the direction that the object was actually placed |
343 | * returns true to indicate whether the operation was successful. |
344 | * in. |
344 | * destroys the object is unsuccessful. |
345 | */ |
345 | */ |
346 | int |
346 | bool |
347 | cast_create_obj (object *op, object *caster, object *new_op, int dir) |
347 | cast_create_obj (object *op, object *caster, object *new_op, int dir) |
348 | { |
348 | { |
349 | maptile *m; |
349 | mapxy pos (op); |
350 | sint16 sx, sy; |
350 | pos.move (dir); |
351 | |
351 | |
352 | if (dir && |
352 | if (!pos.normalise () |
353 | ((get_map_flags (op->map, &m, op->x + freearr_x[dir], op->y + freearr_y[dir], &sx, &sy) & P_OUT_OF_MAP) || |
353 | || pos->blocks (op) // perversely enough, we check if the palyer can reach that space |
354 | OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))) |
354 | || !new_op->can_drop_at (pos.m, pos.x, pos.y) |
|
|
355 | ) |
355 | { |
356 | { |
356 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
357 | op->failmsg ("Your spell fizzles! H<Something is in the way.>"); |
357 | new_draw_info (NDI_UNIQUE, 0, op, "You cast it at your feet."); |
358 | new_op->destroy (); |
358 | dir = 0; |
359 | return 0; |
359 | } |
360 | } |
360 | |
361 | |
361 | new_op->set_flag (FLAG_IDENTIFIED); |
362 | new_op->set_flag (FLAG_IDENTIFIED); |
362 | op->map->insert (new_op, |
|
|
363 | op->x + freearr_x[dir], op->y + freearr_y[dir], |
|
|
364 | op, |
|
|
365 | dir ? 0 : INS_BELOW_ORIGINATOR); |
|
|
366 | |
363 | |
|
|
364 | pos.insert (new_op, op, dir ? 0 : INS_BELOW_ORIGINATOR); |
|
|
365 | |
367 | return dir; |
366 | return 1; |
368 | } |
367 | } |
369 | |
368 | |
370 | static bool |
369 | static bool |
371 | mergable_owner (object *o1, object *o2) |
370 | mergable_owner (object *o1, object *o2) |
372 | { |
371 | { |
… | |
… | |
820 | op->failmsgf ("%s smites you!" HINT_GRACE, godname); |
819 | op->failmsgf ("%s smites you!" HINT_GRACE, godname); |
821 | cast_magic_storm (op, tmp, power); |
820 | cast_magic_storm (op, tmp, power); |
822 | } |
821 | } |
823 | } |
822 | } |
824 | |
823 | |
825 | /* |
824 | /* |
826 | * spell_failure() handles the various effects for differing degrees |
825 | * spell_failure() handles the various effects for differing degrees |
827 | * of failure badness. |
826 | * of failure badness. |
828 | * op is the player that failed. |
827 | * op is the player that failed. |
829 | * failure is a random value of how badly you failed. |
828 | * failure is a random value of how badly you failed. |
830 | * power is how many spellpoints you'd normally need for the spell. |
829 | * power is how many spellpoints you'd normally need for the spell. |
831 | * skill is the skill you'd need to cast the spell. |
830 | * skill is the skill you'd need to cast the spell. |
832 | */ |
831 | */ |
833 | |
|
|
834 | void |
832 | void |
835 | spell_failure (object *op, int failure, int power, object *skill) |
833 | spell_failure (object *op, int failure, int power, object *skill) |
836 | { |
834 | { |
837 | object *tmp; |
835 | object *tmp; |
838 | |
836 | |