Difference between revisions of "Useful Scripts"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Illyism
(created page :"Example scripts".)
 
imported>Cipscis
(Reference scripts can use implied reference syntax)
Line 6: Line 6:


Begin OnEquip
Begin OnEquip
player.RewardKarma -650
    player.RewardKarma -650
END
End


Begin OnUnequip
Begin OnUnequip
player.RewardKarma 650
    player.RewardKarma 650
END
End
</pre>
</pre>


Line 38: Line 38:
Begin OnActivate
Begin OnActivate
     Activate
     Activate
     if IsActionRef Player == 0  ;if it only works for NPCs remove this .....
     if IsActionRef Player == 0  ;if it shouldn't work for the player remove this...
         set doorTimer to 5
         set doorTimer to 5
         set closeDoor to 1
         set closeDoor to 1
     endif                                   ;...and this
     endif                       ;...and this
End
End
</pre>
</pre>
Line 48: Line 48:
Script Type: Effect
Script Type: Effect


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


<pre>
<pre>
scn CALFPeffectSCR
scn CALFPeffectSCR
ref Target


short ActorValue1
short ActorValue1
Line 61: Line 59:


Begin ScriptEffectStart
Begin ScriptEffectStart
   
    set Target to GetSelf
      
      
     ; places initial explosion when hit, just in case there's no specified explosion effect in the weapons projectile
     ; 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
     ; also useful if you'd want a melee weapon or fist to cause explosions on hit
     Target.placeatme {ExplosionType}
     placeatme {ExplosionType}
      
      
     Player.PushActorAway Target 104
     Player.PushActorAway Target 104
Line 80: Line 76:
      
      
     set Damage to -1 * ( {formula incorporating actor values} )
     set Damage to -1 * ( {formula incorporating actor values} )
     Target.ModAv Health DamageValue
     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
     ; make the effect play a certain sound-you could also use the sound of the explosion and not specify a specific sound
Line 90: Line 86:
     ; this is the part where you place a smoke effect on every axis the NPC/Creature is located
     ; 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
     ; it makes as if the smoke is always coming out of the target while the effect is taking place
     Target.placeatme {smokeeffect}
     placeatme {smokeeffect}
      
      
     ; alternatively add a smoke actor effect on the character
     ; alternatively add a smoke actor effect on the character
     Target.CastImmediateOnSelf {smoke actor effect}
     CastImmediateOnSelf {smoke actor effect}
End
End




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


Line 112: Line 108:
scn LightSwitchScript
scn LightSwitchScript


ref myself
ref light
ref light
short toggle
short toggle


begin onactivate
begin onactivate
    if myself == 0
        set myself to this
    endif
     if light == 0
     if light == 0
         set light to myself.getlinkedref
         set light to getlinkedref
     endif
     endif
      
      

Revision as of 06:28, 15 February 2009

Karma Effects on Items

Script Type: Object

scn KarmaEffect

Begin OnEquip
    player.RewardKarma -650
End

Begin OnUnequip
    player.RewardKarma 650
End

Autoclosing door

Script Type: Object

Scriptname AutoClosingDoor

float doorTimer
short closeDoor

Begin GameMode
    if closeDoor == 1
        if doorTimer > 0
            set doorTimer to doorTimer - getSecondsPassed
        else
       ;close the door
            Activate
       ; Lock
            set closeDoor to 0
        endif
    endif    
End

Begin OnActivate
    Activate
    if IsActionRef Player == 0  ;if it shouldn't work for the player remove this...
        set doorTimer to 5
        set closeDoor to 1
    endif                       ;...and this
End

Pusheffect

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
End


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}
End


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

Light switch

Script Type:Object

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

scn LightSwitchScript

ref light
short toggle

begin onactivate
    if light == 0
        set light to getlinkedref
    endif
    
    if toggle == 0
        light.disable
        activate
        set toggle to 1
    else
        light.enable
        set toggle to 0
        activate
    endif
end