… | |
… | |
833 | AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS); |
833 | AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS); |
834 | AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW); |
834 | AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW); |
835 | AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); |
835 | AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); |
836 | |
836 | |
837 | for (int s = 0; s < NUM_SKILLS; s++) |
837 | for (int s = 0; s < NUM_SKILLS; s++) |
838 | if (object *skill = opl->last_skill_ob[s]) |
838 | if (object *skill = opl->last_skill_ob [s]) |
839 | if (skill->stats.exp != ns->last_skill_exp [s]) |
839 | if (skill->stats.exp != ns->last_skill_exp [s]) |
840 | { |
840 | { |
841 | ns->last_skill_exp [s] = skill->stats.exp; |
841 | ns->last_skill_exp [s] = skill->stats.exp; |
842 | |
842 | |
843 | /* Always send along the level if exp changes. This is only |
843 | /* Always send along the level if exp changes. This is only |
… | |
… | |
912 | << uint32 (pl->ob->face) |
912 | << uint32 (pl->ob->face) |
913 | << data8 (pl->ob->name); |
913 | << data8 (pl->ob->name); |
914 | |
914 | |
915 | pl->ns->last_weight = weight; |
915 | pl->ns->last_weight = weight; |
916 | pl->ns->send_packet (sl); |
916 | pl->ns->send_packet (sl); |
917 | SET_FLAG (pl->ob, FLAG_CLIENT_SENT); |
|
|
918 | } |
917 | } |
919 | |
918 | |
920 | /****************************************************************************** |
919 | /****************************************************************************** |
921 | * |
920 | * |
922 | * Start of map related commands. |
921 | * Start of map related commands. |
… | |
… | |
1177 | |
1176 | |
1178 | int d = pl->blocked_los[ax][ay]; |
1177 | int d = pl->blocked_los[ax][ay]; |
1179 | |
1178 | |
1180 | if (d > 3) |
1179 | if (d > 3) |
1181 | { |
1180 | { |
1182 | |
|
|
1183 | int need_send = 0, count; |
1181 | int need_send = 0, count; |
1184 | |
1182 | |
1185 | /* This block deals with spaces that are not visible for whatever |
1183 | /* This block deals with spaces that are not visible for whatever |
1186 | * reason. Still may need to send the head for this space. |
1184 | * reason. Still may need to send the head for this space. |
1187 | */ |
1185 | */ |
… | |
… | |
1193 | if (lastcell.count != -1) |
1191 | if (lastcell.count != -1) |
1194 | need_send = 1; |
1192 | need_send = 1; |
1195 | |
1193 | |
1196 | count = -1; |
1194 | count = -1; |
1197 | |
1195 | |
1198 | /* properly clear a previously sent big face */ |
|
|
1199 | if (lastcell.faces[0] || lastcell.faces[1] || lastcell.faces[2] |
1196 | if (lastcell.faces[0] || lastcell.faces[1] || lastcell.faces[2] |
1200 | || lastcell.stat_hp || lastcell.flags || lastcell.player) |
1197 | || lastcell.stat_hp || lastcell.flags || lastcell.player) |
1201 | need_send = 1; |
1198 | need_send = 1; |
1202 | |
1199 | |
|
|
1200 | /* properly clear a previously sent big face */ |
1203 | map_clearcell (&lastcell, count); |
1201 | map_clearcell (&lastcell, count); |
1204 | |
1202 | |
1205 | if ((mask & 0xf) || need_send) |
1203 | if ((mask & 0xf) || need_send) |
1206 | sl[oldlen + 1] = mask & 0xff; |
1204 | sl[oldlen + 1] = mask & 0xff; |
1207 | else |
1205 | else |
… | |
… | |
1263 | { |
1261 | { |
1264 | if (op->stats.maxhp > op->stats.hp |
1262 | if (op->stats.maxhp > op->stats.hp |
1265 | && op->stats.maxhp > 0 |
1263 | && op->stats.maxhp > 0 |
1266 | && (op->type == PLAYER |
1264 | && (op->type == PLAYER |
1267 | || op->type == DOOR // does not work, have maxhp 0 |
1265 | || op->type == DOOR // does not work, have maxhp 0 |
1268 | || QUERY_FLAG (op, FLAG_MONSTER) || QUERY_FLAG (op, FLAG_ALIVE) || QUERY_FLAG (op, FLAG_GENERATOR))) |
1266 | || QUERY_FLAG (op, FLAG_MONSTER) |
|
|
1267 | || QUERY_FLAG (op, FLAG_ALIVE) |
|
|
1268 | || QUERY_FLAG (op, FLAG_GENERATOR))) |
1269 | { |
1269 | { |
1270 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
1270 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
1271 | stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge |
1271 | stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge |
1272 | } |
1272 | } |
1273 | |
1273 | |
1274 | if (op->msg && op->msg[0] == '@') |
1274 | if (op->has_dialogue ()) |
1275 | flags |= 1; |
1275 | flags |= 1; |
1276 | |
1276 | |
1277 | if (op->type == PLAYER && op != ob) |
1277 | if (op->type == PLAYER) |
1278 | player = op->count; |
1278 | player = op == ob ? pl->ob->count |
|
|
1279 | : op == pl->ob ? ob->count |
|
|
1280 | : op->count; |
1279 | } |
1281 | } |
1280 | |
1282 | |
1281 | if (lastcell.stat_hp != stat_hp) |
1283 | if (lastcell.stat_hp != stat_hp) |
1282 | { |
1284 | { |
1283 | lastcell.stat_hp = stat_hp; |
1285 | lastcell.stat_hp = stat_hp; |
… | |
… | |
1433 | { |
1435 | { |
1434 | packet sl; |
1436 | packet sl; |
1435 | sl << "replyinfo skill_info\n"; |
1437 | sl << "replyinfo skill_info\n"; |
1436 | |
1438 | |
1437 | for (int i = 1; i < NUM_SKILLS; i++) |
1439 | for (int i = 1; i < NUM_SKILLS; i++) |
1438 | sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names[i]); |
1440 | sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names [i]); |
1439 | |
1441 | |
1440 | if (sl.length () > MAXSOCKBUF) |
1442 | if (sl.length () > MAXSOCKBUF) |
1441 | { |
1443 | { |
1442 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
1444 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
1443 | fatal (0); |
1445 | fatal (0); |
… | |
… | |
1487 | if (spell->type == SPELL) |
1489 | if (spell->type == SPELL) |
1488 | { |
1490 | { |
1489 | int flags = 0; |
1491 | int flags = 0; |
1490 | |
1492 | |
1491 | /* check if we need to update it */ |
1493 | /* check if we need to update it */ |
1492 | if (spell->last_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) |
1494 | if (spell->cached_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) |
1493 | { |
1495 | { |
1494 | spell->last_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
1496 | spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
1495 | flags |= UPD_SP_MANA; |
1497 | flags |= UPD_SP_MANA; |
1496 | } |
1498 | } |
1497 | |
1499 | |
1498 | if (spell->last_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) |
1500 | if (spell->cached_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) |
1499 | { |
1501 | { |
1500 | spell->last_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1502 | spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1501 | flags |= UPD_SP_GRACE; |
1503 | flags |= UPD_SP_GRACE; |
1502 | } |
1504 | } |
1503 | |
1505 | |
1504 | if (spell->last_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) |
1506 | if (spell->cached_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) |
1505 | { |
1507 | { |
1506 | spell->last_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1508 | spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1507 | flags |= UPD_SP_DAMAGE; |
1509 | flags |= UPD_SP_DAMAGE; |
1508 | } |
1510 | } |
1509 | |
1511 | |
1510 | if (flags) |
1512 | if (flags) |
1511 | { |
1513 | { |
… | |
… | |
1513 | |
1515 | |
1514 | sl << "updspell " |
1516 | sl << "updspell " |
1515 | << uint8 (flags) |
1517 | << uint8 (flags) |
1516 | << uint32 (spell->count); |
1518 | << uint32 (spell->count); |
1517 | |
1519 | |
1518 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->last_sp); |
1520 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp); |
1519 | if (flags & UPD_SP_GRACE ) sl << uint16 (spell->last_grace); |
1521 | if (flags & UPD_SP_GRACE ) sl << uint16 (spell->cached_grace); |
1520 | if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->last_eat); |
1522 | if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->cached_eat); |
1521 | |
1523 | |
1522 | pl->ns->send_packet (sl); |
1524 | pl->ns->send_packet (sl); |
1523 | } |
1525 | } |
1524 | } |
1526 | } |
1525 | } |
1527 | } |
… | |
… | |
1555 | LOG (llevError, "item number %d is a spell with no name.\n", spell->count); |
1557 | LOG (llevError, "item number %d is a spell with no name.\n", spell->count); |
1556 | return; |
1558 | return; |
1557 | } |
1559 | } |
1558 | |
1560 | |
1559 | /* store costs and damage in the object struct, to compare to later */ |
1561 | /* 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); |
1562 | 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); |
1563 | 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); |
1564 | spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1563 | |
1565 | |
1564 | /* figure out which skill it uses, if it uses one */ |
1566 | /* figure out which skill it uses, if it uses one */ |
1565 | if (spell->skill) |
1567 | if (spell->skill) |
1566 | { |
1568 | if (object *tmp = pl->find_skill (spell->skill)) |
1567 | for (i = 1; i < NUM_SKILLS; i++) |
|
|
1568 | if (!strcmp (spell->skill, skill_names[i])) |
|
|
1569 | { |
|
|
1570 | skill = i + CS_STAT_SKILLINFO; |
1569 | skill = tmp->subtype + CS_STAT_SKILLINFO; |
1571 | break; |
|
|
1572 | } |
|
|
1573 | } |
|
|
1574 | |
1570 | |
1575 | // spells better have a face |
1571 | // spells better have a face |
1576 | if (!spell->face) |
1572 | if (!spell->face) |
1577 | { |
1573 | { |
1578 | LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); |
1574 | LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); |
… | |
… | |
1583 | |
1579 | |
1584 | /* send the current values */ |
1580 | /* send the current values */ |
1585 | sl << uint32 (spell->count) |
1581 | sl << uint32 (spell->count) |
1586 | << uint16 (spell->level) |
1582 | << uint16 (spell->level) |
1587 | << uint16 (spell->casting_time) |
1583 | << uint16 (spell->casting_time) |
1588 | << uint16 (spell->last_sp) |
1584 | << uint16 (spell->cached_sp) |
1589 | << uint16 (spell->last_grace) |
1585 | << uint16 (spell->cached_grace) |
1590 | << uint16 (spell->last_eat) |
1586 | << uint16 (spell->cached_eat) |
1591 | << uint8 (skill) |
1587 | << uint8 (skill) |
1592 | << uint32 (spell->path_attuned) |
1588 | << uint32 (spell->path_attuned) |
1593 | << uint32 (spell->face) |
1589 | << uint32 (spell->face) |
1594 | << data8 (spell->name) |
1590 | << data8 (spell->name) |
1595 | << data16 (spell->msg); |
1591 | << data16 (spell->msg); |