From 9c3c378b5c998e689cefd9cad3e2deb863cbcefa Mon Sep 17 00:00:00 2001 From: Joe Wreschnig Date: Fri, 5 Apr 2013 15:51:57 +0200 Subject: [PATCH] Add gift, embrace commands. Implement flirting with nothing. --- command.c | 7 +++++++ init.c | 5 +++-- rogue.h | 3 ++- romance.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 68 insertions(+), 5 deletions(-) diff --git a/command.c b/command.c index c85020a..52e7e62 100644 --- a/command.c +++ b/command.c @@ -150,6 +150,13 @@ command() after = FALSE; else flirt(delta.y, delta.x); + when 'g': + if (!get_dir()) + after = FALSE; + else + gift(delta.y, delta.x); + when 'E': + embrace(); when '>' : after = FALSE; d_level(); when '<' : after = FALSE; u_level(); when '?' : after = FALSE; help(); diff --git a/init.c b/init.c index c75f5e7..50cbc51 100644 --- a/init.c +++ b/init.c @@ -559,7 +559,6 @@ struct h_list helpstr[] = { 'B', " run down & left", 'N', " run down & right", 't', " throw something", - 'f', " flirt with someone", 'p', " zap a wand in a direction", 'z', " zap a wand or staff", '>', " go down a staircase", @@ -577,12 +576,14 @@ struct h_list helpstr[] = { 'R', " remove ring", 'd', " drop object", 'c', " call object", + 'f', " flirt with someone", + 'g', " give an item as a gift", + 'E', " embrace", 'o', " examine/set options", CTRL('L'), " redraw screen", CTRL('R'), " repeat last message", ESCAPE, " cancel command", 'v', " print program version number", - '!', " shell escape", 'S', " save game", 'Q', " quit", 0, 0 diff --git a/rogue.h b/rogue.h index 0281b1d..f426f9e 100644 --- a/rogue.h +++ b/rogue.h @@ -48,7 +48,7 @@ #define otherwise break;default #define until(expr) while(!(expr)) #define ce(a, b) ((a).x == (b).x && (a).y == (b).y) -#define draw(window) (wrefresh(window),usleep(50000)) +#define draw(window) (wrefresh(window),usleep(20000)) #define hero player.t_pos #define pstats player.t_stats #define pack player.t_pack @@ -71,6 +71,7 @@ #define newgrp() ++group #define o_charges o_ac #define ISMULT(type) (type == POTION || type == SCROLL || type == FOOD) +#define rndchoice(a) (a[rnd(sizeof(a)/sizeof((a)[0]))]) /* * Things that appear on the screens diff --git a/romance.c b/romance.c index 70a06a1..a47b897 100644 --- a/romance.c +++ b/romance.c @@ -23,11 +23,65 @@ flirt(ydelta, xdelta) int ydelta, xdelta; { - register struct linked_list *item, *nitem; - struct object obj; + register struct linked_list *item; + struct object obj = {}; obj.o_pos = hero; obj.o_type = '~'; do_motion(&obj, ydelta, xdelta); mvwaddch(cw, hero.y, hero.x, PLAYER); + if ((item = find_mons(obj.o_pos.y, obj.o_pos.x)) == NULL) + { + const char *msgs[] = { + "You wink at nothing in particular.", + "You smile suggestively at the wall.", + "Unprompted, you suddenly blush.", + }; + msg(rndchoice(msgs)); + return; + } +} + +gift(ydelta, xdelta) +int ydelta, xdelta; +{ + register struct linked_list *obj, *nobj; + register struct linked_list *mob; + register struct object *op; + register struct thing *tp; + register bool did_hit = TRUE; + + if ((mob = find_mons(hero.y + ydelta, hero.x + xdelta)) == NULL) + { + msg("There's no-one around here."); + return(0); + } + tp = (struct thing *) ldata(mob); + + if ((obj = get_item("give", 0)) == NULL) + return; + op = (struct object *) ldata(obj); + if (!dropcheck(op)) + return; + /* + * Take it out of the pack + */ + if (op->o_count >= 2 && op->o_type != WEAPON) + { + nobj = new_item(sizeof *op); + op->o_count--; + op = (struct object *) ldata(nobj); + *op = *((struct object *) ldata(obj)); + op->o_count = 1; + obj = nobj; + if (op->o_group != 0) + inpack++; + } + else + detach(pack, obj); + inpack--; +} + +embrace() +{ } -- 2.30.2