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

Function obj_no_longer_held

src/do.c:892–920  ·  view source on GitHub ↗

things that must change when not held; recurse into containers. Called for both player and monsters */

Source from the content-addressed store, hash-verified

890/* things that must change when not held; recurse into containers.
891 Called for both player and monsters */
892void
893obj_no_longer_held(struct obj *obj)
894{
895 if (!obj) {
896 return;
897 } else if (Has_contents(obj)) {
898 struct obj *contents;
899
900 for (contents = obj->cobj; contents; contents = contents->nobj)
901 obj_no_longer_held(contents);
902 }
903 switch (obj->otyp) {
904 case CRYSKNIFE:
905 /* Normal crysknife reverts to worm tooth when not held by hero
906 * or monster; fixed crysknife has only 10% chance of reverting.
907 * When a stack of the latter is involved, it could be worthwhile
908 * to give each individual crysknife its own separate 10% chance,
909 * but we aren't in any position to handle stack splitting here.
910 */
911 if (!obj->oerodeproof || !rn2(10)) {
912 /* if monsters aren't moving, assume player is responsible */
913 if (!svc.context.mon_moving && !program_state.gameover)
914 costly_alteration(obj, COST_DEGRD);
915 obj->otyp = WORM_TOOTH;
916 obj->oerodeproof = 0;
917 }
918 break;
919 }
920}
921
922/* the #droptype command: drop several things */
923int

Callers 6

drop_upon_deathFunction · 0.85
throwitFunction · 0.85
extract_from_minventFunction · 0.85
place_objectFunction · 0.85
add_to_containerFunction · 0.85
use_whipFunction · 0.85

Calls 2

rn2Function · 0.85
costly_alterationFunction · 0.85

Tested by

no test coverage detected