#include "mon.h" #include "vars.h" #include "pline.h" #include "util.h" #include "fight.h" /* * One monster (agr, the aggressor) tries to hit another one (def, the * defender) in combat. This makes attack and defense rolls, resolves * the combat, and, if appropriate, delivers damage. * * At present all combat is between the player-avatar monster and other * monsters. If this is changed, reporting messages to the player * will probably need to be made conditional. * * Note that, at present, all combat is melee combat. When ranged * combat is implemented, this may need to be changed. */ void mhitm(MONST *agr, MONST *def) { int dd; TDRV drv; dd = (*agr->ops->attack)(agr) + mon_extra_hit(agr) - (*def->ops->defend)(def) - mon_extra_def(def); if (dd < 0) { if (monst_cansee_monst(you,agr)) { if (monst_cansee_monst(you,def)) { pline("%s%s %s %s!", (*agr->ops->Name)(agr), (dd < -10) ? "" : " barely", pickverb(agr,"miss","misses"), (*def->ops->name)(def) ); } else if (agr == you) { pline("You miss something!"); } } else if (def == you) { pline("Something misses you!"); } } else { if (monst_cansee_monst(you,agr)) { if (monst_cansee_monst(you,def)) { pline("%s %s %s!", (*agr->ops->Name)(agr), pickverb(agr,"hit","hits"), (*def->ops->name)(def) ); } else if (agr == you) { pline("You hit something!"); } } else if (def == you) { pline("Something hits you!"); } drv = (*def->ops->takedamage)(def,(*agr->ops->givedamage)(agr,dd)+mon_extra_dmg(agr)); if (drv.flags & TDRV_DIED) { if (monst_cansee_monst(you,def)) { pline("%s %s!",(*def->ops->Name)(def),pickverb(def,"die","dies")); } else if (agr == you) { pline("It dies!"); } } if (agr->flags & MF_VAMP_REGEN) { gainhp(agr,drv.taken/3); } } }