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. |
… | |
… | |
735 | */ |
735 | */ |
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 | |
|
|
741 | printf ("%s %s => %s (%s)\n",//D |
|
|
742 | pl->ranged_ob ? &pl->ranged_ob->name : "-", |
|
|
743 | pl->combat_ob ? &pl->combat_ob->name : "-", |
|
|
744 | pl->ob->current_weapon ? &pl->ob->current_weapon->name : "-", |
|
|
745 | pl->ob->chosen_skill ? &pl->ob->chosen_skill->name : "-" |
|
|
746 | ); |
740 | |
747 | |
741 | if (pl->ranged_ob) |
748 | if (pl->ranged_ob) |
742 | buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; |
749 | buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; |
743 | |
750 | |
744 | if (pl->combat_ob) |
751 | if (pl->combat_ob) |
… | |
… | |
1279 | |
1286 | |
1280 | if (!pl->ns->monitor_spells) |
1287 | if (!pl->ns->monitor_spells) |
1281 | return; |
1288 | return; |
1282 | |
1289 | |
1283 | for (object *spell = pl->ob->inv; spell; spell = spell->below) |
1290 | for (object *spell = pl->ob->inv; spell; spell = spell->below) |
1284 | { |
|
|
1285 | if (spell->type == SPELL) |
1291 | if (spell->type == SPELL) |
1286 | { |
1292 | { |
1287 | int flags = 0; |
1293 | int flags = 0; |
|
|
1294 | int val; |
1288 | |
1295 | |
1289 | /* check if we need to update it */ |
1296 | /* check if we need to update it */ |
1290 | if (spell->cached_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) |
1297 | val = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
|
|
1298 | if (spell->cached_sp != val) |
1291 | { |
1299 | { |
1292 | spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
1300 | spell->cached_sp = val; |
1293 | flags |= UPD_SP_MANA; |
1301 | flags |= UPD_SP_MANA; |
1294 | } |
1302 | } |
1295 | |
1303 | |
1296 | if (spell->cached_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) |
1304 | val = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
|
|
1305 | if (spell->cached_grace != val) |
1297 | { |
1306 | { |
1298 | spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1307 | spell->cached_grace = val; |
1299 | flags |= UPD_SP_GRACE; |
1308 | flags |= UPD_SP_GRACE; |
1300 | } |
1309 | } |
1301 | |
1310 | |
1302 | if (spell->cached_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) |
1311 | val = casting_level (pl->ob, spell); |
|
|
1312 | if (spell->cached_eat != val) |
1303 | { |
1313 | { |
1304 | spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1314 | spell->cached_eat = val; |
1305 | flags |= UPD_SP_DAMAGE; |
1315 | flags |= UPD_SP_LEVEL; |
1306 | } |
1316 | } |
1307 | |
1317 | |
1308 | if (flags) |
1318 | if (flags) |
1309 | { |
1319 | { |
1310 | packet sl; |
1320 | packet sl; |
1311 | |
1321 | |
1312 | sl << "updspell " |
1322 | sl << "updspell " |
1313 | << uint8 (flags) |
1323 | << uint8 (flags) |
1314 | << uint32 (spell->count); |
1324 | << uint32 (spell->count); |
1315 | |
1325 | |
1316 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp); |
1326 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp); |
1317 | if (flags & UPD_SP_GRACE ) sl << uint16 (spell->cached_grace); |
1327 | if (flags & UPD_SP_GRACE) sl << uint16 (spell->cached_grace); |
1318 | if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->cached_eat); |
1328 | if (flags & UPD_SP_LEVEL) sl << uint16 (spell->cached_eat); |
1319 | |
1329 | |
1320 | pl->ns->send_packet (sl); |
1330 | pl->ns->send_packet (sl); |
1321 | } |
1331 | } |
1322 | } |
1332 | } |
1323 | } |
|
|
1324 | } |
1333 | } |
1325 | |
1334 | |
1326 | void |
1335 | void |
1327 | esrv_remove_spell (player *pl, object *spell) |
1336 | esrv_remove_spell (player *pl, object *spell) |
1328 | { |
1337 | { |
… | |
… | |
1355 | } |
1364 | } |
1356 | |
1365 | |
1357 | /* store costs and damage in the object struct, to compare to later */ |
1366 | /* 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); |
1367 | 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); |
1368 | 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); |
1369 | spell->cached_eat = casting_level (pl->ob, spell); |
1361 | |
1370 | |
1362 | /* figure out which skill it uses, if it uses one */ |
1371 | /* figure out which skill it uses, if it uses one */ |
1363 | if (spell->skill) |
1372 | if (spell->skill) |
1364 | if (object *tmp = pl->find_skill (spell->skill)) |
1373 | if (object *tmp = pl->find_skill (spell->skill)) |
1365 | skill = tmp->subtype + CS_STAT_SKILLINFO; |
1374 | skill = tmp->subtype + CS_STAT_SKILLINFO; |