]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.steal.c
1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.steal.c - version 1.0.3 */
6 long /* actually returns something that fits in an int */
8 return( (u
.ugold
< 100) ? u
.ugold
:
9 (u
.ugold
> 10000) ? rnd(10000) : rnd((int) u
.ugold
) );
12 stealgold(mtmp
) register struct monst
*mtmp
; {
13 register struct gold
*gold
= g_at(u
.ux
, u
.uy
);
15 if(gold
&& ( !u
.ugold
|| gold
->amount
> u
.ugold
|| !rn2(5))) {
16 mtmp
->mgold
+= gold
->amount
;
18 if(Invisible
) newsym(u
.ux
, u
.uy
);
19 pline("%s quickly snatches some gold from between your feet!",
21 if(!u
.ugold
|| !rn2(5)) {
26 u
.ugold
-= (tmp
= somegold());
27 pline("Your purse feels lighter.");
35 /* steal armor after he finishes taking it off */
36 unsigned stealoid
; /* object to be stolen */
37 unsigned stealmid
; /* monster doing the stealing */
39 register struct monst
*mtmp
;
40 register struct obj
*otmp
;
42 for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
)
43 if(otmp
->o_id
== stealoid
) {
44 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
45 if(mtmp
->m_id
== stealmid
) {
46 if(dist(mtmp
->mx
,mtmp
->my
) < 3) {
48 pline("%s steals %s!", Monnam(mtmp
), doname(otmp
));
60 /* returns 1 when something was stolen */
61 /* (or at least, when N should flee now) */
62 /* avoid stealing the object stealoid */
66 register struct obj
*otmp
;
72 pline("Somebody tries to rob you, but finds nothing to steal.");
74 pline("%s tries to rob you, but she finds nothing to steal!",
76 return(1); /* let her flee */
79 for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
) if(otmp
!= uarm2
)
80 tmp
+= ((otmp
->owornmask
& (W_ARMOR
| W_RING
)) ? 5 : 1);
82 for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
) if(otmp
!= uarm2
)
83 if((tmp
-= ((otmp
->owornmask
& (W_ARMOR
| W_RING
)) ? 5 : 1))
86 impossible("Steal fails!");
89 if(otmp
->o_id
== stealoid
)
91 if((otmp
->owornmask
& (W_ARMOR
| W_RING
))){
97 if(multi
< 0 || otmp
== uarms
){
98 setworn((struct obj
*) 0, otmp
->owornmask
& W_ARMOR
);
101 { int curssv
= otmp
->cursed
;
104 pline("%s seduces you and %s off your %s.",
105 Amonnam(mtmp
, Blind
? "gentle" : "beautiful"),
106 otmp
->cursed
? "helps you to take"
107 : "you start taking",
108 (otmp
== uarmg
) ? "gloves" :
109 (otmp
== uarmh
) ? "helmet" : "armor");
111 (void) armoroff(otmp
);
112 otmp
->cursed
= curssv
;
114 extern char *nomovemsg
;
115 extern int (*afternmv
)();
121 stealoid
= otmp
->o_id
;
122 stealmid
= mtmp
->m_id
;
129 impossible("Tried to steal a strange worn thing.");
132 else if(otmp
== uwep
)
133 setuwep((struct obj
*) 0);
134 if(otmp
->olet
== CHAIN_SYM
) {
135 impossible("How come you are carrying that chain?");
137 if(Punished
&& otmp
== uball
){
140 free((char *) uchain
);
141 uchain
= (struct obj
*) 0;
143 uball
= (struct obj
*) 0; /* superfluous */
146 pline("%s stole %s.", named
? "She" : Monnam(mtmp
), doname(otmp
));
148 return((multi
< 0) ? 0 : 1);
152 register struct monst
*mtmp
;
153 register struct obj
*otmp
;
155 otmp
->nobj
= mtmp
->minvent
;
156 mtmp
->minvent
= otmp
;
160 register struct monst
*mtmp
;
162 register struct obj
*otmp
;
164 for(otmp
= invent
; otmp
; otmp
= otmp
->nobj
) {
165 if(otmp
->olet
== AMULET_SYM
) {
166 /* might be an imitation one */
167 if(otmp
== uwep
) setuwep((struct obj
*) 0);
170 pline("%s stole %s!", Monnam(mtmp
), doname(otmp
));
177 /* release the objects the killed animal has stolen */
179 register struct monst
*mtmp
;
182 register struct obj
*otmp
, *otmp2
;
184 for(otmp
= mtmp
->minvent
; otmp
; otmp
= otmp2
){
191 if(show
& cansee(mtmp
->mx
,mtmp
->my
))
192 atl(otmp
->ox
,otmp
->oy
,otmp
->olet
);
194 mtmp
->minvent
= (struct obj
*) 0;
195 if(mtmp
->mgold
|| mtmp
->data
->mlet
== 'L') {
198 tmp
= (mtmp
->mgold
> 10000) ? 10000 : mtmp
->mgold
;
199 mkgold((long)(tmp
+ d(dlevel
,30)), mtmp
->mx
, mtmp
->my
);
200 if(show
& cansee(mtmp
->mx
,mtmp
->my
))
201 atl(mtmp
->mx
,mtmp
->my
,'$');