Jump to content

[Sovled] how to make character gain sanity upon successfully catching a fish


Recommended Posts

 

I tried this but it seems the reason "success" doesn't ever even get triggered even upon catching a fish with the oceanfishingrod

local function CatchFish(inst, data)
	if data.reason == "success" then
		data.fisher.components.sanity:DoDelta(10)
	end
end

inst:ListenForEvent("oceanfishing_stoppedfishing", CatchFish)

anyone know what im doing wrong?

Edited by --- -.-
Link to comment
Share on other sites

It seems like "oceanfishing_stoppedfishing" is used for cases where the fisher fails to catch a fish.

I'd recommend taking a look at components/oceanfishingrod.lua at the CatchFish method.

Seems like it calls a function to indicate success when a fish is caught, so you might want to try overriding that function on your fishing rod.

Here's a rough example.

local oldfn = inst.components.oceanfishingrod.ondonefishing

inst.components.oceanfishingrod.ondonefishing = function(inst, msg, lost_tackle, fisher, fish, ...)
  print("Caught a fish!")
  if oldfn then
    return oldfn(inst, msg, lost_tackle, fisher, fish, ...)
  end
end

 

Edited by penguin0616
Added example.
  • Thanks 1
Link to comment
Share on other sites

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
 Share

×
  • Create New...