Page 1 of 1

How to change the behavior of deactivate when 'G' or save?

Posted: Thu Feb 15, 2018 8:46 pm
by ghostbuster
On going to the levelup screen or saving, sustained talents are deactivated. Most of the time, it is OK, but if deactivating does an action, it may be a problem. For instance, in one of my talents, deactivating does a phase door. So anytime I go to levelup, the char has moved...
Slightly annoying, but could be potentially abused seriously.
I know this is an old issue, for instance for the celestial/chant tree.

I wonder if there is solution...

If not, I noticed that deactivate has a third optional parameter for particles (I think). Could we have another one or an ingame variable that could be tested to indicate that it is a fake deactivate and to change the behavior of deactivate accordingly?

Re: How to change the behavior of deactivate when 'G' or sav

Posted: Thu Feb 15, 2018 10:53 pm
by HousePet
Stick no_sustain_autoreset = true, in the talent definition.

Re: How to change the behavior of deactivate when 'G' or sav

Posted: Thu Feb 15, 2018 11:21 pm
by ghostbuster
Thanks.
It works perfectly.

Re: How to change the behavior of deactivate when 'G' or sav

Posted: Sat Feb 17, 2018 3:39 pm
by ghostbuster
Actually, it works perfectly for the levelup screen.
But not for saves... The talent is desactivated (and for that talent, the player is randomly teleported on save most of the times).
Somehow painful.
And abusable

After some search in the source, I tried to add before the teleport stuff in deactivate

if game.saving then return true end

but it does not work.

Isn't it a way to detect if the game is currently performing a save, in order to adapt the behavior of deactivate?

Re: How to change the behavior of deactivate when 'G' or sav

Posted: Sat Feb 17, 2018 10:42 pm
by HousePet
Well that is annoying.
I don't know how to solve that.

Re: How to change the behavior of deactivate when 'G' or sav

Posted: Sun Feb 18, 2018 11:05 am
by Lokean
ghostbuster wrote:But not for saves...

After some search in the source, I tried to add before the teleport stuff in deactivate

if game.saving then return true end
The check you're looking for is

Code: Select all

if self:attr("save_cleanup") then return true end

Re: How to change the behavior of deactivate when 'G' or sav

Posted: Sun Feb 18, 2018 12:41 pm
by ghostbuster
Thanks, it works perfectly.

Re: How to change the behavior of deactivate when 'G' or sav

Posted: Sun Feb 18, 2018 12:56 pm
by Lokean
No problem; I've been doing a lot of obscure source diving, so at least I get to help someone else out too!

Re: How to change the behavior of deactivate when 'G' or sav

Posted: Sun Feb 18, 2018 5:16 pm
by Lokean
Oh, one thing to note about this; you might find you get bugs from extra lives if there's any other cleanup that gets skipped as a result of the escape condition.

When an actor dies, all of its sustains are legitimately deactivated, with the save_cleanup flag in place. If there's anything stored outside the talents structure that it ought to be changing on 'real deactivate' you will need to account for this, without teleporting away. As such, you probably want the phase door to be the very last thing called in the deactivate function, immediately preceded by the escape condition for save_cleanup.