--- deliantra/server/server/spell_attack.C 2008/04/30 10:31:04 1.54 +++ deliantra/server/server/spell_attack.C 2008/05/17 00:17:02 1.55 @@ -622,11 +622,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) @@ -646,8 +646,8 @@ 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; @@ -1731,15 +1731,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) { @@ -1750,11 +1748,9 @@ int adjustdir; maptile *m; #endif - int basedir; - object *owner; + object *owner = op->env; - owner = op->owner; - if (op->duration == 0 || owner == NULL) + if (!op->duration || !owner->is_on_map ()) { op->destroy (); return; @@ -1762,12 +1758,10 @@ op->duration--; - basedir = op->direction; - if (basedir == 0) - { - /* spray in all directions! 8) */ - basedir = rndm (1, 8); - } + int basedir = op->direction; + if (!basedir) + /* spray in all directions! 8) */ + basedir = rndm (1, 8); #if 0 // this is bogus: it causes wrong places to be checked below @@ -1841,9 +1835,6 @@ } } - - - /* fire_swarm: * The following routine creates a swarm of objects. It actually * sets up a specific swarm object, which then fires off all @@ -1855,23 +1846,16 @@ * 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. */ + object *tmp = archetype::get (SWARM_SPELL); 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); - + tmp->level = caster_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) @@ -1879,17 +1863,17 @@ 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->insert_at (op, op); + op->insert (tmp); + return 1; } - /* See the spells documentation file for why this is its own * function. */