ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_effect.C
(Generate patch)

Comparing deliantra/server/server/spell_effect.C (file contents):
Revision 1.131 by root, Fri Apr 23 04:32:47 2010 UTC vs.
Revision 1.145 by root, Wed Nov 16 23:42:03 2016 UTC

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,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 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.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the Affero GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25#include <global.h> 25#include <global.h>
26#include <object.h> 26#include <object.h>
73 if (!(random_roll (0, 3, op, PREFER_HIGH))) 73 if (!(random_roll (0, 3, op, PREFER_HIGH)))
74 { 74 {
75 op->failmsgf ("The %s vibrates violently, then explodes!", query_name (wand)); 75 op->failmsgf ("The %s vibrates violently, then explodes!", query_name (wand));
76 op->play_sound (sound_find ("ob_explode")); 76 op->play_sound (sound_find ("ob_explode"));
77 wand->destroy (); 77 wand->destroy ();
78 object *tmp = get_archetype (shstr_fireball); 78 object *tmp = archetype::get (shstr_fireball);
79 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; 79 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10;
80 80
81 if (!tmp->stats.dam) 81 if (!tmp->stats.dam)
82 tmp->stats.dam = 1; 82 tmp->stats.dam = 1;
83 83
196 /* Can't get any money for these objects */ 196 /* Can't get any money for these objects */
197 missile->value = 0; 197 missile->value = 0;
198 198
199 missile->set_flag (FLAG_IDENTIFIED); 199 missile->set_flag (FLAG_IDENTIFIED);
200 200
201 if (!cast_create_obj (op, caster, missile, dir) && op->type == PLAYER && !missile->destroyed ()) 201 cast_create_obj (op, caster, missile, dir);
202
203 if (!dir
204 && op->type == PLAYER
205 && !missile->destroyed ())
202 pick_up (op, missile); 206 pick_up (op, missile);
203 207
204 return 1; 208 return 1;
205} 209}
206
207 210
208/* allows the choice of what sort of food object to make. 211/* allows the choice of what sort of food object to make.
209 * If spellparam is NULL, it will create food dependent on level --PeterM*/ 212 * If spellparam is NULL, it will create food dependent on level --PeterM*/
210int 213int
211cast_create_food (object *op, object *caster, object *spell_ob, int dir, const char *spellparam) 214cast_create_food (object *op, object *caster, object *spell_ob, int dir, const char *spellparam)
389 392
390 /* Remove the switch with 90% duplicate code - just handle the differences with 393 /* Remove the switch with 90% duplicate code - just handle the differences with
391 * and if statement or two. 394 * and if statement or two.
392 */ 395 */
393 op->invisible += spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 396 op->invisible += spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
397
394 /* max duration */ 398 /* limit duration */
395 if (op->invisible > 1000) 399 min_it (op->invisible, 1000);
396 op->invisible = 1000;
397 400
398 if (op->type == PLAYER) 401 if (op->type == PLAYER)
399 { 402 {
400 op->contr->invis_race = spell_ob->race; 403 op->contr->invis_race = spell_ob->race;
401 404
402 if (spell_ob->flag [FLAG_MAKE_INVIS]) 405 if (spell_ob->flag [FLAG_MAKE_INVIS])
403 op->contr->tmp_invis = 0; 406 op->contr->tmp_invis = 0;
404 else 407 else
405 op->contr->tmp_invis = 1; 408 op->contr->tmp_invis = 1;
406
407 op->contr->hidden = 0;
408 } 409 }
409 410
410 if (makes_invisible_to (op, op)) 411 if (makes_invisible_to (op, op))
411 new_draw_info (NDI_UNIQUE, 0, op, "You can't see your hands!"); 412 new_draw_info (NDI_UNIQUE, 0, op, "You can't see your hands!");
412 else 413 else
485 { 486 {
486 new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); 487 new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you.");
487 return 1; 488 return 1;
488 } 489 }
489 490
490 object *dummy = get_archetype (FORCE_NAME); 491 object *dummy = archetype::get (FORCE_NAME);
491 492
492 int time = max (1, spell_ob->duration - SP_level_duration_adjust (caster, spell_ob)); 493 int time = max (1, spell_ob->duration - SP_level_duration_adjust (caster, spell_ob));
493 494
494 /* value of speed really doesn't make much difference, as long as it is 495 /* value of speed really doesn't make much difference, as long as it is
495 * positive. Lower value may be useful so that the problem doesn't 496 * positive. Lower value may be useful so that the problem doesn't
1072 1073
1073 new_draw_info_format (NDI_UNIQUE, 0, op, 1074 new_draw_info_format (NDI_UNIQUE, 0, op,
1074 "You create an aura of magical force. H<The effect will last for about %.10g seconds.>", 1075 "You create an aura of magical force. H<The effect will last for about %.10g seconds.>",
1075 TICK2TIME (duration)); 1076 TICK2TIME (duration));
1076 1077
1077 force = get_archetype (FORCE_NAME); 1078 force = archetype::get (FORCE_NAME);
1078 force->subtype = FORCE_CHANGE_ABILITY; 1079 force->subtype = FORCE_CHANGE_ABILITY;
1079 force->duration = duration; 1080 force->duration = duration;
1080 1081
1081 if (spell_ob->race) 1082 if (spell_ob->race)
1082 force->name = spell_ob->race; 1083 force->name = spell_ob->race;
1089 force->speed_left = -1.0; 1090 force->speed_left = -1.0;
1090 force->set_flag (FLAG_APPLIED); 1091 force->set_flag (FLAG_APPLIED);
1091 1092
1092 /* Now start processing the effects. First, protections */ 1093 /* Now start processing the effects. First, protections */
1093 for (i = 0; i < NROFATTACKS; i++) 1094 for (i = 0; i < NROFATTACKS; i++)
1094 {
1095 if (spell_ob->resist[i]) 1095 if (spell_ob->resist[i])
1096 {
1097 force->resist[i] = spell_ob->resist[i] + SP_level_dam_adjust (caster, spell_ob); 1096 force->resist[i] = min (100, spell_ob->resist[i] + SP_level_dam_adjust (caster, spell_ob));
1098 if (force->resist[i] > 100)
1099 force->resist[i] = 100;
1100 }
1101 }
1102 1097
1103 if (spell_ob->stats.hp) 1098 if (spell_ob->stats.hp)
1104 force->stats.hp = spell_ob->stats.hp + SP_level_dam_adjust (caster, spell_ob); 1099 force->stats.hp = spell_ob->stats.hp + SP_level_dam_adjust (caster, spell_ob);
1105 1100
1106 if (tmp->type == PLAYER) 1101 if (tmp->type == PLAYER)
1192 } 1187 }
1193 } 1188 }
1194 1189
1195 if (force == NULL) 1190 if (force == NULL)
1196 { 1191 {
1197 force = get_archetype (FORCE_NAME); 1192 force = archetype::get (FORCE_NAME);
1198 force->subtype = FORCE_CHANGE_ABILITY; 1193 force->subtype = FORCE_CHANGE_ABILITY;
1199 if (spell_ob->race) 1194 if (spell_ob->race)
1200 force->name = spell_ob->race; 1195 force->name = spell_ob->race;
1201 else 1196 else
1202 force->name = spell_ob->name; 1197 force->name = spell_ob->name;
1217 { 1212 {
1218 new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect."); 1213 new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect.");
1219 } 1214 }
1220 return 0; 1215 return 0;
1221 } 1216 }
1217
1222 force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50; 1218 force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50;
1223 force->speed = 1.0; 1219 force->speed = 1.0;
1224 force->speed_left = -1.0; 1220 force->speed_left = -1.0;
1225 force->set_flag (FLAG_APPLIED); 1221 force->set_flag (FLAG_APPLIED);
1226 1222
1262 1258
1263/* Alchemy code by Mark Wedel 1259/* Alchemy code by Mark Wedel
1264 * 1260 *
1265 * This code adds a new spell, called alchemy. Alchemy will turn 1261 * This code adds a new spell, called alchemy. Alchemy will turn
1266 * objects to pyrite ("false gold"), henceforth called gold nuggets. 1262 * objects to pyrite ("false gold"), henceforth called gold nuggets.
1267 * 1263 *
1268 * The value of the gold nuggets being about 90% of that of the item 1264 * The value of the gold nuggets being about 90% of that of the item
1269 * itself. It uses the value of the object before charisma adjustments, 1265 * itself. It uses the value of the object before charisma adjustments,
1270 * because the nuggets themselves will be will be adjusted by charisma 1266 * because the nuggets themselves will be will be adjusted by charisma
1271 * when sold. 1267 * when sold.
1272 * 1268 *
1374 } 1370 }
1375 1371
1376 value -= rndm (value >> 4); 1372 value -= rndm (value >> 4);
1377 value = min (value, value_max); 1373 value = min (value, value_max);
1378 1374
1379 for (int i = 0; i < sizeof (nugget) / sizeof (nugget [0]); ++i) 1375 for (int i = 0; i < array_length (nugget); ++i)
1380 if (int nrof = value / nugget [i]->value) 1376 if (int nrof = value / nugget [i]->value)
1381 { 1377 {
1382 value -= nrof * nugget[i]->value; 1378 value -= nrof * nugget[i]->value;
1383 1379
1384 object *tmp = nugget[i]->instance (); 1380 object *tmp = nugget[i]->instance ();
1402int 1398int
1403remove_curse (object *op, object *caster, object *spell) 1399remove_curse (object *op, object *caster, object *spell)
1404{ 1400{
1405 int success = 0, was_one = 0; 1401 int success = 0, was_one = 0;
1406 1402
1403 int num_uncurse = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell));
1404
1405 op->splay_marked ();
1406
1407 int typeflag = spell->last_sp ? FLAG_DAMNED : FLAG_CURSED;
1408
1407 for (object *tmp = op->inv; tmp; tmp = tmp->below) 1409 for (object *tmp = op->inv; tmp && num_uncurse; tmp = tmp->below)
1408 if (tmp->flag [FLAG_APPLIED] && 1410 if (!tmp->invisible && tmp->flag [typeflag])
1409 ((tmp->flag [FLAG_CURSED] && spell->flag [FLAG_CURSED]) ||
1410 (tmp->flag [FLAG_DAMNED] && spell->flag [FLAG_DAMNED])))
1411 { 1411 {
1412 was_one++; 1412 ++was_one;
1413 1413
1414 if (tmp->level <= casting_level (caster, spell)) 1414 if (tmp->level <= casting_level (caster, spell))
1415 { 1415 {
1416 success++; 1416 ++success;
1417 if (spell->flag [FLAG_DAMNED]) 1417 --num_uncurse;
1418 tmp->clr_flag (FLAG_DAMNED);
1419 1418
1419 tmp->clr_flag (typeflag);
1420 tmp->clr_flag (FLAG_CURSED); 1420 tmp->clr_flag (FLAG_CURSED);
1421 tmp->clr_flag (FLAG_KNOWN_CURSED); 1421 tmp->clr_flag (FLAG_KNOWN_CURSED);
1422 tmp->value = 0; /* Still can't sell it */ 1422 tmp->value = 0; /* Still can't sell it */
1423 1423
1424 if (object *pl = tmp->visible_to ()) 1424 if (object *pl = tmp->visible_to ())
1427 } 1427 }
1428 1428
1429 if (op->type == PLAYER) 1429 if (op->type == PLAYER)
1430 { 1430 {
1431 if (success) 1431 if (success)
1432 new_draw_info (NDI_UNIQUE, 0, op, "You feel like some of your items are looser now."); 1432 new_draw_info (NDI_UNIQUE, 0, op, "You realise that some of your items look shinier now. H<You successfully removed some curses.>");
1433 else 1433 else
1434 { 1434 {
1435 if (was_one) 1435 if (was_one)
1436 new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse."); 1436 new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove any curse. H<The spell was not strong enough.>");
1437 else 1437 else
1438 new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items."); 1438 new_draw_info (NDI_UNIQUE, 0, op, "You are not having any cursed items. H<Epic fail.>");
1439 } 1439 }
1440 } 1440 }
1441 1441
1442 return success; 1442 return success;
1443} 1443}
1444 1444
1445/* Identifies objects in the players inventory/on the ground */ 1445/* Identifies objects in the players inventory/on the ground */
1446int 1446int
1447cast_identify (object *op, object *caster, object *spell) 1447cast_identify (object *op, object *caster, object *spell)
1448{ 1448{
1449 object *tmp;
1450 dynbuf_text &buf = msg_dynbuf; buf.clear (); 1449 dynbuf_text &buf = msg_dynbuf; buf.clear ();
1451 1450
1452 int num_ident = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell)); 1451 int num_ident = max (1, spell->stats.dam + SP_level_dam_adjust (caster, spell));
1453 1452
1453 op->splay_marked ();
1454
1454 for (tmp = op->inv; tmp; tmp = tmp->below) 1455 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1455 { 1456 {
1456 if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && tmp->need_identify ()) 1457 if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && tmp->need_identify ())
1457 { 1458 {
1458 identify (tmp); 1459 identify (tmp);
1459 1460
1474 * stuff on the floor. Only identify stuff on the floor if the spell 1475 * stuff on the floor. Only identify stuff on the floor if the spell
1475 * was not fully used. 1476 * was not fully used.
1476 */ 1477 */
1477 if (num_ident) 1478 if (num_ident)
1478 { 1479 {
1479 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above) 1480 for (object *tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above)
1480 if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && tmp->need_identify ()) 1481 if (!tmp->flag [FLAG_IDENTIFIED] && !tmp->invisible && tmp->need_identify ())
1481 { 1482 {
1482 identify (tmp); 1483 identify (tmp);
1483 1484
1484 if (object *pl = tmp->visible_to ()) 1485 if (object *pl = tmp->visible_to ())
1511 1512
1512int 1513int
1513cast_detection (object *op, object *caster, object *spell, object *skill) 1514cast_detection (object *op, object *caster, object *spell, object *skill)
1514{ 1515{
1515 object *tmp, *last, *god, *detect; 1516 object *tmp, *last, *god, *detect;
1516 int done_one, range, mflags, floor, level; 1517 int done_one, range, floor, level;
1517 sint16 x, y, nx, ny; 1518 sint16 x, y, nx, ny;
1518 maptile *m; 1519 maptile *m;
1519 1520
1520 /* We precompute some values here so that we don't have to keep 1521 /* We precompute some values here so that we don't have to keep
1521 * doing it over and over again. 1522 * doing it over and over again.
2109 /* Improve weapon's armour value according to best save vs. physical of its material */ 2110 /* Improve weapon's armour value according to best save vs. physical of its material */
2110 2111
2111 if (a > 14) 2112 if (a > 14)
2112 a = 14; 2113 a = 14;
2113 2114
2114 tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.0 - (float) tmp->resist[ATNR_PHYSICAL]) / (30.0 - 2.0 * a)); 2115 tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.f - (float) tmp->resist[ATNR_PHYSICAL]) / (30.f - 2.f * a));
2115 2116
2116 /* Determine golem's speed */ 2117 /* Determine golem's speed */
2117 tmp->set_speed (min (3.33, 0.4 + 0.1 * SP_level_range_adjust (caster, spell))); 2118 tmp->set_speed (min (3.33f, 0.4f + 0.1f * SP_level_range_adjust (caster, spell)));
2118 2119
2119 if (!spell->race) 2120 if (!spell->race)
2120 { 2121 {
2121 sprintf (buf, "animated %s", &weapon->name); 2122 sprintf (buf, "animated %s", &weapon->name);
2122 tmp->name = buf; 2123 tmp->name = buf;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines