]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.steal.c
1 /* $NetBSD: hack.steal.c,v 1.4 1997/10/19 16:59:04 christos Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.steal.c,v 1.4 1997/10/19 16:59:04 christos Exp $");
16 long /* actually returns something that fits in an
20 return ((u
.ugold
< 100) ? u
.ugold
:
21 (u
.ugold
> 10000) ? rnd(10000) : rnd((int) u
.ugold
));
28 struct gold
*gold
= g_at(u
.ux
, u
.uy
);
30 if (gold
&& (!u
.ugold
|| gold
->amount
> u
.ugold
|| !rn2(5))) {
31 mtmp
->mgold
+= gold
->amount
;
35 pline("%s quickly snatches some gold from between your feet!",
37 if (!u
.ugold
|| !rn2(5)) {
42 u
.ugold
-= (tmp
= somegold());
43 pline("Your purse feels lighter.");
51 /* steal armor after he finishes taking it off */
52 unsigned stealoid
; /* object to be stolen */
53 unsigned stealmid
; /* monster doing the stealing */
60 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
61 if (otmp
->o_id
== stealoid
) {
62 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
63 if (mtmp
->m_id
== stealmid
) {
64 if (dist(mtmp
->mx
, mtmp
->my
) < 3) {
66 pline("%s steals %s!", Monnam(mtmp
), doname(otmp
));
79 /* returns 1 when something was stolen */
80 /* (or at least, when N should flee now) */
81 /* avoid stealing the object stealoid */
92 pline("Somebody tries to rob you, but finds nothing to steal.");
94 pline("%s tries to rob you, but she finds nothing to steal!",
96 return (1); /* let her flee */
99 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
101 tmp
+= ((otmp
->owornmask
& (W_ARMOR
| W_RING
)) ? 5 : 1);
103 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
105 if ((tmp
-= ((otmp
->owornmask
& (W_ARMOR
| W_RING
)) ? 5 : 1))
109 impossible("Steal fails!");
112 if (otmp
->o_id
== stealoid
)
114 if ((otmp
->owornmask
& (W_ARMOR
| W_RING
))) {
115 switch (otmp
->olet
) {
120 if (multi
< 0 || otmp
== uarms
) {
121 setworn((struct obj
*) 0, otmp
->owornmask
& W_ARMOR
);
124 int curssv
= otmp
->cursed
;
127 pline("%s seduces you and %s off your %s.",
128 Amonnam(mtmp
, Blind
? "gentle" : "beautiful"),
129 otmp
->cursed
? "helps you to take"
130 : "you start taking",
131 (otmp
== uarmg
) ? "gloves" :
132 (otmp
== uarmh
) ? "helmet" : "armor");
134 (void) armoroff(otmp
);
135 otmp
->cursed
= curssv
;
142 stealoid
= otmp
->o_id
;
143 stealmid
= mtmp
->m_id
;
150 impossible("Tried to steal a strange worn thing.");
152 } else if (otmp
== uwep
)
153 setuwep((struct obj
*) 0);
154 if (otmp
->olet
== CHAIN_SYM
) {
155 impossible("How come you are carrying that chain?");
157 if (Punished
&& otmp
== uball
) {
160 free((char *) uchain
);
161 uchain
= (struct obj
*) 0;
163 uball
= (struct obj
*) 0; /* superfluous */
166 pline("%s stole %s.", named
? "She" : Monnam(mtmp
), doname(otmp
));
167 mpickobj(mtmp
, otmp
);
168 return ((multi
< 0) ? 0 : 1);
176 otmp
->nobj
= mtmp
->minvent
;
177 mtmp
->minvent
= otmp
;
186 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
) {
187 if (otmp
->olet
== AMULET_SYM
) {
188 /* might be an imitation one */
190 setuwep((struct obj
*) 0);
192 mpickobj(mtmp
, otmp
);
193 pline("%s stole %s!", Monnam(mtmp
), doname(otmp
));
200 /* release the objects the killed animal has stolen */
206 struct obj
*otmp
, *otmp2
;
208 for (otmp
= mtmp
->minvent
; otmp
; otmp
= otmp2
) {
215 if (show
& cansee(mtmp
->mx
, mtmp
->my
))
216 atl(otmp
->ox
, otmp
->oy
, otmp
->olet
);
218 mtmp
->minvent
= (struct obj
*) 0;
219 if (mtmp
->mgold
|| mtmp
->data
->mlet
== 'L') {
222 tmp
= (mtmp
->mgold
> 10000) ? 10000 : mtmp
->mgold
;
223 mkgold((long) (tmp
+ d(dlevel
, 30)), mtmp
->mx
, mtmp
->my
);
224 if (show
& cansee(mtmp
->mx
, mtmp
->my
))
225 atl(mtmp
->mx
, mtmp
->my
, '$');