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

Function act_on_act

src/cmd.c:4657–4838  ·  view source on GitHub ↗

queue up command(s) to perform #therecmdmenu action */

Source from the content-addressed store, hash-verified

4655
4656/* queue up command(s) to perform #therecmdmenu action */
4657staticfn void
4658act_on_act(
4659 int act, /* action */
4660 coordxy dx, coordxy dy) /* delta to adjacent spot (farther sometimes) */
4661{
4662 struct obj *otmp;
4663 int dir;
4664
4665 /* a few there_cmd_menu_far() actions use dx,dy differently */
4666 switch (act) {
4667 case MCMD_THROW_OBJ:
4668 case MCMD_TRAVEL:
4669 case MCMD_LOOK_AT:
4670 /* keep dx,dy as-is */
4671 break;
4672 default:
4673 /* force dx and dy to be +1, 0, or -1 */
4674 dx = sgn(dx);
4675 dy = sgn(dy);
4676 break;
4677 }
4678
4679 switch (act) {
4680 case MCMD_TRAVEL:
4681 /* FIXME: player has explicitly picked "travel to this location"
4682 from the menu but it will only work if flags.travelcmd is True.
4683 That option is intended as way to guard against stray mouse
4684 clicks and shouldn't inhibit explicit travel. */
4685 iflags.travelcc.x = u.tx = u.ux + dx;
4686 iflags.travelcc.y = u.ty = u.uy + dy;
4687 cmdq_add_ec(CQ_CANNED, dotravel_target);
4688 break;
4689 case MCMD_THROW_OBJ:
4690 cmdq_add_ec(CQ_CANNED, dothrow);
4691 cmdq_add_userinput(CQ_CANNED);
4692 cmdq_add_dir(CQ_CANNED, dx, dy, 0);
4693 break;
4694 case MCMD_OPEN_DOOR:
4695 cmdq_add_ec(CQ_CANNED, doopen);
4696 cmdq_add_dir(CQ_CANNED, dx, dy, 0);
4697 break;
4698 case MCMD_LOCK_DOOR:
4699 otmp = carrying(SKELETON_KEY);
4700 if (!otmp)
4701 otmp = carrying(LOCK_PICK);
4702 if (!otmp)
4703 otmp = carrying(CREDIT_CARD);
4704 if (otmp) {
4705 cmdq_add_ec(CQ_CANNED, doapply);
4706 cmdq_add_key(CQ_CANNED, otmp->invlet);
4707 cmdq_add_dir(CQ_CANNED, dx, dy, 0);
4708 cmdq_add_key(CQ_CANNED, 'y'); /* "Lock it?" */
4709 }
4710 break;
4711 case MCMD_UNTRAP_DOOR:
4712 cmdq_add_ec(CQ_CANNED, dountrap);
4713 cmdq_add_dir(CQ_CANNED, dx, dy, 0);
4714 break;

Callers 1

there_cmd_menuFunction · 0.85

Calls 7

sgnFunction · 0.85
cmdq_add_ecFunction · 0.85
cmdq_add_userinputFunction · 0.85
cmdq_add_dirFunction · 0.85
carryingFunction · 0.85
cmdq_add_keyFunction · 0.85
xytodirFunction · 0.85

Tested by

no test coverage detected