Tips and option to disable them
Adds a more general way to handle gameplay tips, and adds a boolean option "tips", which can be used to disable all tips. Adds a helpful longer message when the game goes into the "farlook" mode. Also adds a lua binding to easily show multi-line text in a menu window. Breaks save compat.
This commit is contained in:
@@ -806,6 +806,8 @@ getpos(coord *ccp, boolean force, const char *goal)
|
||||
mMoOdDxX[i] = gc.Cmd.spkeys[mMoOdDxX_def[i]];
|
||||
mMoOdDxX[SIZE(mMoOdDxX_def)] = '\0';
|
||||
|
||||
handle_tip(TIP_GETPOS);
|
||||
|
||||
if (!goal)
|
||||
goal = "desired location";
|
||||
if (Verbose(0, getpos1)) {
|
||||
|
||||
35
src/hack.c
35
src/hack.c
@@ -1641,6 +1641,32 @@ u_simple_floortyp(coordxy x, coordxy y)
|
||||
return ROOM;
|
||||
}
|
||||
|
||||
/* maybe show a helpful gameplay tip? */
|
||||
void
|
||||
handle_tip(int tip)
|
||||
{
|
||||
if (!flags.tips)
|
||||
return;
|
||||
|
||||
if (tip >= 0 && tip < NUM_TIPS && !gc.context.tips[tip]) {
|
||||
gc.context.tips[tip] = TRUE;
|
||||
switch (tip) {
|
||||
case TIP_ENHANCE:
|
||||
pline("(Use the #enhance command to advance them.)");
|
||||
break;
|
||||
case TIP_SWIM:
|
||||
pline("(Use '%s' prefix to step in if you really want to.)",
|
||||
visctrl(cmd_from_func(do_reqmenu)));
|
||||
break;
|
||||
case TIP_GETPOS:
|
||||
l_nhcore_call(NHCORE_GETPOS_TIP);
|
||||
break;
|
||||
default:
|
||||
impossible("Unknown tip in handle_tip(%i)", tip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Is it dangerous for hero to move to x,y due to water or lava? */
|
||||
static boolean
|
||||
swim_move_danger(coordxy x, coordxy y)
|
||||
@@ -1665,18 +1691,13 @@ swim_move_danger(coordxy x, coordxy y)
|
||||
|| liquid_wall) {
|
||||
if (gc.context.nopick) {
|
||||
/* moving with m-prefix */
|
||||
gc.context.swim_tip = TRUE;
|
||||
gc.context.tips[TIP_SWIM] = TRUE;
|
||||
return FALSE;
|
||||
} else if (ParanoidSwim || liquid_wall) {
|
||||
You("avoid %s into the %s.",
|
||||
ing_suffix(u_locomotion("step")),
|
||||
waterbody_name(x, y));
|
||||
if (!gc.context.swim_tip) {
|
||||
pline(
|
||||
"(Use '%s' prefix to step in if you really want to.)",
|
||||
visctrl(cmd_from_func(do_reqmenu)));
|
||||
gc.context.swim_tip = TRUE;
|
||||
}
|
||||
handle_tip(TIP_SWIM);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
50
src/nhlua.c
50
src/nhlua.c
@@ -49,6 +49,7 @@ static int nhl_pline(lua_State *);
|
||||
static int nhl_verbalize(lua_State *);
|
||||
static int nhl_parse_config(lua_State *);
|
||||
static int nhl_menu(lua_State *);
|
||||
static int nhl_text(lua_State *);
|
||||
static int nhl_getlin(lua_State *);
|
||||
static int nhl_makeplural(lua_State *);
|
||||
static int nhl_makesingular(lua_State *);
|
||||
@@ -80,6 +81,7 @@ static const char *const nhcore_call_names[NUM_NHCORE_CALLS] = {
|
||||
"restore_old_game",
|
||||
"moveloop_turn",
|
||||
"game_exit",
|
||||
"getpos_tip",
|
||||
};
|
||||
static boolean nhcore_call_available[NUM_NHCORE_CALLS];
|
||||
|
||||
@@ -769,6 +771,53 @@ nhl_menu(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* text("foo\nbar\nbaz") */
|
||||
static int
|
||||
nhl_text(lua_State *L)
|
||||
{
|
||||
int argc = lua_gettop(L);
|
||||
|
||||
if (argc > 0) {
|
||||
menu_item *picks = (menu_item *) 0;
|
||||
winid tmpwin;
|
||||
anything any = cg.zeroany;
|
||||
|
||||
tmpwin = create_nhwindow(NHW_MENU);
|
||||
start_menu(tmpwin, MENU_BEHAVE_STANDARD);
|
||||
|
||||
while (lua_gettop(L) > 0) {
|
||||
char *ostr = dupstr(luaL_checkstring(L, 1));
|
||||
char *ptr, *str = ostr;
|
||||
char *lstr = str + strlen(str) - 1;
|
||||
|
||||
do {
|
||||
char *nlp = strchr(str, '\n');
|
||||
|
||||
if (nlp && (nlp - str) <= 76) {
|
||||
ptr = nlp;
|
||||
} else {
|
||||
ptr = str + 76;
|
||||
if (ptr > lstr)
|
||||
ptr = lstr;
|
||||
}
|
||||
while ((ptr > str) && !(*ptr == ' ' || *ptr == '\n'))
|
||||
ptr--;
|
||||
*ptr = '\0';
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, 0,
|
||||
str, MENU_ITEMFLAGS_NONE);
|
||||
str = ptr + 1;
|
||||
} while (*str && str <= lstr);
|
||||
lua_pop(L, 1);
|
||||
free(ostr);
|
||||
}
|
||||
|
||||
end_menu(tmpwin, (char *) 0);
|
||||
(void) select_menu(tmpwin, PICK_NONE, &picks);
|
||||
destroy_nhwindow(tmpwin);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* makeplural("zorkmid") */
|
||||
static int
|
||||
nhl_makeplural(lua_State *L)
|
||||
@@ -1448,6 +1497,7 @@ static const struct luaL_Reg nhl_functions[] = {
|
||||
{"pline", nhl_pline},
|
||||
{"verbalize", nhl_verbalize},
|
||||
{"menu", nhl_menu},
|
||||
{"text", nhl_text},
|
||||
{"getlin", nhl_getlin},
|
||||
|
||||
{"makeplural", nhl_makeplural},
|
||||
|
||||
@@ -77,11 +77,7 @@ give_may_advance_msg(int skill)
|
||||
: (skill <= P_LAST_WEAPON) ? "weapon "
|
||||
: (skill <= P_LAST_SPELL) ? "spell casting "
|
||||
: "fighting ");
|
||||
|
||||
if (!gc.context.enhance_tip) {
|
||||
gc.context.enhance_tip = TRUE;
|
||||
pline("(Use the #enhance command to advance them.)");
|
||||
}
|
||||
handle_tip(TIP_ENHANCE);
|
||||
}
|
||||
|
||||
/* weapon's skill category name for use as generalized description of weapon;
|
||||
@@ -1170,7 +1166,7 @@ enhance_weapon_skill(void)
|
||||
int clr = 0;
|
||||
|
||||
/* player knows about #enhance, don't show tip anymore */
|
||||
gc.context.enhance_tip = TRUE;
|
||||
gc.context.tips[TIP_ENHANCE] = TRUE;
|
||||
|
||||
if (wizard && y_n("Advance skills without practice?") == 'y')
|
||||
speedy = TRUE;
|
||||
|
||||
Reference in New Issue
Block a user