Jump to content

[LE] Scripting: Trying to put the player at an arbitrary point, but they always go to the floor.


monsto

Recommended Posts

In game using the console, I can go player.setpos z 256. assuming the floor is at zero, the player is set up there, then they fall to the floor. If tcl is active (collision off) then they'll hang in air. You can do this for any non-construction static.

 

Using a script, the player seemingly cannot be put up in the air. The script equivalent would be Game.GetPlayer().SetPosition(<parms>) coupled with ToggleCollision(). This however doesn't even raise the player off the floor.

 

The script does everything I need it to do, my problem now is finding a way to achieve this effect.

 

The question is what do I need to be able to do to put the player in mid air?

 

I've used a marker with Game.GetPlayer().MoveTo(<marker>) and they go to the XY but not Z

 

I've tried using an iron dagger... to set the position I have to be in tcl and ending that mode drops the dagger to the floor.

 

The little map flag stays where you put it because it's a MiscObj, but it seemed to break the entire script.

Link to comment
Share on other sites

You wrote: "what do I need to be able to do to put the player in mid air?"

 

Have you ever tried this? http://www.creationkit.com/index.php?title=SetRestrained_-_Actor

Game.GetPlayer().SetRestrained()  ; be careful with that code

Do not forget to check what is happen about restrain status after your script has been removed, caused by mod uninstall !!

 

Additional info about package templates:

http://www.creationkit.com/index.php?title=HoldPosition_(Package_Template)

 

Are you suggesting that I move the player into position, then 'restrain' them to that position?

 

That won't work. When I Game.GetPlayer().SetPosition(x, y, 256), the player never goes to 256 at all. As said in the OP, player will set to the XY but stay on the floor of the cell.

Link to comment
Share on other sites

I quote because it helps with notification. Depending on the board, if you're just a participant and not the op, you won't get a notification of further action in the thread. On IPB forums default, quoting is the best way to make sure notifications are sent.

 

The code works completely as expected. It drops position markers, and when prompted it attempts to set me at the marker. It's the method/function to use as traversal that doesn't set Z position. And it's behaviours are really consistent between MoveTo and SetPosition functions which makes me suspect that I've bumped up against some kind of a limitation.

 

I tried TranslateToRef, which works as expected from its description... but with the exception that the player never rotates, regardless of DisablePlayerControls.

 

on MoveTo i missed the MatchRotation flag. Even tho it defaults to true, it only sets Z (compass) angle and not X (up/dn)

 

is there a way to feed console commands as opposed to using scripting functions? If I could tell it to TCL then player.moveto, it probably wouldn't be as efficient as far as the game is concerned, but it would apparently achieve the goal.

 

Thanks again for the replies.

Edited by monsto
Link to comment
Share on other sites

I had originally asked in the last post

 

how do you mean "make the player static"? ARe you talking about DisablePlayerControls or related?

 

 

But I had missed where you mentioned SetMotionType. That makes a lot of sense. I'll try that now.

 

My other question about feeding out console commands is still relevant tho.

 

thanks again.

Link to comment
Share on other sites

Welp . . . no love.

 

  • Bracketing any of the move functions with Game.GetPlayer().SetMotionType() (4 then 1) had no effect.
  • Game.GetPlayer().TranslateToRef(x, 500, 120) (x is the ObjRef) slides the player to the XYZ destination, but without changing any angles.
  • putting Game.GetPlayer().SetAngle(x.GetAngleX(), x.GetAngleY(), x.GetAngleZ()) along with the above translation first puts the player on the floor then slides the player from there to XYZ destination, setting Z angle but not X angle.
  • a note on SetAngle discussion tab said that X angle wouldn't be set without toggling collision. Following the code snippet on the page, bracketing translate, moveto or setpos/angle with Debug.ToggleCollisions() had no effect.

Either there's some kind of limitation there, or I've fat-fingered and been blind to a typo so here's the code. It's unclean right now as it's the aftermath of inserting, changing, commenting all these attempts, but the crux is there and should be clear enough.

 

Scriptname CameraTourNodes extends activemagiceffect  
{Go from one camera node to another after a short wait}


Furniture Property CamMarker  Auto  
Keyword Property isCameraMarker Auto
{camera marker}


Function mbMovePlayerTo(ObjectReference x)
    {Get the position of the marker and set the position of the player.}
    Debug.ToggleCollisions()
    ;Game.GetPlayer().SetPosition(x.GetPositionX(), x.GetPositionY(), x.GetPositionZ())
    Game.GetPlayer().SetAngle(x.GetAngleX(), x.GetAngleY(), x.GetAngleZ())
    Debug.ToggleCollisions()
endFunction


EVENT OnEffectStart(Actor akTarget, Actor akCaster)
    ; what cell?
    Cell kCell = Game.GetPlayer().GetParentCell()
    
    ; Get number of furnitures in cell
    int numfurns = kCell.GetNumRefs(40)
    int furncount = numfurns ; keep the original count


    int i = 0


    ; start the traversal
    While (i < furncount)
        Game.GetPlayer().SetMotionType(4)


        game.disableplayercontrols(true, true, true, true, true, true, true, true, 0)
        ObjectReference x = kCell.GetNthRef(i, 40)
        Debug.Notification(i + "/" + numfurns + ": " + x)
        if x.HasKeyword(isCameraMarker)
            ;mbMovePlayerTo(x)


            ;/Debug.ToggleCollisions()
            Game.GetPlayer().SetPosition(x.GetPositionX(), x.GetPositionY(), x.GetPositionZ())
            Game.GetPlayer().SetAngle(x.GetAngleX(), x.GetAngleY(), x.GetAngleZ())
            Debug.ToggleCollisions()/;
            
            Debug.ToggleCollisions()
            ;Game.GetPlayer().TranslateToRef(x, 500, 120)
            Game.GetPlayer().MoveTo(x, abMatchRotation = true)
            Utility.wait(3) ; bask
            Debug.ToggleCollisions()


        endif
        i += 1


        Game.GetPlayer().SetMotionType(1)
    endWhile
    game.enableplayercontrols(true, true, true, true, true, true, true, true, 0)
endEvent

 

If you want to see the entire mod, I have it up on BitBucket and will give you access if you want.

Edited by monsto
Link to comment
Share on other sites

The game forces actors to a surface if they would be placed too far away from some place that would support them to avoid having them accidentally fall to their deaths like would happen in previous games. You might be able to place some item (and invisible collision plane) just below where the player should appear, move the player, let the player settle on to the platform, and then remove it if you want them to fall (or leave it until the player moves somewhere else).

Link to comment
Share on other sites

The game forces actors to a surface if they would be placed too far away from some place that would support them to avoid having them accidentally fall to their deaths like would happen in previous games. You might be able to place some item (and invisible collision plane) just below where the player should appear, move the player, let the player settle on to the platform, and then remove it if you want them to fall (or leave it until the player moves somewhere else).

 

Thanks. I was . . . well, beyond just beginning to suspect something like that. a collision plane it is then.

 

Have any thoughts on the whole "cant rotate player on X" deal? At no point thruout this whole deal have I been able to force vertical view rotation onto the player. Z (compass) happens under the right circumstances, but never X.

 

2ndarily . . . is this spelled out somewhere in the documentation? This is my favorite part of this whole thing that necessary papyrus knowledge doesn't exist anywhere concretely, it's passed down thru the generations from father to son like witch doctor rituals or geopoliticial secrets.

Edited by monsto
Link to comment
Share on other sites

You can try moving the player to a heading marker to control facing, but I think part of the adjustment automatically forces the player to look straight ahead.

 

And yes, unfortunately many little things like this are just passed along by word of mouth because no one ever thinks to document them on the CK Wiki. It's publicly editable and I've added some things in the past but like so many others I just don't think about it or decide it would take too much time in most cases. There's also the problem of deciding where exactly you would document something like this.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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