… | |
… | |
204 | op->update_stats (); |
204 | op->update_stats (); |
205 | tmp->decrease (); |
205 | tmp->decrease (); |
206 | return 1; |
206 | return 1; |
207 | } |
207 | } |
208 | |
208 | |
209 | if (!(at = archetype::find (ARCH_DEPLETION))) |
209 | if (!(at = archetype::find (shstr_depletion))) |
210 | { |
210 | { |
211 | LOG (llevError, "Could not find archetype depletion\n"); |
211 | LOG (llevError, "Could not find archetype depletion\n"); |
212 | return 0; |
212 | return 0; |
213 | } |
213 | } |
214 | |
214 | |
… | |
… | |
231 | } |
231 | } |
232 | |
232 | |
233 | /* improvement potion - only for players */ |
233 | /* improvement potion - only for players */ |
234 | if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) |
234 | if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) |
235 | { |
235 | { |
236 | for (i = 1; i < MIN (11, op->level); i++) |
236 | for (i = 1; i < min (11, op->level); i++) |
237 | { |
237 | { |
238 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
238 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
239 | { |
239 | { |
240 | if (op->contr->levhp[i] != 1) |
240 | if (op->contr->levhp[i] != 1) |
241 | { |
241 | { |
… | |
… | |
276 | } |
276 | } |
277 | } |
277 | } |
278 | } |
278 | } |
279 | |
279 | |
280 | /* Just makes checking easier */ |
280 | /* Just makes checking easier */ |
281 | if (i < MIN (11, op->level)) |
281 | if (i < min (11, op->level)) |
282 | got_one = 1; |
282 | got_one = 1; |
283 | |
283 | |
284 | if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)) |
284 | if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)) |
285 | { |
285 | { |
286 | if (got_one) |
286 | if (got_one) |
… | |
… | |
860 | * what the converter wants, this will not do anything. |
860 | * what the converter wants, this will not do anything. |
861 | */ |
861 | */ |
862 | int |
862 | int |
863 | convert_item (object *item, object *converter) |
863 | convert_item (object *item, object *converter) |
864 | { |
864 | { |
865 | sint64 nr, price_in; |
865 | sint64 nr = 0, price_in; |
866 | |
866 | |
867 | if (item->flag [FLAG_UNPAID]) |
867 | if (item->flag [FLAG_UNPAID]) |
868 | return 0; |
868 | return 0; |
869 | |
869 | |
870 | shstr conv_from = converter->slaying; |
870 | shstr conv_from = converter->slaying; |
871 | archetype *conv_to = converter->other_arch; |
871 | archetype *conv_to = converter->other_arch; |
872 | sint64 need = converter->stats.food; |
872 | sint64 need = converter->stats.food; |
873 | sint64 give = converter->stats.sp; |
873 | sint64 give = converter->stats.sp; |
874 | |
874 | |
… | |
… | |
1353 | trap->stats.maxsp = 2; |
1353 | trap->stats.maxsp = 2; |
1354 | |
1354 | |
1355 | /* Is this correct? From the docs, it doesn't look like it |
1355 | /* Is this correct? From the docs, it doesn't look like it |
1356 | * should be divided by trap->speed |
1356 | * should be divided by trap->speed |
1357 | */ |
1357 | */ |
1358 | victim->speed_left = -FABS (trap->stats.maxsp * victim->speed / trap->speed); |
1358 | victim->speed_left = -trap->stats.maxsp * victim->speed / trap->speed; |
1359 | |
1359 | |
1360 | /* Just put in some sanity check. I think there is a bug in the |
1360 | /* Just put in some sanity check. I think there is a bug in the |
1361 | * above with some objects have zero speed, and thus the player |
1361 | * above with some objects have zero speed, and thus the player |
1362 | * getting permanently paralyzed. |
1362 | * getting permanently paralyzed. |
1363 | */ |
1363 | */ |
… | |
… | |
1404 | * trigger this here and get hit by own missile - and will be own enemy. |
1404 | * trigger this here and get hit by own missile - and will be own enemy. |
1405 | * Victim then is his own enemy and will start to kill herself (this is |
1405 | * Victim then is his own enemy and will start to kill herself (this is |
1406 | * removed) but we have not synced victim and his missile. To avoid senseless |
1406 | * removed) but we have not synced victim and his missile. To avoid senseless |
1407 | * action, we avoid hits here |
1407 | * action, we avoid hits here |
1408 | */ |
1408 | */ |
1409 | if ((QUERY_FLAG (victim, FLAG_ALIVE) && trap->speed) && trap->owner != victim) |
1409 | if ((QUERY_FLAG (victim, FLAG_ALIVE) && trap->has_active_speed ()) |
|
|
1410 | && trap->owner != victim) |
1410 | hit_with_arrow (trap, victim); |
1411 | hit_with_arrow (trap, victim); |
1411 | break; |
1412 | break; |
1412 | |
1413 | |
1413 | case SPELL_EFFECT: |
1414 | case SPELL_EFFECT: |
1414 | apply_spell_effect (trap, victim); |
1415 | apply_spell_effect (trap, victim); |
… | |
… | |
1765 | * instead of having their spell stored in stats.sp. These are |
1766 | * instead of having their spell stored in stats.sp. These are |
1766 | * legacy spellbooks |
1767 | * legacy spellbooks |
1767 | */ |
1768 | */ |
1768 | if (tmp->slaying) |
1769 | if (tmp->slaying) |
1769 | { |
1770 | { |
1770 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1771 | spell = find_archetype_by_object_name (tmp->slaying)->instance (); |
|
|
1772 | |
1771 | if (!spell) |
1773 | if (!spell) |
1772 | { |
1774 | { |
1773 | op->failmsg (format ("The book's formula for %s is incomplete.", &tmp->slaying)); |
1775 | op->failmsg (format ("The book's formula for %s is incomplete.", &tmp->slaying)); |
1774 | return; |
1776 | return; |
1775 | } |
1777 | } |
… | |
… | |
1852 | * literacy rate very useful! -b.t. |
1854 | * literacy rate very useful! -b.t. |
1853 | */ |
1855 | */ |
1854 | if (QUERY_FLAG (op, FLAG_CONFUSED)) |
1856 | if (QUERY_FLAG (op, FLAG_CONFUSED)) |
1855 | { |
1857 | { |
1856 | op->failmsg ("In your confused state you flub the wording of the text!"); |
1858 | op->failmsg ("In your confused state you flub the wording of the text!"); |
1857 | scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), MAX (spell->stats.sp, spell->stats.grace)); |
1859 | scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), max (spell->stats.sp, spell->stats.grace)); |
1858 | } |
1860 | } |
1859 | else if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || |
1861 | else if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || |
1860 | (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int]) |
1862 | (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int]) |
1861 | { |
1863 | { |
1862 | op->statusmsg ("You succeed in learning the spell!", NDI_GREEN); |
1864 | op->statusmsg ("You succeed in learning the spell!", NDI_GREEN); |
… | |
… | |
1996 | int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */ |
1998 | int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */ |
1997 | int winners = 0; /* number of winners */ |
1999 | int winners = 0; /* number of winners */ |
1998 | int i; /* index */ |
2000 | int i; /* index */ |
1999 | |
2001 | |
2000 | /* let's make sure and doublecheck the parameters */ |
2002 | /* let's make sure and doublecheck the parameters */ |
2001 | if (meal->type != FLESH || !is_dragon_pl (op)) |
2003 | if (meal->type != FLESH || !op->is_dragon ()) |
2002 | return 0; |
2004 | return 0; |
2003 | |
2005 | |
2004 | /* now grab the 'dragon_skin'- and 'dragon_ability'-forces |
2006 | /* now grab the 'dragon_skin'- and 'dragon_ability'-forces |
2005 | from the player's inventory */ |
2007 | from the player's inventory */ |
2006 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2008 | for (tmp = op->inv; tmp; tmp = tmp->below) |
… | |
… | |
2022 | op->stats.hp += meal->stats.food / 50; |
2024 | op->stats.hp += meal->stats.food / 50; |
2023 | |
2025 | |
2024 | if (op->stats.hp > op->stats.maxhp) |
2026 | if (op->stats.hp > op->stats.maxhp) |
2025 | op->stats.hp = op->stats.maxhp; |
2027 | op->stats.hp = op->stats.maxhp; |
2026 | |
2028 | |
2027 | op->stats.food = MIN (999, op->stats.food + meal->stats.food); |
2029 | op->stats.food = min (999, op->stats.food + meal->stats.food); |
2028 | |
2030 | |
2029 | /*LOG(llevDebug, "-> player: %d, flesh: %d\n", op->level, meal->level); */ |
2031 | /*LOG(llevDebug, "-> player: %d, flesh: %d\n", op->level, meal->level); */ |
2030 | |
2032 | |
2031 | /* on to the interesting part: chances for adding resistance */ |
2033 | /* on to the interesting part: chances for adding resistance */ |
2032 | for (i = 0; i < NROFATTACKS; i++) |
2034 | for (i = 0; i < NROFATTACKS; i++) |
… | |
… | |
2042 | |
2044 | |
2043 | /* monster bonus increases with level, because high-level |
2045 | /* monster bonus increases with level, because high-level |
2044 | flesh is too rare */ |
2046 | flesh is too rare */ |
2045 | mbonus = op->level * 20. / ((double) settings.max_level); |
2047 | mbonus = op->level * 20. / ((double) settings.max_level); |
2046 | |
2048 | |
2047 | chance = (((double) MIN (op->level + bonus, meal->level + bonus + mbonus)) * 100. / |
2049 | chance = (((double)min (op->level + bonus, meal->level + bonus + mbonus)) * 100. / |
2048 | ((double) settings.max_level)) - skin->resist[i]; |
2050 | ((double)settings.max_level)) - skin->resist[i]; |
2049 | |
2051 | |
2050 | if (chance >= 0.) |
2052 | if (chance >= 0.) |
2051 | chance += 1.; |
2053 | chance += 1.; |
2052 | else |
2054 | else |
2053 | chance = (chance < -12) ? 0. : 1. / pow (2., -chance); |
2055 | chance = (chance < -12) ? 0. : 1. / pow (2., -chance); |
2054 | |
2056 | |
2055 | /* chance is proportional to amount of resistance (max. 50) */ |
2057 | /* chance is proportional to amount of resistance (max. 50) */ |
2056 | chance *= ((double) (MIN (meal->resist[i], 50))) / 50.; |
2058 | chance *= ((double)(min (meal->resist[i], 50))) / 50.; |
2057 | |
2059 | |
2058 | /* doubled chance for resistance of ability-focus */ |
2060 | /* doubled chance for resistance of ability-focus */ |
2059 | if (i == abil->stats.exp) |
2061 | if (i == abil->stats.exp) |
2060 | chance = MIN (100., chance * 2.); |
2062 | chance = min (100., chance * 2.); |
2061 | |
2063 | |
2062 | /* now make the throw and save all winners (Don't insert luck bonus here!) */ |
2064 | /* now make the throw and save all winners (Don't insert luck bonus here!) */ |
2063 | if (rndm (10000) < (unsigned int) (chance * 100)) |
2065 | if (rndm (10000) < (unsigned int)(chance * 100)) |
2064 | { |
2066 | { |
2065 | atnr_winner[winners] = i; |
2067 | atnr_winner[winners] = i; |
2066 | winners++; |
2068 | winners++; |
2067 | } |
2069 | } |
2068 | |
2070 | |
… | |
… | |
2144 | if (op->type != PLAYER) |
2146 | if (op->type != PLAYER) |
2145 | op->stats.hp = op->stats.maxhp; |
2147 | op->stats.hp = op->stats.maxhp; |
2146 | else |
2148 | else |
2147 | { |
2149 | { |
2148 | /* check if this is a dragon (player), eating some flesh */ |
2150 | /* check if this is a dragon (player), eating some flesh */ |
2149 | if (tmp->type == FLESH && is_dragon_pl (op) && dragon_eat_flesh (op, tmp)) |
2151 | if (tmp->type == FLESH && op->is_dragon () && dragon_eat_flesh (op, tmp)) |
2150 | ; |
2152 | ; |
2151 | else |
2153 | else |
2152 | { |
2154 | { |
2153 | /* usual case - no dragon meal: */ |
2155 | /* usual case - no dragon meal: */ |
2154 | if (op->stats.food + tmp->stats.food > 999) |
2156 | if (op->stats.food + tmp->stats.food > 999) |
… | |
… | |
2169 | |
2171 | |
2170 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2172 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2171 | { |
2173 | { |
2172 | const char *buf; |
2174 | const char *buf; |
2173 | |
2175 | |
2174 | if (!is_dragon_pl (op)) |
2176 | if (!op->is_dragon ()) |
2175 | { |
2177 | { |
2176 | /* eating message for normal players */ |
2178 | /* eating message for normal players */ |
2177 | if (tmp->type == DRINK) |
2179 | if (tmp->type == DRINK) |
2178 | buf = format ("Ahhh...that %s tasted good.", &tmp->name); |
2180 | buf = format ("Ahhh...that %s tasted good.", &tmp->name); |
2179 | else |
2181 | else |
… | |
… | |
2618 | static void |
2620 | static void |
2619 | apply_item_transformer (object *pl, object *transformer) |
2621 | apply_item_transformer (object *pl, object *transformer) |
2620 | { |
2622 | { |
2621 | object *marked; |
2623 | object *marked; |
2622 | object *new_item; |
2624 | object *new_item; |
2623 | char *find; |
2625 | const char *find; |
2624 | char *separator; |
2626 | char *separator; |
2625 | int yield; |
2627 | int yield; |
2626 | char got[MAX_BUF]; |
2628 | char got[MAX_BUF]; |
2627 | int len; |
2629 | int len; |
2628 | |
2630 | |
… | |
… | |
2671 | while (*find == ' ') |
2673 | while (*find == ' ') |
2672 | find++; |
2674 | find++; |
2673 | |
2675 | |
2674 | memset (got, 0, MAX_BUF); |
2676 | memset (got, 0, MAX_BUF); |
2675 | |
2677 | |
2676 | if ((separator = strchr (find, ';')) != NULL) |
2678 | if ((separator = strchr (find, ';'))) |
2677 | len = separator - find; |
2679 | len = separator - find; |
2678 | else |
2680 | else |
2679 | len = strlen (find); |
2681 | len = strlen (find); |
2680 | |
2682 | |
2681 | if (len > MAX_BUF - 1) |
2683 | min_it (len, MAX_BUF - 1); |
2682 | len = MAX_BUF - 1; |
|
|
2683 | |
2684 | |
2684 | strcpy (got, find); |
2685 | strcpy (got, find); |
2685 | got[len] = '\0'; |
2686 | got[len] = '\0'; |
2686 | |
2687 | |
2687 | /* Now create new item, remove used ones when required. */ |
2688 | /* Now create new item, remove used ones when required. */ |
… | |
… | |
3878 | * treasure again for this object |
3879 | * treasure again for this object |
3879 | */ |
3880 | */ |
3880 | invtmp->randomitems = NULL; |
3881 | invtmp->randomitems = NULL; |
3881 | } |
3882 | } |
3882 | } |
3883 | } |
|
|
3884 | |
3883 | /* This is really temporary - the code at the bottom will |
3885 | /* This is really temporary - the code at the bottom will |
3884 | * also set randomitems to null. The problem is there are bunches |
3886 | * also set randomitems to null. The problem is there are bunches |
3885 | * of maps/players already out there with items that have spells |
3887 | * of maps/players already out there with items that have spells |
3886 | * which haven't had the randomitems set to null yet. |
3888 | * which haven't had the randomitems set to null yet. |
3887 | * MSW 2004-05-13 |
3889 | * MSW 2004-05-13 |
… | |
… | |
3891 | * Ryo 2004-08-16 |
3893 | * Ryo 2004-08-16 |
3892 | */ |
3894 | */ |
3893 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3895 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3894 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3896 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3895 | tmp->randomitems = NULL; |
3897 | tmp->randomitems = NULL; |
3896 | |
|
|
3897 | } |
3898 | } |
3898 | |
3899 | |
3899 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3900 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3900 | auto_apply (tmp); |
3901 | auto_apply (tmp); |
3901 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
3902 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
… | |
… | |
3958 | /* bigger morsel of food = longer effect time */ |
3959 | /* bigger morsel of food = longer effect time */ |
3959 | int duration = TIME2TICK (food->stats.food); |
3960 | int duration = TIME2TICK (food->stats.food); |
3960 | |
3961 | |
3961 | if (force = who->force_find (key)) |
3962 | if (force = who->force_find (key)) |
3962 | { |
3963 | { |
3963 | if (duration > abs (force->speed_left / force->speed)) |
3964 | if (duration > fabs (force->speed_left / force->speed)) |
3964 | { |
3965 | { |
3965 | new_draw_info_format (NDI_UNIQUE, 0, who, "More magical force spreads through you. H<The effect will last for about %.10g more seconds.>", TICK2TIME (duration)); |
3966 | new_draw_info_format (NDI_UNIQUE, 0, who, "More magical force spreads through you. H<The effect will last for about %.10g more seconds.>", TICK2TIME (duration)); |
3966 | force->force_set_timer (duration); |
3967 | force->force_set_timer (duration); |
3967 | } |
3968 | } |
3968 | else |
3969 | else |