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 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. |
… | |
… | |
1279 | |
1279 | |
1280 | if (!pl->ns->monitor_spells) |
1280 | if (!pl->ns->monitor_spells) |
1281 | return; |
1281 | return; |
1282 | |
1282 | |
1283 | for (object *spell = pl->ob->inv; spell; spell = spell->below) |
1283 | for (object *spell = pl->ob->inv; spell; spell = spell->below) |
1284 | { |
|
|
1285 | if (spell->type == SPELL) |
1284 | if (spell->type == SPELL) |
1286 | { |
1285 | { |
1287 | int flags = 0; |
1286 | int flags = 0; |
|
|
1287 | int val; |
1288 | |
1288 | |
1289 | /* check if we need to update it */ |
1289 | /* check if we need to update it */ |
1290 | if (spell->cached_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) |
1290 | val = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
|
|
1291 | if (spell->cached_sp != val) |
1291 | { |
1292 | { |
1292 | spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); |
1293 | spell->cached_sp = val; |
1293 | flags |= UPD_SP_MANA; |
1294 | flags |= UPD_SP_MANA; |
1294 | } |
1295 | } |
1295 | |
1296 | |
1296 | if (spell->cached_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) |
1297 | val = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
|
|
1298 | if (spell->cached_grace != val) |
1297 | { |
1299 | { |
1298 | spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1300 | spell->cached_grace = val; |
1299 | flags |= UPD_SP_GRACE; |
1301 | flags |= UPD_SP_GRACE; |
1300 | } |
1302 | } |
1301 | |
1303 | |
1302 | if (spell->cached_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) |
1304 | val = casting_level (pl->ob, spell); |
|
|
1305 | if (spell->cached_eat != val) |
1303 | { |
1306 | { |
1304 | spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1307 | spell->cached_eat = val; |
1305 | flags |= UPD_SP_DAMAGE; |
1308 | flags |= UPD_SP_LEVEL; |
1306 | } |
1309 | } |
1307 | |
1310 | |
1308 | if (flags) |
1311 | if (flags) |
1309 | { |
1312 | { |
1310 | packet sl; |
1313 | packet sl; |
1311 | |
1314 | |
1312 | sl << "updspell " |
1315 | sl << "updspell " |
1313 | << uint8 (flags) |
1316 | << uint8 (flags) |
1314 | << uint32 (spell->count); |
1317 | << uint32 (spell->count); |
1315 | |
1318 | |
1316 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp); |
1319 | if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp); |
1317 | if (flags & UPD_SP_GRACE ) sl << uint16 (spell->cached_grace); |
1320 | if (flags & UPD_SP_GRACE) sl << uint16 (spell->cached_grace); |
1318 | if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->cached_eat); |
1321 | if (flags & UPD_SP_LEVEL) sl << uint16 (spell->cached_eat); |
1319 | |
1322 | |
1320 | pl->ns->send_packet (sl); |
1323 | pl->ns->send_packet (sl); |
1321 | } |
1324 | } |
1322 | } |
1325 | } |
1323 | } |
|
|
1324 | } |
1326 | } |
1325 | |
1327 | |
1326 | void |
1328 | void |
1327 | esrv_remove_spell (player *pl, object *spell) |
1329 | esrv_remove_spell (player *pl, object *spell) |
1328 | { |
1330 | { |
… | |
… | |
1355 | } |
1357 | } |
1356 | |
1358 | |
1357 | /* store costs and damage in the object struct, to compare to later */ |
1359 | /* 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); |
1360 | 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); |
1361 | 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); |
1362 | spell->cached_eat = casting_level (pl->ob, spell); |
1361 | |
1363 | |
1362 | /* figure out which skill it uses, if it uses one */ |
1364 | /* figure out which skill it uses, if it uses one */ |
1363 | if (spell->skill) |
1365 | if (spell->skill) |
1364 | if (object *tmp = pl->find_skill (spell->skill)) |
1366 | if (object *tmp = pl->find_skill (spell->skill)) |
1365 | skill = tmp->subtype + CS_STAT_SKILLINFO; |
1367 | skill = tmp->subtype + CS_STAT_SKILLINFO; |