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

Function use_offensive

src/muse.c:1823–2032  ·  view source on GitHub ↗

Perform an offensive action for a monster. Must be called immediately * after find_offensive(). Return values are same as use_defensive(). */

Source from the content-addressed store, hash-verified

1821 * after find_offensive(). Return values are same as use_defensive().
1822 */
1823int
1824use_offensive(struct monst *mtmp)
1825{
1826 int i;
1827 struct obj *otmp = gm.m.offensive;
1828 boolean oseen;
1829
1830 /* if a monster has never used an attack wand before, it takes them some
1831 time to get used to holding that much power, so the first shot always
1832 misses */
1833 void (*buzzfn)(int, int, coordxy, coordxy, int, int) =
1834 mtmp->mwandexp ? buzz : buzz_force_miss;
1835
1836 /* offensive potions are not drunk, they're thrown */
1837 if (otmp->oclass != POTION_CLASS && (i = precheck(mtmp, otmp)) != 0)
1838 return i;
1839 oseen = canseemon(mtmp);
1840
1841 switch (gm.m.has_offense) {
1842 case MUSE_WAN_DEATH:
1843 case MUSE_WAN_SLEEP:
1844 case MUSE_WAN_FIRE:
1845 case MUSE_WAN_COLD:
1846 case MUSE_WAN_LIGHTNING:
1847 case MUSE_WAN_MAGIC_MISSILE:
1848 mzapwand(mtmp, otmp, FALSE);
1849 if (oseen)
1850 makeknown(otmp->otyp);
1851 gm.m_using = TRUE;
1852 gc.current_wand = otmp;
1853 gb.buzzer = mtmp;
1854 buzzfn(BZ_M_WAND(BZ_OFS_WAN(otmp->otyp)),
1855 (otmp->otyp == WAN_MAGIC_MISSILE) ? 2 : 6, mtmp->mx, mtmp->my,
1856 sgn(mtmp->mux - mtmp->mx), sgn(mtmp->muy - mtmp->my));
1857 gb.buzzer = 0;
1858 gc.current_wand = 0;
1859 gm.m_using = FALSE;
1860 mtmp->mwandexp = TRUE;
1861 return (DEADMONSTER(mtmp)) ? 1 : 2;
1862 case MUSE_FIRE_HORN:
1863 case MUSE_FROST_HORN:
1864 mplayhorn(mtmp, otmp, FALSE);
1865 gm.m_using = TRUE;
1866 gb.buzzer = mtmp;
1867 gc.current_wand = otmp; /* needed by zhitu() */
1868 buzzfn(BZ_M_WAND(BZ_OFS_AD(
1869 (otmp->otyp == FROST_HORN) ? AD_COLD : AD_FIRE)),
1870 rn1(6, 6), mtmp->mx, mtmp->my, sgn(mtmp->mux - mtmp->mx),
1871 sgn(mtmp->muy - mtmp->my));
1872 gb.buzzer = 0;
1873 gc.current_wand = 0;
1874 gm.m_using = FALSE;
1875 mtmp->mwandexp = TRUE;
1876 return (DEADMONSTER(mtmp)) ? 1 : 2;
1877 case MUSE_WAN_TELEPORTATION:
1878 case MUSE_WAN_UNDEAD_TURNING:
1879 case MUSE_WAN_STRIKING:
1880 gz.zap_oseen = oseen;

Callers 1

mattackuFunction · 0.85

Calls 15

canseemonFunction · 0.85
mzapwandFunction · 0.85
sgnFunction · 0.85
mplayhornFunction · 0.85
mbhitFunction · 0.85
mreadmsgFunction · 0.85
pline_TheFunction · 0.85
ceilingFunction · 0.85
mon_namFunction · 0.85
map_invisibleFunction · 0.85
m_useupFunction · 0.85
isokFunction · 0.85

Tested by

no test coverage detected