things that must change when not held; recurse into containers. Called for both player and monsters */
| 890 | /* things that must change when not held; recurse into containers. |
| 891 | Called for both player and monsters */ |
| 892 | void |
| 893 | obj_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 */ |
| 923 | int |
no test coverage detected