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.12 by root, Mon Sep 11 20:26:41 2006 UTC vs.
Revision 1.17 by root, Sat Sep 16 22:24:13 2006 UTC

1
2/*
3 * static char *rcsid_spell_util_c =
4 * "$Id: spell_util.C,v 1.12 2006/09/11 20:26:41 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) 2001 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2001 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 24
32#include <global.h> 25#include <global.h>
33#include <spells.h> 26#include <spells.h>
126 } 119 }
127 120
128 i = 0; 121 i = 0;
129 while (spell_mapping[i]) 122 while (spell_mapping[i])
130 { 123 {
131 if (!find_archetype (spell_mapping[i])) 124 if (!archetype::find (spell_mapping[i]))
132 { 125 {
133 LOG (llevError, "Unable to find spell mapping %s (%i)\n", spell_mapping[i], i); 126 LOG (llevError, "Unable to find spell mapping %s (%i)\n", spell_mapping[i], i);
134 } 127 }
135 i++; 128 i++;
136 } 129 }
160/* pretty basic function - basically just takes 153/* pretty basic function - basically just takes
161 * an object, sets the x,y, and calls insert_ob_in_map 154 * an object, sets the x,y, and calls insert_ob_in_map
162 */ 155 */
163 156
164void 157void
165spell_effect (object *spob, int x, int y, mapstruct *map, object *originator) 158spell_effect (object *spob, int x, int y, maptile *map, object *originator)
166{ 159{
167 160
168 if (spob->other_arch != NULL) 161 if (spob->other_arch != NULL)
169 { 162 {
170 object *effect = arch_to_object (spob->other_arch); 163 object *effect = arch_to_object (spob->other_arch);
451 * reflect_spell fails.) 444 * reflect_spell fails.)
452 * Caller should be sure it passes us valid map coordinates 445 * Caller should be sure it passes us valid map coordinates
453 * eg, updated for tiled maps. 446 * eg, updated for tiled maps.
454 */ 447 */
455int 448int
456reflwall (mapstruct *m, int x, int y, object *sp_op) 449reflwall (maptile *m, int x, int y, object *sp_op)
457{ 450{
458 object *op; 451 object *op;
459 452
460 if (OUT_OF_REAL_MAP (m, x, y)) 453 if (OUT_OF_REAL_MAP (m, x, y))
461 return 0; 454 return 0;
475 * in. 468 * in.
476 */ 469 */
477int 470int
478cast_create_obj (object *op, object *caster, object *new_op, int dir) 471cast_create_obj (object *op, object *caster, object *new_op, int dir)
479{ 472{
480 mapstruct *m; 473 maptile *m;
481 sint16 sx, sy; 474 sint16 sx, sy;
482 475
483 if (dir && 476 if (dir &&
484 ((get_map_flags (op->map, &m, op->x + freearr_x[dir], op->y + freearr_y[dir], &sx, &sy) & P_OUT_OF_MAP) || 477 ((get_map_flags (op->map, &m, op->x + freearr_x[dir], op->y + freearr_y[dir], &sx, &sy) & P_OUT_OF_MAP) ||
485 OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy)))) 478 OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, sx, sy))))
505 * does not have AT_MAGIC, then counterwalls do not effect the spell. 498 * does not have AT_MAGIC, then counterwalls do not effect the spell.
506 * 499 *
507 */ 500 */
508 501
509int 502int
510ok_to_put_more (mapstruct *m, sint16 x, sint16 y, object *op, int immune_stop) 503ok_to_put_more (maptile *m, sint16 x, sint16 y, object *op, int immune_stop)
511{ 504{
512 object *tmp; 505 object *tmp;
513 int mflags; 506 int mflags;
514 mapstruct *mp; 507 maptile *mp;
515 508
516 mp = m; 509 mp = m;
517 mflags = get_map_flags (m, &mp, x, y, &x, &y); 510 mflags = get_map_flags (m, &mp, x, y, &x, &y);
518 511
519 if (mflags & P_OUT_OF_MAP) 512 if (mflags & P_OUT_OF_MAP)
585int 578int
586fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, object *spell) 579fire_arch_from_position (object *op, object *caster, sint16 x, sint16 y, int dir, object *spell)
587{ 580{
588 object *tmp; 581 object *tmp;
589 int mflags; 582 int mflags;
590 mapstruct *m; 583 maptile *m;
591 584
592 if (spell->other_arch == NULL) 585 if (spell->other_arch == NULL)
593 return 0; 586 return 0;
594 587
595 m = op->map; 588 m = op->map;
685 678
686object * 679object *
687find_target_for_friendly_spell (object *op, int dir) 680find_target_for_friendly_spell (object *op, int dir)
688{ 681{
689 object *tmp; 682 object *tmp;
690 mapstruct *m; 683 maptile *m;
691 sint16 x, y; 684 sint16 x, y;
692 int mflags; 685 int mflags;
693 686
694 /* I don't really get this block - if op isn't a player or rune, 687 /* I don't really get this block - if op isn't a player or rune,
695 * we then make the owner of this object the target. 688 * we then make the owner of this object the target.
745 * any, otherwise -1. 738 * any, otherwise -1.
746 * note that exclude can be NULL, in which case all bets are off. 739 * note that exclude can be NULL, in which case all bets are off.
747 */ 740 */
748 741
749int 742int
750spell_find_dir (mapstruct *m, int x, int y, object *exclude) 743spell_find_dir (maptile *m, int x, int y, object *exclude)
751{ 744{
752 int i, max = SIZEOFFREE; 745 int i, max = SIZEOFFREE;
753 sint16 nx, ny; 746 sint16 nx, ny;
754 int owner_type = 0, mflags; 747 int owner_type = 0, mflags;
755 object *tmp; 748 object *tmp;
756 mapstruct *mp; 749 maptile *mp;
757 750
758 if (exclude && exclude->head) 751 if (exclude && exclude->head)
759 exclude = exclude->head; 752 exclude = exclude->head;
760 if (exclude && exclude->type) 753 if (exclude && exclude->type)
761 owner_type = exclude->type; 754 owner_type = exclude->type;
796 archetype *at; 789 archetype *at;
797 int dir; 790 int dir;
798 791
799 /* Handle cases where we are passed a bogus mosntername */ 792 /* Handle cases where we are passed a bogus mosntername */
800 793
801 if ((at = find_archetype (monstername)) == NULL) 794 if ((at = archetype::find (monstername)) == NULL)
802 return; 795 return;
803 796
804 /* find a free square nearby 797 /* find a free square nearby
805 * first we check the closest square for free squares 798 * first we check the closest square for free squares
806 */ 799 */
1125 */ 1118 */
1126 1119
1127int 1120int
1128cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg) 1121cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg)
1129{ 1122{
1130
1131 const char *godname; 1123 const char *godname;
1132 int success = 0, mflags, cast_level = 0, old_shoottype; 1124 int success = 0, mflags, cast_level = 0, old_shoottype;
1133 object *skill = NULL; 1125 object *skill = NULL;
1134 1126
1135 old_shoottype = op->contr ? op->contr->shoottype : 0; 1127 old_shoottype = op->contr ? op->contr->shoottype : 0;
1137 if (!spell_ob) 1129 if (!spell_ob)
1138 { 1130 {
1139 LOG (llevError, "cast_spell: null spell object passed\n"); 1131 LOG (llevError, "cast_spell: null spell object passed\n");
1140 return 0; 1132 return 0;
1141 } 1133 }
1134
1142 if (!strcmp ((godname = determine_god (op)), "none")) 1135 if (!strcmp ((godname = determine_god (op)), "none"))
1143 godname = "A random spirit"; 1136 godname = "A random spirit";
1144 1137
1145 /* the caller should set caster to op if appropriate */ 1138 /* the caller should set caster to op if appropriate */
1146 if (!caster) 1139 if (!caster)
1695 break; 1688 break;
1696 1689
1697 case SP_MAGIC_MISSILE: 1690 case SP_MAGIC_MISSILE:
1698 if (QUERY_FLAG (victim, FLAG_ALIVE)) 1691 if (QUERY_FLAG (victim, FLAG_ALIVE))
1699 { 1692 {
1700 tag_t spell_tag = spell->count;
1701
1702 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); 1693 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1);
1703 if (!was_destroyed (spell, spell_tag)) 1694
1695 if (!spell->destroyed ())
1704 { 1696 {
1705 remove_ob (spell); 1697 remove_ob (spell);
1706 free_object (spell); 1698 free_object (spell);
1707 } 1699 }
1708 } 1700 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines