… | |
… | |
1487 | if (spell->type == SPELL) |
1487 | if (spell->type == SPELL) |
1488 | { |
1488 | { |
1489 | int flags = 0; |
1489 | int flags = 0; |
1490 | |
1490 | |
1491 | /* check if we need to update it */ |
1491 | /* check if we need to update it */ |
1492 | if (spell->last_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) |
1492 | if (spell->cached_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) |
1493 | { |
1493 | { |
1494 | spell->last_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
1494 | spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
1495 | flags |= UPD_SP_MANA; |
1495 | flags |= UPD_SP_MANA; |
1496 | } |
1496 | } |
1497 | |
1497 | |
1498 | if (spell->last_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) |
1498 | if (spell->cached_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) |
1499 | { |
1499 | { |
1500 | spell->last_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1500 | spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1501 | flags |= UPD_SP_GRACE; |
1501 | flags |= UPD_SP_GRACE; |
1502 | } |
1502 | } |
1503 | |
1503 | |
1504 | if (spell->last_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) |
1504 | if (spell->cached_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) |
1505 | { |
1505 | { |
1506 | spell->last_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1506 | spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1507 | flags |= UPD_SP_DAMAGE; |
1507 | flags |= UPD_SP_DAMAGE; |
1508 | } |
1508 | } |
1509 | |
1509 | |
1510 | if (flags) |
1510 | if (flags) |
1511 | { |
1511 | { |
… | |
… | |
1513 | |
1513 | |
1514 | sl << "updspell " |
1514 | sl << "updspell " |
1515 | << uint8 (flags) |
1515 | << uint8 (flags) |
1516 | << uint32 (spell->count); |
1516 | << uint32 (spell->count); |
1517 | |
1517 | |
1518 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->last_sp); |
1518 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp); |
1519 | if (flags & UPD_SP_GRACE ) sl << uint16 (spell->last_grace); |
1519 | if (flags & UPD_SP_GRACE ) sl << uint16 (spell->cached_grace); |
1520 | if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->last_eat); |
1520 | if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->cached_eat); |
1521 | |
1521 | |
1522 | pl->ns->send_packet (sl); |
1522 | pl->ns->send_packet (sl); |
1523 | } |
1523 | } |
1524 | } |
1524 | } |
1525 | } |
1525 | } |
… | |
… | |
1555 | LOG (llevError, "item number %d is a spell with no name.\n", spell->count); |
1555 | LOG (llevError, "item number %d is a spell with no name.\n", spell->count); |
1556 | return; |
1556 | return; |
1557 | } |
1557 | } |
1558 | |
1558 | |
1559 | /* store costs and damage in the object struct, to compare to later */ |
1559 | /* store costs and damage in the object struct, to compare to later */ |
1560 | spell->last_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
1560 | spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
1561 | spell->last_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1561 | spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1562 | spell->last_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1562 | spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1563 | |
1563 | |
1564 | /* figure out which skill it uses, if it uses one */ |
1564 | /* figure out which skill it uses, if it uses one */ |
1565 | if (spell->skill) |
1565 | if (spell->skill) |
1566 | { |
1566 | { |
1567 | for (i = 1; i < NUM_SKILLS; i++) |
1567 | for (i = 1; i < NUM_SKILLS; i++) |
… | |
… | |
1583 | |
1583 | |
1584 | /* send the current values */ |
1584 | /* send the current values */ |
1585 | sl << uint32 (spell->count) |
1585 | sl << uint32 (spell->count) |
1586 | << uint16 (spell->level) |
1586 | << uint16 (spell->level) |
1587 | << uint16 (spell->casting_time) |
1587 | << uint16 (spell->casting_time) |
1588 | << uint16 (spell->last_sp) |
1588 | << uint16 (spell->cached_sp) |
1589 | << uint16 (spell->last_grace) |
1589 | << uint16 (spell->cached_grace) |
1590 | << uint16 (spell->last_eat) |
1590 | << uint16 (spell->cached_eat) |
1591 | << uint8 (skill) |
1591 | << uint8 (skill) |
1592 | << uint32 (spell->path_attuned) |
1592 | << uint32 (spell->path_attuned) |
1593 | << uint32 (spell->face) |
1593 | << uint32 (spell->face) |
1594 | << data8 (spell->name) |
1594 | << data8 (spell->name) |
1595 | << data16 (spell->msg); |
1595 | << data16 (spell->msg); |