Jump to content

Recommended Posts

Hello. There is a script. Actually here it is 

Spoiler

local prefabs = {}

local function Onsanitydelta(inst,data)
   if inst.components.sanity.current <= 190 and inst.components.sanity.current > 170 then
      inst.components.combat.damagemultiplier = 1.1
      inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.15)
      inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.15)
   elseif  inst.components.sanity.current <= 170 and inst.components.sanity.current > 150 then
      inst.components.combat.damagemultiplier = 1.2
      inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2)
      inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2)
   elseif  inst.components.sanity.current <= 150 and inst.components.sanity.current > 120 then
      inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.25)
      inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.25)
      inst.components.combat.damagemultiplier = 1.3
      
TUNING.SANITY_NIGHT_LIGHT = -20/60
      
      TUNING.SANITY_NIGHT_MID = -20/60
       
      TUNING.SANITY_NIGHT_DARK = -20/60
      TUNING.SANITY_DAY_GAIN = -20/60
   elseif  inst.components.sanity.current <= 120 and inst.components.sanity.current > 90 then
      inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.3)
      inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.3)
      inst.components.combat.damagemultiplier = 1.4
   elseif  inst.components.sanity.current <= 90 then
      inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.35)
      inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.35)
      inst.components.combat.damagemultiplier = 1.5
      
TUNING.SANITY_NIGHT_LIGHT = -4/60
      
      TUNING.SANITY_NIGHT_MID = -4/60
       
      TUNING.SANITY_NIGHT_DARK = -4/60
      TUNING.SANITY_DAY_GAIN = -4/60
   elseif  inst.components.sanity.current > 90 then
      inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.4)
      inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.4)
      
TUNING.SANITY_NIGHT_LIGHT = -45/60
      
      TUNING.SANITY_NIGHT_MID = -45/60
       
      TUNING.SANITY_NIGHT_DARK = -45/60
      TUNING.SANITY_DAY_GAIN = -45/60
   end
   if IsDLCEnabled(REIGN_OF_GIANTS) then 
      if inst.components.sanity.current < 100 then
         inst.Light:Enable(true)
      else
         inst.Light:Enable(false)
      end
   end
end

local function Attack(inst,data)
   inst.components.sanity:DoDelta(5)
   if math.random() <= 0.1 then
     inst.components.health:DoDelta(5)
   end
   return inst
end


local common_postinit = function(inst) 
    -- Minimap icon
    inst.MiniMapEntity:SetIcon( "yuno.tex" )
end


local master_postinit = function(inst)

    -- choose which sounds this character will play
    inst.soundsname = "willow"


    -- Stats    
         inst.components.health:SetMaxHealth(150)
         inst.components.hunger:SetMax(150)
        inst.components.combat.damagemultiplier = 1.0
     
        inst.components.sanity:SetMax(200)
    inst.components.combat:SetAttackPeriod(0.25)
    inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.1)
    inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.1)
        inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.2)
        inst:ListenForEvent("onhitother",Attack)
        inst.components.health:StartRegen(-1,30)
        if IsDLCEnabled(REIGN_OF_GIANTS) then 
      inst.Light:SetRadius(9)
      inst.Light:SetFalloff(1)
      inst.Light:SetIntensity(.5)
      inst.Light:SetColour(128/255,128/255,255/255)
      inst.Light:Enable(false)
        end
        inst:ListenForEvent("sanitydelta",Onsanitydelta)
    return inst
end


STRINGS.CHARACTER_TITLES.yuno = "**"
STRINGS.CHARACTER_NAMES.yuno = "**"
STRINGS.CHARACTER_DESCRIPTIONS.yuno = "*"
STRINGS.CHARACTER_QUOTES.yuno = "\".....\""


return MakePlayerCharacter("yuno", prefabs, assets, common_postinit, master_postinit)

That character has sanity drain all the time and it is good. But if I'll want to play with my friends I face with the problem that every friend has sanity drain like me.
What should I do?

You can't change TUNING values because when you change it, it will effect to all players.
Instead of changing TUNING values you can use the code below:

local function RecalcSanity(inst)
   -- if <your condition> then return <your value here> end
end
inst.components.sanity.custom_rate_fn = RecalcSanity


You can look in sanity component at "Sanity:Recalc" function to know more how it work.

Edited by zUsername
On 26.02.2016 at 8:14 PM, zUsername said:

You can't change TUNING values because when you change it, it will effect to all players.
Instead of changing TUNING values you can use the code below:


local function RecalcSanity(inst)
   -- if <your condition> then return <your value here> end
end
inst.components.sanity.custom_rate_fn = RecalcSanity


You can look in sanity component at "Sanity:Recalc" function to know more how it work.

Thx

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
×
  • Create New...