1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.steal.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.steal.c,v 1.4 1999/11/16 10:26:38 marcel Exp $ */
4 /* $DragonFly: src/games/hack/hack.steal.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */
8 static void stealarm(void);
10 /* actually returns something that fits in an int */
14 return ((u
.ugold
< 100) ? u
.ugold
:
15 (u
.ugold
> 10000) ? rnd(10000) : rnd((int)u
.ugold
));
19 stealgold(struct monst
*mtmp
)
21 struct gold
*gold
= g_at(u
.ux
, u
.uy
);
24 if (gold
&& (!u
.ugold
|| gold
->amount
> u
.ugold
|| !rn2(5))) {
25 mtmp
->mgold
+= gold
->amount
;
29 pline("%s quickly snatches some gold from between your feet!",
31 if (!u
.ugold
|| !rn2(5)) {
36 u
.ugold
-= (tmp
= somegold());
37 pline("Your purse feels lighter.");
45 /* steal armor after he finishes taking it off */
46 unsigned stealoid
; /* object to be stolen */
47 unsigned stealmid
; /* monster doing the stealing */
55 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
56 if (otmp
->o_id
== stealoid
) {
57 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
58 if (mtmp
->m_id
== stealmid
) {
59 if (dist(mtmp
->mx
, mtmp
->my
) < 3) {
61 pline("%s steals %s!", Monnam(mtmp
), doname(otmp
));
73 /* returns 1 when something was stolen */
74 /* (or at least, when N should flee now) */
75 /* avoid stealing the object stealoid */
77 steal(struct monst
*mtmp
)
85 pline("Somebody tries to rob you, but finds nothing to steal.");
87 pline("%s tries to rob you, but she finds nothing to steal!",
89 return (1); /* let her flee */
92 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
94 tmp
+= ((otmp
->owornmask
& (W_ARMOR
| W_RING
)) ? 5 : 1);
96 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
98 if ((tmp
-= ((otmp
->owornmask
& (W_ARMOR
| W_RING
)) ? 5 : 1))
102 impossible("Steal fails!");
105 if (otmp
->o_id
== stealoid
)
107 if ((otmp
->owornmask
& (W_ARMOR
| W_RING
))) {
108 switch (otmp
->olet
) {
113 if (multi
< 0 || otmp
== uarms
) {
114 setworn(NULL
, otmp
->owornmask
& W_ARMOR
);
118 int curssv
= otmp
->cursed
;
121 pline("%s seduces you and %s off your %s.",
122 Amonnam(mtmp
, Blind
? "gentle" : "beautiful"),
123 otmp
->cursed
? "helps you to take"
124 : "you start taking",
125 (otmp
== uarmg
) ? "gloves" :
126 (otmp
== uarmh
) ? "helmet" : "armor");
129 otmp
->cursed
= curssv
;
131 stealoid
= otmp
->o_id
;
132 stealmid
= mtmp
->m_id
;
139 impossible("Tried to steal a strange worn thing.");
141 } else if (otmp
== uwep
)
143 if (otmp
->olet
== CHAIN_SYM
)
144 impossible("How come you are carrying that chain?");
145 if (Punished
&& otmp
== uball
) {
151 uball
= NULL
; /* superfluous */
154 pline("%s stole %s.", named
? "She" : Monnam(mtmp
), doname(otmp
));
155 mpickobj(mtmp
, otmp
);
156 return ((multi
< 0) ? 0 : 1);
160 mpickobj(struct monst
*mtmp
, struct obj
*otmp
)
162 otmp
->nobj
= mtmp
->minvent
;
163 mtmp
->minvent
= otmp
;
167 stealamulet(struct monst
*mtmp
)
171 for (otmp
= invent
; otmp
; otmp
= otmp
->nobj
) {
172 if (otmp
->olet
== AMULET_SYM
) {
173 /* might be an imitation one */
177 mpickobj(mtmp
, otmp
);
178 pline("%s stole %s!", Monnam(mtmp
), doname(otmp
));
185 /* release the objects the killed animal has stolen */
187 relobj(struct monst
*mtmp
, int show
)
189 struct obj
*otmp
, *otmp2
;
191 for (otmp
= mtmp
->minvent
; otmp
; otmp
= otmp2
) {
198 if (show
& cansee(mtmp
->mx
, mtmp
->my
))
199 atl(otmp
->ox
, otmp
->oy
, otmp
->olet
);
201 mtmp
->minvent
= NULL
;
202 if (mtmp
->mgold
|| mtmp
->data
->mlet
== 'L') {
205 tmp
= (mtmp
->mgold
> 10000) ? 10000 : mtmp
->mgold
;
206 mkgold((long)(tmp
+ d(dlevel
, 30)), mtmp
->mx
, mtmp
->my
);
207 if (show
& cansee(mtmp
->mx
, mtmp
->my
))
208 atl(mtmp
->mx
, mtmp
->my
, '$');