function NPC:spawn()
	local ent = {
		id = self.id,
		x = self.x, y = self.y,
		mx = 0, my = 0,
		type = self.type,
		flags = self.flags,
		anim = self.anim,
		frame = 1,
		ticks = 0
	}
	if self.id == -1 -- client-side ents don't take up network slots.
		table.insert(stage.ents,256,ent)
	else
		stage.ents[self.id] = ent
	end
	return ent
end

function NPC:draw(screen,cx,cy)
	local info = NPC[self.type]
	if not info.anims return end
	if not graphics[info.sheet] return end
	local anim = self.anim
	if not info.anims[self.anim] anim = 1 end
	local frame = info.anims[anim][self.frame][1]
	if self.flags & NPCF.FLIP ~= 0 and info.anims[anim][self.frame][2]
		frame = info.anims[anim][self.frame][2]
	end
	local fw = info.display[BBOX.LEFT]+info.display[BBOX.RIGHT]
	local fh = info.display[BBOX.TOP]+info.display[BBOX.BOTTOM]
	screen.draw(graphics[info.sheet],
		{frame[1],frame[2],fw,fh},
		{(math.floor(self.x)-info.display[BBOX.LEFT])-cx,(math.floor(self.y)-info.display[BBOX.TOP])-cy})
end
