… | |
… | |
1602 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
1602 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
1603 | } |
1603 | } |
1604 | } |
1604 | } |
1605 | |
1605 | |
1606 | /** |
1606 | /** |
|
|
1607 | * op made some mistake with a scroll, this takes care of punishment. |
|
|
1608 | * scroll_failure()- hacked directly from spell_failure |
|
|
1609 | */ |
|
|
1610 | static void |
|
|
1611 | scroll_failure (object *op, int failure, int power) |
|
|
1612 | { |
|
|
1613 | if (abs (failure / 4) > power) |
|
|
1614 | power = abs (failure / 4); /* set minimum effect */ |
|
|
1615 | |
|
|
1616 | if (failure <= -1 && failure > -15) |
|
|
1617 | { /* wonder */ |
|
|
1618 | object *tmp; |
|
|
1619 | |
|
|
1620 | op->failmsg ("Your spell warps!"); |
|
|
1621 | tmp = get_archetype (SPELL_WONDER); |
|
|
1622 | cast_wonder (op, op, 0, tmp); |
|
|
1623 | tmp->destroy (); |
|
|
1624 | } |
|
|
1625 | else if (failure <= -15 && failure > -35) |
|
|
1626 | { /* drain mana */ |
|
|
1627 | op->failmsg ("Your mana is drained!"); |
|
|
1628 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
|
|
1629 | if (op->stats.sp < 0) |
|
|
1630 | op->stats.sp = 0; |
|
|
1631 | } |
|
|
1632 | else if (settings.spell_failure_effects == TRUE) |
|
|
1633 | { |
|
|
1634 | if (failure <= -35 && failure > -60) |
|
|
1635 | { /* confusion */ |
|
|
1636 | op->failmsg ("The magic recoils on you!"); |
|
|
1637 | confuse_player (op, op, power); |
|
|
1638 | } |
|
|
1639 | else if (failure <= -60 && failure > -70) |
|
|
1640 | { /* paralysis */ |
|
|
1641 | op->failmsg ("The magic recoils and paralyzes you!"); |
|
|
1642 | paralyze_player (op, op, power); |
|
|
1643 | } |
|
|
1644 | else if (failure <= -70 && failure > -80) |
|
|
1645 | { /* blind */ |
|
|
1646 | op->failmsg ("The magic recoils on you!"); |
|
|
1647 | blind_player (op, op, power); |
|
|
1648 | } |
|
|
1649 | else if (failure <= -80) |
|
|
1650 | { /* blast the immediate area */ |
|
|
1651 | object *tmp = get_archetype (LOOSE_MANA); |
|
|
1652 | cast_magic_storm (op, tmp, power); |
|
|
1653 | op->failmsg ("You unleash uncontrolled mana!"); |
|
|
1654 | tmp->destroy (); |
|
|
1655 | } |
|
|
1656 | } |
|
|
1657 | } |
|
|
1658 | |
|
|
1659 | /** |
1607 | * Handles the applying of a skill scroll, calling learn_skill straight. |
1660 | * Handles the applying of a skill scroll, calling learn_skill straight. |
1608 | * op is the person learning the skill, tmp is the skill scroll object |
1661 | * op is the person learning the skill, tmp is the skill scroll object |
1609 | */ |
1662 | */ |
1610 | static void |
1663 | static void |
1611 | apply_skillscroll (object *op, object *tmp) |
1664 | apply_skillscroll (object *op, object *tmp) |
… | |
… | |
1919 | if (!tmp->destroyed () && !tmp->inv) |
1972 | if (!tmp->destroyed () && !tmp->inv) |
1920 | tmp->decrease (true); |
1973 | tmp->decrease (true); |
1921 | } |
1974 | } |
1922 | |
1975 | |
1923 | /** |
1976 | /** |
1924 | * op eats food. |
|
|
1925 | * If player, takes care of messages and dragon special food. |
|
|
1926 | */ |
|
|
1927 | static void |
|
|
1928 | apply_food (object *op, object *tmp) |
|
|
1929 | { |
|
|
1930 | int capacity_remaining; |
|
|
1931 | |
|
|
1932 | if (op->type != PLAYER) |
|
|
1933 | op->stats.hp = op->stats.maxhp; |
|
|
1934 | else |
|
|
1935 | { |
|
|
1936 | /* check if this is a dragon (player), eating some flesh */ |
|
|
1937 | if (tmp->type == FLESH && is_dragon_pl (op) && dragon_eat_flesh (op, tmp)) |
|
|
1938 | ; |
|
|
1939 | else |
|
|
1940 | { |
|
|
1941 | /* usual case - no dragon meal: */ |
|
|
1942 | if (op->stats.food + tmp->stats.food > 999) |
|
|
1943 | { |
|
|
1944 | if (tmp->type == FOOD || tmp->type == FLESH) |
|
|
1945 | op->failmsg ("You feel full, but what a waste of food!"); |
|
|
1946 | else |
|
|
1947 | op->statusmsg ("Most of the drink goes down your face not your throat!"); |
|
|
1948 | } |
|
|
1949 | |
|
|
1950 | tmp->play_sound ( |
|
|
1951 | tmp->sound |
|
|
1952 | ? tmp->sound |
|
|
1953 | : tmp->type == DRINK |
|
|
1954 | ? sound_find ("eat_drink") |
|
|
1955 | : sound_find ("eat_food") |
|
|
1956 | ); |
|
|
1957 | |
|
|
1958 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
|
|
1959 | { |
|
|
1960 | const char *buf; |
|
|
1961 | |
|
|
1962 | if (!is_dragon_pl (op)) |
|
|
1963 | { |
|
|
1964 | /* eating message for normal players */ |
|
|
1965 | if (tmp->type == DRINK) |
|
|
1966 | buf = format ("Ahhh...that %s tasted good.", &tmp->name); |
|
|
1967 | else |
|
|
1968 | buf = format ("The %s tasted %s", &tmp->name, tmp->type == FLESH ? "terrible!" : "good."); |
|
|
1969 | } |
|
|
1970 | else |
|
|
1971 | /* eating message for dragon players */ |
|
|
1972 | buf = format ("The %s tasted terrible!", &tmp->name); |
|
|
1973 | |
|
|
1974 | op->statusmsg (buf); |
|
|
1975 | |
|
|
1976 | capacity_remaining = 999 - op->stats.food; |
|
|
1977 | op->stats.food += tmp->stats.food; |
|
|
1978 | if (capacity_remaining < tmp->stats.food) |
|
|
1979 | op->stats.hp += capacity_remaining / 50; |
|
|
1980 | else |
|
|
1981 | op->stats.hp += tmp->stats.food / 50; |
|
|
1982 | |
|
|
1983 | if (op->stats.hp > op->stats.maxhp) |
|
|
1984 | op->stats.hp = op->stats.maxhp; |
|
|
1985 | if (op->stats.food > 999) |
|
|
1986 | op->stats.food = 999; |
|
|
1987 | } |
|
|
1988 | |
|
|
1989 | /* special food hack -b.t. */ |
|
|
1990 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
|
|
1991 | eat_special_food (op, tmp); |
|
|
1992 | } |
|
|
1993 | } |
|
|
1994 | |
|
|
1995 | handle_apply_yield (tmp); |
|
|
1996 | tmp->decrease (); |
|
|
1997 | } |
|
|
1998 | |
|
|
1999 | /** |
|
|
2000 | * A dragon is eating some flesh. If the flesh contains resistances, |
1977 | * A dragon is eating some flesh. If the flesh contains resistances, |
2001 | * there is a chance for the dragon's skin to get improved. |
1978 | * there is a chance for the dragon's skin to get improved. |
2002 | * |
1979 | * |
2003 | * attributes: |
1980 | * attributes: |
2004 | * object *op the object (dragon player) eating the flesh |
1981 | * object *op the object (dragon player) eating the flesh |
2005 | * object *meal the flesh item, getting chewed in dragon's mouth |
1982 | * object *meal the flesh item, getting chewed in dragon's mouth |
2006 | * return: |
1983 | * return: |
2007 | * int 1 if eating successful, 0 if it doesn't work |
1984 | * int 1 if eating successful, 0 if it doesn't work |
2008 | */ |
1985 | */ |
2009 | int |
1986 | static int |
2010 | dragon_eat_flesh (object *op, object *meal) |
1987 | dragon_eat_flesh (object *op, object *meal) |
2011 | { |
1988 | { |
2012 | object *skin = NULL; /* pointer to dragon skin force */ |
1989 | object *skin = NULL; /* pointer to dragon skin force */ |
2013 | object *abil = NULL; /* pointer to dragon ability force */ |
1990 | object *abil = NULL; /* pointer to dragon ability force */ |
2014 | object *tmp = NULL; /* tmp. object */ |
1991 | object *tmp = NULL; /* tmp. object */ |
… | |
… | |
2155 | |
2132 | |
2156 | return 1; |
2133 | return 1; |
2157 | } |
2134 | } |
2158 | |
2135 | |
2159 | /** |
2136 | /** |
|
|
2137 | * op eats food. |
|
|
2138 | * If player, takes care of messages and dragon special food. |
|
|
2139 | */ |
|
|
2140 | static void |
|
|
2141 | apply_food (object *op, object *tmp) |
|
|
2142 | { |
|
|
2143 | int capacity_remaining; |
|
|
2144 | |
|
|
2145 | if (op->type != PLAYER) |
|
|
2146 | op->stats.hp = op->stats.maxhp; |
|
|
2147 | else |
|
|
2148 | { |
|
|
2149 | /* check if this is a dragon (player), eating some flesh */ |
|
|
2150 | if (tmp->type == FLESH && is_dragon_pl (op) && dragon_eat_flesh (op, tmp)) |
|
|
2151 | ; |
|
|
2152 | else |
|
|
2153 | { |
|
|
2154 | /* usual case - no dragon meal: */ |
|
|
2155 | if (op->stats.food + tmp->stats.food > 999) |
|
|
2156 | { |
|
|
2157 | if (tmp->type == FOOD || tmp->type == FLESH) |
|
|
2158 | op->failmsg ("You feel full, but what a waste of food!"); |
|
|
2159 | else |
|
|
2160 | op->statusmsg ("Most of the drink goes down your face not your throat!"); |
|
|
2161 | } |
|
|
2162 | |
|
|
2163 | tmp->play_sound ( |
|
|
2164 | tmp->sound |
|
|
2165 | ? tmp->sound |
|
|
2166 | : tmp->type == DRINK |
|
|
2167 | ? sound_find ("eat_drink") |
|
|
2168 | : sound_find ("eat_food") |
|
|
2169 | ); |
|
|
2170 | |
|
|
2171 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
|
|
2172 | { |
|
|
2173 | const char *buf; |
|
|
2174 | |
|
|
2175 | if (!is_dragon_pl (op)) |
|
|
2176 | { |
|
|
2177 | /* eating message for normal players */ |
|
|
2178 | if (tmp->type == DRINK) |
|
|
2179 | buf = format ("Ahhh...that %s tasted good.", &tmp->name); |
|
|
2180 | else |
|
|
2181 | buf = format ("The %s tasted %s", &tmp->name, tmp->type == FLESH ? "terrible!" : "good."); |
|
|
2182 | } |
|
|
2183 | else |
|
|
2184 | /* eating message for dragon players */ |
|
|
2185 | buf = format ("The %s tasted terrible!", &tmp->name); |
|
|
2186 | |
|
|
2187 | op->statusmsg (buf); |
|
|
2188 | |
|
|
2189 | capacity_remaining = 999 - op->stats.food; |
|
|
2190 | op->stats.food += tmp->stats.food; |
|
|
2191 | if (capacity_remaining < tmp->stats.food) |
|
|
2192 | op->stats.hp += capacity_remaining / 50; |
|
|
2193 | else |
|
|
2194 | op->stats.hp += tmp->stats.food / 50; |
|
|
2195 | |
|
|
2196 | if (op->stats.hp > op->stats.maxhp) |
|
|
2197 | op->stats.hp = op->stats.maxhp; |
|
|
2198 | if (op->stats.food > 999) |
|
|
2199 | op->stats.food = 999; |
|
|
2200 | } |
|
|
2201 | |
|
|
2202 | /* special food hack -b.t. */ |
|
|
2203 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
|
|
2204 | eat_special_food (op, tmp); |
|
|
2205 | } |
|
|
2206 | } |
|
|
2207 | |
|
|
2208 | handle_apply_yield (tmp); |
|
|
2209 | tmp->decrease (); |
|
|
2210 | } |
|
|
2211 | |
|
|
2212 | /** |
2160 | * Handles applying an improve armor scroll. |
2213 | * Handles applying an improve armor scroll. |
2161 | * Does some sanity checks, then calls improve_armour. |
2214 | * Does some sanity checks, then calls improve_armour. |
2162 | */ |
2215 | */ |
2163 | static void |
2216 | static void |
2164 | apply_armour_improver (object *op, object *tmp) |
2217 | apply_armour_improver (object *op, object *tmp) |
… | |
… | |
2547 | if (op->other_arch) |
2600 | if (op->other_arch) |
2548 | get_animation_from_arch (op, switch_on ? op->other_arch : op->arch); |
2601 | get_animation_from_arch (op, switch_on ? op->other_arch : op->arch); |
2549 | |
2602 | |
2550 | if (object *pl = op->visible_to ()) |
2603 | if (object *pl = op->visible_to ()) |
2551 | esrv_update_item (UPD_ANIM | UPD_FACE | UPD_NAME, pl, op); |
2604 | esrv_update_item (UPD_ANIM | UPD_FACE | UPD_NAME, pl, op); |
|
|
2605 | } |
|
|
2606 | |
|
|
2607 | /** |
|
|
2608 | * This handles items of type 'transformer'. |
|
|
2609 | * Basically those items, used with a marked item, transform both items into something |
|
|
2610 | * else. |
|
|
2611 | * "Transformer" item has food decreased by 1, removed if 0 (0 at start means illimited).. |
|
|
2612 | * Change information is contained in the 'slaying' field of the marked item. |
|
|
2613 | * The format is as follow: transformer:[number ]yield[;transformer:...]. |
|
|
2614 | * This way an item can be transformed in many things, and/or many objects. |
|
|
2615 | * The 'slaying' field for transformer is used as verb for the action. |
|
|
2616 | */ |
|
|
2617 | static void |
|
|
2618 | apply_item_transformer (object *pl, object *transformer) |
|
|
2619 | { |
|
|
2620 | object *marked; |
|
|
2621 | object *new_item; |
|
|
2622 | char *find; |
|
|
2623 | char *separator; |
|
|
2624 | int yield; |
|
|
2625 | char got[MAX_BUF]; |
|
|
2626 | int len; |
|
|
2627 | |
|
|
2628 | if (!pl || !transformer) |
|
|
2629 | return; |
|
|
2630 | |
|
|
2631 | marked = find_marked_object (pl); |
|
|
2632 | |
|
|
2633 | if (!marked) |
|
|
2634 | { |
|
|
2635 | pl->failmsg (format ("Use the %s with what item?", query_name (transformer))); |
|
|
2636 | return; |
|
|
2637 | } |
|
|
2638 | |
|
|
2639 | if (!marked->slaying) |
|
|
2640 | { |
|
|
2641 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
|
|
2642 | return; |
|
|
2643 | } |
|
|
2644 | |
|
|
2645 | /* check whether they are compatible or not */ |
|
|
2646 | find = strstr (&marked->slaying, transformer->arch->archname); |
|
|
2647 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
|
|
2648 | { |
|
|
2649 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
|
|
2650 | return; |
|
|
2651 | } |
|
|
2652 | |
|
|
2653 | find += strlen (transformer->arch->archname) + 1; |
|
|
2654 | /* Item can be used, now find how many and what it yields */ |
|
|
2655 | if (isdigit (*(find))) |
|
|
2656 | { |
|
|
2657 | yield = atoi (find); |
|
|
2658 | if (yield < 1) |
|
|
2659 | { |
|
|
2660 | LOG (llevDebug, "apply_item_transformer: item %s has slaying-yield %d.", query_base_name (marked, 0), yield); |
|
|
2661 | yield = 1; |
|
|
2662 | } |
|
|
2663 | } |
|
|
2664 | else |
|
|
2665 | yield = 1; |
|
|
2666 | |
|
|
2667 | while (isdigit (*find)) |
|
|
2668 | find++; |
|
|
2669 | |
|
|
2670 | while (*find == ' ') |
|
|
2671 | find++; |
|
|
2672 | |
|
|
2673 | memset (got, 0, MAX_BUF); |
|
|
2674 | |
|
|
2675 | if ((separator = strchr (find, ';')) != NULL) |
|
|
2676 | len = separator - find; |
|
|
2677 | else |
|
|
2678 | len = strlen (find); |
|
|
2679 | |
|
|
2680 | if (len > MAX_BUF - 1) |
|
|
2681 | len = MAX_BUF - 1; |
|
|
2682 | |
|
|
2683 | strcpy (got, find); |
|
|
2684 | got[len] = '\0'; |
|
|
2685 | |
|
|
2686 | /* Now create new item, remove used ones when required. */ |
|
|
2687 | new_item = get_archetype (got); |
|
|
2688 | if (!new_item) |
|
|
2689 | { |
|
|
2690 | pl->failmsg (format ("This %s is strange, better to not use it.", query_base_name (marked, 0))); |
|
|
2691 | return; |
|
|
2692 | } |
|
|
2693 | |
|
|
2694 | new_item->nrof = yield; |
|
|
2695 | |
|
|
2696 | pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0))); |
|
|
2697 | |
|
|
2698 | pl->insert (new_item); |
|
|
2699 | /* Eat up one item */ |
|
|
2700 | marked->decrease (); |
|
|
2701 | |
|
|
2702 | /* Eat one transformer if needed */ |
|
|
2703 | if (transformer->stats.food) |
|
|
2704 | if (--transformer->stats.food == 0) |
|
|
2705 | transformer->decrease (); |
2552 | } |
2706 | } |
2553 | |
2707 | |
2554 | /** |
2708 | /** |
2555 | * Main apply handler. |
2709 | * Main apply handler. |
2556 | * |
2710 | * |
… | |
… | |
3896 | } |
4050 | } |
3897 | |
4051 | |
3898 | who->update_stats (); |
4052 | who->update_stats (); |
3899 | } |
4053 | } |
3900 | |
4054 | |
3901 | /** |
|
|
3902 | * op made some mistake with a scroll, this takes care of punishment. |
|
|
3903 | * scroll_failure()- hacked directly from spell_failure |
|
|
3904 | */ |
|
|
3905 | void |
|
|
3906 | scroll_failure (object *op, int failure, int power) |
|
|
3907 | { |
|
|
3908 | if (abs (failure / 4) > power) |
|
|
3909 | power = abs (failure / 4); /* set minimum effect */ |
|
|
3910 | |
|
|
3911 | if (failure <= -1 && failure > -15) |
|
|
3912 | { /* wonder */ |
|
|
3913 | object *tmp; |
|
|
3914 | |
|
|
3915 | op->failmsg ("Your spell warps!"); |
|
|
3916 | tmp = get_archetype (SPELL_WONDER); |
|
|
3917 | cast_wonder (op, op, 0, tmp); |
|
|
3918 | tmp->destroy (); |
|
|
3919 | } |
|
|
3920 | else if (failure <= -15 && failure > -35) |
|
|
3921 | { /* drain mana */ |
|
|
3922 | op->failmsg ("Your mana is drained!"); |
|
|
3923 | op->stats.sp -= random_roll (0, power - 1, op, PREFER_LOW); |
|
|
3924 | if (op->stats.sp < 0) |
|
|
3925 | op->stats.sp = 0; |
|
|
3926 | } |
|
|
3927 | else if (settings.spell_failure_effects == TRUE) |
|
|
3928 | { |
|
|
3929 | if (failure <= -35 && failure > -60) |
|
|
3930 | { /* confusion */ |
|
|
3931 | op->failmsg ("The magic recoils on you!"); |
|
|
3932 | confuse_player (op, op, power); |
|
|
3933 | } |
|
|
3934 | else if (failure <= -60 && failure > -70) |
|
|
3935 | { /* paralysis */ |
|
|
3936 | op->failmsg ("The magic recoils and paralyzes you!"); |
|
|
3937 | paralyze_player (op, op, power); |
|
|
3938 | } |
|
|
3939 | else if (failure <= -70 && failure > -80) |
|
|
3940 | { /* blind */ |
|
|
3941 | op->failmsg ("The magic recoils on you!"); |
|
|
3942 | blind_player (op, op, power); |
|
|
3943 | } |
|
|
3944 | else if (failure <= -80) |
|
|
3945 | { /* blast the immediate area */ |
|
|
3946 | object *tmp = get_archetype (LOOSE_MANA); |
|
|
3947 | cast_magic_storm (op, tmp, power); |
|
|
3948 | op->failmsg ("You unleash uncontrolled mana!"); |
|
|
3949 | tmp->destroy (); |
|
|
3950 | } |
|
|
3951 | } |
|
|
3952 | } |
|
|
3953 | |
|
|
3954 | void |
4055 | void |
3955 | apply_changes_to_player (object *pl, object *change) |
4056 | apply_changes_to_player (object *pl, object *change) |
3956 | { |
4057 | { |
3957 | int excess_stat = 0; /* if the stat goes over the maximum |
4058 | int excess_stat = 0; /* if the stat goes over the maximum |
3958 | for the race, put the excess stat some |
4059 | for the race, put the excess stat some |
… | |
… | |
4033 | break; |
4134 | break; |
4034 | } |
4135 | } |
4035 | } |
4136 | } |
4036 | } |
4137 | } |
4037 | |
4138 | |
4038 | /** |
|
|
4039 | * This handles items of type 'transformer'. |
|
|
4040 | * Basically those items, used with a marked item, transform both items into something |
|
|
4041 | * else. |
|
|
4042 | * "Transformer" item has food decreased by 1, removed if 0 (0 at start means illimited).. |
|
|
4043 | * Change information is contained in the 'slaying' field of the marked item. |
|
|
4044 | * The format is as follow: transformer:[number ]yield[;transformer:...]. |
|
|
4045 | * This way an item can be transformed in many things, and/or many objects. |
|
|
4046 | * The 'slaying' field for transformer is used as verb for the action. |
|
|
4047 | */ |
|
|
4048 | void |
|
|
4049 | apply_item_transformer (object *pl, object *transformer) |
|
|
4050 | { |
|
|
4051 | object *marked; |
|
|
4052 | object *new_item; |
|
|
4053 | char *find; |
|
|
4054 | char *separator; |
|
|
4055 | int yield; |
|
|
4056 | char got[MAX_BUF]; |
|
|
4057 | int len; |
|
|
4058 | |
|
|
4059 | if (!pl || !transformer) |
|
|
4060 | return; |
|
|
4061 | |
|
|
4062 | marked = find_marked_object (pl); |
|
|
4063 | |
|
|
4064 | if (!marked) |
|
|
4065 | { |
|
|
4066 | pl->failmsg (format ("Use the %s with what item?", query_name (transformer))); |
|
|
4067 | return; |
|
|
4068 | } |
|
|
4069 | |
|
|
4070 | if (!marked->slaying) |
|
|
4071 | { |
|
|
4072 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
|
|
4073 | return; |
|
|
4074 | } |
|
|
4075 | |
|
|
4076 | /* check whether they are compatible or not */ |
|
|
4077 | find = strstr (&marked->slaying, transformer->arch->archname); |
|
|
4078 | if (!find || (*(find + strlen (transformer->arch->archname)) != ':')) |
|
|
4079 | { |
|
|
4080 | pl->failmsg (format ("You can't use the %s with your %s!", query_name (transformer), query_name (marked))); |
|
|
4081 | return; |
|
|
4082 | } |
|
|
4083 | |
|
|
4084 | find += strlen (transformer->arch->archname) + 1; |
|
|
4085 | /* Item can be used, now find how many and what it yields */ |
|
|
4086 | if (isdigit (*(find))) |
|
|
4087 | { |
|
|
4088 | yield = atoi (find); |
|
|
4089 | if (yield < 1) |
|
|
4090 | { |
|
|
4091 | LOG (llevDebug, "apply_item_transformer: item %s has slaying-yield %d.", query_base_name (marked, 0), yield); |
|
|
4092 | yield = 1; |
|
|
4093 | } |
|
|
4094 | } |
|
|
4095 | else |
|
|
4096 | yield = 1; |
|
|
4097 | |
|
|
4098 | while (isdigit (*find)) |
|
|
4099 | find++; |
|
|
4100 | |
|
|
4101 | while (*find == ' ') |
|
|
4102 | find++; |
|
|
4103 | |
|
|
4104 | memset (got, 0, MAX_BUF); |
|
|
4105 | |
|
|
4106 | if ((separator = strchr (find, ';')) != NULL) |
|
|
4107 | len = separator - find; |
|
|
4108 | else |
|
|
4109 | len = strlen (find); |
|
|
4110 | |
|
|
4111 | if (len > MAX_BUF - 1) |
|
|
4112 | len = MAX_BUF - 1; |
|
|
4113 | |
|
|
4114 | strcpy (got, find); |
|
|
4115 | got[len] = '\0'; |
|
|
4116 | |
|
|
4117 | /* Now create new item, remove used ones when required. */ |
|
|
4118 | new_item = get_archetype (got); |
|
|
4119 | if (!new_item) |
|
|
4120 | { |
|
|
4121 | pl->failmsg (format ("This %s is strange, better to not use it.", query_base_name (marked, 0))); |
|
|
4122 | return; |
|
|
4123 | } |
|
|
4124 | |
|
|
4125 | new_item->nrof = yield; |
|
|
4126 | |
|
|
4127 | pl->statusmsg (format ("You %s the %s.", &transformer->slaying, query_base_name (marked, 0))); |
|
|
4128 | |
|
|
4129 | pl->insert (new_item); |
|
|
4130 | /* Eat up one item */ |
|
|
4131 | marked->decrease (); |
|
|
4132 | |
|
|
4133 | /* Eat one transformer if needed */ |
|
|
4134 | if (transformer->stats.food) |
|
|
4135 | if (--transformer->stats.food == 0) |
|
|
4136 | transformer->decrease (); |
|
|
4137 | } |
|
|
4138 | |
|
|