Jump to content

Custom perk anim goes crazy


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)   

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...