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 long /* actually returns something that fits in an int */
13 return( (u
.ugold
< 100) ? u
.ugold
:
14 (u
.ugold
> 10000) ? rnd(10000) : rnd((int) u
.ugold
) );
18 stealgold(struct monst
*mtmp
)
20 struct gold
*gold
= g_at(u
.ux
, u
.uy
);
22 if(gold
&& ( !u
.ugold
|| gold
->amount
> u
.ugold
|| !rn2(5))) {
23 mtmp
->mgold
+= gold
->amount
;
25 if(Invisible
) newsym(u
.ux
, u
.uy
);
26 pline("%s quickly snatches some gold from between your feet!",
28 if(!u
.ugold
|| !rn2(5)) {
33 u
.ugold
-= (tmp
= somegold());
34 pline("Your purse feels lighter.");
42 /* steal armor after he finishes taking it off */
43 unsigned stealoid
; /* object to be stolen */
44 unsigned stealmid
; /* monster doing the stealing */
52 for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
53 if(otmp
->o_id
== stealoid
) {
54 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
55 if(mtmp
->m_id
== stealmid
) {
56 if(dist(mtmp
->mx
,mtmp
->my
) < 3) {
58 pline("%s steals %s!", Monnam(mtmp
), doname(otmp
));
70 /* returns 1 when something was stolen */
71 /* (or at least, when N should flee now) */
72 /* avoid stealing the object stealoid */
74 steal(struct monst
*mtmp
)
82 pline("Somebody tries to rob you, but finds nothing to steal.");
84 pline("%s tries to rob you, but she finds nothing to steal!",
86 return(1); /* let her flee */
89 for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
) if(otmp
!= uarm2
)
90 tmp
+= ((otmp
->owornmask
& (W_ARMOR
| W_RING
)) ? 5 : 1);
92 for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
) if(otmp
!= uarm2
)
93 if((tmp
-= ((otmp
->owornmask
& (W_ARMOR
| W_RING
)) ? 5 : 1))
96 impossible("Steal fails!");
99 if(otmp
->o_id
== stealoid
)
101 if((otmp
->owornmask
& (W_ARMOR
| W_RING
))){
107 if(multi
< 0 || otmp
== uarms
){
108 setworn((struct obj
*) 0, otmp
->owornmask
& W_ARMOR
);
111 { int curssv
= otmp
->cursed
;
114 pline("%s seduces you and %s off your %s.",
115 Amonnam(mtmp
, Blind
? "gentle" : "beautiful"),
116 otmp
->cursed
? "helps you to take"
117 : "you start taking",
118 (otmp
== uarmg
) ? "gloves" :
119 (otmp
== uarmh
) ? "helmet" : "armor");
122 otmp
->cursed
= curssv
;
124 stealoid
= otmp
->o_id
;
125 stealmid
= mtmp
->m_id
;
132 impossible("Tried to steal a strange worn thing.");
135 else if(otmp
== uwep
)
136 setuwep((struct obj
*) 0);
137 if(otmp
->olet
== CHAIN_SYM
) {
138 impossible("How come you are carrying that chain?");
140 if(Punished
&& otmp
== uball
){
143 free((char *) uchain
);
144 uchain
= (struct obj
*) 0;
146 uball
= (struct obj
*) 0; /* superfluous */
149 pline("%s stole %s.", named
? "She" : Monnam(mtmp
), doname(otmp
));
151 return((multi
< 0) ? 0 : 1);
155 mpickobj(struct monst
*mtmp
, struct obj
*otmp
)
157 otmp
->nobj
= mtmp
->minvent
;
158 mtmp
->minvent
= otmp
;
162 stealamulet(struct monst
*mtmp
)
166 for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
) {
167 if(otmp
->olet
== AMULET_SYM
) {
168 /* might be an imitation one */
169 if(otmp
== uwep
) setuwep((struct obj
*) 0);
172 pline("%s stole %s!", Monnam(mtmp
), doname(otmp
));
179 /* release the objects the killed animal has stolen */
181 relobj(struct monst
*mtmp
, int show
)
183 struct obj
*otmp
, *otmp2
;
185 for(otmp
= mtmp
->minvent
; otmp
; otmp
= otmp2
){
192 if(show
& cansee(mtmp
->mx
,mtmp
->my
))
193 atl(otmp
->ox
,otmp
->oy
,otmp
->olet
);
195 mtmp
->minvent
= (struct obj
*) 0;
196 if(mtmp
->mgold
|| mtmp
->data
->mlet
== 'L') {
199 tmp
= (mtmp
->mgold
> 10000) ? 10000 : mtmp
->mgold
;
200 mkgold((long)(tmp
+ d(dlevel
,30)), mtmp
->mx
, mtmp
->my
);
201 if(show
& cansee(mtmp
->mx
,mtmp
->my
))
202 atl(mtmp
->mx
,mtmp
->my
,'$');