--- deliantra/server/server/spell_attack.C 2006/12/12 20:53:03 1.16 +++ deliantra/server/server/spell_attack.C 2006/12/22 16:34:00 1.22 @@ -59,7 +59,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 (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) { int num_sections = 1; @@ -142,8 +142,7 @@ return; /* OK, we made a fork */ - new_bolt = get_object (); - copy_object (tmp, new_bolt); + new_bolt = tmp->clone (); /* reduce chances of subsequent forking */ new_bolt->stats.Dex -= 10; @@ -176,8 +175,7 @@ if (--(op->duration) < 0) { - op->remove (); - op->destroy (0); + op->destroy (); return; } @@ -252,8 +250,8 @@ } else { /* Create a copy of this object and put it ahead */ - tmp = get_object (); - copy_object (op, tmp); + tmp = op->clone (); + tmp->speed_left = -0.1; tmp->x += DIRX (tmp), tmp->y += DIRY (tmp); tmp = insert_ob_in_map (tmp, op->map, op, 0); @@ -312,7 +310,7 @@ if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) SET_ANIMATION (tmp, dir); - set_owner (tmp, op); + tmp->set_owner (op); set_spell_skill (op, caster, spob, tmp); tmp->x = op->x + DIRX (tmp); @@ -322,23 +320,27 @@ mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); if (mflags & P_OUT_OF_MAP) { - tmp->destroy (0); + tmp->destroy (); return 0; } + if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) { if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) { - tmp->destroy (0); + tmp->destroy (); return 0; } + tmp->x = op->x; tmp->y = op->y; tmp->direction = absdir (tmp->direction + 4); tmp->map = op->map; } + if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) move_bolt (tmp); + return 1; } @@ -363,10 +365,10 @@ if (--(op->duration) < 0) { - op->remove (); - op->destroy (0); + op->destroy (); return; } + hit_map (op, 0, op->attacktype, 0); if (op->range > 0) @@ -382,8 +384,7 @@ */ if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) { - tmp = get_object (); - copy_object (op, tmp); + tmp = op->clone (); tmp->state = 0; tmp->speed_left = -0.21; tmp->range--; @@ -409,8 +410,7 @@ if (op->other_arch == NULL) { LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); - op->remove (); - op->destroy (0); + op->destroy (); return; } @@ -422,10 +422,10 @@ if (env->map == NULL || out_of_map (env->map, env->x, env->y)) { LOG (llevError, "BUG: explode_bullet(): env out of map\n"); - op->remove (); - op->destroy (0); + op->destroy (); return; } + op->remove (); op->x = env->x; op->y = env->y; @@ -434,8 +434,7 @@ else if (out_of_map (op->map, op->x, op->y)) { LOG (llevError, "BUG: explode_bullet(): op out of map\n"); - op->remove (); - op->destroy (0); + op->destroy (); return; } @@ -444,8 +443,7 @@ // 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->remove (); - op->destroy (0); + op->destroy (); return; } @@ -459,15 +457,14 @@ /* other_arch contains what this explodes into */ tmp = arch_to_object (op->other_arch); - copy_owner (tmp, op); + tmp->set_owner (op); tmp->skill = op->skill; - owner = get_owner (op); + owner = op->owner; if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) { - op->remove (); - op->destroy (0); + op->destroy (); return; } @@ -507,8 +504,7 @@ /* remove the firebullet */ if (!op->destroyed ()) { - op->remove (); - op->destroy (0); + op->destroy (); } } @@ -542,7 +538,7 @@ if (!(mflags & P_IS_ALIVE)) return; - for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) + for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) { if (QUERY_FLAG (tmp, FLAG_ALIVE)) { @@ -551,8 +547,7 @@ { if (!QUERY_FLAG (op, FLAG_REMOVED)) { - op->remove (); - op->destroy (0); + op->destroy (); return; } } @@ -591,14 +586,10 @@ if (--op->range <= 0) { if (op->other_arch) - { - explode_bullet (op); - } + explode_bullet (op); else - { - op->remove (); - op->destroy (0); - } + op->destroy (); + return; } @@ -609,22 +600,17 @@ if (mflags & P_OUT_OF_MAP) { - op->remove (); - op->destroy (0); + op->destroy (); return; } if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) { if (op->other_arch) - { - explode_bullet (op); - } + explode_bullet (op); else - { - op->remove (); - op->destroy (0); - } + op->destroy (); + return; } @@ -687,7 +673,7 @@ if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) SET_ANIMATION (tmp, dir); - set_owner (tmp, op); + tmp->set_owner (op); set_spell_skill (op, caster, spob, tmp); tmp->x = op->x + freearr_x[dir]; @@ -697,25 +683,27 @@ mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); if (mflags & P_OUT_OF_MAP) { - tmp->destroy (0); + tmp->destroy (); return 0; } + if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) { if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) { - tmp->destroy (0); + tmp->destroy (); return 0; } + tmp->x = op->x; tmp->y = op->y; tmp->direction = absdir (tmp->direction + 4); tmp->map = op->map; } + if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) - { - check_bullet (tmp); - } + check_bullet (tmp); + return 1; } @@ -738,7 +726,7 @@ new_ob->x = op->x; new_ob->y = op->y; new_ob->level = op->level; - set_owner (new_ob, op->owner); + new_ob->set_owner (op->owner); /* preserve skill ownership */ if (op->skill && op->skill != new_ob->skill) @@ -777,10 +765,9 @@ * when their cone dies when they die. */ /* If no owner left, the spell dies out. */ - if (get_owner (op) == NULL) + if (op->owner == NULL) { - op->remove (); - op->destroy (0); + op->destroy (); return; } #endif @@ -799,8 +786,7 @@ if ((op->duration--) < 0) { - op->remove (); - op->destroy (0); + op->destroy (); return; } /* Object has hit maximum range, so don't have it move @@ -819,9 +805,8 @@ if (ok_to_put_more (op->map, x, y, op, op->attacktype)) { - object *tmp = get_object (); + object *tmp = op->clone (); - copy_object (op, tmp); tmp->x = x; tmp->y = y; @@ -915,7 +900,7 @@ success = 1; tmp = arch_to_object (spell->other_arch); - set_owner (tmp, op); + tmp->set_owner (op); set_spell_skill (op, caster, spell, tmp); tmp->level = caster_level (caster, spell); tmp->x = sx; @@ -1026,8 +1011,7 @@ // as bombs can be carried. if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) { - op->remove (); - op->destroy (0); + op->destroy (); return; } @@ -1048,7 +1032,7 @@ tmp->stats.dam = op->stats.dam; tmp->duration = op->duration; tmp->attacktype = op->attacktype; - copy_owner (tmp, op); + tmp->set_owner (op); if (op->skill && op->skill != tmp->skill) { tmp->skill = op->skill; @@ -1088,7 +1072,7 @@ tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); tmp->attacktype = spell->attacktype; - set_owner (tmp, op); + tmp->set_owner (op); set_spell_skill (op, caster, spell, tmp); tmp->x = dx; tmp->y = dy; @@ -1141,7 +1125,7 @@ if (mflags & P_IS_ALIVE) { - for (target = get_map_ob (mp, x, y); target; target = target->above) + for (target = GET_MAP_OB (mp, x, y); target; target = target->above) { if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) { @@ -1218,8 +1202,7 @@ effect->level = spell->stats.dam + SP_level_dam_adjust (caster, spell); /* casting death spells at undead isn't a good thing */ - if QUERY_FLAG - (target, FLAG_UNDEAD) + if (QUERY_FLAG (target, FLAG_UNDEAD)) { if (random_roll (0, 2, op, PREFER_LOW)) { @@ -1231,7 +1214,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 (0); + effect->destroy (); return 0; } } @@ -1242,7 +1225,7 @@ effect->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); } - set_owner (effect, op); + effect->set_owner (op); set_spell_skill (op, caster, spell, effect); /* ok, tell it where to be, and insert! */ @@ -1272,20 +1255,18 @@ if (op->range-- <= 0) { - op->remove (); - op->destroy (0); + op->destroy (); return; } - owner = get_owner (op); + 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) { - op->remove (); - op->destroy (0); + op->destroy (); return; } #endif @@ -1302,7 +1283,7 @@ * we need to remove it if someone hasn't already done so. */ if (!op->destroyed ()) - op->destroy (0); + op->destroy (); return; } @@ -1311,14 +1292,14 @@ if (!op->direction || (mflags & P_OUT_OF_MAP)) { - op->destroy (0); + op->destroy (); return; } op->x = new_x; op->y = new_y; op->map = m; - i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); + i = spell_find_dir (op->map, op->x, op->y, op->owner); if (i > 0 && i != op->direction) { op->direction = i; @@ -1418,7 +1399,7 @@ continue; if (mflags & P_IS_ALIVE) { - for (tmp = get_map_ob (m, sx, sy); tmp; tmp = tmp->above) + for (tmp = GET_MAP_OB (m, sx, sy); tmp; tmp = tmp->above) { if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) break; @@ -1551,7 +1532,7 @@ change_abil (tmp, force); /* Mostly to display any messages */ insert_ob_in_ob (force, tmp); - fix_player (tmp); + tmp->update_stats (); return 1; } @@ -1612,7 +1593,7 @@ if (!(mflags & P_IS_ALIVE)) continue; - for (tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) + for (tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above) if (QUERY_FLAG (tmp, FLAG_MONSTER)) break; @@ -1710,7 +1691,7 @@ 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); - set_owner (head, op); + head->set_owner (op); set_spell_skill (op, caster, spell, head); add_friendly_object (head); head->attack_movement = PETMOVE; @@ -1748,7 +1729,7 @@ object *owner; maptile *m; - owner = get_owner (op); + owner = op->owner; /* the following logic makes sure that the ball doesn't move into a wall, * and makes sure that it will move along a wall to try and get at it's @@ -1837,7 +1818,7 @@ /* restore to the center location and damage */ op->stats.dam = dam_save; - i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); + i = spell_find_dir (op->map, op->x, op->y, op->owner); if (i >= 0) { /* we have a preferred direction! */ @@ -1873,13 +1854,13 @@ int basedir; object *owner; - owner = get_owner (op); + owner = op->owner; if (op->duration == 0 || owner == NULL) { - op->remove (); - op->destroy (0); + op->destroy (); return; } + op->duration--; basedir = op->direction; @@ -1988,7 +1969,7 @@ tmp = get_archetype (SWARM_SPELL); tmp->x = op->x; tmp->y = op->y; - set_owner (tmp, op); /* needed so that if swarm elements kill, caster gets xp. */ + 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. */ @@ -2045,7 +2026,7 @@ if (mflags & P_IS_ALIVE && spell->attacktype) { - for (target = get_map_ob (m, x, y); target; target = target->above) + for (target = GET_MAP_OB (m, x, y); target; target = target->above) if (QUERY_FLAG (target, FLAG_MONSTER)) { /* oky doky. got a target monster. Lets make a blinding attack */ @@ -2137,12 +2118,12 @@ if (mflags & P_IS_ALIVE) { /* search this square for a victim */ - for (walk = get_map_ob (m, x, y); walk; walk = walk->above) + for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above) if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) { /* found a victim */ object *disease = arch_to_object (spell->other_arch); - set_owner (disease, op); + disease->set_owner (op); set_spell_skill (op, caster, spell, disease); disease->stats.exp = 0; disease->level = caster_level (caster, spell); @@ -2201,7 +2182,7 @@ new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); - disease->destroy (0); /* don't need this one anymore */ + disease->destroy (); /* don't need this one anymore */ flash = get_archetype (ARCH_DETECT_MAGIC); flash->x = x; flash->y = y; @@ -2209,7 +2190,8 @@ insert_ob_in_map (flash, walk->map, op, 0); return 1; } - disease->destroy (0); + + disease->destroy (); } } /* if living creature */ } /* for range of spaces */