… | |
… | |
172 | */ |
172 | */ |
173 | int |
173 | int |
174 | apply_potion (object *op, object *tmp) |
174 | apply_potion (object *op, object *tmp) |
175 | { |
175 | { |
176 | int got_one = 0, i; |
176 | int got_one = 0, i; |
177 | object *force = 0, *floor = 0; |
177 | object *force = 0; |
178 | |
178 | |
179 | floor = GET_MAP_OB (op->map, op->x, op->y); |
179 | object *floor = GET_MAP_OB (op->map, op->x, op->y); |
180 | |
180 | |
181 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
181 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
182 | { |
182 | { |
183 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
183 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
184 | |
184 | |
… | |
… | |
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 | */ |
… | |
… | |
1576 | : lev_diff < 15 ? "This book is way beyond your comprehension." |
1576 | : lev_diff < 15 ? "This book is way beyond your comprehension." |
1577 | : "This book is totally beyond your comprehension."); |
1577 | : "This book is totally beyond your comprehension."); |
1578 | return; |
1578 | return; |
1579 | } |
1579 | } |
1580 | |
1580 | |
|
|
1581 | // we currently don't use the message types for anything. |
1581 | readable_message_type *msgType = get_readable_message_type (tmp); |
1582 | // readable_message_type *msgType = get_readable_message_type (tmp); |
|
|
1583 | |
|
|
1584 | tmp->play_sound (tmp->sound ? tmp->sound : sound_find ("apply_book")); |
1582 | |
1585 | |
1583 | if (player *pl = op->contr) |
1586 | if (player *pl = op->contr) |
1584 | if (client *ns = pl->ns) |
1587 | if (client *ns = pl->ns) |
1585 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
1588 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
1586 | |
1589 | |
… | |
… | |
1766 | * instead of having their spell stored in stats.sp. These are |
1769 | * instead of having their spell stored in stats.sp. These are |
1767 | * legacy spellbooks |
1770 | * legacy spellbooks |
1768 | */ |
1771 | */ |
1769 | if (tmp->slaying) |
1772 | if (tmp->slaying) |
1770 | { |
1773 | { |
1771 | spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); |
1774 | spell = find_archetype_by_object_name (tmp->slaying)->instance (); |
|
|
1775 | |
1772 | if (!spell) |
1776 | if (!spell) |
1773 | { |
1777 | { |
1774 | op->failmsg (format ("The book's formula for %s is incomplete.", &tmp->slaying)); |
1778 | op->failmsg (format ("The book's formula for %s is incomplete.", &tmp->slaying)); |
1775 | return; |
1779 | return; |
1776 | } |
1780 | } |
… | |
… | |
1997 | int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */ |
2001 | int atnr_winner[NROFATTACKS]; /* winning candidates for resistance improvement */ |
1998 | int winners = 0; /* number of winners */ |
2002 | int winners = 0; /* number of winners */ |
1999 | int i; /* index */ |
2003 | int i; /* index */ |
2000 | |
2004 | |
2001 | /* let's make sure and doublecheck the parameters */ |
2005 | /* let's make sure and doublecheck the parameters */ |
2002 | if (meal->type != FLESH || !is_dragon_pl (op)) |
2006 | if (meal->type != FLESH || !op->is_dragon ()) |
2003 | return 0; |
2007 | return 0; |
2004 | |
2008 | |
2005 | /* now grab the 'dragon_skin'- and 'dragon_ability'-forces |
2009 | /* now grab the 'dragon_skin'- and 'dragon_ability'-forces |
2006 | from the player's inventory */ |
2010 | from the player's inventory */ |
2007 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2011 | for (tmp = op->inv; tmp; tmp = tmp->below) |
… | |
… | |
2145 | if (op->type != PLAYER) |
2149 | if (op->type != PLAYER) |
2146 | op->stats.hp = op->stats.maxhp; |
2150 | op->stats.hp = op->stats.maxhp; |
2147 | else |
2151 | else |
2148 | { |
2152 | { |
2149 | /* check if this is a dragon (player), eating some flesh */ |
2153 | /* check if this is a dragon (player), eating some flesh */ |
2150 | if (tmp->type == FLESH && is_dragon_pl (op) && dragon_eat_flesh (op, tmp)) |
2154 | if (tmp->type == FLESH && op->is_dragon () && dragon_eat_flesh (op, tmp)) |
2151 | ; |
2155 | ; |
2152 | else |
2156 | else |
2153 | { |
2157 | { |
2154 | /* usual case - no dragon meal: */ |
2158 | /* usual case - no dragon meal: */ |
2155 | if (op->stats.food + tmp->stats.food > 999) |
2159 | if (op->stats.food + tmp->stats.food > 999) |
… | |
… | |
2170 | |
2174 | |
2171 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2175 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2172 | { |
2176 | { |
2173 | const char *buf; |
2177 | const char *buf; |
2174 | |
2178 | |
2175 | if (!is_dragon_pl (op)) |
2179 | if (!op->is_dragon ()) |
2176 | { |
2180 | { |
2177 | /* eating message for normal players */ |
2181 | /* eating message for normal players */ |
2178 | if (tmp->type == DRINK) |
2182 | if (tmp->type == DRINK) |
2179 | buf = format ("Ahhh...that %s tasted good.", &tmp->name); |
2183 | buf = format ("Ahhh...that %s tasted good.", &tmp->name); |
2180 | else |
2184 | else |
… | |
… | |
2619 | static void |
2623 | static void |
2620 | apply_item_transformer (object *pl, object *transformer) |
2624 | apply_item_transformer (object *pl, object *transformer) |
2621 | { |
2625 | { |
2622 | object *marked; |
2626 | object *marked; |
2623 | object *new_item; |
2627 | object *new_item; |
2624 | char *find; |
2628 | const char *find; |
2625 | char *separator; |
2629 | char *separator; |
2626 | int yield; |
2630 | int yield; |
2627 | char got[MAX_BUF]; |
2631 | char got[MAX_BUF]; |
2628 | int len; |
2632 | int len; |
2629 | |
2633 | |
… | |
… | |
2672 | while (*find == ' ') |
2676 | while (*find == ' ') |
2673 | find++; |
2677 | find++; |
2674 | |
2678 | |
2675 | memset (got, 0, MAX_BUF); |
2679 | memset (got, 0, MAX_BUF); |
2676 | |
2680 | |
2677 | if ((separator = strchr (find, ';')) != NULL) |
2681 | if ((separator = (char *) strchr (find, ';'))) |
2678 | len = separator - find; |
2682 | len = separator - find; |
2679 | else |
2683 | else |
2680 | len = strlen (find); |
2684 | len = strlen (find); |
2681 | |
2685 | |
2682 | if (len > MAX_BUF - 1) |
2686 | min_it (len, MAX_BUF - 1); |
2683 | len = MAX_BUF - 1; |
|
|
2684 | |
2687 | |
2685 | strcpy (got, find); |
2688 | strcpy (got, find); |
2686 | got[len] = '\0'; |
2689 | got[len] = '\0'; |
2687 | |
2690 | |
2688 | /* Now create new item, remove used ones when required. */ |
2691 | /* Now create new item, remove used ones when required. */ |
… | |
… | |
3879 | * treasure again for this object |
3882 | * treasure again for this object |
3880 | */ |
3883 | */ |
3881 | invtmp->randomitems = NULL; |
3884 | invtmp->randomitems = NULL; |
3882 | } |
3885 | } |
3883 | } |
3886 | } |
|
|
3887 | |
3884 | /* This is really temporary - the code at the bottom will |
3888 | /* This is really temporary - the code at the bottom will |
3885 | * also set randomitems to null. The problem is there are bunches |
3889 | * also set randomitems to null. The problem is there are bunches |
3886 | * of maps/players already out there with items that have spells |
3890 | * of maps/players already out there with items that have spells |
3887 | * which haven't had the randomitems set to null yet. |
3891 | * which haven't had the randomitems set to null yet. |
3888 | * MSW 2004-05-13 |
3892 | * MSW 2004-05-13 |
… | |
… | |
3892 | * Ryo 2004-08-16 |
3896 | * Ryo 2004-08-16 |
3893 | */ |
3897 | */ |
3894 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3898 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3895 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3899 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3896 | tmp->randomitems = NULL; |
3900 | tmp->randomitems = NULL; |
3897 | |
|
|
3898 | } |
3901 | } |
3899 | |
3902 | |
3900 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3903 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3901 | auto_apply (tmp); |
3904 | auto_apply (tmp); |
3902 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
3905 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
… | |
… | |
3959 | /* bigger morsel of food = longer effect time */ |
3962 | /* bigger morsel of food = longer effect time */ |
3960 | int duration = TIME2TICK (food->stats.food); |
3963 | int duration = TIME2TICK (food->stats.food); |
3961 | |
3964 | |
3962 | if (force = who->force_find (key)) |
3965 | if (force = who->force_find (key)) |
3963 | { |
3966 | { |
3964 | if (duration > abs (force->speed_left / force->speed)) |
3967 | if (duration > fabs (force->speed_left / force->speed)) |
3965 | { |
3968 | { |
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)); |
3969 | 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)); |
3967 | force->force_set_timer (duration); |
3970 | force->force_set_timer (duration); |
3968 | } |
3971 | } |
3969 | else |
3972 | else |