Jump to content

[LE] Simple question related to "delete.self" in a script.


Recommended Posts

Do activators (mostly invisible activators) that their scripts have a "delete.self" keep having traces in the "save file" or after "deleting" (delete.self) all traces of the script and their Refs are also deleted from the save file ?.


And if NO, then what's the use of it inside a script ?.


I'm researching this and i can't find anything releated to this online.

Edited by maxarturo
Link to comment
Share on other sites

You asked: "Do activators .. keep having traces in the save file or after 'delete()' are all traces of the script also deleted".
It depends on level of persistence for this activator! Activators are objectReference with own subType.

IF self.IsEnabled()
    self.Disable()       ; 1
ENDIF
    self.Delete()        ; 2

probably you know already: https://www.creationkit.com/index.php?title=Delete_-_ObjectReference

 

Only references created in game can actually be deleted.
Remember that Delete() only flags an object for deletion. What does it mean?

The method "delete()" is pushing the refID into a garbage pool, but it can be deleted (script as well) only, if no other script or script property is pointing to this refID. Its clear now?

 

vanilla sample scripts:

PlayerHorseScript

  Reveal hidden contents

 

 

defaultDeleteSelfOnReset

  Reveal hidden contents

 

Edited by ReDragon2013
Link to comment
Share on other sites

Thanks ReDragon for your explanation !

 

It's kind of clear.

So if i "delete.self" only the "trigger box - Activator" the static object that the script - Activator is controlling won't get delete, i'll will have to put also a "delete.self" after "disable.self" to the static object too.
Also, if is not too much trouble or i'm asking too much, could you take a look at this Script, i cant seem to make it work - compile or if it is compiling it won't work.
The script below is just one of many attempts.... It's giving me a headache...
  Reveal hidden contents

This is a short version of the same script working just fine, but i have to make three of them, one for each Value and shrine Health - Magicka - Stamina
  Reveal hidden contents

 

 

Thank you very much in advance !!

Edited by maxarturo
Link to comment
Share on other sites

Well, for starters, you shouldn't need three versions of the script: The same script with a string property that gets filled with the AV you want to change will work in all three cases. Is this intended to be a once-ever use? The coding suggests it.

Link to comment
Share on other sites

  On 4/4/2019 at 12:47 AM, foamyesque said:

Well, for starters, you shouldn't need three versions of the script: The same script with a string property that gets filled with the AV you want to change will work in all three cases. Is this intended to be a once-ever use? The coding suggests it.

No is not intended to be used only once, but the player can activate each shrine and gain Health or Stamina or Magicka whenever he wants, if he has 10 Black Souls.
And that's what i'm trying to do, merge the three scripts into one, the merge script has property with the AV to change for each shrine.
bool property isHealth auto

bool property isMagicka auto

bool property isStamina auto

The single script works fine everytime i activate it.
Link to comment
Share on other sites

The reason I asked about single use is that you have an if-statement checking a flag that's meant to track if the activation has happened, but you never set it. Wasn't sure what the intent was.

 

Some small tweaks:

 

 

Scriptname aXMDshrinePowerUpSCRIPT01 extends ObjectReference  
{Activate custom Shrine & change an ActorValue if the activator has a number of Filled Black Soul Gems }
 
String Property sWorkingAV Auto
{Sets what ActorValue to work on}

SoulGem Property FilledBlackSouls Auto
{Required item - Black Soul}

int Property iSacrificeCount = 10 Auto
{Number of items required. Default 10}

float Property fActorValueBoost = 10.0 Auto
{How much to change the ActorValue by. Default 10}

Message PROPERTY NoBlackSoulsMessage01 auto
{Message to show if you don't have BlackSouls}
 
EffectShader Property PowerUpVisualFX  Auto  
{Visual FX to Play when Powered up on SELF}
 
Sound Property PowerUpSoundFX  Auto  
{Sound FX to play when Powered up}
 
;bool Property isTriggered = false auto hidden
;not needed if multiple uses intended
 
Auto State Waiting
 
Event OnActivate(ObjectReference akActionRef)


    GotoState("Activated")
    ;protects against the player spamming the activate button for free upgrades

    Actor ActorRef = akActionRef as Actor
    if !ActorRef
        GotoState("Waiting")
        return
    endif
    ;makes sure the activator is an actor
    if ActorRef != Game.GetPlayer()
        GotoState("Waiting")
        return
    endif
    ;makes sure the activator is the player. This supercedes the prior check, but this way you can easily choose whether to make this work for NPCs or not.

    if ActorRef.GetItemCount(FilledBlackSouls) < iSacrificeCount
                  NoBlackSoulsMessage01.Show()
    else
    ;If (isTriggered != TRUE && akactionref.getitemcount(FilledBlackSouls) >= 10)

        ActorRef.SetActorValue(sWorkingAV, ActorRef.GetBaseActorValue(sWorkingAV) + fActorValueBoost)
        ActorRef.RemoveItem(FilledBlackSouls, iSacrificeCount)
        Game.ForceThirdPerson()
        PowerUpSoundFX.Play(ActorRef)
        PowerUpVisualFX.Play(ActorRef, 3)
    endif

    GotoState("Waiting")
    ;resets the state back to await the next activation
EndEvent

EndState

 

 

Haven't plugged this into the compiler, so, you know, typos etc may cause errors, but it should work so that all you need to do to make it work for any ActorValue and amount is to set the properties appropriately. WIth a bit of further work you could make it work for any item at all as the sacrifice (or multiple different items in any counts you choose), but that's not what you're after here.

 

The state change is done so that any other OnActivate events that arrive whilst the first one is processing, say because the player is hammering the interact button, will be thrown out. This is a precaution against a race condition where several OnActivate blocks will run the GetItemCount() call before any of them run the RemoveItem() call, allowing the player to potentially get multiple boosts per set of soulgems.

Link to comment
Share on other sites

Thanks a lot foamyesque !.


Your script version is very similar to my first attempt that actually worked.

But the main issue i have is that i want each shrine to display its own "NoBlackSouls" message, and this is where the script gets F****.

I have a working merge script which shows only one common message for the three shrines.


I'm done with this for today...


Thank you very much for spending your time thinking about this one !,

Link to comment
Share on other sites

HOLY S**** !!!

I just realize what a potato i did with the "message".

The first script i made was working fine... i was the stupid !!!!.....

Edited by maxarturo
Link to comment
Share on other sites

I write some stuff but its not very important xD

Your effect can be easly deleted by other mods :x

 

so better way is using Magic Effects or something like this maybe Perks instead of SetValue

 

 

Full Post: xD

 

  Reveal hidden contents

 

Edited by TobiaszPL
Link to comment
Share on other sites

Hey Toby.

I don't really mind if an other mod will delete or overwrite it, this is just a small bonus attached to a possible "player's house" in a secret room (if he decides to use it as a player's house).


The mod's secret room offers the player the chance to gain 10 point of Health or Stamina or Magicka, or gain a Perk for the Perk tree or advance any Skill he wishes to (level up), always for a price.

I'm even thinking to add a sacrifice ritual for those players playing dark characters.


So i don't really mind for other mods overwriting it, it doesn't have a PRIMARY importance, especially since the house has Sooooo much more to offer to the player.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...