Fancy_Fox_Pers Posted December 25, 2015 Share Posted December 25, 2015 I'm sorry, I really thought I got the hang of it this time... All I see is a big shadow on the ground :/ I don't see what's wrong. If anyone has the time, here are the mobs' files. lua prefab :local brain = require "brains/wurm_thibaudbrain"--[NEW] Here we list any assets required by our prefab.local assets={--[NEW] this is the name of the Spriter file.Asset("ANIM", "anim/wurm_thibaud.zip"),}STRINGS.NAMES.WURM_THIBAUD = "Wurm"local prefabs = { "wurm_thibaud" }local function OnStartFollowing(inst) inst:AddTag("companion")endlocal function OnStopFollowing(inst) inst:RemoveTag("companion")endlocal function ShouldWakeUp(inst) return DefaultWakeTest(inst) or not inst.components.follower:IsNearLeader(WAKE_TO_FOLLOW_DISTANCE)endlocal function ShouldSleep(inst) return DefaultSleepTest(inst) and not inst.sg:HasStateTag("open") and inst.components.follower:IsNearLeader(SLEEP_NEAR_LEADER_DISTANCE) and not TheWorld.state.isfullmoonend--[NEW] This function creates a new entity based on a prefab.local function init_prefab()--[NEW] First we create an entity.local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState()inst.AnimState:SetBank("wurm_thibaud") inst.AnimState:SetBuild("wurm_thibaud")-- inst.AnimState:PlayAnimation("idle") inst.entity:AddSoundEmitter() inst.entity:AddDynamicShadow()inst.DynamicShadow:SetSize(2.5, .75) inst.entity:AddMiniMapEntity() inst.entity:AddNetwork() inst.entity:AddLightWatcher()MakeCharacterPhysics(inst, 75, .5) inst.Physics:SetCollisionGroup(COLLISION.CHARACTERS) inst.Physics:ClearCollisionMask() inst.Physics:CollidesWith(COLLISION.WORLD) inst.Physics:CollidesWith(COLLISION.OBSTACLES) inst.Physics:CollidesWith(COLLISION.CHARACTERS)inst.Transform:SetFourFaced()inst:AddComponent("follower")inst:ListenForEvent("stopfollowing", OnStopFollowing)inst:ListenForEvent("startfollowing", OnStartFollowing)inst:AddComponent("health") inst.components.health:SetMaxHealth(TUNING.TALLBIRD_HEALTH) inst:AddComponent("sleeper") inst.components.sleeper:SetResistance(3)inst.components.sleeper.testperiod = GetRandomWithVariance(6, 2) inst.components.sleeper:SetSleepTest(ShouldSleep) inst.components.sleeper:SetWakeTest(ShouldWakeUp)inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 6 inst.components.locomotor.runspeed = 6inst:AddComponent("inspectable")inst:SetStateGraph("SGwurm_thibaud") inst.sg:GoToState("idle")inst:AddTag("companion")inst:AddTag("scarytoprey")inst:AddTag("notraptrigger")inst:AddTag("wurm_thibaud")inst:SetBrain(brain) return instend--[NEW] Here we register our new prefab so that it can be used in game.return Prefab( "common/wurm_thibaud", init_prefab, assets, nil) stategraph :require("stategraphs/commonstates")local actionhandlers = {}local events={CommonHandlers.OnStep(), CommonHandlers.OnSleep(), CommonHandlers.OnLocomote(false,true), EventHandler("attacked", function(inst) if inst.components.health and not inst.components.health:IsDead() then inst.sg:GoToState("hit") inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/hurt") end end), EventHandler("death", function(inst) inst.sg:GoToState("death") end),}local states={ State{ name = "idle", tags = {"idle", "canrotate"}, onenter = function(inst, pushanim) inst.Physics:Stop() inst.AnimState:PlayAnimation("idle_loop") if not inst.sg.mem.pant_ducking or inst.sg:InNewState() theninst.sg.mem.pant_ducking = 1end end, events= { EventHandler("animover", function(inst) inst.sg:GoToState("idle") end), }, timeline= { TimeEvent(7*FRAMES, function(inst) inst.sg.mem.pant_ducking = inst.sg.mem.pant_ducking or 1inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pant", nil, inst.sg.mem.pant_ducking) if inst.sg.mem.pant_ducking and inst.sg.mem.pant_ducking > .35 theninst.sg.mem.pant_ducking = inst.sg.mem.pant_ducking - .05endend), }, }, State{ name = "death", tags = {"busy"}, onenter = function(inst) inst.components.container:Close() inst.components.container:DropEverything() inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/death") inst.AnimState:PlayAnimation("death") inst.Physics:Stop() RemovePhysicsColliders(inst) end, },} CommonStates.AddWalkStates(states, { walktimeline = { --TimeEvent(0*FRAMES, function(inst) end), TimeEvent(1*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/boing") inst.components.locomotor:RunForward() end), --TimeEvent(12*FRAMES, function(inst) PlayFootstep(inst) end), TimeEvent(14*FRAMES, function(inst) PlayFootstep(inst) inst.components.locomotor:WalkForward() end), }}, nil, true)CommonStates.AddSleepStates(states,{ starttimeline = { TimeEvent(0*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/close") end) }, waketimeline = { TimeEvent(0*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/open") end) },})CommonStates.AddSimpleState(states, "hit", "hit", {"busy"})return StateGraph("wurm_thibaud", states, events, "idle", actionhandlers) brain (I guess this one's irrelevant, so I'm not posting it for now) : spriter :wurm_thibaud.zip Thanks in advance, sorry that I have to ask this. I just can't see it. I hope next time I won't have such a stupid problem ^^ Link to comment Share on other sites More sharing options...
Fancy_Fox_Pers Posted December 29, 2015 Author Share Posted December 29, 2015 Does anyone have any experience with creature modding? There's probably something obviously wrong in the prefab/stategraph code Thank you Link to comment Share on other sites More sharing options...
BjFiddles Posted February 10, 2016 Share Posted February 10, 2016 So the same thing happened for me (I am using mods) and I can add that they were baby beefalo. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now