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

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
ghostbuster
Uruivellas
Posts: 617
Joined: Mon Oct 09, 2006 7:47 pm

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

#1 Post 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?

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

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

#2 Post by HousePet »

Stick no_sustain_autoreset = true, in the talent definition.
My feedback meter decays into coding. Give me feedback and I make mods.

ghostbuster
Uruivellas
Posts: 617
Joined: Mon Oct 09, 2006 7:47 pm

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

#3 Post by ghostbuster »

Thanks.
It works perfectly.

ghostbuster
Uruivellas
Posts: 617
Joined: Mon Oct 09, 2006 7:47 pm

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

#4 Post 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?

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

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

#5 Post by HousePet »

Well that is annoying.
I don't know how to solve that.
My feedback meter decays into coding. Give me feedback and I make mods.

Lokean
Halfling
Posts: 88
Joined: Sun Dec 10, 2017 12:27 am

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

#6 Post 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

ghostbuster
Uruivellas
Posts: 617
Joined: Mon Oct 09, 2006 7:47 pm

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

#7 Post by ghostbuster »

Thanks, it works perfectly.

Lokean
Halfling
Posts: 88
Joined: Sun Dec 10, 2017 12:27 am

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

#8 Post 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!

Lokean
Halfling
Posts: 88
Joined: Sun Dec 10, 2017 12:27 am

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

#9 Post 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.

Post Reply