as time goes by - called by moveloop(every move) & domove(melee attack) */
| 3160 | |
| 3161 | /* as time goes by - called by moveloop(every move) & domove(melee attack) */ |
| 3162 | void |
| 3163 | gethungry(void) |
| 3164 | { |
| 3165 | int accessorytime; |
| 3166 | |
| 3167 | if (u.uinvulnerable || iflags.debug_hunger) |
| 3168 | return; /* you don't feel hungrier */ |
| 3169 | |
| 3170 | /* being polymorphed into a creature which doesn't eat prevents |
| 3171 | this first uhunger decrement, but to stay in such form the hero |
| 3172 | will need to wear an Amulet of Unchanging so still burn a small |
| 3173 | amount of nutrition in the 'moves % 20' ring/amulet check below */ |
| 3174 | if ((!Unaware || !rn2(10)) /* slow metabolic rate while asleep */ |
| 3175 | && (carnivorous(gy.youmonst.data) |
| 3176 | || herbivorous(gy.youmonst.data) |
| 3177 | || metallivorous(gy.youmonst.data)) |
| 3178 | && !Slow_digestion) |
| 3179 | u.uhunger--; /* ordinary food consumption */ |
| 3180 | |
| 3181 | /* |
| 3182 | * 5.0: trigger is randomized instead of (moves % N). Makes |
| 3183 | * ring juggling (using the 'time' option to see the turn counter |
| 3184 | * in order to time swapping of a pair of rings of slow digestion, |
| 3185 | * wearing one on one hand, then putting on the other and taking |
| 3186 | * off the first, then vice versa, over and over and over and ... |
| 3187 | * to avoid any hunger from wearing a ring) become ineffective. |
| 3188 | * Also causes melee-induced hunger to vary from turn-based hunger |
| 3189 | * instead of just replicating that. |
| 3190 | */ |
| 3191 | accessorytime = rn2(20); /* rn2(20) replaces (int) (svm.moves % 20L) */ |
| 3192 | if (accessorytime % 2) { /* odd */ |
| 3193 | /* Regeneration uses up food, unless due to an artifact */ |
| 3194 | if ((HRegeneration & ~FROMFORM) |
| 3195 | || (ERegeneration & ~(W_ARTI | W_WEP))) |
| 3196 | u.uhunger--; |
| 3197 | if (near_capacity() > SLT_ENCUMBER) |
| 3198 | u.uhunger--; |
| 3199 | } else { /* even */ |
| 3200 | if (Hunger) |
| 3201 | u.uhunger--; |
| 3202 | /* Conflict uses up food too */ |
| 3203 | if (HConflict || (EConflict & (~W_ARTI))) |
| 3204 | u.uhunger--; |
| 3205 | /* |
| 3206 | * +0 charged rings don't do anything, so don't affect hunger. |
| 3207 | * Slow digestion cancels movement and melee hunger but still |
| 3208 | * causes ring hunger. |
| 3209 | * Possessing the real Amulet imposes a separate hunger penalty |
| 3210 | * from wearing an amulet (so gets a double penalty when worn). |
| 3211 | * |
| 3212 | * 5.0.0: Worn meat rings don't affect hunger. |
| 3213 | * Same with worn cheap plastic imitation of the Amulet. |
| 3214 | * +0 ring of protection might do something (enhanced "magical |
| 3215 | * cancellation") if hero doesn't have protection from some |
| 3216 | * other source (cloak or second ring). |
| 3217 | * |
| 3218 | * [If wearing duplicate rings whose effects don't stack, |
| 3219 | * should they both consume nutrition, or just one of them? |
no test coverage detected