require "ZomboLewd/ZomboLewdConfig"

ZomboLewdConfig.Modules.SpawnIsoPlayerSurvivor = function(worldobjects, character)
	print("Zombolewd SpawnIsoPlayerSurvivor debug:")
	-- near player (old version)
	--local random_instance = newrandom()
	--local offsetX = character:getX() + random_instance:random(-3, 3)	
	--local offsetY = character:getY() + random_instance:random(-3, 3)
	--on cursor (new version)
	local firstObject;
	for _,o in ipairs(worldobjects) do
	  if not firstObject then firstObject = o; end
	end
	local offsetX = firstObject:getX()
	local offsetY = firstObject:getY()
	--local desc = SurvivorFactory.CreateSurvivor(nil, not character:isFemale())
	local desc = SurvivorFactory.CreateSurvivor()
	local cell = getWorld():getCell()
	--SurvivorFactory.randomName(desc)
	SurvivorFactory.getRandomSurname()
	SurvivorFactory.getRandomForename(not character:isFemale())
	SurvivorFactory.setTorso(desc)
	local survivorModel = IsoPlayer.new(cell, desc, offsetX, offsetY, character:getZ())
	--survivorModel:getInventory():emptyIt()
	if character:isFemale() then
		survivorModel:setFemale(false)
		survivorModel:dressInNamedOutfit("Biker")
	else
		survivorModel:setFemale(true)
		survivorModel:dressInNamedOutfit("DressLong")
	end
	survivorModel:dressInRandomOutfit() --глючит и непись получается стабильно голым	
	survivorModel:setSceneCulled(false)
	survivorModel:setBlockMovement(true)
	--survivorModel:setNPC(true)	
	survivorModel:setDir(character:getDir())
	survivorModel:addToWorld()
	survivorModel:resetModelNextFrame()
	survivorModel:resetModel()	
	--print("trying to fix Survivor animation...")
	--IsoPlayer.setLocalPlayer(character)
	--IsoPlayer.setInstance(character)
	--cell:addMovingObject(survivorModel)

end