--- deliantra/server/server/spell_attack.C 2007/05/28 21:28:36 1.37 +++ deliantra/server/server/spell_attack.C 2008/09/29 10:31:32 1.66 @@ -1,25 +1,24 @@ /* - * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. + * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team + * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2002-2003,2007 Mark Wedel & Crossfire Development Team * Copyright (©) 1992,2007 Frank Tore Johansen * - * Crossfire TRT is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. + * Deliantra is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . * - * The authors can be reached via e-mail to + * The authors can be reached via e-mail to */ /* This file contains all the spell attack code. Grouping this code @@ -39,11 +38,9 @@ * but moved here so it could be applied to bolts too * op is the spell object. */ - void check_spell_knockback (object *op) { - object *tmp, *tmp2; /* object on the map */ int weight_move; int frictionmod = 2; /*poor man's physics - multipy targets weight by this amount */ @@ -58,7 +55,7 @@ /*LOG (llevDebug, "DEBUG: arch weighs %d and masses %d (%s,level %d)\n", op->weight,weight_move,op->name,op->level); */ } - for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) + for (object *tmp = op->ms ().bot; tmp; tmp = tmp->above) { int num_sections = 1; @@ -75,7 +72,7 @@ continue; /* count the object's sections */ - for (tmp2 = tmp; tmp2 != NULL; tmp2 = tmp2->more) + for (object *tmp2 = tmp; tmp2; tmp2 = tmp2->more) num_sections++; /* I'm not sure if it makes sense to divide by num_sections - bigger @@ -109,10 +106,9 @@ * ***************************************************************************/ -/* Causes op to fork. op is the original bolt, tmp +/* Causes op to fork. op is the original bolt, tmp * is the first piece of the fork. */ - void forklightning (object *op, object *tmp) { @@ -154,6 +150,7 @@ new_bolt->stats.dam++; tmp->stats.dam /= 2; /* reduce father bolt damage */ tmp->stats.dam++; + if ((new_bolt = m->insert (new_bolt, sx, sy, op))) update_turn_face (new_bolt); } @@ -161,7 +158,6 @@ /* move_bolt: moves bolt 'op'. Basically, it just advances a space, * and checks for various things that may stop it. */ - void move_bolt (object *op) { @@ -171,7 +167,7 @@ if (--op->duration < 0) { - op->destroy (); + op->drop_and_destroy (); return; } @@ -254,10 +250,8 @@ /* New forking code. Possibly create forks of this object * going off in other directions. */ - if (rndm (0, 99) < tmp->stats.Dex) - { /* stats.Dex % of forking */ - forklightning (op, tmp); - } + if (tmp->stats.Dex && rndm (0, 99) < tmp->stats.Dex) + forklightning (op, tmp); /* stats.Dex % of forking */ /* In this way, the object left behind sticks on the space, but * doesn't create any bolts that continue to move onward. @@ -291,8 +285,10 @@ /* peterm: level dependency for bolts */ tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob); tmp->attacktype = spob->attacktype; + if (spob->slaying) tmp->slaying = spob->slaying; + tmp->range = spob->range + SP_level_range_adjust (caster, spob); tmp->duration = spob->duration + SP_level_duration_adjust (caster, spob); tmp->stats.Dex = spob->stats.Dex; @@ -313,7 +309,7 @@ mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); if (mflags & P_OUT_OF_MAP) { - tmp->destroy (); + tmp->drop_and_destroy (); return 0; } @@ -323,7 +319,7 @@ { if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) { - tmp->destroy (); + tmp->drop_and_destroy (); return 0; } @@ -339,8 +335,6 @@ return 1; } - - /*************************************************************************** * * BULLET/BALL CODE @@ -348,7 +342,7 @@ ***************************************************************************/ /* expands an explosion. op is a piece of the - * explosion - this expans it in the different directions. + * explosion - this expands it in the different directions. * At least that is what I think this does. */ void @@ -359,7 +353,7 @@ if (--op->duration < 0) { - op->destroy (); + op->destroy (true); return; } @@ -392,7 +386,6 @@ } } - /* Causes an object to explode, eg, a firebullet, * poison cloud ball, etc. op is the object to * explode. @@ -402,20 +395,21 @@ { object *tmp, *owner; - if (op->other_arch == NULL) + if (!op->other_arch) { LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); - op->destroy (); + op->destroy (true); return; } if (op->env) { - object *env = object_get_env_recursive (op); - if (env->map == NULL || out_of_map (env->map, env->x, env->y)) + object *env = op->outer_env (); + + if (!env->map || out_of_map (env->map, env->x, env->y)) { LOG (llevError, "BUG: explode_bullet(): env out of map\n"); - op->destroy (); + op->destroy (true); return; } @@ -424,7 +418,7 @@ else if (out_of_map (op->map, op->x, op->y)) { LOG (llevError, "BUG: explode_bullet(): op out of map\n"); - op->destroy (); + op->destroy (true); return; } @@ -433,13 +427,14 @@ // bad at the moment that might happen from this. if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) { - op->destroy (); + op->destroy (true); return; } if (op->attacktype) { hit_map (op, 0, op->attacktype, 1); + if (op->destroyed ()) return; } @@ -452,9 +447,12 @@ owner = op->owner; - if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) + if ((tmp->attacktype & AT_HOLYWORD + || tmp->attacktype & AT_GODPOWER) + && owner + && !tailor_god_spell (tmp, owner)) { - op->destroy (); + op->destroy (true); return; } @@ -489,8 +487,10 @@ op->move_on = 0; tmp->insert_at (op, op); + tmp->play_sound (tmp->sound); + /* remove the firebullet */ - op->destroy (); + op->destroy (true); } /* checks to see what op should do, given the space it is on @@ -525,11 +525,13 @@ if (QUERY_FLAG (tmp, FLAG_ALIVE)) { dam = hit_player (tmp, op->stats.dam, op, op->attacktype, 1); + + // TODO: can't understand the following if's if (op->destroyed () || !tmp->destroyed () || (op->stats.dam -= dam) < 0) { if (!QUERY_FLAG (op, FLAG_REMOVED)) { - op->destroy (); + op->destroy (true); return; } } @@ -568,7 +570,7 @@ if (op->other_arch) explode_bullet (op); else - op->destroy (); + op->destroy (true); return; } @@ -580,7 +582,7 @@ if (mflags & P_OUT_OF_MAP) { - op->destroy (); + op->destroy (true); return; } @@ -589,7 +591,7 @@ if (op->other_arch) explode_bullet (op); else - op->destroy (); + op->destroy (true); return; } @@ -614,7 +616,6 @@ * This function sets up the appropriate owner and skill * pointers. */ - int fire_bullet (object *op, object *caster, int dir, object *spob) { @@ -624,11 +625,11 @@ if (!spob->other_arch) return 0; - tmp = arch_to_object (spob->other_arch); - if (tmp == NULL) + tmp = spob->other_arch->instance (); + if (!tmp) return 0; - /* peterm: level dependency for bolts */ + /* peterm: level dependency for bolts */ tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob); tmp->attacktype = spob->attacktype; if (spob->slaying) @@ -648,15 +649,15 @@ tmp->set_owner (op); set_spell_skill (op, caster, spob, tmp); - tmp->x = op->x + freearr_x[dir]; - tmp->y = op->y + freearr_y[dir]; + tmp->x = op->x + freearr_x[dir]; + tmp->y = op->y + freearr_y[dir]; tmp->map = op->map; maptile *newmap; mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); if (mflags & P_OUT_OF_MAP) { - tmp->destroy (); + tmp->destroy (true); return 0; } @@ -666,7 +667,7 @@ { if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) { - tmp->destroy (); + tmp->destroy (true); return 0; } @@ -709,8 +710,6 @@ void move_cone (object *op) { - int i; - /* if no map then hit_map will crash so just ignore object */ if (!op->map) { @@ -733,7 +732,7 @@ /* If no owner left, the spell dies out. */ if (op->owner == NULL) { - op->destroy (); + op->destroy (true); return; } #endif @@ -750,9 +749,9 @@ if (op->destroyed ()) return; - if ((op->duration--) < 0) + if (op->duration-- < 0) { - op->destroy (); + op->destroy (true); return; } /* Object has hit maximum range, so don't have it move @@ -765,7 +764,7 @@ return; } - for (i = -1; i < 2; i++) + for (int i = -1; i <= 1; i++) { sint16 x = op->x + freearr_x[absdir (op->stats.sp + i)], y = op->y + freearr_y[absdir (op->stats.sp + i)]; @@ -822,7 +821,7 @@ * to create is, so we can know if the space we are about to * insert it into is blocked. */ - movetype = spell->other_arch->clone.move_type; + movetype = spell->other_arch->move_type; for (i = range_min; i <= range_max; i++) { @@ -867,7 +866,7 @@ tmp = arch_to_object (spell->other_arch); tmp->set_owner (op); set_spell_skill (op, caster, spell, tmp); - tmp->level = caster_level (caster, spell); + tmp->level = casting_level (caster, spell); tmp->attacktype = spell->attacktype; /* holy word stuff */ @@ -911,10 +910,10 @@ } if (!(tmp->move_type & MOVE_FLY_LOW)) - LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", &spell->other_arch->name); + LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", &spell->other_arch->archname); if (!tmp->move_on && tmp->stats.dam) - LOG (llevDebug, "cast_cone(): arch %s doesn't have move_on set\n", &spell->other_arch->name); + LOG (llevDebug, "cast_cone(): arch %s doesn't have move_on set\n", &spell->other_arch->archname); m->insert (tmp, sx, sy, op); @@ -936,29 +935,22 @@ * ****************************************************************************/ - /* This handles an exploding bomb. * op is the original bomb object. */ void animate_bomb (object *op) { - int i; - object *env, *tmp; - if (op->state != NUM_ANIMATIONS (op) - 1) return; - env = object_get_env_recursive (op); + object *env = op->outer_env (); if (op->env) { if (env->map == NULL) return; - if (env->type == PLAYER) - esrv_del_item (env->contr, op->count); - if (!(op = op->insert_at (env, op))) return; } @@ -968,7 +960,7 @@ // as bombs can be carried. if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) { - op->destroy (); + op->destroy (true); return; } @@ -978,12 +970,12 @@ */ if (archetype *at = archetype::find (SPLINT)) { - for (i = 1; i < 9; i++) + for (int i = 1; i < 9; i++) { if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) continue; - tmp = arch_to_object (at); + object *tmp = arch_to_object (at); tmp->direction = i; tmp->range = op->range; tmp->stats.dam = op->stats.dam; @@ -1007,7 +999,6 @@ int create_bomb (object *op, object *caster, int dir, object *spell) { - object *tmp; int mflags; sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; @@ -1019,6 +1010,7 @@ new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); return 0; } + tmp = arch_to_object (spell->other_arch); /* level dependencies for bomb */ @@ -1049,7 +1041,6 @@ * type is the type of spell - either SPELL_MANA or SPELL_GRACE. * this info is used for blocked magic/unholy spaces. */ - object * get_pointed_target (object *op, int dir, int range, int type) { @@ -1078,20 +1069,14 @@ return NULL; if (mflags & P_IS_ALIVE) - { - for (target = GET_MAP_OB (mp, x, y); target; target = target->above) - { - if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) - { - return target; - } - } - } + for (target = GET_MAP_OB (mp, x, y); target; target = target->above) + if (QUERY_FLAG (target, FLAG_MONSTER)) + return target; } + return NULL; } - /* cast_smite_arch() - the priest points to a creature and causes * a 'godly curse' to decend. * usual params - @@ -1100,7 +1085,6 @@ * dir = direction being cast * spell = spell object */ - int cast_smite_spell (object *op, object *caster, int dir, object *spell) { @@ -1134,7 +1118,7 @@ return 0; /* tailor the effect by priest level and worshipped God */ - effect->level = caster_level (caster, spell); + effect->level = casting_level (caster, spell); effect->attacktype = spell->attacktype; if (effect->attacktype & (AT_HOLYWORD | AT_GODPOWER)) { @@ -1168,7 +1152,7 @@ { new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); target->stats.hp = target->stats.maxhp * 2; - effect->destroy (); + effect->destroy (true); return 0; } } @@ -1188,7 +1172,6 @@ return 1; } - /**************************************************************************** * * MAGIC MISSILE code. @@ -1200,62 +1183,47 @@ void move_missile (object *op) { - int i, mflags; - object *owner; - sint16 new_x, new_y; - maptile *m; - if (op->range-- <= 0) { - op->destroy (); + op->drop_and_destroy (); return; } - owner = op->owner; -#if 0 - /* It'd make things nastier if this wasn't here - spells cast by - * monster that are then killed would continue to survive - */ - if (owner == NULL) + mapxy pos (op); + pos.move (op->direction); + + if (!pos.normalise ()) { - op->destroy (); + op->destroy (true); return; } -#endif - - new_x = op->x + DIRX (op); - new_y = op->y + DIRY (op); - mflags = get_map_flags (op->map, &m, new_x, new_y, &new_x, &new_y); + mapspace &ms = pos.ms (); - if (!(mflags & P_OUT_OF_MAP) && ((mflags & P_IS_ALIVE) || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))) + if (ms.flags () & P_IS_ALIVE || ms.blocks (op)) { hit_map (op, op->direction, AT_MAGIC, 1); /* Basically, missile only hits one thing then goes away. * we need to remove it if someone hasn't already done so. */ - if (!op->destroyed ()) - op->destroy (); - + op->destroy (true); return; } - op->remove (); - - if (!op->direction || (mflags & P_OUT_OF_MAP)) + if (!op->direction) { - op->destroy (); + op->destroy (true); return; } - i = spell_find_dir (m, new_x, new_y, op->owner); + int i = spell_find_dir (pos.m, pos.x, pos.y, op->owner); if (i > 0 && i != op->direction) { op->direction = i; SET_ANIMATION (op, op->direction); } - m->insert (op, new_x, new_y, op); + pos.insert (op, op); } /**************************************************************************** @@ -1268,17 +1236,14 @@ * make this work for non-living objects, we would have to * give them the capability to have an inventory. b.t. */ - int make_object_glow (object *op, int radius, int time) { - object *tmp; - /* some things are unaffected... */ if (op->path_denied & PATH_LIGHT) return 0; - tmp = get_archetype (FORCE_NAME); + object *tmp = get_archetype (FORCE_NAME); tmp->speed = 0.01; tmp->stats.food = time; SET_FLAG (tmp, FLAG_IS_USED_UP); @@ -1286,19 +1251,11 @@ if (tmp->glow_radius > MAX_LIGHT_RADII) tmp->glow_radius = MAX_LIGHT_RADII; - tmp->x = op->x; - tmp->y = op->y; - if (tmp->speed < MIN_ACTIVE_SPEED) - tmp->speed = MIN_ACTIVE_SPEED; /* safety */ tmp = insert_ob_in_ob (tmp, op); + if (tmp->glow_radius > op->glow_radius) op->glow_radius = tmp->glow_radius; - if (!tmp->env || op != tmp->env) - { - LOG (llevError, "make_object_glow() failed to insert glowing force in %s\n", &op->name); - return 0; - } return 1; } @@ -1333,9 +1290,9 @@ op->change_skill (find_skill_by_name (op, op->skill)); - for (i = -range; i < range; i++) + for (i = -range; i <= range; i++) { - for (j = -range; j < range; j++) + for (j = -range; j <= range; j++) { m = op->map; sx = op->x + i; @@ -1362,6 +1319,7 @@ if (spell_ob->subtype == SP_DESTRUCTION) { hit_player (tmp, dam, op, spell_ob->attacktype, 0); + if (spell_ob->other_arch) m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op); } @@ -1399,8 +1357,10 @@ return 0; } + tmp = tmp->head_ (); + /* If we've already got a force of this type, don't add a new one. */ - for (force = tmp->inv; force != NULL; force = force->below) + for (force = tmp->inv; force; force = force->below) { if (force->type == FORCE && force->subtype == FORCE_CHANGE_ABILITY) { @@ -1416,10 +1376,11 @@ } } - if (force == NULL) + if (!force) { force = get_archetype (FORCE_NAME); force->subtype = FORCE_CHANGE_ABILITY; + if (spell_ob->race) force->name = spell_ob->race; else @@ -1439,11 +1400,11 @@ new_draw_info (NDI_UNIQUE, 0, op, "You recast the spell while in effect."); } else - { - new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect."); - } + new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect."); + return 1; } + force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50; force->speed = 1.f; force->speed_left = -1.f; @@ -1496,7 +1457,7 @@ * doing it over and over again. */ god = find_god (determine_god (op)); - level = caster_level (caster, spell); + level = casting_level (caster, spell); range = spell->range + SP_level_range_adjust (caster, spell); /* On the bright side, no monster should ever have a race of GOD_... @@ -1626,7 +1587,9 @@ /* charm */ if (QUERY_FLAG (spell, FLAG_NO_ATTACK) && !QUERY_FLAG (head, FLAG_FRIENDLY)) { - /* Prevent uncontolled outbreaks of self replicating monsters. + INVOKE_OBJECT (KILL, head, ARG_OBJECT (caster)); + + /* Prevent uncontrolled outbreaks of self replicating monsters. Typical use case is charm, go somwhere, use aggravation to make hostile. This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ CLEAR_FLAG (head, FLAG_GENERATOR); @@ -1654,7 +1617,6 @@ * op is the spell effect. * note that duration is handled by process_object() in time.c */ - void move_ball_spell (object *op) { @@ -1730,8 +1692,8 @@ { if (j) op->stats.dam = dam_save / 2; - hit_map (op, j, op->attacktype, 1); + hit_map (op, j, op->attacktype, 1); } /* insert the other arch */ @@ -1755,15 +1717,13 @@ } } - -/* move_swarm_spell: peterm +/* move_swarm_spell: peterm * This is an implementation of the swarm spell. It was written for - * meteor swarm, but it could be used for any swarm. A swarm spell + * meteor swarm, but it could be used for any swarm. A swarm spell * is a special type of object that casts swarms of other types - * of spells. Which spell it casts is flexible. It fires the spells + * of spells. Which spell it casts is flexible. It fires the spells * from a set of squares surrounding the caster, in a given direction. */ - void move_swarm_spell (object *op) { @@ -1774,23 +1734,29 @@ int adjustdir; maptile *m; #endif - int basedir; - object *owner; + object *owner = op->env; - owner = op->owner; - if (op->duration == 0 || owner == NULL) + if (!owner) // MUST not happen, remove when true TODO { - op->destroy (); + LOG (llevError, "swarm spell found outside inventory: %s\n", op->debug_desc ()); + op->destroy (true); + return; + } + + if (!op->duration || !owner->is_on_map ()) + { + op->drop_and_destroy (); return; } op->duration--; - basedir = op->direction; - if (basedir == 0) + int basedir = op->direction; + if (!basedir) { /* spray in all directions! 8) */ - basedir = rndm (1, 8); + op->facing = (op->facing + op->state) & 7; + basedir = op->facing + 1; } #if 0 @@ -1861,13 +1827,10 @@ if (op->spell->subtype == SP_BULLET) fire_bullet (owner, op, basedir, op->spell); else if (op->spell->subtype == SP_MAGIC_MISSILE) - fire_arch_from_position (owner, op, op->x, op->y, basedir, op->spell); + fire_arch_from_position (owner, op, owner->x, owner->y, basedir, op->spell); } } - - - /* fire_swarm: * The following routine creates a swarm of objects. It actually * sets up a specific swarm object, which then fires off all @@ -1879,23 +1842,17 @@ * spell - the spell that is this spell. * n: the number to be fired. */ - int fire_swarm (object *op, object *caster, object *spell, int dir) { - object *tmp; - int i; - if (!spell->other_arch) return 0; - tmp = get_archetype (SWARM_SPELL); - tmp->set_owner (op); /* needed so that if swarm elements kill, caster gets xp. */ - set_spell_skill (op, caster, spell, tmp); - - tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */ - tmp->spell = arch_to_object (spell->other_arch); + object *tmp = archetype::get (SWARM_SPELL); + set_spell_skill (op, caster, spell, tmp); + tmp->level = casting_level (caster, spell); /* needed later, to get level dep. right. */ + tmp->spell = spell->other_arch->instance (); tmp->attacktype = tmp->spell->attacktype; if (tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) @@ -1903,17 +1860,20 @@ return 1; tmp->duration = SP_level_duration_adjust (caster, spell); - for (i = 0; i < spell->duration; i++) + for (int i = 0; i < spell->duration; i++) tmp->duration += die_roll (1, 3, op, PREFER_HIGH); - tmp->direction = dir; tmp->invisible = 1; + tmp->flag [FLAG_NO_DROP] = 1; // make sure it stays in inv, or else + tmp->direction = dir; + tmp->facing = rndm (1, 8); // initial firing direction + tmp->state = rndm (4) * 2 + 1; // direction increment + + op->insert (tmp); - tmp->insert_at (op, op); return 1; } - /* See the spells documentation file for why this is its own * function. */ @@ -1953,7 +1913,8 @@ /* oky doky. got a target monster. Lets make a blinding attack */ if (target->head) target = target->head; - (void) hit_player (target, dam, op, spell->attacktype, 1); + + hit_player (target, dam, op, spell->attacktype, 1); return 1; /* one success only! */ } } @@ -1984,16 +1945,12 @@ return 1; } - - - /* cast_cause_disease: this spell looks along from the * player and infects someone. * op is the player/monster, caster is the object, dir is the direction * to cast, disease_arch is the specific disease, and type is the spell number * perhaps this should actually be in disease.c? */ - int cast_cause_disease (object *op, object *caster, object *spell, int dir) { @@ -2010,6 +1967,7 @@ */ if (!dir) dir = op->facing; + if (!dir) return 0; /* won't find anything if casting on ourself, so just return */ @@ -2046,14 +2004,14 @@ disease->set_owner (op); set_spell_skill (op, caster, spell, disease); disease->stats.exp = 0; - disease->level = caster_level (caster, spell); + disease->level = casting_level (caster, spell); /* do level adjustments */ if (disease->stats.wc) disease->stats.wc += dur_mod / 2; if (disease->magic > 0) - disease->magic += dur_mod / 4; + disease->magic += dur_mod / 8; if (disease->stats.maxhp > 0) disease->stats.maxhp += dur_mod; @@ -2100,12 +2058,12 @@ { new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); - disease->destroy (); /* don't need this one anymore */ - walk->map->insert (get_archetype (ARCH_DETECT_MAGIC), x, y, op); + disease->destroy (true); /* don't need this one anymore */ + walk->map->insert (get_archetype ("detect_magic"), x, y, op); return 1; } - disease->destroy (); + disease->destroy (true); } } /* if living creature */ } /* for range of spaces */