rogue

Ken Arnold's Rogue
git clone https://git.woozle.org/neale/rogue.git

Neale Pickett  ·  2011-10-13

sendit.c

  1/*
  2 * All the daemon and fuse functions are in here
  3 *
  4 * @(#)sendit.c	4.24 (Berkeley) 02/05/99
  5 */
  6
  7#include <curses.h>
  8#include "netprot.h"
  9
 10/*
 11 * doctor:
 12 *	A healing daemon that restors hit points after rest
 13 */
 14void
 15doctor(void)
 16{
 17    int lv, ohp;
 18
 19    lv = Pstats.s_lvl;
 20    ohp = Pstats.s_hpt;
 21    Quiet++;
 22    if (lv < 8)
 23    {
 24	if (Quiet + (lv << 1) > 20)
 25	    Pstats.s_hpt++;
 26    }
 27    else
 28	if (Quiet >= 3)
 29	    Pstats.s_hpt += rnd(lv - 7) + 1;
 30    if (ISRING(LEFT, R_REGEN))
 31	Pstats.s_hpt++;
 32    if (ISRING(RIGHT, R_REGEN))
 33	Pstats.s_hpt++;
 34    if (ohp != Pstats.s_hpt)
 35    {
 36	if (Pstats.s_hpt > Max_hp)
 37	    Pstats.s_hpt = Max_hp;
 38	Quiet = 0;
 39    }
 40}
 41
 42/*
 43 * Swander:
 44 *	Called when it is time to start rolling for wandering monsters
 45 */
 46void
 47swander(void)
 48{
 49    start_daemon(rollwand, 0, BEFORE);
 50}
 51
 52/*
 53 * rollwand:
 54 *	Called to roll to see if a wandering monster starts up
 55 */
 56void
 57rollwand(void)
 58{
 59    static int between = 0;
 60
 61    if (++between >= 4)
 62    {
 63	if (roll(1, 6) == 4)
 64	{
 65	    wanderer();
 66	    kill_daemon(rollwand);
 67	    fuse(swander, 0, WANDERTIME, BEFORE);
 68	}
 69	between = 0;
 70    }
 71}
 72
 73/*
 74 * unconfuse:
 75 *	Release the poor player from his confusion
 76 */
 77void
 78unconfuse(void)
 79{
 80    Player.t_flags &= ~ISHUH;
 81    msg("you feel less %s now", choose_str("trippy", "confused"));
 82}
 83
 84/*
 85 * unsee:
 86 *	Turn off the ability to see invisible
 87 */
 88void
 89unsee(void)
 90{
 91    THING *th;
 92
 93    for (th = Mlist; th != NULL; th = next(th))
 94	if (on(*th, ISINVIS) && see_monst(th))
 95	    mvaddch(th->t_pos.y, th->t_pos.x, th->t_oldch);
 96    Player.t_flags &= ~CANSEE;
 97}
 98
 99/*
100 * sight:
101 *	He gets his sight back
102 */
103void
104sight(void)
105{
106    if (on(Player, ISBLIND))
107    {
108	extinguish(sight);
109	Player.t_flags &= ~ISBLIND;
110	if (!(Proom->r_flags & ISGONE))
111	    enter_room(&Hero);
112	msg(choose_str("far out!  Everything is all cosmic again",
113		       "the veil of darkness lifts"));
114    }
115}
116
117/*
118 * nohaste:
119 *	End the hasting
120 */
121void
122nohaste(void)
123{
124    Player.t_flags &= ~ISHASTE;
125    msg("you feel yourself slowing down");
126}
127
128/*
129 * stomach:
130 *	Digest the hero's food
131 */
132void
133stomach(void)
134{
135    int oldfood;
136    int orig_hungry = Hungry_state;
137
138    if (Food_left <= 0)
139    {
140	if (Food_left-- < -STARVETIME)
141	    death('s');
142	/*
143	 * the hero is fainting
144	 */
145	if (No_command || rnd(5) != 0)
146	    return;
147	No_command += rnd(8) + 4;
148	Hungry_state = 3;
149	if (!Terse)
150	    addmsg(choose_str("the munchies overpower your motor capabilities.  ",
151			      "you feel too weak from lack of food.  "));
152	msg(choose_str("You freak out", "You faint"));
153    }
154    else
155    {
156	oldfood = Food_left;
157	Food_left -= ring_eat(LEFT) + ring_eat(RIGHT) + 1 - Amulet;
158
159	if (Food_left < MORETIME && oldfood >= MORETIME)
160	{
161	    Hungry_state = 2;
162	    msg(choose_str("the munchies are interfering with your motor capabilites",
163			   "you are starting to feel weak"));
164	}
165	else if (Food_left < 2 * MORETIME && oldfood >= 2 * MORETIME)
166	{
167	    Hungry_state = 1;
168	    if (Terse)
169		msg(choose_str("getting the munchies", "getting hungry"));
170	    else
171		msg(choose_str("you are getting the munchies",
172			       "you are starting to get hungry"));
173	}
174    }
175    if (Hungry_state != orig_hungry) {
176	Player.t_flags &= ~ISRUN;
177	Running = FALSE;
178	To_death = FALSE;
179	Count = 0;
180    }
181}
182
183/*
184 * come_down:
185 *	Take the hero down off her acid trip.
186 */
187void
188come_down(void)
189{
190    THING *tp;
191    bool seemonst;
192
193    if (!on(Player, ISHALU))
194	return;
195
196    kill_daemon(visuals);
197    Player.t_flags &= ~ISHALU;
198
199    if (on(Player, ISBLIND))
200	return;
201
202    /*
203     * undo the things
204     */
205    for (tp = Lvl_obj; tp != NULL; tp = next(tp))
206	if (cansee(tp->o_pos.y, tp->o_pos.x))
207	    mvaddch(tp->o_pos.y, tp->o_pos.x, tp->o_type);
208
209    /*
210     * undo the monsters
211     */
212    seemonst = on(Player, SEEMONST);
213    for (tp = Mlist; tp != NULL; tp = next(tp))
214    {
215	move(tp->t_pos.y, tp->t_pos.x);
216	if (cansee(tp->t_pos.y, tp->t_pos.x))
217	    if (!on(*tp, ISINVIS) || on(Player, CANSEE))
218		addch(tp->t_disguise);
219	    else
220		addch(chat(tp->t_pos.y, tp->t_pos.x));
221	else if (seemonst)
222	{
223	    standout();
224	    addch(tp->t_type);
225	    standend();
226	}
227    }
228    msg("Everything looks SO boring now.");
229}
230
231/*
232 * visuals:
233 *	change the characters for the player
234 */
235void
236visuals(void)
237{
238    THING *tp;
239    bool seemonst;
240
241    if (!After || (Running && Jump))
242	return;
243    /*
244     * change the things
245     */
246    for (tp = Lvl_obj; tp != NULL; tp = next(tp))
247	if (cansee(tp->o_pos.y, tp->o_pos.x))
248	    mvaddch(tp->o_pos.y, tp->o_pos.x, rnd_thing());
249
250    /*
251     * change the stairs
252     */
253    if (!Seenstairs && cansee(Stairs.y, Stairs.x))
254	mvaddch(Stairs.y, Stairs.x, rnd_thing());
255
256    /*
257     * change the monsters
258     */
259    seemonst = on(Player, SEEMONST);
260    for (tp = Mlist; tp != NULL; tp = next(tp))
261    {
262	move(tp->t_pos.y, tp->t_pos.x);
263	if (see_monst(tp))
264	{
265	    if (tp->t_type == 'X' && tp->t_disguise != 'X')
266		addch(rnd_thing());
267	    else
268		addch(rnd(26) + 'A');
269	}
270	else if (seemonst)
271	{
272	    standout();
273	    addch(rnd(26) + 'A');
274	    standend();
275	}
276    }
277}
278
279/*
280 * land:
281 *	Land from a levitation potion
282 */
283void
284land(void)
285{
286    Player.t_flags &= ~ISLEVIT;
287    msg(choose_str("bummer!  You've hit the ground",
288		   "you float gently to the ground"));
289}