Jump to content

moving objects with scripts


d1vanov

Recommended Posts

Hello there.

 

Maybe someone here remembers my "Leather backpack" mod. It was abandoned for some months but now I'm working on it again. And I need a bit of help with scripting.

 

For those who don't know or remember the mentioned mod I'll explain: I have a model of a backpack. When it's dropped on the floor and being activated, the PC gets the menu to open the backpack, take it or unfold the mattress which backpack contains. The last aspect of the mod is a bit buggy because sometimes the mattress appears with weird angles.

 

Here goes my story:

The idea was following: as long as the PC chooses the "Unfold the mattress" option, the quest variable "PlacingMattress" is being set to 1. In the quest script I have a following block inside the GameMode section:

 

if (PlacingMattress == 1)	 
Set rLBMattressMarker to Player.PlaceAtMe LBMattressMarker 1
Set PlacingMattress to 2
endif

if ( PlacingMattress == 2 )

; Using the script from "Useful scripts" page on geck wiki
; http://geck.bethsoft.com/index.php/Useful_Scripts
Set PlayerXAngle to Player.GetAngle x
Set PlayerZAngle to Player.GetAngle z * -1 + 90

if ( PlayerXAngle <= 5 )
	Set Lont to 1300;  you can change this value if you need to
else
	if ( Player.IsSneaking == 0 )
		Set PlayerHeight to 322
	else
		Set PlayerHeight to 252
	endif
	Set Lont to (PlayerHeight * cos PlayerXAngle / sin PlayerXAngle * 0.34118010537042257764)
endif

Set PlayerXAngle to Player.GetAngle x * -1

Set MarkerX to Lont * cos PlayerXAngle * cos PlayerZAngle
Set MarkerY to Lont * cos PlayerXAngle * sin PlayerZAngle

rLBMattressMarker.MoveTo Player MarkerX MarkerY 0

endif

if ( (PlacingMattress == 2) && (IsKeyPressed 49) )
; N button is pressed
Set rLBMattress to rLBMattressMarker.PlaceAtMe LBMattress 1
rLBMattressMarker.Disable
rLBMattressMarker.MarkForDelete
rLBMattress.SetPos x MarkerX
rLBMattress.SetPos y MarkerY
Set PlacingMattress to 0
endif

 

As you can see, at first I want to place the mattress marker and then with pressing N to confirm the position for the mattress itself to show up. This is done to avoid any potential problems with the mesh with furniture markers. The mattress marker model is a model without furniture markers and with Layer = OI_CLUTTER in the collision properties, so it should animate just fine. But in the game I see that there's no real animation, the mattress marker is too slow to follow the crosshair instantly, it just updates its position and angles once per second or two.

 

What am I doing wrong?

Edited by d_ivanov
Link to comment
Share on other sites

Hi there!

 

Im a total scripting noob and admire all poeple doing this. Anyway even tho my help may be not that much in depth, have you already taken a look at the placable lights mod? It has about the same or very similar functionality. And also you can search for "portable" and look at the scripts you find in those mods, to maybe learn something more about it. Good luck!

 

PS: I dunno about your collision, but i would try to make sure, you are using a very basic object first and try to make it work with that, then work your way up to slightly more complicated matters including furniture markers, special effects and whatnot.

Edited by Nadimos
Link to comment
Share on other sites

Nadimos, thank you for the response.

 

I've tried to analyze some mods with more complicated scripts - like RTS New Wave and Feng Shui. I've even managed to understand a couple of things there )) But they seem not to have something to do with my problems with extremely slow animation. I'll check out the mod you mentioned and maybe some others, thanks again for the advice.

Link to comment
Share on other sites

It sounds like the quest delay time.

To make the object appear smoother, temporarily reduce the delay.

 

 

if (PlacingMattress == 1)        
       Set rLBMattressMarker to Player.PlaceAtMe LBMattressMarker 1
       Set PlacingMattress to 2
       SetQuestDelay YourQuestName .001 ; Run every frame. <------------------------ Edit quest name
elseif ( PlacingMattress == 2 )

       ; Using the script from "Useful scripts" page on geck wiki
       ; http://geck.bethsoft.com/index.php/Useful_Scripts
       Set PlayerXAngle to Player.GetAngle x
       Set PlayerZAngle to Player.GetAngle z * -1 + 90

       if ( PlayerXAngle <= 5 )
               Set Lont to 1300;  you can change this value if you need to
       else
               if ( Player.IsSneaking == 0 )
                       Set PlayerHeight to 322
               else
                       Set PlayerHeight to 252
               endif
               Set Lont to (PlayerHeight * cos PlayerXAngle / sin PlayerXAngle * 0.34118010537042257764)
       endif

       Set PlayerXAngle to Player.GetAngle x * -1

       Set MarkerX to Lont * cos PlayerXAngle * cos PlayerZAngle
       Set MarkerY to Lont * cos PlayerXAngle * sin PlayerZAngle

       rLBMattressMarker.MoveTo Player MarkerX MarkerY 0

       if (IsKeyPressed 49) )
               ; N button is pressed
               Set rLBMattress to rLBMattressMarker.PlaceAtMe LBMattress 1
               rLBMattressMarker.Disable
               rLBMattressMarker.MarkForDelete
               rLBMattress.SetPos x MarkerX
               rLBMattress.SetPos y MarkerY
               Set PlacingMattress to 0
               SetQuestDelay YourQuestName 5 ; Reduce to default. <------------------------ Edit quest name
       endif
endif

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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