From efb1335002efedd46b532a3e1daf6f390a20cce7 Mon Sep 17 00:00:00 2001 From: Joe Wreschnig Date: Fri, 5 Apr 2013 18:56:51 +0200 Subject: [PATCH] Monsters now have an orientation which can be inclined to like or dislike the player, as well as a level of romantic interest in the player. Flirting rolls can raise or lower this level. --- init.c | 1 + monsters.c | 1 + rogue.h | 4 ++++ romance.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/init.c b/init.c index 50cbc51..be6ce7a 100644 --- a/init.c +++ b/init.c @@ -112,6 +112,7 @@ init_player() { pstats.s_lvl = 1; pstats.s_exp = 0L; + pstats.s_ont = rnd(1 << NUM_FEATURES); max_hp = pstats.s_hpt = 12; if (rnd(100) == 7) { diff --git a/monsters.c b/monsters.c index 8121959..137559b 100644 --- a/monsters.c +++ b/monsters.c @@ -71,6 +71,7 @@ register coord *cp; strcpy(tp->t_stats.s_dmg,mp->m_stats.s_dmg); tp->t_stats.s_exp = mp->m_stats.s_exp; tp->t_stats.s_str.st_str = 10; + tp->t_stats.s_ont = rnd(1 << NUM_FEATURES); tp->t_flags = mp->m_flags; tp->t_turn = TRUE; tp->t_pack = NULL; diff --git a/rogue.h b/rogue.h index f426f9e..2e67f38 100644 --- a/rogue.h +++ b/rogue.h @@ -337,6 +337,8 @@ struct trap { extern struct trap traps[MAXTRAPS]; +#define NUM_FEATURES 6 + /* * Structure describing a fighting being */ @@ -347,6 +349,8 @@ struct stats { int s_arm; /* Armor class */ int s_hpt; /* Hit points */ char s_dmg[30]; /* String describing damage done */ + int s_ont; /* Orientation flags */ + int s_int; /* Level of interest in rogue */ }; /* diff --git a/romance.c b/romance.c index a47b897..bff5588 100644 --- a/romance.c +++ b/romance.c @@ -15,6 +15,17 @@ #include #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 @@ -23,14 +34,14 @@ 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.", @@ -38,7 +49,42 @@ int ydelta, xdelta; "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); + } } } -- 2.30.2