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.96 by root, Sun Apr 5 21:16:46 2009 UTC vs.
Revision 1.101 by root, Fri Nov 6 13:03:34 2009 UTC

3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your 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 GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * 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>
22 */ 23 */
23 24
24#include <global.h> 25#include <global.h>
637 638
638/* put_a_monster: puts a monster named monstername near by 639/* put_a_monster: puts a monster named monstername near by
639 * op. This creates the treasures for the monsters, and 640 * op. This creates the treasures for the monsters, and
640 * also deals with multipart monsters properly. 641 * also deals with multipart monsters properly.
641 */ 642 */
642void 643static void
643put_a_monster (object *op, const char *monstername) 644put_a_monster (object *op, const char *monstername)
644{ 645{
645 object *tmp, *head = NULL, *prev = NULL; 646 object *tmp, *head = NULL, *prev = NULL;
646 archetype *at; 647 archetype *at;
647 int dir; 648 int dir;
783 * at casting a prayer. 784 * at casting a prayer.
784 * op is the player. 785 * op is the player.
785 * failure is basically how much grace they had. 786 * failure is basically how much grace they had.
786 * power is how much grace the spell would normally take to cast. 787 * power is how much grace the spell would normally take to cast.
787 */ 788 */
788void 789static void
789prayer_failure (object *op, int failure, int power) 790prayer_failure (object *op, int failure, int power)
790{ 791{
791 const char *godname; 792 const char *godname;
792 object *tmp; 793 object *tmp;
793 794
886 tmp->insert_at (op); 887 tmp->insert_at (op);
887 } 888 }
888 } 889 }
889} 890}
890 891
891int 892static int
892cast_party_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) 893cast_party_spell (object *op, object *caster, int dir, object *spell_ob, char *spellparam)
893{ 894{
894 int success;
895 object *spell;
896
897 if (!spell_ob->other_arch) 895 if (!spell_ob->other_arch)
898 { 896 {
899 LOG (llevError, "cast_party_spell: empty other arch\n"); 897 LOG (llevError, "cast_party_spell: empty other arch\n");
900 return 0; 898 return 0;
901 } 899 }
902 900
903 spell = arch_to_object (spell_ob->other_arch); 901 object *spell = arch_to_object (spell_ob->other_arch);
904 902
905 /* Always cast spell on caster */ 903 /* Always cast spell on caster */
906 success = cast_spell (op, caster, dir, spell, stringarg); 904 int success = cast_spell (op, caster, dir, spell, spellparam);
907 905
908 if (!op->contr || !op->contr->party) 906 if (!op->contr || !op->contr->party)
909 { 907 {
910 spell->remove (); 908 spell->remove ();
911 return success; 909 return success;
912 } 910 }
913 911
914 for_all_players (pl) 912 for_all_players (pl)
915 if ((pl->ob->contr->party == op->contr->party) && (on_same_map (pl->ob, caster))) 913 if ((pl->ob->contr->party == op->contr->party)
914 && on_same_map (pl->ob, op)
915 && pl->ob != op)
916 cast_spell (pl->ob, caster, pl->ob->facing, spell, stringarg); 916 cast_spell (pl->ob, caster, pl->ob->facing, spell, spellparam);
917 917
918 spell->remove (); 918 spell->remove ();
919 return success; 919 return success;
920} 920}
921 921
927 * same as op. 927 * same as op.
928 * dir is the direction to cast in. Note in some cases, if the spell 928 * dir is the direction to cast in. Note in some cases, if the spell
929 * is self only, dir really doesn't make a difference. 929 * is self only, dir really doesn't make a difference.
930 * spell_ob is the spell object that is being cast. From that, 930 * spell_ob is the spell object that is being cast. From that,
931 * we can determine what to do. 931 * we can determine what to do.
932 * stringarg is any options that are being used. It can be NULL. Almost 932 * spellparam is any options that are being used. It can be NULL. Almost
933 * certainly, only players will set it. It is basically used as optional 933 * certainly, only players will set it. It is basically used as optional
934 * parameters to a spell (eg, item to create, information for marking runes, 934 * parameters to a spell (eg, item to create, information for marking runes,
935 * etc. 935 * etc.
936 * returns 1 on successful cast, or 0 on error. These values should really 936 * returns 1 on successful cast, or 0 on error. These values should really
937 * be swapped, so that 0 is successful, and non zero is failure, with a code 937 * be swapped, so that 0 is successful, and non zero is failure, with a code
945 * if it is a player casting the spell (op->type == PLAYER, op == caster), 945 * if it is a player casting the spell (op->type == PLAYER, op == caster),
946 * this function will decrease the mana/grace appropriately. For other 946 * this function will decrease the mana/grace appropriately. For other
947 * objects, the caller should do what it considers appropriate. 947 * objects, the caller should do what it considers appropriate.
948 */ 948 */
949int 949int
950cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) 950cast_spell (object *op, object *caster, int dir, object *spell_ob, char *spellparam)
951{ 951{
952 const char *godname; 952 const char *godname;
953 int success = 0; 953 int success = 0;
954 object *skill = NULL; 954 object *skill = NULL;
955 955
1162 } 1162 }
1163 1163
1164 op->change_skill (skill); /* needed for proper exp credit */ 1164 op->change_skill (skill); /* needed for proper exp credit */
1165 } 1165 }
1166 1166
1167 if (INVOKE_OBJECT (CAST_SPELL, spell_ob, ARG_OBJECT (op), ARG_OBJECT (caster), ARG_INT (dir), ARG_STRING (stringarg))) 1167 if (INVOKE_OBJECT (CAST_SPELL, spell_ob, ARG_OBJECT (op), ARG_OBJECT (caster), ARG_INT (dir), ARG_STRING (spellparam)))
1168 return RESULT_INT (0); 1168 return RESULT_INT (0);
1169 1169
1170 switch (spell_ob->subtype) 1170 switch (spell_ob->subtype)
1171 { 1171 {
1172 /* The order of case statements is same as the order they show up 1172 /* The order of case statements is same as the order they show up
1173 * in spells.h. 1173 * in spells.h.
1174 */ 1174 */
1175 case SP_RAISE_DEAD: 1175 case SP_RAISE_DEAD:
1176 success = cast_raise_dead_spell (op, caster, spell_ob, dir, stringarg); 1176 success = cast_raise_dead_spell (op, caster, spell_ob, dir, spellparam);
1177 break; 1177 break;
1178 1178
1179 case SP_RUNE: 1179 case SP_RUNE:
1180 success = write_rune (op, caster, spell_ob, dir, stringarg); 1180 success = write_rune (op, caster, spell_ob, dir, spellparam);
1181 break; 1181 break;
1182 1182
1183 case SP_MAKE_MARK: 1183 case SP_MAKE_MARK:
1184 success = write_mark (op, spell_ob, stringarg); 1184 success = write_mark (op, spell_ob, spellparam);
1185 break; 1185 break;
1186 1186
1187 case SP_BOLT: 1187 case SP_BOLT:
1188 success = fire_bolt (op, caster, dir, spell_ob, skill); 1188 success = fire_bolt (op, caster, dir, spell_ob, skill);
1189 break; 1189 break;
1218 1218
1219 case SP_DIMENSION_DOOR: 1219 case SP_DIMENSION_DOOR:
1220 /* dimension door needs the actual caster, because that is what is 1220 /* dimension door needs the actual caster, because that is what is
1221 * moved. 1221 * moved.
1222 */ 1222 */
1223 success = dimension_door (op, caster, spell_ob, dir); 1223 success = dimension_door (op, caster, spell_ob, dir, spellparam);
1224 break; 1224 break;
1225 1225
1226 case SP_MAGIC_MAPPING: 1226 case SP_MAGIC_MAPPING:
1227 if (op->type == PLAYER) 1227 if (op->type == PLAYER)
1228 { 1228 {
1261 case SP_HEALING: 1261 case SP_HEALING:
1262 success = cast_heal (op, caster, spell_ob, dir); 1262 success = cast_heal (op, caster, spell_ob, dir);
1263 break; 1263 break;
1264 1264
1265 case SP_CREATE_FOOD: 1265 case SP_CREATE_FOOD:
1266 success = cast_create_food (op, caster, spell_ob, dir, stringarg); 1266 success = cast_create_food (op, caster, spell_ob, dir, spellparam);
1267 break; 1267 break;
1268 1268
1269 case SP_EARTH_TO_DUST: 1269 case SP_EARTH_TO_DUST:
1270 success = cast_earth_to_dust (op, caster, spell_ob); 1270 success = cast_earth_to_dust (op, caster, spell_ob);
1271 break; 1271 break;
1281 case SP_CURSE: 1281 case SP_CURSE:
1282 success = cast_curse (op, caster, spell_ob, dir); 1282 success = cast_curse (op, caster, spell_ob, dir);
1283 break; 1283 break;
1284 1284
1285 case SP_SUMMON_MONSTER: 1285 case SP_SUMMON_MONSTER:
1286 success = summon_object (op, caster, spell_ob, dir, stringarg); 1286 success = summon_object (op, caster, spell_ob, dir, spellparam);
1287 break; 1287 break;
1288 1288
1289 case SP_CHARGING: 1289 case SP_CHARGING:
1290 success = recharge (op, caster, spell_ob); 1290 success = recharge (op, caster, spell_ob);
1291 break; 1291 break;
1345 /* in rune.c */ 1345 /* in rune.c */
1346 success = dispel_rune (op, caster, spell_ob, skill, dir); 1346 success = dispel_rune (op, caster, spell_ob, skill, dir);
1347 break; 1347 break;
1348 1348
1349 case SP_CREATE_MISSILE: 1349 case SP_CREATE_MISSILE:
1350 success = cast_create_missile (op, caster, spell_ob, dir, stringarg); 1350 success = cast_create_missile (op, caster, spell_ob, dir, spellparam);
1351 break; 1351 break;
1352 1352
1353 case SP_CONSECRATE: 1353 case SP_CONSECRATE:
1354 success = cast_consecrate (op, caster, spell_ob); 1354 success = cast_consecrate (op, caster, spell_ob);
1355 break; 1355 break;
1377 case SP_AURA: 1377 case SP_AURA:
1378 success = create_aura (op, caster, spell_ob); 1378 success = create_aura (op, caster, spell_ob);
1379 break; 1379 break;
1380 1380
1381 case SP_PARTY_SPELL: 1381 case SP_PARTY_SPELL:
1382 success = cast_party_spell (op, caster, dir, spell_ob, stringarg); 1382 success = cast_party_spell (op, caster, dir, spell_ob, spellparam);
1383 break; 1383 break;
1384 1384
1385 default: 1385 default:
1386 LOG (llevError, "cast_spell: Unhandled spell subtype %d\n", spell_ob->subtype); 1386 LOG (llevError, "cast_spell: Unhandled spell subtype %d\n", spell_ob->subtype);
1387 } 1387 }
1449} 1449}
1450 1450
1451/* this checks to see if something special should happen if 1451/* this checks to see if something special should happen if
1452 * something runs into the object. 1452 * something runs into the object.
1453 */ 1453 */
1454void 1454static void
1455check_spell_effect (object *op) 1455check_spell_effect (object *op)
1456{ 1456{
1457 switch (op->subtype) 1457 switch (op->subtype)
1458 { 1458 {
1459 case SP_BOLT: 1459 case SP_BOLT:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines