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

Function mcast_spell

src/mcastu.c:800–897  ·  view source on GitHub ↗

If dmg is zero, then the monster is not casting at you. If the monster is intentionally not casting at you, we have previously called spell_would_be_useless() and spellnum should always be a valid undirected spell. If you modify either of these, be sure to change is_undirected_spell() and spell_would_be_useless(). */

Source from the content-addressed store, hash-verified

798 and spell_would_be_useless().
799 */
800staticfn void
801mcast_spell(struct monst *mtmp, int dmg, int spellnum)
802{
803 if (dmg < 0) {
804 impossible("monster cast spell (%d) with negative dmg (%d)?",
805 spellnum, dmg);
806 return;
807 }
808 if (dmg == 0 && !is_undirected_spell(spellnum)) {
809 impossible("cast directed wizard spell (%d) with dmg=0?", spellnum);
810 return;
811 }
812
813 switch (spellnum) {
814 case MCAST_DEATH_TOUCH:
815 mcast_death_touch(mtmp);
816 dmg = 0;
817 break;
818 case MCAST_CLONE_WIZ:
819 mcast_clone_wiz(mtmp);
820 dmg = 0;
821 break;
822 case MCAST_SUMMON_MONS:
823 mcast_summon_mons(mtmp);
824 dmg = 0;
825 break;
826 case MCAST_AGGRAVATION:
827 You_feel("that monsters are aware of your presence.");
828 aggravate();
829 dmg = 0;
830 break;
831 case MCAST_CURSE_ITEMS:
832 You_feel("as if you need some help.");
833 rndcurse();
834 dmg = 0;
835 break;
836 case MCAST_DESTRY_ARMR:
837 mcast_destroy_armor();
838 dmg = 0;
839 break;
840 case MCAST_WEAKEN_YOU: /* drain strength */
841 mcast_weaken_you(mtmp, dmg);
842 dmg = 0;
843 break;
844 case MCAST_DISAPPEAR: /* makes self invisible */
845 mcast_disappear(mtmp);
846 dmg = 0;
847 break;
848 case MCAST_STUN_YOU:
849 mcast_stun_you(dmg);
850 dmg = 0;
851 break;
852 case MCAST_HASTE_SELF:
853 mon_adjust_speed(mtmp, 1, (struct obj *) 0);
854 dmg = 0;
855 break;
856 case MCAST_CURE_SELF:
857 dmg = m_cure_self(mtmp, dmg);

Callers 1

castmuFunction · 0.85

Calls 15

is_undirected_spellFunction · 0.85
mcast_death_touchFunction · 0.85
mcast_clone_wizFunction · 0.85
mcast_summon_monsFunction · 0.85
You_feelFunction · 0.85
aggravateFunction · 0.85
rndcurseFunction · 0.85
mcast_destroy_armorFunction · 0.85
mcast_weaken_youFunction · 0.85
mcast_disappearFunction · 0.85
mcast_stun_youFunction · 0.85
mon_adjust_speedFunction · 0.85

Tested by

no test coverage detected