ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_util.C
(Generate patch)

Comparing deliantra/server/server/spell_util.C (file contents):
Revision 1.120 by root, Sat Apr 23 04:56:57 2011 UTC vs.
Revision 1.125 by root, Mon Nov 12 03:48:34 2012 UTC

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>
158 sp *= (int) PATH_SP_MULT (caster, spell); 158 sp *= (int) PATH_SP_MULT (caster, spell);
159 if (!sp && spell->stats.sp) 159 if (!sp && spell->stats.sp)
160 sp = 1; 160 sp = 1;
161 161
162 if (spell->stats.grace && spell->stats.maxgrace) 162 if (spell->stats.grace && spell->stats.maxgrace)
163 grace = spell->stats.grace * (1.0 + max (0, float (level - spell->level) / spell->stats.maxgrace)); 163 grace = spell->stats.grace * (1.f + max (0.f, float (level - spell->level) / spell->stats.maxgrace));
164 else 164 else
165 grace = spell->stats.grace; 165 grace = spell->stats.grace;
166 166
167 grace *= PATH_SP_MULT (caster, spell); 167 grace *= PATH_SP_MULT (caster, spell);
168 if (spell->stats.grace && !grace) 168 if (spell->stats.grace && !grace)
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 */
346int 346bool
347cast_create_obj (object *op, object *caster, object *new_op, int dir) 347cast_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
370static bool 369static bool
371mergable_owner (object *o1, object *o2) 370mergable_owner (object *o1, object *o2)
372{ 371{
795 godname = "Your spirit"; 794 godname = "Your spirit";
796 795
797 if (failure <= -20 && failure > -40) /* wonder */ 796 if (failure <= -20 && failure > -40) /* wonder */
798 { 797 {
799 op->failmsgf ("%s gives a sign to renew your faith." HINT_GRACE, godname); 798 op->failmsgf ("%s gives a sign to renew your faith." HINT_GRACE, godname);
800 tmp = get_archetype (SPELL_WONDER); 799 tmp = archetype::get (SPELL_WONDER);
801 cast_cone (op, op, 0, tmp); 800 cast_cone (op, op, 0, tmp);
802 tmp->destroy (); 801 tmp->destroy ();
803 } 802 }
804 803
805 else if (failure <= -40 && failure > -60) /* confusion */ 804 else if (failure <= -40 && failure > -60) /* confusion */
814 godname); 813 godname);
815 paralyze_player (op, op, 99); 814 paralyze_player (op, op, 99);
816 } 815 }
817 else if (failure <= -150) /* blast the immediate area */ 816 else if (failure <= -150) /* blast the immediate area */
818 { 817 {
819 tmp = get_archetype (GOD_POWER); 818 tmp = archetype::get (GOD_POWER);
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
834void 832void
835spell_failure (object *op, int failure, int power, object *skill) 833spell_failure (object *op, int failure, int power, object *skill)
836{ 834{
837 object *tmp; 835 object *tmp;
838 836
840 return; 838 return;
841 839
842 if (failure <= -20 && failure > -40) /* wonder */ 840 if (failure <= -20 && failure > -40) /* wonder */
843 { 841 {
844 op->failmsg ("Your spell causes an unexpected effect."); 842 op->failmsg ("Your spell causes an unexpected effect.");
845 tmp = get_archetype (SPELL_WONDER); 843 tmp = archetype::get (SPELL_WONDER);
846 cast_cone (op, op, 0, tmp); 844 cast_cone (op, op, 0, tmp);
847 tmp->destroy (); 845 tmp->destroy ();
848 } 846 }
849 847
850 else if (failure <= -40 && failure > -60) /* confusion */ 848 else if (failure <= -40 && failure > -60) /* confusion */
869 867
870 } 868 }
871 else 869 else
872 { 870 {
873 op->failmsg ("You lose control of the mana! The uncontrolled magic blasts you!"); 871 op->failmsg ("You lose control of the mana! The uncontrolled magic blasts you!");
874 tmp = get_archetype (LOOSE_MANA); 872 tmp = archetype::get (LOOSE_MANA);
875 tmp->level = skill->level; 873 tmp->level = skill->level;
876 874
877 /* increase the area of destruction a little for more powerful spells */ 875 /* increase the area of destruction a little for more powerful spells */
878 tmp->range += isqrt (power); 876 tmp->range += isqrt (power);
879 877
1504 * the victim with a specific maximum level. 1502 * the victim with a specific maximum level.
1505 */ 1503 */
1506void 1504void
1507create_exploding_ball_at (object *victim, int level) 1505create_exploding_ball_at (object *victim, int level)
1508{ 1506{
1509 object *ball = get_archetype (EXPLODING_FIREBALL); 1507 object *ball = archetype::get (EXPLODING_FIREBALL);
1510 ball->dam_modifier = random_roll (1, level, victim, PREFER_LOW) / 5 + 1; 1508 ball->dam_modifier = random_roll (1, level, victim, PREFER_LOW) / 5 + 1;
1511 ball->stats.maxhp = random_roll (1, level, victim, PREFER_LOW) / 10 + 2; 1509 ball->stats.maxhp = random_roll (1, level, victim, PREFER_LOW) / 10 + 2;
1512 ball->insert_at (victim); 1510 ball->insert_at (victim);
1513} 1511}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines