1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel |
5 | * Copyright (©) 2001 Mark Wedel |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
736 | static void |
736 | static void |
737 | rangetostring (player *pl, char *obuf) |
737 | rangetostring (player *pl, char *obuf) |
738 | { |
738 | { |
739 | dynbuf_text &buf = msg_dynbuf; buf.clear (); |
739 | dynbuf_text &buf = msg_dynbuf; buf.clear (); |
740 | |
740 | |
|
|
741 | #if 0 |
|
|
742 | // print ranged/chosen_skill etc. objects every call |
|
|
743 | printf ("%s %s => %s (%s)\n", |
|
|
744 | pl->ranged_ob ? &pl->ranged_ob->name : "-", |
|
|
745 | pl->combat_ob ? &pl->combat_ob->name : "-", |
|
|
746 | pl->ob->current_weapon ? &pl->ob->current_weapon->name : "-", |
|
|
747 | pl->ob->chosen_skill ? &pl->ob->chosen_skill->name : "-" |
|
|
748 | ); |
|
|
749 | #endif |
|
|
750 | |
741 | if (pl->ranged_ob) |
751 | if (pl->ranged_ob) |
742 | buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; |
752 | buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; |
743 | |
753 | |
744 | if (pl->combat_ob) |
754 | if (pl->combat_ob) |
745 | buf << " Combat" << (pl->ob->current_weapon == pl->combat_ob ? "*" : "") << ": " << pl->combat_ob->name; |
755 | buf << " Combat" << (pl->ob->current_weapon == pl->combat_ob ? "*" : "") << ": " << pl->combat_ob->name; |
… | |
… | |
981 | prefetch_surrounding_maps (maptile *map, int distance) |
991 | prefetch_surrounding_maps (maptile *map, int distance) |
982 | { |
992 | { |
983 | map->touch (); |
993 | map->touch (); |
984 | |
994 | |
985 | if (--distance) |
995 | if (--distance) |
986 | for (int dir = 4; --dir; ) |
996 | for (int dir = 4; dir--; ) |
987 | if (const shstr &path = map->tile_path [dir]) |
997 | if (const shstr &path = map->tile_path [dir]) |
988 | if (maptile *&neigh = map->tile_map [dir]) |
998 | if (maptile *&neigh = map->tile_map [dir]) |
989 | prefetch_surrounding_maps (neigh, distance); |
999 | prefetch_surrounding_maps (neigh, distance); |
990 | else |
1000 | else |
991 | neigh = maptile::find_async (path, map); |
1001 | neigh = maptile::find_async (path, map); |
… | |
… | |
1084 | map_clearcell (&lastcell, -1); |
1094 | map_clearcell (&lastcell, -1); |
1085 | } |
1095 | } |
1086 | |
1096 | |
1087 | continue; |
1097 | continue; |
1088 | } |
1098 | } |
1089 | |
1099 | |
1090 | int d = pl->blocked_los_uc (dx, dy); |
1100 | int d = pl->blocked_los_uc (dx, dy); |
1091 | |
1101 | |
1092 | if (d > 3) |
1102 | if (d > 3) |
1093 | { |
1103 | { |
1094 | /* This block deals with spaces that are not visible for whatever |
1104 | /* This block deals with spaces that are not visible for whatever |
… | |
… | |
1279 | |
1289 | |
1280 | if (!pl->ns->monitor_spells) |
1290 | if (!pl->ns->monitor_spells) |
1281 | return; |
1291 | return; |
1282 | |
1292 | |
1283 | for (object *spell = pl->ob->inv; spell; spell = spell->below) |
1293 | for (object *spell = pl->ob->inv; spell; spell = spell->below) |
1284 | { |
|
|
1285 | if (spell->type == SPELL) |
1294 | if (spell->type == SPELL) |
1286 | { |
1295 | { |
1287 | int flags = 0; |
1296 | int flags = 0; |
|
|
1297 | int val; |
1288 | |
1298 | |
1289 | /* check if we need to update it */ |
1299 | /* check if we need to update it */ |
1290 | if (spell->cached_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) |
1300 | val = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
|
|
1301 | if (spell->cached_sp != val) |
1291 | { |
1302 | { |
1292 | spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
1303 | spell->cached_sp = val; |
1293 | flags |= UPD_SP_MANA; |
1304 | flags |= UPD_SP_MANA; |
1294 | } |
1305 | } |
1295 | |
1306 | |
1296 | if (spell->cached_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) |
1307 | val = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
|
|
1308 | if (spell->cached_grace != val) |
1297 | { |
1309 | { |
1298 | spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1310 | spell->cached_grace = val; |
1299 | flags |= UPD_SP_GRACE; |
1311 | flags |= UPD_SP_GRACE; |
1300 | } |
1312 | } |
1301 | |
1313 | |
1302 | if (spell->cached_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) |
1314 | val = casting_level (pl->ob, spell); |
|
|
1315 | if (spell->cached_eat != val) |
1303 | { |
1316 | { |
1304 | spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1317 | spell->cached_eat = val; |
1305 | flags |= UPD_SP_DAMAGE; |
1318 | flags |= UPD_SP_LEVEL; |
1306 | } |
1319 | } |
1307 | |
1320 | |
1308 | if (flags) |
1321 | if (flags) |
1309 | { |
1322 | { |
1310 | packet sl; |
1323 | packet sl; |
1311 | |
1324 | |
1312 | sl << "updspell " |
1325 | sl << "updspell " |
1313 | << uint8 (flags) |
1326 | << uint8 (flags) |
1314 | << uint32 (spell->count); |
1327 | << uint32 (spell->count); |
1315 | |
1328 | |
1316 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp); |
1329 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp); |
1317 | if (flags & UPD_SP_GRACE ) sl << uint16 (spell->cached_grace); |
1330 | if (flags & UPD_SP_GRACE) sl << uint16 (spell->cached_grace); |
1318 | if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->cached_eat); |
1331 | if (flags & UPD_SP_LEVEL) sl << uint16 (spell->cached_eat); |
1319 | |
1332 | |
1320 | pl->ns->send_packet (sl); |
1333 | pl->ns->send_packet (sl); |
1321 | } |
1334 | } |
1322 | } |
1335 | } |
1323 | } |
|
|
1324 | } |
1336 | } |
1325 | |
1337 | |
1326 | void |
1338 | void |
1327 | esrv_remove_spell (player *pl, object *spell) |
1339 | esrv_remove_spell (player *pl, object *spell) |
1328 | { |
1340 | { |
… | |
… | |
1355 | } |
1367 | } |
1356 | |
1368 | |
1357 | /* store costs and damage in the object struct, to compare to later */ |
1369 | /* store costs and damage in the object struct, to compare to later */ |
1358 | spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
1370 | spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
1359 | spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1371 | spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1360 | spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1372 | spell->cached_eat = casting_level (pl->ob, spell); |
1361 | |
1373 | |
1362 | /* figure out which skill it uses, if it uses one */ |
1374 | /* figure out which skill it uses, if it uses one */ |
1363 | if (spell->skill) |
1375 | if (spell->skill) |
1364 | if (object *tmp = pl->find_skill (spell->skill)) |
1376 | if (object *tmp = pl->find_skill (spell->skill)) |
1365 | skill = tmp->subtype + CS_STAT_SKILLINFO; |
1377 | skill = tmp->subtype + CS_STAT_SKILLINFO; |