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

Get POS with using Properties


DsoS
 Share

Recommended Posts

Okay so I'm playing around with the script below and it works fantastic, but I would like to refine it a little bit more.

Instead of using the Wait command:

		Game.GetPlayer().TranslateToRef(Point01, 5000)

	Wait(5.0)
I would like to be able to get the coordinates of the Trigger Box and when the player is in the correct position (Point01) the next part of the script runs. Thing is I have about 8 of these sitting out using 8 trigger boxes, so I would need to have the coordinates set as a Property, also all these trigger boxes are in different positions on the X, Y and Z coordinates. I would search the CK Wiki, but not sure where to begin at :lmao:
Scriptname aaDSosKznarzulchand---TopSecret--- extends ObjectReference  

{TOP SECRET.}


Import Debug

Import Utility


ObjectReference Property Point01 Auto



Event OnTriggerEnter(ObjectReference akActionRef)

	If akActionRef == Game.GetPlayer() ; Limit this trigger to the player only.

		;Do my secret Stuff

	Wait(0.1) ;Give the script time...

		Game.GetPlayer().TranslateToRef(Point01, 5000)

	Wait(5.0)

		:Do my other secret stuff!

		GoToState ("Finished")

	Endif


EndEvent


State Finished

	;Do Nothing

EndState

Thank You,

DSoS

Link to comment
Share on other sites

Try this. Can't guarantee anything, but it might give you a jumping-off point.

Scriptname aaDSosKznarzulchand extends ObjectReference  

{TOP SECRET.}


Import Debug

Import Game

Import Utility


ObjectReference property Point01 Auto

ObjectReference property Point02 Auto

ObjectReference property Point03 Auto

ObjectReference property Point04 Auto

ObjectReference property Point05 Auto

ObjectReference property Point06 Auto

ObjectReference property Point07 Auto

ObjectReference property Point08 Auto


Int Increment


ObjectReference property Point

	ObjectReference Function Get()

		If Increment == 1

			MyRef = Point01

		ElseIf Increment == 2

			MyRef = Point02

		ElseIf Increment == 3

			MyRef = Point03

		ElseIf Increment == 4

			MyRef = Point04

		ElseIf Increment == 5

			MyRef = Point05

		ElseIf Increment == 6

			MyRef = Point06

		ElseIf Increment == 7

			MyRef = Point07

		ElseIf Increment == 8

			MyRef = Point08

		EndIf

		Return MyRef

	EndFunction

EndProperty

ObjectReference MyRef



Event OnTriggerEnter(ObjectReference akActionRef)

        If akActionRef == Game.GetPlayer() ; Limit this trigger to the player only.

                ;Do my secret Stuff

        Wait(0.1) ;Give the script time...

                Game.GetPlayer().TranslateToRef(Point01, 5000)

				Increment = 1

				GoToState("Moving")

        Endif


EndEvent


State Moving

Event OnTranslationComplete()


        Increment += 1


	Float PlayerPosX = getPlayer().GetPositionX()

	Float PlayerPosY = getPlayer().GetPositionY()

	Float PlayerPosZ = getPlayer().getPositionZ()


	Float OBJPosX = Point.GetPositionX()

	Float OBJPosY = Point.GetPositionY()

	Float OBJPosZ = Point.GetPositionZ()


	If Increment < 9

		If PlayerPosX == OBJPosX

			If PlayerPosY == OBJPosY

				If PlayerPosZ == OBJPosZ

					GetPlayer().TranslateToRef(Point, 5000)

				EndIf

			EndIf

		EndIf

	EndIf


	If Increment == 9

		;Do my other secret stuff!

        GoToState ("Finished")

	EndIf


EndEvent

EndState






State Finished

        ;Do Nothing

EndState

Edited by ThomasKaira
Link to comment
Share on other sites

Try this. Can't guarantee anything, but it might give you a jumping-off point.

Scriptname aaDSosKznarzulchand extends ObjectReference  

{TOP SECRET.}


Import Debug

Import Game

Import Utility


ObjectReference property Point01 Auto

ObjectReference property Point02 Auto

ObjectReference property Point03 Auto

ObjectReference property Point04 Auto

ObjectReference property Point05 Auto

ObjectReference property Point06 Auto

ObjectReference property Point07 Auto

ObjectReference property Point08 Auto


Int Increment


ObjectReference property Point

	ObjectReference Function Get()

		If Increment == 1

			MyRef = Point01

		ElseIf Increment == 2

			MyRef = Point02

		ElseIf Increment == 3

			MyRef = Point03

		ElseIf Increment == 4

			MyRef = Point04

		ElseIf Increment == 5

			MyRef = Point05

		ElseIf Increment == 6

			MyRef = Point06

		ElseIf Increment == 7

			MyRef = Point07

		ElseIf Increment == 8

			MyRef = Point08

		EndIf

		Return MyRef

	EndFunction

EndProperty

Storing the points for Point's getter in an array would be more efficient; the worst case scenario would execute much faster (no comparisons required vs. maximum of eight comparisons required, or if you want to get technical: O(1) vs. O(n) ). Something like this (note: not sure about array syntax for Papyrus):

ObjectReference Function Get()

	return PointXx[Increment-1]

EndFunction

You'd then have to declare an array of ObjectReferences as a property (is that possible? If it's not, you'd have to initialize the array/its elements). Also, this assumes that Increment will have a minimum value of 1 (would be better if it started at 0, since you could eliminate the subtraction (not that it'd make much of a difference)) and that Papyrus arrays use zero-based indexing. Another benefit of doing it this way: adding/removing points requires only modification of the array property. To be honest, you could completely remove the getter and just access the array directly in the OnTranslationComplete() event.

Float PlayerPosX = getPlayer().GetPositionX()

Float PlayerPosY = getPlayer().GetPositionY()

Float PlayerPosZ = getPlayer().getPositionZ()

Wouldn't hurt to store GetPlayer() in a variable, instead of calling the function three times. Save a couple of clock cycles, could make a difference due to Papyrus' multi-threaded nature.

If Increment < 9

                If PlayerPosX == OBJPosX

                        If PlayerPosY == OBJPosY

                                If PlayerPosZ == OBJPosZ

                                        GetPlayer().TranslateToRef(Point, 5000)

                                EndIf

                        EndIf

                EndIf

        EndIf


        If Increment == 9

                ;Do my other secret stuff!

        GoToState ("Finished")

        EndIf

Setting this up like this:

if( Increment < 9)

        ; do whatever

elseif( Increment == 9) ; using just an 'else' is another possibility. Based on what TK posted, I'd recommend it since there's no chance of Increment being larger than 9.

        ; do whatever, version 2

endif

Would be a minor improvement since only one of the two conditions is ever going to execute.

Hopefully this made sense. Kinda drunk and I make not very much sense when drunk.

Link to comment
Share on other sites

<snip>

That did make sense (most of the issues were me once again trying to make things more complex than needed). Based on that, we get this:

Scriptname aaDSosKznarzulchand extends ObjectReference  

{TOP SECRET.}


Import Debug

Import Game

Import Utility


ObjectReference[] property Point Auto


Int Increment

Actor Player


Event OnTriggerEnter(ObjectReference akActionRef)

        Player = getPlayer()

        If akActionRef == Player ; Limit this trigger to the player only.

                ;Do my secret Stuff

        Wait(0.1) ;Give the script time...

                Player.TranslateToRef(Point[Increment], 5000)

                                Increment = 1

                                GoToState("Moving")

        Endif


EndEvent


State Moving

Event OnTranslationComplete()


        Increment += 1


        Float PlayerPosX = Player.GetPositionX()

        Float PlayerPosY = Player.GetPositionY()

        Float PlayerPosZ = Player.getPositionZ()


        Float OBJPosX = Point.GetPositionX()

        Float OBJPosY = Point.GetPositionY()

        Float OBJPosZ = Point.GetPositionZ()


        If Increment < 8

                If PlayerPosX == OBJPosX

                        If PlayerPosY == OBJPosY

                                If PlayerPosZ == OBJPosZ

                                        Player.TranslateToRef(Point[Increment], 5000)

                                EndIf

                        EndIf

                EndIf

        ElseIf Increment == 8

                ;Do my other secret stuff!

        GoToState ("Finished")

        EndIf


EndEvent

EndState






State Finished

        ;Do Nothing

EndState

This brings the final value for Increment down to 8 because, of course, Papyrus arrays start at 0. And yes, when a Property is declared as an array, you can place all the elements you need inside it with the CK, so no need to initialize.

Edited by ThomasKaira
Link to comment
Share on other sites


Event OnTriggerEnter(ObjectReference akActionRef)

        Player = getPlayer()

        If (akActionRef == Player) ; Limit this trigger to the player only.

                ;Do my secret Stuff

                Wait(0.1) ;Give the script time...

                Increment = 0

                Player.TranslateToRef( Point[Increment], 5000 )

                GoToState("Moving")

        Endif


EndEvent

Minor adjustment :)

Link to comment
Share on other sites

I used the code below and it worked great... I had to remove two things:

Player.TranslateToRef( Point[increment], 5000 ) <----------- Had to remove the Increment thing, it threw an error, after removing it the script compiled perfectly and ran great in game.

Scriptname aaDSosKznarzulchand extends ObjectReference  

{Top Secret}


Import Debug

Import Game

Import Utility


ObjectReference property Point Auto


Int Increment

Actor Player


Event OnTriggerEnter(ObjectReference akActionRef)

        Player = getPlayer()

        If akActionRef == Player ; Limit this trigger to the player only.

                ;Do my secret Stuff

        Wait(0.1) ;Give the script time...

                Player.TranslateToRef(Point, 5000)

                                Increment = 1

                                GoToState("Moving")

        Endif


EndEvent


State Moving

Event OnTranslationComplete()


        Increment += 1


        Float PlayerPosX = Player.GetPositionX()

        Float PlayerPosY = Player.GetPositionY()

        Float PlayerPosZ = Player.getPositionZ()


        Float OBJPosX = Point.GetPositionX()

        Float OBJPosY = Point.GetPositionY()

        Float OBJPosZ = Point.GetPositionZ()


        If Increment < 8

                If PlayerPosX == OBJPosX

                        If PlayerPosY == OBJPosY

                                If PlayerPosZ == OBJPosZ

                                        Player.TranslateToRef(Point, 5000)

                                EndIf

                        EndIf

                EndIf

        ElseIf Increment == 8

                ;Do my other secret stuff!

        GoToState ("Finished")

        EndIf


EndEvent

EndState






State Finished

        ;Do Nothing

EndState

Thank You very much for all the help :pints:

Link to comment
Share on other sites

I was testing the script and it seems to work for the most part so I looked back through the script and have a question about it...

What are the increments for?

My last ";Do My Secret Stuff" doesn't work as is.

Link to comment
Share on other sites

The increments are there to tell the array which trigger box to refer to, so the script has the data needed to send the player to the next box sequentially.

Also, in this section:

Event OnTriggerEnter(ObjectReference akActionRef)

        Player = getPlayer()

        If akActionRef == Player ; Limit this trigger to the player only.

                ;Do my secret Stuff

        Wait(0.1) ;Give the script time...

                Player.TranslateToRef(Point, 5000)

                                Increment = 1

                                GoToState("Moving")

        Endif


EndEvent

Change Increment = 1 to Increment = 0.

Edited by ThomasKaira
Link to comment
Share on other sites

okay, I think I didn't explain very well.

I do have 8 points, however they will not be close to each other. The player will hit one trigZone and then this script happens, after they are moved, they will have to walk/run/jump/etc.

The Trigger Zones are independent of each other and will not ever be used with each other.

I hope that explains it a little better

Link to comment
Share on other sites

Oh. So the player will need to move to the next zone in order for the next Translation to take place? Is that correct?

In that case, we don't even need the OnTranslationComplete event, the script will just re-fire when the player enters the next trigger zone:

Scriptname aaDSosKznarzulchand extends ObjectReference  

{Top Secret}


Import Debug

Import Game

Import Utility


ObjectReference[] property Point Auto


Int Increment

Actor Player


Event OnTriggerEnter(ObjectReference akActionRef)

        Player = getPlayer()

        If akActionRef == Player ; Limit this trigger to the player only.

                ;Do my secret Stuff

        Wait(0.1) ;Give the script time...

                Player.TranslateToRef(Point[Increment], 5000)

                Increment += 1

		If Increment == 8

		        ;Do my other secret stuff!

			GoToState ("Finished")

		EndIf


        Endif


EndEvent


State Finished

        ;Do Nothing

EndState

Edited by ThomasKaira
Link to comment
Share on other sites

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