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,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001 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 <cmath> |
25 | #include <cmath> |
26 | |
26 | |
… | |
… | |
1393 | |
1393 | |
1394 | static bool |
1394 | static bool |
1395 | apply_special (object *who, object *op, int aflags) |
1395 | apply_special (object *who, object *op, int aflags) |
1396 | { |
1396 | { |
1397 | int basic_flag = aflags & AP_MODE; |
1397 | int basic_flag = aflags & AP_MODE; |
1398 | object *tmp, *tmp2, *skop = NULL; |
1398 | object *tmp, *skop = NULL; |
1399 | |
1399 | |
1400 | /* trying to unequip op */ |
1400 | /* trying to unequip op */ |
1401 | if (op->flag [FLAG_APPLIED]) |
1401 | if (op->flag [FLAG_APPLIED]) |
1402 | { |
1402 | { |
1403 | /* always apply, so no reason to unapply */ |
1403 | /* always apply, so no reason to unapply */ |
… | |
… | |
1779 | apply_potion (object *op, object *tmp) |
1779 | apply_potion (object *op, object *tmp) |
1780 | { |
1780 | { |
1781 | int got_one = 0, i; |
1781 | int got_one = 0, i; |
1782 | object *force = 0; |
1782 | object *force = 0; |
1783 | |
1783 | |
1784 | object *floor = GET_MAP_OB (op->map, op->x, op->y); |
|
|
1785 | |
|
|
1786 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1784 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1787 | { |
1785 | { |
1788 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
1786 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
1789 | |
1787 | |
1790 | tmp->clr_flag (FLAG_APPLIED); |
1788 | tmp->clr_flag (FLAG_APPLIED); |
… | |
… | |
1943 | for (i = 0; i < NROFATTACKS; i++) |
1941 | for (i = 0; i < NROFATTACKS; i++) |
1944 | { |
1942 | { |
1945 | if (tmp->resist[i]) |
1943 | if (tmp->resist[i]) |
1946 | { |
1944 | { |
1947 | if (!force) |
1945 | if (!force) |
1948 | force = get_archetype (FORCE_NAME); |
1946 | force = archetype::get (FORCE_NAME); |
1949 | |
1947 | |
1950 | memcpy (force->resist, tmp->resist, sizeof (tmp->resist)); |
1948 | memcpy (force->resist, tmp->resist, sizeof (tmp->resist)); |
1951 | force->type = POTION_EFFECT; |
1949 | force->type = POTION_EFFECT; |
1952 | break; /* Only need to find one protection since we copy entire batch */ |
1950 | break; /* Only need to find one protection since we copy entire batch */ |
1953 | } |
1951 | } |
… | |
… | |
2096 | case ARROW: |
2094 | case ARROW: |
2097 | /* bad bug: monster throw a object, make a step forwards, step on object , |
2095 | /* bad bug: monster throw a object, make a step forwards, step on object , |
2098 | * trigger this here and get hit by own missile - and will be own enemy. |
2096 | * trigger this here and get hit by own missile - and will be own enemy. |
2099 | * Victim then is his own enemy and will start to kill herself (this is |
2097 | * Victim then is his own enemy and will start to kill herself (this is |
2100 | * removed) but we have not synced victim and his missile. To avoid senseless |
2098 | * removed) but we have not synced victim and his missile. To avoid senseless |
2101 | * action, we avoid hits here |
2099 | * action, we avoid hits here |
2102 | */ |
2100 | */ |
2103 | if ((victim->flag [FLAG_ALIVE] && trap->has_active_speed ()) |
2101 | if ((victim->flag [FLAG_ALIVE] && trap->has_active_speed ()) |
2104 | && trap->owner != victim) |
2102 | && trap->owner != victim) |
2105 | hit_with_arrow (trap, victim); |
2103 | hit_with_arrow (trap, victim); |
2106 | break; |
2104 | break; |
… | |
… | |
2313 | if (failure <= -1 && failure > -15) |
2311 | if (failure <= -1 && failure > -15) |
2314 | { /* wonder */ |
2312 | { /* wonder */ |
2315 | object *tmp; |
2313 | object *tmp; |
2316 | |
2314 | |
2317 | op->failmsg ("Your spell warps!"); |
2315 | op->failmsg ("Your spell warps!"); |
2318 | tmp = get_archetype (SPELL_WONDER); |
2316 | tmp = archetype::get (SPELL_WONDER); |
2319 | cast_wonder (op, op, 0, tmp); |
2317 | cast_wonder (op, op, 0, tmp); |
2320 | tmp->destroy (); |
2318 | tmp->destroy (); |
2321 | } |
2319 | } |
2322 | else if (failure <= -15 && failure > -35) |
2320 | else if (failure <= -15 && failure > -35) |
2323 | { /* drain mana */ |
2321 | { /* drain mana */ |
… | |
… | |
2343 | op->failmsg ("The magic recoils on you!"); |
2341 | op->failmsg ("The magic recoils on you!"); |
2344 | blind_player (op, op, power); |
2342 | blind_player (op, op, power); |
2345 | } |
2343 | } |
2346 | else if (failure <= -80) |
2344 | else if (failure <= -80) |
2347 | { /* blast the immediate area */ |
2345 | { /* blast the immediate area */ |
2348 | object *tmp = get_archetype (LOOSE_MANA); |
2346 | object *tmp = archetype::get (LOOSE_MANA); |
2349 | cast_magic_storm (op, tmp, power); |
2347 | cast_magic_storm (op, tmp, power); |
2350 | op->failmsg ("You unleash uncontrolled mana!"); |
2348 | op->failmsg ("You unleash uncontrolled mana!"); |
2351 | tmp->destroy (); |
2349 | tmp->destroy (); |
2352 | } |
2350 | } |
2353 | } |
2351 | } |
… | |
… | |
3027 | * the selected object to "burn". -b.t. |
3025 | * the selected object to "burn". -b.t. |
3028 | */ |
3026 | */ |
3029 | static void |
3027 | static void |
3030 | apply_lighter (object *who, object *lighter) |
3028 | apply_lighter (object *who, object *lighter) |
3031 | { |
3029 | { |
3032 | int is_player_env = 0; |
|
|
3033 | |
|
|
3034 | if (object *item = who->mark ()) |
3030 | if (object *item = who->mark ()) |
3035 | { |
3031 | { |
3036 | if (!auto_apply_lighter (who, item, lighter)) |
3032 | if (!auto_apply_lighter (who, item, lighter)) |
3037 | return; |
3033 | return; |
3038 | |
3034 | |
… | |
… | |
3295 | |
3291 | |
3296 | strcpy (got, find); |
3292 | strcpy (got, find); |
3297 | got[len] = '\0'; |
3293 | got[len] = '\0'; |
3298 | |
3294 | |
3299 | /* Now create new item, remove used ones when required. */ |
3295 | /* Now create new item, remove used ones when required. */ |
3300 | new_item = get_archetype (got); |
3296 | new_item = archetype::get (got); |
3301 | if (!new_item) |
3297 | if (!new_item) |
3302 | { |
3298 | { |
3303 | pl->failmsgf ("This %s is strange, better to not use it.", query_base_name (marked, 0)); |
3299 | pl->failmsgf ("This %s is strange, better to not use it.", query_base_name (marked, 0)); |
3304 | return; |
3300 | return; |
3305 | } |
3301 | } |
… | |
… | |
3724 | * Generates shop floor's item, and treasures. |
3720 | * Generates shop floor's item, and treasures. |
3725 | */ |
3721 | */ |
3726 | int |
3722 | int |
3727 | auto_apply (object *op) |
3723 | auto_apply (object *op) |
3728 | { |
3724 | { |
3729 | object *tmp = NULL, *tmp2; |
3725 | object *tmp = NULL; |
3730 | int i; |
3726 | int i; |
3731 | |
3727 | |
3732 | op->clr_flag (FLAG_AUTO_APPLY); |
3728 | op->clr_flag (FLAG_AUTO_APPLY); |
3733 | |
3729 | |
3734 | switch (op->type) |
3730 | switch (op->type) |
… | |
… | |
3820 | while (invtmp->stats.hp-- > 0) |
3816 | while (invtmp->stats.hp-- > 0) |
3821 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3817 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3822 | |
3818 | |
3823 | invtmp->randomitems = NULL; |
3819 | invtmp->randomitems = NULL; |
3824 | } |
3820 | } |
3825 | else if (invtmp && invtmp->arch |
3821 | else if (invtmp->arch |
3826 | && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS && invtmp->has_random_items ()) |
3822 | && invtmp->type != TREASURE && invtmp->type != SPELL && invtmp->type != CLASS |
|
|
3823 | && invtmp->has_random_items ()) |
3827 | { |
3824 | { |
3828 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3825 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3829 | /* Need to clear this so that we never try to create |
3826 | /* Need to clear this so that we never try to create |
3830 | * treasure again for this object |
3827 | * treasure again for this object |
3831 | */ |
3828 | */ |