Jump to content

[HELP!] The super boomerang !


XXQ

Recommended Posts

Hi everyone , my favorite item in the game is "boomerang"...

Because its effective on distance and not need to reload :) (realy  people i love boomerangs much im playing with them since i was a kid-i mean in real life)....

 

Here is the point:

 

 im realy get tired of try to catch it back because the boomerang is soo weak an i cant stand  anymore of  sound of " pushing the space button"....

                           

I wish: 

          1-) can anybody make someting (mod-tool etc.) to configure power,max distance, auto-catching etc. ?

          2-) please show my the way -how can i do all those  things with original game files ? 

 

thanks everyone who will reads this and gives me help in the future...

 

p.s: sorry about my bad english im tryn' to learn :))

 

  :wilson_cool:

 

Link to comment
Share on other sites

Have a look at the boomerang in my Link mod. It has an auto-catch feature - the max distance and power and everything are pretty obvious, if I recall.

im already playing with your "link the hero" :) he is my favorite but i wanna play maxwell and i can't do without boomerang :(

 

Since morning im tryng to solve your "linkereang" codes and make same respond (catchback) mechanism to main boomerang (the orginal) but there is no succsess...

 

Can you give me the edited version of "boomerang.lua"  i can change power-distance but catch-back mechanism; thats the point im fail...

 

_____

im fan of "Legend of Zelda" and your custom "Link" he is the best ...

*please add bow in a short time ,i cant wait fot it :D

thanks much...

Link to comment
Share on other sites

I'm not really a coder - art and animation is my domain - but I believe this is the section that handles the auto-catch:

    local oldhit = inst.components.projectile.Hit    function inst.components.projectile:Hit(target)        if target == self.owner and target.components.catcher then            target:PushEvent("catch", {projectile = self.inst})            self.inst:PushEvent("caught", {catcher = target})            self:Catch(target)            target.components.catcher:StopWatching(self.inst)        else            oldhit(self, target)        end    end
Link to comment
Share on other sites

I'm not really a coder - art and animation is my domain - but I believe this is the section that handles the auto-catch:

    local oldhit = inst.components.projectile.Hit    function inst.components.projectile:Hit(target)        if target == self.owner and target.components.catcher then            target:PushEvent("catch", {projectile = self.inst})            self.inst:PushEvent("caught", {catcher = target})            self:Catch(target)            target.components.catcher:StopWatching(self.inst)        else            oldhit(self, target)        end    end

It is. :razz:

Link to comment
Share on other sites

 

I'm not really a coder - art and animation is my domain - but I believe this is the section that handles the auto-catch:

    local oldhit = inst.components.projectile.Hit    function inst.components.projectile:Hit(target)        if target == self.owner and target.components.catcher then            target:PushEvent("catch", {projectile = self.inst})            self.inst:PushEvent("caught", {catcher = target})            self:Catch(target)            target.components.catcher:StopWatching(self.inst)        else            oldhit(self, target)        end    end

thanks for your attention :)

 

but could you do this as "super boomerang mod" ?

 

because when i change somethng about gamefiles game crashs...

 

i think ist about the game mechanism if somethng changes game stops itself...doesnt work etc...

 

please i trust you you are experienced about making mods , could you do that for me ,make a little mod  ? 

Link to comment
Share on other sites

Sorry that i cant test this (i dont have any games with boomerangs) but I -think- this will work to do what you need

 

https://dl.dropboxusercontent.com/u/13440285/coding%20zips/autocatch.zip

 

The modmain.lua just contains the following:

 

function setAutoCatch(inst)	local oldhit = inst.components.projectile.Hit	function inst.components.projectile:Hit(target)		if target == self.owner and target.components.catcher then			target:PushEvent("catch", {projectile = self.inst}) 			self.inst:PushEvent("caught", {catcher = target})			self:Catch(target)			target.components.catcher:StopWatching(self.inst)		else			oldhit(self, target)		end	endendAddPrefabPostInit("boomerang", setAutoCatch)
Link to comment
Share on other sites

 

Sorry that i cant test this (i dont have any games with boomerangs) but I -think- this will work to do what you need

 

https://dl.dropboxusercontent.com/u/13440285/coding%20zips/autocatch.zip

 

The modmain.lua just contains the following:

 

function setAutoCatch(inst)	local oldhit = inst.components.projectile.Hit	function inst.components.projectile:Hit(target)		if target == self.owner and target.components.catcher then			target:PushEvent("catch", {projectile = self.inst}) 			self.inst:PushEvent("caught", {catcher = target})			self:Catch(target)			target.components.catcher:StopWatching(self.inst)		else			oldhit(self, target)		end	endendAddPrefabPostInit("boomerang", setAutoCatch)

 

thank you buddy :D 

and Dana Addams thanks for codes...

 

god bless you...

Link to comment
Share on other sites

Excuse me

Anyone here?

I still have a problem

 

 

Can this happen?

 

when the boomerang on thrown, immediately equip my other boomerang in my inventory.

i try to write a code in the scripts/prefabs/boomerang.lua

but it become cannot throw.

 

 

local function OnThrown(inst, owner, target)
owner.components.inventory:Equipitem(inst)
    if target ~= owner then
        owner.SoundEmitter: PlaySound("dontstarve/wilson/boomerang_throw")
    end
    inst.AnimState: PlayAnimation("spin_loop", true)
end
 
 

 

Can anyone teach me ?

THX

Link to comment
Share on other sites

But i try to slow the boomerang speed, i can equip another boomerang manually.

Then i can throw again.

 

If my hand is not empty, the auto-catch code still work.

So the first boomerang wiil be caught, turn into my inventory.

 

Then i can do it again and again.

 

But i dont know how to write the auto-equip code. Orz

 

(wish you can understand my poor grammar)

Link to comment
Share on other sites

Check in  projectile.lua and when a projectile is thrown you will see it posts an 'onthrow' event and the objects previous owner (entity that threw it) is included in the attached data for the event. So in a PrefabPostInit() for the boomerang add in a listener for the onthrow event.

 

at the top of your handler for the onthrow event check to make sure the thrower is either just the player, or the specific character that you want to be able to speed throw multiple rangs. Then you need to see if the owner even has an extra boomerang in their inventory.  You do this with something like

 

local item = owner.components.inventory:FindItem(function(item) return item.prefab == "boomerang" end ) 

 

If 'item' isnt set to nil then it means the thrower had a spare 'rang. Then you just equip it using the line you pasted above

 

owner.components.inventory:Equipitem(item)

Link to comment
Share on other sites

Sorry i still not figure out.

But where should i add this code?

 

local item = owner.components.inventory:FindItem(function(item) return item.prefab == "boomerang" end ) 

 

I try several places, but still cannot run.

 

Should i add it at PrefabPostInit() ?

But i can't find it.

 

 

Thanks

Link to comment
Share on other sites

It work!! Thank you!!

 

 

local function OnThrown(inst, owner, target)

local item = owner.components.inventory:FindItem(function(item) return item.prefab == "boomerang" end ) 

owner.components.inventory:Equip(item)

    if target ~= owner then
        owner.SoundEmitter: PlaySound("dontstarve/wilson/boomerang_throw")
    end
    inst.AnimState: PlayAnimation("spin_loop", true)
end
Link to comment
Share on other sites

If you want to make that OnThrown() a little more generic you can prob change

 

item.prefab == "boomerang" 

 

to

 

item.prefab == inst.prefab

 

that will allow it to be usable on multiple projectile types if you ever decide to add throwing rocks or spears etc. As it is right now you have a bug. I told you in the other post you need to check if 'item' is nil or not. you never do this. You just blindly tell the player to equip item even if item doesnt exist.  You also arent checking if the boomerang was just thrown, or if it hit its target and is now being 'rethrown' back to the owner.  So your code will attempt to equip 2 different boomerangs each time you throw one.

Link to comment
Share on other sites

I want to check, but i don't know how and where.

 

This is my first contact with file .lua

 

So what i can do is just try the simplest way to let my idea come true.

 

Still thanks a lot that you solved my problem and many advices.

 

It's a good idea to throw rocks or spears, maybe i will try them later.

Then i have to face the bug.

 

But now i wonder that can the throwing boomerang have its own brain which can auto-attack my enemy, or attack maybe two target

then return to owner.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...