Jump to content

Prefab Crashes Everybody but Host


Recommended Posts

So i have this mod, and a certain prefab crashes everybody but the host. I have no idea why this is. Maybe one of you could help?

 

This is the prefab lua:

local assets=
    Asset("ANIM", "anim/javelin.zip"),
    Asset("ANIM", "anim/swap_javelin.zip"), 
 
    Asset("ATLAS", "images/inventoryimages/javelin.xml"),
    Asset("IMAGE", "images/inventoryimages/javelin.tex"),
}
 
local prefabs = {}
 
local function OnFinished(inst)
    inst.AnimState:PlayAnimation("used")
    inst.AnimState:SetOrientation( ANIM_ORIENTATION.Default )
    inst:ListenForEvent("animover", function() inst:Remove() end)
end
 
local function OnEquip(inst, owner) 
    owner.AnimState:OverrideSymbol("swap_object", "swap_javelin", "swap_javelin")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
end
 
local function OnUnequip(inst, owner) 
    owner.AnimState:Hide("ARM_carry") 
    owner.AnimState:Show("ARM_normal") 
    inst.AnimState:PlayAnimation("idle")
end
 
 
local function OnThrown(inst, owner, target)
    if target ~= owner then
        owner.SoundEmitter:PlaySound("dontstarve/wilson/boomerang_throw")
    end
    inst.AnimState:PlayAnimation("throw", true)
    inst.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround )
end
 
local function OnHit(inst, owner, target)
    if owner == target then
        OnDropped(inst)
    end
    local impactfx = SpawnPrefab("impact")
    if impactfx then
        local follower = impactfx.entity:AddFollower()
        follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0 )
        impactfx:FacePoint(inst.Transform:GetWorldPosition())
    end
    if owner and not (inst.components.finiteuses and inst.components.finiteuses:GetUses() < 1) then
        inst.AnimState:PlayAnimation("idle", true)
        inst.AnimState:SetOrientation( ANIM_ORIENTATION.Default )
    end
end
 
local function OnMiss(inst, owner, target)
    inst.AnimState:PlayAnimation("missed")
    inst.AnimState:SetOrientation( ANIM_ORIENTATION.Default )
    inst.Physics:Stop()
end
 
local function fn(Sim)
    local inst = CreateEntity()
    local trans = inst.entity:AddTransform()
    local anim = inst.entity:AddAnimState()
    local sound = inst.entity:AddSoundEmitter()
 
    inst.entity:AddNetwork()
    if not TheWorld.ismastersim then
        return inst
    end
    inst.entity:SetPristine()
    MakeHauntableLaunch(inst)
 
    MakeInventoryPhysics(inst)
    
    anim:SetBank("javelin")
    anim:SetBuild("javelin")
    anim:PlayAnimation("idle")
 
    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(TUNING.BOOMERANG_DAMAGE*2)
    inst.components.weapon:SetRange(TUNING.BOOMERANG_DISTANCE, TUNING.BOOMERANG_DISTANCE+2)
 
    inst:AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(TUNING.BOOMERANG_USES/2)
    inst.components.finiteuses:SetUses(TUNING.BOOMERANG_USES/2)
    
    inst.components.finiteuses:SetOnFinished(OnFinished)
 
    inst:AddComponent("projectile")
    inst.components.projectile:SetSpeed(20)
    inst.components.projectile:SetOnThrownFn(OnThrown)
    inst.components.projectile:SetOnHitFn(OnHit)
    inst.components.projectile:SetHoming(false)
    inst.components.projectile:SetOnMissFn(OnMiss)
    inst.components.projectile:SetLaunchOffset(Vector3(3, 2, 0))
    inst.components.projectile:SetRange(20)
 
    inst:AddComponent("inspectable")
 
    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "javelin"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/javelin.xml"
    
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )
 
    return inst
end
 
STRINGS.NAMES.JAVELIN = "Throwing Spear"
STRINGS.CHARACTERS.DROK.DESCRIBE.JAVELIN = "Drok good hunt!"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.JAVELIN = "It's some sort of ancient throwing device."
 
return  Prefab("common/inventory/javelin", fn, assets, prefabs)

 

This is the crash log of a person who wasnt the host:

 

[........]ReleaseAll FinishedcGame::StartPlayingLOADING LUADoLuaFile scripts/main.luaDoLuaFile loading buffer scripts/main.luascripts/main.lua(166,1) running main.lua	loaded modindex	ModIndex: Beginning normal load sequence.	ModIndex:GetModsToLoad inserting moddir, 	Drok Together Beta	Could not load mod_config_data/modconfiguration_Drok Together Beta	Loading mod: Drok Together Beta (Drok)	Mod: Drok Together Beta (Drok)	Loading modworldgenmain.lua	Mod: Drok Together Beta (Drok)	  Mod had no modworldgenmain.lua. Skipping.	Mod: Drok Together Beta (Drok)	Loading modmain.lua	LOADING LUA SUCCESSPlayerDeaths loaded morgue	4061	loaded profile	bloom_enabled	false	loaded saveindex	OnFilesLoaded()	OnUpdatePurchaseStateComplete		Unload FE		Unload FE done	Mod: Drok Together Beta (Drok)	Registering prefabs	Mod: Drok Together Beta (Drok)	  Registering prefab file: prefabs/drok	Mod: Drok Together Beta (Drok)	    drok	Mod: Drok Together Beta (Drok)	  Registering prefab file: prefabs/wigstanstone	Mod: Drok Together Beta (Drok)	    wigstanstone	Mod: Drok Together Beta (Drok)	  Registering prefab file: prefabs/wigstan	Mod: Drok Together Beta (Drok)	    wigstan	Mod: Drok Together Beta (Drok)	  Registering prefab file: prefabs/wigstanfull	Mod: Drok Together Beta (Drok)	    wigstanfull	Mod: Drok Together Beta (Drok)	  Registering prefab file: prefabs/javelin	Mod: Drok Together Beta (Drok)	    javelin	Mod: Drok Together Beta (Drok)	  Registering prefab file: prefabs/redpaint	Mod: Drok Together Beta (Drok)	    redpaint	Mod: Drok Together Beta (Drok)	  Registering prefab file: prefabs/beefalo_hide	Mod: Drok Together Beta (Drok)	    beefalo_hide	Mod: Drok Together Beta (Drok)	  Registering prefab file: prefabs/paintedrock	Mod: Drok Together Beta (Drok)	    paintedrock	Mod: Drok Together Beta (Drok)	    paintedrock_placer	Mod: Drok Together Beta (Drok)	  Registering default mod prefab		LOAD BE	Could not preload undefined prefab 0x20e21d7a (puppet_wes)Could not preload undefined prefab 0x20e21d7a (puppet_wes)	LOAD BE: done	MiniMapComponent::AddAtlas( minimap/minimap_data.xml )MiniMapComponent::AddAtlas( ../mods/Drok Together Beta/images/map_icons/drok.xml )Loading Nav Grid	ClearCurrentResurrectors CB	ModIndex: Load sequence finished successfully.	Reset() returningAssert failure 'false && "cNetworkConnection::AllocReplica Invalid Prefab"' at ..\source\networklib\NetworkConnection.cpp(121): Trace follows... 

 

Thank you for your help.

Edited by QuickShot010
Link to comment
Share on other sites

MakeInventoryPhysics(inst)

    

    anim:SetBank("javelin")

    anim:SetBuild("javelin")

    anim:PlayAnimation("idle")

 I think this should all be above not TheWorld.ismastersim... But I wouldn't expect that to cause the error you're seeing. It looks valid to me... are you sure everyone has the same version of the mod?
Link to comment
Share on other sites

For future reference to anyone experiencing this problem, here is an example on how to replicate this error:

 
Where "entity" is the connected player who will crash,
 
local fakeprefab=Prefabs["berries"].fn()
fakeprefab.Transform:SetPosition(entity.Transform:GetWorldPosition())
 
Is it possible the prefab was not being spawned with function SpawnPrefab or was not initialized properly?
 
Link to comment
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
 Share

×
×
  • Create New...