Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Trigger Scripts


Tonycubed2
 Share

Recommended Posts

  • 2 weeks later...

Simple Trigger box

Enter and Exiting them

Here is a simple trigger box including how to set it up.

1. Make a new >Activator.

Give it an ID, but no name or model. Give it a default primitive color (usually red) and save it.

2. Make your script for the above new activator you made. It will extend the 'ObjectReference'. Save and compile it.

Scriptname DefaultTriggerScript extends ObjectReference  
{demo look at a trigger zone}

EVENT onTriggerEnter(objectReference triggerRef)
if triggerRef == GetPlayer()
Debug.MessageBox("Enter the Zone!")
endif
endEvent

EVENT OnTriggerLeave(objectReference triggerRef)
if triggerRef == GetPlayer()
Debug.MessageBox("Exit the Zone!")
endif
endEvent[/code]

3. On your activator, attach the script to it.

4. Click on an object in the render window where you want the trigger zone to appear.

5. On the toolbar, the 'box with a T' in it is called 'Create Trigger'. Click it and a box will appear around the object you clicked on in #4 above. You can use the arrows that come with it to resize the trigger zone box.

6. Once you have placed your triggerzone, double-click on it and if you want the player to be able to activate it, put a check mark in the 'Player Activation' box.

Now save your mod and test.

Doesn't work? change the angle of the triggerzone box by a degree and test again.

Link to comment
Share on other sites

  • 2 months later...

Play Sound Effect and Explosion Script

This is a script that was made by WillieSea upon request and edited somewhat by myself.

The purpose of this script is to play a sound effect when a trigger is activated and to place a particular explosion at the player.

WillieSea's original script:

Scriptname MyTriggerBoxScript extends ObjectReference  

{Attached to triggerzone}

Sound Property QSTAstrolabeButtonPressX  Auto


Event OnTriggerEnter (objectReference activateRef)

        if activateRef == Game.GetPlayer()

                QSTAstrolabeButtonPressX.Play(Self)

                ;Depends on what you want to do

        endif

endEvent
My edited version of WillieSea's script:
Scriptname MODPlayEffectonEnterTrigger extends ObjectReference    

{Attached to triggerzone}


Sound Property QSTAstrolabeButtonPressX  Auto

Explosion Property MGEyeOpenExplosion Auto


Event OnTriggerEnter (objectReference activateRef)

        if activateRef == Game.GetPlayer()

                QSTAstrolabeButtonPressX.Play(Self)

                        placeAtMe(MGEyeOpenExplosion)

                ;Depends on what you want to do

        endif

endEvent

Please take note! That the reason I edited WillieSea's script was because I did not manage to get it to work in the state that it was in. With minor tweaking and just about all the legwork already done for me, I have found the edited version to function without any problems so far.

Edited by Altrunchen
Link to comment
Share on other sites

  • 1 year later...

This will close a door visually...

 

Scriptname CloseMyDoorScript extends ObjectReference

ObjectReference Property MyDoor auto

Event OnTriggerEnter(ObjectReference akActionRef)
	if akActionRef == Game.GetPlayer()
		MyDoor.SetOpen(false)
	endif
EndEvent

If you need it to be locked you can also add the Lock command.

Link to comment
Share on other sites

Another question. Does this script look right to allow the player and or NPC's to activate the trigger?

Scriptname CloseMyDoorScript extends ObjectReference

ObjectReference Property MyDoor auto

Event OnTriggerEnter( ObjectReference akActionRef )

if akActionRef == Game. GetPlayer()

elseif akActionRef != PlayerREF

MyDoor. SetOpen (false )

endif

EndEvent

Link to comment
Share on other sites

Believe I figured it out

Scriptname CloseMyDoorScript extends ObjectReference

ObjectReference Property MyDoor auto

Event OnTriggerEnter(ObjectReference akActionRef)
    if akActionRef == Game.GetPlayer()
        MyDoor.SetOpen(false)
    elseif akActionRef != Game.GetPlayer()
        MyDoor.SetOpen(false)
    endif
EndEvent

Now my NPC;s aren:t leaving doors open all the time!  :good:

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...

Add A Faction to the Player Via Lever or Add/Remove Faction From An Actor Via Trigger

That mini script did not work for me, it failed in compiling.

:book:  After doing comparisons I made a discovery to share!

I created a lever that would change the players faction or the actors faction.

I wanted to make it seemless by deleting the lever and replacing it with a trigger.

I found a default ONACTIVATE script and noticed the ONTriggerEnter was very similar.

By changing one line, I got the trigger to work.

It compiles successfully.

I will do a complete ' HOW TO' in the other forum.

SETUP

    Create your trigger by clicking on 'T' in the toolbar.
    Name your trigger:                                    Example:  AddFactionToPlayerActorTrigger
    Only fill out  ' ID ' field
    Click on 'ADD' inside the Papyrus Scripts area on the right.
    Click on NEW SCRIPT
    Name your script similar to the name of the trigger:  Example:  AddFactionToPlayerActorScript
    It already extends objectreference so press ok
    You are back in the papyrus Scripts area with the new script name, RIGHT click your new script.
    Click ' EDIT SOURCE'
    Your script is empty except for the header line.  So copy and paste the 'RAW CODE' from the spoiler below.
    Make sure you paste the raw code UNDER the generated line you created.
    Compile and Save.
    Quit the script manager.
    Size the trigger with arrows.  If you lost the arrows or want them to go away, press '2' to toggle the arrows.
    Double click on the trigger.
    Change the properties of the trigger to what suits your needs.
    Example:    Change the 'factionforplayer' if you want to add a faction to just the player.

Congratulations!

You should be done with the creation and ready for testing.

This is useful for engaging in conversations requiring the actors in the cell to trust the player long enough to have a conversation

but will 'turn on the player' when the player goes into another part of the cell.

In this example:  I used it at the starting location and the people in the room will treat the player as one of them.  The player will

investigate or learn more about the actors and will leave the area to investigate their stories.  This triggers the part where this

script will remove the player from their faction and will have to fight their treachery.

Also, if you created a hostile dungeon and want to test your dungeon, you don't want to die every time you want to

test a change.  So you can use this trigger to make your testing character friendly to the monsters / actors.

When you are done testing, remove the trigger.

Here is the raw code.

:woohoo:

;Scriptname AshChangeActorPlayerFactionViaTrig extends ObjectReference Conditional
{Change Referenced Actors Factoins via Switch Multiple Targets (6)}

objectReference property RefToGovern auto
objectReference property RefToGovern2 auto
objectReference property RefToGovern3 auto
objectReference property RefToGovern4 auto
objectReference property RefToGovern5 auto
objectReference property RefToGovern6 auto
faction property factionToLeave auto
faction property factionToLeave2 auto
faction property factionToLeave3 auto
faction property factionToLeave4 auto
faction property factionToLeave5 auto
faction property factionToLeave6 auto

faction property factionToJoin auto
{Actor1 Joins a faction, NOT the player}

faction property factionToJoin2 auto
{Actor2 Joins a faction, NOT the player}
faction property factionToJoin3 auto
faction property factionToJoin4 auto
faction property factionToJoin5 auto
faction property factionToJoin6 auto
faction property factionforplayer auto
{Only the PLAYER joins chosen faction}

bool property FrenzyOnActivate = FALSE auto

bool property beenActivated auto hidden

;EVENT onActivate(objectReference akActivatingRef)
EVENT onTriggerEnter(objectReference triggerRef)
if !beenActivated
  beenActivated = TRUE
         Game.getplayer().addtofaction(factionforplayer)
  if factionToLeave
   (refToGovern as actor).removeFromFaction(factionToLeave)
   (refToGovern as actor).removeFromFaction(factionToLeave2)
   (refToGovern as actor).removeFromFaction(factionToLeave3)
   (refToGovern as actor).removeFromFaction(factionToLeave4)
   (refToGovern as actor).removeFromFaction(factionToLeave5)
   (refToGovern as actor).removeFromFaction(factionToLeave6)
  endif
  if factionToJoin
   (refToGovern as actor).addToFaction(factionToJoin)
   (refToGovern as actor).addToFaction(factionToJoin2)
   (refToGovern as actor).addToFaction(factionToJoin3)
   (refToGovern as actor).addToFaction(factionToJoin4)
   (refToGovern as actor).addToFaction(factionToJoin5)
   (refToGovern as actor).addToFaction(factionToJoin6)

    endif

  if FrenzyOnActivate
   (refToGovern as actor).setAV("aggression",3)
   (refToGovern2 as actor).setAV("aggression",3)
   (refToGovern3 as actor).setAV("aggression",3)
   (refToGovern4 as actor).setAV("aggression",3)
   (refToGovern5 as actor).setAV("aggression",3)
   (refToGovern6 as actor).setAV("aggression",3)

  endif
endif
endEVENT

Edited by Ashenfire
Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...