#!/usr/bin/perl
# This needs to be stackless so others can do damage. Of course, that lets
# anyone modify the hitpoints..
#use Mooix::Thing;
run sub {
	my $this=shift;
	my $damage=shift;

	return if $this->unbreakable;
	
	my $orig_hitpoints = $this->hitpoints;
	$this->hp_regen;
	my $hitpoints = $this->hitpoints($this->hitpoints - $damage);
	
	# Death, unless already dead.
	my $min=$this->minhitpoints;
	if ($hitpoints <= $min && $orig_hitpoints > $min) {
		$this->die;
	}
	# Go unconcious at zero.
	elsif ($hitpoints <= 0 && $orig_hitpoints > 0) {
		$this->collapse;
	}
}
