Jump to content

Opening a Door using a Spell


SerchBoogie

Recommended Posts

Hi.

I have no experience or knowledge about scripting, nothing, none, zero, negative, nonexistent. So I googled it and I found this script. The script is attached to the door, I created a new spell and I chose it in the Properties menu for the script. So it is supposed to open when you hit it with the spell.

Scriptname SpellActivationScript extends ObjectReference

Actor property PlayerRef auto
Spell property ActivatorSpell auto


AUTO STATE ClosedPosition ; assumed the door is closed by default(Open by default not checked on reference)
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
bool abBashAttack, bool abHitBlocked)

if akSource == ActivatorSpell
self.Activate(PlayerRef)
endif
EndEvent

Event OnActivate(ObjectReference akActionRef)
GoToState("Busy")
self.SetOpen()
GoToState("OpenPosition")
EndEvent
ENDSTATE

STATE Busy
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
bool abBashAttack, bool abHitBlocked)
;empty, event thrown out.
EndEvent

Event OnActivate(ObjectReference akActionRef)
;empty, event thrown out.
EndEvent
ENDSTATE

STATE OpenPosition
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
bool abBashAttack, bool abHitBlocked)

if akSource == ActivatorSpell
self.Activate(PlayerRef)
endif
EndEvent

Event OnActivate(ObjectReference akActionRef)


I doesn't work. The door wont open. I'm trying to use this door.

 

 

 

What am I missing?

Is it something to do with the spell I created? It's a Magelight spell basically.

 

Thanks =D

Edited by SerchBoogie
Link to comment
Share on other sites

Event OnEffectStart(Actor akTarget, Actor akCaster)
  ObjectReference MyDoor = akTarget
  If ( MyDoor.IsLocked() == 0 )
    MyDoor.Activate(PlayerRef)
  ElseIf ( MyDoor.IsLocked() == 1 )
    MyDoor.Lock(False)
    MyDoor.Activate(PlayerRef)
  EndIf
EndEvent

Why are you trying to overcomplicate an open door spell (not trying to be rude just puzzled why your trying something like that), usually I add something like this to a perk and it works like a charm to open and unlock doors however this is a first time I'm adding it to a magic effect so let me know if it works here. Just add this to your magic effect and remove that script from your door; if it doesn't work I'll write something for you for a perk and a magic effect that'll work 100% (its the same one I use on my astral projection power, though I've simplified it a bit to see if it'll work on your door through an effect instead). You'll also need to add a condition on the spell and magic effect to only work on doors or else it will activate anything it touches including people.

Link to comment
Share on other sites

Hi. Thank you so much for answering =D

 

I guess I have to open the magic effect properties in the object window and add the script there. Well I got this error.

 

Starting 1 compile threads for 1 files...
Compiling "LightKey"...
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\LightKey.psc(6,20): variable PlayerRef is undefined
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\LightKey.psc(9,20): variable PlayerRef is undefined
No output generated for LightKey, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on LightKey

 

What I want is to have a door that won't open unless you hit it with a spell or use a power. Like those doors in the Metroid Game series which you have to hit them with the corresponding beam color to open them.

 

But I just give up. I will be happy with anything similar. How does that "perk" thing would work?. I just need the door to open exclusively by the use of anything related to magic XD

 

Thanks.

Edited by SerchBoogie
Link to comment
Share on other sites

I did just that on my paladin mod, a secret door (no name so it's not activatable by the player) that is opened when hit by a specific spell, this is the script:

Scriptname FFPAACryptDoor extends ObjectReference  

Spell Property KeySpell Auto ; spell that opens it.
ObjectReference Property ActivateRef Auto ; this is the activate parent of the door, so that it can also be opened by a lever on the other side
;youd directly activate the door itself: self.Activate(Game.GetPlayer())

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
If (akSource as Spell) &&  (akSource as Spell == KeySpell) ; first condition to avoid script errors.
ActivateRef.Activate(Game.GetPlayer())
EndIf
EndEvent

A different approach is using OnMagicEffectApply instead, like in Labrynthian that you have to cast a spell of certain school to a stone for the doors to open.

 

And btw the above script gave you an erro because you need to add a property on top in order to call playerRef later.

Actor Property playerRef Auto
Edited by FrankFamily
Link to comment
Share on other sites

Whichever method you use after the script compiles you need to set up the properties of the spell or else it won't work so you click on the script and it opens a properties window (left click twice) then you fill in the properties to what they need to be;

 

so if your using Franks method then you need to fill the activator property and the spell property and if your using the magiceffect one then you need to fill in the playerref property (but this one you could click auto-fill).

 

And Frank was right you need to add:

 

Actor Property PlayerRef Auto

 

to the top of the script before the Event OnEffectStart. Do you want the doors to be open by a specific magic effect or by any magic effect?

Link to comment
Share on other sites

By an specific spell. I created a Spell for that porpuse. Anyway I made it work.

 

Just for the record, here is what I did, in case someone wants to MOD Skyrim in 2021

 

I used FrankFamily's Script. I attached the scrip to one of those doors that have "No name" in their name, those Doors cannot be activated by the player. Then I throw a Lever Activator into the scene and set it as a Activate Parent for the Door because... reasons, because the all myghty god of programming says so. Then in the Script properties I selected the desired Spell. Then for the ActivateRef property I selected the Lever Activator. I just hid the lever and there you have it!.

 

Thaks you so much both for your help, now I'm one step closer to finish my MOD, I will give you credit once I publish it. But there is still a lot of work to do. Cheers.

Edited by SerchBoogie
Link to comment
Share on other sites

  • Recently Browsing   0 members

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