Jump to content

[LE] I Need Help with a script!


Recommended Posts

Hello! I'm a new Skyrim Modder, however i have had experience with Oblivion Modding, so I've gotten a stable grip on the Creation Kit. But not its new language Papyrus. I know how to code in C#, And know basic idea sets of Java, but dear god, Papyrus as easy as it seems, its abhorrent syntax destroys any chance of me making a script i can coherently understand.

 

 

Put simply, I need help making a script for an unlock spell, like that found in Oblivion, and i barely know where to start. I want it to work for everything from doors to containers. I know i need to instantiate an object, but i want every door/container that the spell projectile hits to not only check its lock level, but if its above an adept lock level, to not unlock it.

I'm lost on it. I've never used a language like Papyrus. For instance Python, which i know its nearly parallel to, I've never used. Knowing its OOP Language allows me to understand it a bit, but nothing as complex as this, all i know is how to make popup boxes and notifications, that's it :-/. Take pity on a old mad man!(even though I'm not old, maybe a little mad :devil:)

But nonetheless, I thank you for any answers or help given to me!

~P

Link to comment
Share on other sites

I've not tested this for compilation of function. I just took some things from within one of my own mods and adapted it to your needs. It requires SKSE in order to work.

The intent is to have a 'touch' spell so that the player has to get close enough for the 'E to Activate" type of message to appear above the crosshair. The script would go on a magic effect assigned to your spell.

 

 

 

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 

 

The alternative to avoiding SKSE is to somehow apply a script to each container and door in the game that could be unlocked by the spell (quest aliases would be preferred for compatibility reasons). Then use a projectile spell and have the script on the container/door listen for the OnHit event. This would eliminate the GetCurrentCrosshairRef and GetType functions which require SKSE.

Link to comment
Share on other sites

I've not tested this for compilation of function. I just took some things from within one of my own mods and adapted it to your needs. It requires SKSE in order to work.

The intent is to have a 'touch' spell so that the player has to get close enough for the 'E to Activate" type of message to appear above the crosshair. The script would go on a magic effect assigned to your spell.

 

 

 

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 

 

The alternative to avoiding SKSE is to somehow apply a script to each container and door in the game that could be unlocked by the spell (quest aliases would be preferred for compatibility reasons). Then use a projectile spell and have the script on the container/door listen for the OnHit event. This would eliminate the GetCurrentCrosshairRef and GetType functions which require SKSE.

 

Don't need to do it to everything in the game, just stuff in the loaded area. A search quest could do so pretty effectively.

 

However, I wonder: Could you not simply script it into an OnEffectStart event on the magic effect itself? The lock and unlock archetypes are depreciated, according to the CK wiki, but there's a suggestion there that script-archetype magic effects can be applied to objectreferences generally, not just actors. If so, that would be by far the simplest solution.

Link to comment
Share on other sites

 

I've not tested this for compilation of function. I just took some things from within one of my own mods and adapted it to your needs. It requires SKSE in order to work.

The intent is to have a 'touch' spell so that the player has to get close enough for the 'E to Activate" type of message to appear above the crosshair. The script would go on a magic effect assigned to your spell.

 

 

 

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 

 

The alternative to avoiding SKSE is to somehow apply a script to each container and door in the game that could be unlocked by the spell (quest aliases would be preferred for compatibility reasons). Then use a projectile spell and have the script on the container/door listen for the OnHit event. This would eliminate the GetCurrentCrosshairRef and GetType functions which require SKSE.

 

Don't need to do it to everything in the game, just stuff in the loaded area. A search quest could do so pretty effectively.

 

However, I wonder: Could you not simply script it into an OnEffectStart event on the magic effect itself? The lock and unlock archetypes are depreciated, according to the CK wiki, but there's a suggestion there that script-archetype magic effects can be applied to objectreferences generally, not just actors. If so, that would be by far the simplest solution.

 

Where do you get that lock is depreciated? Cannot find what you are talking about.

 

 

I suppose another route would be one spell to act as a primer (scripted magic effect to launch a quest which grabs up to 10 or so of the closest locked objects). Then a second spell is cast (projectile magic effect) at the desired locked object. A script added to the object via the quest alias could use the OnHit event and listen for the impact of the projectile and unlock as needed. Not sure how to work out the timing if wanting it all to appear seamless as if it were just one spell that the player used. Certainly don't think a constantly restarting quest in a cloak type of effect is best as it doesn't need to run all the time.

Link to comment
Share on other sites

I've not tested this for compilation of function. I just took some things from within one of my own mods and adapted it to your needs. It requires SKSE in order to work.

The intent is to have a 'touch' spell so that the player has to get close enough for the 'E to Activate" type of message to appear above the crosshair. The script would go on a magic effect assigned to your spell.

 

 

 

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 

 

The alternative to avoiding SKSE is to somehow apply a script to each container and door in the game that could be unlocked by the spell (quest aliases would be preferred for compatibility reasons). Then use a projectile spell and have the script on the container/door listen for the OnHit event. This would eliminate the GetCurrentCrosshairRef and GetType functions which require SKSE.

I compiled it and it said, ...\UnlockObjectsSpellScript.psc(10,7): no viable alternative at input 'LL' soooooo i dont know what happened, it looks correct, you instanticated LL and called GetLockLevel(), then asked for it, so I don't know

 

Link to comment
Share on other sites

Oh, typo on my part. On the "If LL" line change the = to ==

 

= means shove what is on the right into the variable on the left

== means compare what is on the left with what is on the right

 

 

 

EDIT: corrected mistakes from only half paying attention to what I was writing.

Edited by IsharaMeradin
Link to comment
Share on other sites

 

 

I've not tested this for compilation of function. I just took some things from within one of my own mods and adapted it to your needs. It requires SKSE in order to work.

The intent is to have a 'touch' spell so that the player has to get close enough for the 'E to Activate" type of message to appear above the crosshair. The script would go on a magic effect assigned to your spell.

 

 

 

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 

 

The alternative to avoiding SKSE is to somehow apply a script to each container and door in the game that could be unlocked by the spell (quest aliases would be preferred for compatibility reasons). Then use a projectile spell and have the script on the container/door listen for the OnHit event. This would eliminate the GetCurrentCrosshairRef and GetType functions which require SKSE.

 

Don't need to do it to everything in the game, just stuff in the loaded area. A search quest could do so pretty effectively.

 

However, I wonder: Could you not simply script it into an OnEffectStart event on the magic effect itself? The lock and unlock archetypes are depreciated, according to the CK wiki, but there's a suggestion there that script-archetype magic effects can be applied to objectreferences generally, not just actors. If so, that would be by far the simplest solution.

 

Where do you get that lock is depreciated? Cannot find what you are talking about.

 

 

Not the lock function, the lock and open magic effect archetypes.

 

https://www.creationkit.com/index.php?title=Magic_Effect

 

 

If, as the wiki says, a script archetype can hit objects, then running an unlock function OnEffectStart should do the job. I'll poke at it and see.

Link to comment
Share on other sites

Heres the script with one error and one =, http://imgur.com/a/8xPgK

And heres the one with many errors and ==, http://imgur.com/a/ghWew

(The site wont let me upload the photos even though they are .jpgs)

Soooo, i had one of my friends look at the script and he agrees it should work, but nothing seems to want to compile...

 

Couldn't help without seeing the errors and the current version of the script that you have that produces the errors on compilation.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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