Sufficiently interested monsters will now accept gifts.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Sat, 6 Apr 2013 12:18:04 +0000 (14:18 +0200)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Sat, 6 Apr 2013 12:18:04 +0000 (14:18 +0200)
rogue.h
romance.c

diff --git a/rogue.h b/rogue.h
index 2e67f38..b79c5f9 100644 (file)
--- a/rogue.h
+++ b/rogue.h
@@ -72,7 +72,7 @@
 #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
+#define hash(i) ((unsigned)(i)*2654435761u)\r
 /*\r
  * Things that appear on the screens\r
  */\r
index 1a73fbe..bafafa7 100644 (file)
--- a/romance.c
+++ b/romance.c
@@ -54,7 +54,7 @@ int ydelta, xdelta;
     {
         register struct thing *tp = (struct thing *) ldata(mob);
         int attr = count_bits_set(tp->t_stats.s_ont ^ player.t_stats.s_ont);
-        attr += tp->t_stats.s_int - 1;
+        attr += tp->t_stats.s_int - 2;
         if (rnd(NUM_FEATURES) < attr)
         {
             tp->t_stats.s_int++;
@@ -95,7 +95,7 @@ int ydelta, xdelta;
     register struct linked_list *mob;
     register struct object *op;
     register struct thing *tp;
-    register bool did_hit = TRUE;
+    register int liking;
 
     if ((mob = find_mons(hero.y + ydelta, hero.x + xdelta)) == NULL)
     {
@@ -109,6 +109,41 @@ int ydelta, xdelta;
     op = (struct object *) ldata(obj);
     if (!dropcheck(op))
        return;
+
+    liking = count_bits_set(
+        hash((op->o_type << 4) ^ op->o_which) & tp->t_stats.s_ont) - 1;
+    if (liking == 0 || tp->t_stats.s_int <= 3)
+    {
+        const char *msgs[] = {
+            "The %s ignores %s",
+            "The %s isn't interested in %s",
+        };
+        msg(rndchoice(msgs), monsters[tp->t_type - 'A'].m_name,
+            inv_name(op, TRUE));
+        return;
+    }    
+    else if (liking > 0)
+    {
+        const char *msgs[] = {
+            "The %s accepts %s.",
+            "The %s takes %s.",
+        };
+        msg(rndchoice(msgs), monsters[tp->t_type - 'A'].m_name,
+            inv_name(op, TRUE));
+        tp->t_stats.s_int += liking * 10;
+    }
+    else if (liking < 0)
+    {
+        const char *msgs[] = {
+            "The %s throws away %s.",
+            "The %s breaks %s.",
+            "The %s hates %s.",
+        };
+        msg(rndchoice(msgs), monsters[tp->t_type - 'A'].m_name,
+            inv_name(op, TRUE));
+        tp->t_stats.s_int -= liking * 2;
+    }
+    
     /*
      * Take it out of the pack
      */