Skip to main content

Scripting help needed!

Submitted by eloth on

i need help with this script that is supposed to be attached to trapped doors in morroblivion:

SCN 0AAMWTrapHeavyBurdenTouch

; Applied to things like chests and doors

Begin OnActivate
    If IsActionRef Player
        Cast 0heavySburdenStouch Player
        Message "The door was trapped!"
    Activate
        Else
            Activate
        EndIf
    EndIf
End

How can i rewrite this script so that it will only activate once, when opening the door

for the first time? And last but not least, be able to close the door again, without activating

the trap again.

 

Karma: 0 (0 votes)
Last edited by eloth on 28 Sep 2011 - 07:45.

Try this:

SCN 0AAMWTrapHeavyBurdenTouch
short ACount
; Applied to things like chests and doors

Begin OnActivate

If Acount == 0 && IsActionRef Player
        Cast 0heavySburdenStouch Player
        Message "The door was trapped!"
    Activate
Set Acount to 1

        Else
            Activate
        EndIf
    End

Karma: 0 (0 votes)

Oldwolf's solution looks legit to me.

Karma: 0 (0 votes)

thank you! works like a charm :)

Karma: 0 (0 votes)

You're welcome :)

Karma: 0 (0 votes)

Is it possible by script, to change the name of an item/door?

Karma: 0 (0 votes)

OBSE has a series of Name commands but they are kind of dangerous...

Functions:

SetName - sets the display name of the type. SetName is a special function. It is defined to work on Inventory items, but it can be used with any form. To use with a non-Inventory item you must first assign the objectID to a ref. For most forms the name is part of the base form and changing the name will change it for all instances of the type.
(nothing) reference.SetName name:string objectID:ref

GetName - returns the name of an object.
(name:string_var) reference.GetName object:ref

CompareName - returns 1 if stringToFindInName is found in the name of the object
(nameContainsString) reference.CompareName toFindInName:string objectID:ref
(nameContainsString) reference.NameIncludes toFindInName:string objectID:ref

CompareNames - compares the names of two objects and returns -1 if the first occurs alphabetically before the second, 1 if the first occurs after the second, or 0 for equality. Comparison is case-insensitive.
(comparison:int) reference.CompareNames compareTo:ref compare:ref

CopyName - copies the name from the source to the target. It is defined to work on Inventory items, but it can be used with any form. To use with a non-Inventory item you must first assign the objectID to a ref. For most forms the name is part of the base form and changing the name will change it for all instances of the type.
(nothing) CopyName srcObjectID:ref targetObjectID:ref

ModName - modifies the name of the calling reference or passed objectID. The toReplaceAndReplaceWith string has the following format: "toReplace|replaceWith". We will do a case insensitve search for the toReplace portion and if found will replace it with the replaceWith portion. The | character is used to separate the portions of the string. If there is nothing before the | character, the replaceWith string is prepended to the name. In the console, use @ instead of |.
(nothing) reference.ModName toReplaceAndReplaceWith:string toObject:ref

AppendToName - appends the passed string to the end of the name of the calling reference or passed objectID.
(nothing) reference.AppendToName toAppend:string toObject:ref

HasName - returns 1 if the object has a id consisting of at least one character.
(hasName:bool) reference.HasName objectID:ref

SetNameEx - sets the name of the base object. The new name is a string constructed from a format string using the same format specifiers used by OBSE's output functions. Unlike SetName, SetNameEx cannot be called on a reference.
(nothing) reference.SetNameEx formatString:string var1 var2 ... var20 object:ref

...

there are a bunch of name commands besides these though: http://cs.elderscrolls.com/constwiki/index.php/Special:Search?search=name&fulltext=Search

Karma: 0 (0 votes)

do'h wrong thread sorry

Karma: 0 (0 votes)

im not getting this right, what is wrong here? scripting is not for me hehe

    SCN 0AAMWTrapBlind
   
Short controlvar
Short button
short ACount
   
Begin OnActivate
    If ( controlvar == 0 ) && Acount == 0 && IsActionRef Player && GetIsUsedItem 0probeugrandmaster == 0
    Messagebox "You need a probe to untrap this door! Would you like to open the door anyway?", "Yes", "No"
   
    Set controlvar to 1
;    ElseIf ( controlvar > 1 ) && IsActionRef Player && GetIsUsedItem 0probeugrandmaster == 1
    ElseIf ( controlvar == 1 ) && Acount == 0 && IsActionRef Player && GetIsUsedItem 0probeugrandmaster == 1
    Activate
    Message "Door untrapped successfully!"
    RemoveItem 0probeUgrandmaster 1

    EndIf
End

Begin GameMode
    If ( controlvar == 1 )
    Set button to GetButtonPressed
    If ( button == -1 )
    Return
    ElseIf ( button == 0 )
    Cast 0Blind Player
    Activate
    Set Acount to 1
    Set controlvar to 2
Activate

    Else
;    MessageBox "Your answer was wrong."
    Set controlvar to 0
    ;Activate
    EndIf
    ElseIf ( controlvar == 2 )
    Activate
    Set Acount to 1
    Set controlvar to 3
    EndIf
End

Karma: 0 (0 votes)

Changing names is problematic. You would either have to make a seperate Base object for each individual trapped door ... or you would have to make a presistent reference for each individual trapped door. Neither is a good solution and I think its best to avoid it.

Anyways ... I've made some modifications to your script which should hopefully work <<< See attached .txt file>>>.

At the very beginning is a part like this:

Short ControlXnoPROBE Short ControlXyesProbe Short button short XDisarmSwitch ref XProbeID ref XSpellID Begin OnActivate Set XProbeID to "Lockpick" Set XSpellID to "TestFireball" If XDisarmSwitch == 1

Change the "Lockpick" to the editor ID of your lockpick and "TestFireball" to the editor ID of your Spell (I couldn't find 0probemaster ... and 0Blind doesn't work because blind effect is absent in Oblivion).

 

If you want its should also be possible to further modify this script to include Random or Skill based Chance of Failure.

 

PS: Make sure you make a new base object to apply this script to ... since every instance of the door with this script attached will be trapped.

Attachments

Karma: 0 (0 votes)

thank you Hashmi :) that worked sweetly, now its time to bring back the good old morrowind traps :)

one more thing, is it possible to include some kind of skill requirement, or maybe something like this:

 

your security skill = random chance in percent based on skill level

eg, if you have security skill 60, there is a 60% chance the probe will untrap the trap

 

Karma: 0 (0 votes)

I can't think of a good formula right now... but if you can finalize  a mathematical expression for it then I can integrate it into the code.

 

 

Karma: 0 (0 votes)

a formula like that is bound to be very complex, way beyond my math capabilities :)

Karma: 0 (0 votes)

Let me work on it for a day ... I'll post an updated script soon. We can also perhaps assign randomly chosen trap effects for variety and also make the the "detection" of the trap dependent on PC's security skill.

Karma: 0 (0 votes)

sounds good to me :)

i have recreated the different probes from morrowind, but im not sure

if its nescessary to complicate things even further, by implementing

those into the script as well :)

Karma: 0 (0 votes)

Alright, so I am done with the script (attached as .7z containing a .txt). PC's security skill should now determine whether or not a Trap can get detected. If it does get detected ... you will be given the option to try to disarm it (if you have a probe) ... and Disarming will again take your security skill into consideration. Someone at 100 Security will be able to detect and Disarm traps virtually 100% of the time. A failed Disarm attempt 'may'  or may not accidently trigger the trap.

I've also added the ability to cast a variety of different spells ... so that we can use a single script for all trapped doors and chests.

Do tell me if there are any bugs or adjustments that you need.

 

 

 

Attachments

Karma: 0 (0 votes)

Do you guys need any icons for probes?

Karma: 0 (0 votes)

Hashmi didn't really mean Morrowind "Probes," he meant Oblivion Lockpicks.
Karma: 0 (0 votes)

i meant morrowind probes hehe, and i have recreated them, and have made icons for them.

@hashmi1:

your a scripting genious man :) i will take it for a spin, and give some feedback :)

 

Karma: 0 (0 votes)

I'm  implemented support for all the different Probe types that were present in Morrowind (Apprentice, Journeyman, Master etc.), Probe "Health" which deteriorates upon your skill and have also improved the Skill-Based formulae.

 

Karma: 0 (0 votes)

great work :) the script works very good, except for a rare occation, where nothing happens when trying to

open a door, and you have to press space once more and it will be fine.

 

another version have to be made for chests, but thats only simple adjustments.

Karma: 0 (0 votes)

Nice work guys!  That is one part of Morrowind that I really miss when playing Oblivion.

Karma: 0 (0 votes)

@eloth: I am curious: are you making new references for trapped doors and placing them in cells by hand? Because otherwise if you trap a velothi door (for example) the trap would also be applied to the doors in Vivec and Vos. I am trying to make the script differetaite between dungeons and towns (using GetInCell) but from some early tests it seems slow (or maybe not ... I am trying multiple things at the same time so the problem causer might be someting else.).

On a side note, a new script should be ready within a few days ... I'll try to make sure that it remains compatible with any work you might have already done.

Karma: 0 (0 votes)

I have already made new references for all doors that was trapped in morrowind, and divided them into different categories, like velothi, jaildoors, etc. all that is left is adding your script to them

Karma: 0 (0 votes)

If you can send me your esp via PM I should be able to more easily integrate the script and fix any potential bugs.

Karma: 0 (0 votes)

Holy crud guys, nice work! It will be so awesome to go through some dwemer ruins with the probe now!

Karma: 0 (0 votes)