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