#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 * wiwll probably need to be made conditional. */ void mhitm(MONST *agr, MONST *def) { int dd; dd = (*agr->ops->attack)(agr) - (*def->ops->defend)(def); if (dd < 0) { pline("%s%s %s %s!", (*agr->ops->Name)(agr), (dd < -10) ? "" : " barely", pickverb(agr,"miss","misses"), (*def->ops->name)(def) ); } else { pline("%s %s %s!", (*agr->ops->Name)(agr), pickverb(agr,"hit","hits"), (*def->ops->name)(def) ); if ((*def->ops->takedamage)(def,(*agr->ops->givedamage)(agr,dd))) { pline("%s %s!",(*def->ops->Name)(def),pickverb(def,"die","dies")); } } }