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.70 by elmex, Sun Dec 21 20:35:37 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}
1497 /* If there is nothing living on this space, no need to go further */ 1474 /* If there is nothing living on this space, no need to go further */
1498 if (!(mflags & P_IS_ALIVE)) 1475 if (!(mflags & P_IS_ALIVE))
1499 continue; 1476 continue;
1500 1477
1501 // players can only affect spaces that they can actually see 1478 // players can only affect spaces that they can actually see
1479 if (caster
1502 if (caster && caster->contr 1480 && caster->contr
1503 && caster->contr->visibility_at (m, nx, ny) < 70) 1481 && caster->contr->darkness_at (m, nx, ny) == LOS_BLOCKED)
1504 continue; 1482 continue;
1505 1483
1506 for (tmp = GET_MAP_TOP (m, nx, ny); tmp; tmp = tmp->below) 1484 for (tmp = GET_MAP_TOP (m, nx, ny); tmp; tmp = tmp->below)
1507 if (QUERY_FLAG (tmp, FLAG_MONSTER)) 1485 if (QUERY_FLAG (tmp, FLAG_MONSTER))
1508 break; 1486 break;
1618 } /* for y */ 1596 } /* for y */
1619 1597
1620 return 1; 1598 return 1;
1621} 1599}
1622 1600
1623
1624/* Move_ball_spell: This handles ball type spells that just sort of wander 1601/* Move_ball_spell: This handles ball type spells that just sort of wander
1625 * about. was called move_ball_lightning, but since more than the ball 1602 * about. was called move_ball_lightning, but since more than the ball
1626 * lightning spell used it, that seemed misnamed. 1603 * lightning spell used it, that seemed misnamed.
1627 * op is the spell effect. 1604 * op is the spell effect.
1628 * note that duration is handled by process_object() in time.c 1605 * note that duration is handled by process_object() in time.c
1653 for (i = 1; i < 9; i++) 1630 for (i = 1; i < 9; i++)
1654 { 1631 {
1655 /* i bit 0: alters sign of offset 1632 /* i bit 0: alters sign of offset
1656 * other bits (i / 2): absolute value of offset 1633 * other bits (i / 2): absolute value of offset
1657 */ 1634 */
1658
1659 int offset = ((i ^ j) & 1) ? (i / 2) : -(i / 2); 1635 int offset = ((i ^ j) & 1) ? (i / 2) : -(i / 2);
1660 int tmpdir = absdir (op->direction + offset); 1636 int tmpdir = absdir (op->direction + offset);
1661 1637
1662 nx = op->x + freearr_x[tmpdir]; 1638 nx = op->x + freearr_x[tmpdir];
1663 ny = op->y + freearr_y[tmpdir]; 1639 ny = op->y + freearr_y[tmpdir];
1665 { 1641 {
1666 dir = tmpdir; 1642 dir = tmpdir;
1667 break; 1643 break;
1668 } 1644 }
1669 } 1645 }
1646
1670 if (dir == 0) 1647 if (dir == 0)
1671 { 1648 {
1672 nx = op->x; 1649 nx = op->x;
1673 ny = op->y; 1650 ny = op->y;
1674 m = op->map; 1651 m = op->map;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines