Script help - moving platform

Post » Thu Dec 24, 2009 4:58 am

Hey there,

I am tearing my hair out over this script - but it's just not working. If someone can fix it/write a new one from scratch I would much appricate it.

The script essentailly is designed that when the palyer steps on the activator ( a floor/platform) it moves downwards but its not working :(. Nothing happens at all.

Begin sm_GN_Falmer_PitBlock_Script


short PlatformMoving

Float timer
Float PitTimer

If ( CellChanged == 1 )
Set PlatformMoving to 100
Endif

If ( PlatformMoving == 0 )
If ( GetStandingPC == 1 ) ; PC Activate
Messagebox "the trap works?"
Set PitTimer to ( PitTimer + getsecondspassed )
If ( PitTimer >= .3 )
Set PlatformMoving to 1
EndIf
ElseIf ( GetStandingActor == 1 ) ; NPC/AI Activate
Set PitTimer to ( PitTimer + getsecondspassed )
If ( PitTimer >= .3 )
Set PlatformMoving to 1
EndIf
Else
Return
Endif
Endif

If ( PlatformMoving == 100 )
Set timer to 0
"sm_GN_Falmer_Pit_Block"->SetAtStart
Set PlatformMoving to 0

Elseif ( PlatformMoving == 1 )
Set timer to ( timer + getsecondspassed )
If ( timer <= .5 )
"sm_GN_Falmer_Pit_Block"->MoveWorld z -1090 ; Block moves down fast
Else
Set timer to 0
Set PlatformMoving to 2
Endif

Elseif ( PlatformMoving == 2 )
Set timer to ( timer + getsecondspassed )
If ( timer <= 7 ) ; Wait before moving again
Return
Else
Set timer to 0
Set PlatformMoving to 3
Endif

Elseif ( PlatformMoving == 3 )
Set timer to ( timer + getsecondspassed )
If ( timer <= 3 )
"sm_GN_Falmer_Pit_Block"->MoveWorld z 181 ; Moves up slowly
Else
Set timer to 0
Set PlatformMoving to 4
"sm_GN_Falmer_Pit_Block"->SetAtStart
Endif

Elseif ( PlatformMoving == 4 )
Set timer to ( timer + getsecondspassed )
If ( timer >= 5 ) ; Give 5 second reset
Set timer to 0
Set PitTimer to 0
Set PlatformMoving to 0
Endif
Endif

End

User avatar
Oscar Vazquez
 
Posts: 3418
Joined: Sun Sep 30, 2007 12:08 pm

Post » Thu Dec 24, 2009 8:13 am

I would do something like this:

begin sm_GN_Falmer_PitBlock_Scriptshort statefloat sm_GN_startposfloat sm_GN_lowposfloat sm_GN_downspeedfloat sm_GN_delayfloat sm_GN_upspeedfloat sm_GN_tempfloat sm_GN_baserotationfloat sm_GN_rotatestateif ( state == 0 )    set sm_GN_startpos to GetPos, Z    set sm_GN_lowpos to sm_GN_startpos - 545 ;by adjusting the number you can set how many units the block moves downwards    set sm_GN_downspeed to -1090 ;this adjusts the falling speed of the block (unit per second)    set sm_GN_delay to 3 ;this adjests the time (in seconds) that the block waits after a fall before rising again    set sm_GN_upspeed to 181 ;this adjusts the rising speed of the block (unit per second)    set sm_GN_baserotation to GetAngle, Z    set sm_GN_rotatestate to 0.001    set state to 1endifif ( CellChanged == 1 )    set state to -1endif    if ( state == -1 )    SetPos, Z, sm_GN_startpos    SetAngle, Z, sm_GN_baserotation    set state to 1elseif ( state == 1 )    if ( GetStandingActor == 1 )        set state to 2    endifelseif ( state == 2 )    Move, Z, sm_GN_downspeed    set sm_GN_temp to GetPos, Z    if ( sm_GN_temp <= sm_GN_lowpos )        SetPos, Z, sm_GN_lowpos        set sm_GN_temp to 0        set state to 3    endif    Disable    Enable    Rotate, Z, sm_GN_rotatestate    set sm_GN_rotatestate to sm_GN_rotatestate * -1elseif ( state == 3 )    set sm_GN_temp to sm_GN_temp + GetSecondsPassed    if ( sm_GN_temp >= sm_GN_delay )        set sm_GN_temp to 0        set state to 4    endifelseif ( state == 4 )    Move, Z, sm_GN_upspeed    set sm_GN_temp to GetPos, Z    if ( sm_GN_temp >= sm_GN_startpos )        SetPos, Z, sm_GN_startpos        set sm_GN_temp to 0        set state to 1    endif    Disable    Enable    Rotate, Z, sm_GN_rotatestate    set sm_GN_rotatestate to sm_GN_rotatestate * -1endifend


Let me know if that doesn't work. :)

Edit: I had trouble SetAtStart working in the past, so I've replaced those.
User avatar
Michelle davies
 
Posts: 3509
Joined: Wed Sep 27, 2006 3:59 am

Post » Thu Dec 24, 2009 5:13 am

Ah I see you're finally tackling this Midge. Strange that the script didn't work for you, that was copied straight from my testing .esp for the traps and it worked then. Oh well, I'm certainly no scripting genius and Adul's looks good.

As I stated before, you may have problem with falling/clipping through the block when it's rising back up in laggy situations. The block may somehow need to be disabled/enabled every frame to hopefully prevent that problem. The various "boating" mods out there do this.
User avatar
Hella Beast
 
Posts: 3434
Joined: Mon Jul 16, 2007 2:50 am

Post » Thu Dec 24, 2009 3:43 am

Ah I see you're finally tackling this Midge. Strange that the script didn't work for you, that was copied straight from my testing .esp for the traps and it worked then. Oh well, I'm certainly no scripting genius and Adul's looks good.

As I stated before, you may have problem with falling/clipping through the block when it's rising back up in laggy situations. The block may somehow need to be disabled/enabled every frame to hopefully prevent that problem. The various "boating" mods out there do this.


I have found that rather than using the enable/disable trick, a rotate command can refresh collision properly just as easily.

Specifying something like "Rotate, y, 0.001" to execute every frame during the motion where y is whatever axis makes you happy, tends to keep things going for me. Whatever works for you =)
User avatar
GRAEME
 
Posts: 3363
Joined: Sat May 19, 2007 2:48 am

Post » Thu Dec 24, 2009 3:14 am

I only pieced together the original script Midge posted, scripting isn't something I do. I hadn't seen "Rotate" being used to refresh collision before so that's new to me. Using "Rotate" would probably be easier to implement in the current script than enable/disable.
User avatar
Crystal Clear
 
Posts: 3552
Joined: Wed Aug 09, 2006 4:42 am

Post » Wed Dec 23, 2009 6:55 pm

Good points there, I've edited my above post to include Disable Enable. I've never worked with moving statics / activators before, so I do not know if that is a good solution. If rotating works better, those two lines can be replaced easily.
User avatar
Tinkerbells
 
Posts: 3432
Joined: Sat Jun 24, 2006 10:22 pm

Post » Wed Dec 23, 2009 6:54 pm

Thanks Adul :) - I will try it out.

Also - does it match the downwardss position that Ghostnull made? Its just that its supposed to go all the way down a pit to spikes at the bottom.

@ghostnull - yeah, I have been working on the Forgottenhalls again recently. I tweaked your script into diffrent variants but none worked :( - so I pm'd fligg and chainy with your script and posted here in a bids to fix it.


I have found that rather than using the enable/disable trick, a rotate command can refresh collision properly just as easily.

Specifying something like "Rotate, y, 0.001" to execute every frame during the motion where y is whatever axis makes you happy, tends to keep things going for me. Whatever works for you =)

intresting,

If i do get a problem with collision would you mind implimenting the rotate feature?
User avatar
Prisca Lacour
 
Posts: 3375
Joined: Thu Mar 15, 2007 9:25 am

Post » Wed Dec 23, 2009 6:20 pm

Certainly, if you end up with issues using the Rotate method but still want to try it, I'd be happy to help. I won't have my Morrowind PC available today, but tomorrow evening it should be back up and running. So if you'd like a second pair of eyes at that (or any time after) point feel free to PM me any files or scripts. I had never read anywhere that Rotate updated collision but while working on Elemental Magicka I found that it worked well for my projectiles and certain other things like "Path of Stone." You're also welcome to download the beta and take anything you'd like from the scripts.
User avatar
Emzy Baby!
 
Posts: 3416
Joined: Wed Oct 18, 2006 5:02 pm

Post » Thu Dec 24, 2009 9:20 am

Certainly, if you end up with issues using the Rotate method but still want to try it, I'd be happy to help. I won't have my Morrowind PC available today, but tomorrow evening it should be back up and running. So if you'd like a second pair of eyes at that (or any time after) point feel free to PM me any files or scripts. I had never read anywhere that Rotate updated collision but while working on Elemental Magicka I found that it worked well for my projectiles and certain other things like "Path of Stone." You're also welcome to download the beta and take anything you'd like from the scripts.

I've been meaning to ask you about those scripts - I have given up that mod i pm'd you about ;) - proved to over my head lol. Though some falmer spells would be nice ... hint hint ;)

:D
User avatar
mimi_lys
 
Posts: 3514
Joined: Mon Apr 09, 2007 11:17 am

Post » Wed Dec 23, 2009 9:46 pm

Well I added some rotation to that script anyway. Also, I've tuned the variables to resemble the values in your original script. You can adjust them yourself if you want faster, slower, deeper, etc, right after the "if ( state == 0 )" part. I've added some comments for ease of use.
User avatar
Laura Ellaby
 
Posts: 3355
Joined: Sun Jul 02, 2006 9:59 am

Post » Thu Dec 24, 2009 9:04 am

Thanks Adul :) - I will try it out.

Also - does it match the downwardss position that Ghostnull made? Its just that its supposed to go all the way down a pit to spikes at the bottom.



Well I added some rotation to that script anyway. Also, I've tuned the variables to resemble the values in your original script. You can adjust them yourself if you want faster, slower, deeper, etc, right after the "if ( state == 0 )" part. I've added some comments for ease of use.


Looks good. - 545 units is a little too high for the pit IIRC :) Since the script uses units now to determine the position, it'd be much easier to tweak.

To match the downward or low position of the block using Adul's script, set up the pit and block in the CS with the block flush with the top of the pit. Take note of the coordinates at the bottom of the CS window. Then move the block downwards in the CS until it's flush with the bottom, take note of the new coordinates. By subtracting the Z coordinate numbers it should give you a pretty good idea what to set "set sm_GN_lowpos to sm_GN_startpos" to. Just remember to undo the block move in the CS :)

Unless I'm horribly mistaken on the workings of the script :o
User avatar
Rachel Cafferty
 
Posts: 3442
Joined: Thu Jun 22, 2006 1:48 am

Post » Thu Dec 24, 2009 1:05 am

Ok, it must just be me :S

- that script doesnt work either. I stand on the block and..... nothing.

so I thought it might be the mesh - i applied the same script to another mesh (a rock) and again nothing.

Then I thought maybe its the cell - so I put both meshes (rock and block) at the top of the lighthouse in seyda neen and again nothing.

for some reason when I stand on the rock/block platform, they dont seem to want to move!
User avatar
Gemma Flanagan
 
Posts: 3432
Joined: Sun Aug 13, 2006 6:34 pm

Post » Thu Dec 24, 2009 6:36 am

I'm checking it in-game and tweaking it a bit. Looks like the main issue was that Move does not take local variables. There are a few other issues with it as well however, I'll try to address these and post the working script.
User avatar
Cartoon
 
Posts: 3350
Joined: Mon Jun 25, 2007 4:31 pm

Post » Thu Dec 24, 2009 12:06 am

I'm checking it in-game and tweaking it a bit. Looks like the main issue was that Move does not take local variables. There are a few other issues with it as well however, I'll try to address these and post the working script.

thanks Adul - I appricate it. Its the only thing holding back the Forgottenhalls - And the ghostnull knows how long its taken to get the forgotten halls of the ground! lol.
User avatar
Georgia Fullalove
 
Posts: 3390
Joined: Mon Nov 06, 2006 11:48 pm

Post » Wed Dec 23, 2009 9:41 pm

Ah yes, the numerous PM's we sent back and forth to each other. You needed the resources again or I was sending you updates for said resources or you wanted something new :P

Still think you should replace those crummy, earlier shard lights with the ones I recently released ;) But it's your mod and that discussion is for a PM...
User avatar
bimsy
 
Posts: 3541
Joined: Wed Oct 11, 2006 3:04 pm

Post » Thu Dec 24, 2009 7:15 am

Ah yes, the numerous PM's we sent back and forth to each other. You needed the resources again or I was sending you updates for said resources or you wanted something new :P

Still think you should replace those crummy, earlier shard lights with the ones I recently released ;) But it's your mod and that discussion is for a PM...

:P - what you mean the asian inspired lamps? And its all related to the same mod so no need to PM :D (and its also my thread so I dont mind lol)
User avatar
BethanyRhain
 
Posts: 3434
Joined: Wed Oct 11, 2006 9:50 am

Post » Wed Dec 23, 2009 6:56 pm

Fixed code is included below. I've adjusted the variables to values I found to be working best. Feel free to test them in-game and fine-tune them - I've added comments to that code section to explain what each one does. Here's the part which deals with setting up the variables (it's also in the code, just adding it here for reference):

    set sm_GN_lowpos to sm_GN_startpos - 300 ;by adjusting this number you can set how many units the block moves downwards    set sm_GN_fallspeed to -1500 ;this adjusts the falling speed of the block (units per second)    set sm_GN_risespeed to 180 ;this adjusts the rising speed of the block (units per second)    set sm_GN_predelay to 0.1 ;seconds that need to pass between the actor stepping on the block and it starting falling    set sm_GN_delay to 2 ;seconds that need to pass between the block falling and rising again    set sm_GN_afterdelay to 0.3 ;seconds that need to pass after a full sequence before it can play again


Also, I've added stone-grinding sound effects to the fall and rise events. If you don't like them, let me know and I'll remove them from the code.


So here's the whole hulking thing:

begin sm_GN_Falmer_PitBlock_Scriptshort statefloat sm_GN_startposfloat sm_GN_lowposfloat sm_GN_fallspeedfloat sm_GN_risespeedfloat sm_GN_predelayfloat sm_GN_delayfloat sm_GN_afterdelayfloat sm_GN_tempfloat sm_GN_tempbfloat sm_GN_baserotationfloat sm_GN_rotatestateif ( MenuMode == 1 )    returnendifif ( state == 0 )    set sm_GN_startpos to GetPos, Z    set sm_GN_lowpos to sm_GN_startpos - 300 ;by adjusting this number you can set how many units the block moves downwards    set sm_GN_fallspeed to -1500 ;this adjusts the falling speed of the block (units per second)    set sm_GN_risespeed to 180 ;this adjusts the rising speed of the block (units per second)    set sm_GN_predelay to 0.1 ;seconds that need to pass between the actor stepping on the block and it starting falling    set sm_GN_delay to 2 ;seconds that need to pass between the block falling and rising again    set sm_GN_afterdelay to 0.3 ;seconds that need to pass after a full sequence before it can play again    set sm_GN_baserotation to GetAngle, Z    set sm_GN_rotatestate to 0.001    set state to 1endifif ( CellChanged == 1 )    set state to -1endif    if ( state == -1 )    SetPos, Z, sm_GN_startpos    SetAngle, Z, sm_GN_baserotation    set state to 1elseif ( state == 1 )    if ( GetStandingActor == 1 )        set state to 2    endifelseif ( state == 2 )    set sm_GN_temp to sm_GN_temp + GetSecondsPassed    if ( sm_GN_temp >= sm_GN_predelay )        set sm_GN_temp to 0        set state to 3        PlaySound3D, "Stone Door Open 1"    endifelseif ( state == 3 )    set sm_GN_temp to GetSecondsPassed    set sm_GN_temp to sm_GN_temp * sm_GN_fallspeed    set sm_GN_tempb to GetPos, Z    set sm_GN_tempb to sm_GN_tempb + sm_GN_temp    if ( sm_GN_tempb <= sm_GN_lowpos )        set sm_GN_tempb to sm_GN_lowpos        set sm_GN_temp to 0        set state to 4        StopSound, "Stone Door Open 1"    endif    SetPos, Z, sm_GN_tempb    Disable    Enable    Rotate, Z, sm_GN_rotatestate    set sm_GN_rotatestate to sm_GN_rotatestate * -1elseif ( state == 4 )    set sm_GN_temp to sm_GN_temp + GetSecondsPassed    if ( sm_GN_temp >= sm_GN_delay )        set sm_GN_temp to 0        set state to 5        PlaySound3D, "Stone Door Open 1"    endifelseif ( state == 5 )    set sm_GN_temp to GetSecondsPassed    set sm_GN_temp to sm_GN_temp * sm_GN_risespeed    set sm_GN_tempb to GetPos, Z    set sm_GN_tempb to sm_GN_tempb + sm_GN_temp    if ( sm_GN_tempb >= sm_GN_startpos )        set sm_GN_tempb to sm_GN_startpos        set sm_GN_temp to 0        set state to 6        StopSound, "Stone Door Open 1"    endif    SetPos, Z, sm_GN_tempb    Disable    Enable    Rotate, Z, sm_GN_rotatestate    set sm_GN_rotatestate to sm_GN_rotatestate * -1elseif ( state == 6 )    set sm_GN_temp to sm_GN_temp + GetSecondsPassed    if ( sm_GN_temp >= sm_GN_afterdelay )        set sm_GN_temp to 0        set state to 1    endifendifend

User avatar
clelia vega
 
Posts: 3433
Joined: Wed Mar 21, 2007 6:04 pm

Post » Thu Dec 24, 2009 1:52 am

That is great!!! Works perfectly! The settings will need tweaking to my tastes, but other than that its great!

Thank you for sorting this Adul - finally Forgottenhalls is one step closer to being finished!!!! (Yay) :celebration:
User avatar
Andres Lechuga
 
Posts: 3406
Joined: Sun Aug 12, 2007 8:47 pm

Post » Thu Dec 24, 2009 10:50 am

Sure thing, I'm glad to have been able to help. :)

Looking forward to this awesome mod.
User avatar
Lindsay Dunn
 
Posts: 3247
Joined: Sun Sep 10, 2006 9:34 am

Post » Wed Dec 23, 2009 8:18 pm

Sure thing, I'm glad to have been able to help. :)

Looking forward to this awesome mod.

:) - keep your eye out for the Forgottenhalls ;)
User avatar
Nicole Mark
 
Posts: 3384
Joined: Wed Apr 25, 2007 7:33 pm

Post » Thu Dec 24, 2009 7:50 am

I've been meaning to ask you about those scripts - I have given up that mod i pm'd you about ;) - proved to over my head lol. Though some falmer spells would be nice ... hint hint ;)

:D


If that's an invitation, I might just be available to be of service. ^_^
User avatar
Jade
 
Posts: 3520
Joined: Mon Jul 10, 2006 6:42 am


Return to III - Morrowind