ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_attack.C
(Generate patch)

Comparing deliantra/server/server/spell_attack.C (file contents):
Revision 1.73 by root, Sun Dec 28 06:59:27 2008 UTC vs.
Revision 1.74 by root, Sun Dec 28 07:48:44 2008 UTC

1270} 1270}
1271 1271
1272int 1272int
1273cast_destruction (object *op, object *caster, object *spell_ob) 1273cast_destruction (object *op, object *caster, object *spell_ob)
1274{ 1274{
1275 int i, j, range, mflags, friendly = 0, dam, dur;
1276 sint16 sx, sy;
1277 maptile *m;
1278 object *tmp;
1279 const char *skill;
1280
1281 range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); 1275 int range = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
1282 dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); 1276 int dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob);
1283 dur = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 1277 int dur = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
1284 if (QUERY_FLAG (op, FLAG_FRIENDLY) || op->type == PLAYER) 1278
1285 friendly = 1; 1279 bool friendly = op->flag [FLAG_FRIENDLY] || op->is_player ();
1286 1280
1287 /* destruction doesn't use another spell object, so we need 1281 /* destruction doesn't use another spell object, so we need
1288 * update op's skill pointer so that exp is properly awarded. 1282 * update op's skill pointer so that exp is properly awarded.
1289 * We do some shortcuts here - since this is just temporary
1290 * and we'll reset the values back, we don't need to go through
1291 * the full share string/free_string route.
1292 */ 1283 */
1293 skill = op->skill; 1284 const shstr skill = op->skill;
1285
1294 if (caster == op) 1286 if (caster == op)
1295 op->skill = spell_ob->skill; 1287 op->skill = spell_ob->skill;
1296 else if (caster->skill) 1288 else if (caster->skill)
1297 op->skill = caster->skill; 1289 op->skill = caster->skill;
1298 else 1290 else
1299 op->skill = NULL; 1291 op->skill = 0;
1300 1292
1301 op->change_skill (find_skill_by_name (op, op->skill)); 1293 op->change_skill (find_skill_by_name (op, op->skill));
1302 1294
1303 for (i = -range; i <= range; i++) 1295 unordered_mapwalk (op, -range, -range, range, range)
1304 { 1296 {
1305 for (j = -range; j <= range; j++) 1297 mapspace &ms = m->at (nx, ny);
1306 {
1307 m = op->map;
1308 sx = op->x + i;
1309 sy = op->y + j;
1310 1298
1311 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
1312 if (mflags & P_OUT_OF_MAP)
1313 continue;
1314
1315 if (mflags & P_IS_ALIVE) 1299 if (ms.flags () & P_IS_ALIVE)
1300 for (object *tmp = ms.bot; tmp; tmp = tmp->above)
1301 if (tmp->flag [FLAG_ALIVE] || tmp->is_player ())
1316 { 1302 {
1317 for (tmp = GET_MAP_OB (m, sx, sy); tmp; tmp = tmp->above) 1303 tmp = tmp->head_ ();
1318 if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER)
1319 break;
1320 1304
1321 if (tmp) 1305 if ((friendly && !tmp->flag [FLAG_FRIENDLY] && !tmp->is_player ())
1306 || (!friendly && (tmp->flag [FLAG_FRIENDLY] || tmp->is_player ())))
1322 { 1307 {
1323 if (tmp->head) 1308 if (spell_ob->subtype == SP_DESTRUCTION)
1324 tmp = tmp->head;
1325
1326 if ((friendly && !QUERY_FLAG (tmp, FLAG_FRIENDLY) && tmp->type != PLAYER) ||
1327 (!friendly && (QUERY_FLAG (tmp, FLAG_FRIENDLY) || tmp->type == PLAYER)))
1328 { 1309 {
1329 if (spell_ob->subtype == SP_DESTRUCTION)
1330 {
1331 hit_player (tmp, dam, op, spell_ob->attacktype, 0); 1310 hit_player (tmp, dam, op, spell_ob->attacktype, 0);
1332 1311
1333 if (spell_ob->other_arch) 1312 if (spell_ob->other_arch)
1334 m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op); 1313 m->insert (arch_to_object (spell_ob->other_arch), nx, ny, op);
1335 } 1314 }
1336 else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist[ATNR_MAGIC] != 100) 1315 else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist [ATNR_MAGIC] != 100)
1337 { 1316 {
1338 if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) 1317 if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch)
1339 m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op); 1318 m->insert (arch_to_object (spell_ob->other_arch), nx, ny, op);
1340 }
1341 } 1319 }
1342 } 1320 }
1343 } 1321 }
1344 }
1345 } 1322 }
1346 1323
1347 op->skill = skill; 1324 op->skill = skill;
1348 return 1; 1325 return 1;
1349} 1326}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines