\r
extern struct trap traps[MAXTRAPS];\r
\r
+#define NUM_FEATURES 6\r
+\r
/*\r
* Structure describing a fighting being\r
*/\r
int s_arm; /* Armor class */\r
int s_hpt; /* Hit points */\r
char s_dmg[30]; /* String describing damage done */\r
+ int s_ont; /* Orientation flags */\r
+ int s_int; /* Level of interest in rogue */\r
};\r
\r
/*\r
#include <string.h>
#include "rogue.h"
+count_bits_set(v)
+unsigned v; // count bits set in this (32-bit value)
+{
+ unsigned c = v - ((v >> 1) & 0x55555555);
+ c = ((c >> 2) & 0x33333333) + (c & 0x33333333);
+ c = ((c >> 4) + c) & 0x0F0F0F0F;
+ c = ((c >> 8) + c) & 0x00FF00FF;
+ c = ((c >> 16) + c) & 0x0000FFFF;
+ return c;
+}
+
/*
* flirt:
* Make eyes in the given direction
flirt(ydelta, xdelta)
int ydelta, xdelta;
{
- register struct linked_list *item;
+ register struct linked_list *mob;
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)
+ if ((mob = find_mons(obj.o_pos.y, obj.o_pos.x)) == NULL)
{
const char *msgs[] = {
"You wink at nothing in particular.",
"Unprompted, you suddenly blush.",
};
msg(rndchoice(msgs));
- return;
+ }
+ else
+ {
+ 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;
+ if (rnd(NUM_FEATURES) < attr)
+ {
+ tp->t_stats.s_int++;
+ const char *msgs[] = {
+ "The %s smiles back at you.",
+ "You catch the %s staring at you out of the corner of eir eye.",
+ "The %s blushes and waves cautiously.",
+ };
+ msg(rndchoice(msgs), monsters[tp->t_type - 'A'].m_name);
+ }
+ else if (attr <= 0)
+ {
+ tp->t_stats.s_int--;
+ const char *msgs[] = {
+ "The %s scowls at you.",
+ "The %s tells you to stop it.",
+ "The %s is sick of your crap.",
+ };
+ msg(rndchoice(msgs), monsters[tp->t_type - 'A'].m_name);
+ }
+ else
+ {
+ const char *msgs[] = {
+ "The %s ignores you.",
+ "The %s is completely uninterested in you.",
+ "The %s acts like it can't hear you.",
+ "The %s doesn't care.",
+ };
+ msg(rndchoice(msgs), monsters[tp->t_type - 'A'].m_name);
+ }
}
}