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 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*/ |
210 | int |
213 | int |
211 | cast_create_food (object *op, object *caster, object *spell_ob, int dir, const char *spellparam) |
214 | cast_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 | |
… | |
… | |
485 | { |
488 | { |
486 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); |
489 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a force starting to build up inside you."); |
487 | return 1; |
490 | return 1; |
488 | } |
491 | } |
489 | |
492 | |
490 | object *dummy = get_archetype (FORCE_NAME); |
493 | object *dummy = archetype::get (FORCE_NAME); |
491 | |
494 | |
492 | int time = max (1, spell_ob->duration - SP_level_duration_adjust (caster, spell_ob)); |
495 | int time = max (1, spell_ob->duration - SP_level_duration_adjust (caster, spell_ob)); |
493 | |
496 | |
494 | /* value of speed really doesn't make much difference, as long as it is |
497 | /* 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 |
498 | * positive. Lower value may be useful so that the problem doesn't |
… | |
… | |
1072 | |
1075 | |
1073 | new_draw_info_format (NDI_UNIQUE, 0, op, |
1076 | 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.>", |
1077 | "You create an aura of magical force. H<The effect will last for about %.10g seconds.>", |
1075 | TICK2TIME (duration)); |
1078 | TICK2TIME (duration)); |
1076 | |
1079 | |
1077 | force = get_archetype (FORCE_NAME); |
1080 | force = archetype::get (FORCE_NAME); |
1078 | force->subtype = FORCE_CHANGE_ABILITY; |
1081 | force->subtype = FORCE_CHANGE_ABILITY; |
1079 | force->duration = duration; |
1082 | force->duration = duration; |
1080 | |
1083 | |
1081 | if (spell_ob->race) |
1084 | if (spell_ob->race) |
1082 | force->name = spell_ob->race; |
1085 | force->name = spell_ob->race; |
… | |
… | |
1186 | } |
1189 | } |
1187 | } |
1190 | } |
1188 | |
1191 | |
1189 | if (force == NULL) |
1192 | if (force == NULL) |
1190 | { |
1193 | { |
1191 | force = get_archetype (FORCE_NAME); |
1194 | force = archetype::get (FORCE_NAME); |
1192 | force->subtype = FORCE_CHANGE_ABILITY; |
1195 | force->subtype = FORCE_CHANGE_ABILITY; |
1193 | if (spell_ob->race) |
1196 | if (spell_ob->race) |
1194 | force->name = spell_ob->race; |
1197 | force->name = spell_ob->race; |
1195 | else |
1198 | else |
1196 | force->name = spell_ob->name; |
1199 | force->name = spell_ob->name; |
… | |
… | |
1257 | |
1260 | |
1258 | /* Alchemy code by Mark Wedel |
1261 | /* Alchemy code by Mark Wedel |
1259 | * |
1262 | * |
1260 | * This code adds a new spell, called alchemy. Alchemy will turn |
1263 | * This code adds a new spell, called alchemy. Alchemy will turn |
1261 | * objects to pyrite ("false gold"), henceforth called gold nuggets. |
1264 | * objects to pyrite ("false gold"), henceforth called gold nuggets. |
1262 | * |
1265 | * |
1263 | * The value of the gold nuggets being about 90% of that of the item |
1266 | * The value of the gold nuggets being about 90% of that of the item |
1264 | * itself. It uses the value of the object before charisma adjustments, |
1267 | * itself. It uses the value of the object before charisma adjustments, |
1265 | * because the nuggets themselves will be will be adjusted by charisma |
1268 | * because the nuggets themselves will be will be adjusted by charisma |
1266 | * when sold. |
1269 | * when sold. |
1267 | * |
1270 | * |
… | |
… | |
1511 | |
1514 | |
1512 | int |
1515 | int |
1513 | cast_detection (object *op, object *caster, object *spell, object *skill) |
1516 | cast_detection (object *op, object *caster, object *spell, object *skill) |
1514 | { |
1517 | { |
1515 | object *tmp, *last, *god, *detect; |
1518 | object *tmp, *last, *god, *detect; |
1516 | int done_one, range, mflags, floor, level; |
1519 | int done_one, range, floor, level; |
1517 | sint16 x, y, nx, ny; |
1520 | sint16 x, y, nx, ny; |
1518 | maptile *m; |
1521 | maptile *m; |
1519 | |
1522 | |
1520 | /* We precompute some values here so that we don't have to keep |
1523 | /* We precompute some values here so that we don't have to keep |
1521 | * doing it over and over again. |
1524 | * doing it over and over again. |
… | |
… | |
2109 | /* Improve weapon's armour value according to best save vs. physical of its material */ |
2112 | /* Improve weapon's armour value according to best save vs. physical of its material */ |
2110 | |
2113 | |
2111 | if (a > 14) |
2114 | if (a > 14) |
2112 | a = 14; |
2115 | a = 14; |
2113 | |
2116 | |
2114 | tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.0 - (float) tmp->resist[ATNR_PHYSICAL]) / (30.0 - 2.0 * a)); |
2117 | tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.f - (float) tmp->resist[ATNR_PHYSICAL]) / (30.f - 2.f * a)); |
2115 | |
2118 | |
2116 | /* Determine golem's speed */ |
2119 | /* Determine golem's speed */ |
2117 | tmp->set_speed (min (3.33, 0.4 + 0.1 * SP_level_range_adjust (caster, spell))); |
2120 | tmp->set_speed (min (3.33f, 0.4f + 0.1f * SP_level_range_adjust (caster, spell))); |
2118 | |
2121 | |
2119 | if (!spell->race) |
2122 | if (!spell->race) |
2120 | { |
2123 | { |
2121 | sprintf (buf, "animated %s", &weapon->name); |
2124 | sprintf (buf, "animated %s", &weapon->name); |
2122 | tmp->name = buf; |
2125 | tmp->name = buf; |