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.78 by root, Tue Jan 15 12:02:24 2008 UTC vs.
Revision 1.83 by root, Tue May 6 16:55:26 2008 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 Marc Alexander Lehmann / Robin Redeker / the Deliantra 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 * Deliantra 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
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)
466 if (object *pl = op->in_player ()) 465 if (object *pl = op->in_player ())
467 { 466 {
468 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))
469 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.");
470 else 469 else
471 { 470 pl->player_goto (op->slaying, op->stats.hp, op->stats.sp);
472 // remove first so we do not call update_stats
473 op->remove ();
474 pl->enter_exit (op);
475 }
476 } 471 }
477 472
478 op->destroy (); 473 op->destroy ();
479} 474}
480 475
1411 1406
1412bailout: 1407bailout:
1413 return 1; 1408 return 1;
1414} 1409}
1415 1410
1416
1417/* This function removes the cursed/damned status on equipped 1411/* This function removes the cursed/damned status on equipped
1418 * items. 1412 * items.
1419 */ 1413 */
1420int 1414int
1421remove_curse (object *op, object *caster, object *spell) 1415remove_curse (object *op, object *caster, object *spell)
1427 if (QUERY_FLAG (tmp, FLAG_APPLIED) && 1421 if (QUERY_FLAG (tmp, FLAG_APPLIED) &&
1428 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) || 1422 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) ||
1429 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED)))) 1423 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED))))
1430 { 1424 {
1431 was_one++; 1425 was_one++;
1426
1432 if (tmp->level <= caster_level (caster, spell)) 1427 if (tmp->level <= caster_level (caster, spell))
1433 { 1428 {
1434 success++; 1429 success++;
1435 if (QUERY_FLAG (spell, FLAG_DAMNED)) 1430 if (QUERY_FLAG (spell, FLAG_DAMNED))
1436 CLEAR_FLAG (tmp, FLAG_DAMNED); 1431 CLEAR_FLAG (tmp, FLAG_DAMNED);
1437 1432
1438 CLEAR_FLAG (tmp, FLAG_CURSED); 1433 CLEAR_FLAG (tmp, FLAG_CURSED);
1439 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED); 1434 CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED);
1440 tmp->value = 0; /* Still can't sell it */ 1435 tmp->value = 0; /* Still can't sell it */
1441 if (op->type == PLAYER) 1436
1437 if (object *pl = tmp->visible_to ())
1442 esrv_send_item (op, tmp); 1438 esrv_update_item (UPD_FLAGS, pl, tmp);
1443 } 1439 }
1444 } 1440 }
1445 1441
1446 if (op->type == PLAYER) 1442 if (op->type == PLAYER)
1447 { 1443 {
1500 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)
1501 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) 1497 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp))
1502 { 1498 {
1503 identify (tmp); 1499 identify (tmp);
1504 1500
1505 if (op->type == PLAYER) 1501 if (object *pl = tmp->visible_to ())
1506 { 1502 {
1507 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));
1508 1504
1509 if (tmp->msg) 1505 if (tmp->msg)
1510 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";
1511
1512 esrv_send_item (op, tmp);
1513 } 1507 }
1514 1508
1515 num_ident--; 1509 num_ident--;
1516 if (!num_ident) 1510 if (!num_ident)
1517 break; 1511 break;
1680 1674
1681 /* 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 */
1682 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))
1683 { 1677 {
1684 done_one = 0; 1678 done_one = 0;
1679
1685 for (tmp = op->inv; tmp; tmp = tmp->below) 1680 for (tmp = op->inv; tmp; tmp = tmp->below)
1686 { 1681 {
1687 if (!tmp->invisible && !QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 1682 if (!tmp->invisible && !QUERY_FLAG (tmp, FLAG_IDENTIFIED))
1688 { 1683 {
1689 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))
1690 { 1685 {
1691 SET_FLAG (tmp, FLAG_KNOWN_MAGICAL); 1686 SET_FLAG (tmp, FLAG_KNOWN_MAGICAL);
1692 if (op->type == PLAYER) 1687
1688 if (object *pl = tmp->visible_to ())
1693 esrv_send_item (op, tmp); 1689 esrv_update_item (UPD_FLAGS, pl, tmp);
1694 } 1690 }
1691
1695 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) &&
1696 (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))) 1693 (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)))
1697 { 1694 {
1698 SET_FLAG (tmp, FLAG_KNOWN_CURSED); 1695 SET_FLAG (tmp, FLAG_KNOWN_CURSED);
1699 if (op->type == PLAYER) 1696
1697 if (object *pl = tmp->visible_to ())
1700 esrv_send_item (op, tmp); 1698 esrv_update_item (UPD_FLAGS, pl, tmp);
1701 } 1699 }
1702 } /* if item is not identified */ 1700 } /* if item is not identified */
1703 } /* for the players inventory */ 1701 } /* for the players inventory */
1704 } /* if detect magic/curse and object is a player */ 1702 } /* if detect magic/curse and object is a player */
1703
1705 return 1; 1704 return 1;
1706} 1705}
1707 1706
1708 1707
1709/** 1708/**
1899 break; 1898 break;
1900 } 1899 }
1901 } 1900 }
1902} 1901}
1903 1902
1904
1905
1906/* cast_consecrate() - a spell to make an altar your god's */ 1903/* cast_consecrate() - a spell to make an altar your god's */
1907int 1904int
1908cast_consecrate (object *op, object *caster, object *spell) 1905cast_consecrate (object *op, object *caster, object *spell)
1909{ 1906{
1910 char buf[MAX_BUF]; 1907 char buf[MAX_BUF];
1934 /* If we got here, we are consecrating an altar */ 1931 /* If we got here, we are consecrating an altar */
1935 sprintf (buf, "Altar of %s", &god->name); 1932 sprintf (buf, "Altar of %s", &god->name);
1936 tmp->name = buf; 1933 tmp->name = buf;
1937 tmp->level = caster_level (caster, spell); 1934 tmp->level = caster_level (caster, spell);
1938 tmp->other_arch = god->arch; 1935 tmp->other_arch = god->arch;
1936
1939 if (op->type == PLAYER) 1937 if (op->type == PLAYER)
1940 esrv_update_item (UPD_NAME, op, tmp); 1938 esrv_update_item (UPD_NAME, op, tmp);
1939
1941 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);
1942 return 1; 1941 return 1;
1943 } 1942 }
1944 } 1943 }
1945 } 1944 }
2021 { 2020 {
2022 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));
2023 return 0; 2022 return 0;
2024 } 2023 }
2025 2024
2026 if (weapon->nrof > 1) 2025 weapon = weapon->split ();
2027 {
2028 tmp = get_split_ob (weapon, 1);
2029 esrv_send_item (op, weapon);
2030 weapon = tmp;
2031 }
2032 2026
2033 /* create the golem object */ 2027 /* create the golem object */
2034 tmp = arch_to_object (spell->other_arch); 2028 tmp = arch_to_object (spell->other_arch);
2035 2029
2036 /* 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 */
2041 tmp->set_owner (op); 2035 tmp->set_owner (op);
2042 op->contr->golem = tmp; 2036 op->contr->golem = tmp;
2043 set_spell_skill (op, caster, spell, tmp); 2037 set_spell_skill (op, caster, spell, tmp);
2044 2038
2045 /* 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
2046 * removed flag - it should only be set if get_split_object was 2040 * removed flag - it should only be set if weapon->split was
2047 * used above. 2041 * used above.
2048 */ 2042 */
2049 if (!QUERY_FLAG (weapon, FLAG_REMOVED)) 2043 if (!QUERY_FLAG (weapon, FLAG_REMOVED))
2050 weapon->remove (); 2044 weapon->remove ();
2051 2045
2052 insert_ob_in_ob (weapon, tmp); 2046 tmp->insert (weapon);
2053 esrv_send_item (op, weapon); 2047
2054 /* 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,
2055 * 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
2056 * body_info, skills, etc) 2050 * body_info, skills, etc)
2057 */ 2051 */
2058 SET_FLAG (tmp, FLAG_USE_WEAPON); 2052 SET_FLAG (tmp, FLAG_USE_WEAPON);
2276 object *tmp; 2270 object *tmp;
2277 2271
2278 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)
2279 { 2273 {
2280 int atk_lev, def_lev; 2274 int atk_lev, def_lev;
2281 object *victim = tmp; 2275 object *victim = tmp->head_ ();
2282 2276
2283 if (tmp->head)
2284 victim = tmp->head;
2285 if (!QUERY_FLAG (victim, FLAG_MONSTER)) 2277 if (!QUERY_FLAG (victim, FLAG_MONSTER))
2286 continue; 2278 continue;
2279
2287 if (QUERY_FLAG (victim, FLAG_UNAGGRESSIVE)) 2280 if (QUERY_FLAG (victim, FLAG_UNAGGRESSIVE))
2288 continue; 2281 continue;
2282
2289 if (victim->stats.exp == 0) 2283 if (victim->stats.exp == 0)
2290 continue; 2284 continue;
2291 2285
2292 def_lev = MAX (1, victim->level); 2286 def_lev = MAX (1, victim->level);
2293 atk_lev = MAX (1, op->level); 2287 atk_lev = MAX (1, op->level);
2294 2288
2295 if (rndm (0, atk_lev - 1) > def_lev) 2289 if (rndm (0, atk_lev - 1) > def_lev)
2296 { 2290 {
2297 /* make this sucker peaceful. */ 2291 /* make this sucker peaceful. */
2298 2292
2293 INVOKE_OBJECT (KILL, victim, ARG_OBJECT (op));
2299 change_exp (op->owner, victim->stats.exp, op->skill, 0); 2294 change_exp (op->owner, victim->stats.exp, op->skill, 0);
2300 victim->stats.exp = 0; 2295 victim->stats.exp = 0;
2301#if 0 2296#if 0
2302 /* No idea why these were all set to zero - if something 2297 /* No idea why these were all set to zero - if something
2303 * makes this creature agressive, he should still do damage. 2298 * makes this creature agressive, he should still do damage.
2310 victim->attack_movement = RANDO2; 2305 victim->attack_movement = RANDO2;
2311 SET_FLAG (victim, FLAG_UNAGGRESSIVE); 2306 SET_FLAG (victim, FLAG_UNAGGRESSIVE);
2312 SET_FLAG (victim, FLAG_RUN_AWAY); 2307 SET_FLAG (victim, FLAG_RUN_AWAY);
2313 SET_FLAG (victim, FLAG_RANDOM_MOVE); 2308 SET_FLAG (victim, FLAG_RANDOM_MOVE);
2314 CLEAR_FLAG (victim, FLAG_MONSTER); 2309 CLEAR_FLAG (victim, FLAG_MONSTER);
2310
2315 if (victim->name) 2311 if (victim->name)
2316 {
2317 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);
2318 }
2319 } 2313 }
2320 } 2314 }
2321} 2315}
2322 2316
2323 2317

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines