. . . Posted September 4, 2016 Share Posted September 4, 2016 (edited) Hello, I need help . So, like the title says... Is it possible to make a character always auto catch boomerangs & be able to craft boomerangs without a need of a science machine? If someone could help me with this that would be so great, thank you so much for reading my problem !!! Edited September 5, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
CarlZalph Posted September 4, 2016 Share Posted September 4, 2016 AddPrefabPostInit("boomerang", function(inst) if(inst.components and inst.components.projectile) then local hit_old = inst.components.projectile.Hit or function(...) end inst.components.projectile.Hit = function(inst, target, ...) local owner = inst.owner if(target and owner and owner==target and owner.prefab=="wilson") then inst:Catch(owner) else hit_old(inst, target, ...) end end end end ) AddPrefabPostInit("wilson", function(inst) if(inst.components and inst.components.builder) then inst.components.builder:UnlockRecipe("boomerang") end end ) 1 Link to comment Share on other sites More sharing options...
. . . Posted September 4, 2016 Author Share Posted September 4, 2016 (edited) @CarlZalph Thank you very much! Also, ff I can just ask you two more things ! Would it be possible to make the character play the catch animation like they reach their hand out to the boomerang (like normal characters do when catching the boomerang) with this code or is that not possible? I tried AddPrefabPostInit("boomerang", function(inst) if(inst.components and inst.components.projectile) then local hit_old = inst.components.projectile.Hit or function(...) end inst.components.projectile.Hit = function(inst, target, ...) local owner = inst.owner if(target and owner and owner==target and owner.prefab=="amazon") then inst:Catch(owner) owner.AnimState:PlayAnimation("catch") owner.AnimState:PushAnimation("catch") owner.SoundEmitter:PlaySound("dontstarve/wilson/boomerang_catch") else hit_old(inst, target, ...) end end end end ) but that didn't work ... So if you can say that would be awesome !! Also, would it be possible to make it that if this character throws the boomerang it goes faster? I tried doing something like AddPrefabPostInit("boomerang", function(inst) local owner = inst.owner if(owner and owner.prefab=="amazon") then inst.components.projectile:SetSpeed(20) end end ) but that didn't work either obviously ... Could you maybe also tell me if this would be possible or not? Thank you a lot CarlZalph !!!! Edited September 4, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
CarlZalph Posted September 4, 2016 Share Posted September 4, 2016 AddPrefabPostInit("boomerang", function(inst) if(inst.components and inst.components.projectile) then local hit_old = inst.components.projectile.Hit or function(...) end inst.components.projectile.Hit = function(inst, target, ...) local owner = inst.owner if(target and owner and owner==target and owner.prefab=="wilson") then if(owner.sg) then owner.sg:GoToState("catch") end inst:Catch(owner) else hit_old(inst, target, ...) end end local onthrown_old = inst.components.projectile.onthrown or function(...) end inst.components.projectile.onthrown = function(inst, owner, target, ...) if(owner and owner.prefab=="wilson") then inst.Physics:SetMotorVel(20, 0, 0) end onthrown_old(inst, owner, target, ...) end end end ) What's neat is setting the velocity really high an watching the boomerang miss you as it tries to get back into your hand, and flies all around in circles. Link to comment Share on other sites More sharing options...
. . . Posted September 4, 2016 Author Share Posted September 4, 2016 @CarlZalph Thank you so much !!!!!!! Link to comment Share on other sites More sharing options...
. . . Posted September 5, 2016 Author Share Posted September 5, 2016 (edited) @CarlZalph I'm so, so, so, so sorry for bothering you again but I need your help again ..... What I have problem is when my character throws a boomerang in a world with caves on she does the animation just fine like this but when she throws a boomerang in a world with no caves the animation gets weird & she plays animation like she's putting a item in inventory which cuts off the throw animation! Like this do you know a way this could be fixed? I'm so, so sorry for bothering you so much! Please forgive me...and thank you so, so, so, so, so much for your help & guidance !!!!!!! Edited September 5, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
CarlZalph Posted September 5, 2016 Share Posted September 5, 2016 1 hour ago, SuperDavid said: @CarlZalph I'm so, so, so, so sorry for bothering you again but I need your help again ..... What I have problem is when my character throws a boomerang in a world with caves on she does the animation just fine like this but when she throws a boomerang in a world with no caves the animation gets weird & she plays animation like she's putting a item in inventory which cuts off the throw animation! Like this do you know a way this could be fixed? I'm so, so sorry for bothering you so much! Please forgive me...and thank you so, so, so, so, so much for your help & guidance !!!!!!! A world without caverns enabled is treated slightly differently in that it's a listen server rather than a full blown client-server type of thing. I'm not too familiar with such discrepancies that are introduced when this is present, and unfortunately cannot assist in this manner. It should only affect the client hosting, so it may be minor enough to not worry about it. Though if it will niggle your mind to no end, then I'd have to guess it's either in the stategraph or the buffered actions portion of the code base and you might start to look for a fix for this edge case. Link to comment Share on other sites More sharing options...
. . . Posted September 5, 2016 Author Share Posted September 5, 2016 (edited) 27 minutes ago, CarlZalph said: I'd have to guess it's either in the stategraph Your guess was right ! I made a new state & everything works lovely now, thank you very much for the important hint @CarlZalph !!! Edited September 5, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
DarkXero Posted September 5, 2016 Share Posted September 5, 2016 Carl doesn't have to fix anything. It's on the original code. Because of this: EventHandler("unequip", function(inst) inst.sg:GoToState("idle") end), The boomerang unequips when it's dropped for being thrown. The above line doesn't occur in the wilson_client stategraph. But it does in the wilson stategraph. Something needs to say "ignore the boomerang unequip". State { name = "throw", tags = { "attack", "notalking", "abouttoattack", "autopredict" }, onenter = function(inst) local buffaction = inst:GetBufferedAction() local target = buffaction ~= nil and buffaction.target or nil inst.components.combat:SetTarget(target) inst.components.combat:StartAttack() inst.components.locomotor:Stop() local cooldown = math.max(inst.components.combat.min_attack_period + .5 * FRAMES, 11 * FRAMES) inst.AnimState:PlayAnimation("throw") inst.sg:SetTimeout(cooldown) if target ~= nil and target:IsValid() then inst:FacePoint(target.Transform:GetWorldPosition()) inst.sg.statemem.attacktarget = target end end, timeline = { TimeEvent(7 * FRAMES, function(inst) -- alright, the boomerang was tossed inst.sg.statemem.throwstate = true inst:PerformBufferedAction() inst.sg:RemoveStateTag("abouttoattack") end), }, ontimeout = function(inst) inst.sg:RemoveStateTag("attack") inst.sg:AddStateTag("idle") end, events = { EventHandler("equip", function(inst) inst.sg:GoToState("idle") end), EventHandler("unequip", function(inst) -- if the variable doesn't exist, it means there was no throw, abort and go to idle state; else, just keep going if not inst.sg.statemem.throwstate then inst.sg:GoToState("idle") else inst.sg.statemem.throwstate = nil end end), EventHandler("animover", function(inst) if inst.AnimState:AnimDone() then inst.sg:GoToState("idle") end end), }, onexit = function(inst) inst.components.combat:SetTarget(nil) if inst.sg:HasStateTag("abouttoattack") then inst.components.combat:CancelAttack() end end, } The event handlers could also be removed to mimic wilson_client. So, uh, @V2C? Link to comment Share on other sites More sharing options...
Developer V2C Posted September 5, 2016 Developer Share Posted September 5, 2016 Thanks for the report. We'll take a look at fixing this next week. 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