Restoring resources with callBackOnRest

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
Razakai
Uruivellas
Posts: 889
Joined: Tue May 14, 2013 3:45 pm

Restoring resources with callBackOnRest

#1 Post by Razakai »

I have a throwing knife talent that uses stacks on a temporary effect to simulate ammo. To make it simple, I wanted it to restore knives while resting, via the following callback:

Code: Select all

	callbackOnRest = function(self, t)
		local reload = self:callTalent(self.T_THROWING_KNIVES, "getReload")
		local max = self:callTalent(self.T_THROWING_KNIVES, "getNb")
		self:setEffect(self.EFF_THROWING_KNIVES, 1, {stacks=reload, max_stacks=max })
	end,
However, what instead happens is that when you hit the rest key, even if there are mobs nearby and you only rest for 0 turns it still restores your stacks to maximum. What am I doing wrong?

Effigy
Uruivellas
Posts: 970
Joined: Fri Oct 10, 2014 4:00 pm

Re: Restoring resources with callBackOnRest

#2 Post by Effigy »

Have you verified that it's not a problem with those getReload and getNb methods? Also, I would recommend changing getNb to a more descriptive name.

Razakai
Uruivellas
Posts: 889
Joined: Tue May 14, 2013 3:45 pm

Re: Restoring resources with callBackOnRest

#3 Post by Razakai »

Yeah, the same bit of code is used elsewhere so it's fine. What I did notice is that it seems to trigger twice on a 0 turn rest - e.g. when it's supposed to reload 2 daggers per turn, just hitting rest once returns 4.

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Restoring resources with callBackOnRest

#4 Post by HousePet »

Does it have a state variable notifying if it is triggering on rest initiated or on rest ended/interupted?
My feedback meter decays into coding. Give me feedback and I make mods.

Razakai
Uruivellas
Posts: 889
Joined: Tue May 14, 2013 3:45 pm

Re: Restoring resources with callBackOnRest

#5 Post by Razakai »

Nope! Looking at it now I think that's the issue, that it's prob just calling the reload without checking whether the rest is in progress etc. Shame there isn't many examples of on rest callbacks in the code.

Post Reply