MCPcopy Index your code
hub / github.com/NetHack/NetHack / throwspell

Function throwspell

src/spell.c:1654–1702  ·  view source on GitHub ↗

Choose location where spell takes effect. */

Source from the content-addressed store, hash-verified

1652
1653/* Choose location where spell takes effect. */
1654staticfn int
1655throwspell(void)
1656{
1657 coord cc, uc;
1658 struct monst *mtmp;
1659
1660 if (u.uinwater) {
1661 pline("You're joking! In this weather?");
1662 return 0;
1663 } else if (Is_waterlevel(&u.uz)) {
1664 You("had better wait for the sun to come out.");
1665 return 0;
1666 }
1667
1668 pline("Where do you want to cast the spell?");
1669 cc.x = u.ux;
1670 cc.y = u.uy;
1671 getpos_sethilite(display_spell_target_positions,
1672 can_center_spell_location);
1673 if (getpos(&cc, TRUE, "the desired position") < 0)
1674 return 0; /* user pressed ESC */
1675 clear_nhwindow(WIN_MESSAGE); /* discard any autodescribe feedback */
1676
1677 /* The number of moves from hero to where the spell drops.*/
1678 if (distmin(u.ux, u.uy, cc.x, cc.y) > 10) {
1679 pline_The("spell dissipates over the distance!");
1680 return 0;
1681 } else if (u.uswallow) {
1682 pline_The("spell is cut short!");
1683 exercise(A_WIS, FALSE); /* What were you THINKING! */
1684 u.dx = 0;
1685 u.dy = 0;
1686 return 1;
1687 } else if (((cc.x != u.ux || cc.y != u.uy) && !cansee(cc.x, cc.y)
1688 && (!(mtmp = m_at(cc.x, cc.y)) || !canspotmon(mtmp)))
1689 || IS_STWALL(levl[cc.x][cc.y].typ)) {
1690 Your("mind fails to lock onto that location!");
1691 return 0;
1692 }
1693
1694 uc.x = u.ux;
1695 uc.y = u.uy;
1696
1697 walk_path(&uc, &cc, spell_aim_step, (genericptr_t) 0);
1698
1699 u.dx = cc.x;
1700 u.dy = cc.y;
1701 return 1;
1702}
1703
1704/* add/hide/remove/unhide teleport-away on behalf of dotelecmd() to give
1705 more control to behavior of ^T when used in wizard mode */

Callers 1

spelleffectsFunction · 0.85

Calls 9

YouFunction · 0.85
getpos_sethiliteFunction · 0.85
getposFunction · 0.85
distminFunction · 0.85
pline_TheFunction · 0.85
exerciseFunction · 0.85
YourFunction · 0.85
walk_pathFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected