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

Comparing deliantra/server/server/spell_util.C (file contents):
Revision 1.11 by root, Sun Sep 10 15:59:58 2006 UTC vs.
Revision 1.12 by root, Mon Sep 11 20:26:41 2006 UTC

1 1
2/* 2/*
3 * static char *rcsid_spell_util_c = 3 * static char *rcsid_spell_util_c =
4 * "$Id: spell_util.C,v 1.11 2006/09/10 15:59:58 root Exp $"; 4 * "$Id: spell_util.C,v 1.12 2006/09/11 20:26:41 root Exp $";
5 */ 5 */
6 6
7 7
8/* 8/*
9 CrossFire, A Multiplayer game for X-windows 9 CrossFire, A Multiplayer game for X-windows
1268 if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace) 1268 if ((mflags & P_NO_CLERIC) && spell_ob->stats.grace)
1269 new_draw_info_format (NDI_UNIQUE, 0, op, "This ground is unholy! %s ignores you.", godname); 1269 new_draw_info_format (NDI_UNIQUE, 0, op, "This ground is unholy! %s ignores you.", godname);
1270 else 1270 else
1271 switch (op->contr->shoottype) 1271 switch (op->contr->shoottype)
1272 { 1272 {
1273 case range_magic: 1273 case range_magic:
1274 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your spellcasting."); 1274 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your spellcasting.");
1275 break; 1275 break;
1276 case range_misc: 1276 case range_misc:
1277 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your item."); 1277 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your item.");
1278 break; 1278 break;
1279 case range_golem: 1279 case range_golem:
1280 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your scroll."); 1280 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of your scroll.");
1281 break; 1281 break;
1282 default: 1282 default:
1283 break; 1283 break;
1284 } 1284 }
1285 return 0; 1285 return 0;
1286 } 1286 }
1287 1287
1288 if (caster == op && settings.casting_time == TRUE && spell_ob->type == SPELL) 1288 if (caster == op && settings.casting_time == TRUE && spell_ob->type == SPELL)
1362 change_skill (op, skill, 0); /* needed for proper exp credit */ 1362 change_skill (op, skill, 0); /* needed for proper exp credit */
1363 } 1363 }
1364 1364
1365 switch (spell_ob->subtype) 1365 switch (spell_ob->subtype)
1366 { 1366 {
1367 /* The order of case statements is same as the order they show up 1367 /* The order of case statements is same as the order they show up
1368 * in in spells.h. 1368 * in in spells.h.
1369 */ 1369 */
1370 case SP_RAISE_DEAD: 1370 case SP_RAISE_DEAD:
1371 success = cast_raise_dead_spell (op, caster, spell_ob, dir, stringarg); 1371 success = cast_raise_dead_spell (op, caster, spell_ob, dir, stringarg);
1372 break; 1372 break;
1373 1373
1374 case SP_RUNE: 1374 case SP_RUNE:
1375 success = write_rune (op, caster, spell_ob, dir, stringarg); 1375 success = write_rune (op, caster, spell_ob, dir, stringarg);
1376 break; 1376 break;
1377 1377
1378 case SP_MAKE_MARK: 1378 case SP_MAKE_MARK:
1379 success = write_mark (op, spell_ob, stringarg); 1379 success = write_mark (op, spell_ob, stringarg);
1380 break; 1380 break;
1381 1381
1382 case SP_BOLT: 1382 case SP_BOLT:
1383 success = fire_bolt (op, caster, dir, spell_ob, skill); 1383 success = fire_bolt (op, caster, dir, spell_ob, skill);
1384 break; 1384 break;
1385 1385
1386 case SP_BULLET: 1386 case SP_BULLET:
1387 success = fire_bullet (op, caster, dir, spell_ob); 1387 success = fire_bullet (op, caster, dir, spell_ob);
1388 break; 1388 break;
1389 1389
1390 case SP_CONE: 1390 case SP_CONE:
1391 success = cast_cone (op, caster, dir, spell_ob); 1391 success = cast_cone (op, caster, dir, spell_ob);
1392 break; 1392 break;
1393 1393
1394 case SP_BOMB: 1394 case SP_BOMB:
1395 success = create_bomb (op, caster, dir, spell_ob); 1395 success = create_bomb (op, caster, dir, spell_ob);
1396 break; 1396 break;
1397 1397
1398 case SP_WONDER: 1398 case SP_WONDER:
1399 success = cast_wonder (op, caster, dir, spell_ob); 1399 success = cast_wonder (op, caster, dir, spell_ob);
1400 break; 1400 break;
1401 1401
1402 case SP_SMITE: 1402 case SP_SMITE:
1403 success = cast_smite_spell (op, caster, dir, spell_ob); 1403 success = cast_smite_spell (op, caster, dir, spell_ob);
1404 break; 1404 break;
1405 1405
1406 case SP_MAGIC_MISSILE: 1406 case SP_MAGIC_MISSILE:
1407 success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob);
1408 break;
1409
1410 case SP_SUMMON_GOLEM:
1411 success = summon_golem (op, caster, dir, spell_ob);
1412 old_shoottype = range_golem;
1413 break;
1414
1415 case SP_DIMENSION_DOOR:
1416 /* dimension door needs the actual caster, because that is what is
1417 * moved.
1418 */
1419 success = dimension_door (op, caster, spell_ob, dir);
1420 break;
1421
1422 case SP_MAGIC_MAPPING:
1423 if (op->type == PLAYER)
1424 {
1425 spell_effect (spell_ob, op->x, op->y, op->map, op);
1426 draw_magic_map (op);
1427 success = 1;
1428 }
1429 else
1430 success = 0;
1431 break;
1432
1433 case SP_MAGIC_WALL:
1434 success = magic_wall (op, caster, dir, spell_ob);
1435 break;
1436
1437 case SP_DESTRUCTION:
1438 success = cast_destruction (op, caster, spell_ob);
1439 break;
1440
1441 case SP_PERCEIVE_SELF:
1442 success = perceive_self (op);
1443 break;
1444
1445 case SP_WORD_OF_RECALL:
1446 success = cast_word_of_recall (op, caster, spell_ob);
1447 break;
1448
1449 case SP_INVISIBLE:
1450 success = cast_invisible (op, caster, spell_ob);
1451 break;
1452
1453 case SP_PROBE:
1454 success = probe (op, caster, spell_ob, dir);
1455 break;
1456
1457 case SP_HEALING:
1458 success = cast_heal (op, caster, spell_ob, dir);
1459 break;
1460
1461 case SP_CREATE_FOOD:
1462 success = cast_create_food (op, caster, spell_ob, dir, stringarg);
1463 break;
1464
1465 case SP_EARTH_TO_DUST:
1466 success = cast_earth_to_dust (op, caster, spell_ob);
1467 break;
1468
1469 case SP_CHANGE_ABILITY:
1470 success = cast_change_ability (op, caster, spell_ob, dir, 0);
1471 break;
1472
1473 case SP_BLESS:
1474 success = cast_bless (op, caster, spell_ob, dir);
1475 break;
1476
1477 case SP_CURSE:
1478 success = cast_curse (op, caster, spell_ob, dir);
1479 break;
1480
1481 case SP_SUMMON_MONSTER:
1482 success = summon_object (op, caster, spell_ob, dir, stringarg);
1483 break;
1484
1485 case SP_CHARGING:
1486 success = recharge (op, caster, spell_ob);
1487 break;
1488
1489 case SP_POLYMORPH:
1490#ifdef NO_POLYMORPH
1491 /* Not great, but at least provide feedback so if players do have
1492 * polymorph (ie, find it as a preset item or left over from before
1493 * it was disabled), they get some feedback.
1494 */
1495 new_draw_info (NDI_UNIQUE, 0, op, "The spell fizzles");
1496 success = 0;
1497#else
1498 success = cast_polymorph (op, caster, spell_ob, dir);
1499#endif
1500 break;
1501
1502 case SP_ALCHEMY:
1503 success = alchemy (op, caster, spell_ob);
1504 break;
1505
1506 case SP_REMOVE_CURSE:
1507 success = remove_curse (op, caster, spell_ob);
1508 break;
1509
1510 case SP_IDENTIFY:
1511 success = cast_identify (op, caster, spell_ob);
1512 break;
1513
1514 case SP_DETECTION:
1515 success = cast_detection (op, caster, spell_ob, skill);
1516 break;
1517
1518 case SP_MOOD_CHANGE:
1519 success = mood_change (op, caster, spell_ob);
1520 break;
1521
1522 case SP_MOVING_BALL:
1523 if (spell_ob->path_repelled && (spell_ob->path_repelled & caster->path_attuned) != spell_ob->path_repelled)
1524 {
1525 new_draw_info_format (NDI_UNIQUE, 0, op, "You lack the proper attunement to cast %s", &spell_ob->name);
1526 success = 0;
1527 }
1528 else
1407 success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob); 1529 success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob);
1408 break; 1530 break;
1409 1531
1410 case SP_SUMMON_GOLEM:
1411 success = summon_golem (op, caster, dir, spell_ob);
1412 old_shoottype = range_golem;
1413 break;
1414
1415 case SP_DIMENSION_DOOR:
1416 /* dimension door needs the actual caster, because that is what is
1417 * moved.
1418 */
1419 success = dimension_door (op, caster, spell_ob, dir);
1420 break;
1421
1422 case SP_MAGIC_MAPPING:
1423 if (op->type == PLAYER)
1424 {
1425 spell_effect (spell_ob, op->x, op->y, op->map, op);
1426 draw_magic_map (op);
1427 success = 1;
1428 }
1429 else
1430 success = 0;
1431 break;
1432
1433 case SP_MAGIC_WALL:
1434 success = magic_wall (op, caster, dir, spell_ob);
1435 break;
1436
1437 case SP_DESTRUCTION:
1438 success = cast_destruction (op, caster, spell_ob);
1439 break;
1440
1441 case SP_PERCEIVE_SELF:
1442 success = perceive_self (op);
1443 break;
1444
1445 case SP_WORD_OF_RECALL:
1446 success = cast_word_of_recall (op, caster, spell_ob);
1447 break;
1448
1449 case SP_INVISIBLE:
1450 success = cast_invisible (op, caster, spell_ob);
1451 break;
1452
1453 case SP_PROBE:
1454 success = probe (op, caster, spell_ob, dir);
1455 break;
1456
1457 case SP_HEALING:
1458 success = cast_heal (op, caster, spell_ob, dir);
1459 break;
1460
1461 case SP_CREATE_FOOD:
1462 success = cast_create_food (op, caster, spell_ob, dir, stringarg);
1463 break;
1464
1465 case SP_EARTH_TO_DUST:
1466 success = cast_earth_to_dust (op, caster, spell_ob);
1467 break;
1468
1469 case SP_CHANGE_ABILITY:
1470 success = cast_change_ability (op, caster, spell_ob, dir, 0);
1471 break;
1472
1473 case SP_BLESS:
1474 success = cast_bless (op, caster, spell_ob, dir);
1475 break;
1476
1477 case SP_CURSE:
1478 success = cast_curse (op, caster, spell_ob, dir);
1479 break;
1480
1481 case SP_SUMMON_MONSTER:
1482 success = summon_object (op, caster, spell_ob, dir, stringarg);
1483 break;
1484
1485 case SP_CHARGING:
1486 success = recharge (op, caster, spell_ob);
1487 break;
1488
1489 case SP_POLYMORPH:
1490#ifdef NO_POLYMORPH
1491 /* Not great, but at least provide feedback so if players do have
1492 * polymorph (ie, find it as a preset item or left over from before
1493 * it was disabled), they get some feedback.
1494 */
1495 new_draw_info (NDI_UNIQUE, 0, op, "The spell fizzles");
1496 success = 0;
1497#else
1498 success = cast_polymorph (op, caster, spell_ob, dir);
1499#endif
1500 break;
1501
1502 case SP_ALCHEMY:
1503 success = alchemy (op, caster, spell_ob);
1504 break;
1505
1506 case SP_REMOVE_CURSE:
1507 success = remove_curse (op, caster, spell_ob);
1508 break;
1509
1510 case SP_IDENTIFY:
1511 success = cast_identify (op, caster, spell_ob);
1512 break;
1513
1514 case SP_DETECTION:
1515 success = cast_detection (op, caster, spell_ob, skill);
1516 break;
1517
1518 case SP_MOOD_CHANGE:
1519 success = mood_change (op, caster, spell_ob);
1520 break;
1521
1522 case SP_MOVING_BALL:
1523 if (spell_ob->path_repelled && (spell_ob->path_repelled & caster->path_attuned) != spell_ob->path_repelled)
1524 {
1525 new_draw_info_format (NDI_UNIQUE, 0, op, "You lack the proper attunement to cast %s", &spell_ob->name);
1526 success = 0;
1527 }
1528 else
1529 success = fire_arch_from_position (op, caster, op->x + freearr_x[dir], op->y + freearr_y[dir], dir, spell_ob);
1530 break;
1531
1532 case SP_SWARM: 1532 case SP_SWARM:
1533 success = fire_swarm (op, caster, spell_ob, dir); 1533 success = fire_swarm (op, caster, spell_ob, dir);
1534 break; 1534 break;
1535 1535
1536 case SP_CHANGE_MANA: 1536 case SP_CHANGE_MANA:
1537 success = cast_transfer (op, caster, spell_ob, dir); 1537 success = cast_transfer (op, caster, spell_ob, dir);
1538 break; 1538 break;
1539 1539
1540 case SP_DISPEL_RUNE: 1540 case SP_DISPEL_RUNE:
1541 /* in rune.c */ 1541 /* in rune.c */
1542 success = dispel_rune (op, caster, spell_ob, skill, dir); 1542 success = dispel_rune (op, caster, spell_ob, skill, dir);
1543 break; 1543 break;
1544 1544
1545 case SP_CREATE_MISSILE: 1545 case SP_CREATE_MISSILE:
1546 success = cast_create_missile (op, caster, spell_ob, dir, stringarg); 1546 success = cast_create_missile (op, caster, spell_ob, dir, stringarg);
1547 break; 1547 break;
1548 1548
1549 case SP_CONSECRATE: 1549 case SP_CONSECRATE:
1550 success = cast_consecrate (op, caster, spell_ob); 1550 success = cast_consecrate (op, caster, spell_ob);
1551 break; 1551 break;
1552 1552
1553 case SP_ANIMATE_WEAPON: 1553 case SP_ANIMATE_WEAPON:
1554 success = animate_weapon (op, caster, spell_ob, dir); 1554 success = animate_weapon (op, caster, spell_ob, dir);
1555 old_shoottype = range_golem; 1555 old_shoottype = range_golem;
1556 break; 1556 break;
1557 1557
1558 case SP_LIGHT: 1558 case SP_LIGHT:
1559 success = cast_light (op, caster, spell_ob, dir); 1559 success = cast_light (op, caster, spell_ob, dir);
1560 break; 1560 break;
1561 1561
1562 case SP_CHANGE_MAP_LIGHT: 1562 case SP_CHANGE_MAP_LIGHT:
1563 success = cast_change_map_lightlevel (op, caster, spell_ob); 1563 success = cast_change_map_lightlevel (op, caster, spell_ob);
1564 break; 1564 break;
1565 1565
1566 case SP_FAERY_FIRE: 1566 case SP_FAERY_FIRE:
1567 success = cast_destruction (op, caster, spell_ob); 1567 success = cast_destruction (op, caster, spell_ob);
1568 break; 1568 break;
1569 1569
1570 case SP_CAUSE_DISEASE: 1570 case SP_CAUSE_DISEASE:
1571 success = cast_cause_disease (op, caster, spell_ob, dir); 1571 success = cast_cause_disease (op, caster, spell_ob, dir);
1572 break; 1572 break;
1573 1573
1574 case SP_AURA: 1574 case SP_AURA:
1575 success = create_aura (op, caster, spell_ob); 1575 success = create_aura (op, caster, spell_ob);
1576 break; 1576 break;
1577 1577
1578 case SP_TOWN_PORTAL: 1578 case SP_TOWN_PORTAL:
1579 success = cast_create_town_portal (op, caster, spell_ob, dir); 1579 success = cast_create_town_portal (op, caster, spell_ob, dir);
1580 break; 1580 break;
1581 1581
1582 case SP_PARTY_SPELL: 1582 case SP_PARTY_SPELL:
1583 success = cast_party_spell (op, caster, dir, spell_ob, stringarg); 1583 success = cast_party_spell (op, caster, dir, spell_ob, stringarg);
1584 break; 1584 break;
1585 1585
1586 default: 1586 default:
1587 if (!INVOKE_OBJECT (CAST_SPELL, spell_ob, ARG_OBJECT (op), ARG_OBJECT (caster), ARG_INT (dir), ARG_STRING (stringarg))) 1587 if (!INVOKE_OBJECT (CAST_SPELL, spell_ob, ARG_OBJECT (op), ARG_OBJECT (caster), ARG_INT (dir), ARG_STRING (stringarg)))
1588 LOG (llevError, "cast_spell: Unhandled spell subtype %d\n", spell_ob->subtype); 1588 LOG (llevError, "cast_spell: Unhandled spell subtype %d\n", spell_ob->subtype);
1589
1590
1591 } 1589 }
1592 1590
1593 /* FIXME - we need some better sound suppport */ 1591 /* FIXME - we need some better sound suppport */
1594 // yes, for example, augment map info with the spell effect 1592 // yes, for example, augment map info with the spell effect
1595 // so clients can calculate the sounds themselves 1593 // so clients can calculate the sounds themselves
1617 * then dispatches them to the appropriate specific routines. 1615 * then dispatches them to the appropriate specific routines.
1618 */ 1616 */
1619void 1617void
1620move_spell_effect (object *op) 1618move_spell_effect (object *op)
1621{ 1619{
1622
1623 switch (op->subtype) 1620 switch (op->subtype)
1624 { 1621 {
1625 case SP_BOLT: 1622 case SP_BOLT:
1626 move_bolt (op); 1623 move_bolt (op);
1627 break; 1624 break;
1628 1625
1629 case SP_BULLET: 1626 case SP_BULLET:
1630 move_bullet (op); 1627 move_bullet (op);
1631 break; 1628 break;
1632 1629
1633 case SP_EXPLOSION: 1630 case SP_EXPLOSION:
1634 explosion (op); 1631 explosion (op);
1635 break; 1632 break;
1636 1633
1637 case SP_CONE: 1634 case SP_CONE:
1638 move_cone (op); 1635 move_cone (op);
1639 break; 1636 break;
1640 1637
1641 case SP_BOMB: 1638 case SP_BOMB:
1642 animate_bomb (op); 1639 animate_bomb (op);
1643 break; 1640 break;
1644 1641
1645 case SP_MAGIC_MISSILE: 1642 case SP_MAGIC_MISSILE:
1646 move_missile (op); 1643 move_missile (op);
1647 break; 1644 break;
1648 1645
1649 case SP_WORD_OF_RECALL: 1646 case SP_WORD_OF_RECALL:
1650 execute_word_of_recall (op); 1647 execute_word_of_recall (op);
1651 break; 1648 break;
1652 1649
1653 case SP_MOVING_BALL: 1650 case SP_MOVING_BALL:
1654 move_ball_spell (op); 1651 move_ball_spell (op);
1655 break; 1652 break;
1656 1653
1657 case SP_SWARM: 1654 case SP_SWARM:
1658 move_swarm_spell (op); 1655 move_swarm_spell (op);
1659 break; 1656 break;
1660 1657
1661 case SP_AURA: 1658 case SP_AURA:
1662 move_aura (op); 1659 move_aura (op);
1663 break; 1660 break;
1664
1665 } 1661 }
1666} 1662}
1667 1663
1668/* this checks to see if something special should happen if 1664/* this checks to see if something special should happen if
1669 * something runs into the object. 1665 * something runs into the object.
1670 */ 1666 */
1671void 1667void
1672check_spell_effect (object *op) 1668check_spell_effect (object *op)
1673{ 1669{
1674
1675 switch (op->subtype) 1670 switch (op->subtype)
1676 { 1671 {
1677 case SP_BOLT: 1672 case SP_BOLT:
1678 move_bolt (op); 1673 move_bolt (op);
1679 return; 1674 return;
1680 1675
1681 case SP_BULLET: 1676 case SP_BULLET:
1682 check_bullet (op); 1677 check_bullet (op);
1683 return; 1678 return;
1684 } 1679 }
1685
1686} 1680}
1687 1681
1688/* This is called by move_apply. Basically, if someone 1682/* This is called by move_apply. Basically, if someone
1689 * moves onto a spell effect and the walk_on or fly_on flags 1683 * moves onto a spell effect and the walk_on or fly_on flags
1690 * are set, this is called. This should only be called for 1684 * are set, this is called. This should only be called for
1693void 1687void
1694apply_spell_effect (object *spell, object *victim) 1688apply_spell_effect (object *spell, object *victim)
1695{ 1689{
1696 switch (spell->subtype) 1690 switch (spell->subtype)
1697 { 1691 {
1698 case SP_CONE: 1692 case SP_CONE:
1699 if (QUERY_FLAG (victim, FLAG_ALIVE) && spell->speed && spell->attacktype) 1693 if (QUERY_FLAG (victim, FLAG_ALIVE) && spell->speed && spell->attacktype)
1700 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 0); 1694 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 0);
1701 break; 1695 break;
1702 1696
1703 case SP_MAGIC_MISSILE: 1697 case SP_MAGIC_MISSILE:
1704 if (QUERY_FLAG (victim, FLAG_ALIVE)) 1698 if (QUERY_FLAG (victim, FLAG_ALIVE))
1705 { 1699 {
1706 tag_t spell_tag = spell->count; 1700 tag_t spell_tag = spell->count;
1707 1701
1708 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1);
1709 if (!was_destroyed (spell, spell_tag))
1710 {
1711 remove_ob (spell);
1712 free_object (spell);
1713 }
1714 }
1715 break;
1716
1717 case SP_MOVING_BALL:
1718 if (QUERY_FLAG (victim, FLAG_ALIVE))
1719 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1); 1702 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1);
1703 if (!was_destroyed (spell, spell_tag))
1704 {
1705 remove_ob (spell);
1706 free_object (spell);
1707 }
1708 }
1709 break;
1710
1711 case SP_MOVING_BALL:
1712 if (QUERY_FLAG (victim, FLAG_ALIVE))
1713 hit_player (victim, spell->stats.dam, spell, spell->attacktype, 1);
1720 else if (victim->material || victim->materialname) 1714 else if (victim->material || victim->materialname)
1721 save_throw_object (victim, spell->attacktype, spell); 1715 save_throw_object (victim, spell->attacktype, spell);
1722 break; 1716 break;
1723 } 1717 }
1724} 1718}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines