Jump to content

Recommended Posts

I'm not familiar with making something auto do something that's intended to do with said input by oneself, I took a mod from the workshop that "auto catches" the said boomerang, but it fails to ever work. How would I go about starting to make it so the boomerang when in my characters proximity will be auto caught?

Link to comment
https://forums.kleientertainment.com/forums/topic/71508-mod-boomerang-auto-catch/
Share on other sites

I have this auto catch mod and it does work:
http://steamcommunity.com/sharedfiles/filedetails/?id=371920345

I took a quick look at the code some months ago and I think it was very comlicated, especially for a beginner.
I think I, not expert, not beginner, would take hours to make such a mod.

AddPrefabPostInit("boomerang", -- Put your catchable prefab here or just keep it boomerang if u want boomerang auto-catch
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=="YOUR CHARACTER NAME HERE")
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=="YOUR CHARACTER NAME HERE") then
end
onthrown_old(inst, owner, target, ...)
end
end
end
)

You'd put this code in your modmain.lua, credit to CarlZalph.

It wouldn't need the second portion, seeming as there aren't any edits for when it is thrown.

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
        end
    end
)

 

2 hours ago, CarlZalph said:

It wouldn't need the second portion, seeming as there aren't any edits for when it is thrown.


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
        end
    end
)

 

Works like a charm, thank you both! But.. is there a way to remove the small "stun" when you catch it? Also if there's a way to increase the range too.  IF not that's perfectly fine, would just make this far more enjoyable if i could get that down.

Edited by Lokoluna
1 hour ago, Lokoluna said:

Works like a charm, thank you both! But.. is there a way to remove the small "stun" when you catch it? Also if there's a way to increase the range too.  IF not that's perfectly fine, would just make this far more enjoyable if i could get that down.

By removing the portion about going to the state "catch" it should also stop the animation/stun you're feeling.

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