MCPcopy Create free account
hub / github.com/NetHack/NetHack / setuwep

Function setuwep

src/wield.c:99–135  ·  view source on GitHub ↗

Functions that place a given item in a slot ***/ Proper usage includes: * 1. Initializing the slot during character generation or a * restore. * 2. Setting the slot due to a player's actions. * 3. If one of the objects in the slot is split off, these * functions can be used to put the remainder back in the slot. * 4. Putting an item that was thrown and returned back into the slot

Source from the content-addressed store, hash-verified

97 * to print the appropriate messages.
98 */
99void
100setuwep(struct obj *obj)
101{
102 struct obj *olduwep = uwep;
103
104 if (obj == uwep)
105 return; /* necessary to not set gu.unweapon */
106 setworn(obj, W_WEP);
107 /* handle Ogresmasher before Sunsword; even though they can't be happening
108 at the same time, botl flag update should come before pline message */
109 if (uwep == obj
110 && ((uwep && uwep->oartifact == ART_OGRESMASHER)
111 || (olduwep && olduwep->oartifact == ART_OGRESMASHER)))
112 disp.botl = TRUE; /* gaining or losing Con bonus */
113 /* This message isn't printed in the caller because it happens
114 * *whenever* Sunsword is unwielded, from whatever cause. */
115 if (uwep == obj && artifact_light(olduwep) && olduwep->lamplit) {
116 end_burn(olduwep, FALSE);
117 if (!Blind)
118 pline("%s shining.", Tobjnam(olduwep, "stop"));
119 }
120 if (uwep == obj
121 && (u_wield_art(ART_OGRESMASHER)
122 || is_art(olduwep, ART_OGRESMASHER)))
123 disp.botl = TRUE;
124 /* Note: Explicitly wielding a pick-axe will not give a "bashing"
125 * message. Wielding one via 'a'pplying it will.
126 * 3.2.2: Wielding arbitrary objects will give bashing message too.
127 */
128 if (obj) {
129 gu.unweapon = (obj->oclass == WEAPON_CLASS)
130 ? is_launcher(obj) || is_ammo(obj) || is_missile(obj)
131 || (is_pole(obj) && !u.usteed && !is_art(obj, ART_SNICKERSNEE))
132 : !is_weptool(obj) && !is_wet_towel(obj);
133 } else
134 gu.unweapon = TRUE; /* for "bare hands" message */
135}
136
137staticfn boolean
138cant_wield_corpse(struct obj *obj)

Callers 15

ready_weaponFunction · 0.85
doquiver_coreFunction · 0.85
wield_toolFunction · 0.85
Ring_onFunction · 0.85
glibrFunction · 0.85
do_takeoffFunction · 0.85
hmon_hitmon_potionFunction · 0.85
ballreleaseFunction · 0.85
dropFunction · 0.85
dropzFunction · 0.85
restgamestateFunction · 0.85
domove_fight_ironbarsFunction · 0.85

Calls 6

setwornFunction · 0.85
artifact_lightFunction · 0.85
end_burnFunction · 0.85
TobjnamFunction · 0.85
is_artFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected