generate a corpse and some items on top of a trap */
| 1812 | |
| 1813 | /* generate a corpse and some items on top of a trap */ |
| 1814 | staticfn void |
| 1815 | mktrap_victim(struct trap *ttmp) |
| 1816 | { |
| 1817 | /* Object generated by the trap; initially NULL, stays NULL if |
| 1818 | the trap doesn't generate objects. */ |
| 1819 | struct obj *otmp = NULL; |
| 1820 | int victim_mnum; /* race of the victim */ |
| 1821 | unsigned lvl = level_difficulty(); |
| 1822 | int kind = ttmp->ttyp; |
| 1823 | coordxy x = ttmp->tx, y = ttmp->ty; |
| 1824 | |
| 1825 | assert(x > 0 && x < COLNO && y >= 0 && y < ROWNO); |
| 1826 | /* Not all trap types have special handling here; only the ones |
| 1827 | that kill in a specific way that's obvious after the fact. */ |
| 1828 | switch (kind) { |
| 1829 | case ARROW_TRAP: |
| 1830 | otmp = mksobj(ARROW, TRUE, FALSE); |
| 1831 | otmp->opoisoned = 0; |
| 1832 | /* don't adjust the quantity; maybe the trap shot multiple |
| 1833 | times, there was an untrapping attempt, etc... */ |
| 1834 | break; |
| 1835 | case DART_TRAP: |
| 1836 | otmp = mksobj(DART, TRUE, FALSE); |
| 1837 | break; |
| 1838 | case ROCKTRAP: |
| 1839 | otmp = mksobj(ROCK, TRUE, FALSE); |
| 1840 | break; |
| 1841 | default: |
| 1842 | /* no item dropped by the trap */ |
| 1843 | break; |
| 1844 | } |
| 1845 | if (otmp) { |
| 1846 | place_object(otmp, x, y); |
| 1847 | } |
| 1848 | |
| 1849 | /* now otmp is reused for other items we're placing */ |
| 1850 | |
| 1851 | /* Place a random possession. This could be a weapon, tool, |
| 1852 | food, or gem, i.e. the item classes that are typically |
| 1853 | nonmagical and not worthless. */ |
| 1854 | do { |
| 1855 | int poss_class = RANDOM_CLASS; /* init => lint suppression */ |
| 1856 | |
| 1857 | switch (rn2(4)) { |
| 1858 | case 0: |
| 1859 | poss_class = WEAPON_CLASS; |
| 1860 | break; |
| 1861 | case 1: |
| 1862 | poss_class = TOOL_CLASS; |
| 1863 | break; |
| 1864 | case 2: |
| 1865 | poss_class = FOOD_CLASS; |
| 1866 | break; |
| 1867 | case 3: |
| 1868 | poss_class = GEM_CLASS; |
| 1869 | break; |
| 1870 | } |
| 1871 |
no test coverage detected