Need help with scripting a door

Post » Mon Nov 19, 2012 11:16 am

I'm new to scripting, and I want to make a door open when you cast a spell at it and then close automatically after a few seconds. I've tried to figure it out by myself but haven't found the information I need.

This is what I've concluded so far:

*If I want the door to react to a spell or shout, I should probably use Event OnHit.

*If I want the door to open, I should probably use PlayAnimation.

...and that's about all. I think the tutorials and wiki are very unclear. Only thing I understand is the hello world tutorials, in which I'm not interested.


Scriptname MyScript extends ObjectReferenceEvent OnHitForm akMySpellPlayAnimation WhateverYouWriteToOpenTheDoorEndEvent
User avatar
Tamara Primo
 
Posts: 3483
Joined: Fri Jul 28, 2006 7:15 am

Post » Mon Nov 19, 2012 10:21 am

Check out this page on the wiki.

http://www.creationkit.com/SetOpen_-_ObjectReference

Also, you may want to look into the OnHit event a little more closely, so you can use the variables that it comes with to determine if it was in fact your spell that hit it, and not just any spell/projectile/weapon.

http://www.creationkit.com/OnHit_-_ObjectReference
User avatar
Erich Lendermon
 
Posts: 3322
Joined: Sat Nov 03, 2007 4:20 pm

Post » Mon Nov 19, 2012 11:19 pm

It's listed on the page that PhiniusMaster linked to, but you'll probably want to use this function to open and close your door - http://www.creationkit.com/SetOpen_-_ObjectReference.

You'll also want to use a http://www.creationkit.com/Property_Reference in order to refer to your spell, which is stored in the data file (that the script compiler doesn't have access to).

If you're new to Papyrus, might I suggest you take a look through my http://cipscis.com/skyrim/tutorials/beginners.aspx tutorial? It might help you become more familiar with the basics of Papyrus, including the syntax it uses.

Cipscis
User avatar
Marlo Stanfield
 
Posts: 3432
Joined: Wed May 16, 2007 11:00 pm

Post » Mon Nov 19, 2012 10:33 am

Thanks for trying to help.

I'd been looking for something like SetOpen in the wiki but didn't find it.

I had already read the OnHit page, and cipscis' Papyrus For Beginners, before I posted this topic. But I didn't understand much, or rather, I don't know how to use what I did understand. Especially properties. I understand what you need them FOR, but not how to use them.

cipscis: Maybe it would be easier for beginners to understand how to use properties, functions and such (and in which order to write things), if you provided more concrete examples on your page. Maybe a section with example scripts and some explanation of what they're doing. Looking at other scripts in the creation kit has helped somewhat, but not much either, since there's no explaining what does what.
User avatar
Olga Xx
 
Posts: 3437
Joined: Tue Jul 11, 2006 8:31 pm

Post » Mon Nov 19, 2012 4:56 pm

Properties are pointers, to put it simply. If you have a particular reference that you need to manipulate, you make an ObjectReference property (in this case we'll call it myDoor) and then you have to set the property (by double clicking the script, and then clicking the property you want to set, and then either selecting it in the render window or by selecting the cell and then the particular reference in the drop down boxes). Now you have a property that is properly 'pointing' out which reference your script is talking about.

So, your script would look like this:

Scriptname OpenDoorWithParticularSpell extends ObjectReference;always declare properties outside of events or functionsObjectReference Property myDoor autoSpell Property mySpell autoEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \  bool abBashAttack, bool abHitBlocked); it is very important that you include all of the parameters of an event, or it simply won't work the easiest way to do this is to ccopypaste the function or event from creationkit.comif akSource==mySpell   SetOpen()endIfendEvent

EDIT: Oh, I assumed you were placing this on the door itself. If you wanted to hit, say, a target and have that open the door you would just replace SetOpen() with myDoor.SetOpen(). The ObjectReference property isn't necessary if you're placing the script on the object being opened though.
User avatar
Jessica Raven
 
Posts: 3409
Joined: Thu Dec 21, 2006 4:33 am

Post » Mon Nov 19, 2012 11:21 pm

Ok, now it's clear :smile: I thought I should write mySpell instead of akSource, but you use it in an "if" statement afterwards.

cipscis. I read your "editor IDs in papyrus", and that made a lot more sense to me. :)
User avatar
Chloe Botham
 
Posts: 3537
Joined: Wed Aug 30, 2006 12:11 am

Post » Mon Nov 19, 2012 5:24 pm

Ok, I've made a script with Event OnHit, and the door didn't open.

So I changed it to OnMagicEffectApply, and now it opens. Just informing, if anyone else wants to make a door that opens when you cast magic at it.
User avatar
Alberto Aguilera
 
Posts: 3472
Joined: Wed Aug 29, 2007 12:42 am


Return to V - Skyrim