Sign in to follow this  
DarkCrafter

Need a little help

Recommended Posts

DarkCrafter    6

You are missing something:

    inst:AddComponent("hauntable")    inst.components.hauntable:SetHauntValue(TUNING.HAUNT_INSTANT_REZ)    inst.components.hauntable:SetOnHauntFn(onhaunt)

And you may want to replace 0.8 with 0.2 or it will break often.

inst.components.hauntable:SetOnHauntFn(onhaunt) made the resurrect part not work. :\

Share this post


Link to post
Share on other sites
DarkXero    2892
local function onhaunt(inst)
    inst.components.resurrector.active = true
    inst.SoundEmitter:PlaySound("dontstarve/common/resurrectionstone_activate")
    if math.random() <= 0.8 then
          inst:Remove()
    end
    return true
end

 

Share this post


Link to post
Share on other sites
DarkXero    2892

After trying, I don't think what you want to get with shadows is doable, since the only way you can hit them is when they are pissed at something, like you or other players. If they ignore me and they don't have targets, then I can't target them.

 

I tried removing the grue component but strangely it didn't work, so you can also try:

AddComponentPostInit("grue", function(Grue)	local old = Grue.SetSleeping	function Grue:SetSleeping(asleep)		old(self, asleep)		if self.inst.prefab == "MyCharacter" then			self.sleeping = true		end	endend)

in modmain.lua and

inst.components.grue:SetSleeping(false)

in your character prefab.

 

EDIT: Toying around, I got something that you may like.

Add this to modmain.lua:

AddPrefabPostInit("crawlinghorror", function(inst)	inst.hitbyfriend = false	inst.warnings = 0end)AddPrefabPostInit("terrorbeak", function(inst)	inst.hitbyfriend = false	inst.warnings = 0end)AddStategraphPostInit("shadowcreature", function(sg)	sg.events.attacked.fn = function(inst) 		if not inst.components.health:IsDead() and not inst.sg:HasStateTag("attack") then 			if inst.components.combat.target:HasTag("shadowfriend") then				inst.hitbyfriend = true			end			inst.sg:GoToState("hit")		end	end	sg.events.doattack.fn = function(inst, data) 		if not inst.components.health:IsDead() and not inst.sg:HasStateTag("busy") then			local check = inst.components.combat.target:HasTag("shadowfriend")			if (inst.hitbyfriend and check) or not check then				inst.sg:GoToState("attack", data.target)				else				if inst.warnings < 3 then					inst.warnings = inst.warnings + 1					inst.sg:GoToState("taunt")				else					inst.warnings = 0					inst.sg:GoToState("hit")				end			end		end	endend)

And this to your character prefab:

inst:AddTag("shadowfriend")

Shadows will go to yell at you and get aggressive when you hit them.

Edited by DarkXero

Share this post


Link to post
Share on other sites
DarkXero    2892

Use the code I gave you and where it says

if self.inst.prefab == "MyCharacter" then

replace MyCharacter for the name of your character prefab. And it will work.

Share this post


Link to post
Share on other sites
DarkXero    2892
AddComponentPostInit("grue", function(Grue)    local old = Grue.SetSleeping    function Grue:SetSleeping(asleep)        old(self, asleep)        if self.inst.prefab == "wilson" then            self.sleeping = true        end    endend)AddPlayerPostInit(function(player)	if player.prefab == "wilson" then		player.components.grue:SetSleeping(false)	endend)

Put this in modmain.lua and rename "wilson" into whatever your character prefab is.

You have a custom character, right?

Share this post


Link to post
Share on other sites
DarkCrafter    6
AddComponentPostInit("grue", function(Grue)    local old = Grue.SetSleeping    function Grue:SetSleeping(asleep)        old(self, asleep)        if self.inst.prefab == "wilson" then            self.sleeping = true        end    endend)AddPlayerPostInit(function(player)	if player.prefab == "wilson" then		player.components.grue:SetSleeping(false)	endend)

Put this in modmain.lua and rename "wilson" into whatever your character prefab is.

You have a custom character, right?

 

yes

Share this post


Link to post
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
Sign in to follow this