Jump to content

How to enable nightvision as a personal perk instead of a shared perk?


Recommended Posts

I have a friend using a character called the nightmare which has nightvision, but other characters around him can also make use of it. I want to be able to give my character nightvision but without others being able to make use of it. I've looked through the code and this is what I found.

local function NightVision(inst)
	if not TheWorld.state.isday or TheWorld:HasTag("cave") then
		inst.Light:Enable(true)
		nightVision = true
		print("NightVision On")
    else
        inst.Light:Enable(false)
		nightVision = false
		print("NightVision Off")
end
end

-- This initializes for both clients and the host
local common_postinit = function(inst) 	
	inst.soundsname = "maxwell"

	-- Minimap icon
	inst.MiniMapEntity:SetIcon( "nightmareplayer.tex" )
	
	inst:AddTag("monster")
	
	inst:ListenForEvent("respawnfromghost", function(inst)
	    --inst:DoTaskInTime(5, SpawnTerrorbeakpet(inst))
		inst:DoTaskInTime(0.5, NightVision) 
	end)
    
	inst:WatchWorldState("startnight", NightVision)
	inst:WatchWorldState("startday", NightVision)
	
	if TheWorld.state.isnight and nightVision == false or TheWorld:HasTag("cave") and nightVision == false then
		inst:DoTaskInTime(0, NightVision)		
	elseif not TheWorld.state.isnight and nightVision == true or not TheWorld:HasTag("cave") and nightVision == true then
		inst:DoTaskInTime(0, NightVision)		
	end
	
	inst.entity:AddLight()
    inst.Light:Enable(false)
	inst.Light:SetRadius(30)
    inst.Light:SetFalloff(0.9)
    inst.Light:SetIntensity(0.7)
    inst.Light:SetColour(180/255,195/255,150/255)
end

I'm not sure what to change to make the nightvision a personal perk.

Edited by Rainbow Kitty
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...