Jump to content

Some scripting help needed once more!


ZansoHel

Recommended Posts

Hey!

 

I wanted to make a script for "floating" rock (slow up and down movement mostly). However, it loops for certain amount of times (see "number" in script) and won't reset when the trigger is re-entered. My idea was to make it loop infinite times or atleast (100000 times) everytime you enter the trigger. Anyone got some great ideas how to make it happen? :)

 

Script

 

 

Scriptname RockFloatScript extends ObjectReference

 

ObjectReference property Rock Auto

Int loop = 0

 

 

Event OnTriggerEnter(ObjectReference ActionRef)

 

If ActionRef as Actor == Game.GetPlayer()

Actor ActorRef = ActionRef as Actor

 

While(loop < "number")

Rock.TranslateTo(-465.48740, 330.75350, 665.0, -35.1780, -31.5284, -41.5715, 1.5, 7.0)

Utility.Wait(5.2)

Rock.TranslateTo(-465.48740, 330.75350, 603.67590, -35.1780, -31.5284, -33.5715, 1.5, 7.0)

Utility.Wait(5.2)

 

loop += 1

EndWhile

 

EndIF

EndEvent

 

 

Link to comment
Share on other sites

This script will activate only once and the rock will float forever (infinite loop).

 

Note that you can't call translate functions on the rock if it's 3D isn't loaded (eg. after the cell unloads), it will spam the Papyrus log with errors, with no way of switching it off. I've added a test to help minimize this, but you might still find that it throws errors into the log from time to time. Also, this loop will keep running even when the cell had unloaded. Need to be careful with scripts like this. A script like this should never be installed as a loose file, make sure to put it in a bsa file or it could cause massive log spam if the user deactivates the esp without deleting the script.

 

 

 

Scriptname RockFloatScript extends ObjectReference 

ObjectReference property Rock Auto

AUTO STATE WAITING
Event OnTriggerEnter(ObjectReference ActionRef)

If ActionRef as Actor == Game.GetPlayer()
	GoToState("DONE")
;		Actor ActorRef = ActionRef as Actor ; (not required unless you want to call functions on the actor who entered the trigger)

	bool bLoop = True
	While(bLoop)
		If Rock.Is3DLoaded() && Rock.GetParentCell() != None ; we can't call translate functions on unloaded objects, it will spam the error log
			Rock.TranslateTo(-465.48740, 330.75350, 665.0, -35.1780, -31.5284, -41.5715, 1.5, 7.0)
		EndIf
		Utility.Wait(5.2)
		If Rock.Is3DLoaded() && Rock.GetParentCell() != None ; we can't call translate functions on unloaded objects, it will spam the error log
			Rock.TranslateTo(-465.48740, 330.75350, 603.67590, -35.1780, -31.5284, -33.5715, 1.5, 7.0)
		EndIf
		Utility.Wait(5.2)
	EndWhile
EndIF
EndEvent
ENDSTATE

STATE DONE
; do nothing
ENDSTATE

 

Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...