Jump to content

Recommended Posts

So, what's the deal. I've decided to make a character mod again, and it has to have seizures everytime sanity drop at certain level.

I've figured out a code, that doesn't crash the game down (at least), but doesn't work properly anyway.

local function seizure(inst)
    if inst.components.sanity.current > (25) and inst.components.sanity.current <= (50) then 
        
        inst.AnimState:PlayAnimation("idle_inaction_sanity_down", true)
        inst.components.locomotor.walkspeed = ( TUNING.WILSON_WALK_SPEED * 0.50 )
        inst.components.locomotor.runspeed = ( TUNING.WILSON_RUN_SPEED * 0.50 )
        inst.components.talker:Say("I feel... Not so... Well...", 3, false)

    elseif inst.components.sanity.current >= (0) and inst.components.sanity.current <= (25) then 
        
        local x, y, z = inst.Transform:GetWorldPosition()
        for i, v in ipairs(ents) do
            v:PushEvent("knockedout", { grogginess = 4, knockoutduration = time + math.random() })
            if v.components.sleeper ~= nil then
                v.components.sleeper:AddSleepiness(7, time + math.random())
            elseif v.components.grogginess ~= nil then
                v.components.grogginess:AddGrogginess(4, time + math.random())
            else
                v:PushEvent("knockedout")
            end
--inst.components.talker:Say("Help...", 2, false)
        end    
    end
end

As a base of second "phase" I was looking for mandrake's props, if so.
And I also can't figure out, what's the animation of insanity, while standing, called in files ~_~ Was looking for it everywhere, still doesn't work (character just disappears in time of anim)   

Ok, i've figured some things out, but i still have issues.

local function seizure(inst)
	  
	   inst.components.talker:Say("My head goes dizzy a bit...", 3.0, false)
	if inst.components.sanity.current > (2) and inst.components.sanity.current <= (50) then 
		
		inst.components.locomotor.walkspeed = ( TUNING.WILSON_WALK_SPEED * 0.50 )
		inst.components.locomotor.runspeed = ( TUNING.WILSON_RUN_SPEED * 0.50 )
		inst.components.combat.damagemultiplier = 0.40
	    
elseif inst.components.sanity.current >= (0) and inst.components.sanity.current <= (2) then 
	
		inst:PushEvent("sleep", { grogginess = 4, knockoutduration = 10 })
            if inst.components.sleeper ~= nil then
                inst.components.sleeper:AddSleepiness(7, 50)
            elseif inst.components.grogginess ~= nil then
                inst.components.grogginess:AddGrogginess(4, 50)
            else
                inst:PushEvent("knockedout")
            end
            inst.components.talker:Say("Help...", 2)
    end    
end

How to make first speech line not repeatable for endless amount of times, and how to put good sanity regen while in second phase of seizure (aka sleeping)? I'd be very pleased if someone would help me w this ><

--what about set a range for the speech and only announce once each your sanity is lower than that
--like
if inst.components.sanity.current <= 50 then
    if inst.announcedizzy == nil
    then
        inst.announcedizzy = true
        inst.components.talker:Say("My head goes dizzy a bit...", 3.0, false)
    end
else
    inst.announcedizzy = nil
end
--so it announces only once when your san is lower than 50

 

--I don't exactly understand what is a good sanity regen you need,does it means sanity increase in sleep is not enough for you?
--then you can try
inst.components.sanity:DoDelta(1)
--since you've periodically call this fn, you can just change the num of sanity

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...