Jump to content

Post your Scripts Here


Smosh

Recommended Posts

I just did some testing with that script, and found that it has a bug - the door won't update its closed state if the frame in which SetOpenState is called occurs while the door is animating. I've changed the script to fix the but, here's the new one:

ScriptName TriggerAutoDoorScript

short sCount
ref rActionRef
short sLinkedRefSet
ref rLinkedRef

Begin OnTriggerEnter
set sCount to sCount + 1
End

Begin OnTriggerLeave
set sCount to sCount - 1
End

Begin GameMode

if sLinkedRefSet == 0
	set sLinkedRefSet to 1
	set rLinkedRef to GetLinkedRef
elseif rLinkedRef.GetOpenState == ( sCount == 0 )
	set rLinkedRef to GetLinkedRef
	rLinkedRef.SetOpenState 0
elseif rLinkedRef.GetOpenState == 3 && sCount
	set rLinkedRef to GetLinkedRef
	rLinkedRef.SetOpenState 1
endif

End

Cipscis

Link to comment
Share on other sites

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

Cipcis, thanks for reviewing my script.

I was unaware that the placeatme command in FO3 would cause savegame bloat.

 

Problem is, even though using castimmediateonself to cast a smoke effect is a viable solution, what if I want to cast the explosion effect to the target on every frame? Would I have to make refs for each of the placed explosion and use removeme on each of them?

There has to be a better way of making those explosion effects stick to the target for a period of time. Making a custom effect which calls an explosion only plays the explosion once.

Link to comment
Share on other sites

Thanks for bringing that up again Callighan, I've actually found some new information pertaining to this since I reviewed that script.

 

Using explosions created via PlaceAtMe (to detect nearby Actors, for example) is a very useful tool, and I've been doing some testing with it recently. I found that RefIDs assigned to explosions are marked for deletion once the explosion has "run it's course".

 

I've confirmed this by attempting to select the previously assigned RefID via PicKRefByID in the console, and I've also noticed that the game engine often chooses to cycle through a small number of RefIDs, again confirming that calling MarkForDelete is not required after creating explosions via PlaceAtMe.

 

Cipscis

Link to comment
Share on other sites

Just added another "useful script" to the appropriate page on the GECK Wiki. It allows you to position a reference relative to the player's z angle. Here is the excerpt from the GECK Wiki page:

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 fAngleZ
float fRelativePos

Begin GameMode

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

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

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

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

End

- <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.

- <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.

 

=====================

 

 

I've got a template that I use for scripting multi-level menus as well, which is something I've done for both of my Mods - AMPUTATE! and CASM. Here's the template:

ScriptName MenuTokenScript

short sMenuLevel ; Records the current depth of the ShowMessage framework
; 0 - Initialisation
; 1 - First Level
; 2 - Middle Level
; 3 - Final Level

short sButton1 ; sButton variable for First Level
short sButton2 ; sButton variable for Middle Level
short sButton3 ; sButton variable for Final Level

Begin GameMode

; =================================================
; INITIALISATION
; =================================================
if sMenuLevel == 0
	ShowMessage FirstLevelMessage ; Menu initialisation
	set sMenuLevel to 1 ; Menu Level initialisation
endif

; =================================================
; FIRST LEVEL
; =================================================
if sMenuLevel == 1
	set sButton1 to GetButtonPressed ; Button set
	if sButton1 == -1 ; Button check 1 - none of the buttons have been pressed yet
		Return
	elseif sButton1 == 0 ; Button check 2 - 0th button pressed
		ShowMessage MiddleLevelMessage0 ; Button result - show the 0th Middle Level Menu
	elseif sButton1 == 1 ; Button check 2 - 1st button pressed
		ShowMessage MiddleLevelMessage1 ; Button result - show the 1st Middle Level Menu
	else ; Button check 2 - "Done" button pressed
		RemoveMe ; Button result - close Menu
	endif
	set sMenuLevel to 2 ; Menu Level incrementation
endif

; =================================================
; MIDDLE LEVEL
; =================================================
if sMenuLevel == 2
	set sButton2 to GetButtonPressed ; Button set
	if sButton2 == -1 ; Button check 1 - none of the buttons have been pressed yet
		Return
	elseif sButton1 == 0 ; Navigation check 1 - 0th Middle Level Menu
		if sButton2 == 0 ; Button check 2 - 0th button pressed
			ShowMessage FinalLevelMessage00 ; Button result - show the 0th Final Level Menu
		elseif sButton2 == 1 ; Button check 2 - 1st button pressed
			ShowMessage FinalLevelMessage01 ; Button result - show the 1st Final Level Menu
		else ; Button check 2 - "Back" button pressed
			ShowMessage FirstLevelMessage ; Button result - return to FirstLevelMessage
			set sMenuLevel to 1
			Return
		endif
	elseif sButton1 == 1 ; Navigation check 1 - 1st Middle Level Menu
		if sButton2 == 0 ; Button check 2 - 0th button pressed
			ShowMessage FinalLevelMessage10
		elseif sButton2 == 1 ; Button check 2 - 1st button pressed
			ShowMessage FinalLevelMessage11
		else ; Button check 2 - "Back" button pressed
			ShowMessage FirstLevelMessage ; Button result - return to FirstLevelMessage
			set sMenuLevel to 1
			Return ; Exclude common button result
		endif
	endif
	set sMenuLevel to 3 ; Common button result - increment sMenuLevel
endif

; =================================================
; FINAL LEVEL
; =================================================
if sMenuLevel == 3
	set sButton3 to GetButtonPressed ; Button set
	if sButton3 == -1 ; Button check 1 - none of the buttons have been pressed yet
		Return
	elseif sButton1 == 0 ; Navigation check 1 - 0th Middle Level Menu
		if sButton2 == 0 ; Navigation check 2 - 0th Final Level Menu
			if sButton3 == 0 ; Button check 2 - 0th button pressed
				; Button result
			elseif sButton3 == 1 ; Button check 2 - 1st button pressed
				; Button result
			else ; Button check 2 - "Back" button pressed
				ShowMessage MiddleLevelMessage0 ; Button result - return to MiddleLevelMessage0
				set sMenuLevel to 2
				Return ; Exclude common button result
			endif
			ShowMessage FinalLevelMessage00 ; Common button result - reset current menu
		elseif sButton2 == 1 ; Navigation check 2 - 1st Final Level Menu
			if sButton3 == 0 ; Button check 2 - 0th button pressed
				; Button result
			elseif sButton3 == 1 ; Button check 2 - 1st button pressed
				; Button result
			else ; Button check 2 - "Back" button pressed
				ShowMessage MiddleLevelMessage0 ; Button result - return to MiddleLevelMessage0
				set sMenuLevel to 2
				Return ; Exclude common button result
			endif
			ShowMessage FinalLevelMessage01 ; Common button result - reset current menu
		endif
	elseif sButton1 == 1 ; Navigation check 1 - 1st Middle Level Menu
		if sButton2 == 0 ; Navigation check 2 - 0th Final Level Menu
			if sButton3 == 0 ; Button check 2 - 0th button pressed
				; Button result
			elseif sButton3 == 1 ; Button check 2 - 1st button pressed
				; Button result
			else ; Button check 2 - "Back" button pressed
				ShowMessage MiddleLevelMessage1 ; Button result - return to MiddleLevelMessage1
				set sMenuLevel to 2
				Return ; Exclude common button result
			endif
			ShowMessage FinalLevelMessage10 ; Common button result - reset current menu
		elseif sButton2 == 1 ; Navigation check 2 - 1st Final Level Menu
			if sButton3 == 0 ; Button check 2 - 0th button pressed
				; Button result
			elseif sButton3 == 1 ; Button check 2 - 1st button pressed
				; Button result
			else ; Button check 2 - "Back" button pressed
				ShowMessage MiddleLevelMessage1 ; Button result - return to MiddleLevelMessage1
				set sMenuLevel to 2
				Return ; Exclude common button result
			endif
			ShowMessage FinalLevelMessage11 ; Common button result - reset current menu
		endif
	endif
endif

End

I've also written a tutorial for the GECK Wiki for making multi-level menus that uses this template, which is why the template is so heavily commented. Here is the tutorial - Adding an Options Menu

 

Here is an uncommented version of the template:

ScriptName MenuTokenScript

short sMenuLevel

short sButton1
short sButton2
short sButton3

Begin GameMode

if sMenuLevel == 0
	ShowMessage FirstLevelMessage
	set sMenuLevel to 1
endif

if sMenuLevel == 1
	set sButton1 to GetButtonPressed
	if sButton1 == -1
		Return
	elseif sButton1 == 0
		ShowMessage MiddleLevelMessage0
	elseif sButton1 == 1
		ShowMessage MiddleLevelMessage1
	else
		RemoveMe
	endif
	set sMenuLevel to 2
endif

if sMenuLevel == 2
	set sButton2 to GetButtonPressed
	if sButton2 == -1
		Return
	elseif sButton1 == 0
		if sButton2 == 0
			ShowMessage FinalLevelMessage00
		elseif sButton2 == 1
			ShowMessage FinalLevelMessage01
		else
			ShowMessage FirstLevelMessage
			set sMenuLevel to 1
			Return
		endif
	elseif sButton1 == 1
		if sButton2 == 0
			ShowMessage FinalLevelMessage10
		elseif sButton2 == 1
			ShowMessage FinalLevelMessage11
		else
			ShowMessage FirstLevelMessage
			set sMenuLevel to 1
			Return
		endif
	endif
	set sMenuLevel to 3
endif

if sMenuLevel == 3
	set sButton3 to GetButtonPressed
	if sButton3 == -1
		Return
	elseif sButton1 == 0
		if sButton2 == 0
			if sButton3 == 0
				
			elseif sButton3 == 1
				
			else
				ShowMessage MiddleLevelMessage0
				set sMenuLevel to 2
				Return
			endif
			ShowMessage FinalLevelMessage00
		elseif sButton2 == 1
			if sButton3 == 0
				
			elseif sButton3 == 1
				
			else
				ShowMessage MiddleLevelMessage0
				set sMenuLevel to 2
				Return
			endif
			ShowMessage FinalLevelMessage01
		endif
	elseif sButton1 == 1
		if sButton2 == 0
			if sButton3 == 0
				
			elseif sButton3 == 1
				
			else
				ShowMessage MiddleLevelMessage1
				set sMenuLevel to 2
				Return
			endif
			ShowMessage FinalLevelMessage10
		elseif sButton2 == 1
			if sButton3 == 0
				
			elseif sButton3 == 1
				
			else
				ShowMessage MiddleLevelMessage1
				set sMenuLevel to 2
				Return
			endif
			ShowMessage FinalLevelMessage11
		endif
	endif
endif

End

I'm currently working on a utility that can be used to easily generate the ShowMessage framework for a multi-level menu, so that instead of writing it yourself from the template, all you'll have to do is define the structure of the menu, and the framework will be generated for you. Then all you'll have to do is fill in the results for each button.

 

It's not quite done yet, but hopefully it'll be ready for release in a week or so.

 

Cipscis

Link to comment
Share on other sites

Heres my script for makeing any NPC almost run a script pack and set aggres, ect

 

scn SRSStartScriptEffect

;Follower Variables
short StartingAggression
Short StartingAssistance 
Short StartingConfidence 
Short StartingEnergy 
Short StartingResponsibility 
Short StartingMood 
short StartingIgnoreCrime

;ID's for the ref that he has been hired
short HasBeenHired

Begin ScriptEffectStart
Say IdleChatter
		RemoveFromAllFactions

		AddToFaction SRFaction 10

		AddScriptPackage SRSoldierFollowersPlayerWAIT

		set StartingAggression to getAv Aggression
		set StartingAssistance to getAv Assistance
		set StartingConfidence to getAv Confidence
		set StartingEnergy to getAv Energy
		set StartingResponsibility to getAv Responsibility
		set StartingMood to getAv Mood 
		set StartingIgnoreCrime to GetIgnoreCrime

		setAv Aggression 1
		setAv Assistance 1
		setAv Confidence 2
		setAv Energy 50
		setAv Responsibility 50
		setAv Mood 5
		ignoreCrime 1
		SetPlayerTeammate 1

End

 

make this into a base effect script then add it as actor effect then use castimmediateonself in Dialogue and you get a NPC that runs a script in any way you want them to run it. I think i should also add some more lines but this works well when casted. also when you add this to Dialogue as castimmedaiteonself make shure you set up the conditions for the responces right otherwise it might cast on you or not work right. also make the SCPack run forever too otherwise it will EVP and stop running.

 

Now I need a way to add building statics like the DemoNukeMarker does so i can build buildings in my mod?

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Simple timed door script I put together earlier to help someone elsewhere on the forum. Any ideas for better ways to do it or for optimizations etc. are welcome, I'm still pretty noob to FO3 scripting :)

 

Just modify the GetCurrentTime values for whatever times you want the door to be open/closed. Placed door reference needs to be persistant and the door unlocked.

 

scn TimedDoorScript

BEGIN GameMode
if GetCurrentTime >= 8
	TimedDoorREF.Unlock 1
	TimedDoorREF.setOpenState 1
endif

if GetCurrentTime >= 20
	TimedDoorREF.setOpenState 0
	TimedDoorREF.Lock 255	;setting this to 255 = Requires Key.
				;If you want it pickable, 100 = Very Hard, 75 = Hard, 50 = Average, 25 = Easy, 0 = Very Easy
endif

if GetCurrentTime < 8
	TimedDoorREF.setOpenState 0
	TimedDoorREF.Lock 255
endif
END

Link to comment
Share on other sites

scn bfpLongRangeActivateTestScript

short oldlength
ref target
short count

Begin ScriptEffectStart
   set oldlength to GetNumericGameSetting iActivatePickLength
;printc "Old pick length: %x", oldlength
   SetNumericGameSetting iActivatePickLength 40000; Or w/e range you fancy
End

Begin ScriptEffectUpdate
   set count to count + 1
   if (count >= 4);NOTE 1: after several testings, this seems the minimal amount of frames needed to update the crosshair ref
       set target to GetCrossHairRef
       if (target)
;printc "target is: %n", target
               target.Activate player 1
;target.castimmediateonself EnchFlamerEffect
               SetNumericGameSetting iActivatePickLength oldlength
       endif
   endif
End

Begin ScriptEffectFinish
   SetNumericGameSetting iActivatePickLength oldlength
End

 

Long range activating/targeting, replace the "target.activate player 1" with whatever enchantment you fancy (like, setting people on fire), targets items, people, doors, dogs, ants, rocks, chairs, anything and everything under the crosshairs, toy with the range to limit it in any way you fancy.

Simply made by temporally increasing the length at which things highlight on cursor, waiting until the reference updates, and using FOSE's GetCrosshairRef.

Needs to be called as an effect on the player, requires more than 0 of duration.

 

Should be compatible with mods that affect the pickup distance, unless they do it dynamically AND for some unlucky reason they come to affect it JUST in the 4 frame window that this script uses. Not really likely.

 

Requires FOSE.

 

And please, please, sticky this thread ^_^

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...