MCPcopy Create free account
hub / github.com/NetHack/NetHack / doengrave

Function doengrave

src/engrave.c:955–1263  ·  view source on GitHub ↗

the #engrave command */

Source from the content-addressed store, hash-verified

953
954/* the #engrave command */
955int
956doengrave(void)
957{
958 char *sp; /* Place holder for space count of engr text */
959 struct _doengrave_ctx *de;
960 int retval;
961 boolean initial_msg_given = FALSE;
962
963 /* Can the adventurer engrave at all? */
964 if (!u_can_engrave())
965 return ECMD_FAIL;
966
967 de = (struct _doengrave_ctx *) alloc(sizeof (struct _doengrave_ctx));
968 doengrave_ctx_init(de);
969
970 gm.multi = 0; /* moves consumed */
971 gn.nomovemsg = (char *) 0; /* occupation end message */
972
973 /* One may write with finger, or weapon, or wand, or..., or...
974 * Edited by GAN 10/20/86 so as not to change weapon wielded.
975 */
976
977 de->otmp = getobj("write with", stylus_ok, GETOBJ_PROMPT);
978 if (!de->otmp) {/* otmp == &hands_obj if fingers */
979 de->ret = ECMD_CANCEL;
980 goto doengr_exit;
981 }
982
983 if (de->otmp == &hands_obj) {
984 Strcat(strcpy(de->fbuf, "your "), body_part(FINGERTIP));
985 de->writer = de->fbuf;
986 } else {
987 de->writer = yname(de->otmp);
988 }
989
990 /* There's no reason you should be able to write with a wand
991 * while both your hands are tied up.
992 */
993 if (!freehand() && de->otmp != uwep && !de->otmp->owornmask) {
994 You("have no free %s to write with!", body_part(HAND));
995 goto doengr_exit;
996 }
997
998 if (de->jello) {
999 You("tickle %s with %s.", mon_nam(u.ustuck), de->writer);
1000 Your("message dissolves...");
1001 goto doengr_exit;
1002 }
1003 if (!can_reach_floor(TRUE)) {
1004 if (de->otmp->oclass != WAND_CLASS) {
1005 cant_reach_floor(u.ux, u.uy, FALSE, TRUE, FALSE);
1006 goto doengr_exit;
1007 } else {
1008 You("gesture, with your wand, towards the %s below you.",
1009 surface(u.ux, u.uy));
1010 initial_msg_given = TRUE;
1011 }
1012 }

Callers

nothing calls this directly

Calls 15

u_can_engraveFunction · 0.85
doengrave_ctx_initFunction · 0.85
getobjFunction · 0.85
body_partFunction · 0.85
ynameFunction · 0.85
freehandFunction · 0.85
YouFunction · 0.85
mon_namFunction · 0.85
YourFunction · 0.85
can_reach_floorFunction · 0.85
cant_reach_floorFunction · 0.85
surfaceFunction · 0.85

Tested by

no test coverage detected