local peopleSpawned = 0
minetest.register_abm({
    nodenames = {"main:bricks_stone"},
    interval = 10,
    chance = 340,
    action = function(pos, node, active_object_count, active_object_count_wider)
		if peopleSpawned < 100 then
			newPos = {x = pos.x, y = pos.y + 2, z = pos.z}
			local i = math.random(0, 7)
			if i < 2 then
				minetest.add_entity(newPos, "people:female")
		
			else
				minetest.add_entity(newPos, "people:male")
		
			end
			
			peopleSpawned = peopleSpawned + 1
		end
    end})


-- People
-- Currently only male and female.
-- No non-binary erasure intended; there just aren't that many non-binary guys in Eastern Europe.
mobs:register_mob(":people:female", {
	type = "npc",
	passive = true,
	attack_type = "dogfight",
	pathfinding = true,
	reach = 2,
	damage = 1,
	hp_min = 10,
	hp_max = 15,
	collisionbox = 
	{
		-.4, 0, -.4, .4, 2, .4
	},
	pushable = true,
	visual = "mesh",
	mesh = "character.b3d",
	textures = 
	{
		{"female_person.png"},
		{"female_person1.png"},
		{"female_person2.png"},
		{"female_person3.png"},
	},
	
	makes_footstep_sound = true,
	sounds = 
	{
		random = "female_noise",
	},
	
	walk_velocity = 2,
	run_velocity = 8,
	jump_height = 1,
	stepheight = 0,
	floats = 0,
	view_range = 45,
	fall_damage = true,
	
	
	animation = 
	{
		speed_normal = 30,
		speed_run = 50,
		stand_start = 0,
		stand_end = 79,
		walk_start = 168,
		walk_end = 187,
		run_start = 168,
		run_end = 187,
		punch_start = 200,
		punch_end = 219
	},
	on_die = function(self, pos)
		onPersonDie(self, pos)
	end
})

mobs:register_mob(":people:male", {
	type = "npc",
	passive = true,
	attack_type = "dogfight",
	pathfinding = true,
	reach = 2,
	damage = 1,
	hp_min = 10,
	hp_max = 15,
	collisionbox = 
	{
		-.4, 0, -.4, .4, 2, .4
	},
	pushable = true,
	visual = "mesh",
	mesh = "character.b3d",
	textures = 
	{
		{"male_person.png"},
		{"male_person1.png"},
		{"male_person2.png"},
	},
	
	makes_footstep_sound = true,
	sounds = 
	{
		random = "male_noise",
	},
	
	walk_velocity = 2,
	run_velocity = 8,
	jump_height = 1,
	stepheight = 0,
	floats = 0,
	view_range = 45,
	fall_damage = true,
	
	
	animation = 
	{
		speed_normal = 30,
		speed_run = 50,
		stand_start = 0,
		stand_end = 79,
		walk_start = 168,
		walk_end = 187,
		run_start = 168,
		run_end = 187,
		punch_start = 200,
		punch_end = 219
	},
	
	on_die = function(self, pos)
		onPersonDie(self, pos)
	end
})



onPersonDie = function(self, pos)
	minetest.set_node(pos, {name = "literal_trash:bloodstain", param2 = 1})
	destruction_counter.peopleKilled = destruction_counter.peopleKilled + 1
end