Jump to content

Recommended Posts

I try to add a new Maxwell minion type that works like Chester so I call it Shadow bearer, It works correctly if I play alone but if I play with friends the game will crash and freeze when someone on server try to create Shadow bearer. I also attached pictures with error log of my friend as client below. This is a code that makes a minion

local function MakeMinion(prefab, tool, hat, master_postinit)
    local assets =
    {
        Asset("ANIM", "anim/waxwell_shadow_mod.zip"),
        Asset("SOUND", "sound/maxwell.fsb"),
        Asset("ANIM", "anim/"..tool..".zip"),
    }

    local function fn()
        local inst = CreateEntity()

        inst.entity:AddTransform()
        inst.entity:AddAnimState()
        inst.entity:AddSoundEmitter()
        inst.entity:AddNetwork()
        inst.entity:AddDynamicShadow() --Bugfix for hat that alters shadow (eyebrella)
        
        inst.DynamicShadow:Enable(false)

        MakeGhostPhysics(inst, 1, 0.5)

        inst.Transform:SetFourFaced(inst)

        inst.AnimState:SetBank("wilson")
        inst.AnimState:SetBuild("waxwell_shadow_mod")
        inst.AnimState:PlayAnimation("idle")
        inst.AnimState:SetMultColour(0, 0, 0, .5)

        if tool ~= nil then
            inst.AnimState:OverrideSymbol("swap_object", tool, tool)
            inst.AnimState:Hide("ARM_normal")
        else
            inst.AnimState:Hide("ARM_carry")
        end

        if hat ~= nil then
            inst.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat")
            inst.AnimState:Hide("HAIR_NOHAT")
            inst.AnimState:Hide("HAIR")
        else
            inst.AnimState:Hide("HAT")
            inst.AnimState:Hide("HAT_HAIR")
        end
		
		if tool == "swap_cane" then
			inst:AddTag("isCourier")
			inst:AddComponent("container")
			inst.components.container:WidgetSetup("treasurechest")
		end
		
        inst:AddTag("scarytoprey")
        inst:AddTag("shadowminion")

        inst:SetPrefabNameOverride("shadowwaxwell")

        inst.entity:SetPristine()

        if not TheWorld.ismastersim then
            return inst
        end

        inst:AddComponent("locomotor")
        inst.components.locomotor.runspeed = TUNING.SHADOWWAXWELL_SPEED
        inst.components.locomotor.pathcaps = { ignorecreep = true }
        inst.components.locomotor:SetSlowMultiplier(.6)

        inst:AddComponent("health")
        inst.components.health:SetMaxHealth(TUNING.SHADOWWAXWELL_LIFE)
		inst.components.health:StartRegen(TUNING.SHADOWWAXWELL_HEALTH_REGEN / 2, TUNING.SHADOWWAXWELL_HEALTH_REGEN_PERIOD)
        inst.components.health.nofadeout = true
        inst.components.health.redirect = nodebrisdmg

        inst:AddComponent("combat")
        inst.components.combat.hiteffectsymbol = "torso"
		inst.components.combat:SetRange(2)

        inst:AddComponent("follower")
        inst.components.follower:KeepLeaderOnAttacked()
        inst.components.follower.keepdeadleader = true
        
        inst:AddComponent("inventory")
        inst.components.inventory:DisableDropOnDeath()
        
        inst:AddComponent("trader")        
        inst.components.trader:SetAcceptTest(ShouldAcceptItem)
        inst.components.trader.onaccept = OnGetItemFromPlayer
        --inst.components.trader.onrefuse = OnRefuseItem
        inst.components.trader.deleteitemonaccept = false

        inst:SetBrain(brain)
        inst:SetStateGraph("SGshadowwaxwell")

        inst:ListenForEvent("attacked", OnAttacked)

        if master_postinit ~= nil then
            master_postinit(inst)
        end

        return inst
    end

    return Prefab(prefab, fn, assets, prefabs)
end

Basically, this original mod made by Farxodor, I use his make minion code and only add this to his code

		if tool == "swap_cane" then
			inst:AddTag("isCourier")
			inst:AddComponent("container")
			inst.components.container:WidgetSetup("treasurechest")
		end

Does anyone know how I can fix this error?

All help is greatly appreciated. Thank you.

49864454_2002055086764166_6854201422783709184_n.png

Edited by Zeroless

Since the problem happens on clients, it's probably about the components which are/aren't added to the entity on the clients. As you can see in the Chester prefab, the container is not added if TheWorld.ismastersim is false, so I think you need to move your if-statement which adds the container-component below your TheWorld.ismastersim check.

Edited by Ultroman
3 hours ago, Ultroman said:

Since the problem happens on clients, it's probably about the components which are/aren't added to the entity on the clients. As you can see in the Chester prefab, the container is not added if TheWorld.ismastersim is false, so I think you need to move your if-statement which adds the container-component below your TheWorld.ismastersim check.

Thank you for your help,  I have edited as you said, now everyone can make shadow bearer but clients will crash if try to open shadow bearer no matter who created it.

below is error log when clients try to open shadow bearer.

49329772_305130616788007_355835180025380864_n.png

I could be wrong, but is Chester not normally inaccessible to anyone who isn't the "owner" of the Eyebone? I don't think others are supposed to interact with eachother's living containers, using the usual code. Look at how a chest is implemented, to see how they've solved the networking/widget issue.

  • Thanks 1
15 minutes ago, Ultroman said:

I could be wrong, but is Chester not normally inaccessible to anyone who isn't the "owner" of the Eyebone? I don't think others are supposed to interact with eachother's living containers, using the usual code. Look at how a chest is implemented, to see how they've solved the networking/widget issue.

but a client also got crash too, even though he is the owner

Not really. Look at the chest prefab, or one of the many chest mods out there. There's also a bunch of mods which add more Chesters, and even one that makes it possible for everyone to have their own Chester from the start of the game.

Edited by Ultroman
19 hours ago, jcosmick said:

How did you resolved it?

I had a similar problem, I solved it this way

if not TheWorld.ismastersim then
		inst.OnEntityReplicated = function(inst) 
			inst.replica.container:WidgetSetup("shoevel_container") 
		end
		return inst
	end

 

  • Thanks 1

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