Jump to content

Creating a basic lock door script?


Aurawhisperer

Recommended Posts

So I just hoped back into modding again with some programming experience between java, c#, and c++. It's time for me to start scripting.

So I glanced at the logic that the Bethesda wiki provided for the Skyrim language. I understand, and possibly know exactly what to use; however, I am unsure how to execute it. The objective is simple: When the Player opens this door that I named as a reference: lustTrickDoor, when the player insides the house the door locks, forcing the player to kill one or all the bandits in the house to escape. Doing this requires a script triggering this event.

 

Here's what I have planned:

 

Scriptname LustTrap extends Objectreference

 

function ActorOpenDoor(Actor PlayerRef)

if Player == (Need to figure out the code for door)

lustTrickDoor.locked();

else

lustTrickDoor.unlocked();

endif

endfunction

 

Pretty self explanatory. Catch is, how can I implement this? Under the quest database? Or should I create a triggerbox and change the format of the script to where the player must be present? That's my issue is where to put the script, and putting it to where it can be used.

Link to comment
Share on other sites

You could use a triggerbox, but it is easier to just attach this script to the Door.

Scriptname MODINITIALS_DoorScript extends ObjectReference  
Actor Property PlayerRef Auto
ObjectReference Property lustTrickDoor  Auto
bool done

Event OnInit()
    done = false
EndEvent

Event OnOpen(ObjectReference akActionRef)
    if (akActor == PlayerRef) &&  (done == false)
        lustTrickDoor.lock(true)
        done = true
    EndIf
EndEvent

PlayerRef defines itself automatically. lustTrickDoor is an Object Reference of the door you placed.( do NOT make a door reference type).

The bool done is there so the script doesn't launch multiple times.

You then need to attach a script to the bandits:

Scriptname MODINITIALS_BanditScript extends ObjectReference  
ObjectReference Property lustTrickDoor  Auto  

Event OnDeath(Actor akKiller)
    lustTrickDoor.lock(False)
EndEvent

Edited by aldwyn1111
Link to comment
Share on other sites

  • Recently Browsing   0 members

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