Page 1 of 1

Sit down scripting help please

PostPosted: Sat Aug 01, 2009 3:05 pm
by SpiritedTreasure
Hello.

I am making a private house mod for my char. (I can't share because I'm using stuff from Ob. )
I'm trying to make a few chairs sittable. I know it can and has been done using the sitting pants armor.
so I have the original script. I know this one works, I've used it in many games.

Begin Pam_Barhocker32script

short sitzt

if ( MenuMode == 1 )
       return
endif

if ( GetDistance Player > 300 )
       if ( Player-> GetItemCount "Pam_Hockerhose_1" >= 1 )
               Player-> RemoveItem "Pam_Hockerhose_1" 1
       endif
       if ( sitzt >= 1 )
               set sitzt to 0
       endif
endif

if ( OnActivate == 1 )
       if ( sitzt == 0 )
               set sitzt to 1
       endif
       if ( sitzt == 2 )
               set sitzt to 3
       endif
endif

if ( sitzt == 1 )
       if ( Player->GetRace "Argonian" == 1)
               setpos z 142
       elseif ( Player->GetRace "Breton" == 1)
               setpos z 142
       elseif ( Player->GetRace "Dark Elf" == 1)
               setpos z 145
       elseif ( Player->GetRace "High Elf" == 1)
               setpos z 151
       elseif ( Player->GetRace "Imperial" == 1)
               setpos z 145
       elseif ( Player->GetRace "Khajiit" == 1)
               setpos z 141
       elseif ( Player->GetRace "Nord" == 1)
               setpos z 149
       elseif ( Player->GetRace "Orc" == 1)
               setpos z 149
       elseif ( Player->GetRace "Redguard" == 1)
               setpos z 146
       elseif ( Player->GetRace "Wood Elf" == 1)
               setpos z 143
       endif
       "Player"-> PositionCell -163 -82 94 90 "Vos, Varo Tradehouse"
       Player-> AddItem "Pam_Hockerhose_1" 1
       Player-> equip "Pam_Hockerhose_1"
       set sitzt to 2
endif

if ( sitzt == 3 )
       Player-> PositionCell -141 -28 130 45 "Vos, Varo Tradehouse"
       Player-> RemoveItem "Pam_Hockerhose_1" 1
       setpos z 151
       set sitzt to 0
endif

end


and my script which sent her somewhere in timbucktoo with no sitting pants on.
When I delete the last 3 numbers in the placements so that it reads like this instead
4875 5153 12836 0
it puts her standing up backwards in the middle of the bench (no collision?)with no sitting pants on. Then when activated again to have her stand up the bench gets deleted.

Begin 1SpiritSit03script

short sitzt

if ( MenuMode == 1 )
       return
endif

if ( GetDistance Player > 300 )
       if ( Player-> GetItemCount "_stvvsitpant" >= 1 )
               Player-> RemoveItem "_stvvsitpant" 1
       endif
       if ( sitzt >= 1 )
               set sitzt to 0
       endif
endif

if ( OnActivate == 1 )
       if ( sitzt == 0 )
               set sitzt to 1
       endif
       if ( sitzt == 2 )
               set sitzt to 3
       endif
endif

if ( sitzt == 1 )
       if ( Player->GetRace "Argonian" == 1)
               setpos z 142
       elseif ( Player->GetRace "Breton" == 1)
               setpos z 142
       elseif ( Player->GetRace "Dark Elf" == 1)
               setpos z 145
       elseif ( Player->GetRace "High Elf" == 1)
               setpos z 151
       elseif ( Player->GetRace "Imperial" == 1)
               setpos z 145
       elseif ( Player->GetRace "Khajiit" == 1)
               setpos z 141
       elseif ( Player->GetRace "Nord" == 1)
               setpos z 149
       elseif ( Player->GetRace "Orc" == 1)
               setpos z 149
       elseif ( Player->GetRace "Redguard" == 1)
               setpos z 146
       elseif ( Player->GetRace "Wood Elf" == 1)
               setpos z 143
       endif
       "Player"-> PositionCell 4875 5153 12836 0 0 160 "Grey Haven Manor"
       Player-> AddItem "_stvvsitpant" 1
       Player-> equip "_stvvsitpant"
       set sitzt to 2
endif

if ( sitzt == 3 )
       Player-> PositionCell 4943 5126 12871 0 0 304 "Grey Haven Manor"
       Player-> RemoveItem "_stvvsitpant" 1
       setpos z 234
       set sitzt to 0
endif

end


And the one from Princess Stomper's Leyawiin mod for comparison.
I know for a fact this works correctly because I have that mod installed right now.

Begin 1jw_tes3c_PBar01script

short sitzt

if ( MenuMode == 1 )
       return
endif

if ( GetDistance Player > 300 )
       if ( Player-> GetItemCount "1jw_tes3c_Pam_Hockerhose_1" >= 1 )
               Player-> RemoveItem "1jw_tes3c_Pam_Hockerhose_1" 1
       endif
       if ( sitzt >= 1 )
               set sitzt to 0
       endif
endif

if ( OnActivate == 1 )
       if ( sitzt == 0 )
               set sitzt to 1
       endif
       if ( sitzt == 2 )
               set sitzt to 3
       endif
endif

if ( sitzt == 1 )
       if ( Player->GetRace "Argonian" == 1)
               setpos z -239
       elseif ( Player->GetRace "Breton" == 1)
               setpos z -239
       elseif ( Player->GetRace "Dark Elf" == 1)
               setpos z -236
       elseif ( Player->GetRace "High Elf" == 1)
               setpos z -230
       elseif ( Player->GetRace "Imperial" == 1)
               setpos z -236
       elseif ( Player->GetRace "Khajiit" == 1)
               setpos z -240
       elseif ( Player->GetRace "Nord" == 1)
               setpos z -232
       elseif ( Player->GetRace "Orc" == 1)
               setpos z -232
       elseif ( Player->GetRace "Redguard" == 1)
               setpos z -245
       elseif ( Player->GetRace "Wood Elf" == 1)
               setpos z -238
       else
               setpos z -238
       endif
       "Player"-> PositionCell 10010 7114 -287 180 "Leyawiin, Mizu House"
       Player-> AddItem "1jw_tes3c_Pam_Hockerhose_1" 1
       Player-> equip "1jw_tes3c_Pam_Hockerhose_1"
       set sitzt to 2
endif

if ( sitzt == 3 )
       Player-> PositionCell 10012 7072 -230 90 "Leyawiin, Mizu House"
       Player-> RemoveItem "1jw_tes3c_Pam_Hockerhose_1" 1
       setpos z -230
       set sitzt to 0
endif

end



Thank you for your time =s=

Re: Sit down scripting help please

PostPosted: Sat Aug 01, 2009 3:34 pm
by Fliggerty
Without having this to actually play around with, I'm just taking stabs in the dark.  But let's see what we can figure out, eh?  :sheo:

There is no command in the script to delete the bench, so I strongly suspect it is some sort of engine bug creeping in here.  The first suspicious thing I see is the ID's you are using.  "_stvvsitpant" could very well be the cause of all the problems.  Using a "_" at the beginning of the ID in a script can indeed cause very weird behavior; Morrowind's script engine doesn't differentiate functions very well when it sees certain characters like that (because they are used commonly in C++ syntax) at the beginning of an ID.  It's an engine bug that we have to work around.  So first try changing the ID and see if that helps.  Just add a unique prefix to the beginning of it or something.

As for the issue with PositionCell, you want to only have 4 values in there.  The last one is the Z-axis rotation, and I believe it is in radians rather than degrees.  So it could just be that the value you have in there is invalid, and so it sends you to the default 0,0,0 coordinates.  So you do want to have "4875 5153 12836 0" as the parameters.

If none of that helps, try replacing this (sans the changes I already suggested:)
Code: Select all
      "Player"-> PositionCell 4875 5153 12836 0 0 160 "Grey Haven Manor"
      Player-> AddItem "_stvvsitpant" 1
      Player-> equip "_stvvsitpant"
      set sitzt to 2

With this:
Code: Select all
      "Player"->PositionCell 4875 5153 12836 0 0 160 "Grey Haven Manor"
      Player->equip "_stvvsitpant"
      set sitzt to 2


If you don't have something that is called with Equip, it will automatically be added to inventory.  It's one less step for the engine to screw up on.  Also note that I removed the space between "->" and "equip."  Correct scripting syntax is having no spaces around -> in any situation.

Good luck and let me know how it goes!

Re: Sit down scripting help please

PostPosted: Sat Aug 01, 2009 7:41 pm
by Dragon_Lance
Hi, Spirited! :D

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 5:04 am
by SpiritedTreasure
Fliggerty , Thanks =s=
I'll give that a try and post back today or tomorrow.

Dragon Lance , Hi =s=

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 9:34 am
by SpiritedTreasure
Ok new script. She sits down with the pants on properly, but she is backwards and a ways away from where I want her. Hovering above the seat.
She stands up and removes the pants properly But still backwards.. Bench is also removed. I wanted the bench to stay for future sitting sessions. Not just one time.


Image


Image

I'm using the numbers that appear at the bottom of the cs screen when placing the testing dummy in the seat.


Begin 1SpiritSit01script

short sitzt

if ( MenuMode == 1 )
      return
endif

if ( GetDistance Player > 300 )
      if ( Player->GetItemCount "1stebsitpant" >= 1 )
              Player->RemoveItem "1stebsitpant" 1
      endif
      if ( sitzt >= 1 )
              set sitzt to 0
      endif
endif

if ( OnActivate == 1 )
      if ( sitzt == 0 )
              set sitzt to 1
      endif
      if ( sitzt == 2 )
              set sitzt to 3
      endif
endif

if ( sitzt == 1 )
      if ( Player->GetRace "Argonian" == 1)
              setpos z 142
      elseif ( Player->GetRace "Breton" == 1)
              setpos z 142
      elseif ( Player->GetRace "Dark Elf" == 1)
              setpos z 145
      elseif ( Player->GetRace "High Elf" == 1)
              setpos z 151
      elseif ( Player->GetRace "Imperial" == 1)
              setpos z 145
      elseif ( Player->GetRace "Khajiit" == 1)
              setpos z 141
      elseif ( Player->GetRace "Nord" == 1)
              setpos z 149
      elseif ( Player->GetRace "Orc" == 1)
              setpos z 149
      elseif ( Player->GetRace "Redguard" == 1)
              setpos z 146
      elseif ( Player->GetRace "Wood Elf" == 1)
              setpos z 143
      endif
      "Player"->PositionCell 5831 4859 12522 0 "Grey Haven Manor"
      Player->AddItem "1stebsitpant" 1
      Player->equip "1stebsitpant"
      set sitzt to 2
endif

if ( sitzt == 3 )
      Player->PositionCell 5776 4863 12559 0 "Grey Haven Manor"
      Player->RemoveItem "1stebsitpant" 1
      setpos z 234
      set sitzt to 0
endif

end


Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 9:46 am
by SpiritedTreasure
Maybe do I need to add this

    else
              setpos z -238


because she is a custom race? She is the same size as a breton

like this?

if ( sitzt == 1 )
     if ( Player->GetRace "Argonian" == 1)
             setpos z 142
     elseif ( Player->GetRace "Breton" == 1)
             setpos z 142
     elseif ( Player->GetRace "Dark Elf" == 1)
             setpos z 145
     elseif ( Player->GetRace "High Elf" == 1)
             setpos z 151
     elseif ( Player->GetRace "Imperial" == 1)
             setpos z 145
     elseif ( Player->GetRace "Khajiit" == 1)
             setpos z 141
     elseif ( Player->GetRace "Nord" == 1)
             setpos z 149
     elseif ( Player->GetRace "Orc" == 1)
             setpos z 149
     elseif ( Player->GetRace "Redguard" == 1)
             setpos z 146
     elseif ( Player->GetRace "Wood Elf" == 1)
             setpos z 143
 else
              setpos z -238
     endif


and which one of the numbers at the bottom of the screen is the z positon? is that the 160 number?

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 10:46 am
by Fliggerty
The SetPos Z lines are moving the chair itself up or down a little bit to match the height of the player.  That needs to be adjusted to match your bench specifically.  AFAIK, they got those numbers solely with trial and error.  Take a look at the mods that those scripts are from and see what the editor position shows that the Z axis is for one of those chairs, and compare that with the SetPos Z lines in the script.  That may give you an idea of how much the bench needs to move.

After the Else, put the same value there that you have for the Breton check.

The editor position displays like x pos, y pos, z pos [x rotation, yrot, zrot] IIRC.

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 11:06 am
by SpiritedTreasure
What could be making that bench dissapear? It's not supposed to do that.

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 2:31 pm
by Fliggerty
SpiritedTreasure wrote:What could be making that bench dissapear? It's not supposed to do that.


This is:
Code: Select all
setpos z -238


It is probably dropping it below the floor.  If you ToggleCollision after it disappears, I bet you will see it underneath the floor.

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 2:41 pm
by SpiritedTreasure
so I need to delete all those?

if ( sitzt == 1 )
    if ( Player->GetRace "Argonian" == 1)
            setpos z 142
    elseif ( Player->GetRace "Breton" == 1)
            setpos z 142
    elseif ( Player->GetRace "Dark Elf" == 1)
            setpos z 145
    elseif ( Player->GetRace "High Elf" == 1)
            setpos z 151
    elseif ( Player->GetRace "Imperial" == 1)
            setpos z 145
    elseif ( Player->GetRace "Khajiit" == 1)
            setpos z 141
    elseif ( Player->GetRace "Nord" == 1)
            setpos z 149
    elseif ( Player->GetRace "Orc" == 1)
            setpos z 149
    elseif ( Player->GetRace "Redguard" == 1)
            setpos z 146
    elseif ( Player->GetRace "Wood Elf" == 1)
            setpos z 143
else
             setpos z -238
    endif

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 2:53 pm
by Fliggerty
No, don't do that.  Go and find out what the Z pos of the bench is in the game (or in the editor.)  Those values in the script should be very close to that, probably only a few numbers off.

See if you can see how much they differ in Princess_Stomper's script from the Z pos of the chair used in her mod.

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 3:02 pm
by SpiritedTreasure
Ok thanks!

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 3:40 pm
by SpiritedTreasure
Ok Almost! =g=

She sat down properly with the sitting pants on
she stood up properly with them off
the bench did not dissapear.

BUT!
she is absolutely backwards from the way I want her. She is also still way too high up!

bench co-ordinates
Image

tester dummy co-ordinates
Image

Image

Image

=edit=

new script

Begin 1SpiritSit01script

short sitzt

if ( MenuMode == 1 )
      return
endif

if ( GetDistance Player > 300 )
      if ( Player->GetItemCount "1stebsitpant" >= 1 )
              Player->RemoveItem "1stebsitpant" 1
      endif
      if ( sitzt >= 1 )
              set sitzt to 0
      endif
endif

if ( OnActivate == 1 )
      if ( sitzt == 0 )
              set sitzt to 1
      endif
      if ( sitzt == 2 )
              set sitzt to 3
      endif
endif

if ( sitzt == 1 )
      if ( Player->GetRace "Argonian" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Breton" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Dark Elf" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "High Elf" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Imperial" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Khajiit" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Nord" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Orc" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Redguard" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Wood Elf" == 1)
              setpos z 12598.018
      endif
      "Player"->PositionCell 5831 4859 12522 0 "Grey Haven Manor"
      Player->AddItem "1stebsitpant" 1
      Player->equip "1stebsitpant"
      set sitzt to 2
endif

if ( sitzt == 3 )
      Player->PositionCell 5776 4863 12559 0 "Grey Haven Manor"
      Player->RemoveItem "1stebsitpant" 1
      setpos z 12598.018
      set sitzt to 0
endif

end


Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 4:57 pm
by Fliggerty
The computer I'm on at work won't load the images, so I can't see the coords right now.  :s

To turn her, modify this line:
Code: Select all
"Player"->PositionCell 5831 4859 12522 0 "Grey Haven Manor"


I still can't remember exactly if the z rot takes degrees or radians (I know some functions take one, some take the other...usually I look it up in MWSFD.)  But to turn her around completely, try this:
Code: Select all
"Player"->PositionCell 5831 4859 12522 180 "Grey Haven Manor"


Then to lower her position, modify this:
Code: Select all
setpos z 12598.018


The lower the value, the lower the bench will sit, and vice versa.  You might also try decreasing the z pos value (12522) in the PositionCell call, but I doubt that will work since the player will probably be adjusted by the engine to remain on the floor (which is why they move the chair up and down.)


You know, I've never really looked at anybody's sitting scripts before.  They are actually fairly simple in principle.  This gives me ideas.....

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 6:48 pm
by SpiritedTreasure
Thanks! I'll give it a try =s=

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 7:03 pm
by Fliggerty
Let me know how it goes.  :sheo:

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 7:38 pm
by SpiritedTreasure
Taking her down a couple of notches worked. And turning her around 178 also worked. Thank you! =vbs= Now I can sort a couple more sitting chairs =s=
We really really need a better bodies version of these =s= they clip horribly =L=

Image

Thank you!!!

=edit=

final script

Begin 1SpiritSit01script

short sitzt

if ( MenuMode == 1 )
      return
endif

if ( GetDistance Player > 300 )
      if ( Player->GetItemCount "1stebsitpant" >= 1 )
              Player->RemoveItem "1stebsitpant" 1
      endif
      if ( sitzt >= 1 )
              set sitzt to 0
      endif
endif

if ( OnActivate == 1 )
      if ( sitzt == 0 )
              set sitzt to 1
      endif
      if ( sitzt == 2 )
              set sitzt to 3
      endif
endif

if ( sitzt == 1 )
      if ( Player->GetRace "Argonian" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Breton" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Dark Elf" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "High Elf" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Imperial" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Khajiit" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Nord" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Orc" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Redguard" == 1)
              setpos z 12598.018
      elseif ( Player->GetRace "Wood Elf" == 1)
              setpos z 12598.018
      endif
      "Player"->PositionCell 5831 4859 12518 178 "Grey Haven Manor"
      Player->AddItem "1stebsitpant" 1
      Player->equip "1stebsitpant"
      set sitzt to 2
endif

if ( sitzt == 3 )
      Player->PositionCell 5776 4863 12559 178 "Grey Haven Manor"
      Player->RemoveItem "1stebsitpant" 1
      setpos z 12598.018
      set sitzt to 0
endif

end


=edit again=

I need to move her farther away from the bench when she stands up. Collision was keeping her there =L= had to jump a few times to break free.. Other than that I can't remember if I lowered it to 18 or 19 but it wasn't much.

Re: Sit down scripting help please

PostPosted: Sun Aug 02, 2009 8:58 pm
by Fliggerty
Fantastic!

Re: Sit down scripting help please

PostPosted: Fri Aug 07, 2009 2:19 pm
by SpiritedTreasure
ONe little note for those in the future wanting to also sit down..

The game appears to only be able to handle ONE sitting chair per cell. I tried adding several and the whole damn thing went wonky.. Put it back to one and it was fine =s=