Add gift, embrace commands. Implement flirting with nothing.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Fri, 5 Apr 2013 13:51:57 +0000 (15:51 +0200)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Fri, 5 Apr 2013 13:51:57 +0000 (15:51 +0200)
command.c
init.c
rogue.h
romance.c

index c85020a..52e7e62 100644 (file)
--- a/command.c
+++ b/command.c
@@ -150,6 +150,13 @@ command()
                        after = FALSE;\r
                    else\r
                        flirt(delta.y, delta.x);\r
+                when 'g':\r
+                   if (!get_dir())\r
+                       after = FALSE;\r
+                   else\r
+                       gift(delta.y, delta.x);\r
+                when 'E':\r
+                    embrace();\r
                when '>' : after = FALSE; d_level();\r
                when '<' : after = FALSE; u_level();\r
                when '?' : after = FALSE; help();\r
diff --git a/init.c b/init.c
index c75f5e7..50cbc51 100644 (file)
--- a/init.c
+++ b/init.c
@@ -559,7 +559,6 @@ struct h_list helpstr[] = {
     'B',       "       run down & left",\r
     'N',       "       run down & right",\r
     't',       "<dir>  throw something",\r
-    'f',       "<dir>  flirt with someone",\r
     'p',       "<dir>  zap a wand in a direction",\r
     'z',       "       zap a wand or staff",\r
     '>',       "       go down a staircase",\r
@@ -577,12 +576,14 @@ struct h_list helpstr[] = {
     'R',       "       remove ring",\r
     'd',       "       drop object",\r
     'c',       "       call object",\r
+    'f',       "<dir>  flirt with someone",\r
+    'g',       "<dir>  give an item as a gift",\r
+    'E',       "       embrace",\r
     'o',       "       examine/set options",\r
     CTRL('L'), "       redraw screen",\r
     CTRL('R'), "       repeat last message",\r
     ESCAPE,    "       cancel command",\r
     'v',       "       print program version number",\r
-    '!',       "       shell escape",\r
     'S',       "       save game",\r
     'Q',       "       quit",\r
     0, 0\r
diff --git a/rogue.h b/rogue.h
index 0281b1d..f426f9e 100644 (file)
--- a/rogue.h
+++ b/rogue.h
@@ -48,7 +48,7 @@
 #define otherwise break;default\r
 #define until(expr) while(!(expr))\r
 #define ce(a, b) ((a).x == (b).x && (a).y == (b).y)\r
-#define draw(window) (wrefresh(window),usleep(50000))\r
+#define draw(window) (wrefresh(window),usleep(20000))\r
 #define hero player.t_pos\r
 #define pstats player.t_stats\r
 #define pack player.t_pack\r
@@ -71,6 +71,7 @@
 #define newgrp() ++group\r
 #define o_charges o_ac\r
 #define ISMULT(type) (type == POTION || type == SCROLL || type == FOOD)\r
+#define rndchoice(a) (a[rnd(sizeof(a)/sizeof((a)[0]))])\r
 \r
 /*\r
  * Things that appear on the screens\r
index 70a06a1..a47b897 100644 (file)
--- a/romance.c
+++ b/romance.c
 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()
+{
 }