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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002-2003,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002-2003 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 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. |
… | |
… | |
93 | * also be safe for objects. |
93 | * also be safe for objects. |
94 | * This does return if successful or not, but |
94 | * This does return if successful or not, but |
95 | * I don't see us doing anything useful with that information |
95 | * I don't see us doing anything useful with that information |
96 | * right now. |
96 | * right now. |
97 | */ |
97 | */ |
98 | move_object (tmp, absdir (op->stats.sp)); |
98 | tmp->move (absdir (op->stats.sp)); |
99 | } |
99 | } |
100 | |
100 | |
101 | } |
101 | } |
102 | } |
102 | } |
103 | |
103 | |
… | |
… | |
277 | int mflags; |
277 | int mflags; |
278 | |
278 | |
279 | if (!spob->other_arch) |
279 | if (!spob->other_arch) |
280 | return 0; |
280 | return 0; |
281 | |
281 | |
282 | tmp = arch_to_object (spob->other_arch); |
282 | tmp = spob->other_arch->instance (); |
283 | if (tmp == NULL) |
283 | if (tmp == NULL) |
284 | return 0; |
284 | return 0; |
285 | |
285 | |
286 | /* peterm: level dependency for bolts */ |
286 | /* peterm: level dependency for bolts */ |
287 | tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob); |
287 | tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob); |
… | |
… | |
439 | if (op->destroyed ()) |
439 | if (op->destroyed ()) |
440 | return; |
440 | return; |
441 | } |
441 | } |
442 | |
442 | |
443 | /* other_arch contains what this explodes into */ |
443 | /* other_arch contains what this explodes into */ |
444 | tmp = arch_to_object (op->other_arch); |
444 | tmp = op->other_arch->instance (); |
445 | |
445 | |
446 | tmp->set_owner (op); |
446 | tmp->set_owner (op); |
447 | tmp->skill = op->skill; |
447 | tmp->skill = op->skill; |
448 | |
448 | |
449 | owner = op->owner; |
449 | owner = op->owner; |
… | |
… | |
660 | return 0; |
660 | return 0; |
661 | } |
661 | } |
662 | |
662 | |
663 | tmp->map = newmap; |
663 | tmp->map = newmap; |
664 | |
664 | |
|
|
665 | // in case the bullet has direction 0 we explode it in place. |
|
|
666 | // direction 0 is possible for instance when a poison cloud trap springs. |
|
|
667 | if (tmp->direction == 0) |
|
|
668 | { |
|
|
669 | if (tmp->other_arch |
|
|
670 | && (tmp = tmp->insert_at (tmp, op))) // insert before explode cleanly |
|
|
671 | explode_bullet (tmp); // explode object will/should remove tmp |
|
|
672 | else |
|
|
673 | tmp->destroy (); |
|
|
674 | |
|
|
675 | return 0; |
|
|
676 | } |
|
|
677 | |
665 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
678 | if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) |
666 | { |
679 | { |
667 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
680 | if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) |
668 | { |
681 | { |
669 | tmp->destroy (); |
682 | tmp->destroy (); |
… | |
… | |
690 | |
703 | |
691 | /* drops an object based on what is in the cone's "other_arch" */ |
704 | /* drops an object based on what is in the cone's "other_arch" */ |
692 | static void |
705 | static void |
693 | cone_drop (object *op) |
706 | cone_drop (object *op) |
694 | { |
707 | { |
695 | object *new_ob = arch_to_object (op->other_arch); |
708 | object *new_ob = op->other_arch->instance (); |
696 | |
709 | |
697 | new_ob->level = op->level; |
710 | new_ob->level = op->level; |
698 | new_ob->set_owner (op->owner); |
711 | new_ob->set_owner (op->owner); |
699 | |
712 | |
700 | /* preserve skill ownership */ |
713 | /* preserve skill ownership */ |
… | |
… | |
861 | |
874 | |
862 | if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype) |
875 | if ((movetype & GET_MAP_MOVE_BLOCK (m, sx, sy)) == movetype) |
863 | continue; |
876 | continue; |
864 | |
877 | |
865 | success = 1; |
878 | success = 1; |
866 | tmp = arch_to_object (spell->other_arch); |
879 | tmp = spell->other_arch->instance (); |
867 | tmp->set_owner (op); |
880 | tmp->set_owner (op); |
868 | set_spell_skill (op, caster, spell, tmp); |
881 | set_spell_skill (op, caster, spell, tmp); |
869 | tmp->level = casting_level (caster, spell); |
882 | tmp->level = casting_level (caster, spell); |
870 | tmp->attacktype = spell->attacktype; |
883 | tmp->attacktype = spell->attacktype; |
871 | |
884 | |
… | |
… | |
973 | for (int i = 1; i < 9; i++) |
986 | for (int i = 1; i < 9; i++) |
974 | { |
987 | { |
975 | if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) |
988 | if (out_of_map (op->map, op->x + freearr_x[i], op->y + freearr_x[i])) |
976 | continue; |
989 | continue; |
977 | |
990 | |
978 | object *tmp = arch_to_object (at); |
991 | object *tmp = at->instance (); |
979 | tmp->direction = i; |
992 | tmp->direction = i; |
980 | tmp->range = op->range; |
993 | tmp->range = op->range; |
981 | tmp->stats.dam = op->stats.dam; |
994 | tmp->stats.dam = op->stats.dam; |
982 | tmp->duration = op->duration; |
995 | tmp->duration = op->duration; |
983 | tmp->attacktype = op->attacktype; |
996 | tmp->attacktype = op->attacktype; |
… | |
… | |
1017 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1030 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1018 | return 0; |
1031 | return 0; |
1019 | } |
1032 | } |
1020 | } |
1033 | } |
1021 | |
1034 | |
1022 | tmp = arch_to_object (spell->other_arch); |
1035 | tmp = spell->other_arch->instance (); |
1023 | |
1036 | |
1024 | /* level dependencies for bomb */ |
1037 | /* level dependencies for bomb */ |
1025 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
1038 | tmp->range = spell->range + SP_level_range_adjust (caster, spell); |
1026 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1039 | tmp->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); |
1027 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
1040 | tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); |
… | |
… | |
1121 | new_draw_info (NDI_UNIQUE, 0, op, "Your request is unheeded."); |
1134 | new_draw_info (NDI_UNIQUE, 0, op, "Your request is unheeded."); |
1122 | return 0; |
1135 | return 0; |
1123 | } |
1136 | } |
1124 | |
1137 | |
1125 | if (spell->other_arch) |
1138 | if (spell->other_arch) |
1126 | effect = arch_to_object (spell->other_arch); |
1139 | effect = spell->other_arch->instance (); |
1127 | else |
1140 | else |
1128 | return 0; |
1141 | return 0; |
1129 | |
1142 | |
1130 | /* tailor the effect by priest level and worshipped God */ |
1143 | /* tailor the effect by priest level and worshipped God */ |
1131 | effect->level = casting_level (caster, spell); |
1144 | effect->level = casting_level (caster, spell); |
… | |
… | |
1287 | else |
1300 | else |
1288 | op->skill = 0; |
1301 | op->skill = 0; |
1289 | |
1302 | |
1290 | op->change_skill (find_skill_by_name (op, op->skill)); |
1303 | op->change_skill (find_skill_by_name (op, op->skill)); |
1291 | |
1304 | |
|
|
1305 | dynbuf buf; |
1292 | unordered_mapwalk (op, -range, -range, range, range) |
1306 | unordered_mapwalk (buf, op, -range, -range, range, range) |
1293 | { |
1307 | { |
1294 | mapspace &ms = m->at (nx, ny); |
1308 | mapspace &ms = m->at (nx, ny); |
1295 | |
1309 | |
1296 | if (ms.flags () & P_IS_ALIVE) |
1310 | if (ms.flags () & P_IS_ALIVE) |
1297 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
1311 | for (object *next, *tmp = ms.bot; tmp; tmp = next) |
|
|
1312 | { |
|
|
1313 | next = tmp->above; |
|
|
1314 | |
1298 | if (tmp->flag [FLAG_ALIVE] || tmp->is_player ()) |
1315 | if (tmp->flag [FLAG_ALIVE] || tmp->is_player ()) |
1299 | { |
1316 | { |
1300 | tmp = tmp->head_ (); |
1317 | tmp = tmp->head_ (); |
1301 | |
1318 | |
1302 | if ((friendly && !tmp->flag [FLAG_FRIENDLY] && !tmp->is_player ()) |
1319 | if ((friendly && !tmp->flag [FLAG_FRIENDLY] && !tmp->is_player ()) |
1303 | || (!friendly && (tmp->flag [FLAG_FRIENDLY] || tmp->is_player ()))) |
1320 | || (!friendly && (tmp->flag [FLAG_FRIENDLY] || tmp->is_player ()))) |
1304 | { |
1321 | { |
1305 | if (spell_ob->subtype == SP_DESTRUCTION) |
1322 | if (spell_ob->subtype == SP_DESTRUCTION) |
1306 | { |
1323 | { |
1307 | hit_player (tmp, dam, op, spell_ob->attacktype, 0); |
1324 | hit_player (tmp, dam, op, spell_ob->attacktype, 0); |
1308 | |
1325 | |
1309 | if (spell_ob->other_arch) |
1326 | if (spell_ob->other_arch) |
1310 | m->insert (arch_to_object (spell_ob->other_arch), nx, ny, op); |
1327 | m->insert (spell_ob->other_arch->instance (), nx, ny, op); |
1311 | } |
1328 | } |
1312 | else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist [ATNR_MAGIC] != 100) |
1329 | else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist [ATNR_MAGIC] != 100) |
1313 | { |
1330 | { |
1314 | if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) |
1331 | if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) |
1315 | m->insert (arch_to_object (spell_ob->other_arch), nx, ny, op); |
1332 | m->insert (spell_ob->other_arch->instance (), nx, ny, op); |
1316 | } |
1333 | } |
1317 | } |
1334 | } |
1318 | } |
1335 | } |
|
|
1336 | } |
1319 | } |
1337 | } |
1320 | |
1338 | |
1321 | op->skill = skill; |
1339 | op->skill = skill; |
1322 | return 1; |
1340 | return 1; |
1323 | } |
1341 | } |
… | |
… | |
1325 | /*************************************************************************** |
1343 | /*************************************************************************** |
1326 | * |
1344 | * |
1327 | * CURSE |
1345 | * CURSE |
1328 | * |
1346 | * |
1329 | ***************************************************************************/ |
1347 | ***************************************************************************/ |
1330 | |
|
|
1331 | int |
1348 | int |
1332 | cast_curse (object *op, object *caster, object *spell_ob, int dir) |
1349 | cast_curse (object *op, object *caster, object *spell_ob, int dir) |
1333 | { |
1350 | { |
1334 | object *god = find_god (determine_god (op)); |
1351 | object *god = find_god (determine_god (op)); |
1335 | object *tmp, *force; |
1352 | object *tmp, *force; |
… | |
… | |
1413 | force->stats.wc = spell_ob->stats.wc; |
1430 | force->stats.wc = spell_ob->stats.wc; |
1414 | |
1431 | |
1415 | change_abil (tmp, force); /* Mostly to display any messages */ |
1432 | change_abil (tmp, force); /* Mostly to display any messages */ |
1416 | insert_ob_in_ob (force, tmp); |
1433 | insert_ob_in_ob (force, tmp); |
1417 | tmp->update_stats (); |
1434 | tmp->update_stats (); |
|
|
1435 | |
1418 | return 1; |
1436 | return 1; |
1419 | |
|
|
1420 | } |
1437 | } |
1421 | |
1438 | |
1422 | /********************************************************************** |
1439 | /********************************************************************** |
1423 | * mood change |
1440 | * mood change |
1424 | * Arguably, this may or may not be an attack spell. But since it |
1441 | * Arguably, this may or may not be an attack spell. But since it |
… | |
… | |
1453 | else if (god && spell->race == shstr_GOD_FRIEND) |
1470 | else if (god && spell->race == shstr_GOD_FRIEND) |
1454 | race = god->race; |
1471 | race = god->race; |
1455 | else |
1472 | else |
1456 | race = spell->race; |
1473 | race = spell->race; |
1457 | |
1474 | |
|
|
1475 | dynbuf buf; |
1458 | unordered_mapwalk (op, -range, -range, range, range) |
1476 | unordered_mapwalk (buf, op, -range, -range, range, range) |
1459 | { |
1477 | { |
1460 | mapspace &ms = m->at (nx, ny); |
1478 | mapspace &ms = m->at (nx, ny); |
1461 | |
1479 | |
1462 | /* If there is nothing living on this space, no need to go further */ |
1480 | /* If there is nothing living on this space, no need to go further */ |
1463 | if (!ms.flags () & P_IS_ALIVE) |
1481 | if (!ms.flags () & P_IS_ALIVE) |
… | |
… | |
1577 | head->stats.exp = 0; |
1595 | head->stats.exp = 0; |
1578 | } |
1596 | } |
1579 | |
1597 | |
1580 | /* If a monster was effected, put an effect in */ |
1598 | /* If a monster was effected, put an effect in */ |
1581 | if (done_one && spell->other_arch) |
1599 | if (done_one && spell->other_arch) |
1582 | m->insert (arch_to_object (spell->other_arch), nx, ny, op); |
1600 | m->insert (spell->other_arch->instance (), nx, ny, op); |
1583 | } |
1601 | } |
1584 | |
1602 | |
1585 | return 1; |
1603 | return 1; |
1586 | } |
1604 | } |
1587 | |
1605 | |
… | |
… | |
1670 | hit_map (op, j, op->attacktype, 1); |
1688 | hit_map (op, j, op->attacktype, 1); |
1671 | } |
1689 | } |
1672 | |
1690 | |
1673 | /* insert the other arch */ |
1691 | /* insert the other arch */ |
1674 | if (op->other_arch && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy)))) |
1692 | if (op->other_arch && !(OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, hx, hy)))) |
1675 | m->insert (arch_to_object (op->other_arch), hx, hy, op); |
1693 | m->insert (op->other_arch->instance (), hx, hy, op); |
1676 | } |
1694 | } |
1677 | |
1695 | |
1678 | /* restore to the center location and damage */ |
1696 | /* restore to the center location and damage */ |
1679 | op->stats.dam = dam_save; |
1697 | op->stats.dam = dam_save; |
1680 | |
1698 | |
… | |
… | |
1896 | return 0; |
1914 | return 0; |
1897 | } |
1915 | } |
1898 | } |
1916 | } |
1899 | |
1917 | |
1900 | /* ok, looks groovy to just insert a new light on the map */ |
1918 | /* ok, looks groovy to just insert a new light on the map */ |
1901 | tmp = arch_to_object (spell->other_arch); |
1919 | tmp = spell->other_arch->instance (); |
1902 | if (!tmp) |
1920 | if (!tmp) |
1903 | { |
1921 | { |
1904 | LOG (llevError, "Error: spell arch for cast_light() missing.\n"); |
1922 | LOG (llevError, "Error: spell arch for cast_light() missing.\n"); |
1905 | return 0; |
1923 | return 0; |
1906 | } |
1924 | } |
… | |
… | |
1972 | { |
1990 | { |
1973 | /* search this square for a victim */ |
1991 | /* search this square for a victim */ |
1974 | for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above) |
1992 | for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above) |
1975 | if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) |
1993 | if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) |
1976 | { /* found a victim */ |
1994 | { /* found a victim */ |
1977 | object *disease = arch_to_object (spell->other_arch); |
1995 | object *disease = spell->other_arch->instance (); |
1978 | |
1996 | |
1979 | disease->set_owner (op); |
1997 | disease->set_owner (op); |
1980 | set_spell_skill (op, caster, spell, disease); |
1998 | set_spell_skill (op, caster, spell, disease); |
1981 | disease->stats.exp = 0; |
1999 | disease->stats.exp = 0; |
1982 | disease->level = casting_level (caster, spell); |
2000 | disease->level = casting_level (caster, spell); |
1983 | |
2001 | |
1984 | /* do level adjustments */ |
2002 | /* do level adjustments */ |
1985 | if (disease->stats.wc) |
2003 | if (disease->stats.wc ) disease->stats.wc += dur_mod / 2; |
1986 | disease->stats.wc += dur_mod / 2; |
2004 | if (disease->magic > 0) disease->magic += dur_mod / 8; |
1987 | |
2005 | if (disease->stats.maxhp > 0) disease->stats.maxhp += dur_mod; |
1988 | if (disease->magic > 0) |
2006 | if (disease->stats.maxgrace > 0) disease->stats.maxgrace += dur_mod; |
1989 | disease->magic += dur_mod / 8; |
|
|
1990 | |
|
|
1991 | if (disease->stats.maxhp > 0) |
|
|
1992 | disease->stats.maxhp += dur_mod; |
|
|
1993 | |
|
|
1994 | if (disease->stats.maxgrace > 0) |
|
|
1995 | disease->stats.maxgrace += dur_mod; |
|
|
1996 | |
|
|
1997 | if (disease->stats.dam) |
|
|
1998 | { |
|
|
1999 | if (disease->stats.dam > 0) |
|
|
2000 | disease->stats.dam += dam_mod; |
|
|
2001 | else |
|
|
2002 | disease->stats.dam -= dam_mod; |
|
|
2003 | } |
|
|
2004 | |
2007 | |
2005 | if (disease->last_sp) |
2008 | if (disease->last_sp) |
2006 | { |
2009 | { |
2007 | disease->last_sp -= 2 * dam_mod; |
2010 | disease->last_sp -= 2 * dam_mod; |
|
|
2011 | |
2008 | if (disease->last_sp < 1) |
2012 | if (disease->last_sp < 1) |
2009 | disease->last_sp = 1; |
2013 | disease->last_sp = 1; |
2010 | } |
2014 | } |
2011 | |
2015 | |
2012 | if (disease->stats.maxsp) |
2016 | if (disease->stats.dam ) disease->stats.dam += copysign (disease->stats.dam , dam_mod); |
2013 | { |
2017 | if (disease->stats.maxsp) disease->stats.maxsp += copysign (disease->stats.maxsp, dam_mod); |
2014 | if (disease->stats.maxsp > 0) |
2018 | if (disease->stats.ac ) disease->stats.ac += dam_mod; |
2015 | disease->stats.maxsp += dam_mod; |
2019 | if (disease->last_eat ) disease->last_eat -= dam_mod; |
2016 | else |
2020 | if (disease->stats.hp ) disease->stats.hp -= dam_mod; |
2017 | disease->stats.maxsp -= dam_mod; |
2021 | if (disease->stats.sp ) disease->stats.sp -= dam_mod; |
2018 | } |
|
|
2019 | |
|
|
2020 | if (disease->stats.ac) |
|
|
2021 | disease->stats.ac += dam_mod; |
|
|
2022 | |
|
|
2023 | if (disease->last_eat) |
|
|
2024 | disease->last_eat -= dam_mod; |
|
|
2025 | |
|
|
2026 | if (disease->stats.hp) |
|
|
2027 | disease->stats.hp -= dam_mod; |
|
|
2028 | |
|
|
2029 | if (disease->stats.sp) |
|
|
2030 | disease->stats.sp -= dam_mod; |
|
|
2031 | |
2022 | |
2032 | if (infect_object (walk, disease, 1)) |
2023 | if (infect_object (walk, disease, 1)) |
2033 | { |
2024 | { |
2034 | new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); |
2025 | op->statusmsg (format ("You inflict %s on %s!", &disease->name, &walk->name)); |
2035 | |
2026 | |
2036 | disease->destroy (); /* don't need this one anymore */ |
2027 | disease->destroy (); /* don't need this one anymore */ |
2037 | walk->map->insert (get_archetype (shstr_detect_magic), x, y, op); |
2028 | walk->map->insert (get_archetype (shstr_detect_magic), x, y, op); |
2038 | return 1; |
2029 | return 1; |
2039 | } |
2030 | } |