]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.steal.c
2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
6 static char rcsid
[] = "$NetBSD: hack.steal.c,v 1.3 1995/03/23 08:31:34 cgd Exp $";
11 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
) );
17 stealgold(mtmp
) register struct monst
*mtmp
; {
18 register struct gold
*gold
= g_at(u
.ux
, u
.uy
);
20 if(gold
&& ( !u
.ugold
|| gold
->amount
> u
.ugold
|| !rn2(5))) {
21 mtmp
->mgold
+= gold
->amount
;
23 if(Invisible
) newsym(u
.ux
, u
.uy
);
24 pline("%s quickly snatches some gold from between your feet!",
26 if(!u
.ugold
|| !rn2(5)) {
31 u
.ugold
-= (tmp
= somegold());
32 pline("Your purse feels lighter.");
40 /* steal armor after he finishes taking it off */
41 unsigned stealoid
; /* object to be stolen */
42 unsigned stealmid
; /* monster doing the stealing */
44 register struct monst
*mtmp
;
45 register struct obj
*otmp
;
47 for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
48 if(otmp
->o_id
== stealoid
) {
49 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
50 if(mtmp
->m_id
== stealmid
) {
51 if(dist(mtmp
->mx
,mtmp
->my
) < 3) {
53 pline("%s steals %s!", Monnam(mtmp
), doname(otmp
));
65 /* returns 1 when something was stolen */
66 /* (or at least, when N should flee now) */
67 /* avoid stealing the object stealoid */
71 register struct obj
*otmp
;
77 pline("Somebody tries to rob you, but finds nothing to steal.");
79 pline("%s tries to rob you, but she finds nothing to steal!",
81 return(1); /* let her flee */
84 for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
) if(otmp
!= uarm2
)
85 tmp
+= ((otmp
->owornmask
& (W_ARMOR
| W_RING
)) ? 5 : 1);
87 for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
) if(otmp
!= uarm2
)
88 if((tmp
-= ((otmp
->owornmask
& (W_ARMOR
| W_RING
)) ? 5 : 1))
91 impossible("Steal fails!");
94 if(otmp
->o_id
== stealoid
)
96 if((otmp
->owornmask
& (W_ARMOR
| W_RING
))){
102 if(multi
< 0 || otmp
== uarms
){
103 setworn((struct obj
*) 0, otmp
->owornmask
& W_ARMOR
);
106 { int curssv
= otmp
->cursed
;
109 pline("%s seduces you and %s off your %s.",
110 Amonnam(mtmp
, Blind
? "gentle" : "beautiful"),
111 otmp
->cursed
? "helps you to take"
112 : "you start taking",
113 (otmp
== uarmg
) ? "gloves" :
114 (otmp
== uarmh
) ? "helmet" : "armor");
116 (void) armoroff(otmp
);
117 otmp
->cursed
= curssv
;
119 extern char *nomovemsg
;
120 extern int (*afternmv
)();
126 stealoid
= otmp
->o_id
;
127 stealmid
= mtmp
->m_id
;
134 impossible("Tried to steal a strange worn thing.");
137 else if(otmp
== uwep
)
138 setuwep((struct obj
*) 0);
139 if(otmp
->olet
== CHAIN_SYM
) {
140 impossible("How come you are carrying that chain?");
142 if(Punished
&& otmp
== uball
){
145 free((char *) uchain
);
146 uchain
= (struct obj
*) 0;
148 uball
= (struct obj
*) 0; /* superfluous */
151 pline("%s stole %s.", named
? "She" : Monnam(mtmp
), doname(otmp
));
153 return((multi
< 0) ? 0 : 1);
157 register struct monst
*mtmp
;
158 register struct obj
*otmp
;
160 otmp
->nobj
= mtmp
->minvent
;
161 mtmp
->minvent
= otmp
;
165 register struct monst
*mtmp
;
167 register struct obj
*otmp
;
169 for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
) {
170 if(otmp
->olet
== AMULET_SYM
) {
171 /* might be an imitation one */
172 if(otmp
== uwep
) setuwep((struct obj
*) 0);
175 pline("%s stole %s!", Monnam(mtmp
), doname(otmp
));
182 /* release the objects the killed animal has stolen */
184 register struct monst
*mtmp
;
187 register struct obj
*otmp
, *otmp2
;
189 for(otmp
= mtmp
->minvent
; otmp
; otmp
= otmp2
){
196 if(show
& cansee(mtmp
->mx
,mtmp
->my
))
197 atl(otmp
->ox
,otmp
->oy
,otmp
->olet
);
199 mtmp
->minvent
= (struct obj
*) 0;
200 if(mtmp
->mgold
|| mtmp
->data
->mlet
== 'L') {
203 tmp
= (mtmp
->mgold
> 10000) ? 10000 : mtmp
->mgold
;
204 mkgold((long)(tmp
+ d(dlevel
,30)), mtmp
->mx
, mtmp
->my
);
205 if(show
& cansee(mtmp
->mx
,mtmp
->my
))
206 atl(mtmp
->mx
,mtmp
->my
,'$');