Difference between revisions of "Useful Scripts"


(Hotkey: quest link directs to quest category)
Line 356: Line 356:
<small>To be placed on a [[Quest_Data_Tab|quest]], it will run some code when a key is released. See [http://fose.silverlock.org/fose_command_doc.html#DirectX_Scancodes FOSEs Command Docs] for additional DirectX Scancodes</small>
<small>To be placed on a [[:Category: Quests|quest]], it will run some code when a key is released. See [http://fose.silverlock.org/fose_command_doc.html#DirectX_Scancodes FOSEs Command Docs] for additional DirectX Scancodes</small>
ScriptName HotkeyReleased
ScriptName HotkeyReleased

Revision as of 07:23, 7 November 2009


Timed Doors

Script Type:Object

To be placed on an activator, Uses Persistent References to design Objects.

ScriptName VaultpTimedDoor ;By BEArbiter

;This script is to make TimedDoors, Elevators,...
;Once you press the button, Isactivated is set to 1, so pressing the button againt won't do anything, it need to be Reset to 0
;Then, each 1 second, One or more Door will be
;opened/closed. When All the door have been activated, the script
;will reset the Activator.
;It use Persitent Reference of the doors, So You need one
;Script per Activator/Elevator,....
;A Timing Issue Is possible(if you place Two or more activator
;and activate both at little interval), It can be
;Solve by Create An Global Variable instead of Isactivated
;Then, all the button witch use a copy of this
;script won't be useable while a Door is opened

float timer
;For a Global Variable, Go to Global, create a
;new short var named isactivated and delete theses line:
int isactivated
:<end of delete action>

Begin Onactivate
;If the button have been pressed before and
;not been reseted, the activator won't do anything
    if isactivated == 0
   	set isactivated to 1
        ;If you want the Activation to do something

begin gamemode
   If isactivated == 1
      if timer < 8

         if timer < 1;
         elseif Timer < 2;After One second, do the following
	    if Door1.GetOpenState == 3
               Door1.SetOpenState 1
               ;Door3.SetOpenState 1
               ;You can Activate more than one door at a time.
            elseif Door1.GetOpenState == 1
               Door1.SetOpenState 0
               ;Door3.SetOpenState 0
         Elseif Timer < 3
            If Door2.GetOpenState == 3
               Door2.SetOpenState 1
            Elseif Door2.GetOpenState == 1
               Door2.SetOpenState 0
         Elseif Timer < 4
            If Door3.GetOpenState == 3
               Door3.SetOpenState 1
            Elseif Door3.GetOpenState == 1
               Door3.SetOpenState 0

        Set isactivated to 0
        Set timer to 0

Light switch

Script Type:Object

To be placed on an activator, and linked to a light source or x-marker Enable Parent.

ScriptName LightSwitchScript

ref light

Begin OnActivate
	if light == 0
		set light to GetLinkedRef

	if light.GetDisabled

Ground area mark that follows the crosshair

You can see the effect of this script in this video Script Type: Quest or Effect For a Quest script, use a GameMode block. For an Effect script, use a ScriptEffectUpdate block.
Instead of activator put the name of the activator or actor you want to use, in order to use the EditorRefID of your reference in a script like this, it must be a persistent reference.

float xang
float zang
float x
float y
float z
float playerheight
float lont

begin gamemode

	set xang to player.getangle x
	set zang to player.getangle z * -1 + 90

	if xang <= 5
		set lont to 1300;  you can change this value if you need to
		if player.issneaking == 0
			set playerheight to 322
			set playerheight to 252
		set lont to (playerheight*cos xang/sin xang * 0.34118010537042257764)

	set xang to player.getangle x * -1

	set x to lont * cos xang * cos zang
	set y to lont * cos xang * sin zang

	Activator.moveto player x y 0


Forced Relative Orientation

Script Type: Quest, Object or Effect For a Quest or Object script, use a GameMode block. For an Effect script, use a ScriptEffectUpdate block.
In order to use the EditorRefID of your reference in a script like this, it must be a persistent reference.

float fAngle
float fRelativePos

Begin GameMode

	set fRelativePos to player.GetPos z + <Z OFFSET>
	myREF.setPos z fRelativePos

	set fAngle to player.GetAngle Z + <ANGLE OFFSET>
	myREF.SetAngle Z fAngle

	set fRelativePos to player.GetPos Y + <PLAYER OFFSET> * cos fAngle
	myREF.SetPos Y fRelativePos

	set fRelativePos to player.GetPos X + <PLAYER OFFSET> * sin fAngle
	myREF.SetPos X fRelativePos

  • <Z OFFSET> determines the reference's z offset from the player's feet. The higher this is, the further above the player's feet the reference will appear. If <Z OFFSET> should be determined by where the player is looking, this should be used:
    set fAngle to player.GetAngle X
    set fRelativePos to player.GetPos Z - <PLAYER OFFSET> * sin fAngle
  • <ANGLE OFFSET> determines the reference's position relative to the players. As <ANGLE OFFSET> increases, the reference's position will move around the player in an anti-clockwise direction. When <ANGLE OFFSET> is 0, the reference will appear directly in front of the player.
  • <PLAYER OFFSET> determine's the horizontal distance between the reference and the player. As <PLAYER OFFSET> increases, the reference appears further and further from the player

The player can be substituted for any other reference here and the script will still work. Note that the reference may appear to move through solid objects, especially when <PLAYER OFFSET> is set to a particularly large value.

Autoclosing door

Script Type: Object

Scriptname AutoClosingDoor

float doorTimer
short closeDoor

Begin GameMode
	if closeDoor == 1
		if doorTimer > 0
			set doorTimer to doorTimer - getSecondsPassed
		elseif GetOpenState == 1 ; if the door is still open
			SetOpenState 0 ; close the door
			set closeDoor to 0

Begin OnActivate
	if GetOpenState == 3 ; if the door is closed
		if IsActionRef Player == 0  ; if it should work for the player remove this...
			set doorTimer to 5
			set closeDoor to 1
		endif                       ; ...and this

Karma Effects on Items

Script Type: Effect
For armour, you can use a scripted Object Effect. This allows the armour to safely be equipped and unequipped via EquipItem and UnequipItem

ScriptName KarmaEffect

ref rWearer

Begin ScriptEffectStart
	set rWearer to GetSelf
	if rWearer.GetIsReference player
		RewardKarma -650

Begin ScriptEffectFinish
	if rWearer.GetIsReference player
		RewardKarma 650

Script Type: Object
For weapons, you'll have to use an Object Script. "Weapon" type Object Effects are applied to that weapon's target, and are therefore unsuitable for applying effects to the wielder

ScriptName KarmaEffect

Begin OnEquip player
	player.RewardKarma -650

Begin OnUnequip player
	player.RewardKarma 650


Script Type: Effect

spell effect script for a weapon that knocks people far away and creates a trail of smoke or fire along the way.
NOTE - Only works correctly when the player has the weapon equipped.

scn CALFPeffectSCR

short ActorValue1
short ActorValue2
short ActorValue3
short DamageValue

Begin ScriptEffectStart
    ; places initial explosion when hit, just in case there's no specified explosion effect in the weapons projectile
    ; also useful if you'd want a melee weapon or fist to cause explosions on hit
    placeatme {ExplosionType}
    Player.PushActorAway Target 104
    ; this is the part of the script in which you can specify a certain damage formula
    ; the formula can be added to the base damage amount set in the weapons tab
    ; -or you can set the damage in the tab to zero and fully rely on the formula to calculate damage
    ; it can be the target NPC/creature's actor value or the player's
    ; it's also fine not to make a certain damage formula
    set ActorValue1 to Player.GetAv {ActorValue1}
    set ActorValue2 to Player.GetAv {ActorValue2}
    set ActorValue3 to Player.GetAv {ActorValue3}
    set Damage to -1 * ( {formula incorporating actor values} )
    ModAv Health DamageValue
    ; make the effect play a certain sound-you could also use the sound of the explosion and not specify a specific sound
    Playsound3D Play a certain sound

Begin ScriptEffectUpdate
    ; this is the part where you place a smoke effect on every axis the NPC/Creature is located
    ; it makes as if the smoke is always coming out of the target while the effect is taking place
    placeatme {smokeeffect}
    ; alternatively add a smoke actor effect on the character
    CastImmediateOnSelf {smoke actor effect}

begin ScriptEffectFinish
    ;if you used the above alternative, this segment removes the smoke effect from the character
    RemoveSpell {smoke actor effect}



Script Type: Object

Script requires the Fallout Script Extender.

To be placed on a terminal, it changes the usual "Robco" headers to your liking.

ScriptName TerminalChange

Short toggle
Float minitimer
Short activated

Begin OnActivate player
  set activated to 1
  Activate ;For people without FOSE, still works.
  con_setgamesetting sComputersHeader1 "GREAT ACADEMY OF VALHALLA"
  con_setgamesetting sComputersHeader2 "Republic of Valhalla"
  con_setgamesetting sHackingHeader "VALHALLA REPUBLIC TERMLINK PROTOCOL"
  con_setgamesetting shackingintro01 "WELCOME TO VALHALLA REPUBLIC TERMLINK"
  con_setgamesetting shackingintro06 "Initializing Valhalla Republic MF Boot Agent v2.1.9"
  con_setgamesetting shackingintro09 "Copyright 2156-2234 Academy of Valhalla"

Begin MenuMode
  if activated == 1
    set activated to 2

Begin GameMode
  if activated == 2
    set activated to 0
    ;On shutting down the terminal. Makes sure it doesn't show up on others.
    con_setgamesetting sComputersHeader1 "ROBCO INDUSTRIES UNIFIED OPERATING SYSTEM"
    con_setgamesetting sComputersHeader2 "COPYRIGHT 2075-2077 ROBCO INDUSTRIES "
    con_setgamesetting sHackingHeader "ROBCO INDUSTRIES (TM) TERMLINK PROTOCOL"
    con_setgamesetting shackingintro01 "WELCOME TO ROBCO INDUSTRIES (TM) TERMLINK"
    con_setgamesetting shackingintro06 "Initializing Robco Industries(TM) MF Boot Agent v2.3.0"
    con_setgamesetting shackingintro09 "Copyright 2201-2203 Robco Ind."


Script Type: Quest

Script requires the Fallout Script Extender.

To be placed on a quest, it will run some code when a key is released. See FOSEs Command Docs for additional DirectX Scancodes

ScriptName HotkeyReleased

Short sToggle

Begin GameMode
	if IsKeyPressed 25 != sToggle
		set sToggle to sToggle == 0
		if sToggle ;Button pressed
			;Do things when button 'p' is pressed, in this case, decrease karma
			RewardKarma -650
		else ;Button released
			;Do things when button 'p' is released, in this case, increase karma
			RewardKarma 650
Personal tools