Jump to content

Script help


Recommended Posts

Hai. I've been trying to write this script for some time now, but I can't wrap my head around it. What I am trying to accomplish is to have a rock, which player has to "mine" to clear the way.

1. Rock blocks the passage in a cave.

2, Player activates the rock (hidden activator in front of it).

3. Mining animation plays.

4. Couple seconds pass while the animation plays.

5. Rock disappears - the path is clear (and the activator disables itself).

I know how to do everything BUT write the script so that it works. For example I can't understand how to guide the script to the rock so it disables it. My current script is a frankestein made from stuff I found in google and it obviously doesn't even want to compile. Pls help.

 

 

Spoiler

Bool Property PlayIdle = True Auto

Idle Property AutoIdle Auto

Idle Property IdleStop_Loose Auto

Key Property AAA_DM_Rock Auto

Function Enable(bool abFadingOut = True) native

Function Wait(float afSeconds) native global

Event OnActivate(ObjectReference akActionRef)
    if akActionRef == Game.GetPlayer()
        Game.ForceThirdPerson()
        Game.GetPlayer().PlayIdle(AutoIdle)
        Utility.Wait(5.0)
        Game.FadeOutGame(false, true, 2.0, 1.0)
        AAA_DM_Rock.Disable
        Game.GetPlayer().PlayIdle(IdleStop_Loose)   
    EndIf
EndEvent
Self.Disable()
Self.Delete()

 

Edited by ungodlytomato
Link to comment

I've made something similar for a never finished mod but with a different approach. It's basically based on the scripts for mining ore but repurposed to fit my needs.

 

First you need to duplicate the original PickaxeMiningWallMarker (it's in the CK under "Furniture", FormID 000E2BC7) to make your own, and replace the original script with the following:

 

Spoiler

Scriptname N78HVDungeonsRockslideMarker extends ObjectReference  

Event OnUnload()
    isRegistered = true
    UnregisterForEvents()
EndEvent

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
    if(asEventName == "AddToInventory")
        myActivator.Activate(Self)
    endIf    
    
    if(asEventName == "IdleFurnitureExit" || asEventName == "IdlePickaxeExit" || asEventName == "IdlePickaxeFloorExit" || asEventName == "IdlePickaxeTableExit")
        UnregisterForEvents()
        GotoState("Waiting")
    endIf
EndEvent

Auto State Waiting
    Event OnActivate(ObjectReference akActionRef)
        GotoState("Busy")
        RegisterForEvents()
    EndEvent
EndState

State Busy
    Event OnActivate(ObjectReference akActionRef)
        ;Do Nothing
    EndEvent
EndState

State Done
    Event OnBeginState()
        isRegistered = true
        UnregisterForEvents()
    EndEvent
EndState

Function RegisterForEvents()
    if(!isRegistered)
        isRegistered = true
        RegisterForAnimationEvent(PlayerRef, "AddToInventory")
        RegisterForAnimationEvent(PlayerRef, "IdlePickaxeExit")
        RegisterForAnimationEvent(PlayerRef, "IdlePickaxeFloorExit")
        RegisterForAnimationEvent(PlayerRef, "IdlePickaxeTableExit")
        RegisterForAnimationEvent(PlayerRef, "IdleFurnitureExit")
    endIf
EndFunction

Function UnregisterForEvents()
    if(isRegistered)
        isRegistered = false
        UnregisterForAnimationEvent(PlayerRef, "AddToInventory")
        UnregisterForAnimationEvent(PlayerRef, "IdlePickaxeExit")
        UnregisterForAnimationEvent(PlayerRef, "IdlePickaxeFloorExit")
        UnregisterForAnimationEvent(PlayerRef, "IdlePickaxeTableExit")
        UnregisterForAnimationEvent(PlayerRef, "IdleFurnitureExit")
    endIf
EndFunction

Function FinishWork()
    GotoState("Done")
EndFunction

Actor Property PlayerRef Auto

ObjectReference Property myActivator Auto Hidden

Bool isRegistered = false

 

 

 

And you will need an activator with the following script:

 

Spoiler

Scriptname N78HVDungeonsRockslideActivator extends ObjectReference  

Auto State Waiting
    Event OnActivate(ObjectReference akActionRef)
        myFurnitureMarker = GetLinkedRef(LinkCustom01) as N78HVDungeonsRockslideMarker
        myFurnitureMarker.myActivator = Self
        myEnableMarker = GetLinkedRef(LinkCustom02)
        myExplosionMarker = GetLinkedRef(LinkCustom03)
        if(akActionRef == PlayerRef)
            if(PlayerRef.GetItemCount(N78HVListToolsPickaxe) > 0)
                myFurnitureMarker.Activate(PlayerRef)
            else
                if(optQuest && optStagePreRemoval != -1 && !optQuest.GetStageDone(optStagePreRemoval))
                    optQuest.SetStage(optStagePreRemoval)
                endIf
                PickaxeFailureMessage.Show()
            endIf
        elseIf(akActionRef == myFurnitureMarker)
            ProcessStrike()
        endIf
    EndEvent
EndState

State Done
    ;Do Nothing
EndState

Function ProcessStrike()
    if(myExplosionFX)
        myExplosionFX.Delete()
    endIf
    StrikesPerformed += 1
    if(StrikesPerformed < StrikesRequired)
        myExplosionFX = myExplosionMarker.PlaceAtMe(FXdustDropMedExplosion)
        AMBDustDropDebris.Play(myExplosionMarker)
    else
        GotoState("Done")
        Self.DisableNoWait()
        myExplosionFX = myExplosionMarker.PlaceAtMe(FallingDustExplosion01)
        TRPRockfallRelease.Play(myExplosionMarker)
        Game.ShakeCamera(PlayerRef, 0.75)
        myFurnitureMarker.Activate(PlayerRef)
        myFurnitureMarker.FinishWork()
        Utility.Wait(1.0)
        myEnableMarker.Disable()
        if(optQuest && optStagePostRemoval != -1 && !optQuest.GetStageDone(optStagePostRemoval))
            optQuest.SetStage(optStagePostRemoval)
        endIf
        Utility.Wait(6.0)
        myExplosionFX.Delete()
    endIf
EndFunction

Actor Property PlayerRef Auto

Keyword Property LinkCustom01 Auto

Keyword Property LinkCustom02 Auto

Keyword Property LinkCustom03 Auto

FormList Property N78HVListToolsPickaxe Auto

Message Property PickaxeFailureMessage Auto

Explosion Property FallingDustExplosion01 Auto

Explosion Property FXdustDropMedExplosion Auto

Sound Property TRPRockfallRelease Auto

Sound Property AMBDustDropDebris Auto

Quest Property optQuest = None Auto

Int Property optStagePreRemoval = -1 Auto

Int Property optStagePostRemoval = -1 Auto

Int Property StrikesRequired = 3 Auto

Int StrikesPerformed = 0

N78HVDungeonsRockslideMarker myFurnitureMarker

ObjectReference myEnableMarker

ObjectReference myExplosionMarker

ObjectReference myExplosionFX

 

Once you placed both the furniture marker and the activator in the render window, you need to make a linked ref from the activator to the marker using the LinkCustom01 keyword.

LinkCustom02 links to an XMarker that serves as an enable parent for the rocks you're using, and LinkCustom03 to an XMarker placed where some dust will drop when the player hits the stone.

 

I know the scripts look a bit overwhelming, but it also plays some FX, sound, can set quest stage etc. If you have question, feel free to ask ?

Link to comment
On 8/6/2021 at 7:11 PM, ungodlytomato said:

Hai. I've been trying to write this script for some time now, but I can't wrap my head around it. What I am trying to accomplish is to have a rock, which player has to "mine" to clear the way.

1. Rock blocks the passage in a cave.

2, Player activates the rock (hidden activator in front of it).

3. Mining animation plays.

4. Couple seconds pass while the animation plays.

5. Rock disappears - the path is clear (and the activator disables itself).

I know how to do everything BUT write the script so that it works. For example I can't understand how to guide the script to the rock so it disables it. My current script is a frankestein made from stuff I found in google and it obviously doesn't even want to compile. Pls help.

 

1) You need to create ACTIVATOR !... only Activators can get activated

2) You need to set name, and Activate Text for that Activator ( or Activator will be still invisible )

 

3) u can use that Script: ( Open Spoiler to copy Code !... )

This script will disable reference when player Activate it ( click "E" while looking at rock )

s1.png.38fde7c0954b158ffc7ef3418e03c29d.png

Spoiler
Event OnActivate( ObjectReference QRef )
	If( QRef == Game.GetPlayer() )	; We check if thats Player
		If( self.IsEnabled() )		; We check if Rock is enabled
			self.Disable( true )
		EndIf
	EndIf		; Add that Script to Your Rock and it will work
EndEvent
; TheEnd

 

 

That is very simple script... so its not playing animation or sound... but at least it will work :)

 

 1) Create new Script ( as Extension give "ObjectReference" )

 2) Open it in Editor

 3) Paste Code You have above

Edited by -̒̈́̕?̖̪̼?̒̈́̕??̒̈́̕?-
Link to comment
On 8/7/2021 at 7:01 PM, nachtdaemmerung77 said:

I've made something similar for a never finished mod but with a different approach. It's basically based on the scripts for mining ore but repurposed to fit my needs.

 

First you need to duplicate the original PickaxeMiningWallMarker (it's in the CK under "Furniture", FormID 000E2BC7) to make your own, and replace the original script with the following:

 

  Hide contents

Scriptname N78HVDungeonsRockslideMarker extends ObjectReference  

Event OnUnload()
    isRegistered = true
    UnregisterForEvents()
EndEvent

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
    if(asEventName == "AddToInventory")
        myActivator.Activate(Self)
    endIf    
    
    if(asEventName == "IdleFurnitureExit" || asEventName == "IdlePickaxeExit" || asEventName == "IdlePickaxeFloorExit" || asEventName == "IdlePickaxeTableExit")
        UnregisterForEvents()
        GotoState("Waiting")
    endIf
EndEvent

Auto State Waiting
    Event OnActivate(ObjectReference akActionRef)
        GotoState("Busy")
        RegisterForEvents()
    EndEvent
EndState

State Busy
    Event OnActivate(ObjectReference akActionRef)
        ;Do Nothing
    EndEvent
EndState

State Done
    Event OnBeginState()
        isRegistered = true
        UnregisterForEvents()
    EndEvent
EndState

Function RegisterForEvents()
    if(!isRegistered)
        isRegistered = true
        RegisterForAnimationEvent(PlayerRef, "AddToInventory")
        RegisterForAnimationEvent(PlayerRef, "IdlePickaxeExit")
        RegisterForAnimationEvent(PlayerRef, "IdlePickaxeFloorExit")
        RegisterForAnimationEvent(PlayerRef, "IdlePickaxeTableExit")
        RegisterForAnimationEvent(PlayerRef, "IdleFurnitureExit")
    endIf
EndFunction

Function UnregisterForEvents()
    if(isRegistered)
        isRegistered = false
        UnregisterForAnimationEvent(PlayerRef, "AddToInventory")
        UnregisterForAnimationEvent(PlayerRef, "IdlePickaxeExit")
        UnregisterForAnimationEvent(PlayerRef, "IdlePickaxeFloorExit")
        UnregisterForAnimationEvent(PlayerRef, "IdlePickaxeTableExit")
        UnregisterForAnimationEvent(PlayerRef, "IdleFurnitureExit")
    endIf
EndFunction

Function FinishWork()
    GotoState("Done")
EndFunction

Actor Property PlayerRef Auto

ObjectReference Property myActivator Auto Hidden

Bool isRegistered = false

 

 

 

And you will need an activator with the following script:

 

  Hide contents

Scriptname N78HVDungeonsRockslideActivator extends ObjectReference  

Auto State Waiting
    Event OnActivate(ObjectReference akActionRef)
        myFurnitureMarker = GetLinkedRef(LinkCustom01) as N78HVDungeonsRockslideMarker
        myFurnitureMarker.myActivator = Self
        myEnableMarker = GetLinkedRef(LinkCustom02)
        myExplosionMarker = GetLinkedRef(LinkCustom03)
        if(akActionRef == PlayerRef)
            if(PlayerRef.GetItemCount(N78HVListToolsPickaxe) > 0)
                myFurnitureMarker.Activate(PlayerRef)
            else
                if(optQuest && optStagePreRemoval != -1 && !optQuest.GetStageDone(optStagePreRemoval))
                    optQuest.SetStage(optStagePreRemoval)
                endIf
                PickaxeFailureMessage.Show()
            endIf
        elseIf(akActionRef == myFurnitureMarker)
            ProcessStrike()
        endIf
    EndEvent
EndState

State Done
    ;Do Nothing
EndState

Function ProcessStrike()
    if(myExplosionFX)
        myExplosionFX.Delete()
    endIf
    StrikesPerformed += 1
    if(StrikesPerformed < StrikesRequired)
        myExplosionFX = myExplosionMarker.PlaceAtMe(FXdustDropMedExplosion)
        AMBDustDropDebris.Play(myExplosionMarker)
    else
        GotoState("Done")
        Self.DisableNoWait()
        myExplosionFX = myExplosionMarker.PlaceAtMe(FallingDustExplosion01)
        TRPRockfallRelease.Play(myExplosionMarker)
        Game.ShakeCamera(PlayerRef, 0.75)
        myFurnitureMarker.Activate(PlayerRef)
        myFurnitureMarker.FinishWork()
        Utility.Wait(1.0)
        myEnableMarker.Disable()
        if(optQuest && optStagePostRemoval != -1 && !optQuest.GetStageDone(optStagePostRemoval))
            optQuest.SetStage(optStagePostRemoval)
        endIf
        Utility.Wait(6.0)
        myExplosionFX.Delete()
    endIf
EndFunction

Actor Property PlayerRef Auto

Keyword Property LinkCustom01 Auto

Keyword Property LinkCustom02 Auto

Keyword Property LinkCustom03 Auto

FormList Property N78HVListToolsPickaxe Auto

Message Property PickaxeFailureMessage Auto

Explosion Property FallingDustExplosion01 Auto

Explosion Property FXdustDropMedExplosion Auto

Sound Property TRPRockfallRelease Auto

Sound Property AMBDustDropDebris Auto

Quest Property optQuest = None Auto

Int Property optStagePreRemoval = -1 Auto

Int Property optStagePostRemoval = -1 Auto

Int Property StrikesRequired = 3 Auto

Int StrikesPerformed = 0

N78HVDungeonsRockslideMarker myFurnitureMarker

ObjectReference myEnableMarker

ObjectReference myExplosionMarker

ObjectReference myExplosionFX

 

Once you placed both the furniture marker and the activator in the render window, you need to make a linked ref from the activator to the marker using the LinkCustom01 keyword.

LinkCustom02 links to an XMarker that serves as an enable parent for the rocks you're using, and LinkCustom03 to an XMarker placed where some dust will drop when the player hits the stone.

 

I know the scripts look a bit overwhelming, but it also plays some FX, sound, can set quest stage etc. If you have question, feel free to ask ?

 

Thank you, thank you! I like lost any hope of doing this on my oww and decided not to bother. Also forgot that I asked for help here.

So I tried but nothing happens when I activate the rock. I must be doing something wrong in CK :c

Basically I did this and nothing else:

1. I placed the custom activator that has a mesh of a rock and the duplicate of wall mining marker one next to another.

2. I added the script number one to the wall mining marker, deleted the default one.

3. I added link refs to the rock-activator with keywords: one for the mining marker, one for the LinkCustom02 Xmarker and the last one for LinkCustom03 Xmarker.

4. I added the rock-activator to the "Enable parent" section of Xmarker LC02 (prolly did this wrong?).

5. Finally added the script to the rock-activator.

The rock is there and the press E prompt appears but nothing happens when I press it :c

Edited by ungodlytomato
Link to comment

Hmm, have you remembered to auto-fill the properties for both scripts once you've added them to the activator and furniture marker?

 

The property N78HVListToolsPickaxe also needs to be filled with a form list that contains at least the default pick axe from the vanilla game. I did this because I wanted the player to require the tools to remove a rockslide.

Alternatively, if you don't want to check if the player has a pick axe just replace the line

 

 if(PlayerRef.GetItemCount(N78HVListToolsPickaxe) > 0)

 

with

 

 if(true || PlayerRef.GetItemCount(N78HVListToolsPickaxe) > 0)

 

and the check is always successfully passed ?

 

8 hours ago, ungodlytomato said:

4. I added the rock-activator to the "Enable parent" section of Xmarker LC02 (prolly did this wrong?).

 

This isn't really needed, the rock-activator disables itself via the script.

 

Hope that helps, let me know if this fixes the problem ?

Link to comment
3 hours ago, nachtdaemmerung77 said:

Hmm, have you remembered to auto-fill the properties for both scripts once you've added them to the activator and furniture marker?

 

The property N78HVListToolsPickaxe also needs to be filled with a form list that contains at least the default pick axe from the vanilla game. I did this because I wanted the player to require the tools to remove a rockslide.

Alternatively, if you don't want to check if the player has a pick axe just replace the line

 

 if(PlayerRef.GetItemCount(N78HVListToolsPickaxe) > 0)

 

with

 

 if(true || PlayerRef.GetItemCount(N78HVListToolsPickaxe) > 0)

 

and the check is always successfully passed ?

 

 

This isn't really needed, the rock-activator disables itself via the script.

 

Hope that helps, let me know if this fixes the problem ?

 

IT WORKS NOW! HAHA. And it looks so cool with the dust effect and screenshake when the rock goes pop. I need this in my mod so would it be ok if I linked your LL profile in the credit section when I release it on nexus? Also does this script have requirements like SKSE or something because I have no idea how to check this but I know some scripts do apparently.

Link to comment
33 minutes ago, ungodlytomato said:

IT WORKS NOW! HAHA. And it looks so cool with the dust effect and screenshake when the rock goes pop. I need this in my mod so would it be ok if I linked your LL profile in the credit section when I release it on nexus? Also does this script have requirements like SKSE or something because I have no idea how to check this but I know some scripts do apparently.

 

Glad to hear it works! ? The doesn't have any requirements like SKSE, it works all with vanilla stuff. And sure, you can use it in your mod, just credit me and I'm happy ?

Link to comment
  • 1 month later...

How can I make a random animation at startup? because  according to this template,

;===============================

            actor[] sexActors = new actor[2]
            sexActors[0] = off
            sexActors[1] = def

            sslBaseAnimation[] anims

            SexLab.StartSex(sexActors, anims)

;===============================

I always get the same animation for all pairs of actors (FF). although there are enough animations)

 

It is interesting that on LE this template works with a random start, but in SE 1.63 - the animation is always the same.

I don’t understand what’s wrong.

Edited by TDA
Link to comment

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
  • Recently Browsing   0 members

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