Jump to content

location and rotation in papyrus script


blessposter

Recommended Posts

hihi,

 

currently i am evaluating some stuff for my mod idea and need some information which i didn't get through the script reference.

 

1.) is it possible to get the exact current position of the player and store it like { x, y, z }

 

2.) additionally to the position i need the rotation of the player (north or south) in a float or anything like that.

 

I am not really trained in papyrus scripting, so i would be very thankfully for any help.

 

tyty

Link to comment
Share on other sites

You can get player from Game.GetPlayer() as an actor. Actor script extends ObjectReference, so you should be able to use all the methods of ObjectReference with an Actor. There seem to be structs as a new thing in Papyrus now, too, with Fallout 4, I have not looked at them too closely myself yet, but maybe you could use one to store all your info?

 

See this page: http://www.creationkit.com/fallout4/index.php?title=ObjectReference_Script

And maybe this: http://www.creationkit.com/fallout4/index.php?title=Actor_Script

And this for structs: http://www.creationkit.com/fallout4/index.php?title=Struct_Reference

 

For example like this:

Struct PlayerPos
    float fPosX = 0.0
    float fPosY = 0.0
    float fPosZ = 0.0
    float fAngX = 0.0
    float fAngY = 0.0
    float fAngZ = 0.0
EndStruct

PlayerPos Function GetPlayerInfo()
    Actor rPlayer = Game.GetPlayer()
    PlayerPos rTemp = new PlayerPos
    rTemp.fPosX = rPlayer.X
    rTemp.fPosY = rPlayer.Y
    rTemp.fPosZ = rPlayer.Z
    rTemp.fAngX = rPlayer.GetAngleX()
    rTemp.fAngY = rPlayer.GetAngleY()
    rTemp.fAngZ = rPlayer.GetAngleZ()
    Return rTemp
EndFunction

Like I said, I have not done anything real with those Papyrus structs yet. They seem to be a bit limited, though, I tried to initialise the values inside the struct to the relevant info directly using those commands now placed in that separate function, but it refused to compile. You can do more testing to see if there is a more reasonable way to do things. But that might be one idea. If that helps. Another option would be to use an array.

 

Hopefully that helps a little. Happy scripting. :thumbsup:

Edited by Contrathetix
Link to comment
Share on other sites

To add to that and asumming what i know about papyrus scripting applies to fallout 4, some corrections need to be made to the Z angle to get accurate north-south-etc direction while in interiors, not sure if its needed for what you want to do but just in case.. straight copy of a fragment of the script of a compass for skyrim i started developing a while ago but never finished:

Float MyAngle = PlayerRef.GetAngleZ() ; north=0, east=90, south=180, west=270
If PlayerRef.IsInInterior() 
ObjectReference NorthMarkerRef = Game.FindClosestReferenceOfTypeFromRef(NorthMarker, PlayerRef, 10000.0); find a north marker (i guess they exist in fallout 4 just like in skyrim)
If NorthMarkerRef
MyAngle -= (NorthMarkerRef.GetAngleZ())
NorthMarkerRef = None
If MyAngle < 0
MyAngle += 360
Endif
Endif
Endif
Edited by FrankFamily
Link to comment
Share on other sites

  • Recently Browsing   0 members

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