Jump to content

[LE] I Need Help with a script!


Recommended Posts

It is not locating the SKSE functions. Make sure that you have installed SKSE (manually) and have put the SKSE source scripts into the correct folder.

 

I'm not certain but I think that the SKSE installer found on their site and/or at the Steam Workshop only install what is necessary to play the game and not what is needed to mod. Thus my suggestion to use the manual method.

Link to comment
Share on other sites

It is not locating the SKSE functions. Make sure that you have installed SKSE (manually) and have put the SKSE source scripts into the correct folder.

 

I'm not certain but I think that the SKSE installer found on their site and/or at the Steam Workshop only install what is necessary to play the game and not what is needed to mod. Thus my suggestion to use the manual method.

By "Correct Folder" What do you mean, Actually, can you like talk to me over Discord, this is a long and drawn out process, My Discord is ImNotPsychotic#9087

Link to comment
Share on other sites

I don't do Discord, sorry.

 

Here is a good video by GamerPoets which walks through how to install SKSE manually and partially with Mod Organizer (if using it).

 

just unzip the scripts that is in the archive to your scripts folder

Everything is installed correctly, script is all correct, BUT THIS BLASTED ERROR! Perhaps there is a different script that could work?

Link to comment
Share on other sites

All I can say is that I took this version of the script:

 

 

Scriptname UnlockObjectsSpellScript Extends ActiveMagicEffect
{Script for a 'touch' spell to unlock objects}

Event OnEffectStart(Actor akTarget, Actor akCaster)
	ObjectReference Ref = Game.GetCurrentCrosshairRef()
	If Ref != None ;make sure object is valid
		If (((Ref.GetBaseObject().GetType() == 29) && (Ref.GetOpenState() == 3)) || (Ref.GetBaseObject().GetType() == 28)) ;if a door and closed or a container
			If Ref.IsLocked() ;if object is locked
				Int LL = Ref.GetLockLevel()
				If LL == 255 ;requires key
					Debug.Notification("Lock is too complex, a key is required to enter")
				ElseIf Ref.GetLockLevel() > 50 ;anything higher than adept level
					Debug.Notification("Lock is too complex")
				Else
					Ref.Lock(false)
					;unlock the door
				EndIf
			EndIf
		EndIF
	EndIf
EndEvent  

 

Compiled it in my Sublime Text setup with Mod Organizer and got the following positive compilation result

 

 

Starting 1 compile threads for 1 files...
Compiling "UnlockObjectsSpellScript"...
Starting assembly of UnlockObjectsSpellScript
0 error(s), 0 warning(s)
Assembly succeeded

Compilation succeeded.

Batch compile of 1 files finished. 1 succeeded, 0 failed.
[Finished in 9.4s] 

 

 

That says to me that if you are getting error messages where it cannot find the specific SKSE functions, then your PSC files while perhaps present may not be the correct version.

 

GetCurrentCrosshairRef() is on Game.psc

GetType() is on Form.psc

 

Confirm that those two functions are indeed listed on your versions of those scripts. If they are, confirm that the files are indeed in the same location that the CK looks to when compiling. This can be found in the SkyrimEditor.ini located in your main game directory. Look for sScriptSourceFolder= under [Papyrus]

 

If you still cannot get this to work, feel free to wait and see if foamyesque can come up with something with the magic effect stuff.

Link to comment
Share on other sites

Okay, so, OnEffectStart only seems to fire when the effect starts working on an actor, as suggested by the event data. That's unfortunate and leaves us with workarounds.

 

I wound up using two quests to do this. One quest, set to run on game start, has an alias containing the player. That alias has a script attached to it that listens for OnSpellCast events and, if the cast spell was the unlock spell, starts the second quest and registers for an update. When the update fires, it will stop the second quest.

 

The second quest is a search quest. It doesn't start the game enabled, but it has a collection of optional aliases, which it fills by condition in the loaded area, prioritizing things closest to the player. The condition I chose was GetLocked, which straightforwardly fills the aliases with only those things that could be unlocked. GetLockLevel could also be used to get more precision. Each of the aliases gets a script attached to it that listens for an OnMagicEffectApply event. If it fires, it checks to see whether that effect has the correct keyword, and, if it does, unlocks itself.

 

This generally works pretty smoothly, but there are flaws:

 

1. It only works for the player casting the spell. Any NPCs you wish to have use it will need to be manually added.

2. There is a short window just after the spell is cast where the impact events can't be detected (because the search quest hasn't finished starting yet). The projectile used should therefore be relatively slow. I found the illusion projectile to be a reasonable speed, if a tad on the fast side; standing right next to the locked object can be a bit too close.

 

The scripts:

 

Player alias:

Scriptname INP_UnlockPlayerAlias extends ReferenceAlias  

Spell Property INP_UnlockFFAimed Auto
Quest Property INP_UnlockQuest Auto

Event OnInit()
    if GetRef() != Game.GetPlayer()
        ForceRefTo(Game.GetPlayer())
    endif
EndEvent

Event OnSpellCast(Form akSpell)
    if akSpell == INP_UnlockFFAimed
        if INP_UnlockQuest.IsRunning()
            INP_UnlockQuest.Stop()
        endif
        UnregisterForUpdate()
        INP_UnlockQuest.Start()
        RegisterForSingleUpdate(3.0)
    endif
EndEvent

Event OnUpdate()
    if INP_UnlockQuest.IsRunning()
        INP_UnlockQuest.Stop()
    endif
EndEvent

Locked object aliases:

Scriptname INP_UnlockAlias extends ReferenceAlias  

Keyword Property INP_MagicUnlock Auto

Event OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect)
    if akEffect.HasKeyword(INP_MagicUnlock)
        GetRef().Lock(false)
        Clear()
    endif
EndEvent
Edited by foamyesque
Link to comment
Share on other sites

  • Recently Browsing   0 members

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