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.116 by root, Sun Apr 11 00:34:06 2010 UTC vs.
Revision 1.122 by root, Sat Dec 31 06:18:02 2011 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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 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
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)
404 if (OB_TYPE_MOVE_BLOCK (op, ms.move_block)) 404 if (OB_TYPE_MOVE_BLOCK (op, ms.move_block))
405 return 0; 405 return 0;
406 406
407 int max_effects = 5; // max. number of similar spells per mapspace 407 int max_effects = 5; // max. number of similar spells per mapspace
408 408
409 for (object *tmp = ms.bot; tmp; tmp = tmp->above) 409 for (object *tmp = ms.top; tmp; tmp = tmp->below)
410 { 410 {
411 /* If there is a counterspell on the space, and this 411 /* If there is a counterspell on the space, and this
412 * object is using magic, don't progress. I believe we could 412 * object is using magic, don't progress. I believe we could
413 * leave this out and let in progress, and other areas of the code 413 * leave this out and let in progress, and other areas of the code
414 * will then remove it, but that would seem to to use more 414 * will then remove it, but that would seem to to use more
780 * at casting a prayer. 780 * at casting a prayer.
781 * op is the player. 781 * op is the player.
782 * failure is basically how much grace they had. 782 * failure is basically how much grace they had.
783 * power is how much grace the spell would normally take to cast. 783 * power is how much grace the spell would normally take to cast.
784 */ 784 */
785
786#define HINT_GRACE " H<Make sure you always have enough grace points for your prayers.>"
787
785static void 788static void
786prayer_failure (object *op, int failure, int power) 789prayer_failure (object *op, int failure, int power)
787{ 790{
788 const char *godname; 791 const char *godname;
789 object *tmp; 792 object *tmp;
791 if (!strcmp ((godname = determine_god (op)), "none")) 794 if (!strcmp ((godname = determine_god (op)), "none"))
792 godname = "Your spirit"; 795 godname = "Your spirit";
793 796
794 if (failure <= -20 && failure > -40) /* wonder */ 797 if (failure <= -20 && failure > -40) /* wonder */
795 { 798 {
796 new_draw_info_format (NDI_UNIQUE, 0, op, "%s gives a sign to renew your faith.", godname); 799 op->failmsgf ("%s gives a sign to renew your faith." HINT_GRACE, godname);
797 tmp = get_archetype (SPELL_WONDER); 800 tmp = archetype::get (SPELL_WONDER);
798 cast_cone (op, op, 0, tmp); 801 cast_cone (op, op, 0, tmp);
799 tmp->destroy (); 802 tmp->destroy ();
800 } 803 }
801 804
802 else if (failure <= -40 && failure > -60) /* confusion */ 805 else if (failure <= -40 && failure > -60) /* confusion */
803 { 806 {
804 new_draw_info (NDI_UNIQUE, 0, op, "Your diety touches your mind!"); 807 op->failmsg ("Your diety touches your mind!" HINT_GRACE);
805 confuse_player (op, op, 99); 808 confuse_player (op, op, 99);
806 } 809 }
807 else if (failure <= -60 && failure > -150) /* paralysis */ 810 else if (failure <= -60 && failure > -150) /* paralysis */
808 { 811 {
809 new_draw_info_format (NDI_UNIQUE, 0, op, "%s requires you to pray NOW.", godname); 812 op->failmsgf ("%s requires you to pray NOW. "
810 new_draw_info (NDI_UNIQUE, 0, op, "You comply, ignoring all else."); 813 "You comply, ignoring all else." HINT_GRACE,
814 godname);
811 paralyze_player (op, op, 99); 815 paralyze_player (op, op, 99);
812 } 816 }
813 else if (failure <= -150) /* blast the immediate area */ 817 else if (failure <= -150) /* blast the immediate area */
814 { 818 {
815 tmp = get_archetype (GOD_POWER); 819 tmp = archetype::get (GOD_POWER);
816 new_draw_info_format (NDI_UNIQUE, 0, op, "%s smites you!", godname); 820 op->failmsgf ("%s smites you!" HINT_GRACE, godname);
817 cast_magic_storm (op, tmp, power); 821 cast_magic_storm (op, tmp, power);
818 } 822 }
819} 823}
820 824
821/* 825/*
835 if (settings.spell_failure_effects == FALSE) 839 if (settings.spell_failure_effects == FALSE)
836 return; 840 return;
837 841
838 if (failure <= -20 && failure > -40) /* wonder */ 842 if (failure <= -20 && failure > -40) /* wonder */
839 { 843 {
840 new_draw_info (NDI_UNIQUE, 0, op, "Your spell causes an unexpected effect."); 844 op->failmsg ("Your spell causes an unexpected effect.");
841 tmp = get_archetype (SPELL_WONDER); 845 tmp = archetype::get (SPELL_WONDER);
842 cast_cone (op, op, 0, tmp); 846 cast_cone (op, op, 0, tmp);
843 tmp->destroy (); 847 tmp->destroy ();
844 } 848 }
845 849
846 else if (failure <= -40 && failure > -60) /* confusion */ 850 else if (failure <= -40 && failure > -60) /* confusion */
847 { 851 {
848 new_draw_info (NDI_UNIQUE, 0, op, "Your magic recoils on you, making you confused!"); 852 op->failmsg ("Your magic recoils on you, making you confused!");
849 confuse_player (op, op, 99); 853 confuse_player (op, op, 99);
850 } 854 }
851 else if (failure <= -60 && failure > -80) /* paralysis */ 855 else if (failure <= -60 && failure > -80) /* paralysis */
852 { 856 {
853 new_draw_info (NDI_UNIQUE, 0, op, "Your magic stuns you!"); 857 op->failmsg ("Your magic stuns you!");
854 paralyze_player (op, op, 99); 858 paralyze_player (op, op, 99);
855 } 859 }
856 else if (failure <= -80) /* blast the immediate area */ 860 else if (failure <= -80) /* blast the immediate area */
857 { 861 {
858 object *tmp; 862 object *tmp;
859 863
860 /* Safety check to make sure we don't get any mana storms in scorn */ 864 /* Safety check to make sure we don't get any mana storms in scorn */
861 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC) 865 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)
862 { 866 {
863 new_draw_info (NDI_UNIQUE, 0, op, "The magic warps and you are turned inside out!"); 867 op->failmsg ("The magic warps and you are turned inside out!");
864 hit_player (op, 9998, op, AT_INTERNAL, 1); 868 hit_player (op, 9998, op, AT_INTERNAL, 1);
865 869
866 } 870 }
867 else 871 else
868 { 872 {
869 new_draw_info (NDI_UNIQUE, 0, op, "You lose control of the mana! The uncontrolled magic blasts you!"); 873 op->failmsg ("You lose control of the mana! The uncontrolled magic blasts you!");
870 tmp = get_archetype (LOOSE_MANA); 874 tmp = archetype::get (LOOSE_MANA);
871 tmp->level = skill->level; 875 tmp->level = skill->level;
872 876
873 /* increase the area of destruction a little for more powerful spells */ 877 /* increase the area of destruction a little for more powerful spells */
874 tmp->range += isqrt (power); 878 tmp->range += isqrt (power);
875 879
946cast_spell (object *op, object *caster, int dir, object *spell_ob, char *spellparam) 950cast_spell (object *op, object *caster, int dir, object *spell_ob, char *spellparam)
947{ 951{
948 const char *godname; 952 const char *godname;
949 int success = 0; 953 int success = 0;
950 954
955 // make sure spells always take a while, so a) we don't flood the
956 // user with messages and b) too many failures can be harmful (smiting).
957 op->speed_left -= 4 * op->speed; // ~0.5s on failure
958
951 if (!spell_ob) 959 if (!spell_ob)
952 { 960 {
953 LOG (llevError, "cast_spell: null spell object passed\n"); 961 LOG (llevError, "cast_spell: null spell object passed\n");
954 return 0; 962 return 0;
955 } 963 }
967 /* if caster is a spell casting object, this normally shouldn't be 975 /* if caster is a spell casting object, this normally shouldn't be
968 * an issue, because they don't have any spellpaths set up. 976 * an issue, because they don't have any spellpaths set up.
969 */ 977 */
970 if (caster->path_denied & spell_ob->path_attuned && !caster->flag [FLAG_WIZCAST]) 978 if (caster->path_denied & spell_ob->path_attuned && !caster->flag [FLAG_WIZCAST])
971 { 979 {
972 new_draw_info (NDI_UNIQUE, 0, op, "That spell path is denied to you."); 980 op->failmsg ("That spell path is denied to you.");
973 return 0; 981 return 0;
974 } 982 }
975 983
976 object *skill = 0; 984 object *skill = 0;
977 985
1118 op->failmsg ("Something blocks the spell!"); 1126 op->failmsg ("Something blocks the spell!");
1119 1127
1120 return 0; 1128 return 0;
1121 } 1129 }
1122 1130
1131 // undo the flood protection from earlier
1132 op->speed_left += 4 * op->speed; // ~0.5s on failure
1133
1123 /* Take into account how long it takes to cast the spell. 1134 /* Take into account how long it takes to cast the spell.
1124 * if the player is casting it, then we use the time in 1135 * if the player is casting it, then we use the time in
1125 * the spell object. If it is a spell object, have it 1136 * the spell object. If it is a spell object, have it
1126 * take two ticks. Things that cast spells on the players 1137 * take two ticks. Things that cast spells on the players
1127 * behalf (eg, altars, and whatever else) shouldn't cost 1138 * behalf (eg, altars, and whatever else) shouldn't cost
1493 * the victim with a specific maximum level. 1504 * the victim with a specific maximum level.
1494 */ 1505 */
1495void 1506void
1496create_exploding_ball_at (object *victim, int level) 1507create_exploding_ball_at (object *victim, int level)
1497{ 1508{
1498 object *ball = get_archetype (EXPLODING_FIREBALL); 1509 object *ball = archetype::get (EXPLODING_FIREBALL);
1499 ball->dam_modifier = random_roll (1, level, victim, PREFER_LOW) / 5 + 1; 1510 ball->dam_modifier = random_roll (1, level, victim, PREFER_LOW) / 5 + 1;
1500 ball->stats.maxhp = random_roll (1, level, victim, PREFER_LOW) / 10 + 2; 1511 ball->stats.maxhp = random_roll (1, level, victim, PREFER_LOW) / 10 + 2;
1501 ball->insert_at (victim); 1512 ball->insert_at (victim);
1502} 1513}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines