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.73 by root, Sat Sep 1 08:03:46 2007 UTC vs.
Revision 1.83 by root, Tue May 6 16:55:26 2008 UTC

1/* 1/*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Crossfire TRT is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your 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,
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 GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24#include <global.h> 24#include <global.h>
25#include <object.h> 25#include <object.h>
26#include <living.h> 26#include <living.h>
70 } 70 }
71 if (!(random_roll (0, 3, op, PREFER_HIGH))) 71 if (!(random_roll (0, 3, op, PREFER_HIGH)))
72 { 72 {
73 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand)); 73 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand));
74 op->play_sound (sound_find ("ob_explode")); 74 op->play_sound (sound_find ("ob_explode"));
75 esrv_del_item (op->contr, wand->count);
76 wand->destroy (); 75 wand->destroy ();
77 tmp = get_archetype ("fireball"); 76 tmp = get_archetype ("fireball");
78 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; 77 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10;
79 78
80 if (!tmp->stats.dam) 79 if (!tmp->stats.dam)
125 * create nonnmagic arrows, or even -1, etc... 124 * create nonnmagic arrows, or even -1, etc...
126 */ 125 */
127int 126int
128cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg) 127cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg)
129{ 128{
130 int missile_plus = 0, bonus_plus = 0; 129 int bonus_plus = 0;
131 const char *missile_name; 130 const char *missile_name = "arrow";
132 object *tmp, *missile;
133 131
134 missile_name = "arrow";
135
136 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 132 for (object *tmp = op->inv; tmp; tmp = tmp->below)
137 if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) 133 if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED))
138 missile_name = tmp->race; 134 missile_name = tmp->race;
139 135
140 missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell); 136 int missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell);
141 137
142 if (archetype::find (missile_name) == NULL) 138 archetype *missile_arch = archetype::find (missile_name);
139
140 if (!missile_arch)
143 { 141 {
144 LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name); 142 LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name);
145 return 0; 143 return 0;
146 } 144 }
147 145
148 missile = get_archetype (missile_name); 146 object *missile = missile_arch->instance ();
149 147
150 if (stringarg) 148 if (stringarg)
151 { 149 {
152 /* If it starts with a letter, presume it is a description */ 150 /* If it starts with a letter, presume it is a description */
153 if (isalpha (*stringarg)) 151 if (isalpha (*stringarg))
171 new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); 169 new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg);
172 return 0; 170 return 0;
173 } 171 }
174 172
175 give_artifact_abilities (missile, al->item); 173 give_artifact_abilities (missile, al->item);
176 /* These special arrows cost something extra. Don't have them also be magical - 174 /* These special arrows cost something extra. Don't have them also be magical -
177 * otherwise, in most cases, not enough will be created. I don't want to get into 175 * otherwise, in most cases, not enough will be created. I don't want to get into
178 * the parsing of having to do both plus and type. 176 * the parsing of having to do both plus and type.
179 */ 177 */
180 bonus_plus = 1 + (al->item->value / 5); 178 bonus_plus = 1 + (al->item->value / 5);
181 missile_plus = 0; 179 missile_plus = 0;
182 } 180 }
183 else if (atoi (stringarg) < missile_plus) 181 else if (atoi (stringarg) < missile_plus)
184 missile_plus = atoi (stringarg); 182 missile_plus = atoi (stringarg);
185 } 183 }
186 184
187 if (missile_plus > 4) 185 missile_plus = clamp (missile_plus, -4, 4);
188 missile_plus = 4;
189 else if (missile_plus < -4)
190 missile_plus = -4;
191 186
192 missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell); 187 missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell);
193 missile->nrof -= 3 * (missile_plus + bonus_plus); 188 missile->nrof -= 3 * (missile_plus + bonus_plus);
194 189
195 if (missile->nrof < 1) 190 if (missile->nrof < 1)
215{ 210{
216 int food_value; 211 int food_value;
217 archetype *at = NULL; 212 archetype *at = NULL;
218 object *new_op; 213 object *new_op;
219 214
220 food_value = spell_ob->stats.food + +50 * SP_level_duration_adjust (caster, spell_ob); 215 food_value = spell_ob->stats.food + 50 * SP_level_duration_adjust (caster, spell_ob);
221 216
222 if (stringarg) 217 if (stringarg)
223 { 218 {
224 at = find_archetype_by_object_type_name (FOOD, stringarg); 219 at = find_archetype_by_object_type_name (FOOD, stringarg);
225 if (at == NULL) 220 if (at == NULL)
284{ 279{
285 int r, mflags, maxrange; 280 int r, mflags, maxrange;
286 object *tmp; 281 object *tmp;
287 maptile *m; 282 maptile *m;
288 283
289
290 if (!dir) 284 if (!dir)
291 { 285 {
292 examine_monster (op, op); 286 examine_monster (op, op);
293 return 1; 287 return 1;
294 } 288 }
471 if (object *pl = op->in_player ()) 465 if (object *pl = op->in_player ())
472 { 466 {
473 if (pl->ms ().flags () & P_NO_CLERIC && !QUERY_FLAG (pl, FLAG_WIZCAST)) 467 if (pl->ms ().flags () & P_NO_CLERIC && !QUERY_FLAG (pl, FLAG_WIZCAST))
474 new_draw_info (NDI_UNIQUE, 0, pl, "You feel something fizzle inside you."); 468 new_draw_info (NDI_UNIQUE, 0, pl, "You feel something fizzle inside you.");
475 else 469 else
476 { 470 pl->player_goto (op->slaying, op->stats.hp, op->stats.sp);
477 // remove first so we do not call update_stats
478 op->remove ();
479 pl->enter_exit (op);
480 }
481 } 471 }
482 472
483 op->destroy (); 473 op->destroy ();
484} 474}
485 475
1299static void 1289static void
1300alchemy_object (object *obj, uint64 &total_value, int &total_weight) 1290alchemy_object (object *obj, uint64 &total_value, int &total_weight)
1301{ 1291{
1302 uint64 value = query_cost (obj, NULL, F_TRUE); 1292 uint64 value = query_cost (obj, NULL, F_TRUE);
1303 1293
1304 /* Give third price when we alchemy money (This should hopefully 1294 /* Give third price when we alchemy money (this should hopefully
1305 * make it so that it isn't worth it to alchemy money, sell 1295 * make it so that it isn't worth it to alchemy money, sell
1306 * the nuggets, alchemy the gold from that, etc. 1296 * the nuggets, alchemy the gold from that, etc.
1307 * Otherwise, give 9 silver on the gold for other objects, 1297 * Otherwise, give 9 silver on the gold for other objects,
1308 * so that it would still be more affordable to haul 1298 * so that it would still be more affordable to haul
1309 * the stuff back to town. 1299 * the stuff back to town.
1416 1406
1417bailout: 1407bailout:
1418 return 1; 1408 return 1;
1419} 1409}
1420 1410
1421
1422/* This function removes the cursed/damned status on equipped 1411/* This function removes the cursed/damned status on equipped
1423 * items. 1412 * items.
1424 */ 1413 */
1425int 1414int
1426remove_curse (object *op, object *caster, object *spell) 1415remove_curse (object *op, object *caster, object *spell)
1432 if (QUERY_FLAG (tmp, FLAG_APPLIED) && 1421 if (QUERY_FLAG (tmp, FLAG_APPLIED) &&
1433 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) || 1422 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) ||
1434 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED)))) 1423 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED))))
1435 { 1424 {
1436 was_one++; 1425 was_one++;
1426
1437 if (tmp->level <= caster_level (caster, spell)) 1427 if (tmp->level <= caster_level (caster, spell))
1438 { 1428 {
1439 success++; 1429 success++;
1440 if (QUERY_FLAG (spell, FLAG_DAMNED)) 1430 if (QUERY_FLAG (spell, FLAG_DAMNED))
1441 CLEAR_FLAG (tmp, FLAG_DAMNED); 1431 CLEAR_FLAG (tmp, FLAG_DAMNED);
1442 1432
1443 CLEAR_FLAG (tmp, FLAG_CURSED); 1433 CLEAR_FLAG (tmp, FLAG_CURSED);
1444 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED); 1434 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED);
1445 tmp->value = 0; /* Still can't sell it */ 1435 tmp->value = 0; /* Still can't sell it */
1446 if (op->type == PLAYER) 1436
1437 if (object *pl = tmp->visible_to ())
1447 esrv_send_item (op, tmp); 1438 esrv_update_item (UPD_FLAGS, pl, tmp);
1448 } 1439 }
1449 } 1440 }
1450 1441
1451 if (op->type == PLAYER) 1442 if (op->type == PLAYER)
1452 { 1443 {
1505 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above) 1496 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above)
1506 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) 1497 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp))
1507 { 1498 {
1508 identify (tmp); 1499 identify (tmp);
1509 1500
1510 if (op->type == PLAYER) 1501 if (object *pl = tmp->visible_to ())
1511 { 1502 {
1512 buf.printf ("On the ground you identified: %s.\n\n", long_desc (tmp, op)); 1503 buf.printf ("On the ground you identified: %s.\n\n", long_desc (tmp, op));
1513 1504
1514 if (tmp->msg) 1505 if (tmp->msg)
1515 buf << "The item has a story:\n\n" << tmp->msg << "\n\n"; 1506 buf << "The item has a story:\n\n" << tmp->msg << "\n\n";
1516
1517 esrv_send_item (op, tmp);
1518 } 1507 }
1519 1508
1520 num_ident--; 1509 num_ident--;
1521 if (!num_ident) 1510 if (!num_ident)
1522 break; 1511 break;
1685 1674
1686 /* Now process objects in the players inventory if detect curse or magic */ 1675 /* Now process objects in the players inventory if detect curse or magic */
1687 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) || QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL)) 1676 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) || QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL))
1688 { 1677 {
1689 done_one = 0; 1678 done_one = 0;
1679
1690 for (tmp = op->inv; tmp; tmp = tmp->below) 1680 for (tmp = op->inv; tmp; tmp = tmp->below)
1691 { 1681 {
1692 if (!tmp->invisible && !QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 1682 if (!tmp->invisible && !QUERY_FLAG (tmp, FLAG_IDENTIFIED))
1693 { 1683 {
1694 if (QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL) && is_magical (tmp) && !QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL)) 1684 if (QUERY_FLAG (spell, FLAG_KNOWN_MAGICAL) && is_magical (tmp) && !QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL))
1695 { 1685 {
1696 SET_FLAG (tmp, FLAG_KNOWN_MAGICAL); 1686 SET_FLAG (tmp, FLAG_KNOWN_MAGICAL);
1697 if (op->type == PLAYER) 1687
1688 if (object *pl = tmp->visible_to ())
1698 esrv_send_item (op, tmp); 1689 esrv_update_item (UPD_FLAGS, pl, tmp);
1699 } 1690 }
1691
1700 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) && 1692 if (QUERY_FLAG (spell, FLAG_KNOWN_CURSED) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED) &&
1701 (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))) 1693 (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)))
1702 { 1694 {
1703 SET_FLAG (tmp, FLAG_KNOWN_CURSED); 1695 SET_FLAG (tmp, FLAG_KNOWN_CURSED);
1704 if (op->type == PLAYER) 1696
1697 if (object *pl = tmp->visible_to ())
1705 esrv_send_item (op, tmp); 1698 esrv_update_item (UPD_FLAGS, pl, tmp);
1706 } 1699 }
1707 } /* if item is not identified */ 1700 } /* if item is not identified */
1708 } /* for the players inventory */ 1701 } /* for the players inventory */
1709 } /* if detect magic/curse and object is a player */ 1702 } /* if detect magic/curse and object is a player */
1703
1710 return 1; 1704 return 1;
1711} 1705}
1712 1706
1713 1707
1714/** 1708/**
1904 break; 1898 break;
1905 } 1899 }
1906 } 1900 }
1907} 1901}
1908 1902
1909
1910
1911/* cast_consecrate() - a spell to make an altar your god's */ 1903/* cast_consecrate() - a spell to make an altar your god's */
1912int 1904int
1913cast_consecrate (object *op, object *caster, object *spell) 1905cast_consecrate (object *op, object *caster, object *spell)
1914{ 1906{
1915 char buf[MAX_BUF]; 1907 char buf[MAX_BUF];
1939 /* If we got here, we are consecrating an altar */ 1931 /* If we got here, we are consecrating an altar */
1940 sprintf (buf, "Altar of %s", &god->name); 1932 sprintf (buf, "Altar of %s", &god->name);
1941 tmp->name = buf; 1933 tmp->name = buf;
1942 tmp->level = caster_level (caster, spell); 1934 tmp->level = caster_level (caster, spell);
1943 tmp->other_arch = god->arch; 1935 tmp->other_arch = god->arch;
1936
1944 if (op->type == PLAYER) 1937 if (op->type == PLAYER)
1945 esrv_update_item (UPD_NAME, op, tmp); 1938 esrv_update_item (UPD_NAME, op, tmp);
1939
1946 new_draw_info_format (NDI_UNIQUE, 0, op, "You consecrated the altar to %s!", &god->name); 1940 new_draw_info_format (NDI_UNIQUE, 0, op, "You consecrated the altar to %s!", &god->name);
1947 return 1; 1941 return 1;
1948 } 1942 }
1949 } 1943 }
1950 } 1944 }
2026 { 2020 {
2027 new_draw_info_format (NDI_BLACK, 0, op, "You need to unequip %s before using it in this spell", query_name (weapon)); 2021 new_draw_info_format (NDI_BLACK, 0, op, "You need to unequip %s before using it in this spell", query_name (weapon));
2028 return 0; 2022 return 0;
2029 } 2023 }
2030 2024
2031 if (weapon->nrof > 1) 2025 weapon = weapon->split ();
2032 {
2033 tmp = get_split_ob (weapon, 1);
2034 esrv_send_item (op, weapon);
2035 weapon = tmp;
2036 }
2037 2026
2038 /* create the golem object */ 2027 /* create the golem object */
2039 tmp = arch_to_object (spell->other_arch); 2028 tmp = arch_to_object (spell->other_arch);
2040 2029
2041 /* if animated by a player, give the player control of the golem */ 2030 /* if animated by a player, give the player control of the golem */
2046 tmp->set_owner (op); 2035 tmp->set_owner (op);
2047 op->contr->golem = tmp; 2036 op->contr->golem = tmp;
2048 set_spell_skill (op, caster, spell, tmp); 2037 set_spell_skill (op, caster, spell, tmp);
2049 2038
2050 /* Give the weapon to the golem now. A bit of a hack to check the 2039 /* Give the weapon to the golem now. A bit of a hack to check the
2051 * removed flag - it should only be set if get_split_object was 2040 * removed flag - it should only be set if weapon->split was
2052 * used above. 2041 * used above.
2053 */ 2042 */
2054 if (!QUERY_FLAG (weapon, FLAG_REMOVED)) 2043 if (!QUERY_FLAG (weapon, FLAG_REMOVED))
2055 weapon->remove (); 2044 weapon->remove ();
2056 2045
2057 insert_ob_in_ob (weapon, tmp); 2046 tmp->insert (weapon);
2058 esrv_send_item (op, weapon); 2047
2059 /* To do everything necessary to let a golem use the weapon is a pain, 2048 /* To do everything necessary to let a golem use the weapon is a pain,
2060 * so instead, just set it as equipped (otherwise, we need to update 2049 * so instead, just set it as equipped (otherwise, we need to update
2061 * body_info, skills, etc) 2050 * body_info, skills, etc)
2062 */ 2051 */
2063 SET_FLAG (tmp, FLAG_USE_WEAPON); 2052 SET_FLAG (tmp, FLAG_USE_WEAPON);
2281 object *tmp; 2270 object *tmp;
2282 2271
2283 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 2272 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
2284 { 2273 {
2285 int atk_lev, def_lev; 2274 int atk_lev, def_lev;
2286 object *victim = tmp; 2275 object *victim = tmp->head_ ();
2287 2276
2288 if (tmp->head)
2289 victim = tmp->head;
2290 if (!QUERY_FLAG (victim, FLAG_MONSTER)) 2277 if (!QUERY_FLAG (victim, FLAG_MONSTER))
2291 continue; 2278 continue;
2279
2292 if (QUERY_FLAG (victim, FLAG_UNAGGRESSIVE)) 2280 if (QUERY_FLAG (victim, FLAG_UNAGGRESSIVE))
2293 continue; 2281 continue;
2282
2294 if (victim->stats.exp == 0) 2283 if (victim->stats.exp == 0)
2295 continue; 2284 continue;
2296 2285
2297 def_lev = MAX (1, victim->level); 2286 def_lev = MAX (1, victim->level);
2298 atk_lev = MAX (1, op->level); 2287 atk_lev = MAX (1, op->level);
2299 2288
2300 if (rndm (0, atk_lev - 1) > def_lev) 2289 if (rndm (0, atk_lev - 1) > def_lev)
2301 { 2290 {
2302 /* make this sucker peaceful. */ 2291 /* make this sucker peaceful. */
2303 2292
2293 INVOKE_OBJECT (KILL, victim, ARG_OBJECT (op));
2304 change_exp (op->owner, victim->stats.exp, op->skill, 0); 2294 change_exp (op->owner, victim->stats.exp, op->skill, 0);
2305 victim->stats.exp = 0; 2295 victim->stats.exp = 0;
2306#if 0 2296#if 0
2307 /* No idea why these were all set to zero - if something 2297 /* No idea why these were all set to zero - if something
2308 * makes this creature agressive, he should still do damage. 2298 * makes this creature agressive, he should still do damage.
2315 victim->attack_movement = RANDO2; 2305 victim->attack_movement = RANDO2;
2316 SET_FLAG (victim, FLAG_UNAGGRESSIVE); 2306 SET_FLAG (victim, FLAG_UNAGGRESSIVE);
2317 SET_FLAG (victim, FLAG_RUN_AWAY); 2307 SET_FLAG (victim, FLAG_RUN_AWAY);
2318 SET_FLAG (victim, FLAG_RANDOM_MOVE); 2308 SET_FLAG (victim, FLAG_RANDOM_MOVE);
2319 CLEAR_FLAG (victim, FLAG_MONSTER); 2309 CLEAR_FLAG (victim, FLAG_MONSTER);
2310
2320 if (victim->name) 2311 if (victim->name)
2321 {
2322 new_draw_info_format (NDI_UNIQUE, 0, op->owner, "%s no longer feels like fighting.", &victim->name); 2312 new_draw_info_format (NDI_UNIQUE, 0, op->owner, "%s no longer feels like fighting.", &victim->name);
2323 }
2324 } 2313 }
2325 } 2314 }
2326} 2315}
2327 2316
2328 2317

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines