Eusong Posted November 3, 2017 Share Posted November 3, 2017 I'm making a custom creature and, although it takes damage from being on fire, the fire doesn't show up on it. Any help? Here's the code. Spoiler --Here we list any assets required by our prefab. local assets= { --this is the name of the Spriter file. Asset("ANIM", "anim/bloatfly.zip"), } local prefabs= { "radmonstermeat", } local loot = { "radmonstermeat", } local WAKE_TO_FOLLOW_DISTANCE = 10 local SLEEP_NEAR_LEADER_DISTANCE = 7 local function FindEntityFun(inst) --local x, y, z = inst.Transform:GetWorldPosition() for k, v in pairs(AllPlayers) do if inst:GetDistanceSqToInst(v) < 1000 then if v.components and v.components.rads and not v:HasTag("radresistant") and not v:HasTag("radimmune") then v.components.rads.current = v.components.rads.current + 0.005 end end end end local function EnableFlap(inst, enable) if enable then if not inst.flapping then inst.flapping = true if not inst:IsAsleep() then inst.SoundEmitter:PlaySound("dontstarve/creatures/mosquito/mosquito_fly_LP", "flap") end end elseif inst.flapping then inst.flapping = false inst.SoundEmitter:KillSound("flap") end end local function RetargetFn(inst) return not inst.components.sleeper:IsAsleep() and ( FindEntity( inst, 10, function(guy) return guy.components.combat.target == inst and inst.components.combat:CanTarget(guy) end, { "_combat" }, --see entityreplica.lua { "prey", "smallcreature", "INLIMBO" } ) ) or nil end local function KeepTargetFn(inst, target) return inst.components.combat:CanTarget(target) end local function OnAttacked(inst, data) inst.components.combat:SetTarget(data.attacker) end local function OnHitOther(inst, target) end local function SetSpringBirdState(inst) inst:RemoveTag("companion") inst.components.hunger:SetKillRate(0) end local function StartSpringSmallBird(inst, leader) SetSpringBirdState(inst) inst.leader = leader inst.Transform:SetPosition(leader.Transform:GetWorldPosition()) end local function onsave(inst, data) data.springbird = not inst:HasTag("companion") or nil end local function onload(inst, data) if data ~= nil and data.springbird then SetSpringBirdState(inst) end end local function ShouldWakeUp(inst) return DefaultWakeTest(inst) or not inst.components.follower:IsNearLeader(WAKE_TO_FOLLOW_DISTANCE) end local function ShouldSleep(inst) return DefaultSleepTest(inst) and inst.components.follower:IsNearLeader(SLEEP_NEAR_LEADER_DISTANCE) end local function FollowLeader(inst) local leader = inst.leader if leader == nil or not leader:IsValid() then inst.leader = nil if not inst:HasTag("companion") then --Spring birds just become orphans return end local x, y, z = inst.Transform:GetWorldPosition() leader = FindClosestPlayerInRange(x, y, z, 10, true) if leader == nil then --Didn't find a new parent yet return end end if leader.components.leader ~= nil then --print(" adding follower") leader.components.leader:AddFollower(inst) --[[if leader.components.homeseeker and leader.components.homeseeker:HasHome() and leader.components.homeseeker.home.prefab == "tallbirdnest" then leader.components.homeseeker.home.canspawnsmallbird = true end]] end end local function OnAttacked(inst, data) inst.components.combat:SuggestTarget(data.attacker) inst.components.combat:ShareTarget(data.attacker, 10, function(dude) return dude:HasTag("bloatfly") and not dude.components.health:IsDead() end, 5) end --This function creates a new entity based on a prefab. local function init_prefab() --First we create an entity. local inst = CreateEntity() --Then we add a transform component se we can place this entity in the world. local trans = inst.entity:AddTransform() --Then we add an animation component which allows us to animate our entity. local anim = inst.entity:AddAnimState() inst.entity:AddDynamicShadow() inst.entity:AddNetwork() --The bank name is the name of the Spriter file. anim:SetBank("bloatfly") --The build name is the name of the animation folder in spriter. anim:SetBuild("bloatfly") --We need to add a 'locomotor' component otherwise our creature can't walk around the world. inst:AddComponent("locomotor") --Here we can tune how fast our creature runs forward. inst.components.locomotor.runspeed = 7 --We need to add a 'physics' component for our character to walk through the world. Lucky for us, this --this is made easy for us by the 'MakeCharacterPhysics' function. This function sets up physics, --collision tags, collision masks, friction etc. All we need to give it is a mass and a radius which --in this case we've set to 10 and 0.5. inst.Transform:SetScale(1, 1, 1) MakeCharacterPhysics(inst, 10, .25) inst.Transform:SetFourFaced() inst:AddTag("flying") inst:AddTag("insect") inst:AddTag("smallcreature") inst:AddTag("cattoyairborn") inst:AddTag("companion") inst.flapping = true inst.EnableFlap = EnableFlap --Here we attach our stategraph to our prefab. inst:SetStateGraph("SGbloatfly") inst.entity:AddSoundEmitter() inst.SoundEmitter:PlaySound("dontstarve/creatures/mosquito/mosquito_fly_LP", "flap") inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end --We need a reference to the brain we want to attach to our creature. local brain = require "brains/bloatflybrain" --And then we attach the brain to our creature. inst:SetBrain(brain) inst.userfunctions = { FollowLeader = FollowLeader, } inst:AddComponent("follower") inst:AddComponent("lootdropper") inst:AddComponent("health") inst.components.health:SetMaxHealth(50) MakeSmallBurnableCharacter(inst, "head", Vector3(0, -1, 1)) inst.components.health.fire_damage_scale = 1 inst:AddComponent("inspectable") inst:ListenForEvent("attacked", OnAttacked) inst:AddComponent("combat") inst:AddComponent("sleeper") inst.components.sleeper:SetResistance(1) inst.components.combat:SetDefaultDamage(10) inst.components.combat:SetRange(1, 1) inst.components.lootdropper:SetLoot(loot) inst.components.combat.onhitotherfn = OnHitOther MakeSmallFreezableCharacter(inst) inst.components.freezable:SetResistance(1) inst.components.freezable.damagetobreak = 1 inst.components.freezable.diminishingreturns = true inst:DoPeriodicTask(1, FindEntityFun, nil) --return our new entity so that it can be added to the world. return inst end --Here we register our new prefab so that it can be used in game. return Prefab( "bloatfly", init_prefab, assets, nil) Link to comment Share on other sites More sharing options...
Eusong Posted November 4, 2017 Author Share Posted November 4, 2017 Any help? I really need information to fix this. Link to comment Share on other sites More sharing options...
Lumina Posted November 4, 2017 Share Posted November 4, 2017 (edited) You probably need, i guess, a body or something. Example in beefalo.lua : inst:AddComponent("combat") inst.components.combat.hiteffectsymbol = "beefalo_body" MakeLargeBurnableCharacter(inst, "beefalo_body") MakeLargeFreezableCharacter(inst, "beefalo_body") Spider : MakeMediumBurnableCharacter(inst, "body") MakeMediumFreezableCharacter(inst, "body") inst.components.burnable.flammability = TUNING.SPIDER_FLAMMABILITY --------------------- inst:AddComponent("health") inst:AddComponent("combat") inst.components.combat.hiteffectsymbol = "body" inst.components.combat:SetKeepTargetFunction(keeptargetfn) inst.components.combat:SetOnHit(SummonFriends) So the game know where to put the graphical effect and the size of it. Edited November 4, 2017 by Lumina Link to comment Share on other sites More sharing options...
Eusong Posted November 4, 2017 Author Share Posted November 4, 2017 I already have that in my code, using the head instead of the body. I tried using the body and it didn't work either. Link to comment Share on other sites More sharing options...
spideswine Posted November 4, 2017 Share Posted November 4, 2017 Can you upload the spriter file of this creature? Link to comment Share on other sites More sharing options...
Eusong Posted November 5, 2017 Author Share Posted November 5, 2017 Here you go bloatfly.zip Link to comment Share on other sites More sharing options...
spideswine Posted November 5, 2017 Share Posted November 5, 2017 (edited) Alright so if you open the beefalo build.xml(extract with ktools then recomplie) you can see: <Symbol name="beefalo_body"> For your build.xml all you see however is: <Symbol name="bloatfly"> I'm guessing(Yeah I'm not sure, but probably), that this works by the folder you placed the png files in. So if want to body of the fly to set on fire, move the png file into a folder named "body", then make sure you see <Symbol name="body"> in the build.xml(Pay attention to capital letters, they may or may not be important) This should work maybe, I'm not sure. Edited November 5, 2017 by spideswine Link to comment Share on other sites More sharing options...
Eusong Posted November 5, 2017 Author Share Posted November 5, 2017 I've got it to work now, thank you! I didn't realize that was the problem. 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