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

Function dowizcast

src/spell.c:786–815  ·  view source on GitHub ↗

#wizcast - cast any spell even without knowing it */

Source from the content-addressed store, hash-verified

784
785/* #wizcast - cast any spell even without knowing it */
786int
787dowizcast(void)
788{
789 winid win;
790 menu_item *selected;
791 anything any;
792 int i, n;
793
794 win = create_nhwindow(NHW_MENU);
795 start_menu(win, MENU_BEHAVE_STANDARD);
796 any = cg.zeroany;
797
798 for (i = 0; i < MAXSPELL; i++) {
799 n = (SPE_DIG + i);
800 if (n >= SPE_BLANK_PAPER)
801 break;
802 any.a_int = n;
803 add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, NO_COLOR,
804 OBJ_NAME(objects[n]), MENU_ITEMFLAGS_NONE);
805 }
806 end_menu(win, "Cast which spell?");
807 n = select_menu(win, PICK_ONE, &selected);
808 destroy_nhwindow(win);
809 if (n > 0) {
810 i = selected[0].item.a_int;
811 free((genericptr_t) selected);
812 return spelleffects(i, FALSE, TRUE);
813 }
814 return ECMD_OK;
815}
816
817
818/* the #cast command -- cast a spell */

Callers

nothing calls this directly

Calls 3

add_menuFunction · 0.85
select_menuFunction · 0.85
spelleffectsFunction · 0.85

Tested by

no test coverage detected