MORROWIND
SCRIPT LIBRARY

SECTION

Activators
Beds
Buttons
Button Activator 2
Hurting Actor on contact
Invisible Activator
Reset Activator
Teleporting the player

Creatures
Appearing skeletons trapped chest
Making creatures appear by invisible activator
Summon Creature on activating an item
Visual effect on death

Display Cases
DISPLAY CASES TYPE - Lady E's which have the glass lids that lower when activated.
DISPLAY CASE TYPE - Indigo Rage's Display Cases w/the red fabric interior
DISPLAY CASE TYPE - Dongle's Green Glass Display Cabinet

Doors
Tribunal’s dark hole script – option to pass through
Door Lock and Alternative Door Lock script
Auto-Locking doors
Trapped Rug “door”
Trapped Rug 2

Inventories
Adding items after death

Items
Making an item ‘unpickupable’
Teleport Amulet
Teleport Ring
Teleport Ring 2
‘Throbbing’ items
Making objects appear only when an item is in the inventory

Journal
Adding journal entries
Locks
Briefcase Lock
Door Lock and Alternative Door Lock script
Auto-Locking doors
Keypad Lock

Movers
Activator Wall move
Closing a door
Moving wall 1
Moving wall 2
Moving wall 3

Magic
Magic regenerate

Misc
Keg Script
Trash Can

Music
Over-riding battle music

NPCs
Chaning NPCs clothes daily
Disposition
Enforced clothing for a companion (abuse possible)
Making them fight
Making them fight 2
Making them fight two NPCs
Making followers warp to you
Mannequins
Simple Mannequin
Armour Mannequin
Armour Mannequin place holder
Pacifying NPCs

Scale
Scale Script 1, 2 & 3 

Timers
Timer 1

Thanks to:

Darknut, Chia, Zer010, Nikki, Melian, Enmesharra, cyran0, http://www.morrowind-mod.com, Fliggerty, Midgetalien, Trey Leavens, Pokeapoke,qarl, Lurlock, Princess_stomper, Baratheon79, ixidorsbane, Aridale, Rocket, Boblen 1982, Kir, Thamior Amakiir

TOP

ACTIVATORS

Bed Script

begin Bed_Standard

;used for standard beds the player can activate and sleep in

if ( MenuMode == 0)

	if ( OnActivate == 1 )

		ShowRestMenu

	endif

endif

end

TOP

Buttons 							

"activate script"; which would be placed on a button of some sort. You need to make a global variable first, I'll call it "var01", you should name it something with your initials.

CODE
begin button01

short State 
float xpos
float ypos
float zpos

if ( MenuMode == 1 ) 
return 
endif 

if ( OnActivate ==1 ) 
if ( State == 0 ) 
set var01 to 1;your global variable
set xpos to ( GetPos, X )
set ypos to ( GetPos, Y )
set zpos to ( GetPos, Z )
PlaySound "cent spider roar" 
set State to 1
endif 
endif 

end

NOTE: For the mover, use Activator Wall move script.

Button Activator 2 (a-la Ghostgate)

TOP

Here's the classic button/lever leads to wall/gate/whatever moving script: the MW ghostgate script.

this part is put on the activator:
CODE
Begin GG_OpenGate1

;opens first gate as Ghostgate (say that 5 times)
;put on button

float timer
short state

if ( MenuMode == 1 )
	return
endif

if ( OnActivate == 1 )
	
	if ( GG_Gate1_State == 0 ) 
		PlaySound "Open Lock"
		"ex_gg_portcullis_01"->Playsound3DVP "Dwemer Door Open" 1.0 1.0
		set GG_Gate1_State to 10
		set state to 10
	endif
endif

if ( State >= 10 )
	
	set timer to ( timer + GetSecondsPassed )

	;move gate up (210 units)
	if ( timer < 3 )
		"ex_gg_portcullis_01"->MoveWorld z 70

	;set back to start
	elseif ( timer > 21 )
			"ex_gg_portcullis_01"->SetAtStart
			set State to 0		;can now press button again
			set GG_Gate1_State to 0
			set timer to 0

	;move gate down (210 units)
	elseif ( timer > 18 )

			;use state so sound only plays once			
			if ( State == 10 )
				"ex_gg_portcullis_01"->Playsound3DVP "Dwemer Door Open" 1.0 1.0
				Set State to 20
			endif

			"ex_gg_portcullis_01"->MoveWorld z -70

	endif
endif

end GG_OpenGate1

It uses a global variable, GG_Gate1_State

Also, the moved bit needs to have this "script":

begin state
short state
end

which adds a variable to track, although actually I've never seen it being used

Hurting actor on contact

TOP

begin Collide_damage_100

;hurts and standing actor 100 pts per sec when colliding with this object

HurtCollidingActor 100

end

TOP

Invisible activator

Now heres a different version of the above script which will make the wall rise when you get near an invisible marker, the "trigger script". I recommend using the activator mesh with the sound effect scripts on them. You can use the same global variable as the above script but you should not use them both in the same cell.

Create your own “var01” using the gameplay > Globals menu and selecting new and giving your global a unique id. Replace var01 with this ID.

CODE
begin trigger01_script

short doonce 

if ( MenuMode == 1 ) 
return 
endif 

If ( GetDistance, Player <= 128 )
if ( doonce == 0 ) 
set var01 to 1;your global variable
set doonce to 1
endif
endif

end

NOTE: For the mover, use Activator Wall move script.

TOP

Reset Activator

Now heres a script you should place on another invisible activator in the room to reset the global variable when you leave the cell so you can use the script over and over.

begin var_reset01

if ( MenuMode == 1 )
return
endif

if ( CellChanged == 1 )
set var01 to 0;the name of your global variable
endif

end

Teleporting the Player

TOP

Here's a script that makes an object teleport the player somewhere upon activation.
It's supposed to look better in game than a more simple teleportation because it uses fades.
I haven't actually used it myself yet.
You need to create 3 new global float variables for it: My_PC_X, My_PC_Y, My_PC_Z (replace "my" with something unique)
CODE
Begin player_placement
;Global Float My_PC_X
;Global Float My_PC_Y
;Global Float My_PC_Z
Float xpos
Float ypos
Float zpos
Float timer
Short step
If ( OnActivate == 1 )
Set step to 1
Endif
If ( step == 1 )
FadeOut 0.1
ToggleMenus
Set step to 2
Return
Elseif ( step == 2 )
Set timer to ( timer + GetSecondsPassed )
If ( timer > 0.2 )
Set timer to 0
Set step to 3
Endif
Return
Elseif ( step == 3 )
Set step to 0
Player->COE 0 0
Set xpos to My_PC_X
Set ypos to My_PC_Y
Set zpos to My_PC_Z
ToggleMenus
MenuTest
MenuTest
Player->SetPos x xpos
Player->SetPos y ypos
Player->SetPos z zpos
FixMe
Player->SetPos x xpos
Player->SetPos y ypos
Player->SetPos z zpos
FadeIn 0.1
Endif
End

TOP

MOVERS

Activator Wall move

Now heres a script that will cause a wall to rise up when that button is pressed, or you get near that invisible marker. Make an activator from the wall mesh and attach this script to it.

begin WallMove01_script

float Timer 
short State 

if ( MenuMode == 1 ) 
return 
endif 

if ( var01 == 1 ) 
if ( State == 0 ) 
PlaySound3D "SothaDoorOpen" 
set State to 1
endif 
endif 

if ( State >= 1 ) 

set timer to ( timer + GetSecondsPassed ) 

if ( Timer < 1 ) 
Move, Z, 256
set State to 2
endif 
endif 

end

Closing a Door

TOP

I hate having doors opened all over the place about as much as I hate having to always stop and close the door. So I created this simple but useful script for my house mod.

Put this on a door and the door will close by itself 5 seconds after being opened. 

CODE
Begin ZZA_Door_close_script

Short ContVar
float timer

  ;if the door should happen to get messed up or if the player leaves the cell while a door is not finished
  ;closing itself this resets everything whenever the player enters the cell
If ( cellchanged > 0 )  
    SetAtStart
    Set ContVar to 0
endif

If ( ContVar == 0 )
    If ( OnActivate )
        Activate
        set ContVar to 1
        set timer to 0
    Endif
Elseif ( ContVar == 1 )
    If ( OnActivate )       ;if the player closes the door by hand
        set timer to 6
    Endif
    set timer to timer + GetSecondsPassed
    If timer > 5
        Activate
        set ContVar to 0
    Endif
Endif

End

Sliding wall trap 1

TOP

This should be placed on a mesh that the player stands on to activate a wall mover.
Begin GDRN_LostStairTrap

float counter
Short doOnce

if ( doonce == 4 ) ;once script has done it's thing, keep it as short as possible
   return
endif

if ( MenuMode == 1 )
  return
endif

if ( doOnce == 3 )
   if ( CellChanged == 1 )
      "in_dwrv_wall_GDRN_1"->disable
      set doonce to 4
      return
  else
    return
  endif
endif

if doonce ( == 0 )               ;trigger when player stands on item
  if ( GetStandingPC == 1 )
    Set doonce to 1
  endif
  return
endif

if ( doOnce == 1 )
  PlaySound "Door Stone Open"
  Set doOnce to 2
endif

Set counter to counter + GetSecondsPassed

"in_dwrv_wall_GDRN_1"->MoveWorld X 80

if ( counter > 6 )
   Set doOnce to 3
   Set counter to 0
endif

end GDRN_LostStairTrap

TOP

Sliding wall trap 2
This should be placed on a mesh that the player stands on to activate a wall mover.

Begin GDRN_LostStairTrap

float counter
Short doOnce

if ( doonce == 4 ) ;once script has done it's thing, keep it as short as possible
   return
endif

if ( MenuMode == 1 )
  return
endif

if ( doonce == 0 )               ;trigger when player stands on item
    if ( GetStandingPC == 1 )
      Set doonce to 1
    endif
elseif ( doonce == 1 )
    PlaySound "Door Stone Open"
    Set doOnce to 2
elseif ( doonce == 2 )
    Set counter to counter + GetSecondsPassed
    "in_dwrv_wall_GDRN_1"->MoveWorld X 80
    if ( counter > 6 )
       Set doOnce to 3
       Set counter to 0
    endif
elseif ( doOnce == 3 )
   if ( CellChanged == 1 )
      "in_dwrv_wall_GDRN_1"->disable
      set doonce to 4
      return
  endif
endif

end GDRN_LostStairTrap

TOP

Sliding wall trap 3

TOP

This should be placed on a mesh that the player stands on to activate a wall mover.

Begin GDRN_LostStairTrap

short state
float counter
Short doOnce

if ( MenuMode == 1 )
return
endif

if ( GetStandingPC == 0 )
;its best to do it this way ... otherwise the whole script until you step on the mesh 
return
endif

If ( doOnce == 0)

set state to 10

endif

if ( state == 10 )

Set counter to counter + GetSecondsPassed

if ( counter < 6 ) 

"in_dwrv_wall_GDRN_1"->Playsound3DVP "Door Stone Open" 1.0 1.0

"in_dwrv_wall_GDRN_1"->MoveWorld Z 320

elseif ( counter > 6.1 )

Set doOnce to 2
Set counter to 0
Set state to 0

endif

if ( CellChanged == 1 )
if ( doOnce == 2 )
"in_dwrv_wall_GDRN_1"->disable
endif

end GDRN_LostStairTrap

SCALE

TOP

For the scale of your choice, simply edit the ‘setscale X’ number.
Scale Script 1

Begin ScaleScript
short DoOnce
if ( doOnce == 1 )
    return
endif
SetScale 3.0
set DoOnce to 1
end ScaleScript

Scale Script 2

Begin _scale_20

if ( getscale != 20.00 )
setscale 20.00
endif

End _scale_20

Scale Script 3

begin _scale_5
;replace 5.0 with whatever scale you want it to have

if ( getscale != 5.0 )
setscale 5.0
endif

End
INVENTORY

TOP

Making items arrive post-death:

Begin XX_Death_Script

If ( GetHealth <= 0 ) 
  AddItem "item ID" #  
  AddItem "item ID" #
EndIf 

End

ITEMS

Making an item ‘unpickupable’

TOP

MAKING A MISCELLANEOUS OBJECT "UNPICKUPABLE". This script Vorwoda_the_Black wrote for me as I had to change the trees in Abu Manor dining room from Static to Miscellaneous Objects so they wouldn't have collision walls, but I didn't want people to be able to pick them up like Miscellaneous Objects. Just replace the SA_MiscTreeScript with the id of the object in question.	
;Script to prevent Dining Room trees from being
;moved, written by Vorwoda_the_Black 
Begin SA_MiscTreeScript
if ( OnActivate == 1 )
return
endif
End SA_MiscTreeScript	

Teleport Amulet

TOP

Make sure you alter the LOCATION, and inset x/y/z here values.

Begin amuletScript

short button
short messageOn
short reset
short OnPcEquip

;if ( MenuMode == 1 )
;	Return
;endif

if ( OnPCEquip == 0 )
	set reset to 0
endif

if ( reset == 1 )
	return
endif

if ( OnPCEquip == 1 )
	if ( reset == 0 )
		Set OnPCEquip to 0
			MessageBox "Would you like to return to LOCATION?" "Yes" "No"
			set messageOn to 1
		endif
	endif
endif

if ( messageOn == 1)

	set button to GetButtonPressed

	if ( button >= 0 )
		set messageOn to 0
	endif

	if ( button == 0 )
		Player->PositionCell, insert x here, insert y here, insert z here, 180, "LOCATION"
		set reset to 1		
			
	elseif ( button == 1 )
		set reset to 1
		return
	endif
endif

End

 Teleport Ring

TOP

HOME TELEPORT RING 	
;This script is for the home teleport ring, don't know who wrote this. 
Begin SA_AbuManor_TeleportRing
short OnPCEquip
if ( OnPCEquip == 1 )
Player->PositionCell, 2178 2610 1122 0 "Abu Manor"
endif
set OnPCEquip to 0 
End SA_AbuManor_TeleportRing	

Teleport Ring 2

TOP

Change locations to where you want it to take you.

CODE
Begin da_tb_teleportring

short button
short messageOn
short reset
short OnPcEquip

;if ( MenuMode == 1 )
; Return
;endif

if ( OnPCEquip == 0 )
set reset to 0
endif

if ( reset == 1 )
return
endif

if ( OnPCEquip == 1 )
if ( reset == 0 )
Set OnPCEquip to 0
MessageBox "Where would you like to go?" "Balmora" "Vivec" "Sadrith Mora" "Tel Fyr" "Nowhere"
 set messageOn to 1
endif
endif
endif

if ( messageOn == 1 )

set button to GetButtonPressed

if ( button >= 0 )
set messageOn to 0
endif

;Balmora
if ( button == 0 )
playsound "conjuration hit"
Player->PositionCell 4288, 4384, 15300, 90 "Balmora, Temple"
set reset to 1  

;Vivec
elseif ( button == 1 )
playsound "conjuration hit"
Player->PositionCell 5248, 6336, 12850, 180 "Vivec, Hall of Wisdom"
set reset to 1  

;Sadrith Mora
elseif ( button == 2 )
playsound "conjuration hit"
Player->PositionCell 3952, 4344, 1138, 0 "Sadrith Mora, Telvanni Council House, Entry"
set reset to 1
return

;Tel Fyr
elseif ( button == 3 )
playsound "conjuration hit"
Player->PositionCell 108, 102, 54, 0 "Tower of Tel Fyr, Onyx Hall"
set reset to 1
return

elseif ( button == 4 )
set reset to 1
return

endif

endif

End

‘Throbbing’ Items

It makes an object grow and shrink a little bit to simulate a "throbbing" effect.

CODE
begin throb_script

  float timer
  short state
  float temp
  short delay

  if ( MenuMode )
      return
  endif

  set timer to ( timer + getsecondspassed )
  if ( timer >= 3 );change this for delay between grow n shrink
      if ( state == 0 )
          set state to 1
      else
          set state to 0
      endif
      set timer to 0
  endif

  set delay to ( delay + 1 )
  if ( delay < 5 );change this for growth speed
      Return
  endif
  set delay to 0

  if ( state == 0 )
      set temp to GetScale
      set temp to ( temp + 0.015 );tweak these values for size
      SetScale temp
  else
      set temp to GetScale
      set temp to ( temp - 0.015 )
      SetScale temp
  endif

end

Making objects appear only if the player has an item in their inventory

TOP

This one makes the object it's attached to only appear if the player has a certain item in inventory.
It would be pretty cool if you checked for a spell instead of an item, say one which you only got from a faction, since that's not obvious the object appearing would appear to be connected with belonging to said faction.
It's from Trey Leavens at the forums

CODE
begin scriptname

short variable

if ( variable == 0 )
  if ( GetDisabled == 0 )
    disable
  endif
elseif ( variable == 1 )
  if ( getdisabled == 1 )
    enable
  endif
endif

if ( player->GetItemCount, "objectID" >= 1 )
  set variable to 1
endif

end

JOURNAL

TOP

Adding journal entries

Well, here is a script that I frequently use in designing quests. It updates the player’s journal upon reading a book or note. It works whether the player reads the note by activating it in the world or equipping the note from inventory.

CODE
Begin lgnpc_fq_NoteScript

; Attached to note to trigger a journal update when player reads it.

short readNote
short OnPCEquip
short PCSkipEquip

if ( readNote == 1 )
   return
endif

set PCSkipEquip to 0

if ( OnActivate == 1 )
   if ( GetJournalIndex "lgnpc_fq_X" == 40 )
      Journal "lgnpc_fq_X" 50
      set readNote to 1
   endif
   Activate
   return
endif

if ( menumode == 0 )
   return
endif

set PCSkipEquip to 1

if ( OnPCEquip == 1 )
   if ( GetJournalIndex "lgnpc_fq_X" == 40 )
      Journal "lgnpc_fq_X" 50
   endif
   set readNote to 1
   set OnPCEquip to 0
   set PCSkipEquip to 0
   Activate
endif

End lgnpc_fq_NoteScript

LOCKS

TOP

Briefcase Lock

CODE
begin CodeLock_Briefcase

short status
; 0 - initialization
; -1 - locked and standby
; 2 - locked and activated
; 3 - processing buttons
; -4 - unlocked and standby
; 5 - unlocked and activated
; 6 - processing lockpicking
; 7 - blocking from reaction to OpenLockFail sound more than once

short codesum
short code1
short code2
short code3
short code4
short lock1
short lock2
short lock3
short lock4
short locksum
short button
short pickable
float chance
short i
short j

if ( OnActivate == 1 )
if ( status == -4 )
set status to 5
else
set status to 2
endif
endif

if ( GetSoundPlaying "Open Lock Fail" == 1 )
if ( status == -1 )
set status to 6
return
endif
endif

if ( status < 0 )
return
endif

if ( status == 7 )
if ( GetSoundPlaying "Open Lock Fail" == 0 )
set status to -1
endif
return
endif

if ( status == 0 )
set pickable to 100; <= This is the difficulty of the lock regarding lockpicking. Set it to 0 if you don't want the lock to be pickable at all
set code1 to 4; <= This is the combination that opens the lock. Edit at will... and don't forget to give it to player somehow
set code2 to 8; <=
set code3 to 1; <=
set code4 to 0; <=
set codesum to ( code1 * 1000 ) +  ( code2 * 100 ) + ( code3 * 10 ) + code4
set lock1 to Random, 10
set lock2 to Random, 10
set lock3 to Random, 10
set lock4 to Random, 10
if ( pickable > 0 )
Lock 10000; It *must* be insanely high regardless of the intended difficulty - do not change
endif
set status to -1
endif

if ( status == 5 )
Activate
set status to -4
endif

if ( status == 2 )
; MessageBox "Enter the code number:| %.0f    %.0f    %.0f    %.0f", lock1, lock2, lock3, lock4, "  ", "  ", "  ", "  ", "Exit"
MessageBox "  %.0f    %.0f    %.0f    %.0f             ", lock1, lock2, lock3, lock4, "  ", "  ", "  ", "  ", "Exit"
set status to 3
endif

if ( status == 3 )
set button to GetButtonPressed
if ( button == -1 )
return
elseif ( button == 0 )
set lock1 to lock1 + 1
if ( lock1 == 10 )
 set lock1 to 0
endif
elseif ( button == 1 )
set lock2 to lock2 + 1
if ( lock2 == 10 )
 set lock2 to 0
endif
elseif ( button == 2 )
set lock3 to lock3 + 1
if ( lock3 == 10 )
 set lock3 to 0
endif
elseif ( button == 3 )
set lock4 to lock4 + 1
if ( lock4 == 10 )
 set lock4 to 0
endif
elseif ( button == 4 )
set status to -1
return
endif
set locksum to ( lock1 * 1000 ) +  ( lock2 * 100 ) + ( lock3 * 10 ) + lock4
if ( locksum == codesum )
set status to 5
PlaySound "Open Lock"
if ( pickable > 0 )
 Unlock
endif
else
set status to 2
PlaySound "LockedChest"
endif
endif

if ( status == 6 )
set chance to ( Player->GetSecurity )
set chance to ( chance * chance * chance )
set chance to ( chance / 10000 )
set i to Random, 20
set chance to ( chance + i )
set i to ( Player->GetLuck )
set i to ( i / 10 )
set chance to ( chance + i )
;messagebox "Security + Random + Luck chance %.3f" chance

if ( Player->GetItemCount       "skeleton_key" > 0 ); Morrowind only
; if ( Player->HasItemEquipped "skeleton_key" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 2 )
elseif ( Player->GetItemCount       "pick_secretmaster" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_secretmaster" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 1.2 )
elseif ( Player->GetItemCount       "pick_grandmaster" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_grandmaster" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 1.1 )
elseif ( Player->GetItemCount       "pick_master" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_master" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 1.0 )
elseif ( Player->GetItemCount       "pick_journeyman_01" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_journeyman_01" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 0.8 )
elseif ( Player->GetItemCount       "pick_apprentice_01" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_apprentice_01" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 0.6 )
endif
;messagebox "Total chance %.3f" chance

if ( ( Chance * 2 ) < pickable )
set status to 7
MessageBox "You have no slightest idea how to crack this lock"
return
endif
if ( ( Chance * 1.5 ) < pickable )
set status to 7
MessageBox "You tamper with the lock but have no success this time"
return
endif
if ( ( Chance * 1.2 ) < pickable )
set status to 7
MessageBox "You almost pick up one of triggers but at the last moment it's off"
return
endif
set j to Random, 40; choosing random digit out of 4
set i to j / 10
set j to 0

if ( i == 0 ); skipping digits already picked
if ( lock1 == code1 ); this fragment is repeated twice on purpose!
 set i to 1
endif
endif
if ( i == 1 )
if ( lock2 == code2 )
 set i to 2
endif
endif
if ( i == 2 )
if ( lock3 == code3 )
 set i to 3
endif
endif
if ( i == 3 )
if ( lock4 == code4 )
 set i to 0
endif
endif
if ( i == 0 )
if ( lock1 == code1 )
 set i to 1
endif
endif
if ( i == 1 )
if ( lock2 == code2 )
 set i to 2
endif
endif
if ( i == 2 )
if ( lock3 == code3 )
 set i to 3
endif
endif
if ( i == 3 )
if ( lock4 == code4 )
 set i to 0; it should never occur, but version with "while" would occasionally hang the program
messagebox "Program alert"; into eternal loop, so maybe I'm missing something. Mail me if you see this message
endif
endif

if ( i == 0 )
if ( Chance < pickable )
 if ( lock1 < code1 )
  MessageBox "You get the feeling that the first digit must be higher"
  set lock1 to lock1 + 1
 else
  MessageBox "You get the feeling that the first digit must be lower"
  set lock1 to lock1 - 1
 endif
else
 set lock1 to code1
 MessageBox "You manage to figure the first digit of the code. It is ' %.0f '", code1
endif
set status to 7
elseif ( i == 1 )
if ( Chance < pickable )
 if ( lock2 < code2 )
  MessageBox "You get the feeling that the second digit must be higher"
  set lock2 to lock2 + 1
 else
  MessageBox "You get the feeling that the second digit must be lower"
  set lock2 to lock2 - 1
 endif
else
 set lock2 to code2
 MessageBox "You manage to figure the second digit of the code. It is ' %.0f '", code2
endif
elseif ( i == 2 )
if ( Chance < pickable )
 if ( lock3 < code3 )
  MessageBox "You get the feeling that the third digit must be higher"
  set lock3 to lock3 + 1
 else
  MessageBox "You get the feeling that the third digit must be lower"
  set lock3 to lock3 - 1
 endif
else
 set lock3 to code3
 MessageBox "You manage to figure the third digit of the code. It is ' %.0f '", code3
endif
elseif ( i == 3 )
if ( Chance < pickable )
 if ( lock4 < code4 )
  MessageBox "You get the feeling that the fourth digit must be higher"
  set lock4 to lock4 + 1
 else
  MessageBox "You get the feeling that the fourth digit must be lower"
  set lock4 to lock4 - 1
 endif
else
 set lock4 to code4
 MessageBox "You manage to figure the fourth digit of the code. It is ' %.0f '", code4
endif
endif

set status to 7
set locksum to ( lock1 * 1000 ) +  ( lock2 * 100 ) + ( lock3 * 10 ) + lock4
if ( locksum == codesum )
set status to 5
MessageBox "You've successfully picked the code lock"
if ( pickable > 0 )
 Unlock
endif
PlaySound "Open Lock"
endif

endif

end

Keypad lock

TOP

CODE
begin CodeLock_Numpad1

short status
; 0 - initialization
; -1 - locked and standby
; 2 - locked and activated
; 3 - processing buttons
; -4 - unlocked and standby
; 5 - unlocked and activated
; 6 - processing lockpicking
; 7 - blocking from reaction to OpenLockFail sound more than once

long codesum
long code
short lock_length
short lock_order
short code1
short code2
short code3
short code4
short code5
short code6
short code7
short code8
short code9
short code10
short code11
short code12
short code13
short code14
short code15

short button
short pickable
float chance
short doonce
short correct
short i

if ( OnActivate == 1 )
if ( status == -4 )
set status to 5
else
set status to 2
set lock_order to 1
set codesum to 0
endif
endif

if ( GetSoundPlaying "Open Lock Fail" == 1 )
if ( status == -1 )
set status to 6
endif
endif

if ( status < 0 )
return
endif

if ( status == 7 )
if ( GetSoundPlaying "Open Lock Fail" == 0 )
set status to -1
endif
return
endif

if ( status == 0 )
set pickable to 100; <= This is the difficulty of the lock regarding lockpicking. Set it to 0 if you don't want the lock to be pickable at all
set lock_length to 9; <= this is the lenght of code combination (maximum is 9 digits)
set code1 to 1; <= this is the combination that opens the lock
set code2 to 1; <= (no zeroes - there can be only up to 9 buttons in MessageBox!)
set code3 to 2; <=
set code4 to 2; <=
set code5 to 3; <=
set code6 to 3; <=
set code7 to 4; <=
set code8 to 4; <=
set code9 to 5; <=
set code to 0
if ( lock_length >= 1 )
set code to ( code * 10 ) + code1
endif
if ( lock_length >= 2 )
set code to ( code * 10 ) + code2
endif
if ( lock_length >= 3 )
set code to ( code * 10 ) + code3
endif
if ( lock_length >= 4 )
set code to ( code * 10 ) + code4
endif
if ( lock_length >= 5 )
set code to ( code * 10 ) + code5
endif
if ( lock_length >= 6 )
set code to ( code * 10 ) + code6
endif
if ( lock_length >= 7 )
set code to ( code * 10 ) + code7
endif
if ( lock_length >= 8 )
set code to ( code * 10 ) + code8
endif
if ( lock_length >= 9 )
set code to ( code * 10 ) + code9
endif
if ( pickable > 0 )
Lock 10000; It *must* be insanely high regardless of the intended difficulty - do not change!
endif
set status to -1
endif

if ( status == 5 )
Activate
set status to -4
endif

if ( status == 2 )
MessageBox "       Enter the code sequence: %.0f         ", codesum, "1", "2", "3", "4", "5", "6", "7", "8", "9"
set status to 3
endif

if ( status == 3 )
set button to GetButtonPressed + 1
if ( button == 0 )
return
endif
set codesum to codesum * 10
set codesum to codesum + button
set lock_order to lock_order + 1

if ( lock_order > lock_length )
if ( codesum == code )
;   Activate
 set status to 5
 PlaySound "Open Lock"
 Unlock
else
 set status to 7
 PlaySound "Open Lock Fail"
endif
else
set status to 2
PlaySound "LockedChest"
endif
endif

if ( status == 6 )
set chance to ( Player->GetSecurity )
set chance to ( chance * chance * chance )
set chance to ( chance / 10000 )
set i to Random, 20
set chance to ( chance + i )
set i to ( Player->GetLuck )
set i to ( i / 10 )
set chance to ( chance + i )
;messagebox "Security + Random + Luck chance %.3f" chance

if ( Player->GetItemCount       "skeleton_key" > 0 ); Morrowind only
; if ( Player->HasItemEquipped "skeleton_key" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 2 )
elseif ( Player->GetItemCount       "pick_secretmaster" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_secretmaster" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 1.2 )
elseif ( Player->GetItemCount       "pick_grandmaster" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_grandmaster" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 1.1 )
elseif ( Player->GetItemCount       "pick_master" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_master" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 1.0 )
elseif ( Player->GetItemCount       "pick_journeyman_01" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_journeyman_01" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 0.8 )
elseif ( Player->GetItemCount       "pick_apprentice_01" > 0 ); Morrowind only
; elseif ( Player->HasItemEquipped "pick_apprentice_01" > 0 ); Tribunal/Bloodmoon
set chance to ( chance * 0.6 )
endif
;messagebox "Total chance %.3f" chance

set status to 7
if ( ( Chance * 1.5 ) < pickable )
 MessageBox "You have no slightest idea how to crack this lock"
return
endif
if ( ( Chance * 1.2 ) < pickable )
 MessageBox "You need more skill and better tools to crack this lock"
return
endif
if ( Chance < pickable )
MessageBox "You tamper with the lock but have no success this time"
return
endif
set i to 1000
while ( i >= lock_length )
set i to Random, 9
endwhile
if ( i == 0 )
MessageBox "You believe that the first digit of the code should be %.0f", code1
endif
if ( i == 1 )
MessageBox "You believe that the second digit of the code should be %.0f", code2
endif
if ( i == 2 )
MessageBox "You believe that the third digit of the code should be %.0f", code3
endif
if ( i == 3 )
MessageBox "You believe that the fourth digit of the code should be %.0f", code4
endif
if ( i == 4 )
MessageBox "You believe that the fifth digit of the code should be %.0f", code5
endif
if ( i == 5 )
MessageBox "You believe that the sixth digit of the code should be %.0f", code6
endif
if ( i == 6 )
MessageBox "You believe that the seventh digit of the code should be %.0f", code7
endif
if ( i == 7 )
MessageBox "You believe that the eighth digit of the code should be %.0f", code8
endif
if ( i == 8 )
MessageBox "You believe that the ninth digit of the code should be %.0f", code9
endif
endif

end

MAGIC

TOP

Magic regeneration

This global script makes the PC's (and only the PC's) Magicka gradually regenerate.
I find it better than sleeping 26 hours at a stretch.
Note that the formula can be changed, as well as the time.

CODE
begin Global_MagickaRegeneration
     
     float regen
     float timer
     float will
     
     if ( MenuMode == 1 )
         return
     endif
     
     set timer to ( timer + GetSecondsPassed )
     if ( timer < 5 )
         return
     else
         set will to ( player->getwillpower )
         set regen to ( ( will +5) / 10 )
         player->modcurrentmagicka, regen
         set timer to 0
     endif
     
end

MISC

TOP

Keg Script

CODE
begin PRH_Keg_Mazte
short quantity
short activated
short button

if ( onActivate == 1 )
MessageBox "%.3g servings." quantity, "Unload your Mazte", "Pour 1 bottle", "Pour 10 bottles", "Have a drink!", "Load me up!", "Finished"
set activated to 1
endif

if ( activated != 0 )
Set button to GetButtonPressed
If ( button == -1 )
 return
Elseif ( button == 0 );Unload your Mazte
 set activated to player -> getItemCount "Potion_Local_Brew_01"
 if ( activated > 0 )
  while ( activated > 0 )
   set quantity to quantity + 1
   set activated to activated - 1
   player -> removeItem "Potion_Local_Brew_01" 1
  endwhile
  playSound "Item Potion Up"
  MessageBox "You now have %.3g servings." quantity
 else
  MessageBox "You don't have any Mazte to unload."
 endif
elseif ( button == 1 );Pour 1 bottle
 if ( quantity >= 1 )
  set quantity to quantity - 1
  player -> addItem "Potion_Local_Brew_01" 1
  MessageBox "1 bottles poured.  You have %.3g servings left." quantity
  playSound "Item Potion Up"
 else
  MessageBox "Sorry, you're all out of Mazte."
 endif
elseif ( button == 2 );Pour 10 bottles
 if ( quantity >= 10 )
  set quantity to quantity - 10
  player -> addItem "Potion_Local_Brew_01" 10
  MessageBox "10 bottles poured.  You have %.3g servings left." quantity
  playSound "Item Potion Up"
 elseif ( quantity > 0 )
  MessageBox "You don't have enough for 10 bottles.  Here's %.3g bottles." quantity
  while ( quantity > 0 )
   set quantity to quantity - 1
   player -> addItem "Potion_Local_Brew_01" 1
  endwhile
  playSound "Item Potion Up"
 else
  MessageBox "Sorry, you're all out of Mazte."
 endif
elseif ( button == 3 );Have a drink!
 if ( quantity > 0 )
  if ( player -> getSpellEffects, "PRH_Drink_Mazte" == 1 )
   MessageBox "You just had one.  Wait until it wears off first."
  else
   set quantity to quantity - 1
   MessageBox "Down the hatch!  You have %.3g servings left." quantity
   cast "PRH_Drink_Mazte", player
   playSound "Item Potion Up"
  endif
 else
  MessageBox "Sorry, you're all out of Mazte."
 endif
elseif ( button == 4 );Load me up!
 if ( quantity > 0 )
  set activated to 0
  while ( quantity > 0 )
   set quantity to quantity - 1
   set activated to activated + 1
   player -> addItem "Potion_Local_Brew_01" 1
  endwhile
  playSound "Item Potion Up"
  MessageBox "%.3g bottles poured." activated
 else
  MessageBox "Sorry, you're all out of Mazte."
 endif
else
 set activated to 0
endif
endif
end

Trash Can

TOP

CODE
begin container_reset_scr

;original script by Boblen1982 - rewritten by IxidorsBane

short deltimer
;object_reset - glob.variable to start deleting container

if ( object_reset == 0 )
if ( deltimer != 0 )
 set deltimer to 0
endif
return
endif

if ( object_reset == 1 )
if ( deltimer == 0 )
 Disable
endif
if ( deltimer < 4 )
 set deltimer to ( deltimer + 1 )
endif
if ( deltimer == 4 )
 set object_reset to 0
 set deltimer to ( deltimer + 1 )
endif
if ( deltimer == 5 )
 SetDelete, 1
endif
endif

end
-----------part II----------To be put on a hidden activator (a ring under the floor, etc.)

CODE
begin object_activator

;original script by Boblen1982 - rewritten by IxidorsBane

short active
short message_state
short buton
short object_timer
short currentDay
;object_reset - glob.variable to start deleting container

if ( currentDay != Day )
set currentDay to Day
set active to 1
endif

if ( active == 0 )
return
endif

if ( active == 1 )
set active to 2
set object_timer to 0
endif

if ( active == 2 )
set object_reset to 1
set active to 3
elseif ( active == 3 )
set object_timer to ( object_timer + 1 )
if ( object_timer < 6 )
 return
else
 set active to 4
endif
elseif ( active == 4 )
PlaceItem Your Object xPos, yPos, zPos, zAng
set object_timer to 0
set active to 0
endif

end

TOP

MUSIC

Over-Riding Battle Music

This script causes a certain music file to be played and overrides battle music. I always thought battle music ruined the element of suprise in MW, as levitation magic ruins the fun of exploration.

First make two rats, one called "music rat 01" and another called "music rat 01b", check the references persist tab on rat01b. Give each of them a constant paralyze ability. Place this script on "music rat 01":

CODE
begin no_battle_music

Float timer
Short doOnce

set timer to ( timer + getSecondsPassed )

if ( CellChanged == 1 )
    set doOnce to 0
endif

if ( doOnce == 2 )
    if ( timer > 112 ); insert the length of your track (in seconds) here
        StreamMusic "explore\Morrowind title.mp3"; insert your track name here
        set timer to 0
    endif
    
elseif ( doOnce == 1 )
    if ( timer > 1 )
        StreamMusic "explore\Morrowind title.mp3"; insert your track name here
        set doOnce to 2
        set timer to 0
    endif

elseif ( doOnce == 0 )
    StartCombat "music_rat01b"
    set timer to 0
    set doOnce to 1
endif

end no_battle_music

Then place each of them in the cell somewhere where you cant see them like under a rock or something. They will try to fight one another but wont be able to move due to the paralyse ability. The music file you scripted on the other one will loop over and over as long as you are in the cell and will not be interuppted by battle music.

I got this idea from another poster on this forum but the original had just one rat that attacked the player. The problem with that version is that any NPCs or creatures with startcombat scripted on them caused battle music to play again. This one is foolproof.

NPCs

TOP

Changing NPCs clothes daily

Here’s a simple script to make a npc wear different outfits on different days, for each day of the week, and pjs at night. substitute or add lines for whatever outfits you want. they do not have to be in it's inventory, the equip command additems and equips to npcs.

CODE

begin laundryscript

short currentday
short localday
short shirtchange
short pajammas

if ( currentday != Day )
 set currentday to day
 set localday to ( localday + 1 )
 set shirtchange to 0
endif

if ( pajammas == 0 )
 if ( gamehour >= 20 )
   equip, "nightgown"
   set pajammas to 1
endif

if ( shirtchange == 0 )

 if ( localday == 1 )
   if ( gamehour >= 6 )
     equip, "extravagant_robe_01_c"
     set shirtchange to 1
     set pajammas to 0
   endif
 endif

 if ( localday == 2 )
   if ( gamehour >= 6 )
     equip, "extravagant_robe_01_h"
     set shirtchange to 1
     set pajammas to 0
   endif
 endif

 if ( localday == 3 )
   if ( gamehour >= 6 )
     equip, "extravagant_robe_01_r"
     set shirtchange to 1
     set pajammas to 0
   endif
 endif

 if ( localday == 4 )
   if ( gamehour >= 6 )
     equip, "extravagant_robe_01_t"
     set shirtchange to 1
     set pajammas to 0
   endif
 endif

 if ( localday == 5 )
   if ( gamehour >= 6 )
     equip, "extravagant_robe_01"
     set shirtchange to 1
     set pajammas to 0
   endif
 endif

 if ( localday == 6 )
   if ( gamehour >= 6 )
     equip, "extravagant_robe_01_a"
     set shirtchange to 1
     set pajammas to 0
   endif
 endif

 if ( localday == 7 )
   if ( gamehour >= 6 )
     equip, "extravagant_robe_01_b"
     set shirtchange to 1
     set pajammas to 0
     set localday to 0
   endif
 endif

endif

end laundryscript

TOP

Disposition

This one is VERY simple, but I seem to remember people asking about NPC disposition control a lot in the past. Sets an NPC's in-game (not base) disposition to match a variable NPC_Disp.

CODE
begin NPC_local_script

float temp

;short NPC_Disp
;can be local or global, as needed
;can also be a float if you like but not necessary unless you want to mod disp by a float value

if ( MenuMode == 1 )
    if ( NPC_Disp < 0 )
        set NPC_Disp to 0
    elseif ( NPC_Disp > 100 )
        set NPC_Disp to 100
    endif
    set temp to ( GetDisposition )
    set temp to ( NPC_Disp - temp )
    ModDisposition temp
endif

end

The only way to change the NPC's disposition is to set NPC_Disp, nothing else will have any effect. So no "ModDisposition 10", it's "set NPC_Disp to ( NPC_Disp + 10 )". 

Enforced clothing for a companion 

TOP

The concept is for a companion to have their own outfit and not wear the stuff you really just want them to carry for you. This is the simple version, the one I'm using in the mod will allow the player to choose from several outfits.

The script is started in the result box of the companions greetings. When you give the companion things to carry, if they are more valuable or have a better armor rating then the companions personl stuff then they will immediately put them on. Once the dialog ends this script removes all clothes and re-equips the companions personal outfit. This would work for a merchant as well.

The items ZZA_strip_01 through ZZA_strip_05 - are a set of clothing and armor that cover all body parts, ensuring the removal of all clothing/armor. The items ZZA_Comp_outfit_1 and ZZA_Comp_outfit_2 are the companions personal armor and boots.

The potential for abuse exists in that it is easy for the player to create an infinate number of the companions outfit by removeing them each time. When I included checks to see if the companion still possed the outfit it slowed the redressing down too much (at least in the complicated multioutfit version). If someone is going to exploit this, they can just use the console to give themselves a bunch of money much more easily, so I didn't worry about it. (Except to make the companions outfit only worth 1 gold piece).

CODE
Begin ZZA_comp_dress_script

short counter

If ( menumode == 1 )
  return
endif

if ( counter < 3 )      ;when called from a greeting the script will run before menu mode
    set counter to ( counter + 1 );registers, this delay prevents that.
    return
endif

If ( GetHealth <= 0 )                ;just in case
    stopscript ZZA_Slave_nodress_script
    return
endif

equip ZZA_strip_01
equip ZZA_strip_02
equip ZZA_strip_03
equip ZZA_strip_04
equip ZZA_strip_05
removeitem ZZA_strip_01 1
removeitem ZZA_strip_02 1
removeitem ZZA_strip_03 1
removeitem ZZA_strip_04 1
removeitem ZZA_strip_05 1

equip ZZA_Comp_outfit_1
equip ZZA_Comp_outfit_2

set counter to 0

stopscript ZZA_comp_dress_script

end

Making NPC’s fight

TOP

This script could be placed on one or the other NPC, or even on a hidden activator in their cell if there is some reason you do not want the script attached to an NPC. I do not know what distance you want them for combat to begin, but you can play with the distance value I am using until you are satisfied.

CODE
Begin Kite_NPCDuel

short doOnce

if ( doOnce == 1 )
   return
endif

if ( ( “NPC1_ID”->GetDistance “NPC2_ID” ) > 2000 ); change ‘2000’ as needed
   return
endif

set doOnce to 1

“NPC1_ID”->SetFight 100
“NPC2_ID”->SetFight 100
“NPC1_ID”->SetFlee 0
“NPC2_ID”->SetFlee 0
“NPC1_ID”->StartCombat “NPC2_ID”
“NPC2_ID”->StartCombat “NPC1_ID”

End Kite_NPCDuel

Making them fight 2

TOP

This script should be placed on NPC1, and another on NPC2. However, the script for NPC2 should have the locations on NPC1 and NPC2 reversed.

Begin fightNPC1

Short NoLore
short doonceA

if ( CellChanged == 0 )
    Return
endif

if ( doonceA == 0 )
	if ( GetDeadCount NPC2 == 0 )
	    StartCombat NPC2
	    set doonceA to 1
	endif
endif

End fight NPC1

TOP

Making them fight two NPCs

To make an NPC fight with two NPCs, NPC 1 uses this script, NPCs 2 & 3 use the above script, suitably altered.

Begin fightNPC1

Short NoLore
short doonceA
short doonceB
 
if ( CellChanged == 0 )
    Return
endif

if ( doonceA == 0 )
	if ( GetDeadCount "NPC2" == 0 )
	    StartCombat "NPC2"
	    set doonceA to 1
	endif
endif

if ( doonceB == 0 )
	if ( GetDeadCount "NPC3" == 0 )
	    StartCombat "NPC3"
	    set doonceB to 1
	endif
endif

End fightNPC1
Making Companions warp to you

TOP

This script is used a lot, it's Grumpy's companion script which causes a companion to "warp" back to you if 
it gets too far away ( meaning that it's stuck in a hedge or something ).

You still need to put the companion in follow mode through dialogue/script.
CODE
float myx 
float myy 
float myz 
float timer 

if ( GetCurrentAIPackage == 3 ) 
if ( Player->GetEffect sEffectLevitate == 1 ) 
AIWander 0 0 0 0 
endif 

if ( GetWeaponDrawn == 1 ) 
return 
elseif ( GetDistance Player > 800 ) 
set timer to timer + GetSecondsPassed 
if ( timer > 8 ) 
set timer to 0 
set myx to ( Player->GetPos x ) 
set myy to ( Player->GetPos y ) 
set myz to ( Player->GetPos z ) 
SetPos x myx 
SetPos y myy 
SetPos z myz 
endif 
endif 
endif 
endif 

Mannequins

TOP

Simple Mannequin 
A simple mannequin script. This freezes an NPC into position so the player can put armour on them. They're fun but disturbingly detailed for mannequins.

The simplest one is this:
CODE
begin simple_mannequin
skipanim
end

You put it on an NPC with 0 life and "corpses persist" checked, their body stays upright. Problem is you can get rid of them if you hit "dispose of corpse" when activating them. 

TOP

ARMOR MANNEQUINS - Wooden Armor Mannequins by Chris Janosi. These are non-weapon wielding & they are moveable so you need the placeholder script, which is provided here also. 	
;script operates armor mannequins it came from Chris Janosi 
begin SA_mannequin
short button
short questionState
SkipAnim

if ( menumode == 1 )
return
endif
if ( OnActivate == 0 )
if ( questionState == 0 )
return
endif
endif
if ( questionState == 0 )
MessageBox, "Armor Mannequin", "Move Mannequin", "Add/Remove Armor"
set questionState to 1
endif
if ( questionState == 1 )
set button to GetButtonPressed
if ( button == 0 )
set questionState to 10
elseif ( button == 1 )
set questionState to 0
Activate
endif
endif
if ( questionState == 10 )
MessageBox "Did you remove all items from the mannequin?", "Yes", "No"
set questionState to 20
endif
if ( questionState == 20 )
set button to GetButtonPressed

TOP

if ( button == 0 )
set questionState to 0
Disable
player->addItem, "_SA_armorman_placeholder", 1
playSound "Item Misc Up"
elseif ( button == 1 )
set questionState to 0
Activate
endif
endif
end SA_mannequin	
ARMOR MANNEQUIN PLACEHOLDER SCRIPT- used with the above script for Chris Janosi Mannequins 	
;script operates armor mannequin placeholders it came from Chris Janosi 
begin SA_mannequinplaceholder
short OnPCDrop
if ( OnPCDrop == 1 )
Disable
; PlaceAtPC, "_SA_ArmorMann_Wooden", 1, 64, 0
PlaceAtPC, "_SA_ArmorMann_Wooden", 1, 0, 0
Set OnPCDrop to 0
endif
end SA_mannequinplaceholder	

Pacifying NPCs

TOP

CODE
begin punching_Bag
  short OnPCHitMe

  if ( OnPCHitMe == 1 )
      set OnPCHitMe to 0
      stopCombat, player
;Here's a good place to play some sort of sound or whatever.
  endif
end

TOP

CREATURES

Appearing Skeleton Traped chest

Script 1 (on chest)
begin _Cursed_Chest
short doOnce

if ( OnActivate == 1 )
	if ( doOnce == 1 )
		Activate
		return
	else
		MessageBox "You suddenly feel quite cold..."

		"contain_corpse_XXX1"->Disable
		"skeleton champ_XXX1"->Enable
		set "skeleton champ_XXX1".getimBoy to 1

		"contain_corpse_XXX2"->Disable
		"skeleton champ_XXX2"->Enable
		set "skeleton champ_XXX2".getimBoy to 1

		Set doOnce to 1
	endif
endif

End

Script 2 (on all skeletons)
begin BILL_GTs_Skeletal_Guardians
short getimBoy

if ( CellChanged == 1 )
	Disable
endif

if ( MenuMode == 1 )
	return
endif

if ( getimBoy == 1 )
	if ( GetTarget "Player" == 0 )
		StartCombat Player
	endif
endif

End

TOP

Making creatures appear by invisible activator

This one however makes monsters or NPCs warp into existance when you get near a certain invisible marker. 

First make a global variable. Call it something like "warp var01".

Now attach this script to the enemy you want to do the warping:

CODE
begin warpCreat01_script

short state
short playonce
short doonce
float timer
float xpos
float ypos
float zpos

if ( MenuMode == 1 )
    return
;don't run time in Menu Mode. Very bad.
endif

if ( GetDisabled == 0 )
If (state==0)
Disable
set state to 1
endif
endif

if ( warp var01 == 1 ) 
If ( doonce == 0 )
set xpos to ( GetPos, X )
set ypos to ( GetPos, Y )
set zpos to ( GetPos, Z )
set zpos to ( zpos +30 )
Placeitem "sprigganup" xpos ypos zpos 0
Enable
set doonce to 1
set playonce to 1
endif
endif

If ( playonce == 1 )

set timer to ( timer + GetSecondsPassed )    

If ( timer >= 0.50 )
SetFight 100
Startcombat Player
Set playonce to 2
endif
endif

end

And of course the good ol' trigger script to cause the warp to take effect when you get near the invisible marker. I reccomend using the activator mesh with the sound effect scripts on them. You can use the same global variable as the above script but you should not use them both in the same cell.

CODE
begin WarpTrig01_script

short doonce 

if ( MenuMode == 1 ) 
return 
endif 

If ( GetDistance, Player <= 128 )
if ( doonce == 0 ) 
set warp var01 to 1
set doonce to 1
endif
endif

end

Just place the scripted enemy in the cell wherever you want them to appear. You can use as many of them as you want, so you could have ten of them appear to surround the player when they get near an important item. They dont just appear out of thin air either, they appear with a flash of light and pause for a split second before attacking which makes the effect seem more intresting. Oh, make sure to set their fight AI to 0 otherwise the pause will be negated. 

Again, like the scripts in the above post, you must reset the variable when you leave the cell; see the reset script. That way the script can be used again and again.

TOP

Summon Creature on activating an item

begin BILL_MarksDaedraSummon
; Summon an Daedra when an item is removed from altar
;
; script location: should be placed upon an object on a Daedric Altar 

; variables
short done

if ( OnActivate == 1 )
	if ( done == 1 )
		Activate
		return
	else
		Set done to 1
		PlaceAtPC "Dremora_lord" 1 128 1
		;1 of them, 256 units away, in back (1) of the player
		Activate
	endif
endif

End
Visual effect on death

TOP

Heres one which places a special effect when a creature dies. It also disables the creature i.e making look like it diseapered in the magical vortex , just removed the disabled part if you want the creatures corpse to still be there.

CODE
If ( OnDeath == 1 )
    PlaceAtMe sprigganup 1 1 1; Visual effect
    Disable    
endif

DISPLAY CASES

TOP

DISPLAY CASES TYPE - Lady E's which have the glass lids that lower when activated. 	
; Activates the display case lid (_SA_dispcaselid) to slide up/down. 
; Creator of this script is Viking_ Lord from Anastasio The Great's Hideout
begin SA_displaycaselid
float Timer
short State
if ( MenuMode == 1 )
return
endif
if ( OnActivate ==1 ) 
if ( State == 0 )
PlaySound "Door Stone Open"
set State to 245
endif
endif
if ( State >= 245 )
set timer to ( timer + GetSecondsPassed )
;slide lid down
if ( Timer < 3 )
MoveWorld Z, -21

;set back to start
elseif ( Timer > 19 )
SetAtStart
set State to 0 ;can now press button again
set Timer to 0
elseif ( Timer > 16 )
if ( State == 245 )
PlaySound "Door Stone Close"
set State to 246
endif
MoveWorld Z, 21
endif
endif

TOP

end	
DISPLAY CASE TYPE - Indigo Rage's Display Cases w/the red fabric interior 	
;This script is from IndigoRage it operates the cases that have the red fabric on the bottom.
begin SA_Ind_displaycase
short state
short first
short open
short close
float timer
If (MenuMode == 1)
Return
endif
If (OnActivate == 1)
Set state to 1
endif
If (state == 1)
If (first == 0)
playgroup, idle2, 0
set open to 1
endif
endif
if (open == 1) 
set timer to ( timer + GetSecondsPassed )
if ( timer < 0.5 ) 
Return
endif
set timer to 0
playgroup, idle3
set first to 1
set state to 0
set open to 0
endif
if (state == 1)
if (first == 1)
playgroup, idle4, 0
set close to 1
endif
endif

TOP

if (close == 1)
set timer to ( timer + GetSecondsPassed )
if ( timer < 0.5 ) 
Return
endif
set timer to 0
playgroup, idle
set first to 0
set state to 0
set close to 0
endif
end SA_Ind_displaycase	
DISPLAY CASE TYPE - Dongle's Green Glass Display Cabinet	
;This script is from Dongle for use with the Green Glass Display Cases. 
Begin, SA_GlassDisplayScript
Short State
Short First
Short Open
Short Close
Float Timer
If ( MenuMode == 1 )
Return
EndIf
If ( OnActivate == 1 )
Set State to 1
EndIf
If ( State == 1 )
If ( First == 0 )
PlayGroup, Idle2, 0
PlaySound3D, "Door Creaky Open"
Set Open to 1
EndIf
EndIf
If ( Open == 1 )
Set Timer to ( Timer + GetSecondsPassed )
If ( Timer < 0.5 )
Return
EndIf
Set Timer to 0
PlayGroup, Idle3
Set First to 1
Set State to 0
Set Open to 0
EndIf
If ( State == 1 )
If ( First == 1 )
PlayGroup, Idle4, 0
PlaySound3D, "Door Creaky Close"
Set Close to 1
EndIf
EndIf
If ( Close == 1 )
Set Timer to ( Timer + GetSecondsPassed )
If ( Timer < 0.5 )
Return
EndIf
Set Timer to 0
PlayGroup, Idle
Set First to 0
Set State to 0
Set Close to 0
EndIf
End, SA_GlassDisplayScript	

DOORS

TOP

Tribunal’s dark hole script – a door with an option to pass through

CODE
Begin DoorScript 
short button 
short messageOn 
; this part gives you your choice on activating the Door 
if ( OnActivate == 1 ) 
MessageBox "Do you wish pass through the door?" "Yes" "No" 
set messageOn to 1 
endif 
if ( messageOn == 1 ) 
set button to GetButtonPressed 
;resets the variable so you can use the door multiple times 
if ( button >= 0 ) 
set messageOn to 0 
endif 
;should send you through the door normally 
if ( button == 0 ) 
Activate 
; should just reset the script, allowing you to do it again 
elseif ( button == 1 ) 
set button to 0 
return 
endif 
endif 
End DoorScript

Door Lock script.

TOP

CODE
Begin Door_lock

If ( OnActivate == 1 )
If ( Player -> GetItemCount, "Door_key" >= 1 )
 Activate
Else; Either You have a Key, Or you don't
 MessageBox, "You need a key to open this door."
EndIf
EndIf

End

Alternate Door Lock Script

CODE
Begin Door_lock

If ( OnActivate )
 If ( Player->GetItemCount "Door_key" < 1 )
     playSound lockedDoor
     messageBox, "You need a key to open this door."
     return
 endif
 Activate
EndIf

End

Auto-Lock Doors

TOP

CODE
begin auto-relock_door_script

short activate_count
float relock_timer

DontSaveObject

if ( menumode == 1 )
   return
endif

;This part allows the player to open the door if they pick the lock or have
;the key in their inventory.
if ( GetLocked == 0 )
   if ( OnActivate == 1 )
        if ( activate_count < 2 )
             set activate_count to ( activate_count + 1 )
        endif
        Activate
   endif
else
   if ( OnActivate == 1 )
        if ( Player->GetItemCount, "door_key" >= 1 )
             Activate
             set activate_count to ( activate_count + 1 )
        else
             Activate
        endif
   endif
endif

;This section relocks the door once it's closed
if ( activate_count == 2 )
   if ( relock_timer < 2 )
        set relock_timer to ( relock_timer + GetSecondsPassed )
   elseif ( relock_timer >= 2 )
        Lock, 100
        PlaySound3D, "Open Lock"
        set activate_count to 0
        set relock_timer to 0
   endif
endif

end

Trapped Rug 

TOP

use a different spell for this one, you might have to create one.

CODE
begin Script_Trapped_Rug

short state

if ( menuMode == 1 )
  return
endif

if ( onActivate == 1 )
  return
endif

if ( state == 2 )
  return
else
  if ( getStandingPC == 1 )
      if ( state == 0 )
          cast sp_trap_fire_5x50 player

; Place code here to raise
; alarm, summon guards etc ...

          set state to 1
      endif
  else
      set state to 0
  endif
endif

if ( getSoundPlaying "Disarm Trap" == 1 )
  set state to 2
endif

end

Create a door using a rug model like f\Furn_rug_01.nif. Give it a name like "Handwoven Rug" and attach this script. Set the reference data to locked, level 0, with any trap spell.

TOP

Trapped Rug 2

I’m not sure if this is a door, static or activator script…

begin BILL_common_trapped_rug
; hits the player with a glyph of weakness when he walks on the rug.
; trap resets 15 seconds later.
;
; script location: should be called from ac_furn_rug_big_04_dren

; variables
short onMe		; is the Player on me?
short wait
float timer

if ( MenuMode == 1 )
	return
endif

if ( wait == 1 )
	set timer to ( timer + GetSecondsPassed )
	if ( timer < 15 )
		return
	else
		set timer to 0
		set wait to 0
	endif
endif

set onMe to ( GetStandingPC )
if ( onMe == 1 )
	MessageBox, "You have triggered a trap..."
	Cast, "sp_glyphofweakness", Player
	set wait  to 1
endif

end BILL_common_trapped_rug

TIMERS

TOP

Timer 1

Well, here's a timer
Placed on an activator, it'll make it do something five seconds after activation.
CODE
begin activate_timer

float timer
short doonce1
short doonce2

if ( OnActivate == 1 )
if ( doonce2 == 0 )
set doonce1 to 0
set doonce2 to 1
set timer to ( timer + GetSecondspassed )
if ( timer > 5 )
if ( doonce1 == 0 )
;do something here
set doonce1 to 1
set doonce2 to 0 
set timer to 0
endif 
endif
endif
end

Or perhaps it would work with timer=5, and one fewer doonce? Dunno...